2017-06-07 17:35:14 +08:00
|
|
|
# REQUIRES: mips
|
|
|
|
# Check LA25 stubs creation. This stub code is necessary when
|
|
|
|
# non-PIC code calls PIC function.
|
|
|
|
# RUN: echo "SECTIONS { .out 0x20000 : { *(.text.*) . = . + 0x100 ; *(.text) } }" > %t1.script
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
|
|
|
|
# RUN: %p/Inputs/mips-fpic.s -o %t-fpic.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
|
|
|
|
# RUN: %p/Inputs/mips-fnpic.s -o %t-fnpic.o
|
|
|
|
# RUN: ld.lld -r %t-fpic.o %t-fnpic.o -o %t-sto-pic.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
|
|
|
|
# RUN: %p/Inputs/mips-pic.s -o %t-pic.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-npic.o
|
|
|
|
# RUN: ld.lld --script %t1.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t.exe
|
2019-07-25 15:12:23 +08:00
|
|
|
# RUN: llvm-objdump -d --no-show-raw-insn %t.exe | FileCheck %s
|
2017-06-07 17:35:14 +08:00
|
|
|
|
|
|
|
# CHECK: Disassembly of section .out:
|
2019-05-01 18:40:48 +08:00
|
|
|
# CHECK-EMPTY:
|
2017-06-07 17:35:14 +08:00
|
|
|
# CHECK-NEXT: __LA25Thunk_foo1a:
|
2019-07-25 15:12:23 +08:00
|
|
|
# CHECK-NEXT: 20000: lui $25, 2
|
|
|
|
# CHECK-NEXT: 20004: j 131104 <foo1a>
|
|
|
|
# CHECK-NEXT: 20008: addiu $25, $25, 32
|
|
|
|
# CHECK-NEXT: 2000c: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# CHECK: __LA25Thunk_foo1b:
|
2019-07-25 15:12:23 +08:00
|
|
|
# CHECK-NEXT: 20010: lui $25, 2
|
|
|
|
# CHECK-NEXT: 20014: j 131108 <foo1b>
|
|
|
|
# CHECK-NEXT: 20018: addiu $25, $25, 36
|
|
|
|
# CHECK-NEXT: 2001c: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# CHECK: foo1a:
|
2019-07-25 15:12:23 +08:00
|
|
|
# CHECK-NEXT: 20020: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# CHECK: foo1b:
|
2019-07-25 15:12:23 +08:00
|
|
|
# CHECK-NEXT: 20024: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# CHECK: __LA25Thunk_foo2:
|
2019-07-25 15:12:23 +08:00
|
|
|
# CHECK-NEXT: 20028: lui $25, 2
|
|
|
|
# CHECK-NEXT: 2002c: j 131136 <foo2>
|
|
|
|
# CHECK-NEXT: 20030: addiu $25, $25, 64
|
|
|
|
# CHECK-NEXT: 20034: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# CHECK: foo2:
|
2019-07-25 15:12:23 +08:00
|
|
|
# CHECK-NEXT: 20040: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# CHECK: __start:
|
2019-07-25 15:12:23 +08:00
|
|
|
# CHECK-NEXT: 20150: jal 131072 <__LA25Thunk_foo1a>
|
|
|
|
# CHECK-NEXT: 20154: nop
|
|
|
|
# CHECK-NEXT: 20158: jal 131112 <__LA25Thunk_foo2>
|
|
|
|
# CHECK-NEXT: 2015c: nop
|
|
|
|
# CHECK-NEXT: 20160: jal 131088 <__LA25Thunk_foo1b>
|
|
|
|
# CHECK-NEXT: 20164: nop
|
|
|
|
# CHECK-NEXT: 20168: jal 131112 <__LA25Thunk_foo2>
|
|
|
|
# CHECK-NEXT: 2016c: nop
|
|
|
|
# CHECK-NEXT: 20170: jal 131456 <__LA25Thunk_fpic>
|
|
|
|
# CHECK-NEXT: 20174: nop
|
|
|
|
# CHECK-NEXT: 20178: jal 131488 <fnpic>
|
|
|
|
# CHECK-NEXT: 2017c: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# CHECK: __LA25Thunk_fpic:
|
2019-07-25 15:12:23 +08:00
|
|
|
# CHECK-NEXT: 20180: lui $25, 2
|
|
|
|
# CHECK-NEXT: 20184: j 131472 <fpic>
|
|
|
|
# CHECK-NEXT: 20188: addiu $25, $25, 400
|
|
|
|
# CHECK-NEXT: 2018c: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# CHECK: fpic:
|
2019-07-25 15:12:23 +08:00
|
|
|
# CHECK-NEXT: 20190: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# CHECK: fnpic:
|
2019-07-25 15:12:23 +08:00
|
|
|
# CHECK-NEXT: 201a0: nop
|
2017-06-07 17:35:14 +08:00
|
|
|
|
|
|
|
.text
|
|
|
|
.globl __start
|
|
|
|
__start:
|
|
|
|
jal foo1a
|
|
|
|
jal foo2
|
|
|
|
jal foo1b
|
|
|
|
jal foo2
|
|
|
|
jal fpic
|
|
|
|
jal fnpic
|
|
|
|
|
|
|
|
# Test script with orphans added to existing OutputSection, the .text.1 and
|
|
|
|
# .text.2 sections will be added to .text
|
|
|
|
# RUN: echo "SECTIONS { .text 0x20000 : { *(.text) } }" > %t2.script
|
|
|
|
# RUN: ld.lld --script %t2.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t2.exe
|
2019-07-25 15:12:23 +08:00
|
|
|
# RUN: llvm-objdump -d --no-show-raw-insn %t2.exe | FileCheck -check-prefix=ORPH1 %s
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
# ORPH1-EMPTY:
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1-NEXT: __start:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH1-NEXT: 20000: jal 131156 <__LA25Thunk_foo1a>
|
|
|
|
# ORPH1-NEXT: 20004: nop
|
|
|
|
# ORPH1-NEXT: 20008: jal 131208 <__LA25Thunk_foo2>
|
|
|
|
# ORPH1-NEXT: 2000c: nop
|
|
|
|
# ORPH1-NEXT: 20010: jal 131172 <__LA25Thunk_foo1b>
|
|
|
|
# ORPH1-NEXT: 20014: nop
|
|
|
|
# ORPH1-NEXT: 20018: jal 131208 <__LA25Thunk_foo2>
|
|
|
|
# ORPH1-NEXT: 2001c: nop
|
|
|
|
# ORPH1-NEXT: 20020: jal 131120 <__LA25Thunk_fpic>
|
|
|
|
# ORPH1-NEXT: 20024: nop
|
|
|
|
# ORPH1-NEXT: 20028: jal 131152 <fnpic>
|
|
|
|
# ORPH1-NEXT: 2002c: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1: __LA25Thunk_fpic:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH1-NEXT: 20030: lui $25, 2
|
|
|
|
# ORPH1-NEXT: 20034: j 131136 <fpic>
|
|
|
|
# ORPH1-NEXT: 20038: addiu $25, $25, 64
|
|
|
|
# ORPH1-NEXT: 2003c: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1: fpic:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH1-NEXT: 20040: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1: fnpic:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH1-NEXT: 20050: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1: __LA25Thunk_foo1a:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH1-NEXT: 20054: lui $25, 2
|
|
|
|
# ORPH1-NEXT: 20058: j 131200 <foo1a>
|
|
|
|
# ORPH1-NEXT: 2005c: addiu $25, $25, 128
|
|
|
|
# ORPH1-NEXT: 20060: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1: __LA25Thunk_foo1b:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH1-NEXT: 20064: lui $25, 2
|
|
|
|
# ORPH1-NEXT: 20068: j 131204 <foo1b>
|
|
|
|
# ORPH1-NEXT: 2006c: addiu $25, $25, 132
|
|
|
|
# ORPH1-NEXT: 20070: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1: foo1a:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH1-NEXT: 20080: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1: foo1b:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH1-NEXT: 20084: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1: __LA25Thunk_foo2:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH1-NEXT: 20088: lui $25, 2
|
|
|
|
# ORPH1-NEXT: 2008c: j 131232 <foo2>
|
|
|
|
# ORPH1-NEXT: 20090: addiu $25, $25, 160
|
|
|
|
# ORPH1-NEXT: 20094: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH1: foo2:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH1-NEXT: 200a0: nop
|
2017-06-07 17:35:14 +08:00
|
|
|
|
|
|
|
# Test script with orphans added to new OutputSection, the .text.1 and
|
|
|
|
# .text.2 sections will form a new OutputSection .text
|
|
|
|
# RUN: echo "SECTIONS { .out 0x20000 : { *(.text) } }" > %t3.script
|
|
|
|
# RUN: ld.lld --script %t3.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t3.exe
|
2019-07-25 15:12:23 +08:00
|
|
|
# RUN: llvm-objdump -d --no-show-raw-insn %t3.exe | FileCheck -check-prefix=ORPH2 %s
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2: Disassembly of section .out:
|
2019-05-01 18:40:48 +08:00
|
|
|
# ORPH2-EMPTY:
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2-NEXT: __start:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH2-NEXT: 20000: jal 131168 <__LA25Thunk_foo1a>
|
|
|
|
# ORPH2-NEXT: 20004: nop
|
|
|
|
# ORPH2-NEXT: 20008: jal 131208 <__LA25Thunk_foo2>
|
|
|
|
# ORPH2-NEXT: 2000c: nop
|
|
|
|
# ORPH2-NEXT: 20010: jal 131184 <__LA25Thunk_foo1b>
|
|
|
|
# ORPH2-NEXT: 20014: nop
|
|
|
|
# ORPH2-NEXT: 20018: jal 131208 <__LA25Thunk_foo2>
|
|
|
|
# ORPH2-NEXT: 2001c: nop
|
|
|
|
# ORPH2-NEXT: 20020: jal 131120 <__LA25Thunk_fpic>
|
|
|
|
# ORPH2-NEXT: 20024: nop
|
|
|
|
# ORPH2-NEXT: 20028: jal 131152 <fnpic>
|
|
|
|
# ORPH2-NEXT: 2002c: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2: __LA25Thunk_fpic:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH2-NEXT: 20030: lui $25, 2
|
|
|
|
# ORPH2-NEXT: 20034: j 131136 <fpic>
|
|
|
|
# ORPH2-NEXT: 20038: addiu $25, $25, 64
|
|
|
|
# ORPH2-NEXT: 2003c: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2: fpic:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH2-NEXT: 20040: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2: fnpic:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH2-NEXT: 20050: nop
|
2019-05-01 18:40:48 +08:00
|
|
|
# ORPH2-EMPTY:
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2-NEXT: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
# ORPH2-EMPTY:
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2-NEXT: __LA25Thunk_foo1a:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH2-NEXT: 20060: lui $25, 2
|
|
|
|
# ORPH2-NEXT: 20064: j 131200 <foo1a>
|
|
|
|
# ORPH2-NEXT: 20068: addiu $25, $25, 128
|
|
|
|
# ORPH2-NEXT: 2006c: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2: __LA25Thunk_foo1b:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH2-NEXT: 20070: lui $25, 2
|
|
|
|
# ORPH2-NEXT: 20074: j 131204 <foo1b>
|
|
|
|
# ORPH2-NEXT: 20078: addiu $25, $25, 132
|
|
|
|
# ORPH2-NEXT: 2007c: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2: foo1a:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH2-NEXT: 20080: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2: foo1b:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH2-NEXT: 20084: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2: __LA25Thunk_foo2:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH2-NEXT: 20088: lui $25, 2
|
|
|
|
# ORPH2-NEXT: 2008c: j 131232 <foo2>
|
|
|
|
# ORPH2-NEXT: 20090: addiu $25, $25, 160
|
|
|
|
# ORPH2-NEXT: 20094: nop
|
2018-11-16 13:30:47 +08:00
|
|
|
|
2017-06-07 17:35:14 +08:00
|
|
|
# ORPH2: foo2:
|
2019-07-25 15:12:23 +08:00
|
|
|
# ORPH2-NEXT: 200a0: nop
|