Page MenuHomeFreeBSD

Merge commit 894f742acb from llvm git (by me):
ClosedPublic

Authored by arichardson on Jan 16 2020, 10:39 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 22, 9:36 PM
Unknown Object (File)
Jan 16 2024, 3:39 PM
Unknown Object (File)
Jan 5 2024, 11:41 AM
Unknown Object (File)
Jan 5 2024, 11:41 AM
Unknown Object (File)
Jan 5 2024, 11:33 AM
Unknown Object (File)
Jan 5 2024, 11:09 AM
Unknown Object (File)
Dec 20 2023, 2:23 AM
Unknown Object (File)
Dec 18 2023, 2:14 PM
Subscribers

Details

Summary
[MIPS][ELF] Use PC-relative relocations in .eh_frame when possible

When compiling position-independent executables, we now use
DW_EH_PE_pcrel | DW_EH_PE_sdata4. However, the MIPS ABI does not define a
64-bit PC-relative ELF relocation so we cannot use sdata8 for the large
code model case. When using the large code model, we fall back to the
previous behaviour of generating absolute relocations.

With this change clang-generated .o files can be linked by LLD without
having to pass -Wl,-z,notext (which creates text relocations).
This is simpler than the approach used by ld.bfd, which rewrites the
.eh_frame section to convert absolute relocations into relative references.

I saw in D13104 that apparently ld.bfd did not accept pc-relative relocations
for MIPS ouput at some point. However, I also checked that recent ld.bfd
can process the clang-generated .o files so this no longer seems true.

Reviewed By: atanasyan
Differential Revision: https://reviews.llvm.org/D72228

Merge commit 8e8ccf47 from llvm git (by me)

[MIPS] Don't emit R_(MICRO)MIPS_JALR relocations against data symbols

The R_(MICRO)MIPS_JALR optimization only works when used against functions.
Using the relocation against a data symbol (e.g. function pointer) will
cause some linkers that don't ignore the hint in this case (e.g. LLD prior
to commit 5bab291) to generate a relative branch to the data symbol
which crashes at run time. Before this patch, LLVM was erroneously emitting
these relocations against local-dynamic TLS function pointers and global
function pointers with internal visibility.

Reviewers: atanasyan, jrtc27, vstefanovic
Reviewed By: atanasyan
Differential Revision: https://reviews.llvm.org/D72571

These two changes should allow using lld for MIPS64 (and maybe also MIPS32)
by default.
The second commit is not strictly necessary for clang+lld since LLD9 will
not perform the R_MIPS_JALR optimization (it was only added for 10) but it
is probably required in order to use recent ld.bfd.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I am not sure what the correct process is to merge upstream LLVM changes. Is it fine to just commit this diff or are any other steps required?

This is fine. Please make sure to add an MFC after: x line to your commit message, so that the MFC Reminder mails get triggered.

This revision is now accepted and ready to land.Jan 16 2020, 11:56 AM
This revision was automatically updated to reflect the committed changes.