Previously .eh_frame was always SHF_ALLOC and read-only. However, for
MIPS64 PIC code clang emits a R_MIPS_64 relocation that will be converted
to a dynamic relocation so .eh_frame can't be read-only in that case.
Since the input section has the SHF_WRITE flag set we were adding dynamic
relocations against even though the .eh_frame output section is read-only
without requiring -z notext.
Fix this by making .eh_frame writable if one of the input sections is has
the SHF_WRITE flag.
Details
- Reviewers
ruiu atanasyan grimar joerg • espindola
Diff Detail
- Repository
- rLLD LLVM Linker
- Build Status
Buildable 14854 Build 14854: arc lint + arc unit
Event Timeline
As I said in the D43185, probably we need to implement something like _bfd_elf_eh_frame_section_offset from BFD library to convert absolute relocations into relative ones and resolve them at the time of linking.
I agree that this is the correct way forward but this at least allows me to create non-broken .so files.
This patch prevents LLD from creating dynamic relocations against a read-only section without -z notext so I believe it is a valid bugfix and is independent of a .eh_frame format for MIPS that can be read-only.
Please stop adding complexity to doctor around the symptoms. There are two real fixes here and this change doesn't help with either:
(1) Emit cross-section pointers as indirect. This increases the binary size, but otherwise ensures that any linker can create read-only .eh_frame on MIPS.
(2) Teach lld on MIPS to properly reassemble the DWARF instructions, similar to what GNU ld can do. The latter is a bit stupid and needs a good kick to work properly, but this is the correct approach forward.