Skip to content

JIT/AArch64: Fix an undefined symbol issue #12687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2023
Merged

Conversation

pfustc
Copy link
Contributor

@pfustc pfustc commented Nov 16, 2023

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.

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.
Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. Thanks!

@dstogov dstogov merged commit f2706a8 into php:master Nov 16, 2023
@pfustc pfustc deleted the undef_sym branch November 16, 2023 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants