Index: llvm/test/Object/no-section-table.test =================================================================== --- llvm/test/Object/no-section-table.test +++ /dev/null @@ -1,36 +0,0 @@ -RUN: llvm-readobj %p/Inputs/no-section-table.so -hash-table -dynamic-table \ -RUN: | FileCheck %s - -CHECK: DynamicSection [ (24 entries) -CHECK: Tag Type Name/Value -CHECK: 0x0000000000000001 NEEDED Shared library: [libc.so.6] -CHECK: 0x000000000000000C INIT 0x4B8 -CHECK: 0x000000000000000D FINI 0x618 -CHECK: 0x0000000000000019 INIT_ARRAY 0x2006C0 -CHECK: 0x000000000000001B INIT_ARRAYSZ 8 (bytes) -CHECK: 0x000000000000001A FINI_ARRAY 0x2006C8 -CHECK: 0x000000000000001C FINI_ARRAYSZ 8 (bytes) -CHECK: 0x0000000000000004 HASH 0x158 -CHECK: 0x0000000000000005 STRTAB 0x2D8 -CHECK: 0x0000000000000006 SYMTAB 0x1A0 -CHECK: 0x000000000000000A STRSZ 179 (bytes) -CHECK: 0x000000000000000B SYMENT 24 (bytes) -CHECK: 0x0000000000000003 PLTGOT 0x2008C0 -CHECK: 0x0000000000000002 PLTRELSZ 48 (bytes) -CHECK: 0x0000000000000014 PLTREL RELA -CHECK: 0x0000000000000017 JMPREL 0x488 -CHECK: 0x0000000000000007 RELA 0x3C8 -CHECK: 0x0000000000000008 RELASZ 192 (bytes) -CHECK: 0x0000000000000009 RELAENT 24 (bytes) -CHECK: 0x000000006FFFFFFE VERNEED 0x3A8 -CHECK: 0x000000006FFFFFFF VERNEEDNUM 1 -CHECK: 0x000000006FFFFFF0 VERSYM 0x38C -CHECK: 0x000000006FFFFFF9 RELACOUNT 3 -CHECK: 0x0000000000000000 NULL 0x0 -CHECK: ] -CHECK: HashTable { -CHECK: Num Buckets: 3 -CHECK: Num Chains: 13 -CHECK: Buckets: [12, 10, 11] -CHECK: Chains: [0, 0, 0, 0, 2, 3, 4, 0, 7, 5, 6, 8, 9] -CHECK: } Index: llvm/test/tools/llvm-readobj/ELF/hash-table.test =================================================================== --- /dev/null +++ llvm/test/tools/llvm-readobj/ELF/hash-table.test @@ -0,0 +1,117 @@ +## Check how the SHT_HASH section is dumped with --hash-table. + +# RUN: yaml2obj --docnum=1 %s -o %t.x64 +# RUN: yaml2obj --docnum=2 %s -o %t.x32 + +# RUN: llvm-readobj --hash-table %t.x64 | FileCheck %s --check-prefix=HASH +# RUN: llvm-readelf --hash-table %t.x64 | FileCheck %s --check-prefix=HASH + +# RUN: llvm-readobj --hash-table %t.x32 | FileCheck %s --check-prefix=HASH +# RUN: llvm-readelf --hash-table %t.x32 | FileCheck %s --check-prefix=HASH + +# HASH: HashTable { +# HASH-NEXT: Num Buckets: 2 +# HASH-NEXT: Num Chains: 3 +# HASH-NEXT: Buckets: [1, 2] +# HASH-NEXT: Chains: [3, 4, 5] +# HASH-NEXT: } + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .hash + Type: SHT_HASH + Flags: [ SHF_ALLOC ] + Bucket: [ 1, 2 ] + Chain: [ 3, 4, 5 ] + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Entries: + - Tag: DT_HASH + Value: 0x0 + - Tag: DT_NULL + Value: 0x0 +ProgramHeaders: + - Type: PT_LOAD + Sections: + - Section: .hash + - Section: .dynamic + +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_386 +Sections: + - Name: .hash + Type: SHT_HASH + Flags: [ SHF_ALLOC ] + Bucket: [ 1, 2 ] + Chain: [ 3, 4, 5 ] + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Entries: + - Tag: DT_HASH + Value: 0x0 + - Tag: DT_NULL + Value: 0x0 +ProgramHeaders: + - Type: PT_LOAD + Sections: + - Section: .hash + - Section: .dynamic + +## Check we can dump the SHT_HASH section even when an object +## does not have the section header table. + +# RUN: yaml2obj --docnum=3 %s -o %t.noshdr +# RUN: llvm-readobj --hash-table %t.noshdr | FileCheck %s --check-prefix=NOSHDR +# RUN: llvm-readelf --hash-table %t.noshdr | FileCheck %s --check-prefix=NOSHDR + +# NOSHDR: HashTable { +# NOSHDR-NEXT: Num Buckets: 1 +# NOSHDR-NEXT: Num Chains: 1 +# NOSHDR-NEXT: Buckets: [0] +# NOSHDR-NEXT: Chains: [1] +# NOSHDR-NEXT: } + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +## We simulate no section header table by +## overriding the ELF header properties. + SHOff: 0x0 + SHNum: 0 +Sections: + - Name: .hash + Type: SHT_HASH + Flags: [ SHF_ALLOC ] + Bucket: [ 0 ] + Chain: [ 1 ] + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_ALLOC ] + Entries: + - Tag: DT_HASH + Value: 0x0 + - Tag: DT_NULL + Value: 0x0 +ProgramHeaders: + - Type: PT_LOAD + Sections: + - Section: .hash + - Section: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1010 + Sections: + - Section: .dynamic