[PATCH] D33145: Clear output section from linker script command when it's removed.

Mikulin, Dmitry via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 16:37:53 PDT 2017


> On May 17, 2017, at 9:56 PM, Rafael Avila de Espindola <rafael.espindola at gmail.com> wrote:
> 
> Dmitry Mikulin via Phabricator <reviews at reviews.llvm.org> writes:
> 
>> Index: ELF/LinkerScript.cpp
>> ===================================================================
>> --- ELF/LinkerScript.cpp
>> +++ ELF/LinkerScript.cpp
>> @@ -687,22 +687,20 @@
>>   // '.' is assigned to, but creating these section should not have any bad
>>   // consequeces and gives us a section to put the symbol in.
>>   uint64_t Flags = SHF_ALLOC;
>> -  uint32_t Type = SHT_PROGBITS;
>> 
>>   for (int I = 0, E = Opt.Commands.size(); I != E; ++I) {
>>     auto *Cmd = dyn_cast<OutputSectionCommand>(Opt.Commands[I]);
>>     if (!Cmd)
>>       continue;
>>     if (OutputSection *Sec = Cmd->Sec) {
>>       Flags = Sec->Flags;
>> -      Type = Sec->Type;
>>       continue;
>>     }
>> 
>>     if (isAllSectionDescription(*Cmd))
>>       continue;
>> 
>> -    auto *OutSec = make<OutputSection>(Cmd->Name, Type, Flags);
>> +    auto *OutSec = make<OutputSection>(Cmd->Name, SHT_PROGBITS, Flags);
>>     OutSec->SectionIndex = I;
>>     OutputSections->push_back(OutSec);
>>     Cmd->Sec = OutSec;
> 
> I think that the change to LinkerScript.cpp is all that you need, no?
> 
> With that the created sections are never SHT_REL or SHT_RELA.

I’d still keep the change in Writer.cpp. For the sake of consistency we shouldn’t reference output sections, which have effectively been deleted from the output, in script commands. Here we’d be propagating their flags even though they are not in the output.

> 
> Cheers,
> Rafael



More information about the llvm-commits mailing list