mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 03:26:16 +00:00
[ELF2] Add ENTRY command to the linker script
Set ENTRY as an entry point if -e is not specified. Differential Revision: http://reviews.llvm.org/D13509 llvm-svn: 249661
This commit is contained in:
parent
c10b8381f7
commit
90c5099e8a
@ -37,6 +37,7 @@ private:
|
||||
void expect(StringRef Expect);
|
||||
|
||||
void readAsNeeded();
|
||||
void readEntry();
|
||||
void readGroup();
|
||||
void readOutput();
|
||||
void readOutputFormat();
|
||||
@ -49,7 +50,9 @@ private:
|
||||
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::readAsNeeded() {
|
||||
}
|
||||
}
|
||||
|
||||
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 (;;) {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user