File tree 4 files changed +20
-8
lines changed
4 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -294,7 +294,7 @@ int dasm_link(Dst_DECL, size_t *szp)
294
294
295
295
{ /* Handle globals not defined in this translation unit. */
296
296
int idx ;
297
- for (idx = 20 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
297
+ for (idx = 10 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
298
298
int n = D -> lglabels [idx ];
299
299
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
300
300
while (n > 0 ) { int * pb = DASM_POS2PTR (D , n ); n = * pb ; * pb = - idx ; }
@@ -371,7 +371,10 @@ int dasm_encode(Dst_DECL, void *buffer)
371
371
ins &= 255 ; while ((((char * )cp - base ) & ins )) * cp ++ = 0xe1a00000 ;
372
372
break ;
373
373
case DASM_REL_LG :
374
- CK (n >= 0 , UNDEF_LG );
374
+ if (n < 0 ) {
375
+ n = (int )((ptrdiff_t )D -> globals [- n ] - (ptrdiff_t )cp - 4 );
376
+ goto patchrel ;
377
+ }
375
378
/* fallthrough */
376
379
case DASM_REL_PC :
377
380
CK (n >= 0 , UNDEF_PC );
Original file line number Diff line number Diff line change @@ -354,7 +354,7 @@ int dasm_link(Dst_DECL, size_t *szp)
354
354
355
355
{ /* Handle globals not defined in this translation unit. */
356
356
int idx ;
357
- for (idx = 20 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
357
+ for (idx = 10 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
358
358
int n = D -> lglabels [idx ];
359
359
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
360
360
while (n > 0 ) { int * pb = DASM_POS2PTR (D , n ); n = * pb ; * pb = - idx ; }
@@ -432,7 +432,10 @@ int dasm_encode(Dst_DECL, void *buffer)
432
432
ins &= 255 ; while ((((char * )cp - base ) & ins )) * cp ++ = 0xe1a00000 ;
433
433
break ;
434
434
case DASM_REL_LG :
435
- CK (n >= 0 , UNDEF_LG );
435
+ if (n < 0 ) {
436
+ n = (int )((ptrdiff_t )D -> globals [- n ] - (ptrdiff_t )cp + 4 );
437
+ goto patchrel ;
438
+ }
436
439
/* fallthrough */
437
440
case DASM_REL_PC :
438
441
CK (n >= 0 , UNDEF_PC );
Original file line number Diff line number Diff line change @@ -273,7 +273,7 @@ int dasm_link(Dst_DECL, size_t *szp)
273
273
274
274
{ /* Handle globals not defined in this translation unit. */
275
275
int idx ;
276
- for (idx = 20 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
276
+ for (idx = 10 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
277
277
int n = D -> lglabels [idx ];
278
278
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
279
279
while (n > 0 ) { int * pb = DASM_POS2PTR (D , n ); n = * pb ; * pb = - idx ; }
@@ -349,7 +349,10 @@ int dasm_encode(Dst_DECL, void *buffer)
349
349
ins &= 255 ; while ((((char * )cp - base ) & ins )) * cp ++ = 0x60000000 ;
350
350
break ;
351
351
case DASM_REL_LG :
352
- CK (n >= 0 , UNDEF_LG );
352
+ if (n < 0 ) {
353
+ n = (int )((ptrdiff_t )D -> globals [- n ] - (ptrdiff_t )cp );
354
+ goto patchrel ;
355
+ }
353
356
/* fallthrough */
354
357
case DASM_REL_PC :
355
358
CK (n >= 0 , UNDEF_PC );
Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ int dasm_link(Dst_DECL, size_t *szp)
277
277
278
278
{ /* Handle globals not defined in this translation unit. */
279
279
int idx ;
280
- for (idx = 20 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
280
+ for (idx = 10 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
281
281
int n = D -> lglabels [idx ];
282
282
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
283
283
while (n > 0 ) { int * pb = DASM_POS2PTR (D , n ); n = * pb ; * pb = - idx ; }
@@ -353,7 +353,10 @@ int dasm_encode(Dst_DECL, void *buffer)
353
353
ins &= 255 ; while ((((char * )cp - base ) & ins )) * cp ++ = 0x60000000 ;
354
354
break ;
355
355
case DASM_REL_LG :
356
- CK (n >= 0 , UNDEF_LG );
356
+ if (n < 0 ) {
357
+ n = (int )((ptrdiff_t )D -> globals [- n ] - (ptrdiff_t )cp );
358
+ goto patchrel ;
359
+ }
357
360
/* fallthrough */
358
361
case DASM_REL_PC :
359
362
CK (n >= 0 , UNDEF_PC );
You can’t perform that action at this time.
0 commit comments