204 lines · plain
1# The binary blobs in this file were created like this:2# llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu Inputs/elf-packed-relocs1.s -o - | obj2yaml | grep Content:3 4# RUN: yaml2obj --docnum=1 %s -o %t15# RUN: llvm-readobj --relocations %t1 | FileCheck --check-prefix=LLVM1 %s6# LLVM1: Section (1) .rela.dyn {7# LLVM1-NEXT: 0x1100 R_X86_64_RELATIVE - 0x08# LLVM1-NEXT: 0x1180 R_X86_64_RELATIVE - 0x09# LLVM1-NEXT: 0x1188 R_X86_64_64 sym1 0x010# LLVM1-NEXT: 0x1190 R_X86_64_64 sym2 0x011# LLVM1-NEXT: 0x1191 R_X86_64_64 sym1 0x812# LLVM1-NEXT: 0x1193 R_X86_64_64 sym2 0xC13# LLVM1-NEXT: 0x1197 R_X86_64_64 sym1 0xA14# LLVM1-NEXT: 0x119F R_X86_64_64 sym2 0xA15# LLVM1-NEXT: }16 17# RUN: llvm-readelf --relocations %t1 | FileCheck --check-prefix=GNU1 %s18# GNU1: Relocation section '.rela.dyn' at offset 0x40 contains 8 entries:19# GNU1: 0000000000001100 0000000000000008 R_X86_64_RELATIVE 020# GNU1-NEXT: 0000000000001180 0000000000000008 R_X86_64_RELATIVE 021# GNU1-NEXT: 0000000000001188 0000000100000001 R_X86_64_64 0000000000000000 sym1 + 022# GNU1-NEXT: 0000000000001190 0000000200000001 R_X86_64_64 0000000000000000 sym2 + 023# GNU1-NEXT: 0000000000001191 0000000100000001 R_X86_64_64 0000000000000000 sym1 + 824# GNU1-NEXT: 0000000000001193 0000000200000001 R_X86_64_64 0000000000000000 sym2 + c25# GNU1-NEXT: 0000000000001197 0000000100000001 R_X86_64_64 0000000000000000 sym1 + a26# GNU1-NEXT: 000000000000119f 0000000200000001 R_X86_64_64 0000000000000000 sym2 + a27 28# elf-packed-relocs1.s29--- !ELF30FileHeader:31 Class: ELFCLASS6432 Data: ELFDATA2LSB33 Type: ET_DYN34 Machine: EM_X86_6435Sections:36 - Name: .rela.dyn37 Type: SHT_ANDROID_RELA38 Flags: [ SHF_ALLOC ]39 Link: [[LINK=.symtab]]40 Content: 41505332088020020108800280010202088180808010818080802002080181808080100802818080802004020C7E04818080801008818080802041 ShOffset: [[SHOFFSET=<none>]]42Symbols:43 - Name: sym144 Binding: STB_GLOBAL45 - Name: sym246 Binding: STB_GLOBAL47 48## Check we report a warning when we are unable to dump relocations for a SHT_ANDROID_RELA section.49 50# RUN: yaml2obj --docnum=1 -DSHOFFSET=0xffffffff %s -o %t1.broken51# RUN: llvm-readobj --relocations %t1.broken 2>&1 | FileCheck -DFILE=%t1.broken --check-prefix=BROKEN-RELA-LLVM %s52# RUN: llvm-readelf --relocations %t1.broken 2>&1 | FileCheck -DFILE=%t1.broken --check-prefix=BROKEN-RELA-GNU %s53 54# BROKEN-RELA-LLVM: Relocations [55# BROKEN-RELA-LLVM-NEXT: Section (1) .rela.dyn {56# BROKEN-RELA-LLVM-NEXT: warning: '[[FILE]]': unable to read relocations from SHT_ANDROID_RELA section with index 1: section [index 1] has a sh_offset (0xffffffff) + sh_size (0x3a) that is greater than the file size (0x238)57# BROKEN-RELA-LLVM-NEXT: }58# BROKEN-RELA-LLVM-NEXT: ]59 60# BROKEN-RELA-GNU: warning: '[[FILE]]': unable to get the number of relocations in SHT_ANDROID_RELA section with index 1: section [index 1] has a sh_offset (0xffffffff) + sh_size (0x3a) that is greater than the file size (0x238)61# BROKEN-RELA-GNU: Relocation section '.rela.dyn' at offset 0xffffffff contains <?> entries:62# BROKEN-RELA-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend63# BROKEN-RELA-GNU-NEXT: warning: '[[FILE]]': unable to read relocations from SHT_ANDROID_RELA section with index 1: section [index 1] has a sh_offset (0xffffffff) + sh_size (0x3a) that is greater than the file size (0x238)64 65## Check we report a warning when the sh_link field of the SHT_ANDROID_RELA section is broken.66 67# RUN: yaml2obj --docnum=1 -DLINK=0xffffffff %s -o %t1.broken.link68# RUN: llvm-readobj --relocations %t1.broken.link 2>&1 | \69# RUN: FileCheck -DFILE=%t1.broken.link --check-prefix=BROKEN-RELA-LINK-LLVM %s70# RUN: llvm-readelf --relocations %t1.broken.link 2>&1 | \71# RUN: FileCheck -DFILE=%t1.broken.link --check-prefix=BROKEN-RELA-LINK-GNU %s72 73# BROKEN-RELA-LINK-LLVM: Relocations [74# BROKEN-RELA-LINK-LLVM-NEXT: Section (1) .rela.dyn {75# BROKEN-RELA-LINK-LLVM-NEXT: warning: '[[FILE]]': unable to locate a symbol table for SHT_ANDROID_RELA section with index 1: invalid section index: 429496729576# BROKEN-RELA-LINK-LLVM-NEXT: }77# BROKEN-RELA-LINK-LLVM-NEXT: ]78 79# BROKEN-RELA-LINK-GNU: Relocation section '.rela.dyn' at offset 0x40 contains 8 entries:80# BROKEN-RELA-LINK-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend81# BROKEN-RELA-LINK-GNU-NEXT: warning: '[[FILE]]': unable to locate a symbol table for SHT_ANDROID_RELA section with index 1: invalid section index: 429496729582 83# RUN: yaml2obj --docnum=2 %s -o %t284# RUN: llvm-readobj --relocations %t2 | FileCheck --check-prefix=LLVM2 %s85# LLVM2: Section (1) .rel.dyn {86# LLVM2-NEXT: 0x1008 R_386_32 sym1 0x087# LLVM2-NEXT: 0x1010 R_386_GOT32 sym2 0x088# LLVM2-NEXT: 0x100C R_386_RELATIVE - 0x089# LLVM2-NEXT: 0x1008 R_386_RELATIVE - 0x090# LLVM2-NEXT: 0x1004 R_386_RELATIVE - 0x091# LLVM2-NEXT: 0x1000 R_386_RELATIVE - 0x092# LLVM2-NEXT: 0xFFC R_386_RELATIVE - 0x093# LLVM2-NEXT: 0xFF8 R_386_RELATIVE - 0x094# LLVM2-NEXT: 0xFF4 R_386_RELATIVE - 0x095# LLVM2-NEXT: 0xFF0 R_386_RELATIVE - 0x096# LLVM2-NEXT: }97 98# RUN: llvm-readelf --relocations %t2 | FileCheck --check-prefix=GNU2 %s99# GNU2: Relocation section '.rel.dyn' at offset 0x34 contains 10 entries:100# GNU2: 00001008 00000101 R_386_32 00000000 sym1101# GNU2-NEXT: 00001010 00000203 R_386_GOT32 00000000 sym2102# GNU2-NEXT: 0000100c 00000008 R_386_RELATIVE103# GNU2-NEXT: 00001008 00000008 R_386_RELATIVE104# GNU2-NEXT: 00001004 00000008 R_386_RELATIVE105# GNU2-NEXT: 00001000 00000008 R_386_RELATIVE106# GNU2-NEXT: 00000ffc 00000008 R_386_RELATIVE107# GNU2-NEXT: 00000ff8 00000008 R_386_RELATIVE108# GNU2-NEXT: 00000ff4 00000008 R_386_RELATIVE109# GNU2-NEXT: 00000ff0 00000008 R_386_RELATIVE110 111# elf-packed-relocs2.s112--- !ELF113FileHeader:114 Class: ELFCLASS32115 Data: ELFDATA2LSB116 Type: ET_DYN117 Machine: EM_386118Sections:119 - Name: .rel.dyn120 Type: SHT_ANDROID_REL121 Flags: [ SHF_ALLOC ]122 Link: [[LINK=.symtab]]123 Content: 415053320A80200202088102830408037C08124 ShOffset: [[SHOFFSET=<none>]]125Symbols:126 - Name: sym1127 Binding: STB_GLOBAL128 - Name: sym2129 Binding: STB_GLOBAL130 131## Check we report a warning when we are unable to dump relocations for a SHT_ANDROID_REL section.132 133# RUN: yaml2obj --docnum=2 -DSHOFFSET=0xffffffff %s -o %t2.broken134# RUN: llvm-readobj --relocations %t2.broken 2>&1 | FileCheck -DFILE=%t2.broken --check-prefix=BROKEN-REL-LLVM %s135# RUN: llvm-readelf --relocations %t2.broken 2>&1 | FileCheck -DFILE=%t2.broken --check-prefix=BROKEN-REL-GNU %s136 137# BROKEN-REL-LLVM: Relocations [138# BROKEN-REL-LLVM-NEXT: Section (1) .rel.dyn {139# BROKEN-REL-LLVM-NEXT: warning: '[[FILE]]': unable to read relocations from SHT_ANDROID_REL section with index 1: section [index 1] has a sh_offset (0xffffffff) + sh_size (0x12) that cannot be represented140# BROKEN-REL-LLVM-NEXT: }141# BROKEN-REL-LLVM-NEXT: ]142 143# BROKEN-REL-GNU: warning: '[[FILE]]': unable to get the number of relocations in SHT_ANDROID_REL section with index 1: section [index 1] has a sh_offset (0xffffffff) + sh_size (0x12) that cannot be represented144# BROKEN-REL-GNU: Relocation section '.rel.dyn' at offset 0xffffffff contains <?> entries:145# BROKEN-REL-GNU-NEXT: Offset Info Type Sym. Value Symbol's Name146# BROKEN-REL-GNU-NEXT: warning: '[[FILE]]': unable to read relocations from SHT_ANDROID_REL section with index 1: section [index 1] has a sh_offset (0xffffffff) + sh_size (0x12) that cannot be represented147 148## Check we report a warning when the sh_link field of the SHT_ANDROID_REL section is broken.149 150# RUN: yaml2obj --docnum=2 -DLINK=0xffffffff %s -o %t2.broken.link151# RUN: llvm-readobj --relocations %t2.broken.link 2>&1 | \152# RUN: FileCheck -DFILE=%t2.broken.link --check-prefix=BROKEN-REL-LINK-LLVM %s153# RUN: llvm-readelf --relocations %t2.broken.link 2>&1 | \154# RUN: FileCheck -DFILE=%t2.broken.link --check-prefix=BROKEN-REL-LINK-GNU %s155 156# BROKEN-REL-LINK-LLVM: Relocations [157# BROKEN-REL-LINK-LLVM-NEXT: Section (1) .rel.dyn {158# BROKEN-REL-LINK-LLVM-NEXT: warning: '[[FILE]]': unable to locate a symbol table for SHT_ANDROID_REL section with index 1: invalid section index: 4294967295159# BROKEN-REL-LINK-LLVM-NEXT: }160# BROKEN-REL-LINK-LLVM-NEXT: ]161 162# BROKEN-REL-LINK-GNU: Relocation section '.rel.dyn' at offset 0x34 contains 10 entries:163# BROKEN-REL-LINK-GNU-NEXT: Offset Info Type Sym. Value Symbol's Name164# BROKEN-REL-LINK-GNU-NEXT: warning: '[[FILE]]': unable to locate a symbol table for SHT_ANDROID_REL section with index 1: invalid section index: 4294967295165 166# RUN: yaml2obj --docnum=3 %s | llvm-readobj --relocations - | FileCheck --check-prefix=LLVM3 %s167#168# LLVM3: Section (1) .rela.dyn {169# LLVM3-NEXT: 0x1100 R_X86_64_RELATIVE - 0x0170# LLVM3-NEXT: 0x1180 R_X86_64_RELATIVE - 0x8171# LLVM3-NEXT: 0x1200 R_X86_64_64 sym1 0x0172# LLVM3-NEXT: 0x1208 R_X86_64_64 sym2 0x0173# LLVM3-NEXT: 0x1210 R_X86_64_64 sym1 0x0174# LLVM3-NEXT: 0x1218 R_X86_64_64 sym2 0x8175# LLVM3-NEXT: }176 177# RUN: yaml2obj --docnum=3 %s | llvm-readelf -r - | FileCheck --check-prefix=GNU3 %s178# GNU3: Relocation section '.rela.dyn' at offset 0x40 contains 6 entries:179# GNU3: 0000000000001100 0000000000000008 R_X86_64_RELATIVE 0180# GNU3-NEXT: 0000000000001180 0000000000000008 R_X86_64_RELATIVE 8181# GNU3-NEXT: 0000000000001200 0000000100000001 R_X86_64_64 0000000000000000 sym1 + 0182# GNU3-NEXT: 0000000000001208 0000000200000001 R_X86_64_64 0000000000000000 sym2 + 0183# GNU3-NEXT: 0000000000001210 0000000100000001 R_X86_64_64 0000000000000000 sym1 + 0184# GNU3-NEXT: 0000000000001218 0000000200000001 R_X86_64_64 0000000000000000 sym2 + 8185 186# elf-packed-relocs3.s187--- !ELF188FileHeader:189 Class: ELFCLASS64190 Data: ELFDATA2LSB191 Type: ET_DYN192 Machine: EM_X86_64193Sections:194 - Name: .rela.dyn195 Type: SHT_ANDROID_RELA196 Flags: [ SHF_ALLOC ]197 Link: .symtab198 Content: 415053320680200208800208008001080802008001818080801008818080802002080881808080100008818080802008199Symbols:200 - Name: sym1201 Binding: STB_GLOBAL202 - Name: sym2203 Binding: STB_GLOBAL204