1## Show that references in disassembly are labelled with the correct symbol. 2# RUN: yaml2obj %s --docnum=1 -o %t 3# RUN: llvm-objdump --no-print-imm-hex %t -d | FileCheck %s --check-prefix=EXEC 4 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--- !ELF 13FileHeader: 14 Class: ELFCLASS64 15 Data: ELFDATA2LSB 16 Type: ET_EXEC 17 Machine: EM_X86_64 18Sections: 19 - Name: .text1 20 Type: SHT_PROGBITS 21 Address: 0x4000 22 Flags: [SHF_ALLOC, SHF_EXECINSTR] 23 Content: 'e800000000' # Case 1: Referencing an address with a symbol. 24 - Name: .text2 25 Type: SHT_PROGBITS 26 Flags: [SHF_ALLOC, SHF_EXECINSTR] 27 Address: 0x4005 28 Content: 'e812345678' # Case 2: Referencing an address without a symbol. 29 - Name: .text3 30 Type: SHT_PROGBITS 31 Flags: [SHF_ALLOC, SHF_EXECINSTR] 32 Address: 0x400A 33 Content: '8b05f00f0000' # Case 3: Memory operands 34 - Name: .data 35 Type: SHT_PROGBITS 36 Flags: [SHF_ALLOC, SHF_WRITE] 37 Address: 0x5000 38Symbols: 39 - Name: first 40 Section: .text1 41 Value: 0x4000 42 - Name: second 43 Section: .text1 44 Value: 0x4005 45 - Name: third 46 Section: .text2 47 Value: 0x4005 48 - Name: fourth 49 Section: .text3 50 Value: 0x400A 51 - Name: data1 52 Section: .data 53 Value: 0x5000 54 55# RUN: yaml2obj %s --docnum=2 -o %t.o 56# RUN: llvm-objdump --no-print-imm-hex %t.o -d | FileCheck %s --check-prefix=REL 57 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--- !ELF 74FileHeader: 75 Class: ELFCLASS64 76 Data: ELFDATA2LSB 77 Type: ET_REL 78 Machine: EM_X86_64 79Sections: 80 - Name: .text1 81 Type: SHT_PROGBITS 82 Flags: [SHF_ALLOC, SHF_EXECINSTR] 83 Content: 'e800000000' # Case 1: Instruction is patched by a relocation. 84 - Name: .rela.text1 85 Type: SHT_RELA 86 Info: .text1 87 Relocations: 88 - Offset: 1 89 Type: R_X86_64_PC32 90 Symbol: sym3 91 - Name: .text2 92 Type: SHT_PROGBITS 93 Flags: [SHF_ALLOC, SHF_EXECINSTR] 94 Content: 'e800000000' # Case 2: Referencing an address with a matching symbol in that section. 95 - Name: .text3 96 Type: SHT_PROGBITS 97 Flags: [SHF_ALLOC, SHF_EXECINSTR] 98 Content: 'e800000000' # Case 3: Referencing an address without a matching symbol in that section. 99 - Name: .other 100 Type: SHT_PROGBITS 101Symbols: 102 # Shouldn't be picked, despite matching value, as not in right section. 103 - Name: sym1 104 Section: .other 105 Value: 5 106 # Symbol in correct section, with right value should be picked for disassembly of .text2. 107 - Name: sym2 108 Section: .text2 109 Value: 5 110 # Symbol referenced by relocation could be picked for disassembly of .text1, but isn't. 111 - Name: sym3 112