Skip to content

Conversation

@stmonty
Copy link

@stmonty stmonty commented Apr 14, 2025

Hello! This is my first contribution attempt here. I have been working with on jank which uses the Orcv2 machinery for the JIT compilation. I think @lhames might know about this.

One problem we have encountered was that when the Jank binary was fully statically built no symbols were able to be found. This PR ties to remedy that for ELF binaries by opening the current binary and using the symtab portion of the ELF binary to find missing symbols.

Any comments for improvements are greatly appreciated!

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@lhames
Copy link
Contributor

lhames commented May 11, 2025

Hi @stmonty,

The usual way to make such symbols available is to dynamically export them by using -Wl,-export-dynamic, or --export-dynamic-symbol-list.

By using the dynamic symbol table rather than the static table, ORC and dlfcn.h will agree on the set of symbols exported from precompiled code. It also means that you can run strip on your binary to reduce the size without affecting symbol lookup in the JIT.

@stmonty
Copy link
Author

stmonty commented May 28, 2025

@lhames Thanks for the response! If I am understanding correctly, you are saying this generator is unnecessary as the correct way to handle this case would be to just export the symbols into the dynamic symbol table and just use the already existing ORC functionality?

@lhames
Copy link
Contributor

lhames commented May 29, 2025

@lhames Thanks for the response! If I am understanding correctly, you are saying this generator is unnecessary as the correct way to handle this case would be to just export the symbols into the dynamic symbol table and just use the already existing ORC functionality?

Yep, that's the best way to handle this. :)

@MaskRay
Copy link
Member

MaskRay commented May 29, 2025

Agreed. Should just use .dynsym , which cannot be stripped by llvm-strip/GNU strip.
(Additionally, /proc/self/exe works on Linux but probably not other ELF OSes)

@lhames lhames closed this May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants