2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/relocatable.s -o %t2.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/relocatable2.s -o %t3.o
5 # RUN: ld.lld -r %t1.o %t2.o %t3.o -o %t
6 # RUN: llvm-readobj --file-headers --sections -l --symbols -r %t | FileCheck %s
7 # RUN: llvm-objdump --section-headers %t | FileCheck --check-prefix=SECTION %s
8 # RUN: llvm-objdump --no-print-imm-hex -s -d %t | FileCheck --check-prefix=CHECKTEXT %s
10 ## Test --relocatable alias
11 # RUN: ld.lld --relocatable %t1.o %t2.o %t3.o -o %t
12 # RUN: llvm-readobj --file-headers --sections -l --symbols -r %t | FileCheck %s
13 # RUN: llvm-objdump --no-print-imm-hex -s -d %t | FileCheck --check-prefix=CHECKTEXT %s
15 ## Verify that we can use our relocation output as input to produce executable
16 # RUN: ld.lld -e main %t -o %texec
17 # RUN: llvm-readobj --file-headers %texec | FileCheck -check-prefix=CHECKEXE %s
21 # CHECK-NEXT: Magic: (7F 45 4C 46)
22 # CHECK-NEXT: Class: 64-bit
23 # CHECK-NEXT: DataEncoding: LittleEndian
24 # CHECK-NEXT: FileVersion: 1
25 # CHECK-NEXT: OS/ABI: SystemV
26 # CHECK-NEXT: ABIVersion: 0
27 # CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
29 # CHECK-NEXT: Type: Relocatable
30 # CHECK-NEXT: Machine: EM_X86_64
31 # CHECK-NEXT: Version: 1
32 # CHECK-NEXT: Entry: 0x0
33 # CHECK-NEXT: ProgramHeaderOffset: 0x0
34 # CHECK-NEXT: SectionHeaderOffset:
37 # CHECK-NEXT: HeaderSize: 64
38 # CHECK-NEXT: ProgramHeaderEntrySize: 0
39 # CHECK-NEXT: ProgramHeaderCount: 0
40 # CHECK-NEXT: SectionHeaderEntrySize: 64
41 # CHECK-NEXT: SectionHeaderCount: 8
42 # CHECK-NEXT: StringTableSectionIndex: 6
45 # CHECK: Relocations [
46 # CHECK-NEXT: Section ({{.*}}) .rela.text {
47 # CHECK-NEXT: 0x3 R_X86_64_32S x 0x0
48 # CHECK-NEXT: 0xE R_X86_64_32S y 0x0
49 # CHECK-NEXT: 0x23 R_X86_64_32S xx 0x0
50 # CHECK-NEXT: 0x2E R_X86_64_32S yy 0x0
51 # CHECK-NEXT: 0x43 R_X86_64_32S xxx 0x0
52 # CHECK-NEXT: 0x4E R_X86_64_32S yyy 0x0
56 # SECTION: Idx Name Size VMA Type
57 # SECTION: 0 00000000 0000000000000000
58 # SECTION: 1 .text 00000056 0000000000000000 TEXT
59 # SECTION: 2 .rela.text 00000090 0000000000000000
60 # SECTION: 3 .bss 00000018 0000000000000000 BSS
61 # SECTION: 4 .note.GNU-stack 00000000 0000000000000000
62 # SECTION: 5 .symtab 00000168 0000000000000000
63 # SECTION: 6 .shstrtab 00000041 0000000000000000
64 # SECTION: 7 .strtab 0000002d 0000000000000000
66 # CHECKTEXT: Disassembly of section .text:
68 # CHECKTEXT-NEXT: <main>:
69 # CHECKTEXT-NEXT: 0: c7 04 25 00 00 00 00 05 00 00 00 movl $5, 0
70 # CHECKTEXT-NEXT: b: c7 04 25 00 00 00 00 07 00 00 00 movl $7, 0
72 # CHECKTEXT-NEXT: 20: c7 04 25 00 00 00 00 01 00 00 00 movl $1, 0
73 # CHECKTEXT-NEXT: 2b: c7 04 25 00 00 00 00 02 00 00 00 movl $2, 0
75 # CHECKTEXT-NEXT: 40: c7 04 25 00 00 00 00 08 00 00 00 movl $8, 0
76 # CHECKTEXT-NEXT: 4b: c7 04 25 00 00 00 00 09 00 00 00 movl $9, 0
78 # CHECKEXE: Format: elf64-x86-64
79 # CHECKEXE-NEXT: Arch: x86_64
80 # CHECKEXE-NEXT: AddressSize: 64bit
81 # CHECKEXE-NEXT: LoadName:
82 # CHECKEXE-NEXT: ElfHeader {
83 # CHECKEXE-NEXT: Ident {
84 # CHECKEXE-NEXT: Magic: (7F 45 4C 46)
85 # CHECKEXE-NEXT: Class: 64-bit
86 # CHECKEXE-NEXT: DataEncoding: LittleEndian
87 # CHECKEXE-NEXT: FileVersion: 1
88 # CHECKEXE-NEXT: OS/ABI: SystemV (0x0)
89 # CHECKEXE-NEXT: ABIVersion: 0
90 # CHECKEXE-NEXT: Unused: (00 00 00 00 00 00 00)
92 # CHECKEXE-NEXT: Type: Executable
93 # CHECKEXE-NEXT: Machine: EM_X86_64
94 # CHECKEXE-NEXT: Version: 1
95 # CHECKEXE-NEXT: Entry: 0x201160
96 # CHECKEXE-NEXT: ProgramHeaderOffset: 0x40
97 # CHECKEXE-NEXT: SectionHeaderOffset: 0x358
98 # CHECKEXE-NEXT: Flags [
100 # CHECKEXE-NEXT: HeaderSize: 64
101 # CHECKEXE-NEXT: ProgramHeaderEntrySize: 56
102 # CHECKEXE-NEXT: ProgramHeaderCount: 5
103 # CHECKEXE-NEXT: SectionHeaderEntrySize: 64
104 # CHECKEXE-NEXT: SectionHeaderCount: 7
105 # CHECKEXE-NEXT: StringTableSectionIndex: 5