x86/vdso: VDSO updates and fixes for sframes
Subsystems (7)
v11 cover x86/vdso: VDSO updates and fixes for sframes
This enables generation of SFrame V3 stack trace information for VDSO on x86-64. It's a continuation of Josh's and Steve's work:
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
This series focuses only on the VDSO code. They are helpful fixes and updates that doesn't rely on sframes (although the last patch is sframe related).
This series applies on top of tip:master (b07a332d9cbb):
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master
Like the unwind user sframe series [1] it depends on the binutils 2.46 release to be used to build the VDSO with SFrame V3 stack trace information (using the assembler option --gsframe-3).
[1]: [PATCH v14 00/19] unwind_deferred: Implement sframe handling,
https://lore.kernel.org/all/[email protected]/
Changes in v11:
- Rebased on tip:master (b07a332d9cbb).
- This time with correct version in cover letter.
Changes in v10:
- Rebased on tip:master (a375022d6383).
Changes in v9 (see indivicual patch notes):
- Always define KEEP_SFRAME to either true/false in specific VDSO linker scripts and use #if instead of #ifdef in common one. (Peter)
- Reword patch 6 commit message to provide more details.
- Note: Binutils 2.46 with SFrame V3 support has been released.
Changes in v8:
- Discard .sframe for x32 and x86-32 VDSOs. (Josh/Indu)
- Define CFI_SIGNAL_FRAME for !BUILD_VDSO.
- Drop .cfi_sections .sframe in dwarf2.h in favor of the explicitly specified more specific assembler option --gsframe-3.
- Incorporate missing changes and review feedback from Steven's v6 (I erroneously based my v6 on Steven's v5):
- Reword patch 3 commit subject to Steven's v6 one.
- Remove SYM_F_ALIGN in __vdso_sgx_enter_enclave(). (Josh)
Changes in v7:
- Rebase on H. Peter Anvin's vDSO changes on tip:x86/entry. (Peter)
- Simplify adding assembler option -Wa,--gsframe-3. Add for vdso64 only.
- Align to .eh_frame and mark .sframe as KEEP in vDSO linker script. Note that GNU linker 2.46 will mark .sframe as KEEP in its default linker script as well.
Changes in v6:
- SFrame V3 support (SFrame V2 is not supported).
- Prevent GNU_SFRAME program table entry to empty .sframe section.
- Integrate v5 review feedback. (Josh)
Regards,
Jens
Josh Poimboeuf (6):
x86/vdso: Fix DWARF generation for getrandom()
x86/asm: Avoid emitting DWARF CFI for non-VDSO
x86/asm: Use CFI_* macros in SYM_FUNC_* macros so they can be added to
VDSO
x86/vdso: Use SYM_FUNC_{START,END} in __kernel_vsyscall() x86/vdso: Use CFI macros in __vdso_sgx_enter_enclave() x86/vdso: Enable sframe generation in VDSO
arch/Kconfig | 7 +++ arch/x86/entry/vdso/common/vdso-layout.lds.S | 17 +++++- arch/x86/entry/vdso/vdso32/system_call.S | 10 +--- arch/x86/entry/vdso/vdso32/vdso32.lds.S | 3 ++ arch/x86/entry/vdso/vdso64/Makefile | 1 + arch/x86/entry/vdso/vdso64/vdso64.lds.S | 2 + arch/x86/entry/vdso/vdso64/vdsox32.lds.S | 6 +++ .../x86/entry/vdso/vdso64/vgetrandom-chacha.S | 3 +- arch/x86/entry/vdso/vdso64/vsgx.S | 18 +++---- arch/x86/include/asm/dwarf2.h | 52 +++++++++++++------ arch/x86/include/asm/linkage.h | 33 +++++++++--- arch/x86/include/asm/vdso.h | 1 - 12 files changed, 107 insertions(+), 46 deletions(-)
Signature · 1 line
2.51.0
PATCH v11 1/6 x86/vdso: Fix DWARF generation for getrandom()
From: Josh Poimboeuf <[email protected]>
Add CFI annotations to the VDSO implementation of getrandom() so it will have valid DWARF unwinding metadata.
--- arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S +3 -2
@@ -4,7 +4,7 @@ */ #include <linux/linkage.h> -#include <asm/frame.h> +#include <asm/dwarf2.h> .section .rodata, "a" .align 16
@@ -22,7 +22,7 @@ CONSTANTS: .octa 0x6b20657479622d323320646e61707865 * rcx: number of 64-byte blocks to write to output */ SYM_FUNC_START(__arch_chacha20_blocks_nostack) - + CFI_STARTPROC .set output, %rdi .set key, %rsi .set counter, %rdx
@@ -175,4 +175,5 @@ SYM_FUNC_START(__arch_chacha20_blocks_nostack) pxor temp,temp ret + CFI_ENDPROC SYM_FUNC_END(__arch_chacha20_blocks_nostack)
Signature · 1 line
2.51.0
PATCH v11 2/6 x86/asm: Avoid emitting DWARF CFI for non-VDSO
In reply to Jens RemusFrom: Josh Poimboeuf <[email protected]>
It was decided years ago that .cfi_* annotations aren't maintainable in the kernel. They were replaced by objtool unwind hints. For the kernel proper, ensure the CFI_* macros don't do anything.
On the other hand the VDSO library *does* use them, so user space can unwind through it.
Make sure these macros only work for VDSO. They aren't actually being used outside of VDSO anyway, so there's no functional change.
[ Jens Remus: Define CFI_SIGNAL_FRAME for !BUILD_VDSO. ]
--- arch/x86/include/asm/dwarf2.h | 52 ++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 16 deletions(-)
arch/x86/include/asm/dwarf2.h +36 -16
@@ -6,6 +6,15 @@#warning "asm/dwarf2.h should be only included in pure assembly files"#endif +#ifdef BUILD_VDSO + +/* +* For the vDSO, emit both runtime unwind information and debug +* symbols for the .dbg file. +*/ + + .cfi_sections .eh_frame, .debug_frame +#define CFI_STARTPROC .cfi_startproc#define CFI_ENDPROC .cfi_endproc#define CFI_DEF_CFA .cfi_def_cfa
@@ -22,21 +31,32 @@#define CFI_ESCAPE .cfi_escape#define CFI_SIGNAL_FRAME .cfi_signal_frame -#ifndef BUILD_VDSO -/* -* Emit CFI data in .debug_frame sections, not .eh_frame sections. -* The latter we currently just discard since we don't do DWARF -* unwinding at runtime. So only the offline DWARF information is -* useful to anyone. Note we should not use this directive if we -* ever decide to enable DWARF unwinding at runtime. -*/ - .cfi_sections .debug_frame -#else -/* -* For the vDSO, emit both runtime unwind information and debug -* symbols for the .dbg file. -*/ - .cfi_sections .eh_frame, .debug_frame -#endif +#else /* !BUILD_VDSO */ + +/* +* On x86, these macros aren't used outside VDSO. As well they shouldn't be: +* they're fragile and very difficult to maintain. +*/ + +.macro nocfi args:vararg +.endm + +#define CFI_STARTPROC nocfi +#define CFI_ENDPROC nocfi +#define CFI_DEF_CFA nocfi +#define CFI_DEF_CFA_REGISTER nocfi +#define CFI_DEF_CFA_OFFSET nocfi +#define CFI_ADJUST_CFA_OFFSET nocfi +#define CFI_OFFSET nocfi +#define CFI_REL_OFFSET nocfi +#define CFI_REGISTER nocfi +#define CFI_RESTORE nocfi +#define CFI_REMEMBER_STATE nocfi +#define CFI_RESTORE_STATE nocfi +#define CFI_UNDEFINED nocfi +#define CFI_ESCAPE nocfi +#define CFI_SIGNAL_FRAME nocfi + +#endif /* !BUILD_VDSO */ #endif /* _ASM_X86_DWARF2_H */
Signature · 1 line
2.51.0
PATCH v11 3/6 x86/asm: Use CFI_* macros in SYM_FUNC_* macros so they can be added to VDSO
In reply to Jens RemusFrom: Josh Poimboeuf <[email protected]>
Add CFI_STARTPROC and CFI_ENDPROC annotations to the SYM_FUNC_* macros so the VDSO asm functions don't need to add them manually. Note this only affects VDSO, the CFI_* macros are empty for the kernel proper.
--- arch/x86/entry/vdso/common/vdso-layout.lds.S | 2 +- .../x86/entry/vdso/vdso64/vgetrandom-chacha.S | 2 -- arch/x86/entry/vdso/vdso64/vsgx.S | 4 --- arch/x86/include/asm/linkage.h | 33 +++++++++++++++---- arch/x86/include/asm/vdso.h | 1 - 5 files changed, 28 insertions(+), 14 deletions(-)
arch/x86/entry/vdso/common/vdso-layout.lds.S +1 -1
@@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#include <asm/vdso.h> +#include <asm/page_types.h> #include <asm/vdso/vsyscall.h> #include <vdso/datapage.h>
arch/x86/entry/vdso/vdso64/vgetrandom-chacha.S +0 -2
@@ -22,7 +22,6 @@ CONSTANTS: .octa 0x6b20657479622d323320646e61707865 * rcx: number of 64-byte blocks to write to output */ SYM_FUNC_START(__arch_chacha20_blocks_nostack) - CFI_STARTPROC .set output, %rdi .set key, %rsi .set counter, %rdx
@@ -175,5 +174,4 @@ SYM_FUNC_START(__arch_chacha20_blocks_nostack) pxor temp,temp ret - CFI_ENDPROC SYM_FUNC_END(__arch_chacha20_blocks_nostack)
arch/x86/entry/vdso/vdso64/vsgx.S +0 -4
@@ -24,8 +24,6 @@ .section .text, "ax" SYM_FUNC_START(__vdso_sgx_enter_enclave) - /* Prolog */ - .cfi_startproc push %rbp .cfi_adjust_cfa_offset 8 .cfi_rel_offset %rbp, 0
@@ -143,8 +141,6 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) jle .Lout jmp .Lenter_enclave - .cfi_endproc - _ASM_VDSO_EXTABLE_HANDLE(.Lenclu_eenter_eresume, .Lhandle_exception) SYM_FUNC_END(__vdso_sgx_enter_enclave)
arch/x86/include/asm/linkage.h +27 -6
@@ -40,6 +40,10 @@#ifdef __ASSEMBLER__ +#ifndef LINKER_SCRIPT +#include <asm/dwarf2.h> +#endif +#if defined(CONFIG_MITIGATION_RETHUNK ) && !defined(__DISABLE_EXPORTS) && !defined(BUILD_VDSO )#define RET jmp __x86_return_thunk#else /* CONFIG_MITIGATION_RETPOLINE */
@@ -112,34 +116,51 @@# define SYM_FUNC_ALIAS_MEMFUNC SYM_FUNC_ALIAS#endif +#define __SYM_FUNC_START \ + CFI_STARTPROC ASM_NL + +#define __SYM_FUNC_END \ + CFI_ENDPROC ASM_NL +/* SYM_TYPED_FUNC_START -- use for indirectly called globals, w/ CFI type */ #define SYM_TYPED_FUNC_START (name) \ SYM_TYPED_START(name, SYM_L_GLOBAL, SYM_F_ALIGN) \ + __SYM_FUNC_START \ ENDBR/* SYM_FUNC_START -- use for global functions */ #define SYM_FUNC_START (name) \ - SYM_START(name, SYM_L_GLOBAL, SYM_F_ALIGN) + SYM_START(name, SYM_L_GLOBAL, SYM_F_ALIGN) \ + __SYM_FUNC_START/* SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment */ #define SYM_FUNC_START_NOALIGN (name) \ - SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE) + SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE) \ + __SYM_FUNC_START/* SYM_FUNC_START_LOCAL -- use for local functions */ #define SYM_FUNC_START_LOCAL (name) \ - SYM_START(name, SYM_L_LOCAL, SYM_F_ALIGN) + SYM_START(name, SYM_L_LOCAL, SYM_F_ALIGN) \ + __SYM_FUNC_START/* SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o alignment */ #define SYM_FUNC_START_LOCAL_NOALIGN (name) \ - SYM_START(name, SYM_L_LOCAL, SYM_A_NONE) + SYM_START(name, SYM_L_LOCAL, SYM_A_NONE) \ + __SYM_FUNC_START/* SYM_FUNC_START_WEAK -- use for weak functions */ #define SYM_FUNC_START_WEAK (name) \ - SYM_START(name, SYM_L_WEAK, SYM_F_ALIGN) + SYM_START(name, SYM_L_WEAK, SYM_F_ALIGN) \ + __SYM_FUNC_START/* SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment */ #define SYM_FUNC_START_WEAK_NOALIGN (name) \ - SYM_START(name, SYM_L_WEAK, SYM_A_NONE) + SYM_START(name, SYM_L_WEAK, SYM_A_NONE) \ + __SYM_FUNC_START + +#define SYM_FUNC_END (name) \ + __SYM_FUNC_END \ + SYM_END(name, SYM_T_FUNC)/* * Expose 'sym' to the startup code in arch/x86/boot/startup/, by emitting an
arch/x86/include/asm/vdso.h +0 -1
@@ -2,7 +2,6 @@#ifndef _ASM_X86_VDSO_H#define _ASM_X86_VDSO_H -#include <asm/page_types.h> #include <linux/linkage.h> #include <linux/init.h>
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH v11 3/6] x86/asm: Use CFI_* macros in SYM_FUNC_* macros so they can be added to VDSO
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The `__CFI_TYPE` macro in `arch/x86/include/asm/linkage.h` creates unbalanced CFI directives…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The __CFI_TYPE macro in arch/x86/include/asm/linkage.h creates unbalanced CFI directives because it uses SYM_START but closes with SYM_FUNC_END. --
commit 2769cdf2ca16b1b56aace01ab1acf0951b91be1f
Author: Josh Poimboeuf <[email protected]>
x86/asm: Use CFI_* macros in SYM_FUNC_* macros so they can be added to VDSO
This commit adds CFI_STARTPROC and CFI_ENDPROC annotations to the SYM_FUNC_* macros. This allows VDSO asm functions to avoid adding them manually, while leaving the macros empty for the kernel proper.
Quoted 13 lines
arch/x86/include/asm/linkage.h +5
-0@@ -112,34 +116,51 @@# define SYM_FUNC_ALIAS_MEMFUNC SYM_FUNC_ALIAS#endif +#define __SYM_FUNC_START \ + CFI_STARTPROC ASM_NL + +#define __SYM_FUNC_END \ + CFI_ENDPROC ASM_NL
[ ... ]
arch/x86/include/asm/linkage.h line 163
Quoted 3 lines
arch/x86/include/asm/linkage.h +3
-0+#define SYM_FUNC_END (name) \ + __SYM_FUNC_END \ + SYM_END(name, SYM_T_FUNC)
[Severity: Low]
Does this change to SYM_FUNC_END() create unbalanced CFI directives when used with __CFI_TYPE()?
The __CFI_TYPE() macro is defined earlier in this file to expand to a block that starts with SYM_START() and ends with SYM_FUNC_END():
#define __CFI_TYPE(name) \
SYM_START(__cfi_##name, SYM_L_LOCAL, SYM_A_NONE) \
... \
SYM_FUNC_END(__cfi_##name)Because SYM_START() does not emit CFI_STARTPROC (unlike SYM_FUNC_START()), code expanding __CFI_TYPE() will now emit a CFI_ENDPROC directive without a corresponding CFI_STARTPROC.
While this might not break the build today since CFI_ENDPROC evaluates to an empty nocfi macro outside VDSO and __CFI_TYPE() is not used in VDSO code, will this cause issues if KCFI or typed symbols are ever used in VDSO builds?
Should __CFI_TYPE() pair SYM_START() with SYM_END() instead?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v11 3/6] x86/asm: Use CFI_* macros in SYM_FUNC_* macros so they can be added to VDSO
Quoted 37 lines · On 5/22/2026 1:58 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The__CFI_TYPEmacro inarch/x86/include/asm/linkage.hcreates unbalanced CFI directives because it usesSYM_STARTbut closes withSYM_FUNC_END. --commit
2769cdf2ca16b1b56aace01ab1acf0951b91be1f
Author: Josh Poimboeuf <[email protected]>x86/asm: Use CFI_* macros in SYM_FUNC_* macros so they can be added to VDSO
This commit adds
CFI_STARTPROCandCFI_ENDPROCannotations to the SYM_FUNC_* macros. This allows VDSO asm functions to avoid adding them manually, while leaving the macros empty for the kernel proper.Quoted 13 lines
arch/x86/include/asm/linkage.h +5
-0@@ -112,34 +116,51 @@# define SYM_FUNC_ALIAS_MEMFUNC SYM_FUNC_ALIAS#endif +#define __SYM_FUNC_START \ + CFI_STARTPROC ASM_NL + +#define __SYM_FUNC_END \ + CFI_ENDPROC ASM_NL[ ... ]
arch/x86/include/asm/linkage.h line 163
Quoted 3 lines
arch/x86/include/asm/linkage.h +3
-0+#define SYM_FUNC_END (name) \ + __SYM_FUNC_END \ + SYM_END(name, SYM_T_FUNC)[Severity: Low]
Does this change toSYM_FUNC_END()create unbalanced CFI directives when used with__CFI_TYPE()?
Quoted 7 lines
The
__CFI_TYPE()macro is defined earlier in this file to expand to a block that starts withSYM_START()and ends withSYM_FUNC_END():#define __CFI_TYPE(name) \ SYM_START(__cfi_##name, SYM_L_LOCAL, SYM_A_NONE) \ ... \ SYM_FUNC_END(__cfi_##name)
SYM_END(__cfi_##name, SYM_T_FUNC)
Quoted 8 lines
Because
SYM_START()does not emitCFI_STARTPROC(unlikeSYM_FUNC_START()), code expanding__CFI_TYPE()will now emit aCFI_ENDPROCdirective without a correspondingCFI_STARTPROC.While this might not break the build today since
CFI_ENDPROCevaluates to an empty nocfi macro outside VDSO and__CFI_TYPE()is not used in VDSO code, will this cause issues if KCFI or typed symbols are ever used in VDSO builds?
IIUC kCFI would never be used in VDSO builds. But CFI_STARTPROC and CFI_ENDPROC could evaluate to the actual DWARF CFI directives outside of VDSO in the future.
Quoted 2 lines
Should
__CFI_TYPE()pairSYM_START()withSYM_END()instead?
Makes sense, as any future changes that require SYM_FUNC_START*() to be paired with SYM_FUNC_END() would cause to __CFI_TYPE() to break.
I have sent a separate patch:
[PATCH] x86/cfi: Use symmetric SYM_START and SYM_END in __CFI_TYPE()
https://lore.kernel.org/all/[email protected]/
Regards,
Jens
Signature · 6 lines
Jens Remus Linux on Z Development (D3303) [email protected] / [email protected] IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294 IBM Data Privacy Statement: https://www.ibm.com/privacy/
PATCH v11 4/6 x86/vdso: Use SYM_FUNC_{START,END} in __kernel_vsyscall()
In reply to Jens RemusFrom: Josh Poimboeuf <[email protected]>
Use SYM_FUNC_{START,END} instead of all the boilerplate. No functional change.
--- arch/x86/entry/vdso/vdso32/system_call.S | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
arch/x86/entry/vdso/vdso32/system_call.S +2 -8
@@ -9,11 +9,7 @@ #include <asm/alternative.h> .text - .globl __kernel_vsyscall - .type __kernel_vsyscall,@function - ALIGN -__kernel_vsyscall: - CFI_STARTPROC +SYM_FUNC_START(__kernel_vsyscall) /* * If using int $0x80, there is no reason to muck about with the
@@ -85,7 +81,5 @@ SYM_INNER_LABEL(int80_landing_pad, SYM_L_GLOBAL) CFI_RESTORE ecx CFI_ADJUST_CFA_OFFSET -4 RET - CFI_ENDPROC - - .size __kernel_vsyscall,.-__kernel_vsyscall +SYM_FUNC_END(__kernel_vsyscall) .previous
Signature · 1 line
2.51.0
PATCH v11 5/6 x86/vdso: Use CFI macros in __vdso_sgx_enter_enclave()
In reply to Jens RemusFrom: Josh Poimboeuf <[email protected]>
Use the CFI macros instead of the raw .cfi_* directives to be consistent with the rest of the VDSO asm. It's also easier on the eyes.
No functional changes.
--- arch/x86/entry/vdso/vdso64/vsgx.S | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
arch/x86/entry/vdso/vdso64/vsgx.S +6 -8
@@ -25,12 +25,12 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) push %rbp - .cfi_adjust_cfa_offset 8 - .cfi_rel_offset %rbp, 0 + CFI_ADJUST_CFA_OFFSET 8 + CFI_REL_OFFSET %rbp, 0 mov %rsp, %rbp - .cfi_def_cfa_register %rbp + CFI_DEF_CFA_REGISTER %rbp push %rbx - .cfi_rel_offset %rbx, -8 + CFI_REL_OFFSET %rbx, -8 mov %ecx, %eax .Lenter_enclave:
@@ -77,13 +77,11 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) .Lout: pop %rbx leave - .cfi_def_cfa %rsp, 8 + CFI_DEF_CFA %rsp, 8 RET - /* The out-of-line code runs with the pre-leave stack frame. */ - .cfi_def_cfa %rbp, 16 - .Linvalid_input: + CFI_DEF_CFA %rbp, 16 mov $(-EINVAL), %eax jmp .Lout
Signature · 1 line
2.51.0
PATCH v11 6/6 x86/vdso: Enable sframe generation in VDSO
In reply to Jens RemusFrom: Josh Poimboeuf <[email protected]>
Enable .sframe generation in the VDSO library so kernel and user space can unwind through it.
Starting with binutils 2.46 both GNU assembler and GNU linker exclusively support generating and merging .sframe in SFrame V3 format. For x86 SFrame is only supported for x86-64. Not for x86-32 nor x32.
Test whether the assembler supports option '--gsframe-3' to explicitly select SFrame V3 format. Note that testing using Kconfig macro 'as-option' is not sufficient, as GNU assembler will accept the option for any target, regardless of whether it is actually capable to generate .sframe for it, as long the input does not trigger the generation. Therefore it is necessary to use Kconfig macro 'as-instr' to provide minimal CFI directives that trigger generation of .sframe.
For x86-64 VDSO, only if supported by the assembler, generate .sframe, collect it, mark it as KEEP, and generate a GNU_SFRAME program table entry.
For x86-32 and x32 VDSOs, given SFrame is not supported, do not generate any .sframe nor GNU_SFRAME program table entry. Instead explicitly discard any .sframe. The latter is required for x32 VDSO, as it is built from x86-64 VDSO objects (potentially with .sframe) converted to x32. In this regard discarding .sframe also prevents potential issues with linkers, such as GNU linker prior to binutils 2.46 commit 7487c98ff07a ("x32: Allow R_X86_64_PC64 for SFrame V3"), that do not support R_X86_64_PC64 relocations in x32, like those found in .sframe in SFrame V3 format.
[ Jens Remus: Add support for SFrame V3. Prevent GNU_SFRAME program table entry to empty .sframe section. Reword commit message. ]
---
Notes (jremus):
Changes in v9:
- Always define KEEP_SFRAME to either true/false in specific VDSO linker scripts and use #if instead of #ifdef in common one. (Peter)
- Reword commit message to provide more details.
arch/Kconfig | 7 +++++++ arch/x86/entry/vdso/common/vdso-layout.lds.S | 15 +++++++++++++++ arch/x86/entry/vdso/vdso32/vdso32.lds.S | 3 +++ arch/x86/entry/vdso/vdso64/Makefile | 1 + arch/x86/entry/vdso/vdso64/vdso64.lds.S | 2 ++ arch/x86/entry/vdso/vdso64/vdsox32.lds.S | 6 ++++++ 6 files changed, 34 insertions(+)
arch/Kconfig +7 -0
@@ -479,6 +479,13 @@ config HAVE_HARDLOCKUP_DETECTOR_ARCH It uses the same command line parameters, and sysctl interface, as the generic hardlockup detectors. +config AS_SFRAME + bool + +config AS_SFRAME3 + def_bool $(as-instr,.cfi_startproc\n.cfi_endproc,-Wa$(comma)--gsframe-3) + select AS_SFRAME + config UNWIND_USER bool
arch/x86/entry/vdso/common/vdso-layout.lds.S +15 -0
@@ -60,6 +60,13 @@ SECTIONS *(.eh_frame.*) } :text +#if KEEP_SFRAME + .sframe : { + KEEP (*(.sframe)) + *(.sframe.*) + } :text :sframe +#endif + /* * Text is well-separated from actual data: there's plenty of * stuff that isn't used at runtime in between.
@@ -80,6 +87,10 @@ SECTIONS *(.discard) *(.discard.*) *(__bug_table) +#if !KEEP_SFRAME + *(.sframe) + *(.sframe.*) +#endif } }
@@ -89,6 +100,7 @@ SECTIONS #define PT_GNU_EH_FRAME 0x6474e550 #define PT_GNU_STACK 0x6474e551 #define PT_GNU_PROPERTY 0x6474e553 +#define PT_GNU_SFRAME 0x6474e554 /* * We must supply the ELF program headers explicitly to get just one
@@ -104,6 +116,9 @@ PHDRS dynamic PT_DYNAMIC PF_R; note PT_NOTE PF_R; eh_frame_hdr PT_GNU_EH_FRAME PF_R; +#if KEEP_SFRAME + sframe PT_GNU_SFRAME PF_R; +#endif gnu_stack PT_GNU_STACK PF_RW; gnu_property PT_GNU_PROPERTY PF_R; }
arch/x86/entry/vdso/vdso32/vdso32.lds.S +3 -0
@@ -11,6 +11,9 @@ #define BUILD_VDSO32 +/* Discard .sframe if any. SFrame does not support x86-32. */ +#define KEEP_SFRAME 0 + #include "common/vdso-layout.lds.S" /* The ELF entry point can be used to set the AT_SYSINFO value. */
arch/x86/entry/vdso/vdso64/Makefile +1 -0
@@ -14,6 +14,7 @@ vobjs-$(CONFIG_X86_SGX) += vsgx.o # Compilation flags flags-y := -DBUILD_VDSO64 -m64 -mcmodel=small +flags-$(CONFIG_AS_SFRAME3) += -Wa,--gsframe-3 # The location of this include matters! include $(src)/../common/Makefile.include
arch/x86/entry/vdso/vdso64/vdso64.lds.S +2 -0
@@ -9,6 +9,8 @@ #define BUILD_VDSO64 +#define KEEP_SFRAME IS_ENABLED(CONFIG_AS_SFRAME) + #include "common/vdso-layout.lds.S" /*
arch/x86/entry/vdso/vdso64/vdsox32.lds.S +6 -0
@@ -9,6 +9,12 @@ #define BUILD_VDSOX32 +/* + * Discard .sframe from x86-64 compiles. SFrame does not support x32 and + * it contains R_X86_64_PC64 relocations, which linkers may not expect. + */ +#define KEEP_SFRAME 0 + #include "common/vdso-layout.lds.S" /*
Signature · 1 line
2.51.0