[PATCH] D44622: [ELF] - Fix for "LLD crashes with --emit-relocs when trying to proccess .eh_frame"

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 19 16:51:21 PDT 2018


Domagoj Stolfa via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:

> dstolfa added a comment.
>
> In https://reviews.llvm.org/D44622#1042429, @espindola wrote:
>
>> The crash is from
>>
>>   // This is for --emit-relocs. If .text.foo is emitted as .text.bar, we want
>>   // to emit .rela.text.foo as .rela.text.bar for consistency (this is not
>>   // technically required, but not doing it is odd). This code guarantees that.
>>   if ((S->Type == SHT_REL || S->Type == SHT_RELA) &&
>>       !isa<SyntheticSection>(S)) {
>>     OutputSection *Out =
>>         cast<InputSection>(S)->getRelocatedSection()->getOutputSection();
>>   
>>
>> Where Out is null because we call this for the relocation section before .eh_frame. The caller is
>>
>>   std::vector<OutputSection *> V;
>>   for (InputSectionBase *S : InputSections) {
>>     if (!S->Live || S->Parent)
>>       continue;
>>   
>>     StringRef Name = getOutputSectionName(S);
>>   
>>
>> So this suggests two options that might be simpler.
>>
>> - Just handle Out being null. We are just trying to get a better looking output section name. It is not critical.
>> - Do two passes over the input section in LinkerScript::addOrphanSections.
>
>
> This is the approach I've taken in https://reviews.llvm.org/D44601 (though it was still a workaround at that point). @arichardson pointed out that we should probably have an output similar to ld.bfd and gold, so I suppose the fix should be guided by that as well as where it would be best to handle this case?

Instead of returning "" it could return S->Name and that would handle
all real world cases I think.

I think doing two passes in LinkerScript::addOrphanSections might be the
best solution as it is simple and handles even synthetic tests like using
a linker script to assign .eh_frame to an output section with a
different name.

Cheers,
Rafael


More information about the llvm-commits mailing list