reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
# REQUIRES: mips
# Check R_MIPS_GOT16 relocation calculation.

# RUN: echo "SECTIONS { \
# RUN:         . = 0x20000; .text : { *(.text) } \
# RUN:         . = 0x30000; .got  : { *(.got)  } \
# RUN:       }" > %t.script

# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-be.o
# RUN: ld.lld %t-be.o --script %t.script -o %t-be.exe
# RUN: llvm-readobj --sections -r --symbols -A %t-be.exe \
# RUN:   | FileCheck -check-prefix=ELF %s
# RUN: llvm-objdump -d %t-be.exe | FileCheck -check-prefix=DIS %s

# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux %s -o %t-el.o
# RUN: ld.lld %t-el.o --script %t.script -o %t-el.exe
# RUN: llvm-readobj --sections -r --symbols -A %t-el.exe \
# RUN:   | FileCheck -check-prefix=ELF %s
# RUN: llvm-objdump -d %t-el.exe | FileCheck -check-prefix=DIS %s

# RUN: ld.lld -shared %t-be.o --script %t.script -o %t-be.so
# RUN: llvm-readobj --sections -r --symbols -A %t-be.so \
# RUN:   | FileCheck -check-prefix=ELF %s
# RUN: llvm-objdump -d %t-be.so | FileCheck -check-prefix=DIS %s

# RUN: ld.lld -shared %t-el.o --script %t.script -o %t-el.so
# RUN: llvm-readobj --sections -r --symbols -A %t-el.so \
# RUN:   | FileCheck -check-prefix=ELF %s
# RUN: llvm-objdump -d %t-el.so | FileCheck -check-prefix=DIS %s

  .text
  .globl  __start
__start:
  lui $2, %got(v1)

  .data
  .globl v1
v1:
  .word 0

# ELF:      Section {
# ELF:        Name: .got
# ELF:        Flags [
# ELF-NEXT:     SHF_ALLOC
# ELF-NEXT:     SHF_MIPS_GPREL
# ELF-NEXT:     SHF_WRITE
# ELF-NEXT:   ]
#
# ELF:      Relocations [
# ELF-NEXT: ]
#
# ELF:      Symbol {
# ELF:        Name: v1
# ELF-NEXT:   Value: 0x[[V1:[0-9A-F]+]]
#
# ELF:      {{.*}} GOT {
# ELF-NEXT:   Canonical gp value: 0x37FF0
#
# ELF:        Entry {
# ELF:          Address: 0x30008
# ELF-NEXT:     Access: -32744
# ELF-NEXT:     Initial: 0x[[V1]]

# "v1 GOT entry address" - _gp
# 0x30008 - 0x37FF0 = -0x7fe8 == 0x8018 == 32792
# DIS:  lui $2, 32792