1# REQUIRES: x86 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 -s -d %t | FileCheck --check-prefix=CHECKTEXT %s 9 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 -s -d %t | FileCheck --check-prefix=CHECKTEXT %s 14 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 18 19# CHECK: ElfHeader { 20# CHECK-NEXT: Ident { 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) 28# CHECK-NEXT: } 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: 35# CHECK-NEXT: Flags [ 36# CHECK-NEXT: ] 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 43# CHECK-NEXT: } 44 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 53# CHECK-NEXT: } 54 55# SECTION: Sections: 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 65 66# CHECKTEXT: Disassembly of section .text: 67# CHECKTEXT-EMPTY: 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 71# CHECKTEXT: <foo>: 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 74# CHECKTEXT: <bar>: 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 77 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) 91# CHECKEXE-NEXT: } 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 [ 99# CHECKEXE-NEXT: ] 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 106# CHECKEXE-NEXT: } 107 108.text 109.type x,@object 110.bss 111.globl x 112.align 4 113x: 114.long 0 115.size x, 4 116.type y,@object 117.globl y 118.align 4 119y: 120.long 0 121.size y, 4 122 123.text 124.globl main 125.align 16, 0x90 126.type main,@function 127main: 128movl $5, x 129movl $7, y 130 131blah: 132goo: 133abs = 42 134