mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-14 06:29:38 +00:00
[ELF][test] Add linkerscript/linkorder-linked-to.s
Delete relocatable-linkorder.s which is covered.
This commit is contained in:
parent
38ddb49e52
commit
51475e4023
74
lld/test/ELF/linkerscript/linkorder-linked-to.s
Normal file
74
lld/test/ELF/linkerscript/linkorder-linked-to.s
Normal file
@ -0,0 +1,74 @@
|
||||
# REQUIRES: x86
|
||||
## Test how we set the sh_link field of a SHF_LINK_ORDER output section.
|
||||
## Additionally, test that in a relocatable link, SHF_LINK_ORDER sections are
|
||||
## not combined. Combining them will arbitrarily choose a single output
|
||||
## section, losing tracking of correct dependencies.
|
||||
|
||||
# RUN: llvm-mc -filetype=obj --triple=x86_64 %s -o %t.o
|
||||
|
||||
## In the absence of a SECTIONS command.
|
||||
# RUN: ld.lld %t.o -o %t
|
||||
# RUN: llvm-readelf -S -x foo %t | FileCheck --check-prefixes=EXE,EXE-HEX %s
|
||||
# RUN: ld.lld %t.o -o %t.ro -r
|
||||
# RUN: llvm-readelf -S %t.ro | FileCheck --check-prefix=REL %s
|
||||
|
||||
## A non-relocatable link places readonly sections before read-executable sections.
|
||||
# EXE: [Nr] Name {{.*}} Flg Lk
|
||||
# EXE-NEXT: [ 0]
|
||||
# EXE-NEXT: [ 1] foo {{.*}} AL 2
|
||||
# EXE-NEXT: [ 2] .text {{.*}} AX 0
|
||||
|
||||
## An implementation detail: foo is moved after its linked-to section (orphan).
|
||||
# REL: [Nr] Name {{.*}} Flg Lk
|
||||
# REL-NEXT: [ 0]
|
||||
# REL-NEXT: [ 1] .text {{.*}} AX 0
|
||||
# REL-NEXT: [ 2] .text.f1 {{.*}} AX 0
|
||||
# REL-NEXT: [ 3] foo {{.*}} AL 2
|
||||
# REL-NEXT: [ 4] .text.f2 {{.*}} AX 0
|
||||
# REL-NEXT: [ 5] foo {{.*}} AL 4
|
||||
|
||||
## A SECTIONS command combines .text.*
|
||||
# RUN: echo 'SECTIONS { .text : { *(.text.f1) *(.text.f2) } }' > %t1.lds
|
||||
# RUN: ld.lld -T %t1.lds %t.o -o %t1
|
||||
# RUN: llvm-readelf -S -x foo %t1 | FileCheck --check-prefixes=EXE,EXE-HEX %s
|
||||
# RUN: ld.lld -T %t1.lds %t.o -o %t1.ro -r
|
||||
# RUN: llvm-readelf -S -x foo %t1.ro | FileCheck --check-prefix=REL1 %s
|
||||
|
||||
# REL1: [Nr] Name {{.*}} Flg Lk
|
||||
# REL1-NEXT: [ 0]
|
||||
# REL1-NEXT: [ 1] .text {{.*}} AX 0
|
||||
# REL1-NEXT: [ 2] foo {{.*}} AL 1
|
||||
|
||||
## A SECTIONS command separates .text.*
|
||||
# RUN: echo 'SECTIONS { .text.f1 : { *(.text.f1) } .text.f2 : { *(.text.f2) } }' > %t2.lds
|
||||
# RUN: ld.lld -T %t2.lds %t.o -o %t2
|
||||
# RUN: llvm-readelf -S -x foo %t2 | FileCheck --check-prefixes=EXE2,EXE-HEX %s
|
||||
# RUN: ld.lld -T %t2.lds %t.o -o %t2.ro -r
|
||||
# RUN: llvm-readelf -S %t2.ro | FileCheck --check-prefixes=REL2 %s
|
||||
|
||||
# EXE2: [Nr] Name {{.*}} Flg Lk
|
||||
# EXE2-NEXT: [ 0]
|
||||
# EXE2-NEXT: [ 1] foo {{.*}} AL 2
|
||||
# EXE2-NEXT: [ 2] .text.f1 {{.*}} AX 0
|
||||
# EXE2-NEXT: [ 3] .text.f2 {{.*}} AX 0
|
||||
|
||||
# REL2: [Nr] Name {{.*}} Flg Lk
|
||||
# REL2-NEXT: [ 0]
|
||||
# REL2-NEXT: [ 1] .text.f1 {{.*}} AX 0
|
||||
# REL2-NEXT: [ 2] .text.f2 {{.*}} AX 0
|
||||
# REL2-NEXT: [ 3] .text {{.*}} AX 0
|
||||
# REL2-NEXT: [ 4] foo {{.*}} AL 1
|
||||
# REL2-NEXT: [ 5] foo {{.*}} AL 2
|
||||
|
||||
# EXE-HEX: Hex dump of section 'foo':
|
||||
# EXE-HEX-NEXT: 0102
|
||||
|
||||
.section .text.f1,"ax",@progbits
|
||||
ret
|
||||
.section .text.f2,"ax",@progbits
|
||||
ret
|
||||
|
||||
.section foo,"ao",@progbits,.text.f2
|
||||
.byte 2
|
||||
.section foo,"ao",@progbits,.text.f1
|
||||
.byte 1
|
@ -1,36 +0,0 @@
|
||||
// REQUIRES: x86
|
||||
// RUN: llvm-mc %s -o %t.o -filetype=obj --triple=x86_64-unknown-linux
|
||||
// RUN: ld.lld %t.o -o %t -r
|
||||
// RUN: llvm-readelf -S %t | FileCheck --check-prefix=DIFFERENT %s
|
||||
// RUN: echo 'SECTIONS { .text.f1 : { *(.text.f1) } .text.f2 : { *(.text.f2) } }' > %t.lds
|
||||
// RUN: ld.lld %t.o -o %t -r %t.lds
|
||||
// RUN: llvm-readelf -S %t | FileCheck --check-prefix=DIFFERENT %s
|
||||
// RUN: echo 'SECTIONS { .text : { *(.text.f1) *(.text.f2) } }' > %t.lds
|
||||
// RUN: ld.lld %t.o -o %t -r %t.lds
|
||||
// RUN: llvm-readelf -S -x foo %t | FileCheck --check-prefix=SAME %s
|
||||
|
||||
/// Test that SHF_LINK_ORDER sections with different linked sections
|
||||
/// aren't merged.
|
||||
|
||||
.section .text.f1,"ax",@progbits
|
||||
.globl f1
|
||||
f1:
|
||||
ret
|
||||
|
||||
.section .text.f2,"ax",@progbits
|
||||
.globl f2
|
||||
f2:
|
||||
ret
|
||||
|
||||
// SAME: foo
|
||||
// DIFFERENT: foo
|
||||
.section foo,"ao",@progbits,.text.f2,unique,2
|
||||
.quad 2
|
||||
|
||||
// SAME-NOT: foo
|
||||
// DIFFERENT: foo
|
||||
.section foo,"ao",@progbits,.text.f1,unique,1
|
||||
.quad 1
|
||||
|
||||
// SAME: Hex dump of section 'foo':
|
||||
// SAME: 01000000 00000000 02000000 00000000
|
Loading…
x
Reference in New Issue
Block a user