[PATCH] D13509: [ELF2] Add ENTRY command to the linker script
Denis Protivensky via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 7 23:50:32 PDT 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249661: [ELF2] Add ENTRY command to the linker script (authored by denis-protivensky).
Changed prior to commit:
http://reviews.llvm.org/D13509?vs=36733&id=36827#toc
Repository:
rL LLVM
http://reviews.llvm.org/D13509
Files:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/elf2/linkerscript.s
Index: lld/trunk/test/elf2/linkerscript.s
===================================================================
--- lld/trunk/test/elf2/linkerscript.s
+++ lld/trunk/test/elf2/linkerscript.s
@@ -10,6 +10,26 @@
# RUN: ld.lld2 -o %t2 %t.script1
# RUN: llvm-readobj %t2 > /dev/null
+# RUN: echo "ENTRY(_label)" > %t.script
+# RUN: ld.lld2 -o %t2 %t.script %t
+# RUN: llvm-readobj %t2 > /dev/null
+
+# RUN: echo "ENTRY(_wrong_label)" > %t.script
+# RUN: not lld -flavor gnu2 -o %t2 %t.script %t > %t.log 2>&1
+# RUN: FileCheck -check-prefix=ERR-ENTRY %s < %t.log
+
+# ERR-ENTRY: undefined symbol: _wrong_label
+
+# -e has precedence over linker script's ENTRY.
+# RUN: echo "ENTRY(_label)" > %t.script
+# RUN: ld.lld2 -e _start -o %t2 %t.script %t
+# RUN: llvm-readobj -file-headers -symbols %t2 | \
+# RUN: FileCheck -check-prefix=ENTRY-OVERLOAD %s
+
+# ENTRY-OVERLOAD: Entry: [[ENTRY:0x[0-9A-F]+]]
+# ENTRY-OVERLOAD: Name: _start
+# ENTRY-OVERLOAD-NEXT: Value: [[ENTRY]]
+
# RUN: echo "OUTPUT_FORMAT(\"elf64-x86-64\") /*/*/ GROUP(" %t ")" > %t.script
# RUN: ld.lld2 -o %t2 %t.script
# RUN: llvm-readobj %t2 > /dev/null
@@ -29,8 +49,9 @@
# ERR1: unknown directive: FOO
-.globl _start;
+.globl _start, _label;
_start:
mov $60, %rax
mov $42, %rdi
+_label:
syscall
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -37,6 +37,7 @@
void expect(StringRef Expect);
void readAsNeeded();
+ void readEntry();
void readGroup();
void readOutput();
void readOutputFormat();
@@ -49,7 +50,9 @@
void LinkerScript::run() {
while (!atEOF()) {
StringRef Tok = next();
- if (Tok == "GROUP") {
+ if (Tok == "ENTRY") {
+ readEntry();
+ } else if (Tok == "GROUP") {
readGroup();
} else if (Tok == "OUTPUT") {
readOutput();
@@ -131,6 +134,15 @@
}
}
+void LinkerScript::readEntry() {
+ // -e <symbol> takes predecence over ENTRY(<symbol>).
+ expect("(");
+ StringRef Tok = next();
+ if (Config->Entry.empty())
+ Config->Entry = Tok;
+ expect(")");
+}
+
void LinkerScript::readGroup() {
expect("(");
for (;;) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13509.36827.patch
Type: text/x-patch
Size: 2213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151008/8a84e247/attachment.bin>
More information about the llvm-commits
mailing list