brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.3 KiB · de05b73 Raw
218 lines · plain
1# REQUIRES: ppc2# RUN: echo 'SECTIONS { \3# RUN:   .text_caller1 0x10010000 : { *(.text_caller1) } \4# RUN:   .text_caller2 0x10020000 : { *(.text_caller2) } \5# RUN:   .text_caller3 0x10030000 : { *(.text_caller3) } \6# RUN:   }' > %t.script7 8# RUN: llvm-mc -filetype=obj -triple=powerpc64le --defsym AUX=1 %s -o %t1.o9# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t2.o10# RUN: ld.lld --shared %t2.o -o %t2.so11# RUN: ld.lld -T %t.script %t1.o %t2.so -o %t12# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL13# RUN: llvm-readelf -S -d %t | FileCheck %s --check-prefix=SEC14# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=REL15# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s16 17# RUN: llvm-mc -filetype=obj -triple=powerpc64 --defsym AUX=1 %s -o %t1.o18# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t2.o19# RUN: ld.lld --shared %t2.o -o %t2.so20# RUN: ld.lld -T %t.script %t1.o %t2.so -o %t21# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL22# RUN: llvm-readelf -S -d %t | FileCheck %s --check-prefix=SEC23# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=REL24# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s25 26# RUN: llvm-mc -filetype=obj -triple=powerpc64le --defsym AUX=1 %s -o %t1.o27# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t2.o28# RUN: ld.lld --shared %t2.o -o %t2.so29# RUN: ld.lld -T %t.script %t1.o %t2.so -o %t --no-power10-stubs30# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL-NOP1031# RUN: llvm-readelf -S -d %t | FileCheck %s --check-prefix=SEC-NOP1032# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=REL-NOP1033# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefix=CHECK-NOP1034 35# RUN: llvm-mc -filetype=obj -triple=powerpc64 --defsym AUX=1 %s -o %t1.o36# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t2.o37# RUN: ld.lld --shared %t2.o -o %t2.so38# RUN: ld.lld -T %t.script %t1.o %t2.so -o %t --no-power10-stubs39# RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=SYMBOL-NOP1040# RUN: llvm-readelf -S -d %t | FileCheck %s --check-prefix=SEC-NOP1041# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=REL-NOP1042# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefix=CHECK-NOP1043 44## The test is created to check that when a function without TOC access an45## external function, a r12 setup stub is inserted.46 47# SYMBOL: Symbol table '.dynsym' contains 4 entries:48# SYMBOL:      1: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT                UND callee_global_stother049# SYMBOL-NEXT: 2: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT [<other: 0x20>] UND callee_global_stother150# SYMBOL-NEXT: 3: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT [<other: 0x60>] UND callee_global_TOC51 52# SYMBOL: Symbol table '.symtab' contains 12 entries:53# SYMBOL:      2: 0000000010010000     0 NOTYPE  LOCAL  DEFAULT [<other: 0x20>]   6 caller154# SYMBOL-NEXT: 3: 0000000010020000     0 NOTYPE  LOCAL  DEFAULT [<other: 0x20>]   7 caller255# SYMBOL-NEXT: 4: 0000000010030000     0 NOTYPE  LOCAL  DEFAULT [<other: 0x20>]   8 caller356# SYMBOL:      6: 0000000010010010    32 FUNC    LOCAL  DEFAULT                  6 __plt_pcrel_callee_global_stother057# SYMBOL-NEXT: 7: 0000000010020010    32 FUNC    LOCAL  DEFAULT                  7 __plt_pcrel_callee_global_stother158# SYMBOL-NEXT: 8: 0000000010030010    32 FUNC    LOCAL  DEFAULT                  8 __plt_pcrel_callee_global_TOC59# SYMBOL-NEXT: 9: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT                UND callee_global_stother060# SYMBOL-NEXT: 10: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT [<other: 0x20>] UND callee_global_stother161# SYMBOL-NEXT: 11: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT [<other: 0x60>] UND callee_global_TOC62 63# SYMBOL-NOP10: Symbol table '.symtab' contains 12 entries:64# SYMBOL-NOP10:      2: 0000000010010000     0 NOTYPE  LOCAL  DEFAULT [<other: 0x20>]   6 caller165# SYMBOL-NOP10-NEXT: 3: 0000000010020000     0 NOTYPE  LOCAL  DEFAULT [<other: 0x20>]   7 caller266# SYMBOL-NOP10-NEXT: 4: 0000000010030000     0 NOTYPE  LOCAL  DEFAULT [<other: 0x20>]   8 caller367# SYMBOL-NOP10:      6: 0000000010010010    32 FUNC    LOCAL  DEFAULT                  6 __plt_pcrel_callee_global_stother068# SYMBOL-NOP10-NEXT: 7: 0000000010020010    32 FUNC    LOCAL  DEFAULT                  7 __plt_pcrel_callee_global_stother169# SYMBOL-NOP10-NEXT: 8: 0000000010030010    32 FUNC    LOCAL  DEFAULT                  8 __plt_pcrel_callee_global_TOC70# SYMBOL-NOP10-NEXT: 9: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT                UND callee_global_stother071# SYMBOL-NOP10-NEXT: 10: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT [<other: 0x20>] UND callee_global_stother172# SYMBOL-NOP10-NEXT: 11: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT [<other: 0x60>] UND callee_global_TOC73 74## DT_PLTGOT points to .plt75# SEC: .plt              NOBITS          0000000010030168 040168 000028 00  WA  0   0  876# SEC: 0x0000000000000003 (PLTGOT)      0x1003016877 78## DT_PLTGOT points to .plt79# SEC-NOP10: .plt              NOBITS          0000000010030168 040168 000028 00  WA  0   0  880# SEC-NOP10: 0x0000000000000003 (PLTGOT)      0x1003016881 82## The first 2 entries in the .plt are reserved for the dynamic linkers83## usage. The JMP_SLOT relocations are stored at .plt[2], .plt[3], .plt[4].84## Check that we emit 3 R_PPC64_JMP_SLOT in .rela.plt.85# REL:      .rela.plt {86# REL-NEXT:   0x10030178 R_PPC64_JMP_SLOT callee_global_stother0 0x087# REL-NEXT:   0x10030180 R_PPC64_JMP_SLOT callee_global_stother1 0x088# REL-NEXT:   0x10030188 R_PPC64_JMP_SLOT callee_global_TOC 0x089# REL-NEXT: }90 91# REL-NOP10:      .rela.plt {92# REL-NOP10-NEXT:   0x10030178 R_PPC64_JMP_SLOT callee_global_stother0 0x093# REL-NOP10-NEXT:   0x10030180 R_PPC64_JMP_SLOT callee_global_stother1 0x094# REL-NOP10-NEXT:   0x10030188 R_PPC64_JMP_SLOT callee_global_TOC 0x095# REL-NOP10-NEXT: }96 97# CHECK-LABEL: <caller1>:98# CHECK:       10010000: bl 0x1001001099# CHECK-NEXT:  10010004: blr100 101# CHECK-NOP10-LABEL: <caller1>:102# CHECK-NOP10:       10010000: bl 0x10010010103# CHECK-NOP10-NEXT:  10010004: blr104 105## .plt[2] - 0x10010010 = 0x10030178 - 0x10010010 = 0x20168 = 131432106# CHECK-LABEL: <__plt_pcrel_callee_global_stother0>:107# CHECK:       10010010: pld 12, 131432(0), 1108# CHECK-NEXT:  10010018: mtctr 12109# CHECK-NEXT:  1001001c: bctr110 111## No P10; branch to next inst to get addr112# CHECK-NOP10-LABEL: <__plt_pcrel_callee_global_stother0>:113# CHECK-NOP10:       10010010: mflr 12114# CHECK-NOP10-NEXT:            bcl 20, 31, 0x10010018115# CHECK-NOP10-NEXT:  10010018: mflr 11116# CHECK-NOP10-NEXT:            mtlr 12117# CHECK-NOP10-NEXT:            addis 12, 11, 2118# CHECK-NOP10-NEXT:            ld 12, 352(12)119# CHECK-NOP10-NEXT:            mtctr 12120# CHECK-NOP10-NEXT:            bctr121 122# CHECK-LABEL: <caller2>:123# CHECK:       10020000: bl 0x10020010124# CHECK-NEXT:  10020004: blr125 126# CHECK-NOP10-LABEL: <caller2>:127# CHECK-NOP10:       10020000: bl 0x10020010128# CHECK-NOP10-NEXT:  10020004: blr129 130## .plt[3] - 0x10020010 = 0x10030180 - 0x10020010 = 0x10170 = 65904131# CHECK-LABEL: <__plt_pcrel_callee_global_stother1>:132# CHECK:       10020010: pld 12, 65904(0), 1133# CHECK-NEXT:  10020018: mtctr 12134# CHECK-NEXT:  1002001c: bctr135 136## no P10; branch to next inst to get addr137## .plt[3]-r11 = 0x10030170-0x10020018 = 65536*1+344138# CHECK-NOP10-LABEL: <__plt_pcrel_callee_global_stother1>:139# CHECK-NOP10:       10020010: mflr 12140# CHECK-NOP10-NEXT:            bcl 20, 31, 0x10020018141# CHECK-NOP10-NEXT:  10020018: mflr 11142# CHECK-NOP10-NEXT:            mtlr 12143# CHECK-NOP10-NEXT:            addis 12, 11, 1144# CHECK-NOP10-NEXT:            ld 12, 360(12)145# CHECK-NOP10-NEXT:            mtctr 12146# CHECK-NOP10-NEXT:            bctr147 148# CHECK-LABEL: <caller3>:149# CHECK:       10030000: bl 0x10030010150# CHECK-NEXT:  10030004: blr151 152# CHECK-NOP10-LABEL: <caller3>:153# CHECK-NOP10:       10030000: bl 0x10030010154# CHECK-NOP10-NEXT:  10030004: blr155 156## .plt[4] - 0x10030010 = 0x10030188 - 0x10030010 = 0x178 = 376157# CHECK-LABEL: <__plt_pcrel_callee_global_TOC>:158# CHECK:       10030010: pld 12, 376(0), 1159# CHECK-NEXT:  10030018: mtctr 12160# CHECK-NEXT:  1003001c: bctr161 162## no P10; branch to next inst to get addr163## .plt[4]-r11 = 0x10030178-0x10030018 = 65536*0+352164# CHECK-NOP10-LABEL: <__plt_pcrel_callee_global_TOC>:165# CHECK-NOP10-NEXT:  10030010: mflr 12166# CHECK-NOP10-NEXT:            bcl 20, 31, 0x10030018167# CHECK-NOP10-NEXT:  10030018: mflr 11168# CHECK-NOP10-NEXT:            mtlr 12169# CHECK-NOP10-NEXT:            addis 12, 11, 0170# CHECK-NOP10-NEXT:            ld 12, 368(12)171# CHECK-NOP10-NEXT:            mtctr 12172# CHECK-NOP10-NEXT:            bctr173 174.ifdef AUX175.section .text_caller1, "ax", %progbits176caller1:177  .localentry caller1, 1178  bl callee_global_stother0@notoc179  blr180.section .text_caller2, "ax", %progbits181caller2:182  .localentry caller2, 1183  bl callee_global_stother1@notoc184  blr185 186.section .text_caller3, "ax", %progbits187caller3:188  .localentry caller3, 1189  bl callee_global_TOC@notoc190  blr191 192.else193func_extern:194  blr195.globl callee_global_stother0196callee_global_stother0:197  blr198.globl callee_global_stother1199callee_global_stother1:200  .localentry callee_global_stother1, 1201  ## nop is not needed after bl for R_PPC64_REL24_NOTOC202  bl func_extern@notoc203  blr204.globl callee_global_TOC205callee_global_TOC:206.Lfunc_gep1:207  addis 2, 12, .TOC.-.Lfunc_gep1@ha208  addi 2, 2, .TOC.-.Lfunc_gep1@l209.Lfunc_lep1:210  .localentry callee_global_TOC, .Lfunc_lep1-.Lfunc_gep1211  addis 4, 2, global@toc@ha212  lwz 3, global@toc@l(4)213  blr214global:215  .long  0216  .size  global, 4217.endif218