Skip to content

Add -Bsymbolic link option to avoid symbol interposition #432

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

Conversation

BewareMyPower
Copy link
Contributor

Motivation

There is a case that libpulsar.so could unexpectedly call functions from other dependencies.

For example, assuming the application depends on two libraries:

  • libpulsar.so, which includes the symbols from libcurl.a 8.4.0
  • libfoo.so, which includes the symbols from libcurl.a 7.82.0

If the link order is libfoo.so first, then the libcurl definitions from 7.82.0 will also be used by libpulsar.so and then the application might crash due to the incompatibility. This is an issue specifically with Linux ELF format.

Modifications

Add the -Wl,-Bsymbolic link option for GCC.

@BewareMyPower
Copy link
Contributor Author

You can also see https://github.com/BewareMyPower/symbol-interposition for the symbol interposition issue.

@BewareMyPower BewareMyPower self-assigned this Jul 3, 2024
@BewareMyPower BewareMyPower added the enhancement New feature or request label Jul 3, 2024
@BewareMyPower BewareMyPower added this to the 3.6.0 milestone Jul 3, 2024
@BewareMyPower BewareMyPower merged commit d736a1b into apache:main Jul 4, 2024
15 checks passed
@BewareMyPower BewareMyPower deleted the bewaremypower/elf-symbolic branch July 4, 2024 01:52
BewareMyPower added a commit to streamnative/pulsar-client-cpp that referenced this pull request Jul 4, 2024
### Motivation

There is a case that `libpulsar.so` could unexpectedly call functions from other dependencies.

For example, assuming the application depends on two libraries:
- `libpulsar.so`, which includes the symbols from `libcurl.a` 8.4.0
- `libfoo.so`, which includes the symbols from `libcurl.a` 7.82.0

If the link order is `libfoo.so` first, then the libcurl definitions from 7.82.0 will also be used by `libpulsar.so` and then the application might crash due to the incompatibility. This is an issue specifically with Linux ELF format.

### Modifications

Add the `-Wl,-Bsymbolic` link option for GCC.

(cherry picked from commit d736a1b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants