[PATCH] D28612: [ELF] - Added support for --emit-relocs.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 04:01:11 PST 2017


>>    if (B.isSection())
>> -    return Config->Relocatable;
>> +    return Config->Relocatable || Config->EmitRelocs;
>
>You probably want a predicate for "Config->Relocatable ||
>Config->EmitRelocs" as it is used multiple times.

There are only 2 places in the code where they used together now.
Mostly checks are separate for each and isolated. Looks predicate is too much here.

>> +    // If we discard a section, we also should discard a relocation section
>> +    // connected, if any exist when --emit-relocs is specified.
>> +    ArrayRef<InputSectionBase<ELFT> *> Sections = S->getFile()->getSections();
>> +    for (InputSectionBase<ELFT> *IS : Sections) {
>> +      if (!IS || !IS->Live || (IS->Type != SHT_REL && IS->Type != SHT_RELA))
>> +        continue;
>> +      if (cast<InputSection<ELFT>>(IS)->getRelocatedSection() != S)
>> +        continue;
>> +      IS->Live = false;
>> +      reportDiscarded(IS);
>> +    }
>
>You can get the same problem with --gc-sections, so you should handle it
>in a more generic way as Rui pointed out.
>
>Cheers,
>Rafael

Will update patch in a minute.

George.


More information about the llvm-commits mailing list