Skip to content

Commit f2706a8

Browse files
authored
JIT/AArch64: Fix an undefined symbol issue (#12687)
In AArch64 function `zend_jit_set_veneer()`, some debug code calls two other functions `ir_disasm_find_symbol()` and `ir_disasm_add_symbol()` defined in `ir_disasm.c`. However, `ir_disasm.c` is compiled under the condition that capstone is available. This causes an undefined symbol issue while loading `opcache.so` when JIT is triggered if PHP is built without `--with-capstone`. We find this issue on MacOS 12.5 if we build PHP with Clang 14. It does not appear immediately when using other versions of toolchains because of lazy binding. To reproduce this with Linux/GCC, we can disable lazy binding by `export LD_BIND_NOW=1` before building PHP. This fixes the issue by making the debug code conditionally compile.
1 parent ba204a2 commit f2706a8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ static bool zend_jit_set_veneer(ir_ctx *ctx, const void *addr, const void *venee
384384
if (zend_jit_stub_handlers[i] == addr) {
385385
const void **ptr = (const void**)&zend_jit_stub_handlers[count + i];
386386
*ptr = veneer;
387+
#ifdef HAVE_CAPSTONE
387388
if (JIT_G(debug) & ZEND_JIT_DEBUG_ASM) {
388389
const char *name = ir_disasm_find_symbol((uint64_t)(uintptr_t)addr, &offset);
389390

@@ -399,6 +400,7 @@ static bool zend_jit_set_veneer(ir_ctx *ctx, const void *addr, const void *venee
399400
}
400401
}
401402
}
403+
#endif
402404
return 1;
403405
}
404406
}

0 commit comments

Comments
 (0)