1// REQUIRES: x86 2// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o 3// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared.s -o %t2.o 4// RUN: ld.lld --hash-style=sysv -shared %t2.o -soname=t2.so -o %t2.so 5// RUN: llvm-readobj -S %t2.so | FileCheck --check-prefix=SO %s 6// RUN: ld.lld --hash-style=sysv -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath foo -rpath bar --export-dynamic %t.o %t2.so -o %t 7// RUN: llvm-readobj -S -l --dynamic-table --symbols --dyn-syms --section-data --hash-table %t | FileCheck %s 8// RUN: ld.lld --hash-style=sysv %t.o %t2.so %t2.so -o %t2 9// RUN: llvm-readobj --dyn-syms %t2 | FileCheck --check-prefix=DONT_EXPORT %s 10 11// Make sure .symtab is properly aligned. 12// SO: Name: .symtab 13// SO-NEXT: Type: SHT_SYMTAB 14// SO-NEXT: Flags [ 15// SO-NEXT: ] 16// SO-NEXT: Address: 17// SO-NEXT: Offset: 0x1D0 18// SO-NEXT: Size: 19// SO-NEXT: Link: 20// SO-NEXT: Info: 21// SO-NEXT: AddressAlignment: 4 22 23// CHECK: Name: .interp 24// CHECK-NEXT: Type: SHT_PROGBITS 25// CHECK-NEXT: Flags [ 26// CHECK-NEXT: SHF_ALLOC 27// CHECK-NEXT: ] 28// CHECK-NEXT: Address: [[INTERPADDR:.*]] 29// CHECK-NEXT: Offset: [[INTERPOFFSET:.*]] 30// CHECK-NEXT: Size: [[INTERPSIZE:.*]] 31// CHECK-NEXT: Link: 0 32// CHECK-NEXT: Info: 0 33// CHECK-NEXT: AddressAlignment: 1 34// CHECK-NEXT: EntrySize: 0 35// CHECK-NEXT: SectionData ( 36// CHECK-NEXT: 0000: 2F6C6962 36342F6C 642D6C69 6E75782D |/lib64/ld-linux-| 37// CHECK-NEXT: 0010: 7838362D 36342E73 6F2E3200 |x86-64.so.2.| 38// CHECK-NEXT: ) 39// CHECK-NEXT: } 40 41// test that .hash is linked to .dynsym 42// CHECK: Index: 2 43// CHECK-NEXT: Name: .dynsym 44// CHECK-NEXT: Type: SHT_DYNSYM 45// CHECK-NEXT: Flags [ 46// CHECK-NEXT: SHF_ALLOC 47// CHECK-NEXT: ] 48// CHECK-NEXT: Address: [[DYNSYMADDR:.*]] 49// CHECK-NEXT: Offset: 0x170 50// CHECK-NEXT: Size: 51// CHECK-NEXT: Link: [[DYNSTR:.*]] 52// CHECK-NEXT: Info: 1 53// CHECK-NEXT: AddressAlignment: 4 54// CHECK-NEXT: EntrySize: 16 55// CHECK-NEXT: SectionData ( 56// CHECK-NEXT: 0000: 57// CHECK-NEXT: 0010: 58// CHECK-NEXT: 0020: 59// CHECK-NEXT: 0030: 60// CHECK-NEXT: ) 61// CHECK-NEXT: } 62// CHECK-NEXT: Section { 63// CHECK-NEXT: Index: 3 64// CHECK-NEXT: Name: .hash 65// CHECK-NEXT: Type: SHT_HASH 66// CHECK-NEXT: Flags [ 67// CHECK-NEXT: SHF_ALLOC 68// CHECK-NEXT: ] 69// CHECK-NEXT: Address: [[HASHADDR:.*]] 70// CHECK-NEXT: Offset: 71// CHECK-NEXT: Size: 72// CHECK-NEXT: Link: 2 73// CHECK-NEXT: Info: 0 74// CHECK-NEXT: AddressAlignment: 4 75// CHECK-NEXT: EntrySize: 4 76// CHECK: Section { 77// CHECK-NEXT: Index: [[DYNSTR]] 78// CHECK-NEXT: Name: .dynstr 79// CHECK-NEXT: Type: SHT_STRTAB 80// CHECK-NEXT: Flags [ 81// CHECK-NEXT: SHF_ALLOC 82// CHECK-NEXT: ] 83// CHECK-NEXT: Address: [[DYNSTRADDR:.*]] 84// CHECK-NEXT: Offset: 85// CHECK-NEXT: Size: 86// CHECK-NEXT: Link: 0 87// CHECK-NEXT: Info: 0 88// CHECK-NEXT: AddressAlignment: 1 89// CHECK-NEXT: EntrySize: 0 90 91// CHECK: Name: .rel.dyn 92// CHECK-NEXT: Type: SHT_REL 93// CHECK-NEXT: Flags [ 94// CHECK-NEXT: SHF_ALLOC 95// CHECK-NEXT: ] 96// CHECK-NEXT: Address: [[RELADDR:.*]] 97// CHECK-NEXT: Offset: 98// CHECK-NEXT: Size: [[RELSIZE:.*]] 99// CHECK-NEXT: Link: 100// CHECK-NEXT: Info: 101// CHECK-NEXT: AddressAlignment: 102// CHECK-NEXT: EntrySize: [[RELENT:.*]] 103 104// CHECK: Name: .dynamic 105// CHECK-NEXT: Type: SHT_DYNAMIC 106// CHECK-NEXT: Flags [ 107// CHECK-NEXT: SHF_ALLOC 108// CHECK-NEXT: SHF_WRITE 109// CHECK-NEXT: ] 110// CHECK-NEXT: Address: [[ADDR:.*]] 111// CHECK-NEXT: Offset: [[OFFSET:.*]] 112// CHECK-NEXT: Size: [[SIZE:.*]] 113// CHECK-NEXT: Link: [[DYNSTR]] 114// CHECK-NEXT: Info: 0 115// CHECK-NEXT: AddressAlignment: [[ALIGN:.*]] 116// CHECK-NEXT: EntrySize: 8 117// CHECK-NEXT: SectionData ( 118// CHECK: ) 119 120// CHECK: Name: .symtab 121// CHECK-NEXT: Type: SHT_SYMTAB 122// CHECK-NEXT: Flags [ 123// CHECK-NEXT: ] 124// CHECK-NEXT: Address: 125// CHECK-NEXT: Offset: 126// CHECK-NEXT: Size: 127// CHECK-NEXT: Link: 128// CHECK-NEXT: Info: 129// CHECK-NEXT: AddressAlignment: 130// CHECK-NEXT: EntrySize: [[SYMENT:.*]] 131 132// CHECK: ProgramHeaders [ 133// CHECK: Type: PT_INTERP 134// CHECK-NEXT: Offset: [[INTERPOFFSET]] 135// CHECK-NEXT: VirtualAddress: [[INTERPADDR]] 136// CHECK-NEXT: PhysicalAddress: [[INTERPADDR]] 137// CHECK-NEXT: FileSize: [[INTERPSIZE]] 138// CHECK-NEXT: MemSize: [[INTERPSIZE]] 139// CHECK-NEXT: Flags [ 140// CHECK-NEXT: PF_R 141// CHECK-NEXT: ] 142// CHECK-NEXT: Alignment: 1 143// CHECK-NEXT: } 144// CHECK: Type: PT_DYNAMIC 145// CHECK-NEXT: Offset: [[OFFSET]] 146// CHECK-NEXT: VirtualAddress: [[ADDR]] 147// CHECK-NEXT: PhysicalAddress: [[ADDR]] 148// CHECK-NEXT: FileSize: [[SIZE]] 149// CHECK-NEXT: MemSize: [[SIZE]] 150// CHECK-NEXT: Flags [ 151// CHECK-NEXT: PF_R 152// CHECK-NEXT: PF_W 153// CHECK-NEXT: ] 154// CHECK-NEXT: Alignment: [[ALIGN]] 155// CHECK-NEXT: } 156 157// CHECK: DynamicSection [ 158// CHECK-NEXT: Tag Type Name/Value 159// CHECK-NEXT: 0x0000001D RUNPATH Library runpath: [foo:bar] 160// CHECK-NEXT: 0x00000001 NEEDED Shared library: [{{.*}}2.so] 161// CHECK-NEXT: 0x00000015 DEBUG 0x0 162// CHECK-NEXT: 0x00000011 REL [[RELADDR]] 163// CHECK-NEXT: 0x00000012 RELSZ [[RELSIZE]] (bytes) 164// CHECK-NEXT: 0x00000013 RELENT [[RELENT]] (bytes) 165// CHECK-NEXT: 0x00000006 SYMTAB [[DYNSYMADDR]] 166// CHECK-NEXT: 0x0000000B SYMENT [[SYMENT]] (bytes) 167// CHECK-NEXT: 0x00000005 STRTAB [[DYNSTRADDR]] 168// CHECK-NEXT: 0x0000000A STRSZ 169// CHECK-NEXT: 0x00000004 HASH [[HASHADDR]] 170// CHECK-NEXT: 0x00000000 NULL 0x0 171// CHECK-NEXT: ] 172 173// CHECK: Symbols [ 174// CHECK-NEXT: Symbol { 175// CHECK-NEXT: Name: 176// CHECK-NEXT: Value: 0x0 177// CHECK-NEXT: Size: 0 178// CHECK-NEXT: Binding: Local 179// CHECK-NEXT: Type: None 180// CHECK-NEXT: Other: 0 181// CHECK-NEXT: Section: Undefined 182// CHECK-NEXT: } 183// CHECK-NEXT: Symbol { 184// CHECK-NEXT: Name: _DYNAMIC 185// CHECK-NEXT: Value: 0x402210 186// CHECK-NEXT: Size: 0 187// CHECK-NEXT: Binding: Local 188// CHECK-NEXT: Type: None 189// CHECK-NEXT: Other [ (0x2) 190// CHECK-NEXT: STV_HIDDEN 191// CHECK-NEXT: ] 192// CHECK-NEXT: Section: .dynamic 193// CHECK-NEXT: } 194// CHECK-NEXT: Symbol { 195// CHECK-NEXT: Name: _start 196// CHECK-NEXT: Value: 0x401208 197// CHECK-NEXT: Size: 0 198// CHECK-NEXT: Binding: Global 199// CHECK-NEXT: Type: None 200// CHECK-NEXT: Other: 0 201// CHECK-NEXT: Section: .text 202// CHECK-NEXT: } 203// CHECK-NEXT: Symbol { 204// CHECK-NEXT: Name: bar 205// CHECK-NEXT: Value: 0x0 206// CHECK-NEXT: Size: 0 207// CHECK-NEXT: Binding: Global 208// CHECK-NEXT: Type: Function 209// CHECK-NEXT: Other: 0 210// CHECK-NEXT: Section: Undefined 211// CHECK-NEXT: } 212// CHECK-NEXT: Symbol { 213// CHECK-NEXT: Name: zed 214// CHECK-NEXT: Value: 0x0 215// CHECK-NEXT: Size: 0 216// CHECK-NEXT: Binding: Global (0x1) 217// CHECK-NEXT: Type: None (0x0) 218// CHECK-NEXT: Other: 0 219// CHECK-NEXT: Section: Undefined (0x0) 220// CHECK-NEXT: } 221// CHECK-NEXT: ] 222 223// CHECK: DynamicSymbols [ 224// CHECK-NEXT: Symbol { 225// CHECK-NEXT: Name: 226// CHECK-NEXT: Value: 0x0 227// CHECK-NEXT: Size: 0 228// CHECK-NEXT: Binding: Local 229// CHECK-NEXT: Type: None 230// CHECK-NEXT: Other: 0 231// CHECK-NEXT: Section: Undefined 232// CHECK-NEXT: } 233// CHECK-NEXT: Symbol { 234// CHECK-NEXT: Name: _start 235// CHECK-NEXT: Value: 0x401208 236// CHECK-NEXT: Size: 0 237// CHECK-NEXT: Binding: Global 238// CHECK-NEXT: Type: Non 239// CHECK-NEXT: Other: 0 240// CHECK-NEXT: Section: .text 241// CHECK-NEXT: } 242// CHECK-NEXT: Symbol { 243// CHECK-NEXT: Name: bar 244// CHECK-NEXT: Value: 0x0 245// CHECK-NEXT: Size: 0 246// CHECK-NEXT: Binding: Global 247// CHECK-NEXT: Type: Function 248// CHECK-NEXT: Other: 0 249// CHECK-NEXT: Section: Undefined 250// CHECK-NEXT: } 251// CHECK-NEXT: Symbol { 252// CHECK-NEXT: Name: zed 253// CHECK-NEXT: Value: 0x0 254// CHECK-NEXT: Size: 0 255// CHECK-NEXT: Binding: Global 256// CHECK-NEXT: Type: None 257// CHECK-NEXT: Other: 0 258// CHECK-NEXT: Section: Undefined 259// CHECK-NEXT: } 260// CHECK-NEXT: ] 261 262// DONT_EXPORT: DynamicSymbols [ 263// DONT_EXPORT-NEXT: Symbol { 264// DONT_EXPORT-NEXT: Name: 265// DONT_EXPORT-NEXT: Value: 0x0 266// DONT_EXPORT-NEXT: Size: 0 267// DONT_EXPORT-NEXT: Binding: Local (0x0) 268// DONT_EXPORT-NEXT: Type: None (0x0) 269// DONT_EXPORT-NEXT: Other: 0 270// DONT_EXPORT-NEXT: Section: Undefined (0x0) 271// DONT_EXPORT-NEXT: } 272// DONT_EXPORT-NEXT: Symbol { 273// DONT_EXPORT-NEXT: Name: bar 274// DONT_EXPORT-NEXT: Value: 0x0 275// DONT_EXPORT-NEXT: Size: 0 276// DONT_EXPORT-NEXT: Binding: Global 277// DONT_EXPORT-NEXT: Type: Function 278// DONT_EXPORT-NEXT: Other: 0 279// DONT_EXPORT-NEXT: Section: Undefined 280// DONT_EXPORT-NEXT: } 281// DONT_EXPORT-NEXT: Symbol { 282// DONT_EXPORT-NEXT: Name: zed 283// DONT_EXPORT-NEXT: Value: 0x0 284// DONT_EXPORT-NEXT: Size: 0 285// DONT_EXPORT-NEXT: Binding: Global 286// DONT_EXPORT-NEXT: Type: None 287// DONT_EXPORT-NEXT: Other: 0 288// DONT_EXPORT-NEXT: Section: Undefined 289// DONT_EXPORT-NEXT: } 290// DONT_EXPORT-NEXT: ] 291 292// CHECK: HashTable { 293// CHECK-NEXT: Num Buckets: 4 294// CHECK-NEXT: Num Chains: 4 295// CHECK-NEXT: Buckets: [3, 0, 2, 0] 296// CHECK-NEXT: Chains: [0, 0, 0, 1] 297// CHECK-NEXT: } 298 299.global _start 300_start: 301.long bar@GOT 302.long zed@GOT 303