[PATCH] D42790: [ELF] Ensure that Elf_Rela addends are always written with -r

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 13:19:06 PST 2018


Simon Atanasyan via Phabricator <reviews at reviews.llvm.org> writes:

> atanasyan added a comment.
>
> In https://reviews.llvm.org/D42790#994808, @grimar wrote:
>
>> In https://reviews.llvm.org/D42790#994774, @arichardson wrote:
>>
>> > I originally discovered this issue because in our CHERI fork of LLD we set `Config->IsRela = false` when linking  MIPS64 code. We do this because the FreeBSD MIPS rtld only understands Elf_Rel relocations and does not process Elf_Rela.
>>
>>
>> It sounds like FreeBSD MIPS rtld bug honestly and probably should be fixed on their side.
>
>
> MIPS O32 ABI uses the Elf_Rel format in object files, while N32 and N64 ABIs uses the Elf_Rela. But originally in case of all ABIs output relocations in executable files and DSO are written in the Elf_Rel format. I think the goal was to reduce a file size. In case of embedded systems with small amount of memory it can be a benefit. Maybe there are some other reasons. When I implement MIPS LLD backend I used  the same format for input and output files, i.e. Elf_Rel for O32 ABI and Elf_Rela for N32 and N64 ABIs. It works for Linux because the dynamic linker accepts all formats. It looks like FreeBSD linker is more stricter.

Would it make sense to change lld to produce Elf_Rel for all the mips
abis then?

Cheers,
Rafael


More information about the llvm-commits mailing list