[lld] r265208 - [LTO] Fix symbols which were internalized incorrectly.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 13:00:47 PDT 2016


> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=265208&r1=265207&r2=265208&view=diff
> ==============================================================================
> --- lld/trunk/ELF/SymbolTable.cpp (original)
> +++ lld/trunk/ELF/SymbolTable.cpp Fri Apr  1 21:10:40 2016
> @@ -223,6 +223,7 @@ template <class ELFT> void SymbolTable<E
>      }
>      // Found a definition for something also in an archive.
>      // Ignore the archive definition.
> +    New->setUsedInRegularObj();

This is too conservative. It prevents internalizing in valid cases,
for example, given

test.ll:
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @foo() {
  ret void
}

and test2.ll
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @_start() {
  ret void
}

running

-------------------
llvm-as test.ll
llvm-as test2.ll
rm test.a
llvm-ar rc test.a test.bc

./build/bin/ld.lld -m elf_x86_64 test.a test.bc test2.bc -o t -save-temps
llvm-dis t.lto.bc  -o -

./build/bin/ld.lld -m elf_x86_64 test.bc test2.bc -o t -save-temps
llvm-dis t.lto.bc  -o -
-----------------

You will notice that the first case doesn't internalize foo and the
second one does. Both should internalize it.

Cheers,
Rafael


More information about the llvm-commits mailing list