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

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 18 18:26:23 PST 2017


George Rimar via Phabricator <reviews at reviews.llvm.org> writes:

> grimar added inline comments.
>
>
> ================
> Comment at: ELF/LinkerScript.cpp:175
> +    if (auto *Cmd = dyn_cast<SymbolAssignment>(Base)) {
> +      if (Cmd->IsDefsym)
> +        continue;
> ----------------
> smeenai wrote:
>> Why are defsym's handled differently than linker script assignments?
> Interesting. Initially I did that because investigated defsym.ll failture (error : duplicate symbol: bar2)
> with this patch. I found different behavior of gold (and even observed its crash) and bfd, but now I see a error in my testcase.
> I retested and both of them have equal behavior and assign versions to defsym symbols.
> So I am going to update this patch tomorrow (will have to reinvestigate defsym.ll failture though)
>
> Interesting point that when following code and script are used:
> ```
> .global foo
> foo:
> ```
> ```
> VER1 { global: foo ; local: * ; } ;
> ```
>
> Then gold allows to redefine `foo`:
> ld.gold  --defsym=foo=2 --version-script version.txt -shared test.o -o test.so
>
> but bfd does not:
> ```
> ++ ld.bfd --defsym=foo=2 --version-script version.txt -shared test.o -o test.so
> test.o: In function `foo':
> (.text+0x0): multiple definition of `foo'
> ```
>
> LLD 6.0.0 (trunk 319747) also links it fine without errors.
> It looks like an issue of both gold and LLD for me.

Yes, producing a multiple definition error seems reasonable.

Cheers,
Rafael


More information about the llvm-commits mailing list