summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Leviant <evgeny.leviant@gmail.com>2016-07-14 08:26:41 +0000
committerEugene Leviant <evgeny.leviant@gmail.com>2016-07-14 08:26:41 +0000
commit219d9b2b18f8cc1dbdd69719600efc144ff8e4a1 (patch)
tree4bf94246b9db3069da5dfab3b92f12e48513b75c
parent38c2cd0c14993e4dc30f84dc7489b49e5f1ac3c5 (diff)
downloadbcm5719-llvm-219d9b2b18f8cc1dbdd69719600efc144ff8e4a1.tar.gz
bcm5719-llvm-219d9b2b18f8cc1dbdd69719600efc144ff8e4a1.zip
[ELF] Allow overriding reserved symbols in linker scripts
llvm-svn: 275383
-rw-r--r--lld/ELF/LinkerScript.cpp6
-rw-r--r--lld/test/ELF/linkerscript-symbol-conflict.s11
2 files changed, 14 insertions, 3 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index f25d6d400f9..0ea9a7a5c92 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -309,10 +309,10 @@ int LinkerScript<ELFT>::compareSections(StringRef A, StringRef B) {
return I < J ? -1 : 1;
}
-template <class ELFT>
-void LinkerScript<ELFT>::addScriptedSymbols() {
+template <class ELFT> void LinkerScript<ELFT>::addScriptedSymbols() {
for (SectionsCommand &Cmd : Opt.Commands)
- if (Cmd.Kind == SymbolAssignmentKind)
+ if (Cmd.Kind == SymbolAssignmentKind &&
+ Symtab<ELFT>::X->find(Cmd.Name) == nullptr)
Symtab<ELFT>::X->addAbsolute(Cmd.Name, STV_DEFAULT);
}
diff --git a/lld/test/ELF/linkerscript-symbol-conflict.s b/lld/test/ELF/linkerscript-symbol-conflict.s
new file mode 100644
index 00000000000..30186ed5cb8
--- /dev/null
+++ b/lld/test/ELF/linkerscript-symbol-conflict.s
@@ -0,0 +1,11 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+# RUN: echo "SECTIONS {.text : {*(.text.*)} end = .;}" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -t %t1 | FileCheck %s
+# CHECK: 0000000000000121 *ABS* 00000000 end
+
+.global _start
+_start:
+ nop
OpenPOWER on IntegriCloud