75 lines · plain
1# REQUIRES: x862## Test how we set the sh_link field of a SHF_LINK_ORDER output section.3## Additionally, test that in a relocatable link, SHF_LINK_ORDER sections are4## not combined. Combining them will arbitrarily choose a single output5## section, losing tracking of correct dependencies.6 7# RUN: llvm-mc -filetype=obj --triple=x86_64 %s -o %t.o8 9## In the absence of a SECTIONS command.10# RUN: ld.lld %t.o -o %t11# RUN: llvm-readelf -S -x foo %t | FileCheck --check-prefixes=EXE,EXE-HEX %s12# RUN: ld.lld %t.o -o %t.ro -r13# RUN: llvm-readelf -S %t.ro | FileCheck --check-prefix=REL %s14 15## A non-relocatable link places readonly sections before read-executable sections.16# EXE: [Nr] Name {{.*}} Flg Lk17# EXE-NEXT: [ 0]18# EXE-NEXT: [ 1] foo {{.*}} AL 219# EXE-NEXT: [ 2] .text {{.*}} AX 020 21## An implementation detail: foo is moved after its linked-to section (orphan).22# REL: [Nr] Name {{.*}} Flg Lk23# REL-NEXT: [ 0]24# REL-NEXT: [ 1] .text {{.*}} AX 025# REL-NEXT: [ 2] .text.f1 {{.*}} AX 026# REL-NEXT: [ 3] foo {{.*}} AL 227# REL-NEXT: [ 4] .text.f2 {{.*}} AX 028# REL-NEXT: [ 5] foo {{.*}} AL 429 30## A SECTIONS command combines .text.*31# RUN: echo 'SECTIONS { .text : { *(.text.f1) *(.text.f2) } }' > %t1.lds32# RUN: ld.lld -T %t1.lds %t.o -o %t133# RUN: llvm-readelf -S -x foo %t1 | FileCheck --check-prefixes=EXE,EXE-HEX %s34# RUN: ld.lld -T %t1.lds %t.o -o %t1.ro -r35# RUN: llvm-readelf -S -x foo %t1.ro | FileCheck --check-prefix=REL1 %s36 37# REL1: [Nr] Name {{.*}} Flg Lk38# REL1-NEXT: [ 0]39# REL1-NEXT: [ 1] .text {{.*}} AX 040# REL1-NEXT: [ 2] foo {{.*}} AL 141 42## A SECTIONS command separates .text.*43# RUN: echo 'SECTIONS { .text.f1 : { *(.text.f1) } .text.f2 : { *(.text.f2) } }' > %t2.lds44# RUN: ld.lld -T %t2.lds %t.o -o %t245# RUN: llvm-readelf -S -x foo %t2 | FileCheck --check-prefixes=EXE2,EXE-HEX %s46# RUN: ld.lld -T %t2.lds %t.o -o %t2.ro -r47# RUN: llvm-readelf -S %t2.ro | FileCheck --check-prefixes=REL2 %s48 49# EXE2: [Nr] Name {{.*}} Flg Lk50# EXE2-NEXT: [ 0]51# EXE2-NEXT: [ 1] foo {{.*}} AL 252# EXE2-NEXT: [ 2] .text.f1 {{.*}} AX 053# EXE2-NEXT: [ 3] .text.f2 {{.*}} AX 054 55# REL2: [Nr] Name {{.*}} Flg Lk56# REL2-NEXT: [ 0]57# REL2-NEXT: [ 1] .text.f1 {{.*}} AX 058# REL2-NEXT: [ 2] .text.f2 {{.*}} AX 059# REL2-NEXT: [ 3] .text {{.*}} AX 060# REL2-NEXT: [ 4] foo {{.*}} AL 161# REL2-NEXT: [ 5] foo {{.*}} AL 262 63# EXE-HEX: Hex dump of section 'foo':64# EXE-HEX-NEXT: 010265 66.section .text.f1,"ax",@progbits67ret68.section .text.f2,"ax",@progbits69ret70 71.section foo,"ao",@progbits,.text.f272.byte 273.section foo,"ao",@progbits,.text.f174.byte 175