Skip to content

[RuntimeDyld][ELF] Fix unwanted sign extension. #94482

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
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,8 +1183,7 @@ void RuntimeDyldELF::resolveAArch64Branch(unsigned SectionID,
StubMap::const_iterator i = Stubs.find(Value);
if (i != Stubs.end()) {
resolveRelocation(Section, Offset,
(uint64_t)Section.getAddressWithOffset(i->second),
RelType, 0);
Section.getLoadAddressWithOffset(i->second), RelType, 0);
LLVM_DEBUG(dbgs() << " Stub function found\n");
} else if (!resolveAArch64ShortBranch(SectionID, RelI, Value)) {
// Create a new stub function.
Expand Down Expand Up @@ -1217,8 +1216,7 @@ void RuntimeDyldELF::resolveAArch64Branch(unsigned SectionID,
addRelocationForSection(REmovk_g0, Value.SectionID);
}
resolveRelocation(Section, Offset,
reinterpret_cast<uint64_t>(Section.getAddressWithOffset(
Section.getStubOffset())),
Section.getLoadAddressWithOffset(Section.getStubOffset()),
RelType, 0);
Section.advanceStubOffset(getMaxStubSize());
}
Expand Down Expand Up @@ -1349,10 +1347,9 @@ RuntimeDyldELF::processRelocationRef(
// Look for an existing stub.
StubMap::const_iterator i = Stubs.find(Value);
if (i != Stubs.end()) {
resolveRelocation(
Section, Offset,
reinterpret_cast<uint64_t>(Section.getAddressWithOffset(i->second)),
RelType, 0);
resolveRelocation(Section, Offset,
Section.getLoadAddressWithOffset(i->second), RelType,
0);
LLVM_DEBUG(dbgs() << " Stub function found\n");
} else {
// Create a new stub function.
Expand All @@ -1367,10 +1364,10 @@ RuntimeDyldELF::processRelocationRef(
else
addRelocationForSection(RE, Value.SectionID);

resolveRelocation(Section, Offset, reinterpret_cast<uint64_t>(
Section.getAddressWithOffset(
Section.getStubOffset())),
RelType, 0);
resolveRelocation(
Section, Offset,
Section.getLoadAddressWithOffset(Section.getStubOffset()), RelType,
0);
Section.advanceStubOffset(getMaxStubSize());
}
} else {
Expand Down Expand Up @@ -1609,8 +1606,7 @@ RuntimeDyldELF::processRelocationRef(
if (i != Stubs.end()) {
// Symbol function stub already created, just relocate to it
resolveRelocation(Section, Offset,
reinterpret_cast<uint64_t>(
Section.getAddressWithOffset(i->second)),
Section.getLoadAddressWithOffset(i->second),
RelType, 0);
LLVM_DEBUG(dbgs() << " Stub function found\n");
} else {
Expand Down Expand Up @@ -1652,10 +1648,10 @@ RuntimeDyldELF::processRelocationRef(
addRelocationForSection(REl, Value.SectionID);
}

resolveRelocation(Section, Offset, reinterpret_cast<uint64_t>(
Section.getAddressWithOffset(
Section.getStubOffset())),
RelType, 0);
resolveRelocation(
Section, Offset,
Section.getLoadAddressWithOffset(Section.getStubOffset()),
RelType, 0);
Section.advanceStubOffset(getMaxStubSize());
}
if (IsExtern || (AbiVariant == 2 && Value.SectionID != SectionID)) {
Expand Down
Loading