aboutsummaryrefslogtreecommitdiff
path: root/dynasm
diff options
context:
space:
mode:
Diffstat (limited to 'dynasm')
-rw-r--r--dynasm/dasm_arm.h7
-rw-r--r--dynasm/dasm_arm64.h7
-rw-r--r--dynasm/dasm_mips.h7
-rw-r--r--dynasm/dasm_ppc.h7
4 files changed, 20 insertions, 8 deletions
diff --git a/dynasm/dasm_arm.h b/dynasm/dasm_arm.h
index a7295663..ebcf4ac0 100644
--- a/dynasm/dasm_arm.h
+++ b/dynasm/dasm_arm.h
@@ -294,7 +294,7 @@ int dasm_link(Dst_DECL, size_t *szp)
294 294
295 { /* Handle globals not defined in this translation unit. */ 295 { /* Handle globals not defined in this translation unit. */
296 int idx; 296 int idx;
297 for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { 297 for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
298 int n = D->lglabels[idx]; 298 int n = D->lglabels[idx];
299 /* Undefined label: Collapse rel chain and replace with marker (< 0). */ 299 /* Undefined label: Collapse rel chain and replace with marker (< 0). */
300 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } 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 ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000; 371 ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000;
372 break; 372 break;
373 case DASM_REL_LG: 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 /* fallthrough */ 378 /* fallthrough */
376 case DASM_REL_PC: 379 case DASM_REL_PC:
377 CK(n >= 0, UNDEF_PC); 380 CK(n >= 0, UNDEF_PC);
diff --git a/dynasm/dasm_arm64.h b/dynasm/dasm_arm64.h
index b2251532..5ff4414c 100644
--- a/dynasm/dasm_arm64.h
+++ b/dynasm/dasm_arm64.h
@@ -354,7 +354,7 @@ int dasm_link(Dst_DECL, size_t *szp)
354 354
355 { /* Handle globals not defined in this translation unit. */ 355 { /* Handle globals not defined in this translation unit. */
356 int idx; 356 int idx;
357 for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { 357 for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
358 int n = D->lglabels[idx]; 358 int n = D->lglabels[idx];
359 /* Undefined label: Collapse rel chain and replace with marker (< 0). */ 359 /* Undefined label: Collapse rel chain and replace with marker (< 0). */
360 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } 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 ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000; 432 ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000;
433 break; 433 break;
434 case DASM_REL_LG: 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 /* fallthrough */ 439 /* fallthrough */
437 case DASM_REL_PC: 440 case DASM_REL_PC:
438 CK(n >= 0, UNDEF_PC); 441 CK(n >= 0, UNDEF_PC);
diff --git a/dynasm/dasm_mips.h b/dynasm/dasm_mips.h
index 2fd7d71f..b99b56b0 100644
--- a/dynasm/dasm_mips.h
+++ b/dynasm/dasm_mips.h
@@ -273,7 +273,7 @@ int dasm_link(Dst_DECL, size_t *szp)
273 273
274 { /* Handle globals not defined in this translation unit. */ 274 { /* Handle globals not defined in this translation unit. */
275 int idx; 275 int idx;
276 for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { 276 for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
277 int n = D->lglabels[idx]; 277 int n = D->lglabels[idx];
278 /* Undefined label: Collapse rel chain and replace with marker (< 0). */ 278 /* Undefined label: Collapse rel chain and replace with marker (< 0). */
279 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } 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 ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000; 349 ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000;
350 break; 350 break;
351 case DASM_REL_LG: 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 /* fallthrough */ 356 /* fallthrough */
354 case DASM_REL_PC: 357 case DASM_REL_PC:
355 CK(n >= 0, UNDEF_PC); 358 CK(n >= 0, UNDEF_PC);
diff --git a/dynasm/dasm_ppc.h b/dynasm/dasm_ppc.h
index ae540e46..35264f2e 100644
--- a/dynasm/dasm_ppc.h
+++ b/dynasm/dasm_ppc.h
@@ -277,7 +277,7 @@ int dasm_link(Dst_DECL, size_t *szp)
277 277
278 { /* Handle globals not defined in this translation unit. */ 278 { /* Handle globals not defined in this translation unit. */
279 int idx; 279 int idx;
280 for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) { 280 for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
281 int n = D->lglabels[idx]; 281 int n = D->lglabels[idx];
282 /* Undefined label: Collapse rel chain and replace with marker (< 0). */ 282 /* Undefined label: Collapse rel chain and replace with marker (< 0). */
283 while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; } 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 ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000; 353 ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000;
354 break; 354 break;
355 case DASM_REL_LG: 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 /* fallthrough */ 360 /* fallthrough */
358 case DASM_REL_PC: 361 case DASM_REL_PC:
359 CK(n >= 0, UNDEF_PC); 362 CK(n >= 0, UNDEF_PC);