This is an archive of the discontinued LLVM Phabricator instance.

[MIPS] Mark .eh_frame as writable for PIC output
AbandonedPublic

Authored by arichardson on Feb 12 2018, 6:03 AM.

Details

Summary

This is needed since we have a R_MIPS_64 relocation that needs to be
processed at runtime. This allows running LLD without -z notext.

Diff Detail

Event Timeline

arichardson created this revision.Feb 12 2018, 6:03 AM
joerg requested changes to this revision.Feb 12 2018, 6:16 AM
joerg added a subscriber: joerg.

This is not acceptable. If anything, the encoding should be switched to indirect, but that should already be the case.

This revision now requires changes to proceed.Feb 12 2018, 6:16 AM

The way it is currently it is emitting dynamic relocations into the .text segment. This needs -Wl,-z,notext with LLD but for BFD it will just emit those relocations anyway and (probably) crash at runtime.
At least now we are explicit that it requires a writable section (which will be in the relro section if you are using LLD).

I wonder if the following is the reason that we are emitting an absolute relocation for MIPS:

// We don't support PC-relative LSDA references in GAS so we use the default
// DW_EH_PE_absptr for those.

Probably we need to implement something like _bfd_elf_eh_frame_section_offset from BFD library to convert absolute relocations into relative ones.

BTW look at https://reviews.llvm.org/D13104

arichardson abandoned this revision.Feb 12 2018, 7:17 AM

Since this is not the correct solution I'll just keep this in our fork.