164 lines · plain
1## Show that llvm-readobj/llvm-readelf tools can dump the .dynamic section which2## is not alone in PT_DYNAMIC segment.3 4## In the first case .text is placed before .dynamic.5## We check that we warn about this case.6 7# RUN: yaml2obj --docnum=1 %s -o %t1.o8# RUN: llvm-readobj --dynamic-table %t1.o 2>&1 \9# RUN: | FileCheck %s --DFILE=%t1.o --check-prefixes=WARNING,LLVM10# RUN: llvm-readelf --dynamic-table %t1.o 2>&1 \11# RUN: | FileCheck %s --DFILE=%t1.o --check-prefixes=WARNING,GNU12 13# WARNING: warning: '[[FILE]]': SHT_DYNAMIC section with index 2 is not at the start of PT_DYNAMIC segment14# WARNING: warning: '[[FILE]]': invalid PT_DYNAMIC size (0x21){{$}}15# WARNING: warning: '[[FILE]]': SHT_DYNAMIC section header and PT_DYNAMIC program header disagree about the location of the dynamic table16# WARNING: warning: '[[FILE]]': PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used17 18# LLVM: DynamicSection [ (2 entries)19# LLVM-NEXT: Tag Type Name/Value20# LLVM-NEXT: 0x0000000000000018 BIND_NOW 0x121# LLVM-NEXT: 0x0000000000000000 NULL 0x022# LLVM-NEXT: ]23 24# GNU: Dynamic section at offset 0x{{.*}} contains 2 entries:25# GNU-NEXT: Tag Type Name/Value26# GNU-NEXT: 0x0000000000000018 (BIND_NOW) 0x127# GNU-NEXT: 0x0000000000000000 (NULL) 0x028 29--- !ELF30FileHeader:31 Class: ELFCLASS6432 Data: ELFDATA2LSB33 Type: ET_EXEC34Sections:35 - Name: .text36 Type: SHT_PROGBITS37 Flags: [SHF_ALLOC]38 Address: 0x100039 AddressAlign: 0x10040 Content: "00"41 - Name: .dynamic42 Type: SHT_DYNAMIC43 Flags: [SHF_ALLOC]44 Address: 0x100145 Entries:46 - Tag: DT_BIND_NOW47 Value: 0x148 - Tag: DT_NULL49 Value: 0x050ProgramHeaders:51 - Type: PT_LOAD52 VAddr: 0x100053 FirstSec: .text54 LastSec: .dynamic55 - Type: PT_DYNAMIC56 VAddr: 0x100057 FirstSec: .text58 LastSec: .dynamic59 60## In this case .text goes after .dynamic and we don't display any warnings,61## though the content of the .text is used for dumping the dynamic table.62 63# RUN: yaml2obj --docnum=2 %s -o %t2.o64# RUN: llvm-readobj --dynamic-table %t2.o 2>&1 | FileCheck %s --check-prefix=LLVM265# RUN: llvm-readelf --dynamic-table %t2.o 2>&1 | FileCheck %s --check-prefix=GNU266 67# LLVM2: DynamicSection [ (3 entries)68# LLVM2-NEXT: Tag Type Name/Value69# LLVM2-NEXT: 0x0000000000000018 BIND_NOW 0x170# LLVM2-NEXT: 0x0000000000000018 BIND_NOW 0x271# LLVM2-NEXT: 0x0000000000000000 NULL 0x072# LLVM2-NEXT: ]73 74# GNU2: Dynamic section at offset 0x{{.*}} contains 3 entries:75# GNU2-NEXT: Tag Type Name/Value76# GNU2-NEXT: 0x0000000000000018 (BIND_NOW) 0x177# GNU2-NEXT: 0x0000000000000018 (BIND_NOW) 0x278# GNU2-NEXT: 0x0000000000000000 (NULL) 0x079 80--- !ELF81FileHeader:82 Class: ELFCLASS6483 Data: ELFDATA2LSB84 Type: ET_EXEC85Sections:86 - Name: .dynamic87 Type: SHT_DYNAMIC88 Flags: [SHF_ALLOC]89 Address: 0x100090 AddressAlign: 0x100091 Entries:92 - Tag: DT_BIND_NOW93 Value: 0x194 - Tag: DT_BIND_NOW95 Value: 0x296 - Name: .text97 Type: SHT_PROGBITS98 Flags: [SHF_ALLOC]99 Address: 0x1100100 AddressAlign: 0x100101 Content: "00000000000000000000000000000000"102ProgramHeaders:103 - Type: PT_LOAD104 VAddr: 0x1000105 FirstSec: .dynamic106 LastSec: .text107 - Type: PT_DYNAMIC108 VAddr: 0x1000109 FirstSec: .dynamic110 LastSec: .text111 112## In this case .text goes after .dynamic, but (PT_DYNAMIC segment size % dynamic entry size != 0)113## and we have to use the information from the section header instead.114 115# RUN: yaml2obj --docnum=3 %s -o %t3.o116# RUN: llvm-readobj --dynamic-table %t3.o 2>&1 | FileCheck %s --DFILE=%t3.o --check-prefixes=WARNING2,LLVM3117# RUN: llvm-readelf --dynamic-table %t3.o 2>&1 | FileCheck %s --DFILE=%t3.o --check-prefixes=WARNING2,GNU3118 119# WARNING2: warning: '[[FILE]]': invalid PT_DYNAMIC size (0x101){{$}}120# WARNING2: warning: '[[FILE]]': PT_DYNAMIC dynamic table is invalid: SHT_DYNAMIC will be used121 122# LLVM3: DynamicSection [ (2 entries)123# LLVM3-NEXT: Tag Type Name/Value124# LLVM3-NEXT: 0x0000000000000018 BIND_NOW 0x1125# LLVM3-NEXT: 0x0000000000000000 NULL 0x0126# LLVM3-NEXT: ]127 128# GNU3: Dynamic section at offset 0x{{.*}} contains 2 entries:129# GNU3-NEXT: Tag Type Name/Value130# GNU3-NEXT: 0x0000000000000018 (BIND_NOW) 0x1131# GNU3-NEXT: 0x0000000000000000 (NULL) 0x0132 133--- !ELF134FileHeader:135 Class: ELFCLASS64136 Data: ELFDATA2LSB137 Type: ET_EXEC138Sections:139 - Name: .dynamic140 Type: SHT_DYNAMIC141 Flags: [SHF_ALLOC]142 Address: 0x1000143 AddressAlign: 0x1000144 Entries:145 - Tag: DT_BIND_NOW146 Value: 0x1147 - Tag: DT_NULL148 Value: 0x0149 - Name: .text150 Type: SHT_PROGBITS151 Flags: [SHF_ALLOC]152 Address: 0x1100153 AddressAlign: 0x100154 Content: "00"155ProgramHeaders:156 - Type: PT_LOAD157 VAddr: 0x1000158 FirstSec: .dynamic159 LastSec: .text160 - Type: PT_DYNAMIC161 VAddr: 0x1000162 FirstSec: .dynamic163 LastSec: .text164