Skip to content

[cherry-pick] [ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations #134

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 2 commits into from
May 5, 2022

Conversation

ayrtonm
Copy link

@ayrtonm ayrtonm commented Apr 15, 2022

This patch fixes the offsets of .rel[a].eh_frame relocations emitted by lld. That fixes catching panics for the mipsel-sony-psp target which defaults to lld and relies on -Wl,--emit-relocs emitting correct relocations. Catching panics is still broken for the PSP when gc-sections in on, but that requires further fixes in upstream lld.

I included a commit that refactored related tests to avoid manually fixing cherry-pick conflicts and cherry-picked only the final fix since my original fix was briefly reverted then reimplemented correctly. See the review for more details. https://reviews.llvm.org/D122459

cc @overdrivenpotato

MaskRay added 2 commits April 15, 2022 12:30
* Improve eh-frame-merge.s
* Delete invalid .eh_frame+5 test in ehframe-relocation.s
Two code paths may reach the EHFrame case in SectionBase::getOffset:

* .eh_frame reference
* relocation copy for --emit-relocs

The first may be used by clang_rt.crtbegin.o and GCC crtbeginT.o to get the
start address of the output .eh_frame. The relocation has an offset of 0 or
(x86-64 PC-relative leaq for clang_rt.crtbegin.o) -4. The current code just
returns `offset`, which handles this case well.

The second is related to InputSection::copyRelocations on .eh_frame (used by
--emit-relocs). .eh_frame pieces may be dropped due to GC/ICF, so we should
convert the input offset to the output offset. Use the same way as
MergeInputSection with a special case handling outSecOff==-1 for an invalid
piece (see eh-frame-marker.s).

This exposes an issue in mips64-eh-abs-reloc.s that we don't reliably
handle anyway. Just add --no-check-dynamic-relocations to paper over it.

Differential Revision: https://reviews.llvm.org/D122459
@nikic
Copy link

nikic commented Apr 22, 2022

Does this have/need a 14.0.x backport?

@ayrtonm
Copy link
Author

ayrtonm commented May 1, 2022

This doesn't have an upstream backport. I don't think it would benefit from one since the mipsel-sony-psp target requires a relatively recent version of rustc.

@nikic
Copy link

nikic commented May 5, 2022

I was mainly wondering because the change doesn't really look mipsel-sony-psp specific at a cursory glance. But if an upstream backport doesn't seem useful, let's just merge it here...

@nikic nikic merged commit 0004a38 into rust-lang:rustc/14.0-2022-03-22 May 5, 2022
vext01 pushed a commit to vext01/llvm-project that referenced this pull request Apr 19, 2024
Namespace enums in the serialiser.
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