1## Under some circumstances, GNU tools strip/objcopy change REL to RELA. https://sourceware.org/bugzilla/show_bug.cgi?id=28035 2## Test that LLD can handle call graph profile data relocated with RELA relocations. 3# REQUIRES: x86 4 5# RUN: yaml2obj %s -o %t.o 6# RUN: ld.lld %t.o -o %t 7# RUN: llvm-nm --no-sort %t | FileCheck %s 8# RUN: ld.lld --no-call-graph-profile-sort %t.o -o %t 9# RUN: llvm-nm --no-sort %t | FileCheck %s --check-prefix=NO-CG 10 11# CHECK: 0000000000201124 t D 12# CHECK: 0000000000201122 t C 13# CHECK: 0000000000201128 t B 14# CHECK: 0000000000201120 t A 15# CHECK: 0000000000201126 T _start 16 17# NO-CG: 0000000000201120 t D 18# NO-CG: 0000000000201122 t C 19# NO-CG: 0000000000201124 t B 20# NO-CG: 0000000000201126 t A 21# NO-CG: 0000000000201128 T _start 22 23--- !ELF 24FileHeader: 25 Class: ELFCLASS64 26 Data: ELFDATA2LSB 27 Type: ET_REL 28 Machine: EM_X86_64 29Sections: 30 - Name: .text.D 31 Type: SHT_PROGBITS 32 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 33 Size: 2 34 - Name: .text.C 35 Type: SHT_PROGBITS 36 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 37 Size: 2 38 - Name: .text.B 39 Type: SHT_PROGBITS 40 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 41 Size: 2 42 - Name: .text.A 43 Type: SHT_PROGBITS 44 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 45 Size: 2 46 - Name: .text._start 47 Type: SHT_PROGBITS 48 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 49 Size: 2 50 - Name: .llvm.call-graph-profile 51 Type: SHT_LLVM_CALL_GRAPH_PROFILE 52 Flags: [ SHF_EXCLUDE ] 53 Link: .symtab 54 AddressAlign: 0x1 55 Entries: 56 - Weight: 10 57 - Weight: 10 58 - Weight: 80 59 - Weight: 40 60 - Weight: 30 61 - Weight: 90 62 - Name: .rela.llvm.call-graph-profile 63 Type: SHT_RELA 64 Info: .llvm.call-graph-profile 65 Relocations: 66 - Offset: 0x0 67 Symbol: A 68 Type: R_X86_64_NONE 69 - Offset: 0x0 70 Symbol: B 71 Type: R_X86_64_NONE 72 - Offset: 0x8 73 Symbol: A 74 Type: R_X86_64_NONE 75 - Offset: 0x8 76 Symbol: B 77 Type: R_X86_64_NONE 78 - Offset: 0x10 79 Symbol: _start 80 Type: R_X86_64_NONE 81 - Offset: 0x10 82 Symbol: B 83 Type: R_X86_64_NONE 84 - Offset: 0x18 85 Symbol: A 86 Type: R_X86_64_NONE 87 - Offset: 0x18 88 Symbol: C 89 Type: R_X86_64_NONE 90 - Offset: 0x20 91 Symbol: B 92 Type: R_X86_64_NONE 93 - Offset: 0x20 94 Symbol: C 95 Type: R_X86_64_NONE 96 - Offset: 0x28 97 Symbol: C 98 Type: R_X86_64_NONE 99 - Offset: 0x28 100 Symbol: D 101 Type: R_X86_64_NONE 102Symbols: 103 - Name: D 104 Type: STT_FUNC 105 Section: .text.D 106 - Name: C 107 Type: STT_FUNC 108 Section: .text.C 109 - Name: B 110 Type: STT_FUNC 111 Section: .text.B 112 - Name: A 113 Type: STT_FUNC 114 Section: .text.A 115 - Name: _start 116 Binding: STB_GLOBAL 117 Section: .text._start 118