## Check how llvm-readelf prints section details with --section-details. ## Check the output for the 64-bit case. # RUN: yaml2obj %s -DBITS=64 -o %t64.o # RUN: llvm-readelf %t64.o --section-details | \ # RUN: FileCheck %s --strict-whitespace --match-full-lines --check-prefix=GNU64 # GNU64:There are 19 section headers, starting at offset 0xf8: # GNU64-EMPTY: # GNU64-NEXT:Section Headers: # GNU64-NEXT: [Nr] Name # GNU64-NEXT: Type Address Off Size ES Lk Inf Al # GNU64-NEXT: Flags # GNU64-NEXT: [ 0] {{$}} # GNU64-NEXT: NULL 0000000000000000 000000 000000 00 0 0 0 # GNU64-NEXT: [0000000000000000]: {{$}} # GNU64-NEXT: [ 1] allflags_and_long_fields # GNU64-NEXT: PROGBITS 1111111111111111 2222222222222222 4444444444444444 5555555555555555 858993459 1717986918 8608480567731124087 # GNU64-NEXT: [ffffffffffffffff]: WRITE, ALLOC, EXEC, MERGE, STRINGS, INFO LINK, LINK ORDER, OS NONCONF, GROUP, TLS, COMPRESSED, EXCLUDE, OS (000000000ff00000), PROC (0000000070000000), UNKNOWN (ffffffff000ff008) # GNU64-NEXT: [ 2] noflags # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000000]: {{$}} # GNU64-NEXT: [ 3] write # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000001]: WRITE # GNU64-NEXT: [ 4] alloc # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000002]: ALLOC # GNU64-NEXT: [ 5] exec # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000004]: EXEC # GNU64-NEXT: [ 6] merge # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000010]: MERGE # GNU64-NEXT: [ 7] strings # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000020]: STRINGS # GNU64-NEXT: [ 8] infolink # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000040]: INFO LINK # GNU64-NEXT: [ 9] linkorder # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000080]: LINK ORDER # GNU64-NEXT: [10] nonconforming # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000100]: OS NONCONF # GNU64-NEXT: [11] group # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000200]: GROUP # GNU64-NEXT: [12] tls # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000400]: TLS # GNU64-NEXT: [13] compressed # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000000000800]: COMPRESSED # GNU64-NEXT: [14] exclude # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [0000000080000000]: EXCLUDE # GNU64-NEXT: [15] known_and_unknown # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [00000000000f0003]: WRITE, ALLOC, UNKNOWN (00000000000f0000) # GNU64-NEXT: [16] only_unknown # GNU64-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # GNU64-NEXT: [00000000000f0000]: UNKNOWN (00000000000f0000) # GNU64-NEXT: [17] .strtab # GNU64-NEXT: STRTAB 0000000000000000 000040 000001 00 0 0 1 # GNU64-NEXT: [0000000000000000]: {{$}} # GNU64-NEXT: [18] .shstrtab # GNU64-NEXT: STRTAB 0000000000000000 000041 0000b0 00 0 0 1 # GNU64-NEXT: [0000000000000000]: {{$}} # GNU64-NOT:{{.}} --- !ELF FileHeader: Class: ELFCLASS[[BITS]] Data: ELFDATA2LSB Type: ET_REL Flags: [] Sections: - Name: allflags_and_long_fields Type: SHT_PROGBITS ShFlags: 0xffffffffffffffff Address: 0x1111111111111111 ShOffset: 0x2222222222222222 Link: 0x33333333 ShSize: 0x4444444444444444 EntSize: 0x5555555555555555 Info: 0x66666666 ShAddrAlign: 0x7777777777777777 - Name: noflags Type: SHT_PROGBITS Flags: [ ] - Name: write Type: SHT_PROGBITS Flags: [ SHF_WRITE ] - Name: alloc Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] - Name: exec Type: SHT_PROGBITS Flags: [ SHF_EXECINSTR ] - Name: merge Type: SHT_PROGBITS Flags: [ SHF_MERGE ] - Name: strings Type: SHT_PROGBITS Flags: [ SHF_STRINGS ] - Name: infolink Type: SHT_PROGBITS Flags: [ SHF_INFO_LINK ] - Name: linkorder Type: SHT_PROGBITS Flags: [ SHF_LINK_ORDER ] - Name: nonconforming Type: SHT_PROGBITS Flags: [ SHF_OS_NONCONFORMING ] - Name: group Type: SHT_PROGBITS Flags: [ SHF_GROUP ] - Name: tls Type: SHT_PROGBITS Flags: [ SHF_TLS ] - Name: compressed Type: SHT_PROGBITS Flags: [ SHF_COMPRESSED ] - Name: exclude Type: SHT_PROGBITS Flags: [ SHF_EXCLUDE ] - Name: known_and_unknown Type: SHT_PROGBITS ShFlags: 0x000f0003 - Name: only_unknown Type: SHT_PROGBITS ShFlags: 0x000f0000 ## Check the output for the 32-bit case. # RUN: yaml2obj %s -DBITS=32 -o %t32.o # RUN: llvm-readelf %t32.o --section-details | \ # RUN: FileCheck %s --strict-whitespace --match-full-lines --check-prefix=GNU32 # GNU32:There are 19 section headers, starting at offset 0xe8: # GNU32-EMPTY: # GNU32-NEXT:Section Headers: # GNU32-NEXT: [Nr] Name # GNU32-NEXT: Type Addr Off Size ES Lk Inf Al # GNU32-NEXT: Flags # GNU32-NEXT: [ 0] {{$}} # GNU32-NEXT: NULL 00000000 000000 000000 00 0 0 0 # GNU32-NEXT: [00000000]: {{$}} # GNU32-NEXT: [ 1] allflags_and_long_fields # GNU32-NEXT: PROGBITS 11111111 22222222 44444444 55555555 858993459 1717986918 2004318071 # GNU32-NEXT: [ffffffff]: WRITE, ALLOC, EXEC, MERGE, STRINGS, INFO LINK, LINK ORDER, OS NONCONF, GROUP, TLS, COMPRESSED, EXCLUDE, OS (0ff00000), PROC (70000000), UNKNOWN (000ff008) # GNU32-NEXT: [ 2] noflags # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000000]: {{$}} # GNU32-NEXT: [ 3] write # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000001]: WRITE # GNU32-NEXT: [ 4] alloc # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000002]: ALLOC # GNU32-NEXT: [ 5] exec # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000004]: EXEC # GNU32-NEXT: [ 6] merge # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000010]: MERGE # GNU32-NEXT: [ 7] strings # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000020]: STRINGS # GNU32-NEXT: [ 8] infolink # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000040]: INFO LINK # GNU32-NEXT: [ 9] linkorder # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000080]: LINK ORDER # GNU32-NEXT: [10] nonconforming # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000100]: OS NONCONF # GNU32-NEXT: [11] group # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000200]: GROUP # GNU32-NEXT: [12] tls # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000400]: TLS # GNU32-NEXT: [13] compressed # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [00000800]: COMPRESSED # GNU32-NEXT: [14] exclude # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [80000000]: EXCLUDE # GNU32-NEXT: [15] known_and_unknown # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [000f0003]: WRITE, ALLOC, UNKNOWN (000f0000) # GNU32-NEXT: [16] only_unknown # GNU32-NEXT: PROGBITS 00000000 000034 000000 00 0 0 0 # GNU32-NEXT: [000f0000]: UNKNOWN (000f0000) # GNU32-NEXT: [17] .strtab # GNU32-NEXT: STRTAB 00000000 000034 000001 00 0 0 1 # GNU32-NEXT: [00000000]: {{$}} # GNU32-NEXT: [18] .shstrtab # GNU32-NEXT: STRTAB 00000000 000035 0000b0 00 0 0 1 # GNU32-NEXT: [00000000]: {{$}} # GNU32-NOT:{{.}} ## When --section-details and --sections are both specified, --sections is ignored. # RUN: llvm-readelf %t64.o --section-details --sections | FileCheck %s --check-prefix=GNU64 # RUN: llvm-readelf %t64.o --sections --section-details | FileCheck %s --check-prefix=GNU64 ## Check that we produce the same output with -t (alias). # RUN: llvm-readelf --section-details %t64.o > %t.readelf.full # RUN: llvm-readelf -t %t64.o > %t.readelf.alias # RUN: cmp %t.readelf.full %t.readelf.alias ## Check how we dump sections when the section header string table can't be read. # RUN: yaml2obj --docnum=2 %s -o %tshstrndx.o # RUN: llvm-readelf %tshstrndx.o --section-details 2>&1 | \ # RUN: FileCheck %s -DFILE=%tshstrndx.o --check-prefix=SHSTRNDX # SHSTRNDX: Section Headers: # SHSTRNDX-NEXT: [Nr] Name # SHSTRNDX-NEXT: Type Address Off Size ES Lk Inf Al # SHSTRNDX-NEXT: Flags # SHSTRNDX-NEXT: warning: '[[FILE]]': section header string table index 65279 does not exist # SHSTRNDX-NEXT: [ 0] # SHSTRNDX-NEXT: NULL 0000000000000000 000000 000000 00 0 0 0 # SHSTRNDX-NEXT: [0000000000000000]: # 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 table # SHSTRNDX-NEXT: [ 1] # SHSTRNDX-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # SHSTRNDX-NEXT: [0000000000000000]: # 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 table # SHSTRNDX-NEXT: [ 2] # SHSTRNDX-NEXT: PROGBITS 0000000000000000 000040 000000 00 0 0 0 # SHSTRNDX-NEXT: [0000000000000000]: # 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 table # SHSTRNDX-NEXT: [ 3] # SHSTRNDX-NEXT: STRTAB 0000000000000000 000040 000001 00 0 0 1 # SHSTRNDX-NEXT: [0000000000000000]: # 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 table # SHSTRNDX-NEXT: [ 4] # SHSTRNDX-NEXT: STRTAB 0000000000000000 000041 00001b 00 0 0 1 # SHSTRNDX-NEXT: [0000000000000000]: --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_REL EShStrNdx: 0xfeff Sections: - Name: foo Type: SHT_PROGBITS - Name: bar Type: SHT_PROGBITS