105 lines · plain
1# REQUIRES: hexagon2# RUN: echo '.globl bar, weak; .type bar,@function; .type weak,@function; bar: weak:' > %t1.s3 4# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %t1.s -o %t1.o5# RUN: ld.lld -shared %t1.o -soname=t1.so -o %t1.so6# RUN: llvm-mc -mno-fixup -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o7# RUN: ld.lld %t.o %t1.so -z separate-code -o %t8# RUN: llvm-readelf -S -s %t | FileCheck --check-prefixes=SEC,NM %s9# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s10# RUN: llvm-readelf -x .got.plt %t | FileCheck --check-prefix=GOTPLT %s11# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck --check-prefixes=DIS %s12 13# SEC: .plt PROGBITS {{0*}}0002004014 15## A canonical PLT has a non-zero st_value. bar and weak are called but their16## addresses are not taken, so a canonical PLT is not necessary.17# NM: {{0*}}00000000 0 FUNC GLOBAL DEFAULT UND bar18# NM: {{0*}}00000000 0 FUNC WEAK DEFAULT UND weak19 20## The .got.plt slots relocated by .rela.plt point to .plt21## This is required by glibc.22# RELOC: .rela.plt {23# RELOC-NEXT: 0x40078 R_HEX_JMP_SLOT bar 0x024# RELOC-NEXT: 0x4007C R_HEX_JMP_SLOT weak 0x025# RELOC-NEXT: }26# GOTPLT: section '.got.plt'27# GOTPLT-NEXT: 0x00040068 00000000 00000000 00000000 0000000028# GOTPLT-NEXT: 0x00040078 00000000 0000000029 30# DIS: <_start>:31## Direct call32## Call foo directly33# DIS-NEXT: { call 0x2003c <foo> }34## Call bar via plt35# DIS-NEXT: { call 0x20060 <bar@plt> }36## Call weak via plt37# DIS-NEXT: { call 0x20070 <weak@plt> }38# DIS-NEXT: { immext(#0)39 40## Call foo directly41# DIS-NEXT: if (p0) jump:nt 0x2003c <foo> }42# DIS-NEXT: { immext(#64)43## Call bar via plt44# DIS-NEXT: if (p0) jump:nt 0x20060 <bar@plt> }45# DIS-NEXT: { immext(#64)46## Call weak via plt47# DIS-NEXT: if (p0) jump:nt 0x20070 <weak@plt> }48# DIS-NEXT: { immext(#0)49 50## Call foo directly51# DIS-NEXT: r0 = #0 ; jump 0x2003c <foo> }52# DIS-NEXT: { immext(#0)53## Call bar via plt54# DIS-NEXT: r0 = #0 ; jump 0x20060 <bar@plt> }55# DIS-NEXT: { immext(#0)56## Call weak via plt57# DIS-NEXT: r0 = #0 ; jump 0x20070 <weak@plt> }58 59# DIS: <foo>:60# DIS-NEXT: 2003c:61 62 63# DIS: Disassembly of section .plt:64 65# DIS: 00020040 <.plt>:66# DIS-NEXT: 20040: { immext(#131072)67# DIS-NEXT: 20044: r28 = add(pc,##131112) }68# DIS-NEXT: 20048: { r14 -= add(r28,#16)69# DIS-NEXT: 2004c: r15 = memw(r28+#8)70# DIS-NEXT: 20050: r28 = memw(r28+#4) }71# DIS-NEXT: 20054: { r14 = asr(r14,#2)72# DIS-NEXT: 20058: jumpr r28 }73# DIS-NEXT: 2005c: { trap0(#219) }74# DIS-EMPTY:75# DIS-NEXT: 00020060 <bar@plt>:76# DIS-NEXT: 20060: { immext(#131072)77# DIS-NEXT: 20064: r14 = add(pc,##131096) }78# DIS-NEXT: 20068: { r28 = memw(r14+#0) }79# DIS-NEXT: 2006c: { jumpr r28 }80# DIS-EMPTY:81# DIS-NEXT: 00020070 <weak@plt>:82# DIS-NEXT: 20070: { immext(#131072)83# DIS-NEXT: 20074: r14 = add(pc,##131084) }84# DIS-NEXT: 20078: { r28 = memw(r14+#0) }85# DIS-NEXT: 2007c: { jumpr r28 }86 87 88.global _start, foo, bar89.weak weak90 91_start:92 call foo93 call bar94 call weak95 if (p0) jump foo96 if (p0) jump bar97 if (p0) jump weak98 { r0 = #0; jump foo }99 { r0 = #0; jump bar }100 { r0 = #0; jump weak }101 102## foo is local and non-preemptale, no PLT is generated.103foo:104 jumpr r31105