1## Show that --disassemble + --reloc prints relocations inline and does not dump 2## the relocation sections. 3 4# RUN: rm -rf %t && split-file %s %t && cd %t 5# RUN: llvm-mc -filetype=obj -triple=x86_64 1.s -o 1.o 6# RUN: llvm-objdump 1.o -d -r | FileCheck %s --implicit-check-not="RELOCATION RECORDS" 7# RUN: llvm-objdump 1.o -r --disassemble-symbols=x2,x4 | FileCheck %s --check-prefix=CHECK2 8 9# RUN: llvm-mc -filetype=obj -triple=x86_64 -crel 1.s -o 1leb.o 10# RUN: llvm-objdump 1leb.o -d -r | FileCheck %s --implicit-check-not="RELOCATION RECORDS" 11# RUN: llvm-objdump 1leb.o -r --disassemble-symbols=x2,x4 | FileCheck %s --check-prefix=CHECK2 12 13#--- 1.s 14# CHECK: 0000000000000000 <x1>: 15# CHECK-NEXT: 0: e8 00 00 00 00 callq 0x5 <x1+0x5> 16# CHECK-NEXT: 0000000000000001: R_X86_64_PC32 foo-0x4 17# CHECK-NEXT: 0000000000000002: R_X86_64_NONE bar+0x8 18# CHECK-NEXT: 5: e8 00 00 00 00 callq 0xa <x2> 19# CHECK-NEXT: 0000000000000006: R_X86_64_PLT32 foo+0x1 20# CHECK-EMPTY: 21# CHECK-NEXT: 000000000000000a <x2>: 22# CHECK-NEXT: a: 90 nop 23# CHECK-NEXT: b: 48 8b 05 00 00 00 00 movq (%rip), %rax # 0x12 <x3> 24# CHECK-NEXT: 000000000000000e: R_X86_64_REX_GOTPCRELX var-0x4 25# CHECK-EMPTY: 26# CHECK-NEXT: 0000000000000012 <x3>: 27# CHECK-NEXT: 12: e8 00 00 00 00 callq 0x17 <x4> 28# CHECK-NEXT: 0000000000000013: R_X86_64_PLT32 foo-0x4 29# CHECK-EMPTY: 30# CHECK-NEXT: 0000000000000017 <x4>: 31# CHECK-NEXT: 17: 48 8b 05 00 00 00 00 movq (%rip), %rax # 0x1e <x4+0x7> 32# CHECK-NEXT: 000000000000001a: R_X86_64_REX_GOTPCRELX var-0x4 33# CHECK-NOT: {{.}} 34 35# CHECK2: 000000000000000a <x2>: 36# CHECK2-NEXT: a: 90 nop 37# CHECK2-NEXT: b: 48 8b 05 00 00 00 00 movq (%rip), %rax # 0x12 <x3> 38# CHECK2-NEXT: 000000000000000e: R_X86_64_REX_GOTPCRELX var-0x4 39# CHECK2-EMPTY: 40# CHECK2-NEXT: 0000000000000017 <x4>: 41# CHECK2-NEXT: 17: 48 8b 05 00 00 00 00 movq (%rip), %rax # 0x1e <x4+0x7> 42# CHECK2-NEXT: 000000000000001a: R_X86_64_REX_GOTPCRELX var-0x4 43# CHECK2-NOT: {{.}} 44 45.globl x1, x2, x3, x4 46x1: 47 .reloc .+1, R_X86_64_PC32, foo-4 48 .reloc .+2, BFD_RELOC_NONE, bar+8 49 .byte 0xe8, 0, 0, 0, 0 50 .reloc .+1, R_X86_64_PLT32, foo+1 51 .byte 0xe8, 0, 0, 0, 0 52 53x2: 54 nop 55 movq var@GOTPCREL(%rip), %rax 56 57x3: 58 call foo 59 60x4: 61 movq var@GOTPCREL(%rip), %rax 62 63#--- 2.yaml 64## Check we report an error if the relocated section identified by the 65## sh_info field of a relocation section is invalid. 66 67# RUN: yaml2obj 2.yaml -o 2.o 68# RUN: not llvm-objdump 2.o -d --reloc 2>&1 | FileCheck %s --check-prefix=ERR 69 70# ERR: error: '2.o': section (1): failed to get a relocated section: invalid section index: 255 71 72--- !ELF 73FileHeader: 74 Class: ELFCLASS64 75 Data: ELFDATA2LSB 76 Type: ET_REL 77 Machine: EM_X86_64 78Sections: 79- Name: .rela.debug_info 80 Type: SHT_RELA 81 Link: 0 82 Info: 0xFF 83 Relocations: [] 84 85#--- 3.s 86## Check ranges of addends being displayed in a dump of relocations mixed with disassembly. 87# RUN: llvm-mc -filetype=obj -triple=x86_64 3.s -o 3.o 88# RUN: llvm-objdump -d -r 3.o | FileCheck %s --check-prefix=ADDENDS 89 90# ADDENDS: Disassembly of section .text: 91# ADDENDS: R_X86_64_64 glob-0x8000000000000000 92# ADDENDS: R_X86_64_64 glob+0x7fffffffffffffff 93# ADDENDS: R_X86_64_64 glob-0x1 94# ADDENDS: R_X86_64_64 glob+0x12345678 95# ADDENDS: R_X86_64_64 glob{{$}} 96 97.reloc ., BFD_RELOC_64, glob-0x8000000000000000 98.reloc .+1, BFD_RELOC_64, glob+0x7fffffffffffffff 99.reloc .+2, BFD_RELOC_64, glob-1 100.reloc .+3, BFD_RELOC_64, glob+0x12345678 101.reloc .+4, BFD_RELOC_64, glob 102.space 8 103