2022-05-08 14:00:43

by Peter Zijlstra

[permalink] [raw]
Subject: [PATCH 6/6] objtool: Fix STACK_FRAME_NON_STANDARD reloc type

STACK_FRAME_NON_STANDARD results in inconsistent relocation types
depending on .c or .S usage:

Relocation section '.rela.discard.func_stack_frame_non_standard' at offset 0x3c01090 contains 5 entries:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000000000000 00020c2200000002 R_X86_64_PC32 0000000000047b40 do_suspend_lowlevel + 0
0000000000000008 0002461e00000001 R_X86_64_64 00000000000480a0 machine_real_restart + 0
0000000000000010 0000001400000001 R_X86_64_64 0000000000000000 .rodata + b3d4
0000000000000018 0002444600000002 R_X86_64_PC32 00000000000678a0 __efi64_thunk + 0
0000000000000020 0002659d00000001 R_X86_64_64 0000000000113160 __crash_kexec + 0

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
---
include/linux/objtool.h | 4 +++-
tools/include/linux/objtool.h | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)

--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -2,6 +2,8 @@
#ifndef _LINUX_OBJTOOL_H
#define _LINUX_OBJTOOL_H

+#include <asm/asm.h>
+
#ifndef __ASSEMBLY__

#include <linux/types.h>
@@ -137,7 +139,7 @@ struct unwind_hint {

.macro STACK_FRAME_NON_STANDARD func:req
.pushsection .discard.func_stack_frame_non_standard, "aw"
- .long \func - .
+ _ASM_PTR \func
.popsection
.endm

--- a/tools/include/linux/objtool.h
+++ b/tools/include/linux/objtool.h
@@ -2,6 +2,8 @@
#ifndef _LINUX_OBJTOOL_H
#define _LINUX_OBJTOOL_H

+#include <asm/asm.h>
+
#ifndef __ASSEMBLY__

#include <linux/types.h>
@@ -137,7 +139,7 @@ struct unwind_hint {

.macro STACK_FRAME_NON_STANDARD func:req
.pushsection .discard.func_stack_frame_non_standard, "aw"
- .long \func - .
+ _ASM_PTR \func
.popsection
.endm





Subject: [tip: x86/asm] objtool: Fix STACK_FRAME_NON_STANDARD reloc type

The following commit has been merged into the x86/asm branch of tip:

Commit-ID: 38f3803fb4fa588ef7645048285493efbe264d79
Gitweb: https://git.kernel.org/tip/38f3803fb4fa588ef7645048285493efbe264d79
Author: Peter Zijlstra <[email protected]>
AuthorDate: Fri, 06 May 2022 14:14:37 +02:00
Committer: Borislav Petkov <[email protected]>
CommitterDate: Fri, 06 May 2022 16:07:06 +02:00

objtool: Fix STACK_FRAME_NON_STANDARD reloc type

STACK_FRAME_NON_STANDARD results in inconsistent relocation types
depending on .c or .S usage:

Relocation section '.rela.discard.func_stack_frame_non_standard' at offset 0x3c01090 contains 5 entries:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000000000000 00020c2200000002 R_X86_64_PC32 0000000000047b40 do_suspend_lowlevel + 0
0000000000000008 0002461e00000001 R_X86_64_64 00000000000480a0 machine_real_restart + 0
0000000000000010 0000001400000001 R_X86_64_64 0000000000000000 .rodata + b3d4
0000000000000018 0002444600000002 R_X86_64_PC32 00000000000678a0 __efi64_thunk + 0
0000000000000020 0002659d00000001 R_X86_64_64 0000000000113160 __crash_kexec + 0

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
include/linux/objtool.h | 4 +++-
tools/include/linux/objtool.h | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index 586d357..c68d81d 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -2,6 +2,8 @@
#ifndef _LINUX_OBJTOOL_H
#define _LINUX_OBJTOOL_H

+#include <asm/asm.h>
+
#ifndef __ASSEMBLY__

#include <linux/types.h>
@@ -137,7 +139,7 @@ struct unwind_hint {

.macro STACK_FRAME_NON_STANDARD func:req
.pushsection .discard.func_stack_frame_non_standard, "aw"
- .long \func - .
+ _ASM_PTR \func
.popsection
.endm

diff --git a/tools/include/linux/objtool.h b/tools/include/linux/objtool.h
index 586d357..c68d81d 100644
--- a/tools/include/linux/objtool.h
+++ b/tools/include/linux/objtool.h
@@ -2,6 +2,8 @@
#ifndef _LINUX_OBJTOOL_H
#define _LINUX_OBJTOOL_H

+#include <asm/asm.h>
+
#ifndef __ASSEMBLY__

#include <linux/types.h>
@@ -137,7 +139,7 @@ struct unwind_hint {

.macro STACK_FRAME_NON_STANDARD func:req
.pushsection .discard.func_stack_frame_non_standard, "aw"
- .long \func - .
+ _ASM_PTR \func
.popsection
.endm


2022-05-09 07:32:29

by Josh Poimboeuf

[permalink] [raw]
Subject: Re: [PATCH 6/6] objtool: Fix STACK_FRAME_NON_STANDARD reloc type

On Fri, May 06, 2022 at 02:14:37PM +0200, Peter Zijlstra wrote:
> STACK_FRAME_NON_STANDARD results in inconsistent relocation types
> depending on .c or .S usage:
>
> Relocation section '.rela.discard.func_stack_frame_non_standard' at offset 0x3c01090 contains 5 entries:
> Offset Info Type Symbol's Value Symbol's Name + Addend
> 0000000000000000 00020c2200000002 R_X86_64_PC32 0000000000047b40 do_suspend_lowlevel + 0
> 0000000000000008 0002461e00000001 R_X86_64_64 00000000000480a0 machine_real_restart + 0
> 0000000000000010 0000001400000001 R_X86_64_64 0000000000000000 .rodata + b3d4
> 0000000000000018 0002444600000002 R_X86_64_PC32 00000000000678a0 __efi64_thunk + 0
> 0000000000000020 0002659d00000001 R_X86_64_64 0000000000113160 __crash_kexec + 0
>
> Signed-off-by: Peter Zijlstra (Intel) <[email protected]>

Acked-by: Josh Poimboeuf <[email protected]>

--
Josh

Subject: [tip: x86/asm] objtool: Fix STACK_FRAME_NON_STANDARD reloc type

The following commit has been merged into the x86/asm branch of tip:

Commit-ID: e2ef115813c34ea5380ac5b4879f515070150210
Gitweb: https://git.kernel.org/tip/e2ef115813c34ea5380ac5b4879f515070150210
Author: Peter Zijlstra <[email protected]>
AuthorDate: Fri, 06 May 2022 14:14:37 +02:00
Committer: Peter Zijlstra <[email protected]>
CommitterDate: Fri, 06 May 2022 22:20:43 +02:00

objtool: Fix STACK_FRAME_NON_STANDARD reloc type

STACK_FRAME_NON_STANDARD results in inconsistent relocation types
depending on .c or .S usage:

Relocation section '.rela.discard.func_stack_frame_non_standard' at offset 0x3c01090 contains 5 entries:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000000000000 00020c2200000002 R_X86_64_PC32 0000000000047b40 do_suspend_lowlevel + 0
0000000000000008 0002461e00000001 R_X86_64_64 00000000000480a0 machine_real_restart + 0
0000000000000010 0000001400000001 R_X86_64_64 0000000000000000 .rodata + b3d4
0000000000000018 0002444600000002 R_X86_64_PC32 00000000000678a0 __efi64_thunk + 0
0000000000000020 0002659d00000001 R_X86_64_64 0000000000113160 __crash_kexec + 0

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
include/linux/objtool.h | 4 +++-
tools/include/linux/objtool.h | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index 586d357..b9c1474 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -40,6 +40,8 @@ struct unwind_hint {

#ifdef CONFIG_STACK_VALIDATION

+#include <asm/asm.h>
+
#ifndef __ASSEMBLY__

#define UNWIND_HINT(sp_reg, sp_offset, type, end) \
@@ -137,7 +139,7 @@ struct unwind_hint {

.macro STACK_FRAME_NON_STANDARD func:req
.pushsection .discard.func_stack_frame_non_standard, "aw"
- .long \func - .
+ _ASM_PTR \func
.popsection
.endm

diff --git a/tools/include/linux/objtool.h b/tools/include/linux/objtool.h
index 586d357..b9c1474 100644
--- a/tools/include/linux/objtool.h
+++ b/tools/include/linux/objtool.h
@@ -40,6 +40,8 @@ struct unwind_hint {

#ifdef CONFIG_STACK_VALIDATION

+#include <asm/asm.h>
+
#ifndef __ASSEMBLY__

#define UNWIND_HINT(sp_reg, sp_offset, type, end) \
@@ -137,7 +139,7 @@ struct unwind_hint {

.macro STACK_FRAME_NON_STANDARD func:req
.pushsection .discard.func_stack_frame_non_standard, "aw"
- .long \func - .
+ _ASM_PTR \func
.popsection
.endm