2015-09-08 23:50:05 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o
|
2015-09-12 06:42:45 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared.s -o %t2.o
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %t2.o -o %t2.so
|
2015-09-15 03:00:35 +08:00
|
|
|
// RUN: llvm-readobj -s %t2.so | FileCheck --check-prefix=SO %s
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath foo -rpath bar --export-dynamic %t.o %t2.so -o %t
|
2015-09-15 06:08:55 +08:00
|
|
|
// RUN: llvm-readobj --program-headers --dynamic-table -t -s -dyn-symbols -section-data -hash-table %t | FileCheck %s
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld %t.o %t2.so %t2.so -o %t2
|
2015-09-23 07:38:23 +08:00
|
|
|
// RUN: llvm-readobj -dyn-symbols %t2 | FileCheck --check-prefix=DONT_EXPORT %s
|
2015-09-08 23:50:05 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
|
2015-09-15 03:00:35 +08:00
|
|
|
// Make sure .symtab is properly aligned.
|
|
|
|
// SO: Name: .symtab
|
|
|
|
// SO-NEXT: Type: SHT_SYMTAB
|
|
|
|
// SO-NEXT: Flags [
|
|
|
|
// SO-NEXT: ]
|
|
|
|
// SO-NEXT: Address:
|
2015-10-11 07:25:39 +08:00
|
|
|
// SO-NEXT: Offset: 0x1030
|
2015-09-15 03:00:35 +08:00
|
|
|
// SO-NEXT: Size:
|
|
|
|
// SO-NEXT: Link:
|
|
|
|
// SO-NEXT: Info:
|
|
|
|
// SO-NEXT: AddressAlignment: 4
|
|
|
|
|
2015-09-12 02:49:42 +08:00
|
|
|
// CHECK: Name: .interp
|
|
|
|
// CHECK-NEXT: Type: SHT_PROGBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address: [[INTERPADDR:.*]]
|
|
|
|
// CHECK-NEXT: Offset: [[INTERPOFFSET:.*]]
|
|
|
|
// CHECK-NEXT: Size: [[INTERPSIZE:.*]]
|
|
|
|
// CHECK-NEXT: Link: 0
|
|
|
|
// CHECK-NEXT: Info: 0
|
|
|
|
// CHECK-NEXT: AddressAlignment: 1
|
|
|
|
// CHECK-NEXT: EntrySize: 0
|
|
|
|
// CHECK-NEXT: SectionData (
|
|
|
|
// CHECK-NEXT: 0000: 2F6C6962 36342F6C 642D6C69 6E75782D |/lib64/ld-linux-|
|
|
|
|
// CHECK-NEXT: 0010: 7838362D 36342E73 6F2E3200 |x86-64.so.2.|
|
|
|
|
// CHECK-NEXT: )
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
2015-09-15 06:08:55 +08:00
|
|
|
// test that .hash is linked to .dynsym
|
2015-10-02 05:15:02 +08:00
|
|
|
// CHECK: Index: 2
|
2015-09-15 06:08:55 +08:00
|
|
|
// CHECK-NEXT: Name: .dynsym
|
2015-09-11 09:14:39 +08:00
|
|
|
// CHECK-NEXT: Type: SHT_DYNSYM
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address: [[DYNSYMADDR:.*]]
|
2015-11-25 02:48:16 +08:00
|
|
|
// CHECK-NEXT: Offset: 0x150
|
2015-09-23 01:49:38 +08:00
|
|
|
// CHECK-NEXT: Size:
|
2015-09-12 01:53:01 +08:00
|
|
|
// CHECK-NEXT: Link: [[DYNSTR:.*]]
|
2015-09-11 09:14:39 +08:00
|
|
|
// CHECK-NEXT: Info: 1
|
|
|
|
// CHECK-NEXT: AddressAlignment: 4
|
|
|
|
// CHECK-NEXT: EntrySize: 16
|
2015-09-12 02:49:42 +08:00
|
|
|
// CHECK-NEXT: SectionData (
|
|
|
|
// CHECK-NEXT: 0000:
|
|
|
|
// CHECK-NEXT: 0010:
|
|
|
|
// CHECK-NEXT: 0020:
|
2015-09-23 01:49:38 +08:00
|
|
|
// CHECK-NEXT: 0030:
|
2015-09-12 02:49:42 +08:00
|
|
|
// CHECK-NEXT: )
|
2015-09-11 09:14:39 +08:00
|
|
|
// CHECK-NEXT: }
|
2015-09-15 06:08:55 +08:00
|
|
|
// CHECK-NEXT: Section {
|
2015-10-02 05:15:02 +08:00
|
|
|
// CHECK-NEXT: Index: 3
|
2015-09-15 06:08:55 +08:00
|
|
|
// CHECK-NEXT: Name: .hash
|
|
|
|
// CHECK-NEXT: Type: SHT_HASH
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address: [[HASHADDR:.*]]
|
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size:
|
2015-10-02 05:15:02 +08:00
|
|
|
// CHECK-NEXT: Link: 2
|
2015-09-15 06:08:55 +08:00
|
|
|
// CHECK-NEXT: Info: 0
|
|
|
|
// CHECK-NEXT: AddressAlignment: 4
|
|
|
|
// CHECK-NEXT: EntrySize: 4
|
|
|
|
|
2015-09-09 23:33:08 +08:00
|
|
|
// CHECK: Index: [[DYNSTR]]
|
|
|
|
// CHECK-NEXT: Name: .dynstr
|
2015-09-09 03:43:27 +08:00
|
|
|
// CHECK-NEXT: Type: SHT_STRTAB
|
|
|
|
// CHECK-NEXT: Flags [
|
2015-09-09 23:33:08 +08:00
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
2015-09-09 03:43:27 +08:00
|
|
|
// CHECK-NEXT: ]
|
2015-09-09 23:33:08 +08:00
|
|
|
// CHECK-NEXT: Address: [[DYNSTRADDR:.*]]
|
2015-09-09 03:43:27 +08:00
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size:
|
|
|
|
// CHECK-NEXT: Link: 0
|
|
|
|
// CHECK-NEXT: Info: 0
|
|
|
|
// CHECK-NEXT: AddressAlignment: 1
|
|
|
|
// CHECK-NEXT: EntrySize: 0
|
2015-09-12 02:49:42 +08:00
|
|
|
// CHECK-NEXT: SectionData (
|
2015-09-12 03:12:37 +08:00
|
|
|
// CHECK: )
|
2015-09-09 03:43:27 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
2015-09-17 22:02:10 +08:00
|
|
|
// CHECK: Name: .rel.dyn
|
|
|
|
// CHECK-NEXT: Type: SHT_REL
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address: [[RELADDR:.*]]
|
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size: [[RELSIZE:.*]]
|
2015-10-01 05:57:53 +08:00
|
|
|
// CHECK-NEXT: Link:
|
|
|
|
// CHECK-NEXT: Info:
|
|
|
|
// CHECK-NEXT: AddressAlignment:
|
|
|
|
// CHECK-NEXT: EntrySize: [[RELENT:.*]]
|
2015-09-17 22:02:10 +08:00
|
|
|
|
2015-10-02 05:15:02 +08:00
|
|
|
// CHECK: Name: .dynamic
|
|
|
|
// CHECK-NEXT: Type: SHT_DYNAMIC
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_WRITE
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address: [[ADDR:.*]]
|
|
|
|
// CHECK-NEXT: Offset: [[OFFSET:.*]]
|
|
|
|
// CHECK-NEXT: Size: [[SIZE:.*]]
|
|
|
|
// CHECK-NEXT: Link: [[DYNSTR]]
|
|
|
|
// CHECK-NEXT: Info: 0
|
|
|
|
// CHECK-NEXT: AddressAlignment: [[ALIGN:.*]]
|
|
|
|
// CHECK-NEXT: EntrySize: 8
|
|
|
|
// CHECK-NEXT: SectionData (
|
|
|
|
// CHECK: )
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
2015-10-01 05:57:53 +08:00
|
|
|
// CHECK: Name: .symtab
|
|
|
|
// CHECK-NEXT: Type: SHT_SYMTAB
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address:
|
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size:
|
|
|
|
// CHECK-NEXT: Link:
|
|
|
|
// CHECK-NEXT: Info:
|
|
|
|
// CHECK-NEXT: AddressAlignment:
|
|
|
|
// CHECK-NEXT: EntrySize: [[SYMENT:.*]]
|
2015-09-09 03:43:27 +08:00
|
|
|
|
2015-09-08 23:50:05 +08:00
|
|
|
// CHECK: Symbols [
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name:
|
|
|
|
// CHECK-NEXT: Value: 0x0
|
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: Undefined
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
2016-03-02 00:23:13 +08:00
|
|
|
// CHECK-NEXT: Name: _DYNAMIC
|
|
|
|
// CHECK-NEXT: Value: 0x12000
|
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
2016-03-25 00:30:20 +08:00
|
|
|
// CHECK-NEXT: Other [ (0x2)
|
|
|
|
// CHECK-NEXT: STV_HIDDEN
|
|
|
|
// CHECK-NEXT: ]
|
2016-03-02 00:23:13 +08:00
|
|
|
// CHECK-NEXT: Section: .dynamic
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
2015-09-08 23:50:05 +08:00
|
|
|
// CHECK-NEXT: Name: _start
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: Value: 0x11000
|
2015-09-08 23:50:05 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: None
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .text
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: bar
|
|
|
|
// CHECK-NEXT: Value: 0x0
|
2015-09-11 08:30:13 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Function
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: Undefined
|
|
|
|
// CHECK-NEXT: }
|
2015-09-23 01:49:38 +08:00
|
|
|
// CHECK-NEXT: Symbol {
|
2015-10-21 01:21:35 +08:00
|
|
|
// CHECK-NEXT: Name: zed
|
2015-09-23 01:49:38 +08:00
|
|
|
// CHECK-NEXT: Value: 0x0
|
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global (0x1)
|
|
|
|
// CHECK-NEXT: Type: None (0x0)
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: Undefined (0x0)
|
|
|
|
// CHECK-NEXT: }
|
2015-09-11 08:30:13 +08:00
|
|
|
// CHECK-NEXT: ]
|
|
|
|
|
|
|
|
// CHECK: DynamicSymbols [
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: @ (0)
|
|
|
|
// CHECK-NEXT: Value: 0x0
|
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: Undefined
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: _start@
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: Value: 0x11000
|
2015-09-11 08:30:13 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Non
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .text
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: bar@
|
|
|
|
// CHECK-NEXT: Value: 0x0
|
2015-09-08 23:50:05 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Function
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: Undefined
|
|
|
|
// CHECK-NEXT: }
|
2015-09-23 01:49:38 +08:00
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: zed@
|
|
|
|
// CHECK-NEXT: Value: 0x0
|
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: None
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: Undefined
|
|
|
|
// CHECK-NEXT: }
|
2015-09-08 23:50:05 +08:00
|
|
|
// CHECK-NEXT: ]
|
|
|
|
|
2015-09-23 07:38:23 +08:00
|
|
|
// DONT_EXPORT: DynamicSymbols [
|
|
|
|
// DONT_EXPORT-NEXT: Symbol {
|
|
|
|
// DONT_EXPORT-NEXT: Name: @ (0)
|
|
|
|
// DONT_EXPORT-NEXT: Value: 0x0
|
|
|
|
// DONT_EXPORT-NEXT: Size: 0
|
|
|
|
// DONT_EXPORT-NEXT: Binding: Local (0x0)
|
|
|
|
// DONT_EXPORT-NEXT: Type: None (0x0)
|
|
|
|
// DONT_EXPORT-NEXT: Other: 0
|
|
|
|
// DONT_EXPORT-NEXT: Section: Undefined (0x0)
|
|
|
|
// DONT_EXPORT-NEXT: }
|
|
|
|
// DONT_EXPORT-NEXT: Symbol {
|
|
|
|
// DONT_EXPORT-NEXT: Name: bar@
|
|
|
|
// DONT_EXPORT-NEXT: Value: 0x0
|
|
|
|
// DONT_EXPORT-NEXT: Size: 0
|
|
|
|
// DONT_EXPORT-NEXT: Binding: Global
|
|
|
|
// DONT_EXPORT-NEXT: Type: Function
|
|
|
|
// DONT_EXPORT-NEXT: Other: 0
|
|
|
|
// DONT_EXPORT-NEXT: Section: Undefined
|
|
|
|
// DONT_EXPORT-NEXT: }
|
|
|
|
// DONT_EXPORT-NEXT: Symbol {
|
|
|
|
// DONT_EXPORT-NEXT: Name: zed@
|
|
|
|
// DONT_EXPORT-NEXT: Value: 0x0
|
|
|
|
// DONT_EXPORT-NEXT: Size: 0
|
|
|
|
// DONT_EXPORT-NEXT: Binding: Global
|
|
|
|
// DONT_EXPORT-NEXT: Type: None
|
|
|
|
// DONT_EXPORT-NEXT: Other: 0
|
2015-09-23 07:42:55 +08:00
|
|
|
// DONT_EXPORT-NEXT: Section: Undefined
|
2015-09-23 07:38:23 +08:00
|
|
|
// DONT_EXPORT-NEXT: }
|
|
|
|
// DONT_EXPORT-NEXT: ]
|
|
|
|
|
2015-09-09 23:33:08 +08:00
|
|
|
// CHECK: DynamicSection [
|
|
|
|
// CHECK-NEXT: Tag Type Name/Value
|
2016-01-29 09:24:25 +08:00
|
|
|
// CHECK-NEXT: 0x0000001D RUNPATH foo:bar
|
|
|
|
// CHECK-NEXT: 0x00000001 NEEDED SharedLibrary ({{.*}}2.so)
|
2015-09-17 22:02:10 +08:00
|
|
|
// CHECK-NEXT: 0x00000011 REL [[RELADDR]]
|
|
|
|
// CHECK-NEXT: 0x00000012 RELSZ [[RELSIZE]] (bytes)
|
2015-10-01 05:57:53 +08:00
|
|
|
// CHECK-NEXT: 0x00000013 RELENT [[RELENT]] (bytes)
|
2015-09-11 09:14:39 +08:00
|
|
|
// CHECK-NEXT: 0x00000006 SYMTAB [[DYNSYMADDR]]
|
2015-10-01 05:57:53 +08:00
|
|
|
// CHECK-NEXT: 0x0000000B SYMENT [[SYMENT]] (bytes)
|
2015-09-09 23:33:08 +08:00
|
|
|
// CHECK-NEXT: 0x00000005 STRTAB [[DYNSTRADDR]]
|
2015-09-10 04:26:23 +08:00
|
|
|
// CHECK-NEXT: 0x0000000A STRSZ
|
2015-09-15 06:08:55 +08:00
|
|
|
// CHECK-NEXT: 0x00000004 HASH [[HASHADDR]]
|
2016-01-06 23:52:27 +08:00
|
|
|
// CHECK-NEXT: 0x00000015 DEBUG 0x0
|
2015-09-09 23:33:08 +08:00
|
|
|
// CHECK-NEXT: 0x00000000 NULL 0x0
|
|
|
|
// CHECK-NEXT: ]
|
2015-09-09 06:55:28 +08:00
|
|
|
|
2015-10-09 23:31:49 +08:00
|
|
|
// CHECK: ProgramHeaders [
|
|
|
|
// CHECK: Type: PT_INTERP
|
2015-09-12 02:49:42 +08:00
|
|
|
// CHECK-NEXT: Offset: [[INTERPOFFSET]]
|
|
|
|
// CHECK-NEXT: VirtualAddress: [[INTERPADDR]]
|
|
|
|
// CHECK-NEXT: PhysicalAddress: [[INTERPADDR]]
|
|
|
|
// CHECK-NEXT: FileSize: [[INTERPSIZE]]
|
|
|
|
// CHECK-NEXT: MemSize: [[INTERPSIZE]]
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: PF_R
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Alignment: 1
|
|
|
|
// CHECK-NEXT: }
|
2015-09-09 06:55:28 +08:00
|
|
|
// CHECK: Type: PT_DYNAMIC
|
|
|
|
// CHECK-NEXT: Offset: [[OFFSET]]
|
|
|
|
// CHECK-NEXT: VirtualAddress: [[ADDR]]
|
|
|
|
// CHECK-NEXT: PhysicalAddress: [[ADDR]]
|
2015-09-09 23:33:08 +08:00
|
|
|
// CHECK-NEXT: FileSize: [[SIZE]]
|
|
|
|
// CHECK-NEXT: MemSize: [[SIZE]]
|
2015-09-09 06:55:28 +08:00
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: PF_R
|
|
|
|
// CHECK-NEXT: PF_W
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Alignment: [[ALIGN]]
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
2015-09-15 06:08:55 +08:00
|
|
|
// CHECK: HashTable {
|
2015-09-23 01:49:38 +08:00
|
|
|
// CHECK-NEXT: Num Buckets: 4
|
|
|
|
// CHECK-NEXT: Num Chains: 4
|
|
|
|
// CHECK-NEXT: Buckets: [3, 0, 2, 0]
|
|
|
|
// CHECK-NEXT: Chains: [0, 0, 0, 1]
|
2015-09-15 06:08:55 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
2015-09-08 23:50:05 +08:00
|
|
|
.global _start
|
|
|
|
_start:
|
2016-02-25 02:24:23 +08:00
|
|
|
.long bar@GOT
|
|
|
|
.long zed@GOT
|