brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · f37de8e Raw
91 lines · plain
1## This test verifies that the pair pcalau12i + ld.w/d is relaxed/not relaxed2## depending on the target symbol properties.3 4# REQUIRES: loongarch5# RUN: rm -rf %t && split-file %s %t && cd %t6 7# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax symbols.s -o symbols.32.o8# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax symbols.s -o symbols.64.o9# RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax abs.s -o abs.32.o10# RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax abs.s -o abs.64.o11 12# RUN: ld.lld --shared -Tlinker.t symbols.32.o abs.32.o -o symbols.32.so13# RUN: ld.lld --shared -Tlinker.t symbols.64.o abs.64.o -o symbols.64.so14# RUN: llvm-objdump -d --no-show-raw-insn symbols.32.so | FileCheck --check-prefixes=LIB %s15# RUN: llvm-objdump -d --no-show-raw-insn symbols.64.so | FileCheck --check-prefixes=LIB %s16 17# RUN: ld.lld -Tlinker.t -z undefs symbols.32.o abs.32.o -o symbols.3218# RUN: ld.lld -Tlinker.t -z undefs symbols.64.o abs.64.o -o symbols.6419# RUN: llvm-objdump -d --no-show-raw-insn symbols.32 | FileCheck --check-prefixes=EXE %s20# RUN: llvm-objdump -d --no-show-raw-insn symbols.64 | FileCheck --check-prefixes=EXE %s21 22 23## Symbol 'hidden_sym' is nonpreemptible, the relaxation should be applied.24LIB:      pcaddi      $a0, [[#]]25## Symbol 'global_sym' is preemptible, no relaxations should be applied.26LIB-NEXT: pcalau12i   $a1, 427LIB-NEXT: ld.{{[wd]}} $a1, $a1, [[#]]28## Symbol 'undefined_sym' is undefined, no relaxations should be applied.29LIB-NEXT: pcalau12i   $a2, 430LIB-NEXT: ld.{{[wd]}} $a2, $a2, [[#]]31## Symbol 'ifunc_sym' is STT_GNU_IFUNC, no relaxations should be applied.32LIB-NEXT: pcalau12i   $a3, 433LIB-NEXT: ld.{{[wd]}} $a3, $a3, [[#]]34## Symbol 'abs_sym' is absolute, no relaxations should be applied.35LIB-NEXT: pcalau12i   $a4, 436LIB-NEXT: ld.{{[wd]}} $a4, $a4, [[#]]37 38 39## Symbol 'hidden_sym' is nonpreemptible, the relaxation should be applied.40EXE:      pcaddi      $a0, [[#]]41## Symbol 'global_sym' is nonpreemptible, the relaxation should be applied.42EXE-NEXT: pcaddi      $a1, [[#]]43## Symbol 'undefined_sym' is undefined, no relaxations should be applied.44EXE-NEXT: pcalau12i   $a2, 445EXE-NEXT: ld.{{[wd]}} $a2, $a2, [[#]]46## Symbol 'ifunc_sym' is STT_GNU_IFUNC, no relaxations should be applied.47EXE-NEXT: pcalau12i   $a3, 448EXE-NEXT: ld.{{[wd]}} $a3, $a3, [[#]]49## Symbol 'abs_sym' is absolute, relaxations may be applied in -no-pie mode.50EXE-NEXT: pcaddi      $a4, -[[#]]51 52 53## The linker script ensures that .rodata and .text are near (>4M) so that54## the pcalau12i+ld.w/d pair can be relaxed to pcaddi.55#--- linker.t56SECTIONS {57 .text   0x10000: { *(.text) }58 .rodata 0x14000: { *(.rodata) }59}60 61# This symbol is defined in a separate file to prevent the definition from62# being folded into the instructions that reference it.63#--- abs.s64.global abs_sym65.hidden abs_sym66abs_sym = 0x100067 68#--- symbols.s69.rodata70.hidden hidden_sym71hidden_sym:72.word 1073 74.global global_sym75global_sym:76.word 1077 78.text79.type ifunc_sym STT_GNU_IFUNC80.hidden ifunc_sym81ifunc_sym:82  nop83 84.global _start85_start:86  la.got    $a0, hidden_sym87  la.got    $a1, global_sym88  la.got    $a2, undefined_sym89  la.got    $a3, ifunc_sym90  la.got    $a4, abs_sym91