diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-10-30 17:26:12 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-10-30 17:26:12 +0000 |
| commit | 566dbdc2fda38f69f325c7cfcee3c52caf793a85 (patch) | |
| tree | d6530ff5da63d35672482e8355d88da8316db7b5 | |
| parent | 194693e996f98a52a37e957e3ef59e7b4078fa89 (diff) | |
| download | bcm5719-llvm-566dbdc2fda38f69f325c7cfcee3c52caf793a85.tar.gz bcm5719-llvm-566dbdc2fda38f69f325c7cfcee3c52caf793a85.zip | |
Skip abs symbols when handling copy reloc aliases.
Since we now only check st_value, we have to consider the case where
the section index is special.
llvm-svn: 316928
| -rw-r--r-- | lld/ELF/Relocations.cpp | 3 | ||||
| -rw-r--r-- | lld/test/ELF/Inputs/copy-rel-abs.s | 13 | ||||
| -rw-r--r-- | lld/test/ELF/copy-rel-abs.s | 47 |
3 files changed, 62 insertions, 1 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 92bd9bca4df..31ff4fe9d2d 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -469,7 +469,8 @@ static std::vector<SharedSymbol *> getSymbolsAt(SharedSymbol *SS) { std::vector<SharedSymbol *> Ret; for (const Elf_Sym &S : File->getGlobalELFSyms()) { - if (S.st_shndx == 0 || S.st_value != SS->Value) + if (S.st_shndx == SHN_UNDEF || S.st_shndx == SHN_ABS || + S.st_value != SS->Value) continue; StringRef Name = check(S.getName(File->getStringTable())); SymbolBody *Sym = Symtab->find(Name); diff --git a/lld/test/ELF/Inputs/copy-rel-abs.s b/lld/test/ELF/Inputs/copy-rel-abs.s new file mode 100644 index 00000000000..66d08807b9c --- /dev/null +++ b/lld/test/ELF/Inputs/copy-rel-abs.s @@ -0,0 +1,13 @@ + .global foo + .type foo, @object + .size foo, 4 +foo: + .weak bar + .type bar, @object + .size bar, 4 +bar: + .long 42 + + .weak zed + .type zed, @object + zed = 0x1000 diff --git a/lld/test/ELF/copy-rel-abs.s b/lld/test/ELF/copy-rel-abs.s new file mode 100644 index 00000000000..37a2c432381 --- /dev/null +++ b/lld/test/ELF/copy-rel-abs.s @@ -0,0 +1,47 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/copy-rel-abs.s -o %t1.o +// RUN: ld.lld --hash-style=gnu -shared %t1.o -o %t1.so +// RUN: llvm-readelf --dyn-symbols %t1.so | FileCheck --check-prefix=SYMS %s + +// The symbols have the same st_value, but one is ABS. +// SYMS: 0000000000001000 {{.*}} 4 bar +// SYMS: 0000000000001000 {{.*}} 4 foo +// SYMS: 0000000000001000 {{.*}} ABS zed + +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o +// RUN: ld.lld %t2.o %t1.so -o %t2 +// RUN: llvm-readobj --dyn-symbols %t2 | FileCheck %s + +// CHECK: DynamicSymbols [ +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: +// CHECK-NEXT: Binding: +// CHECK-NEXT: Type: +// CHECK-NEXT: Other: +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: foo +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: +// CHECK-NEXT: Binding: +// CHECK-NEXT: Type: +// CHECK-NEXT: Other: +// CHECK-NEXT: Section: .bss.rel.ro +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: bar +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: +// CHECK-NEXT: Binding: +// CHECK-NEXT: Type: +// CHECK-NEXT: Other: +// CHECK-NEXT: Section: .bss.rel.ro +// CHECK-NEXT: } +// CHECK-NEXT: ] + +.global _start +_start: +.quad foo |

