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] Add GOT builder and implement R_ARM_GOT_PREL relocations for ELF #78753

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

weliveindetail
Copy link
Contributor

LLJIT needs this relocation for running deinitializers even if we stick to -fno-pic code otherwise. I summarized the logic of R_ARM_GOT_PREL in this gist based on a test in LLD: https://gist.github.com/weliveindetail/6dd33d43ea743d6e8a7399d1950c77b7

Copy link

github-actions bot commented Jan 19, 2024

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

# The +12 accounts for the ARM branch offset (8) and the .LPC offset (4), which
# is stored as initial addend inline.
# FIXME: We shouldn't need to substract the 64-bit sign-extension manually.
# jitlink-check: *{4}got_prel_offset = got_addr(out.o, target) - (got_prel + 12) - 0xffffffff00000000
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 offset is a signed 32-bit value and it doesn't get sign-extended to JITLink's 64-bit target address type. We should probably fix that, but it seems outside the scope of this PR.

@weliveindetail
Copy link
Contributor Author

This patch implements a new relocation type and it's pretty straightforward. All new code is in JITLink AArch32 and exercised in a test that I adapted from an existing test in LLD. The pre-merge build failed due to MLIR test failures on Windows that are unrelated. The JITLink built went well and tests passed on both platforms.

I have some more patches based on this and I want to land them before release/18.x branches. If there are any questions about the code here, I am happy to discuss post-commit.

@weliveindetail weliveindetail merged commit c4fc563 into llvm:main Jan 22, 2024
3 of 4 checks passed
@weliveindetail weliveindetail deleted the jitlink-aarch32-got-prel branch January 22, 2024 11:00
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

1 participant