[PATCH] D22300: [ELF] Allow overriding reserved symbols in linker script
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 13 03:25:09 PDT 2016
evgeny777 created this revision.
evgeny777 added a reviewer: ruiu.
evgeny777 added subscribers: grimar, ikudrin, llvm-commits.
evgeny777 set the repository for this revision to rL LLVM.
evgeny777 added a project: lld.
This is a small bugfix for http://reviews.llvm.org/D21965
Resverved symbols are added in addReservedSymbols(), which is called before createSections()
Therefore if you define some reserved symbol in linker script then lld will report error because of name conflict
Repository:
rL LLVM
http://reviews.llvm.org/D22300
Files:
ELF/LinkerScript.cpp
test/ELF/linkerscript-symbols.s
Index: test/ELF/linkerscript-symbols.s
===================================================================
--- test/ELF/linkerscript-symbols.s
+++ test/ELF/linkerscript-symbols.s
@@ -1,10 +1,10 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "SECTIONS {.text : {*(.text.*)} text_end = .;}" > %t.script
+# 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 text_end
+# CHECK: 0000000000000121 *ABS* 00000000 end
.global _start
_start:
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -309,10 +309,10 @@
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22300.63790.patch
Type: text/x-patch
Size: 1251 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160713/843c32b4/attachment.bin>
More information about the llvm-commits
mailing list