1# REQUIRES: mips
2# Check R_MIPS_GOT16 relocation against weak symbols.
3
4# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
5# RUN: ld.lld %t.o -shared -o %t1.so
6# RUN: llvm-readelf -r --dyn-syms --dynamic-table -A %t1.so \
7# RUN:   | FileCheck -check-prefixes=CHECK,NOSYM %s
8# RUN: ld.lld %t.o -shared -Bsymbolic -o %t2.so
9# RUN: llvm-readelf -r --dyn-syms --dynamic-table -A %t2.so \
10# RUN:   | FileCheck -check-prefixes=CHECK,SYM %s
11
12# CHECK: Dynamic section
13# CHECK: (MIPS_SYMTABNO)      4
14# NOSYM: (MIPS_LOCAL_GOTNO)   2
15# NOSYM: (MIPS_GOTSYM)        0x1
16#   SYM: (MIPS_LOCAL_GOTNO)   4
17#   SYM: (MIPS_GOTSYM)        0x3
18
19# CHECK: There are no relocations in this file.
20
21# CHECK: Symbol table '.dynsym'
22# CHECK-DAG: [[FOO:[0-9a-f]+]]     0 NOTYPE  WEAK   DEFAULT    8 foo
23# CHECK-DAG:          00000000     0 NOTYPE  WEAK   DEFAULT  UND bar
24# CHECK-DAG: [[SYM:[0-9a-f]+]]     0 NOTYPE  GLOBAL DEFAULT    8 sym
25
26# NOSYM:      Primary GOT:
27# NOSYM-NOT:   Local entries:
28# NOSYM:       Global entries:
29# NOSYM-NEXT:       Access  Initial Sym.Val. Type    Ndx Name
30# NOSYM-NEXT:   -32744(gp)  [[FOO]]  [[FOO]] NOTYPE    8 foo
31# NOSYM-NEXT:   -32740(gp) 00000000 00000000 NOTYPE  UND bar
32# NOSYM-NEXT:   -32736(gp)  [[SYM]]  [[SYM]] NOTYPE    8 sym
33
34# SYM:      Primary GOT:
35# SYM:       Local entries:
36# SYM-NEXT:       Access  Initial
37# SYM-NEXT:   -32744(gp)  [[FOO]]
38# SYM-NEXT:   -32740(gp)  [[SYM]]
39# SYM:       Global entries:
40# SYM-NEXT:       Access  Initial Sym.Val. Type    Ndx Name
41# SYM-NEXT:   -32736(gp) 00000000 00000000 NOTYPE  UND bar
42
43  .text
44  .global  sym
45  .weak    foo,bar
46func:
47  lw      $t0,%got(foo)($gp)
48  lw      $t0,%got(bar)($gp)
49  lw      $t0,%got(sym)($gp)
50
51  .data
52  .weak foo
53foo:
54  .word 0
55sym:
56  .word 0
57