Index: lld/ELF/Writer.cpp =================================================================== --- lld/ELF/Writer.cpp +++ lld/ELF/Writer.cpp @@ -2188,6 +2188,9 @@ if (config->zWxneeded) addHdr(PT_OPENBSD_WXNEEDED, PF_X); + if (OutputSection *cmd = findSection(".note.gnu.property", partNo)) + addHdr(PT_GNU_PROPERTY, PF_R)->add(cmd); + // Create one PT_NOTE per a group of contiguous SHT_NOTE sections with the // same alignment. PhdrEntry *note = nullptr; Index: lld/test/ELF/aarch64-feature-bti.s =================================================================== --- lld/test/ELF/aarch64-feature-bti.s +++ lld/test/ELF/aarch64-feature-bti.s @@ -55,28 +55,30 @@ # BTIDYN: 0x0000000070000001 (AARCH64_BTI_PLT) # BTIDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT) -# BTISO: 0000000000010310 func2: -# BTISO-NEXT: 10310: bl #48 -# BTISO-NEXT: 10314: ret +# BTISO: 0000000000010348 func2: +# BTISO-NEXT: 10348: bl #56 +# BTISO-NEXT: 1034c: ret +# BTISO: 0000000000010350 func3: +# BTISO-NEXT: 10350: ret # BTISO: Disassembly of section .plt: -# BTISO: 0000000000010320 .plt: -# BTISO-NEXT: 10320: bti c -# BTISO-NEXT: 10324: stp x16, x30, [sp, #-16]! -# BTISO-NEXT: 10328: adrp x16, #131072 -# BTISO-NEXT: 1032c: ldr x17, [x16, #1072] -# BTISO-NEXT: 10330: add x16, x16, #1072 -# BTISO-NEXT: 10334: br x17 -# BTISO-NEXT: 10338: nop -# BTISO-NEXT: 1033c: nop -# BTISO: 0000000000010340 func3@plt: -# BTISO-NEXT: 10340: adrp x16, #131072 -# BTISO-NEXT: 10344: ldr x17, [x16, #1080] -# BTISO-NEXT: 10348: add x16, x16, #1080 -# BTISO-NEXT: 1034c: br x17 +# BTISO: 0000000000010360 .plt: +# BTISO-NEXT: 10360: bti c +# BTISO-NEXT: 10364: stp x16, x30, [sp, #-16]! +# BTISO-NEXT: 10368: adrp x16, #131072 +# BTISO-NEXT: 1036c: ldr x17, [x16, #1136] +# BTISO-NEXT: 10370: add x16, x16, #1136 +# BTISO-NEXT: 10374: br x17 +# BTISO-NEXT: 10378: nop +# BTISO-NEXT: 1037c: nop +# BTISO: 0000000000010380 func3@plt: +# BTISO-NEXT: 10380: adrp x16, #131072 +# BTISO-NEXT: 10384: ldr x17, [x16, #1144] +# BTISO-NEXT: 10388: add x16, x16, #1144 +# BTISO-NEXT: 1038c: br x17 # SOGOTPLT2: Hex dump of section '.got.plt' -# SOGOTPLT2-NEXT: 0x00030420 00000000 00000000 00000000 00000000 -# SOGOTPLT2-NEXT: 0x00030430 00000000 00000000 20030100 00000000 +# SOGOTPLT2-NEXT: 0x00030460 00000000 00000000 00000000 00000000 +# SOGOTPLT2-NEXT: 0x00030470 00000000 00000000 60030100 00000000 ## Build an executable with all relocatable inputs having the BTI ## .note.gnu.property. We expect a bti c in front of all PLT entries as the @@ -89,26 +91,26 @@ # RUN: llvm-objdump -d -mattr=+bti --no-show-raw-insn %t.exe | FileCheck --check-prefix=EXECBTI %s # EXECBTI: Disassembly of section .text: -# EXECBTI: 0000000000210310 func1: -# EXECBTI-NEXT: 210310: bl #48 -# EXECBTI-NEXT: 210314: ret +# EXECBTI: 0000000000210348 func1: +# EXECBTI-NEXT: 210348: bl #40 +# EXECBTI-NEXT: 21034c: ret # EXECBTI: Disassembly of section .plt: -# EXECBTI: 0000000000210320 .plt: -# EXECBTI-NEXT: 210320: bti c -# EXECBTI-NEXT: 210324: stp x16, x30, [sp, #-16]! -# EXECBTI-NEXT: 210328: adrp x16, #131072 -# EXECBTI-NEXT: 21032c: ldr x17, [x16, #1112] -# EXECBTI-NEXT: 210330: add x16, x16, #1112 -# EXECBTI-NEXT: 210334: br x17 -# EXECBTI-NEXT: 210338: nop -# EXECBTI-NEXT: 21033c: nop -# EXECBTI: 0000000000210340 func2@plt: -# EXECBTI-NEXT: 210340: bti c -# EXECBTI-NEXT: 210344: adrp x16, #131072 -# EXECBTI-NEXT: 210348: ldr x17, [x16, #1120] -# EXECBTI-NEXT: 21034c: add x16, x16, #1120 -# EXECBTI-NEXT: 210350: br x17 -# EXECBTI-NEXT: 210354: nop +# EXECBTI: 0000000000210350 .plt: +# EXECBTI-NEXT: 210350: bti c +# EXECBTI-NEXT: 210354: stp x16, x30, [sp, #-16]! +# EXECBTI-NEXT: 210358: adrp x16, #131072 +# EXECBTI-NEXT: 21035c: ldr x17, [x16, #1160] +# EXECBTI-NEXT: 210360: add x16, x16, #1160 +# EXECBTI-NEXT: 210364: br x17 +# EXECBTI-NEXT: 210368: nop +# EXECBTI-NEXT: 21036c: nop +# EXECBTI: 0000000000210370 func2@plt: +# EXECBTI-NEXT: 210370: bti c +# EXECBTI-NEXT: 210374: adrp x16, #131072 +# EXECBTI-NEXT: 210378: ldr x17, [x16, #1168] +# EXECBTI-NEXT: 21037c: add x16, x16, #1168 +# EXECBTI-NEXT: 210380: br x17 +# EXECBTI-NEXT: 210384: nop ## We expect the same for PIE, as the address of an ifunc can escape # RUN: ld.lld --pie %t.o %t.so %t2.so -o %tpie.exe @@ -117,26 +119,26 @@ # RUN: llvm-objdump -d -mattr=+bti --no-show-raw-insn %tpie.exe | FileCheck --check-prefix=PIE %s # PIE: Disassembly of section .text: -# PIE: 0000000000010310 func1: -# PIE-NEXT: 10310: bl #48 -# PIE-NEXT: 10314: ret +# PIE: 0000000000010348 func1: +# PIE-NEXT: 10348: bl #40 +# PIE-NEXT: 1034c: ret # PIE: Disassembly of section .plt: -# PIE: 0000000000010320 .plt: -# PIE-NEXT: 10320: bti c -# PIE-NEXT: 10324: stp x16, x30, [sp, #-16]! -# PIE-NEXT: 10328: adrp x16, #131072 -# PIE-NEXT: 1032c: ldr x17, [x16, #1112] -# PIE-NEXT: 10330: add x16, x16, #1112 -# PIE-NEXT: 10334: br x17 -# PIE-NEXT: 10338: nop -# PIE-NEXT: 1033c: nop -# PIE: 0000000000010340 func2@plt: -# PIE-NEXT: 10340: bti c -# PIE-NEXT: 10344: adrp x16, #131072 -# PIE-NEXT: 10348: ldr x17, [x16, #1120] -# PIE-NEXT: 1034c: add x16, x16, #1120 -# PIE-NEXT: 10350: br x17 -# PIE-NEXT: 10354: nop +# PIE: 0000000000010350 .plt: +# PIE-NEXT: 10350: bti c +# PIE-NEXT: 10354: stp x16, x30, [sp, #-16]! +# PIE-NEXT: 10358: adrp x16, #131072 +# PIE-NEXT: 1035c: ldr x17, [x16, #1160] +# PIE-NEXT: 10360: add x16, x16, #1160 +# PIE-NEXT: 10364: br x17 +# PIE-NEXT: 10368: nop +# PIE-NEXT: 1036c: nop +# PIE: 0000000000010370 func2@plt: +# PIE-NEXT: 10370: bti c +# PIE-NEXT: 10374: adrp x16, #131072 +# PIE-NEXT: 10378: ldr x17, [x16, #1168] +# PIE-NEXT: 1037c: add x16, x16, #1168 +# PIE-NEXT: 10380: br x17 +# PIE-NEXT: 10384: nop ## Build and executable with not all relocatable inputs having the BTI ## .note.property, expect no bti c and no .note.gnu.property entry @@ -180,28 +182,28 @@ # RUN: llvm-objdump -d -mattr=+bti --no-show-raw-insn %tforcebti.exe | FileCheck --check-prefix=FORCE %s # FORCE: Disassembly of section .text: -# FORCE: 0000000000210338 func1: -# FORCE-NEXT: 210338: bl #56 -# FORCE-NEXT: 21033c: ret -# FORCE: 0000000000210340 func3: -# FORCE-NEXT: 210340: ret +# FORCE: 0000000000210370 func1: +# FORCE-NEXT: 210370: bl #48 +# FORCE-NEXT: 210374: ret +# FORCE: 0000000000210378 func3: +# FORCE-NEXT: 210378: ret # FORCE: Disassembly of section .plt: -# FORCE: 0000000000210350 .plt: -# FORCE-NEXT: 210350: bti c -# FORCE-NEXT: 210354: stp x16, x30, [sp, #-16]! -# FORCE-NEXT: 210358: adrp x16, #131072 -# FORCE-NEXT: 21035c: ldr x17, [x16, #1144] -# FORCE-NEXT: 210360: add x16, x16, #1144 -# FORCE-NEXT: 210364: br x17 -# FORCE-NEXT: 210368: nop -# FORCE-NEXT: 21036c: nop -# FORCE: 0000000000210370 func2@plt: -# FORCE-NEXT: 210370: bti c -# FORCE-NEXT: 210374: adrp x16, #131072 -# FORCE-NEXT: 210378: ldr x17, [x16, #1152] -# FORCE-NEXT: 21037c: add x16, x16, #1152 -# FORCE-NEXT: 210380: br x17 -# FORCE-NEXT: 210384: nop +# FORCE: 0000000000210380 .plt: +# FORCE-NEXT: 210380: bti c +# FORCE-NEXT: 210384: stp x16, x30, [sp, #-16]! +# FORCE-NEXT: 210388: adrp x16, #131072 +# FORCE-NEXT: 21038c: ldr x17, [x16, #1192] +# FORCE-NEXT: 210390: add x16, x16, #1192 +# FORCE-NEXT: 210394: br x17 +# FORCE-NEXT: 210398: nop +# FORCE-NEXT: 21039c: nop +# FORCE: 00000000002103a0 func2@plt: +# FORCE-NEXT: 2103a0: bti c +# FORCE-NEXT: 2103a4: adrp x16, #131072 +# FORCE-NEXT: 2103a8: ldr x17, [x16, #1200] +# FORCE-NEXT: 2103ac: add x16, x16, #1200 +# FORCE-NEXT: 2103b0: br x17 +# FORCE-NEXT: 2103b4: nop .section ".note.gnu.property", "a" .long 4 Index: lld/test/ELF/aarch64-feature-btipac.s =================================================================== --- lld/test/ELF/aarch64-feature-btipac.s +++ lld/test/ELF/aarch64-feature-btipac.s @@ -15,28 +15,28 @@ # RUN: llvm-readelf --dynamic-table %t.so | FileCheck --check-prefix BTIPACDYN %s # BTIPACSO: Disassembly of section .text: -# BTIPACSO: 0000000000010310 func2: -# BTIPACSO-NEXT: 10310: bl #48 -# BTIPACSO-NEXT: 10314: ret -# BTIPACSO: 0000000000010318 func3: -# BTIPACSO-NEXT: 10318: ret +# BTIPACSO: 0000000000010348 func2: +# BTIPACSO-NEXT: 10348: bl #56 +# BTIPACSO-NEXT: 1034c: ret +# BTIPACSO: 0000000000010350 func3: +# BTIPACSO-NEXT: 10350: ret # BTIPACSO: Disassembly of section .plt: -# BTIPACSO: 0000000000010320 .plt: -# BTIPACSO-NEXT: 10320: bti c -# BTIPACSO-NEXT: 10324: stp x16, x30, [sp, #-16]! -# BTIPACSO-NEXT: 10328: adrp x16, #131072 -# BTIPACSO-NEXT: 1032c: ldr x17, [x16, #1096] -# BTIPACSO-NEXT: 10330: add x16, x16, #1096 -# BTIPACSO-NEXT: 10334: br x17 -# BTIPACSO-NEXT: 10338: nop -# BTIPACSO-NEXT: 1033c: nop -# BTIPACSO: 0000000000010340 func3@plt: -# BTIPACSO-NEXT: 10340: adrp x16, #131072 -# BTIPACSO-NEXT: 10344: ldr x17, [x16, #1104] -# BTIPACSO-NEXT: 10348: add x16, x16, #1104 -# BTIPACSO-NEXT: 1034c: autia1716 -# BTIPACSO-NEXT: 10350: br x17 -# BTIPACSO-NEXT: 10354: nop +# BTIPACSO: 0000000000010360 .plt: +# BTIPACSO-NEXT: 10360: bti c +# BTIPACSO-NEXT: 10364: stp x16, x30, [sp, #-16]! +# BTIPACSO-NEXT: 10368: adrp x16, #131072 +# BTIPACSO-NEXT: 1036c: ldr x17, [x16, #1160] +# BTIPACSO-NEXT: 10370: add x16, x16, #1160 +# BTIPACSO-NEXT: 10374: br x17 +# BTIPACSO-NEXT: 10378: nop +# BTIPACSO-NEXT: 1037c: nop +# BTIPACSO: 0000000000010380 func3@plt: +# BTIPACSO-NEXT: 10380: adrp x16, #131072 +# BTIPACSO-NEXT: 10384: ldr x17, [x16, #1168] +# BTIPACSO-NEXT: 10388: add x16, x16, #1168 +# BTIPACSO-NEXT: 1038c: autia1716 +# BTIPACSO-NEXT: 10390: br x17 +# BTIPACSO-NEXT: 10394: nop # BTIPACPROP: Properties: aarch64 feature: BTI, PAC @@ -53,29 +53,29 @@ # RUN: llvm-readelf --dynamic-table %t.exe | FileCheck --check-prefix BTIPACDYN %s # BTIPACEX: Disassembly of section .text: -# BTIPACEX: 0000000000210338 func1: -# BTIPACEX-NEXT: 210338: bl #56 -# BTIPACEX-NEXT: 21033c: ret -# BTIPACEX-NEXT: 210340: ret -# BTIPACEX: 0000000000210344 func3: -# BTIPACEX-NEXT: 210344: ret +# BTIPACEX: 0000000000210370 func1: +# BTIPACEX-NEXT: 210370: bl #48 +# BTIPACEX-NEXT: 210374: ret +# BTIPACEX-NEXT: 210378: ret +# BTIPACEX: 000000000021037c func3: +# BTIPACEX-NEXT: 21037c: ret # BTIPACEX: Disassembly of section .plt: -# BTIPACEX: 0000000000210350 .plt: -# BTIPACEX-NEXT: 210350: bti c -# BTIPACEX-NEXT: 210354: stp x16, x30, [sp, #-16]! -# BTIPACEX-NEXT: 210358: adrp x16, #131072 -# BTIPACEX-NEXT: 21035c: ldr x17, [x16, #1160] -# BTIPACEX-NEXT: 210360: add x16, x16, #1160 -# BTIPACEX-NEXT: 210364: br x17 -# BTIPACEX-NEXT: 210368: nop -# BTIPACEX-NEXT: 21036c: nop -# BTIPACEX: 0000000000210370 func2@plt: -# BTIPACEX-NEXT: 210370: bti c -# BTIPACEX-NEXT: 210374: adrp x16, #131072 -# BTIPACEX-NEXT: 210378: ldr x17, [x16, #1168] -# BTIPACEX-NEXT: 21037c: add x16, x16, #1168 -# BTIPACEX-NEXT: 210380: autia1716 -# BTIPACEX-NEXT: 210384: br x17 +# BTIPACEX: 0000000000210380 .plt: +# BTIPACEX-NEXT: 210380: bti c +# BTIPACEX-NEXT: 210384: stp x16, x30, [sp, #-16]! +# BTIPACEX-NEXT: 210388: adrp x16, #131072 +# BTIPACEX-NEXT: 21038c: ldr x17, [x16, #1208] +# BTIPACEX-NEXT: 210390: add x16, x16, #1208 +# BTIPACEX-NEXT: 210394: br x17 +# BTIPACEX-NEXT: 210398: nop +# BTIPACEX-NEXT: 21039c: nop +# BTIPACEX: 00000000002103a0 func2@plt: +# BTIPACEX-NEXT: 2103a0: bti c +# BTIPACEX-NEXT: 2103a4: adrp x16, #131072 +# BTIPACEX-NEXT: 2103a8: ldr x17, [x16, #1216] +# BTIPACEX-NEXT: 2103ac: add x16, x16, #1216 +# BTIPACEX-NEXT: 2103b0: autia1716 +# BTIPACEX-NEXT: 2103b4: br x17 ## Check that combinations of BTI+PAC with 0 properties results in standard PLT Index: lld/test/ELF/aarch64-feature-pac.s =================================================================== --- lld/test/ELF/aarch64-feature-pac.s +++ lld/test/ELF/aarch64-feature-pac.s @@ -44,34 +44,36 @@ ## PAC has no effect on PLT[0], for PLT[N] autia1716 is used to authenticate ## the address in x17 (context in x16) before branching to it. The dynamic ## loader is responsible for calling pacia1716 on the entry. -# PACSO: 0000000000010310 func2: -# PACSO-NEXT: 10310: bl #48 -# PACSO-NEXT: 10314: ret +# PACSO: 0000000000010348 func2: +# PACSO-NEXT: 10348: bl #56 +# PACSO-NEXT: 1034c: ret +# PACSO: 0000000000010350 func3: +# PACSO-NEXT: 10350: ret # PACSO: Disassembly of section .plt: -# PACSO: 0000000000010320 .plt: -# PACSO-NEXT: 10320: stp x16, x30, [sp, #-16]! -# PACSO-NEXT: 10324: adrp x16, #131072 -# PACSO-NEXT: 10328: ldr x17, [x16, #1080] -# PACSO-NEXT: 1032c: add x16, x16, #1080 -# PACSO-NEXT: 10330: br x17 -# PACSO-NEXT: 10334: nop -# PACSO-NEXT: 10338: nop -# PACSO-NEXT: 1033c: nop -# PACSO: 0000000000010340 func3@plt: -# PACSO-NEXT: 10340: adrp x16, #131072 -# PACSO-NEXT: 10344: ldr x17, [x16, #1088] -# PACSO-NEXT: 10348: add x16, x16, #1088 -# PACSO-NEXT: 1034c: autia1716 -# PACSO-NEXT: 10350: br x17 -# PACSO-NEXT: 10354: nop +# PACSO: 0000000000010360 .plt: +# PACSO-NEXT: 10360: stp x16, x30, [sp, #-16]! +# PACSO-NEXT: 10364: adrp x16, #131072 +# PACSO-NEXT: 10368: ldr x17, [x16, #1144] +# PACSO-NEXT: 1036c: add x16, x16, #1144 +# PACSO-NEXT: 10370: br x17 +# PACSO-NEXT: 10374: nop +# PACSO-NEXT: 10378: nop +# PACSO-NEXT: 1037c: nop +# PACSO: 0000000000010380 func3@plt: +# PACSO-NEXT: 10380: adrp x16, #131072 +# PACSO-NEXT: 10384: ldr x17, [x16, #1152] +# PACSO-NEXT: 10388: add x16, x16, #1152 +# PACSO-NEXT: 1038c: autia1716 +# PACSO-NEXT: 10390: br x17 +# PACSO-NEXT: 10394: nop # SOGOTPLT: Hex dump of section '.got.plt': # SOGOTPLT-NEXT: 0x000303b0 00000000 00000000 00000000 00000000 # SOGOTPLT-NEXT: 0x000303c0 00000000 00000000 d0020100 00000000 # SOGOTPLT2: Hex dump of section '.got.plt': -# SOGOTPLT2-NEXT: 0x00030428 00000000 00000000 00000000 00000000 -# SOGOTPLT2-NEXT: 0x00030438 00000000 00000000 20030100 00000000 +# SOGOTPLT2-NEXT: 0x00030468 00000000 00000000 00000000 00000000 +# SOGOTPLT2-NEXT: 0x00030478 00000000 00000000 60030100 00000000 # PACPROP: Properties: aarch64 feature: PAC @@ -89,29 +91,28 @@ # RUN: llvm-objdump -d -mattr=+v8.3a --no-show-raw-insn %tpacplt.exe | FileCheck --check-prefix PACPLT %s # PACPLT: Disassembly of section .text: -# PACPLT: 0000000000210338 func1: -# PACPLT-NEXT: 210338: bl #56 -# PACPLT-NEXT: 21033c: ret -# PACPLT: 0000000000210340 func3: -# PACPLT-NEXT: 210340: ret +# PACPLT: 0000000000210370 func1: +# PACPLT-NEXT: 210370: bl #48 +# PACPLT-NEXT: 210374: ret +# PACPLT: 0000000000210378 func3: +# PACPLT-NEXT: 210378: ret # PACPLT: Disassembly of section .plt: -# PACPLT: 0000000000210350 .plt: -# PACPLT-NEXT: 210350: stp x16, x30, [sp, #-16]! -# PACPLT-NEXT: 210354: adrp x16, #131072 -# PACPLT-NEXT: 210358: ldr x17, [x16, #1144] -# PACPLT-NEXT: 21035c: add x16, x16, #1144 -# PACPLT-NEXT: 210360: br x17 -# PACPLT-NEXT: 210364: nop -# PACPLT-NEXT: 210368: nop -# PACPLT-NEXT: 21036c: nop -# PACPLT: 0000000000210370 func2@plt: -# PACPLT-NEXT: 210370: adrp x16, #131072 -# PACPLT-NEXT: 210374: ldr x17, [x16, #1152] -# PACPLT-NEXT: 210378: add x16, x16, #1152 -# PACPLT-NEXT: 21037c: autia1716 -# PACPLT-NEXT: 210380: br x17 -# PACPLT-NEXT: 210384: nop - +# PACPLT: 0000000000210380 .plt: +# PACPLT-NEXT: 210380: stp x16, x30, [sp, #-16]! +# PACPLT-NEXT: 210384: adrp x16, #131072 +# PACPLT-NEXT: 210388: ldr x17, [x16, #1192] +# PACPLT-NEXT: 21038c: add x16, x16, #1192 +# PACPLT-NEXT: 210390: br x17 +# PACPLT-NEXT: 210394: nop +# PACPLT-NEXT: 210398: nop +# PACPLT-NEXT: 21039c: nop +# PACPLT: 00000000002103a0 func2@plt: +# PACPLT-NEXT: 2103a0: adrp x16, #131072 +# PACPLT-NEXT: 2103a4: ldr x17, [x16, #1200] +# PACPLT-NEXT: 2103a8: add x16, x16, #1200 +# PACPLT-NEXT: 2103ac: autia1716 +# PACPLT-NEXT: 2103b0: br x17 +# PACPLT-NEXT: 2103b4: nop .section ".note.gnu.property", "a" .long 4 Index: lld/test/ELF/aarch64-ifunc-bti.s =================================================================== --- lld/test/ELF/aarch64-ifunc-bti.s +++ lld/test/ELF/aarch64-ifunc-bti.s @@ -4,37 +4,37 @@ # RUN: ld.lld --shared --soname=t1.so %t1.o -o %t1.so # RUN: ld.lld --pie %t1.so %t.o -o %t -# RUN: llvm-objdump -d -mattr=+bti -triple=aarch64-linux-gnu %t | FileCheck %s +# RUN: llvm-objdump -d --no-show-raw-insn -mattr=+bti -triple=aarch64-linux-gnu %t | FileCheck %s # When the address of an ifunc is taken using a non-got reference which clang # can do, LLD exports a canonical PLT entry that may have its address taken so # we must use bti c. # CHECK: Disassembly of section .plt: -# CHECK: 0000000000010340 .plt: -# CHECK-NEXT: 10340: 5f 24 03 d5 bti c -# CHECK-NEXT: 10344: f0 7b bf a9 stp x16, x30, [sp, #-16]! -# CHECK-NEXT: 10348: 10 01 00 90 adrp x16, #131072 -# CHECK-NEXT: 1034c: 11 5e 42 f9 ldr x17, [x16, #1208] -# CHECK-NEXT: 10350: 10 e2 12 91 add x16, x16, #1208 -# CHECK-NEXT: 10354: 20 02 1f d6 br x17 -# CHECK-NEXT: 10358: 1f 20 03 d5 nop -# CHECK-NEXT: 1035c: 1f 20 03 d5 nop -# CHECK: 0000000000010360 func1@plt: -# CHECK-NEXT: 10360: 5f 24 03 d5 bti c -# CHECK-NEXT: 10364: 10 01 00 90 adrp x16, #131072 -# CHECK-NEXT: 10368: 11 62 42 f9 ldr x17, [x16, #1216] -# CHECK-NEXT: 1036c: 10 02 13 91 add x16, x16, #1216 -# CHECK-NEXT: 10370: 20 02 1f d6 br x17 -# CHECK-NEXT: 10374: 1f 20 03 d5 nop +# CHECK: 0000000000010380 .plt: +# CHECK-NEXT: 10380: bti c +# CHECK-NEXT: 10384: stp x16, x30, [sp, #-16]! +# CHECK-NEXT: 10388: adrp x16, #131072 +# CHECK-NEXT: 1038c: ldr x17, [x16, #1272] +# CHECK-NEXT: 10390: add x16, x16, #1272 +# CHECK-NEXT: 10394: br x17 +# CHECK-NEXT: 10398: nop +# CHECK-NEXT: 1039c: nop +# CHECK: 00000000000103a0 func1@plt: +# CHECK-NEXT: 103a0: bti c +# CHECK-NEXT: 103a4: adrp x16, #131072 +# CHECK-NEXT: 103a8: ldr x17, [x16, #1280] +# CHECK-NEXT: 103ac: add x16, x16, #1280 +# CHECK-NEXT: 103b0: br x17 +# CHECK-NEXT: 103b4: nop # CHECK-NEXT: ... -# CHECK: 0000000000010380 myfunc: -# CHECK-NEXT: 10380: 5f 24 03 d5 bti c -# CHECK-NEXT: 10384: 10 01 00 90 adrp x16, #131072 -# CHECK-NEXT: 10388: 11 66 42 f9 ldr x17, [x16, #1224] -# CHECK-NEXT: 1038c: 10 22 13 91 add x16, x16, #1224 -# CHECK-NEXT: 10390: 20 02 1f d6 br x17 -# CHECK-NEXT: 10394: 1f 20 03 d5 nop +# CHECK: 00000000000103c0 myfunc: +# CHECK-NEXT: 103c0: bti c +# CHECK-NEXT: 103c4: adrp x16, #131072 +# CHECK-NEXT: 103c8: ldr x17, [x16, #1288] +# CHECK-NEXT: 103cc: add x16, x16, #1288 +# CHECK-NEXT: 103d0: br x17 +# CHECK-NEXT: 103d4: nop .section ".note.gnu.property", "a" .long 4 Index: lld/test/ELF/aarch64-pt-gnu-property.s =================================================================== --- /dev/null +++ lld/test/ELF/aarch64-pt-gnu-property.s @@ -0,0 +1,45 @@ +# REQUIRES: aarch64 +# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t.o +# RUN: ld.lld %t.o -o %t +# RUN: llvm-readobj --sections --program-headers %t | FileCheck %s + +# Test that we generate the PT_GNU_PROPERTY section that describes the +# .note.gnu.property if it is present. + +# CHECK: Name: .note.gnu.property +# CHECK-NEXT: Type: SHT_NOTE (0x7) +# CHECK-NEXT: Flags [ (0x2) +# CHECK-NEXT: SHF_ALLOC (0x2) +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x200190 +# CHECK-NEXT: Offset: 0x190 +# CHECK-NEXT: Size: 32 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: 4 + +# CHECK: Type: PT_GNU_PROPERTY (0x6474E553) +# CHECK-NEXT: Offset: 0x190 +# CHECK-NEXT: VirtualAddress: 0x200190 +# CHECK-NEXT: PhysicalAddress: 0x200190 +# CHECK-NEXT: FileSize: 32 +# CHECK-NEXT: MemSize: 32 +# CHECK-NEXT: Flags [ (0x4) +# CHECK-NEXT: PF_R (0x4) +# CHECK-NEXT: ] +# CHECK-NEXT: Alignment: 4 + +.section ".note.gnu.property", "a" +.long 4 +.long 0x10 +.long 0x5 +.asciz "GNU" + +.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND +.long 4 +.long 3 // GNU_PROPERTY_AARCH64_FEATURE_1_BTI and PAC +.long 0 + +.text +.globl _start + ret