[PATCH] D38239: [ELF] - Define linkerscript symbols early.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 23 02:02:11 PST 2017


>> Index: ELF/Driver.cpp
>> ===================================================================
>> --- ELF/Driver.cpp
>> +++ ELF/Driver.cpp
>> @@ -1029,6 +1029,9 @@
>>    for (StringRef Sym : Script->ReferencedSymbols)
>>      Symtab->addUndefined<ELFT>(Sym);
>>
>> +  // We want to declare linker script's symbols early, so that can version them.
>> +  Script->declareSymbols();
>> +
>>    // Handle the `--undefined <sym>` options.
>>    for (StringRef S : Config->Undefined)
>>      Symtab->fetchIfLazy<ELFT>(S);
>
>Do you need it this early? It should probably be after the fetchIfLazy
>calls since those can add .o files, no?
>
>Cheers,
>Rafael

No need to do that this early.

I think you right, if we have script that sets foo = 0x1; and archive with foo and bar,
then with -u bar, both could be fetched from archive, though we set foo from script.
At the same time currently script would replace the values silently at later steps anyways.
So l do not know how to add testcase for that atm. 

I think we could test it properly if change --defsym behavior like D41438 suggests, so that early
fetching would cause duplicate definition error. 
I'll update patch to move that piece after fetchIfLazy for now.

George.


More information about the llvm-commits mailing list