diff options
| author | George Rimar <grimar@accesssoftek.com> | 2016-08-19 08:31:02 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2016-08-19 08:31:02 +0000 |
| commit | 11f83b7941ecc764441bf62d672fe279955ee0ca (patch) | |
| tree | 857596e2ebfb34b97cd7a9640e2df21281777b34 | |
| parent | 8fa30f2829ddbcc5d31b6e810ae3b270acc8c971 (diff) | |
| download | bcm5719-llvm-11f83b7941ecc764441bf62d672fe279955ee0ca.tar.gz bcm5719-llvm-11f83b7941ecc764441bf62d672fe279955ee0ca.zip | |
[ELF] - Do not change binding of symbols when creating relocatable output.
Spec says "A hidden symbol contained in a relocatable object must be either
removed or converted to STB_LOCAL binding by the link-editor when the
relocatable object is included in an executable file or shared object".
But we previously converted symbols to STB_LOCAL even when -r was specified.
Broken binary was produced, this is PR28967, patch fixes the issue.
Differential revision: https://reviews.llvm.org/D23514
llvm-svn: 279220
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 2 | ||||
| -rw-r--r-- | lld/test/ELF/relocatable-visibility.s | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 139e67505c7..972457ae43a 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -1316,6 +1316,8 @@ static bool sortMipsSymbols(const std::pair<SymbolBody *, unsigned> &L, static uint8_t getSymbolBinding(SymbolBody *Body) { Symbol *S = Body->symbol(); + if (Config->Relocatable) + return S->Binding; uint8_t Visibility = S->Visibility; if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED) return STB_LOCAL; diff --git a/lld/test/ELF/relocatable-visibility.s b/lld/test/ELF/relocatable-visibility.s new file mode 100644 index 00000000000..7cc7da3097b --- /dev/null +++ b/lld/test/ELF/relocatable-visibility.s @@ -0,0 +1,19 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld -r %t.o -o %t1 +# RUN: llvm-readobj -t %t1 | FileCheck --check-prefix=RELOCATABLE %s + +# RELOCATABLE: Name: foo +# RELOCATABLE-NEXT: Value: 0x0 +# RELOCATABLE-NEXT: Size: 0 +# RELOCATABLE-NEXT: Binding: Global +# RELOCATABLE-NEXT: Type: None +# RELOCATABLE-NEXT: Other [ +# RELOCATABLE-NEXT: STV_HIDDEN +# RELOCATABLE-NEXT: ] +# RELOCATABLE-NEXT: Section: Undefined + +.global _start +_start: + callq foo + .hidden foo |

