diff options
author | Mike Pall <mike> | 2021-03-31 18:36:44 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2021-03-31 18:36:44 +0200 |
commit | 20f556e53190ab9a735b932f5d868d45ec536a70 (patch) | |
tree | 76eadb0310ec75132a016a246168f154494c6650 /dynasm/dasm_mips.h | |
parent | d1132afb25e2ba66d5d4c287b886a3c0a61bd9db (diff) | |
download | luajit-20f556e53190ab9a735b932f5d868d45ec536a70.tar.gz luajit-20f556e53190ab9a735b932f5d868d45ec536a70.tar.bz2 luajit-20f556e53190ab9a735b932f5d868d45ec536a70.zip |
DynASM: Fix global label references
ARM64 patch contributed by Hao Sun and Nick Gasson.
Diffstat (limited to 'dynasm/dasm_mips.h')
-rw-r--r-- | dynasm/dasm_mips.h | 7 |
1 files changed, 5 insertions, 2 deletions
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); |