mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[llvm-objcopy][test] Improve many-sections object and test case
Additionally do some test tidy-ups and improve coverage of symbol section indexes where the logical section index >= SHN_LORESERVE. The symbol and section names in the many-section input object were mostly shared. This patch changes them to be distinct, enabling different operations such as --add-symbol, to be more targeted, when using the object. It also makes the test less confusing and removes some oddness in the symbol table order, presumably caused by the duplicate names. The input object was built from assembly that was of the form: .section s1 sym1: .section s2 sym2: ... with a total of 65536 such occurrences. llvm-objcopy was then used to remove the empty .text section automatically generated by MC, and incidentally to move .strtab to the end of the object. This ensured that the section/symbol indexes matched their name (i.e. section index 1 was s1, section index 2 was s2 etc, and sym1 was in s1, sym2 in s2 etc). Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D97660
This commit is contained in:
parent
ebfa93d23f
commit
7aeb2619a9
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
# RUN: %python %p/../Inputs/ungzip.py %p/Inputs/many-sections.o.gz > %t
|
||||
# RUN: llvm-objcopy -R .text -R s0 -R s1 -R s2 -R s3 -R s4 -R s5 -R s6 %t %t2
|
||||
# RUN: llvm-objcopy -R 's65[3-9][0-9][0-9]' -R 's6529[0-9]' -R 's6528[1-9]' %t %t2
|
||||
# RUN: llvm-readobj --sections %t2 | FileCheck --check-prefix=SECS %s
|
||||
|
||||
# SECS-NOT: Name: .symtab_shndx
|
||||
|
@ -1,103 +1,102 @@
|
||||
## Show that llvm-objcopy can handle an input file with many sections.
|
||||
|
||||
RUN: %python %p/../Inputs/ungzip.py %p/Inputs/many-sections.o.gz > %t
|
||||
RUN: llvm-objcopy %t %t2
|
||||
RUN: llvm-readobj --file-headers %t2 | FileCheck --check-prefix=EHDR %s
|
||||
RUN: llvm-readobj --sections %t2 | FileCheck --check-prefix=SECS %s
|
||||
RUN: llvm-readobj --symbols %t2 | grep "Symbol {" | wc -l | FileCheck --check-prefix=SYMS %s
|
||||
RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=SYM_SEC_IDS
|
||||
RUN: llvm-readobj --file-headers --sections --symbols %t2 | FileCheck %s
|
||||
RUN: llvm-readelf --symbols %t2 | FileCheck --check-prefix=SYMS %s
|
||||
|
||||
EHDR: Format: elf64-x86-64
|
||||
EHDR-NEXT: Arch: x86_64
|
||||
EHDR-NEXT: AddressSize: 64bit
|
||||
EHDR-NEXT: LoadName:
|
||||
EHDR-NEXT: ElfHeader {
|
||||
EHDR-NEXT: Ident {
|
||||
EHDR-NEXT: Magic: (7F 45 4C 46)
|
||||
EHDR-NEXT: Class: 64-bit (0x2)
|
||||
EHDR-NEXT: DataEncoding: LittleEndian (0x1)
|
||||
EHDR-NEXT: FileVersion: 1
|
||||
EHDR-NEXT: OS/ABI: SystemV (0x0)
|
||||
EHDR-NEXT: ABIVersion: 0
|
||||
EHDR-NEXT: Unused: (00 00 00 00 00 00 00)
|
||||
EHDR-NEXT: }
|
||||
EHDR-NEXT: Type: Relocatable (0x1)
|
||||
EHDR-NEXT: Machine: EM_X86_64 (0x3E)
|
||||
EHDR-NEXT: Version: 1
|
||||
EHDR-NEXT: Entry: 0x0
|
||||
EHDR-NEXT: ProgramHeaderOffset: 0x0
|
||||
EHDR-NEXT: SectionHeaderOffset:
|
||||
EHDR-NEXT: Flags [ (0x0)
|
||||
EHDR-NEXT: ]
|
||||
EHDR-NEXT: HeaderSize: 64
|
||||
EHDR-NEXT: ProgramHeaderEntrySize: 0
|
||||
EHDR-NEXT: ProgramHeaderCount: 0
|
||||
EHDR-NEXT: SectionHeaderEntrySize: 64
|
||||
EHDR-NEXT: SectionHeaderCount: 0
|
||||
EHDR-NEXT: StringTableSectionIndex: 65535
|
||||
EHDR-NEXT: }
|
||||
## The ELF header should have e_shnum == 0 and e_shstrndx == SHN_XINDEX.
|
||||
# CHECK: SectionHeaderCount: 0
|
||||
# CHECK-NEXT: StringTableSectionIndex: 65535
|
||||
|
||||
SECS: Index: 65285
|
||||
SECS-NEXT: Name: .symtab
|
||||
SECS-NEXT: Type: SHT_SYMTAB
|
||||
SECS: Name: .symtab_shndx
|
||||
SECS-NEXT: Type: SHT_SYMTAB_SHNDX
|
||||
SECS-NEXT: Flags [ (0x0)
|
||||
SECS-NEXT: ]
|
||||
SECS-NEXT: Address: 0x0
|
||||
SECS-NEXT: Offset:
|
||||
# There should be #syms * EntrySize bytes.
|
||||
SECS-NEXT: Size: 261136
|
||||
SECS-NEXT: Link: 65285
|
||||
SECS-NEXT: Info:
|
||||
SECS-NEXT: AddressAlignment: 4
|
||||
SECS-NEXT: EntrySize: 4
|
||||
SECS: Index: 65287
|
||||
SYMS: 65284
|
||||
## The first section header should store the real section header count and
|
||||
## shstrndx in its fields.
|
||||
# CHECK: Section {
|
||||
# CHECK-NEXT: Index: 0
|
||||
# CHECK-NEXT: Name:
|
||||
# CHECK-NEXT: Type: SHT_NULL
|
||||
# CHECK-NEXT: Flags [
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address:
|
||||
# CHECK-NEXT: Offset:
|
||||
# CHECK-NEXT: Size: [[#SHNUM:]]
|
||||
# CHECK-NEXT: Link: [[#SHNUM-1]]
|
||||
|
||||
SYM_SEC_IDS: Section: s9 (0xFEFF)
|
||||
SYM_SEC_IDS-NEXT: }
|
||||
SYM_SEC_IDS-NEXT: Symbol {
|
||||
SYM_SEC_IDS-NEXT: Name: s9 (37)
|
||||
SYM_SEC_IDS-NEXT: Value: 0x0
|
||||
SYM_SEC_IDS-NEXT: Size: 0
|
||||
SYM_SEC_IDS-NEXT: Binding: Local (0x0)
|
||||
SYM_SEC_IDS-NEXT: Type: None (0x0)
|
||||
SYM_SEC_IDS-NEXT: Other: 0
|
||||
SYM_SEC_IDS-NEXT: Section: s9 (0xFF01)
|
||||
SYM_SEC_IDS-NEXT: }
|
||||
SYM_SEC_IDS-NEXT: Symbol {
|
||||
SYM_SEC_IDS-NEXT: Name: s9 (37)
|
||||
SYM_SEC_IDS-NEXT: Value: 0x0
|
||||
SYM_SEC_IDS-NEXT: Size: 0
|
||||
SYM_SEC_IDS-NEXT: Binding: Local (0x0)
|
||||
SYM_SEC_IDS-NEXT: Type: None (0x0)
|
||||
SYM_SEC_IDS-NEXT: Other: 0
|
||||
SYM_SEC_IDS-NEXT: Section: s9 (0xFF00)
|
||||
SYM_SEC_IDS-NEXT: }
|
||||
SYM_SEC_IDS-NEXT: Symbol {
|
||||
SYM_SEC_IDS-NEXT: Name: s9 (37)
|
||||
SYM_SEC_IDS-NEXT: Value: 0x0
|
||||
SYM_SEC_IDS-NEXT: Size: 0
|
||||
SYM_SEC_IDS-NEXT: Binding: Local (0x0)
|
||||
SYM_SEC_IDS-NEXT: Type: None (0x0)
|
||||
SYM_SEC_IDS-NEXT: Other: 0
|
||||
SYM_SEC_IDS-NEXT: Section: s9 (0x1982)
|
||||
SYM_SEC_IDS-NEXT: }
|
||||
SYM_SEC_IDS-NEXT: Symbol {
|
||||
SYM_SEC_IDS-NEXT: Name: s9 (37)
|
||||
SYM_SEC_IDS-NEXT: Value: 0x0
|
||||
SYM_SEC_IDS-NEXT: Size: 0
|
||||
SYM_SEC_IDS-NEXT: Binding: Local (0x0)
|
||||
SYM_SEC_IDS-NEXT: Type: None (0x0)
|
||||
SYM_SEC_IDS-NEXT: Other: 0
|
||||
SYM_SEC_IDS-NEXT: Section: s9 (0xFF03)
|
||||
SYM_SEC_IDS-NEXT: }
|
||||
SYM_SEC_IDS-NEXT: Symbol {
|
||||
SYM_SEC_IDS-NEXT: Name: s9 (37)
|
||||
SYM_SEC_IDS-NEXT: Value: 0x0
|
||||
SYM_SEC_IDS-NEXT: Size: 0
|
||||
SYM_SEC_IDS-NEXT: Binding: Local (0x0)
|
||||
SYM_SEC_IDS-NEXT: Type: None (0x0)
|
||||
SYM_SEC_IDS-NEXT: Other: 0
|
||||
SYM_SEC_IDS-NEXT: Section: s9 (0xFF04)
|
||||
SYM_SEC_IDS-NEXT: }
|
||||
## Show that the .symtab_shndx section has the correct properties.
|
||||
## To avoid accidentally capturing the index of an unrelated section header for
|
||||
## checking the sh_link of the .symtab_shndx section, use the index of the
|
||||
## section immediately following the symbol table.
|
||||
# CHECK: Name: .symtab
|
||||
# CHECK-NEXT: Type: SHT_SYMTAB
|
||||
# CHECK: Index: [[#AFTERSYMTAB:]]
|
||||
# CHECK: Name: .symtab_shndx
|
||||
# CHECK-NEXT: Type: SHT_SYMTAB_SHNDX
|
||||
# CHECK-NEXT: Flags [ (0x0)
|
||||
# CHECK-NEXT: ]
|
||||
# CHECK-NEXT: Address: 0x0
|
||||
# CHECK-NEXT: Offset:
|
||||
## There should be #syms * EntrySize bytes.
|
||||
# CHECK-NEXT: Size: 262148
|
||||
# CHECK-NEXT: Link: [[#AFTERSYMTAB-1]]
|
||||
# CHECK-NEXT: Info: 0
|
||||
# CHECK-NEXT: AddressAlignment: 4
|
||||
# CHECK-NEXT: EntrySize: 4
|
||||
## Show that the sh_link of the first section header is the section header table
|
||||
## index. Also show that the last section is the .strtab.
|
||||
# CHECK: Index: [[#SHNUM-1]]
|
||||
# CHECK-NEXT: Name: .strtab
|
||||
|
||||
## Show that the symbols with section indexes around the reserved range still
|
||||
## have the right section indexes afterwards.
|
||||
# CHECK: Section: s65279 (0xFEFF)
|
||||
# CHECK-NEXT: }
|
||||
## st_shndx == SHN_LORSERVE.
|
||||
# CHECK-NEXT: Symbol {
|
||||
# CHECK-NEXT: Name: sym65280 (
|
||||
# CHECK-NEXT: Value: 0x0
|
||||
# CHECK-NEXT: Size: 0
|
||||
# CHECK-NEXT: Binding: Local (0x0)
|
||||
# CHECK-NEXT: Type: None (0x0)
|
||||
# CHECK-NEXT: Other: 0
|
||||
# CHECK-NEXT: Section: s65280 (0xFF00)
|
||||
# CHECK-NEXT: }
|
||||
## st_shndx == SHN_ABS.
|
||||
# CHECK: Name: sym65521 (
|
||||
# CHECK-NEXT: Value: 0x0
|
||||
# CHECK-NEXT: Size: 0
|
||||
# CHECK-NEXT: Binding: Local (0x0)
|
||||
# CHECK-NEXT: Type: None (0x0)
|
||||
# CHECK-NEXT: Other: 0
|
||||
# CHECK-NEXT: Section: s65521 (0xFFF1)
|
||||
# CHECK-NEXT: }
|
||||
## st_shndx == SHN_COMMON.
|
||||
# CHECK-NEXT: Symbol {
|
||||
# CHECK-NEXT: Name: sym65522 (
|
||||
# CHECK-NEXT: Value: 0x0
|
||||
# CHECK-NEXT: Size: 0
|
||||
# CHECK-NEXT: Binding: Local (0x0)
|
||||
# CHECK-NEXT: Type: None (0x0)
|
||||
# CHECK-NEXT: Other: 0
|
||||
# CHECK-NEXT: Section: s65522 (0xFFF2)
|
||||
# CHECK-NEXT: }
|
||||
## st_shndx == SHN_XINDEX.
|
||||
# CHECK: Name: sym65535 (
|
||||
# CHECK-NEXT: Value: 0x0
|
||||
# CHECK-NEXT: Size: 0
|
||||
# CHECK-NEXT: Binding: Local (0x0)
|
||||
# CHECK-NEXT: Type: None (0x0)
|
||||
# CHECK-NEXT: Other: 0
|
||||
# CHECK-NEXT: Section: s65535 (0xFFFF)
|
||||
# CHECK-NEXT: }
|
||||
## st_shndx > SHN_XINDEX.
|
||||
# CHECK-NEXT: Symbol {
|
||||
# CHECK-NEXT: Name: sym65536 (
|
||||
# CHECK-NEXT: Value: 0x0
|
||||
# CHECK-NEXT: Size: 0
|
||||
# CHECK-NEXT: Binding: Local (0x0)
|
||||
# CHECK-NEXT: Type: None (0x0)
|
||||
# CHECK-NEXT: Other: 0
|
||||
# CHECK-NEXT: Section: s65536 (0x10000)
|
||||
# CHECK-NEXT: }
|
||||
|
||||
# SYMS: Symbol table '.symtab' contains 65537 entries
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
RUN: %python %p/../Inputs/ungzip.py %p/Inputs/many-sections.o.gz > %t.0
|
||||
RUN: echo 'foo' > %t
|
||||
RUN: llvm-objcopy -R .text -R s0 -R s1 -R s2 -R s3 -R s4 -R s5 -R s6 %t.0 %t2
|
||||
RUN: llvm-objcopy -R 's65[3-9][0-9][0-9]' -R 's6529[0-9]' -R 's652[89][0-9]' %t.0 %t2
|
||||
RUN: llvm-objcopy --add-section=.s0=%t --add-section=.s1=%t --add-section=.s2=%t %t2 %t2
|
||||
RUN: llvm-readobj --sections %t2 | FileCheck --check-prefix=SECS %s
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user