File tree Expand file tree Collapse file tree 4 files changed +20
-8
lines changed Expand file tree Collapse file tree 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)
294294
295295 { /* Handle globals not defined in this translation unit. */
296296 int idx ;
297- for (idx = 20 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
297+ for (idx = 10 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
298298 int n = D -> lglabels [idx ];
299299 /* Undefined label: Collapse rel chain and replace with marker (< 0). */
300300 while (n > 0 ) { int * pb = DASM_POS2PTR (D , n ); n = * pb ; * pb = - idx ; }
@@ -371,7 +371,10 @@ int dasm_encode(Dst_DECL, void *buffer)
371371 ins &= 255 ; while ((((char * )cp - base ) & ins )) * cp ++ = 0xe1a00000 ;
372372 break ;
373373 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+ }
375378 /* fallthrough */
376379 case DASM_REL_PC :
377380 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)
354354
355355 { /* Handle globals not defined in this translation unit. */
356356 int idx ;
357- for (idx = 20 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
357+ for (idx = 10 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
358358 int n = D -> lglabels [idx ];
359359 /* Undefined label: Collapse rel chain and replace with marker (< 0). */
360360 while (n > 0 ) { int * pb = DASM_POS2PTR (D , n ); n = * pb ; * pb = - idx ; }
@@ -432,7 +432,10 @@ int dasm_encode(Dst_DECL, void *buffer)
432432 ins &= 255 ; while ((((char * )cp - base ) & ins )) * cp ++ = 0xe1a00000 ;
433433 break ;
434434 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+ }
436439 /* fallthrough */
437440 case DASM_REL_PC :
438441 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)
273273
274274 { /* Handle globals not defined in this translation unit. */
275275 int idx ;
276- for (idx = 20 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
276+ for (idx = 10 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
277277 int n = D -> lglabels [idx ];
278278 /* Undefined label: Collapse rel chain and replace with marker (< 0). */
279279 while (n > 0 ) { int * pb = DASM_POS2PTR (D , n ); n = * pb ; * pb = - idx ; }
@@ -349,7 +349,10 @@ int dasm_encode(Dst_DECL, void *buffer)
349349 ins &= 255 ; while ((((char * )cp - base ) & ins )) * cp ++ = 0x60000000 ;
350350 break ;
351351 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+ }
353356 /* fallthrough */
354357 case DASM_REL_PC :
355358 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)
277277
278278 { /* Handle globals not defined in this translation unit. */
279279 int idx ;
280- for (idx = 20 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
280+ for (idx = 10 ; idx * sizeof (int ) < D -> lgsize ; idx ++ ) {
281281 int n = D -> lglabels [idx ];
282282 /* Undefined label: Collapse rel chain and replace with marker (< 0). */
283283 while (n > 0 ) { int * pb = DASM_POS2PTR (D , n ); n = * pb ; * pb = - idx ; }
@@ -353,7 +353,10 @@ int dasm_encode(Dst_DECL, void *buffer)
353353 ins &= 255 ; while ((((char * )cp - base ) & ins )) * cp ++ = 0x60000000 ;
354354 break ;
355355 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+ }
357360 /* fallthrough */
358361 case DASM_REL_PC :
359362 CK (n >= 0 , UNDEF_PC );
You can’t perform that action at this time.
0 commit comments