brintos

brintos / llvm-project-archived public Read only

0
0
Text · 13.6 KiB · 1b90676 Raw
301 lines · plain
1## Check how llvm-readelf prints section details with --section-details.2 3## Check the output for the 64-bit case.4# RUN: yaml2obj %s -DBITS=64 -DCHDR=0000000008000000000000000400000000000000 -o %t64.o5# RUN: llvm-readelf %t64.o --section-details 2>&1 | \6# RUN:   FileCheck %s -DFILE=%t64.o --strict-whitespace --match-full-lines --check-prefix=GNU647 8#       GNU64:There are 22 section headers, starting at offset 0x198:9# GNU64-EMPTY:10#  GNU64-NEXT:Section Headers:11#  GNU64-NEXT:  [Nr] Name12#  GNU64-NEXT:       Type            Address          Off    Size   ES   Lk Inf Al13#  GNU64-NEXT:       Flags14#  GNU64-NEXT:  [ 0] {{$}}15#  GNU64-NEXT:       NULL            0000000000000000 000000 000000 00   0   0  016#  GNU64-NEXT:       [0000000000000000]: {{$}}17#  GNU64-NEXT:  [ 1] allflags_and_long_fields18#  GNU64-NEXT:       PROGBITS        1111111111111111 2222222222222222 4444444444444444 5555555555555555 858993459 1717986918 860848056773112408719#  GNU64-NEXT:       [ffffffffffffffff]: WRITE, ALLOC, EXEC, MERGE, STRINGS, INFO LINK, LINK ORDER, OS NONCONF, GROUP, TLS, COMPRESSED, EXCLUDE, OS (000000000ff00000), PROC (0000000070000000), UNKNOWN (ffffffff000ff008)20#  GNU64-NEXT:{{.*}}: warning: '[[FILE]]': SHF_COMPRESSED section 'allflags_and_long_fields' does not have an Elf_Chdr header21#  GNU64-NEXT:       [<corrupt>]22#  GNU64-NEXT:  [ 2] noflags23#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  024#  GNU64-NEXT:       [0000000000000000]: {{$}}25#  GNU64-NEXT:  [ 3] write26#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  027#  GNU64-NEXT:       [0000000000000001]: WRITE28#  GNU64-NEXT:  [ 4] alloc29#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  030#  GNU64-NEXT:       [0000000000000002]: ALLOC31#  GNU64-NEXT:  [ 5] exec32#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  033#  GNU64-NEXT:       [0000000000000004]: EXEC34#  GNU64-NEXT:  [ 6] merge35#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  036#  GNU64-NEXT:       [0000000000000010]: MERGE37#  GNU64-NEXT:  [ 7] strings38#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  039#  GNU64-NEXT:       [0000000000000020]: STRINGS40#  GNU64-NEXT:  [ 8] infolink41#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  042#  GNU64-NEXT:       [0000000000000040]: INFO LINK43#  GNU64-NEXT:  [ 9] linkorder44#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  045#  GNU64-NEXT:       [0000000000000080]: LINK ORDER46#  GNU64-NEXT:  [10] nonconforming47#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  048#  GNU64-NEXT:       [0000000000000100]: OS NONCONF49#  GNU64-NEXT:  [11] group50#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  051#  GNU64-NEXT:       [0000000000000200]: GROUP52#  GNU64-NEXT:  [12] tls53#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  054#  GNU64-NEXT:       [0000000000000400]: TLS55#  GNU64-NEXT:  [13] exclude56#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  057#  GNU64-NEXT:       [0000000080000000]: EXCLUDE58#  GNU64-NEXT:  [14] known_and_unknown59#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  060#  GNU64-NEXT:       [00000000000f0003]: WRITE, ALLOC, UNKNOWN (00000000000f0000)61#  GNU64-NEXT:  [15] only_unknown62#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  063#  GNU64-NEXT:       [00000000000f0000]: UNKNOWN (00000000000f0000)64#  GNU64-NEXT:  [16] compressed_corrupted65#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000000 00   0   0  066#  GNU64-NEXT:       [0000000000000800]: COMPRESSED67#  GNU64-NEXT:{{.*}}: warning: '[[FILE]]': SHF_COMPRESSED section 'compressed_corrupted' does not have an Elf_Chdr header68#  GNU64-NEXT:       [<corrupt>]69#  GNU64-NEXT:  [17] compressed_zlib70#  GNU64-NEXT:       PROGBITS        0000000000000000 000040 000023 00   0   0  071#  GNU64-NEXT:       [0000000000000800]: COMPRESSED72#  GNU64-NEXT:       ZLIB, 0000000000000008, 473#  GNU64-NEXT:  [18] compressed_zstd74#  GNU64-NEXT:       PROGBITS        0000000000000000 000063 000029 00   0   0  075#  GNU64-NEXT:       [0000000000000800]: COMPRESSED76#  GNU64-NEXT:       ZSTD, 0000000000000008, 477#  GNU64-NEXT:  [19] compressed_unknown78#  GNU64-NEXT:       PROGBITS        0000000000000000 00008c 000018 00   0   0  079#  GNU64-NEXT:       [0000000000000800]: COMPRESSED80#  GNU64-NEXT:       [<unknown>: 0x3], 0000000000000008, 481#  GNU64-NEXT:  [20] .strtab82#  GNU64-NEXT:       STRTAB          0000000000000000 0000a4 000001 00   0   0  183#  GNU64-NEXT:       [0000000000000000]: {{$}}84#  GNU64-NEXT:  [21] .shstrtab85#  GNU64-NEXT:       STRTAB          0000000000000000 0000a5 0000ed 00   0   0  186#  GNU64-NEXT:       [0000000000000000]: {{$}}87#  GNU64-NOT:{{.}}88 89--- !ELF90FileHeader:91  Class: ELFCLASS[[BITS]]92  Data:  ELFDATA2LSB93  Type:  ET_REL94  Flags: []95Sections:96  - Name:        allflags_and_long_fields97    Type:        SHT_PROGBITS98    ShFlags:     0xffffffffffffffff99    Address:     0x1111111111111111100    ShOffset:    0x2222222222222222101    Link:        0x33333333102    ShSize:      0x4444444444444444103    EntSize:     0x5555555555555555104    Info:        0x66666666105    ShAddrAlign: 0x7777777777777777106  - Name:  noflags107    Type:  SHT_PROGBITS108    Flags: [ ]109  - Name:  write110    Type:  SHT_PROGBITS111    Flags: [ SHF_WRITE ]112  - Name:  alloc113    Type:  SHT_PROGBITS114    Flags: [ SHF_ALLOC ]115  - Name:  exec116    Type:  SHT_PROGBITS117    Flags: [ SHF_EXECINSTR ]118  - Name:  merge119    Type:  SHT_PROGBITS120    Flags: [ SHF_MERGE ]121  - Name:  strings122    Type:  SHT_PROGBITS123    Flags: [ SHF_STRINGS ]124  - Name:  infolink125    Type:  SHT_PROGBITS126    Flags: [ SHF_INFO_LINK ]127  - Name:  linkorder128    Type:  SHT_PROGBITS129    Flags: [ SHF_LINK_ORDER ]130  - Name:  nonconforming131    Type:  SHT_PROGBITS132    Flags: [ SHF_OS_NONCONFORMING ]133  - Name:  group134    Type:  SHT_PROGBITS135    Flags: [ SHF_GROUP ]136  - Name:  tls137    Type:  SHT_PROGBITS138    Flags: [ SHF_TLS ]139  - Name:  exclude140    Type:  SHT_PROGBITS141    Flags: [ SHF_EXCLUDE ]142  - Name:  known_and_unknown143    Type:  SHT_PROGBITS144    ShFlags: 0x000f0003145  - Name:  only_unknown146    Type:  SHT_PROGBITS147    ShFlags: 0x000f0000148  - Name:  compressed_corrupted149    Type:  SHT_PROGBITS150    Flags: [ SHF_COMPRESSED ]151  - Name:  compressed_zlib152    Type:  SHT_PROGBITS153    Flags: [ SHF_COMPRESSED ]154    Content: 01000000[[CHDR]]789c636080000000080001155  - Name:  compressed_zstd156    Type:  SHT_PROGBITS157    Flags: [ SHF_COMPRESSED ]158    Content: 02000000[[CHDR]]28b52ffd20084100000000000000000000159  - Name:  compressed_unknown160    Type:  SHT_PROGBITS161    Flags: [ SHF_COMPRESSED ]162    Content: 03000000[[CHDR]]163 164## Check the output for the 32-bit case.165# RUN: yaml2obj %s -DBITS=32 -DCHDR=0400000002000000 -o %t32.o166# RUN: llvm-readelf %t32.o --section-details 2>&1 | \167# RUN:   FileCheck %s -DFILE=%t32.o --strict-whitespace --match-full-lines --check-prefix=GNU32168 169#       GNU32:There are 22 section headers, starting at offset 0x164:170# GNU32-EMPTY:171#  GNU32-NEXT:Section Headers:172#  GNU32-NEXT:  [Nr] Name173#  GNU32-NEXT:       Type            Addr     Off    Size   ES   Lk Inf Al174#  GNU32-NEXT:       Flags175#  GNU32-NEXT:  [ 0] {{$}}176#  GNU32-NEXT:       NULL            00000000 000000 000000 00   0   0  0177#  GNU32-NEXT:       [00000000]: {{$}}178#  GNU32-NEXT:  [ 1] allflags_and_long_fields179#  GNU32-NEXT:       PROGBITS        11111111 22222222 44444444 55555555 858993459 1717986918 2004318071180#  GNU32-NEXT:       [ffffffff]: WRITE, ALLOC, EXEC, MERGE, STRINGS, INFO LINK, LINK ORDER, OS NONCONF, GROUP, TLS, COMPRESSED, EXCLUDE, OS (0ff00000), PROC (70000000), UNKNOWN (000ff008)181#  GNU32-NEXT:{{.*}}: warning: '[[FILE]]': SHF_COMPRESSED section 'allflags_and_long_fields' does not have an Elf_Chdr header182#  GNU32-NEXT:       [<corrupt>]183#  GNU32-NEXT:  [ 2] noflags184#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0185#  GNU32-NEXT:       [00000000]: {{$}}186#  GNU32-NEXT:  [ 3] write187#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0188#  GNU32-NEXT:       [00000001]: WRITE189#  GNU32-NEXT:  [ 4] alloc190#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0191#  GNU32-NEXT:       [00000002]: ALLOC192#  GNU32-NEXT:  [ 5] exec193#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0194#  GNU32-NEXT:       [00000004]: EXEC195#  GNU32-NEXT:  [ 6] merge196#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0197#  GNU32-NEXT:       [00000010]: MERGE198#  GNU32-NEXT:  [ 7] strings199#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0200#  GNU32-NEXT:       [00000020]: STRINGS201#  GNU32-NEXT:  [ 8] infolink202#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0203#  GNU32-NEXT:       [00000040]: INFO LINK204#  GNU32-NEXT:  [ 9] linkorder205#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0206#  GNU32-NEXT:       [00000080]: LINK ORDER207#  GNU32-NEXT:  [10] nonconforming208#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0209#  GNU32-NEXT:       [00000100]: OS NONCONF210#  GNU32-NEXT:  [11] group211#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0212#  GNU32-NEXT:       [00000200]: GROUP213#  GNU32-NEXT:  [12] tls214#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0215#  GNU32-NEXT:       [00000400]: TLS216#  GNU32-NEXT:  [13] exclude217#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0218#  GNU32-NEXT:       [80000000]: EXCLUDE219#  GNU32-NEXT:  [14] known_and_unknown220#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0221#  GNU32-NEXT:       [000f0003]: WRITE, ALLOC, UNKNOWN (000f0000)222#  GNU32-NEXT:  [15] only_unknown223#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0224#  GNU32-NEXT:       [000f0000]: UNKNOWN (000f0000)225#  GNU32-NEXT:  [16] compressed_corrupted226#  GNU32-NEXT:       PROGBITS        00000000 000034 000000 00   0   0  0227#  GNU32-NEXT:       [00000800]: COMPRESSED228#  GNU32-NEXT:{{.*}}: warning: '[[FILE]]': SHF_COMPRESSED section 'compressed_corrupted' does not have an Elf_Chdr header229#  GNU32-NEXT:       [<corrupt>]230#  GNU32-NEXT:  [17] compressed_zlib231#  GNU32-NEXT:       PROGBITS        00000000 000034 000017 00   0   0  0232#  GNU32-NEXT:       [00000800]: COMPRESSED233#  GNU32-NEXT:       ZLIB, 00000004, 2234#  GNU32-NEXT:  [18] compressed_zstd235#  GNU32-NEXT:       PROGBITS        00000000 00004b 00001d 00   0   0  0236#  GNU32-NEXT:       [00000800]: COMPRESSED237#  GNU32-NEXT:       ZSTD, 00000004, 2238#  GNU32-NEXT:  [19] compressed_unknown239#  GNU32-NEXT:       PROGBITS        00000000 000068 00000c 00   0   0  0240#  GNU32-NEXT:       [00000800]: COMPRESSED241#  GNU32-NEXT:       [<unknown>: 0x3], 00000004, 2242#  GNU32-NEXT:  [20] .strtab243#  GNU32-NEXT:       STRTAB          00000000 000074 000001 00   0   0  1244#  GNU32-NEXT:       [00000000]: {{$}}245#  GNU32-NEXT:  [21] .shstrtab246#  GNU32-NEXT:       STRTAB          00000000 000075 0000ed 00   0   0  1247#  GNU32-NEXT:       [00000000]: {{$}}248#  GNU32-NOT:{{.}}249 250## When --section-details and --sections are both specified, --sections is ignored.251# RUN: llvm-readelf %t64.o --section-details --sections 2>&1 | FileCheck %s -DFILE=%t64.o --check-prefix=GNU64252# RUN: llvm-readelf %t64.o --sections --section-details 2>&1 | FileCheck %s -DFILE=%t64.o --check-prefix=GNU64253 254## Check that we produce the same output with -t (alias).255# RUN: llvm-readelf --section-details %t64.o > %t.readelf.full256# RUN: llvm-readelf -t %t64.o > %t.readelf.alias257# RUN: cmp %t.readelf.full %t.readelf.alias258 259## Check how we dump sections when the section header string table can't be read.260 261# RUN: yaml2obj --docnum=2 %s -o %tshstrndx.o262# RUN: llvm-readelf %tshstrndx.o --section-details 2>&1 | \263# RUN:   FileCheck %s -DFILE=%tshstrndx.o --check-prefix=SHSTRNDX264 265# SHSTRNDX:      Section Headers:266# SHSTRNDX-NEXT:   [Nr] Name267# SHSTRNDX-NEXT:        Type            Address          Off    Size   ES   Lk Inf Al268# SHSTRNDX-NEXT:        Flags269# SHSTRNDX-NEXT: warning: '[[FILE]]': section header string table index 65279 does not exist270# SHSTRNDX-NEXT:   [ 0]271# SHSTRNDX-NEXT:        NULL            0000000000000000 000000 000000 00   0   0  0272# SHSTRNDX-NEXT:        [0000000000000000]:273# SHSTRNDX-NEXT: warning: '[[FILE]]': a section [index 1] has an invalid sh_name (0x5) offset which goes past the end of the section name string table274# SHSTRNDX-NEXT:   [ 1] <?>275# SHSTRNDX-NEXT:        PROGBITS        0000000000000000 000040 000000 00   0   0  0276# SHSTRNDX-NEXT:        [0000000000000000]:277# SHSTRNDX-NEXT: warning: '[[FILE]]': a section [index 2] has an invalid sh_name (0x1) offset which goes past the end of the section name string table278# SHSTRNDX-NEXT:   [ 2] <?>279# SHSTRNDX-NEXT:        PROGBITS        0000000000000000 000040 000000 00   0   0  0280# SHSTRNDX-NEXT:        [0000000000000000]:281# SHSTRNDX-NEXT: warning: '[[FILE]]': a section [index 3] has an invalid sh_name (0x13) offset which goes past the end of the section name string table282# SHSTRNDX-NEXT:   [ 3] <?>283# SHSTRNDX-NEXT:        STRTAB          0000000000000000 000040 000001 00   0   0  1284# SHSTRNDX-NEXT:        [0000000000000000]:285# SHSTRNDX-NEXT: warning: '[[FILE]]': a section [index 4] has an invalid sh_name (0x9) offset which goes past the end of the section name string table286# SHSTRNDX-NEXT:   [ 4] <?>287# SHSTRNDX-NEXT:        STRTAB          0000000000000000 000041 00001b 00   0   0  1288# SHSTRNDX-NEXT:        [0000000000000000]:289 290--- !ELF291FileHeader:292  Class:     ELFCLASS64293  Data:      ELFDATA2LSB294  Type:      ET_REL295  EShStrNdx: 0xfeff296Sections:297  - Name: foo298    Type: SHT_PROGBITS299  - Name: bar300    Type: SHT_PROGBITS301