154 lines · plain
1## Show that llvm-readobj/llvm-readelf tools sometimes can dump the2## dynamic table when it is not in a PT_DYNAMIC segment.3 4## Case 1: The dynamic table found using the dynamic program header is corrupted5## (<size of data> % <size of dynamic entry> != 0). So the table is taken6## from the section header.7 8# RUN: yaml2obj --docnum=1 %s -o %t1.o9# RUN: llvm-readobj --dynamic-table %t1.o 2>&1 \10# RUN: | FileCheck -DFILE=%t1.o --check-prefixes=WARNING1,LLVM1 %s11# RUN: llvm-readelf --dynamic-table %t1.o 2>&1 \12# RUN: | FileCheck -DFILE=%t1.o --check-prefixes=WARNING1,GNU1 %s13 14# WARNING1: warning: '[[FILE]]': SHT_DYNAMIC section with index 1 is not contained within the PT_DYNAMIC segment15# WARNING1: warning: '[[FILE]]': invalid PT_DYNAMIC size (0x1){{$}}16# WARNING1: warning: '[[FILE]]': SHT_DYNAMIC section header and PT_DYNAMIC program header disagree about the location of the dynamic table17# WARNING1: warning: '[[FILE]]': PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used18 19# LLVM1: DynamicSection [ (2 entries)20# LLVM1-NEXT: Tag Type Name/Value21# LLVM1-NEXT: 0x0000000000000018 BIND_NOW 0x122# LLVM1-NEXT: 0x0000000000000000 NULL 0x023# LLVM1-NEXT: ]24 25# GNU1: Dynamic section at offset 0x{{.*}} contains 2 entries:26# GNU1-NEXT: Tag Type Name/Value27# GNU1-NEXT: 0x0000000000000018 (BIND_NOW) 0x128# GNU1-NEXT: 0x0000000000000000 (NULL) 0x029 30--- !ELF31FileHeader:32 Class: ELFCLASS6433 Data: ELFDATA2LSB34 Type: ET_EXEC35Sections:36 - Name: .dynamic37 Type: SHT_DYNAMIC38 Flags: [SHF_ALLOC]39 Address: 0x100040 AddressAlign: 0x100041 Entries:42 - Tag: DT_BIND_NOW43 Value: 0x144 - Tag: DT_NULL45 Value: 0x046 - Name: .text47 Type: SHT_PROGBITS48 Flags: [SHF_ALLOC]49 Address: 0x110050 AddressAlign: 0x10051 Content: "00"52ProgramHeaders:53 - Type: PT_LOAD54 VAddr: 0x100055 FirstSec: .dynamic56 LastSec: .text57 - Type: PT_DYNAMIC58 VAddr: 0x100059 FirstSec: .text60 LastSec: .text61 62## Case 2: The dynamic table found using the dynamic program header is different from the63## table found using the section header table.64 65# RUN: yaml2obj --docnum=2 %s -o %t2.o66# RUN: llvm-readobj --dynamic-table %t2.o 2>&1 \67# RUN: | FileCheck -DFILE=%t2.o --check-prefixes=WARNING2,LLVM2 %s68# RUN: llvm-readelf --dynamic-table %t2.o 2>&1 \69# RUN: | FileCheck -DFILE=%t2.o --check-prefixes=WARNING2,GNU2 %s70 71# WARNING2: warning: '[[FILE]]': SHT_DYNAMIC section with index 1 is not contained within the PT_DYNAMIC segment72# WARNING2: warning: '[[FILE]]': SHT_DYNAMIC section header and PT_DYNAMIC program header disagree about the location of the dynamic table73 74# LLVM2: DynamicSection [ (1 entries)75# LLVM2-NEXT: Tag Type Name/Value76# LLVM2-NEXT: 0x0000000000000000 NULL 0x077# LLVM2-NEXT: ]78 79# GNU2: Dynamic section at offset 0x{{.*}} contains 1 entries:80# GNU2-NEXT: Tag Type Name/Value81# GNU2-NEXT: 0x0000000000000000 (NULL) 0x082 83--- !ELF84FileHeader:85 Class: ELFCLASS6486 Data: ELFDATA2LSB87 Type: ET_EXEC88Sections:89 - Name: .dynamic90 Type: SHT_DYNAMIC91 Flags: [SHF_ALLOC]92 Address: 0x100093 AddressAlign: 0x100094 Entries:95 - Tag: DT_BIND_NOW96 Value: 0x197 - Tag: DT_NULL98 Value: 0x099 - Name: .text100 Type: SHT_PROGBITS101 Flags: [SHF_ALLOC]102 Address: 0x1100103 AddressAlign: 0x100104 Content: "00000000000000000000000000000000"105ProgramHeaders:106 - Type: PT_LOAD107 VAddr: 0x1000108 FirstSec: .dynamic109 LastSec: .text110 - Type: PT_DYNAMIC111 VAddr: 0x1000112 FirstSec: .text113 LastSec: .text114 115## Case 3: Both dynamic tables found using SHT_DYNAMIC/PT_DYNAMIC are corrupted.116 117# RUN: yaml2obj --docnum=3 %s -o %t3.o118# RUN: llvm-readobj --dynamic-table %t3.o 2>&1 \119# RUN: | FileCheck -DFILE=%t3.o --check-prefix=WARNING3 --implicit-check-not="Dynamic" %s120# RUN: llvm-readelf --dynamic-table %t3.o 2>&1 \121# RUN: | FileCheck -DFILE=%t3.o --check-prefix=WARNING3 --implicit-check-not="Dynamic" %s122 123# WARNING3: warning: '[[FILE]]': invalid PT_DYNAMIC size (0x1){{$}}124# WARNING3: warning: '[[FILE]]': SHT_DYNAMIC section header and PT_DYNAMIC program header disagree about the location of the dynamic table125# WARNING3: warning: '[[FILE]]': no valid dynamic table was found126 127--- !ELF128FileHeader:129 Class: ELFCLASS64130 Data: ELFDATA2LSB131 Type: ET_EXEC132Sections:133 - Name: .dynamic134 Type: SHT_DYNAMIC135 Flags: [SHF_ALLOC]136 Address: 0x1000137 AddressAlign: 0x1000138 Content: "00"139 - Name: .text140 Type: SHT_PROGBITS141 Flags: [SHF_ALLOC]142 Address: 0x1100143 AddressAlign: 0x100144 Content: "00"145ProgramHeaders:146 - Type: PT_LOAD147 VAddr: 0x1000148 FirstSec: .dynamic149 LastSec: .text150 - Type: PT_DYNAMIC151 VAddr: 0x1000152 FirstSec: .text153 LastSec: .text154