Skip to content

llvm-jitlink: Fix bug in target address computation. #138794

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

Open
wants to merge 2 commits into
base: users/pcc/spr/main.llvm-jitlink-fix-bug-in-target-address-computation
Choose a base branch
from

Conversation

pcc
Copy link
Contributor

@pcc pcc commented May 7, 2025

llvm-jitlink has a bug revealed by my followup change where the
RuntimeDyldChecker::MemoryRegionInfo::TargetAddress field was
incorrectly being set to the address of the first symbol in the
section instead of the address of the section, which caused the
ExecutionEngine/JITLink/x86-64/ELF_small_pic_relocations.s test to
fail, so fix that for ELF. It looks like the same bug could exist for
the other object formats (but maybe not for Mach-O because of the atom
model?) but I'm not familiar with the JIT linker so I left them as is.

This change will be tested implicitly when my followup change lands.

Created using spr 1.3.6-beta.1
@pcc pcc requested review from lhames and MaskRay May 7, 2025 02:04
Copy link

github-actions bot commented May 7, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@pcc
Copy link
Contributor Author

pcc commented May 7, 2025

(#138795 is the followup change in question.)

Created using spr 1.3.6-beta.1
@@ -194,7 +194,8 @@ Error registerELFGraphInfo(Session &S, LinkGraph &G) {
else
FileInfo.SectionInfos[Sec.getName()] = {
ArrayRef<char>(FirstSym->getBlock().getContent().data(), SecSize),
SecAddr.getValue(), FirstSym->getTargetFlags()};
(SecAddr - FirstSym->getOffset()).getValue(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of setting this here, it seems like it'd be tidier to define SecAddr like this on line 183:

auto SecAddr = FirstSym->getAddress() - FirstSym->getOffset();

Unless you've already tried that and hit other issues I'm happy to go ahead and make that change.

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.

2 participants