118 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o3 4## Test the INPUT_SECTION_FLAGS feature. It prefixes an input section list and5## restricts matches to sections that have the required flags and do not have6## any of the must not have flags.7 8## Uniquely identify each .sec section by flag alone, with .text going into9## to the SHF_EXECINSTR requiring .outsec210# RUN: echo "SECTIONS { \11# RUN: .outsec1 : { INPUT_SECTION_FLAGS(SHF_ALLOC & !SHF_EXECINSTR & \12# RUN: !SHF_WRITE & !SHF_MERGE) *(.sec.*) } \13# RUN: .outsec2 : { INPUT_SECTION_FLAGS(SHF_ALLOC & SHF_EXECINSTR & !SHF_WRITE\14# RUN: & !SHF_MERGE) *(.sec.* .text) } \15# RUN: .outsec3 : { INPUT_SECTION_FLAGS(SHF_WRITE) *(.sec.*) } \16# RUN: .outsec4 : { INPUT_SECTION_FLAGS(SHF_MERGE & !SHF_STRINGS) *(.sec.*) } \17# RUN: .outsec5 : { INPUT_SECTION_FLAGS(SHF_STRINGS) *(.sec.*) } \18# RUN: .outsec6 : { INPUT_SECTION_FLAGS(!SHF_TLS & !SHF_EXCLUDE & !SHF_COMPRESSED & \19# RUN: !SHF_ARM_PURECODE & !SHF_AARCH64_PURECODE) *(.sec.*) } \20# RUN: } " > %t.script21# RUN: ld.lld -o %t1 --script %t.script %t.o22# RUN: llvm-readobj --symbols %t1 | FileCheck %s23# CHECK: Name: _start24# CHECK: Section: .outsec225# CHECK: Name: s126# CHECK: Section: .outsec127# CHECK: Name: s228# CHECK: Section: .outsec229# CHECK: Name: s330# CHECK: Section: .outsec331# CHECK: Name: s432# CHECK: Section: .outsec433# CHECK: Name: s534# CHECK: Section: .outsec535 36## Same test but using OVERLAY.37# RUN: echo "SECTIONS { \38# RUN: OVERLAY 0x1000 : AT ( 0x4000 ) { \39# RUN: .outsec1 { INPUT_SECTION_FLAGS(SHF_ALLOC & !SHF_EXECINSTR & \40# RUN: !SHF_WRITE & !SHF_MERGE) *(.sec.*) }\41# RUN: .outsec2 { INPUT_SECTION_FLAGS(SHF_ALLOC & SHF_EXECINSTR & !SHF_WRITE \42# RUN: & !SHF_MERGE) *(.sec.* .text) } \43# RUN: .outsec3 { INPUT_SECTION_FLAGS(SHF_WRITE) *(.sec.*) } \44# RUN: .outsec4 { INPUT_SECTION_FLAGS(SHF_MERGE & !SHF_STRINGS) *(.sec.*) } \45# RUN: .outsec5 { INPUT_SECTION_FLAGS(SHF_STRINGS) *(.sec.*) } \46# RUN: } } " > %t2.script47 48# RUN: ld.lld -o %t2 --script %t2.script %t.o49# RUN: llvm-readobj --symbols %t2 | FileCheck %s50 51## Same test but using hex representations of the flags.52# RUN: echo "SECTIONS { \53# RUN: .outsec1 : { INPUT_SECTION_FLAGS(0x2 & !0x4 & !0x1 & !0x10) *(.sec.*) }\54# RUN: .outsec2 : { INPUT_SECTION_FLAGS(0x2 & 0x4 & !0x1 & !0x10) \55# RUN: *(.sec.* .text) } \56# RUN: .outsec3 : { INPUT_SECTION_FLAGS(0x1) *(.sec.*) } \57# RUN: .outsec4 : { INPUT_SECTION_FLAGS(0x10 & !0x20) *(.sec.*) } \58# RUN: .outsec5 : { INPUT_SECTION_FLAGS(0x20) *(.sec.*) } \59# RUN: } " > %t3.script60 61# RUN: ld.lld -o %t3 --script %t3.script %t.o62# RUN: llvm-readobj --symbols %t3 | FileCheck %s63 64## Check that we can handle multiple InputSectionDescriptions in a single65## OutputSection66# RUN: echo "SECTIONS { \67# RUN: .outsec1 : { INPUT_SECTION_FLAGS(SHF_ALLOC & !SHF_EXECINSTR & \68# RUN: !SHF_WRITE & !SHF_MERGE) *(.sec.*) ; \69# RUN: INPUT_SECTION_FLAGS(SHF_ALLOC & SHF_EXECINSTR & !SHF_WRITE\70# RUN: & !SHF_MERGE) *(.sec.* *.text) }\71# RUN: } " > %t4.script72 73# RUN: ld.lld -o %t4 --script %t4.script %t.o74# RUN: llvm-readobj --symbols %t4 | FileCheck --check-prefix MULTIPLE %s75 76# MULTIPLE: Name: _start77# MULTIPLE: Section: .outsec178# MULTIPLE: Name: s179# MULTIPLE: Section: .outsec180# MULTIPLE: Name: s281# MULTIPLE: Section: .outsec182# MULTIPLE: Name: s383# MULTIPLE: Section: .sec.aw84# MULTIPLE: Name: s485# MULTIPLE: Section: .sec.aM86# MULTIPLE: Name: s587# MULTIPLE: Section: .sec.aMS88 89 .text90 .global _start91_start:92 nop93 94 .section .sec.a, "a", @progbits95 .globl s196s1:97 .long 198 99 .section .sec.ax, "ax", @progbits100 .globl s2101s2:102 .long 2103 104 .section .sec.aw, "aw", @progbits105 .globl s3106s3:107 .long 3108 109 .section .sec.aM, "aM", @progbits, 4110 .globl s4111s4:112 .long 4113 114 .section .sec.aMS, "aMS", @progbits, 1115 .globl s5116s5:117 .asciz "a"118