1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
## This is a test to test how SHT_RELR sections are dumped.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj --relocations --raw-relr %t1 \
# RUN: | FileCheck --check-prefix=RAW-LLVM1 %s
# RAW-LLVM1: Section (1) .relr.dyn {
# RAW-LLVM1-NEXT: 0x10D60
# RAW-LLVM1-NEXT: 0x103
# RAW-LLVM1-NEXT: 0x20000
# RAW-LLVM1-NEXT: 0xF0501
# RAW-LLVM1-NEXT: 0xA700550400009
# RAW-LLVM1-NEXT: }
# RUN: llvm-readobj --relocations %t1 | \
# RUN: FileCheck --match-full-lines --check-prefix=LLVM1 %s
# LLVM1: Section (1) .relr.dyn {
# LLVM1-NEXT: 0x10D60 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x10D68 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x10DA0 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20000 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20040 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20050 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20080 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20088 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20090 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20098 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20210 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x202A8 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x202D8 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x202E8 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x202F8 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20308 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20358 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20360 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20368 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20380 R_X86_64_RELATIVE -
# LLVM1-NEXT: 0x20390 R_X86_64_RELATIVE -
# LLVM1-NEXT: }
# RUN: llvm-readelf --relocations --raw-relr %t1 \
# RUN: | FileCheck --check-prefix=RAW-GNU1 %s
# RAW-GNU1: Relocation section '.relr.dyn' at offset 0x40 contains 5 entries:
# RAW-GNU1: 0000000000010d60
# RAW-GNU1-NEXT: 0000000000000103
# RAW-GNU1-NEXT: 0000000000020000
# RAW-GNU1-NEXT: 00000000000f0501
# RAW-GNU1-NEXT: 000a700550400009
# RUN: llvm-readelf --relocations %t1 | FileCheck --check-prefix=GNU1 %s
# GNU1: Relocation section '.relr.dyn' at offset 0x40 contains 21 entries:
# GNU1: 0000000000010d60 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000010d68 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000010da0 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020000 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020040 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020050 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020080 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020088 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020090 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020098 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020210 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 00000000000202a8 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 00000000000202d8 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 00000000000202e8 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 00000000000202f8 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020308 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020358 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020360 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020368 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020380 0000000000000008 R_X86_64_RELATIVE
# GNU1-NEXT: 0000000000020390 0000000000000008 R_X86_64_RELATIVE
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .relr.dyn
Type: SHT_RELR
Flags: [ SHF_ALLOC ]
Entries: [ 0x0000000000010D60, 0x0000000000000103, 0x0000000000020000,
0x00000000000F0501, 0x000A700550400009 ]
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: llvm-readobj --relocations --raw-relr %t2 | \
# RUN: FileCheck --check-prefix=RAW-LLVM2 %s
# RAW-LLVM2: Section (1) .relr.dyn {
# RAW-LLVM2-NEXT: 0x10D60
# RAW-LLVM2-NEXT: 0x103
# RAW-LLVM2-NEXT: 0x20000
# RAW-LLVM2-NEXT: 0xF0501
# RAW-LLVM2-NEXT: 0x50400009
# RAW-LLVM2-NEXT: }
# RUN: llvm-readobj --relocations %t2 | \
# RUN: FileCheck --match-full-lines --check-prefix=LLVM2 %s
# LLVM2: Section (1) .relr.dyn {
# LLVM2-NEXT: 0x10D60 R_386_RELATIVE -
# LLVM2-NEXT: 0x10D64 R_386_RELATIVE -
# LLVM2-NEXT: 0x10D80 R_386_RELATIVE -
# LLVM2-NEXT: 0x20000 R_386_RELATIVE -
# LLVM2-NEXT: 0x20020 R_386_RELATIVE -
# LLVM2-NEXT: 0x20028 R_386_RELATIVE -
# LLVM2-NEXT: 0x20040 R_386_RELATIVE -
# LLVM2-NEXT: 0x20044 R_386_RELATIVE -
# LLVM2-NEXT: 0x20048 R_386_RELATIVE -
# LLVM2-NEXT: 0x2004C R_386_RELATIVE -
# LLVM2-NEXT: 0x20088 R_386_RELATIVE -
# LLVM2-NEXT: 0x200D4 R_386_RELATIVE -
# LLVM2-NEXT: 0x200EC R_386_RELATIVE -
# LLVM2-NEXT: 0x200F4 R_386_RELATIVE -
# LLVM2-NEXT: }
# RUN: llvm-readelf --relocations --raw-relr %t2 | \
# RUN: FileCheck --check-prefix=RAW-GNU2 %s
# RAW-GNU2: Relocation section '.relr.dyn' at offset 0x34 contains 5 entries:
# RAW-GNU2: 00010d60
# RAW-GNU2-NEXT: 00000103
# RAW-GNU2-NEXT: 00020000
# RAW-GNU2-NEXT: 000f0501
# RAW-GNU2-NEXT: 50400009
# RUN: llvm-readelf --relocations %t2 | FileCheck --check-prefix=GNU2 %s
# GNU2: Relocation section '.relr.dyn' at offset 0x34 contains 14 entries:
# GNU2: 00010d60 00000008 R_386_RELATIVE
# GNU2-NEXT: 00010d64 00000008 R_386_RELATIVE
# GNU2-NEXT: 00010d80 00000008 R_386_RELATIVE
# GNU2-NEXT: 00020000 00000008 R_386_RELATIVE
# GNU2-NEXT: 00020020 00000008 R_386_RELATIVE
# GNU2-NEXT: 00020028 00000008 R_386_RELATIVE
# GNU2-NEXT: 00020040 00000008 R_386_RELATIVE
# GNU2-NEXT: 00020044 00000008 R_386_RELATIVE
# GNU2-NEXT: 00020048 00000008 R_386_RELATIVE
# GNU2-NEXT: 0002004c 00000008 R_386_RELATIVE
# GNU2-NEXT: 00020088 00000008 R_386_RELATIVE
# GNU2-NEXT: 000200d4 00000008 R_386_RELATIVE
# GNU2-NEXT: 000200ec 00000008 R_386_RELATIVE
# GNU2-NEXT: 000200f4 00000008 R_386_RELATIVE
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386
Sections:
- Name: .relr.dyn
Type: SHT_RELR
Flags: [ SHF_ALLOC ]
Entries: [ 0x00010D60, 0x00000103, 0x00020000,
0x000F0501, 0x50400009 ]
EntSize: [[ENTSIZE=<none>]]
ShType: [[SHTYPE=<none>]]
Link: [[LINK=<none>]]
## Check we report a warning when we are unable to dump relocations
## for a SHT_RELR/SHT_ANDROID_RELR section.
## Case A: check the case when relocations can't be read from an SHT_RELR section.
# RUN: yaml2obj --docnum=2 -DENTSIZE=1 %s -o %t2.broken
# RUN: llvm-readobj --relocations %t2.broken 2>&1 | \
# RUN: FileCheck -DFILE=%t2.broken --check-prefix=BROKEN-LLVM %s -DSECNAME=SHT_RELR
# RUN: llvm-readelf --relocations %t2.broken 2>&1 | \
# RUN: FileCheck -DFILE=%t2.broken --check-prefix=BROKEN-GNU %s -DSECNAME=SHT_RELR
# BROKEN-LLVM: Relocations [
# BROKEN-LLVM-NEXT: Section (1) .relr.dyn {
# BROKEN-LLVM-NEXT: warning: '[[FILE]]': unable to read relocations from [[SECNAME]] section with index 1: section [index 1] has invalid sh_entsize: expected 4, but got 1
# BROKEN-LLVM-NEXT: }
# BROKEN-LLVM-NEXT: ]
# BROKEN-GNU: warning: '[[FILE]]': unable to get the number of relocations in [[SECNAME]] section with index 1: section [index 1] has invalid sh_entsize: expected 4, but got 1
# BROKEN-GNU: Relocation section '.relr.dyn' at offset 0x34 contains <?> entries:
# BROKEN-GNU-NEXT: Offset Info Type Sym. Value Symbol's Name
# BROKEN-GNU-NEXT: warning: '[[FILE]]': unable to read relocations from [[SECNAME]] section with index 1: section [index 1] has invalid sh_entsize: expected 4, but got 1
## Case B: check the case when relocations can't be read from an SHT_ANDROID_RELR section.
## SHT_ANDROID_RELR = 0x6fffff00.
# RUN: yaml2obj --docnum=2 -DENTSIZE=1 -DSHTYPE=0x6fffff00 %s -o %t2.broken.android
# RUN: llvm-readobj --relocations %t2.broken.android 2>&1 | \
# RUN: FileCheck -DFILE=%t2.broken.android --check-prefix=BROKEN-LLVM %s -DSECNAME=SHT_ANDROID_RELR
# RUN: llvm-readelf --relocations %t2.broken.android 2>&1 | \
# RUN: FileCheck -DFILE=%t2.broken.android --check-prefix=BROKEN-GNU %s -DSECNAME=SHT_ANDROID_RELR
## Check the behavior when the sh_link field of the SHT_RELR/SHT_ANDROID_RELR section
## is set to an arbitrary value. Normally, it is set to 0, because such sections contains
## only relative relocations and do not have an associated symbol table, like other
## relocation sections.
## Case A: check we do not report warnings when the sh_link field is set to an arbitrary value
## and the --relocations option is requested.
# RUN: yaml2obj --docnum=2 -DLINK=0xff %s -o %t2.has.link
# RUN: llvm-readobj --relocations %t2.has.link 2>&1 | \
# RUN: FileCheck -DFILE=%t2.has.link --check-prefix=LLVM2 %s --implicit-check-not=warning:
# RUN: llvm-readelf --relocations %t2.has.link 2>&1 | \
# RUN: FileCheck -DFILE=%t2.has.link --check-prefix=GNU2 %s --implicit-check-not=warning:
## Case B: check we do not report warnings when the sh_link field is set to an arbitrary value
## and --relocations and --raw-relr options are requested.
# RUN: llvm-readobj --relocations --raw-relr %t2.has.link | \
# RUN: FileCheck -DFILE=%t2.has.link --check-prefix=RAW-LLVM2 %s
# RUN: llvm-readelf --relocations --raw-relr %t2.has.link 2>&1 | \
# RUN: FileCheck -DFILE=%t2.has.link --check-prefix=RAW-GNU2 %s
|