1# REQUIRES: mips
2# Check MIPS specific .dynamic section entries.
3
4# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
5# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %p/Inputs/mips-dynamic.s -o %td.o
6# RUN: ld.lld -shared %td.o -o %td.so
7
8# RUN: ld.lld %t.o %td.so -o %t.exe
9# RUN: llvm-readobj --sections --dynamic-table %t.exe \
10# RUN:   | FileCheck -check-prefixes=EXE,NOPIE %s
11
12# RUN: ld.lld -pie %t.o %td.so -o %t.so
13# RUN: llvm-readobj --sections --dyn-syms --dynamic-table %t.so \
14# RUN:   | FileCheck -check-prefixes=EXE,PIE %s
15
16# RUN: ld.lld %t.o --image-base=0x123000 %td.so -o %t.exe
17# RUN: llvm-readobj --sections --dynamic-table %t.exe \
18# RUN:   | FileCheck -check-prefix=IMAGE_BASE %s
19
20# RUN: ld.lld -shared %t.o %td.so -o %t.so
21# RUN: llvm-readobj --sections --dyn-syms --dynamic-table %t.so \
22# RUN:   | FileCheck -check-prefix=DSO %s
23
24# EXE:      Sections [
25# EXE:          Name: .dynamic
26# EXE-NEXT:     Type: SHT_DYNAMIC
27# EXE-NEXT:     Flags [
28# EXE-NEXT:       SHF_ALLOC
29# EXE-NEXT:     ]
30# EXE:          Name: .rld_map
31# EXE-NEXT:     Type: SHT_PROGBITS
32# EXE-NEXT:     Flags [
33# EXE-NEXT:       SHF_ALLOC
34# EXE-NEXT:       SHF_WRITE
35# EXE-NEXT:     ]
36# EXE-NEXT:     Address: [[RLDMAPADDR:0x[0-9a-f]+]]
37# EXE-NEXT:     Offset:
38# EXE-NEXT:     Size: 4
39# EXE:          Name: .got
40# EXE-NEXT:     Type: SHT_PROGBITS
41# EXE-NEXT:     Flags [ (0x10000003)
42# EXE-NEXT:       SHF_ALLOC
43# EXE-NEXT:       SHF_MIPS_GPREL
44# EXE-NEXT:       SHF_WRITE
45# EXE-NEXT:     ]
46# EXE-NEXT:     Address: [[GOTADDR:0x[0-9a-f]+]]
47# EXE-NEXT:     Offset:
48# EXE-NEXT:     Size: 8
49# EXE:      ]
50
51# PIE:      DynamicSection [
52# PIE-NEXT:   Tag        Type                 Name/Value
53# PIE:        0x00000004 HASH                 0x{{[0-9A-F]+}}
54# PIE-NEXT:   0x70000001 MIPS_RLD_VERSION     1
55# PIE-NEXT:   0x70000005 MIPS_FLAGS           NOTPOT
56# PIE-NEXT:   0x70000006 MIPS_BASE_ADDRESS    0x0
57# PIE-NEXT:   0x70000011 MIPS_SYMTABNO        2
58# PIE-NEXT:   0x7000000A MIPS_LOCAL_GOTNO     2
59# PIE-NEXT:   0x70000013 MIPS_GOTSYM          0x2
60# PIE-NEXT:   0x00000003 PLTGOT               [[GOTADDR]]
61# PIE-NEXT:   0x70000035 MIPS_RLD_MAP_REL     0x{{[0-9A-F]+}}
62# PIE-NEXT:   0x00000000 NULL                 0x0
63# PIE-NEXT: ]
64
65# NOPIE:      DynamicSection [
66# NOPIE-NEXT:   Tag        Type                 Name/Value
67# NOPIE:        0x00000004 HASH                 0x{{[0-9A-F]+}}
68# NOPIE-NEXT:   0x70000001 MIPS_RLD_VERSION     1
69# NOPIE-NEXT:   0x70000005 MIPS_FLAGS           NOTPOT
70# NOPIE-NEXT:   0x70000006 MIPS_BASE_ADDRESS    0x10000
71# NOPIE-NEXT:   0x70000011 MIPS_SYMTABNO        2
72# NOPIE-NEXT:   0x7000000A MIPS_LOCAL_GOTNO     2
73# NOPIE-NEXT:   0x70000013 MIPS_GOTSYM          0x2
74# NOPIE-NEXT:   0x00000003 PLTGOT               [[GOTADDR]]
75# NOPIE-NEXT:   0x70000016 MIPS_RLD_MAP         [[RLDMAPADDR]]
76# NOPIE-NEXT:   0x70000035 MIPS_RLD_MAP_REL     0x{{[0-9A-F]+}}
77# NOPIE-NEXT:   0x00000000 NULL                 0x0
78# NOPIE-NEXT: ]
79
80# IMAGE_BASE: 0x70000006 MIPS_BASE_ADDRESS    0x123000
81
82# DSO:      Sections [
83# DSO:          Name: .dynamic
84# DSO-NEXT:     Type: SHT_DYNAMIC
85# DSO-NEXT:     Flags [
86# DSO-NEXT:       SHF_ALLOC
87# DSO-NEXT:     ]
88# DSO:          Name: .got
89# DSO-NEXT:     Type: SHT_PROGBITS
90# DSO-NEXT:     Flags [ (0x10000003)
91# DSO-NEXT:       SHF_ALLOC
92# DSO-NEXT:       SHF_MIPS_GPREL
93# DSO-NEXT:       SHF_WRITE
94# DSO-NEXT:     ]
95# DSO-NEXT:     Address: [[GOTADDR:0x[0-9a-f]+]]
96# DSO-NEXT:     Offset:
97# DSO-NEXT:     Size: 8
98# DSO:      ]
99# DSO:      DynamicSection [
100# DSO-NEXT:   Tag        Type                 Name/Value
101# DSO-DAG:    0x00000003 PLTGOT               [[GOTADDR]]
102# DSO-DAG:    0x70000001 MIPS_RLD_VERSION     1
103# DSO-DAG:    0x70000005 MIPS_FLAGS           NOTPOT
104# DSO-DAG:    0x70000006 MIPS_BASE_ADDRESS    0x0
105# DSO-DAG:    0x7000000A MIPS_LOCAL_GOTNO     2
106# DSO-DAG:    0x70000011 MIPS_SYMTABNO        3
107# DSO-DAG:    0x70000013 MIPS_GOTSYM          0x3
108# DSO:      ]
109# DSO-NEXT: DynamicSymbols [
110# DSO:          Name:
111# DSO:          Name: __start
112# DSO:          Name: _foo
113# DSO:      ]
114
115  .text
116  .globl  __start,_foo
117  .type _foo,@function
118__start:
119  nop
120