Skip to content
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

[JITLink][AArch32] Implement R_ARM_PREL31 and process .ARM.exidx sections #79044

Merged
merged 2 commits into from
Jan 23, 2024

Conversation

weliveindetail
Copy link
Contributor

R_ARM_PREL31 is a 31-bits relative data relocation where the most-significant bit is preserved. It's used primarily in .ARM.exidx sections, which we skipped processing until now, because we didn't support the relocation type. This was implemented in RuntimeDyld with https://reviews.llvm.org/D25069 and I implemented it in a similar way in JITLink in order to reach feature parity.

Copy link

github-actions bot commented Jan 22, 2024

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

@@ -397,6 +397,11 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySections() {
orc::ExecutorAddr(Sec.sh_addr),
Sec.sh_addralign, 0);

if (Sec.sh_type == ELF::SHT_ARM_EXIDX) {
// Add live symbol to avoid dead-stripping for .ARM.exidx sections
G->addAnonymousSymbol(*B, orc::ExecutorAddrDiff(), orc::ExecutorAddrDiff(), false, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The compiler emits a R_ARM_NONE relocation from an exception-handling table section to the required personality routine to indicate the dependence, but the edge alone doesn't keep the section alive in JITLink. We add the anonymous live symbol here to preserve it from dead-stripping.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's surprising -- any valid edge should keep the routine alive? Do we actually build an edge, or do we discard R_ARM_NONE relocations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIUC the issue is that here https://github.com/llvm/llvm-project/blob/release/17.x/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp#L271 we start from a set of live symbols and then follow edges and mark their target blocks live. Blocks without any symbols and only outgoing edges will remain dead.

I implemented R_ARM_NONE as no-op here 565470e. Not sure we could use it to mark the block live.

Copy link
Contributor

@lhames lhames left a comment

Choose a reason for hiding this comment

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

LGTM.

@weliveindetail weliveindetail merged commit 9577806 into llvm:main Jan 23, 2024
3 of 4 checks passed
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.

None yet

2 participants