brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 4b3649e Raw
105 lines · plain
1# REQUIRES: riscv2# RUN: echo '.globl bar, weak; .type bar,@function; .type weak,@function; bar: weak:' > %t1.s3 4# RUN: llvm-mc -filetype=obj -triple=riscv32 %t1.s -o %t1.32.o5# RUN: ld.lld -shared %t1.32.o -soname=t1.32.so -o %t1.32.so6# RUN: llvm-mc -filetype=obj -triple=riscv32 %s -o %t.32.o7# RUN: ld.lld %t.32.o %t1.32.so -z separate-code -o %t.328# RUN: llvm-readelf -S -s %t.32 | FileCheck --check-prefixes=SEC,NM %s9# RUN: llvm-readobj -r %t.32 | FileCheck --check-prefix=RELOC32 %s10# RUN: llvm-readelf -x .got.plt %t.32 | FileCheck --check-prefix=GOTPLT32 %s11# RUN: llvm-objdump -d --no-show-raw-insn %t.32 | FileCheck --check-prefixes=DIS,DIS32 %s12 13# RUN: llvm-mc -filetype=obj -triple=riscv64 %t1.s -o %t1.64.o14# RUN: ld.lld -shared %t1.64.o -soname=t1.64.so -o %t1.64.so15# RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t.64.o16# RUN: ld.lld %t.64.o %t1.64.so -z separate-code -o %t.6417# RUN: llvm-readelf -S -s %t.64 | FileCheck --check-prefixes=SEC,NM %s18# RUN: llvm-readobj -r %t.64 | FileCheck --check-prefix=RELOC64 %s19# RUN: llvm-readelf -x .got.plt %t.64 | FileCheck --check-prefix=GOTPLT64 %s20# RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefixes=DIS,DIS64 %s21 22# SEC: .plt PROGBITS {{0*}}0001103023 24## A canonical PLT has a non-zero st_value. bar and weak are called but their25## addresses are not taken, so a canonical PLT is not necessary.26# NM: {{0*}}00000000 0 FUNC GLOBAL DEFAULT UND bar27# NM: {{0*}}00000000 0 FUNC WEAK   DEFAULT UND weak28 29## The .got.plt slots relocated by .rela.plt point to .plt30## This is required by glibc.31# RELOC32:      .rela.plt {32# RELOC32-NEXT:   0x13070 R_RISCV_JUMP_SLOT bar 0x033# RELOC32-NEXT:   0x13074 R_RISCV_JUMP_SLOT weak 0x034# RELOC32-NEXT: }35# GOTPLT32:      section '.got.plt'36# GOTPLT32-NEXT: 0x00013068 00000000 00000000 30100100 3010010037 38# RELOC64:      .rela.plt {39# RELOC64-NEXT:   0x130E0 R_RISCV_JUMP_SLOT bar 0x040# RELOC64-NEXT:   0x130E8 R_RISCV_JUMP_SLOT weak 0x041# RELOC64-NEXT: }42# GOTPLT64:      section '.got.plt'43# GOTPLT64-NEXT: 0x000130d0 00000000 00000000 00000000 0000000044# GOTPLT64-NEXT: 0x000130e0 30100100 00000000 30100100 0000000045 46# DIS:      <_start>:47## Direct call48## foo - . = 0x11020-0x11000 = 3249# DIS-NEXT:   11000: auipc ra, 0x050# DIS-NEXT:          jalr 0x20(ra)51## bar@plt - . = 0x11050-0x11008 = 7252# DIS-NEXT:   11008: auipc ra, 0x053# DIS-NEXT:          jalr 0x48(ra)54## bar@plt - . = 0x11050-0x11010 = 6455# DIS-NEXT:   11010: auipc ra, 0x056# DIS-NEXT:          jalr 0x40(ra)57## weak@plt - . = 0x11060-0x11018 = 7258# DIS-NEXT:   11018: auipc ra, 0x059# DIS-NEXT:          jalr 0x48(ra)60# DIS:      <foo>:61# DIS-NEXT:   11020:62 63# DIS:      Disassembly of section .plt:64# DIS:      <.plt>:65# DIS-NEXT:     auipc t2, 0x266# DIS-NEXT:     sub t1, t1, t367## .got.plt - .plt = 0x13068 - 0x11030 = 4096*2+5668# DIS32-NEXT:   lw t3, 0x38(t2)69# DIS64-NEXT:   ld t3, 0xa0(t2)70# DIS-NEXT:     addi t1, t1, -0x2c71# DIS32-NEXT:   addi t0, t2, 0x3872# DIS64-NEXT:   addi t0, t2, 0xa073# DIS32-NEXT:   srli t1, t1, 0x274# DIS64-NEXT:   srli t1, t1, 0x175# DIS32-NEXT:   lw t0, 0x4(t0)76# DIS64-NEXT:   ld t0, 0x8(t0)77# DIS-NEXT:     jr t378 79## 32-bit: &.got.plt[bar]-. = 0x13070-0x11050 = 4096*2+3280# DIS:        11050: auipc t3, 0x281# DIS32-NEXT:   lw t3, 0x20(t3)82# DIS64-NEXT:   ld t3, 0x90(t3)83# DIS-NEXT:     jalr t1, t384# DIS-NEXT:     nop85 86## 32-bit: &.got.plt[weak]-. = 0x13074-0x11060 = 4096*2+2087# DIS:        11060: auipc t3, 0x288# DIS32-NEXT:   lw t3, 0x14(t3)89# DIS64-NEXT:   ld t3, 0x88(t3)90# DIS-NEXT:     jalr t1, t391# DIS-NEXT:     nop92 93.global _start, foo, bar94.weak weak95 96_start:97  call foo98  call bar99  call bar@plt100  call weak101 102## foo is local and non-preemptale, no PLT is generated.103foo:104  ret105