1# REQUIRES: x86
2
3# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
4
5# RUN: echo "ENTRY(_label)" > %t.script
6# RUN: ld.lld -o %t2 %t.script %t
7# RUN: llvm-readobj %t2 > /dev/null
8
9# The entry symbol should not cause an undefined error.
10# RUN: echo "ENTRY(_wrong_label)" > %t.script
11# RUN: ld.lld -o %t2 %t.script %t
12# RUN: ld.lld --entry=abc -o %t2 %t
13
14# -e has precedence over linker script's ENTRY.
15# RUN: echo "ENTRY(_label)" > %t.script
16# RUN: ld.lld -e _start -o %t2 %t.script %t
17# RUN: llvm-readobj -file-headers -symbols %t2 | \
18# RUN:   FileCheck -check-prefix=OVERLOAD %s
19
20# OVERLOAD: Entry: [[ENTRY:0x[0-9A-F]+]]
21# OVERLOAD: Name: _start
22# OVERLOAD-NEXT: Value: [[ENTRY]]
23
24# The entry symbol can be a linker-script-defined symbol.
25# RUN: echo "ENTRY(foo); foo = 1;" > %t.script
26# RUN: ld.lld -o %t2 %t.script %t
27# RUN: llvm-readobj -file-headers -symbols %t2 | \
28# RUN:   FileCheck -check-prefix=SCRIPT %s
29
30# SCRIPT: Entry: 0x1
31
32# RUN: echo "ENTRY(no_such_symbol);" > %t.script
33# RUN: ld.lld -o %t2 %t.script %t 2>&1 | \
34# RUN:   FileCheck -check-prefix=MISSING %s
35
36# MISSING: warning: cannot find entry symbol no_such_symbol
37
38.globl _start, _label
39_start:
40  ret
41_label:
42  ret
43