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: 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: stp x16, x30, [sp, #-16]! +# BTISO-NEXT: adrp x16, #131072 +# BTISO-NEXT: ldr x17, [x16, #1136] +# BTISO-NEXT: add x16, x16, #1136 +# BTISO-NEXT: br x17 +# BTISO-NEXT: nop +# BTISO-NEXT: nop +# BTISO: 0000000000010380 func3@plt: +# BTISO-NEXT: 10380: adrp x16, #131072 +# BTISO-NEXT: ldr x17, [x16, #1144] +# BTISO-NEXT: add x16, x16, #1144 +# BTISO-NEXT: 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: 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: stp x16, x30, [sp, #-16]! +# EXECBTI-NEXT: adrp x16, #131072 +# EXECBTI-NEXT: ldr x17, [x16, #1160] +# EXECBTI-NEXT: add x16, x16, #1160 +# EXECBTI-NEXT: br x17 +# EXECBTI-NEXT: nop +# EXECBTI-NEXT: nop +# EXECBTI: 0000000000210370 func2@plt: +# EXECBTI-NEXT: 210370: bti c +# EXECBTI-NEXT: adrp x16, #131072 +# EXECBTI-NEXT: ldr x17, [x16, #1168] +# EXECBTI-NEXT: add x16, x16, #1168 +# EXECBTI-NEXT: br x17 +# EXECBTI-NEXT: 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: 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: stp x16, x30, [sp, #-16]! +# PIE-NEXT: adrp x16, #131072 +# PIE-NEXT: ldr x17, [x16, #1160] +# PIE-NEXT: add x16, x16, #1160 +# PIE-NEXT: br x17 +# PIE-NEXT: nop +# PIE-NEXT: nop +# PIE: 0000000000010370 func2@plt: +# PIE-NEXT: 10370: bti c +# PIE-NEXT: adrp x16, #131072 +# PIE-NEXT: ldr x17, [x16, #1168] +# PIE-NEXT: add x16, x16, #1168 +# PIE-NEXT: br x17 +# PIE-NEXT: nop ## Build and executable with not all relocatable inputs having the BTI ## .note.property, expect no bti c and no .note.gnu.property entry @@ -148,24 +150,24 @@ # NOEX: Disassembly of section .text: # NOEX: 00000000002102e0 func1: # NOEX-NEXT: 2102e0: bl #48 -# NOEX-NEXT: 2102e4: ret +# NOEX-NEXT: ret # NOEX: 00000000002102e8 func3: # NOEX-NEXT: 2102e8: ret # NOEX: Disassembly of section .plt: # NOEX: 00000000002102f0 .plt: # NOEX-NEXT: 2102f0: stp x16, x30, [sp, #-16]! -# NOEX-NEXT: 2102f4: adrp x16, #131072 -# NOEX-NEXT: 2102f8: ldr x17, [x16, #1024] -# NOEX-NEXT: 2102fc: add x16, x16, #1024 -# NOEX-NEXT: 210300: br x17 -# NOEX-NEXT: 210304: nop -# NOEX-NEXT: 210308: nop -# NOEX-NEXT: 21030c: nop +# NOEX-NEXT: adrp x16, #131072 +# NOEX-NEXT: ldr x17, [x16, #1024] +# NOEX-NEXT: add x16, x16, #1024 +# NOEX-NEXT: br x17 +# NOEX-NEXT: nop +# NOEX-NEXT: nop +# NOEX-NEXT: nop # NOEX: 0000000000210310 func2@plt: # NOEX-NEXT: 210310: adrp x16, #131072 -# NOEX-NEXT: 210314: ldr x17, [x16, #1032] -# NOEX-NEXT: 210318: add x16, x16, #1032 -# NOEX-NEXT: 21031c: br x17 +# NOEX-NEXT: ldr x17, [x16, #1032] +# NOEX-NEXT: add x16, x16, #1032 +# NOEX-NEXT: br x17 ## Force BTI entries with the --force-bti command line option. Expect a warning ## from the file without the .note.gnu.property. @@ -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: 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: stp x16, x30, [sp, #-16]! +# FORCE-NEXT: adrp x16, #131072 +# FORCE-NEXT: ldr x17, [x16, #1192] +# FORCE-NEXT: add x16, x16, #1192 +# FORCE-NEXT: br x17 +# FORCE-NEXT: nop +# FORCE-NEXT: nop +# FORCE: 00000000002103a0 func2@plt: +# FORCE-NEXT: 2103a0: bti c +# FORCE-NEXT: adrp x16, #131072 +# FORCE-NEXT: ldr x17, [x16, #1200] +# FORCE-NEXT: add x16, x16, #1200 +# FORCE-NEXT: br x17 +# FORCE-NEXT: 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: 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: stp x16, x30, [sp, #-16]! +# BTIPACSO-NEXT: adrp x16, #131072 +# BTIPACSO-NEXT: ldr x17, [x16, #1160] +# BTIPACSO-NEXT: add x16, x16, #1160 +# BTIPACSO-NEXT: br x17 +# BTIPACSO-NEXT: nop +# BTIPACSO-NEXT: nop +# BTIPACSO: 0000000000010380 func3@plt: +# BTIPACSO-NEXT: 10380: adrp x16, #131072 +# BTIPACSO-NEXT: ldr x17, [x16, #1168] +# BTIPACSO-NEXT: add x16, x16, #1168 +# BTIPACSO-NEXT: autia1716 +# BTIPACSO-NEXT: br x17 +# BTIPACSO-NEXT: 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: ret +# BTIPACEX-NEXT: 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: stp x16, x30, [sp, #-16]! +# BTIPACEX-NEXT: adrp x16, #131072 +# BTIPACEX-NEXT: ldr x17, [x16, #1208] +# BTIPACEX-NEXT: add x16, x16, #1208 +# BTIPACEX-NEXT: br x17 +# BTIPACEX-NEXT: nop +# BTIPACEX-NEXT: nop +# BTIPACEX: 00000000002103a0 func2@plt: +# BTIPACEX-NEXT: 2103a0: bti c +# BTIPACEX-NEXT: adrp x16, #131072 +# BTIPACEX-NEXT: ldr x17, [x16, #1216] +# BTIPACEX-NEXT: add x16, x16, #1216 +# BTIPACEX-NEXT: autia1716 +# BTIPACEX-NEXT: br x17 ## Check that combinations of BTI+PAC with 0 properties results in standard PLT @@ -86,25 +86,25 @@ # EX: Disassembly of section .text: # EX: 00000000002102e0 func1: # EX-NEXT: 2102e0: bl #48 -# EX-NEXT: 2102e4: ret -# EX-NEXT: 2102e8: ret +# EX-NEXT: ret +# EX-NEXT: ret # EX: 00000000002102ec func3: # EX-NEXT: 2102ec: ret # EX: Disassembly of section .plt: # EX: 00000000002102f0 .plt: # EX-NEXT: 2102f0: stp x16, x30, [sp, #-16]! -# EX-NEXT: 2102f4: adrp x16, #131072 -# EX-NEXT: 2102f8: ldr x17, [x16, #1024] -# EX-NEXT: 2102fc: add x16, x16, #1024 -# EX-NEXT: 210300: br x17 -# EX-NEXT: 210304: nop -# EX-NEXT: 210308: nop -# EX-NEXT: 21030c: nop +# EX-NEXT: adrp x16, #131072 +# EX-NEXT: ldr x17, [x16, #1024] +# EX-NEXT: add x16, x16, #1024 +# EX-NEXT: br x17 +# EX-NEXT: nop +# EX-NEXT: nop +# EX-NEXT: nop # EX: 0000000000210310 func2@plt: # EX: 210310: adrp x16, #131072 -# EX-NEXT: 210314: ldr x17, [x16, #1032] -# EX-NEXT: 210318: add x16, x16, #1032 -# EX-NEXT: 21031c: br x17 +# EX-NEXT: ldr x17, [x16, #1032] +# EX-NEXT: add x16, x16, #1032 +# EX-NEXT: br x17 # NODYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT) # NODYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT) Index: lld/test/ELF/aarch64-feature-pac.s =================================================================== --- lld/test/ELF/aarch64-feature-pac.s +++ lld/test/ELF/aarch64-feature-pac.s @@ -15,22 +15,22 @@ # NOPAC: 00000000000102b8 func2: # NOPAC-NEXT: 102b8: bl #56 -# NOPAC-NEXT: 102bc: ret +# NOPAC-NEXT: ret # NOPAC: Disassembly of section .plt: # NOPAC: 00000000000102d0 .plt: # NOPAC-NEXT: 102d0: stp x16, x30, [sp, #-16]! -# NOPAC-NEXT: 102d4: adrp x16, #131072 -# NOPAC-NEXT: 102d8: ldr x17, [x16, #960] -# NOPAC-NEXT: 102dc: add x16, x16, #960 -# NOPAC-NEXT: 102e0: br x17 -# NOPAC-NEXT: 102e4: nop -# NOPAC-NEXT: 102e8: nop -# NOPAC-NEXT: 102ec: nop +# NOPAC-NEXT: adrp x16, #131072 +# NOPAC-NEXT: ldr x17, [x16, #960] +# NOPAC-NEXT: add x16, x16, #960 +# NOPAC-NEXT: br x17 +# NOPAC-NEXT: nop +# NOPAC-NEXT: nop +# NOPAC-NEXT: nop # NOPAC: 00000000000102f0 func3@plt: # NOPAC-NEXT: 102f0: adrp x16, #131072 -# NOPAC-NEXT: 102f4: ldr x17, [x16, #968] -# NOPAC-NEXT: 102f8: add x16, x16, #968 -# NOPAC-NEXT: 102fc: br x17 +# NOPAC-NEXT: ldr x17, [x16, #968] +# NOPAC-NEXT: add x16, x16, #968 +# NOPAC-NEXT: br x17 # NOPACDYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT) # NOPACDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT) @@ -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: 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: adrp x16, #131072 +# PACSO-NEXT: ldr x17, [x16, #1144] +# PACSO-NEXT: add x16, x16, #1144 +# PACSO-NEXT: br x17 +# PACSO-NEXT: nop +# PACSO-NEXT: nop +# PACSO-NEXT: nop +# PACSO: 0000000000010380 func3@plt: +# PACSO-NEXT: 10380: adrp x16, #131072 +# PACSO-NEXT: ldr x17, [x16, #1152] +# PACSO-NEXT: add x16, x16, #1152 +# PACSO-NEXT: autia1716 +# PACSO-NEXT: br x17 +# PACSO-NEXT: 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: 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: adrp x16, #131072 +# PACPLT-NEXT: ldr x17, [x16, #1192] +# PACPLT-NEXT: add x16, x16, #1192 +# PACPLT-NEXT: br x17 +# PACPLT-NEXT: nop +# PACPLT-NEXT: nop +# PACPLT-NEXT: nop +# PACPLT: 00000000002103a0 func2@plt: +# PACPLT-NEXT: 2103a0: adrp x16, #131072 +# PACPLT-NEXT: ldr x17, [x16, #1200] +# PACPLT-NEXT: add x16, x16, #1200 +# PACPLT-NEXT: autia1716 +# PACPLT-NEXT: br x17 +# PACPLT-NEXT: 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: stp x16, x30, [sp, #-16]! +# CHECK-NEXT: adrp x16, #131072 +# CHECK-NEXT: ldr x17, [x16, #1272] +# CHECK-NEXT: add x16, x16, #1272 +# CHECK-NEXT: br x17 +# CHECK-NEXT: nop +# CHECK-NEXT: nop +# CHECK: 00000000000103a0 func1@plt: +# CHECK-NEXT: 103a0: bti c +# CHECK-NEXT: adrp x16, #131072 +# CHECK-NEXT: ldr x17, [x16, #1280] +# CHECK-NEXT: add x16, x16, #1280 +# CHECK-NEXT: br x17 +# CHECK-NEXT: 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: adrp x16, #131072 +# CHECK-NEXT: ldr x17, [x16, #1288] +# CHECK-NEXT: add x16, x16, #1288 +# CHECK-NEXT: br x17 +# CHECK-NEXT: nop .section ".note.gnu.property", "a" .long 4 Index: lld/test/ELF/pt-gnu-property.s =================================================================== --- /dev/null +++ lld/test/ELF/pt-gnu-property.s @@ -0,0 +1,45 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-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 segment type 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 0xc0000002 # GNU_PROPERTY_X86_FEATURE_1_AND +.long 4 +.long 1 # GNU_PROPERTY_X86_FEATURE_1_IBT +.long 0 + +.text +.globl _start + ret