112 lines · yaml
1## Show that references in disassembly are labelled with the correct symbol.2# RUN: yaml2obj %s --docnum=1 -o %t3# RUN: llvm-objdump --no-print-imm-hex %t -d | FileCheck %s --check-prefix=EXEC4 5# EXEC-LABEL: <first>:6# EXEC-NEXT: 4000: e8 00 00 00 00 callq 0x4005 <third>7# EXEC-LABEL: <third>:8# EXEC-NEXT: 4005: e8 12 34 56 78 callq 0x7856741c <data1+0x7856241c>9# EXEC-LABEL: <fourth>:10# EXEC-NEXT: 400a: 8b 05 f0 0f 00 00 movl 4080(%rip), %eax # 0x5000 <data1>11 12--- !ELF13FileHeader:14 Class: ELFCLASS6415 Data: ELFDATA2LSB16 Type: ET_EXEC17 Machine: EM_X86_6418Sections:19 - Name: .text120 Type: SHT_PROGBITS21 Address: 0x400022 Flags: [SHF_ALLOC, SHF_EXECINSTR]23 Content: 'e800000000' # Case 1: Referencing an address with a symbol.24 - Name: .text225 Type: SHT_PROGBITS26 Flags: [SHF_ALLOC, SHF_EXECINSTR]27 Address: 0x400528 Content: 'e812345678' # Case 2: Referencing an address without a symbol.29 - Name: .text330 Type: SHT_PROGBITS31 Flags: [SHF_ALLOC, SHF_EXECINSTR]32 Address: 0x400A33 Content: '8b05f00f0000' # Case 3: Memory operands34 - Name: .data35 Type: SHT_PROGBITS36 Flags: [SHF_ALLOC, SHF_WRITE]37 Address: 0x500038Symbols:39 - Name: first40 Section: .text141 Value: 0x400042 - Name: second43 Section: .text144 Value: 0x400545 - Name: third46 Section: .text247 Value: 0x400548 - Name: fourth49 Section: .text350 Value: 0x400A51 - Name: data152 Section: .data53 Value: 0x500054 55# RUN: yaml2obj %s --docnum=2 -o %t.o56# RUN: llvm-objdump --no-print-imm-hex %t.o -d | FileCheck %s --check-prefix=REL57 58# REL: Disassembly of section .text1:59# REL-EMPTY:60# REL-NEXT: 0000000000000000 <.text1>:61# REL-NEXT: 0: e8 00 00 00 00 callq 0x5 <.text1+0x5>62# REL-EMPTY:63# REL-NEXT: Disassembly of section .text2:64# REL-EMPTY:65# REL-NEXT: 0000000000000000 <.text2>:66# REL-NEXT: 0: e8 00 00 00 00 callq 0x5 <sym2>67# REL-EMPTY:68# REL-NEXT: Disassembly of section .text3:69# REL-EMPTY:70# REL-NEXT: 0000000000000000 <.text3>:71# REL-NEXT: 0: e8 00 00 00 00 callq 0x5 <.text3+0x5>72 73--- !ELF74FileHeader:75 Class: ELFCLASS6476 Data: ELFDATA2LSB77 Type: ET_REL78 Machine: EM_X86_6479Sections:80 - Name: .text181 Type: SHT_PROGBITS82 Flags: [SHF_ALLOC, SHF_EXECINSTR]83 Content: 'e800000000' # Case 1: Instruction is patched by a relocation.84 - Name: .rela.text185 Type: SHT_RELA86 Info: .text187 Relocations:88 - Offset: 189 Type: R_X86_64_PC3290 Symbol: sym391 - Name: .text292 Type: SHT_PROGBITS93 Flags: [SHF_ALLOC, SHF_EXECINSTR]94 Content: 'e800000000' # Case 2: Referencing an address with a matching symbol in that section.95 - Name: .text396 Type: SHT_PROGBITS97 Flags: [SHF_ALLOC, SHF_EXECINSTR]98 Content: 'e800000000' # Case 3: Referencing an address without a matching symbol in that section.99 - Name: .other100 Type: SHT_PROGBITS101Symbols:102 # Shouldn't be picked, despite matching value, as not in right section.103 - Name: sym1104 Section: .other105 Value: 5106 # Symbol in correct section, with right value should be picked for disassembly of .text2.107 - Name: sym2108 Section: .text2109 Value: 5110 # Symbol referenced by relocation could be picked for disassembly of .text1, but isn't.111 - Name: sym3112