Skip to content

Commit f387d0e

Browse files
jpoimboeingomolnar
authored andcommitted
x86/asm: Remove ANNOTATE_DATA_SPECIAL usage
Instead of manually annotating each __ex_table entry, just make the section mergeable and store the entry size in the ELF section header. Either way works for objtool create_fake_symbols(), this way produces cleaner code generation. Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://patch.msgid.link/b858cb7891c1ba0080e22a9c32595e6c302435e2.1764694625.git.jpoimboe@kernel.org
1 parent a818f28 commit f387d0e

7 files changed

Lines changed: 20 additions & 12 deletions

File tree

arch/um/include/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ generic-y += device.h
55
generic-y += dma-mapping.h
66
generic-y += emergency-restart.h
77
generic-y += exec.h
8-
generic-y += extable.h
98
generic-y += ftrace.h
109
generic-y += hw_irq.h
1110
generic-y += irq_regs.h

arch/um/include/shared/common-offsets.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ DEFINE(UM_KERN_GDT_ENTRY_TLS_ENTRIES, GDT_ENTRY_TLS_ENTRIES);
2020
DEFINE(UM_SECCOMP_ARCH_NATIVE, SECCOMP_ARCH_NATIVE);
2121

2222
DEFINE(ALT_INSTR_SIZE, sizeof(struct alt_instr));
23+
DEFINE(EXTABLE_SIZE, sizeof(struct exception_table_entry));

arch/x86/include/asm/asm.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,21 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
126126

127127
#ifdef __KERNEL__
128128

129+
#ifndef COMPILE_OFFSETS
130+
#include <asm/asm-offsets.h>
131+
#endif
132+
129133
# include <asm/extable_fixup_types.h>
130134

131135
/* Exception table entry */
132136
#ifdef __ASSEMBLER__
133137

134-
# define _ASM_EXTABLE_TYPE(from, to, type) \
135-
.pushsection "__ex_table","a" ; \
136-
.balign 4 ; \
137-
ANNOTATE_DATA_SPECIAL ; \
138-
.long (from) - . ; \
139-
.long (to) - . ; \
140-
.long type ; \
138+
# define _ASM_EXTABLE_TYPE(from, to, type) \
139+
.pushsection "__ex_table", "aM", @progbits, EXTABLE_SIZE ; \
140+
.balign 4 ; \
141+
.long (from) - . ; \
142+
.long (to) - . ; \
143+
.long type ; \
141144
.popsection
142145

143146
# ifdef CONFIG_KPROBES
@@ -180,18 +183,18 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
180183
".purgem extable_type_reg\n"
181184

182185
# define _ASM_EXTABLE_TYPE(from, to, type) \
183-
" .pushsection \"__ex_table\",\"a\"\n" \
186+
" .pushsection __ex_table, \"aM\", @progbits, " \
187+
__stringify(EXTABLE_SIZE) "\n" \
184188
" .balign 4\n" \
185-
ANNOTATE_DATA_SPECIAL \
186189
" .long (" #from ") - .\n" \
187190
" .long (" #to ") - .\n" \
188191
" .long " __stringify(type) " \n" \
189192
" .popsection\n"
190193

191194
# define _ASM_EXTABLE_TYPE_REG(from, to, type, reg) \
192-
" .pushsection \"__ex_table\",\"a\"\n" \
195+
" .pushsection __ex_table, \"aM\", @progbits, " \
196+
__stringify(EXTABLE_SIZE) "\n" \
193197
" .balign 4\n" \
194-
ANNOTATE_DATA_SPECIAL \
195198
" .long (" #from ") - .\n" \
196199
" .long (" #to ") - .\n" \
197200
DEFINE_EXTABLE_TYPE_REG \

arch/x86/kernel/asm-offsets.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,5 @@ static void __used common(void)
126126

127127
BLANK();
128128
DEFINE(ALT_INSTR_SIZE, sizeof(struct alt_instr));
129+
DEFINE(EXTABLE_SIZE, sizeof(struct exception_table_entry));
129130
}

arch/x86/um/shared/sysdep/kernel-offsets.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2+
#define COMPILE_OFFSETS
23
#include <linux/stddef.h>
34
#include <linux/sched.h>
45
#include <linux/elf.h>
@@ -7,6 +8,7 @@
78
#include <linux/audit.h>
89
#include <asm/mman.h>
910
#include <asm/seccomp.h>
11+
#include <asm/extable.h>
1012

1113
/* workaround for a warning with -Wmissing-prototypes */
1214
void foo(void);

kernel/bounds.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#define __GENERATING_BOUNDS_H
9+
#define COMPILE_OFFSETS
910
/* Include headers that define the enum constants of interest */
1011
#include <linux/page-flags.h>
1112
#include <linux/mmzone.h>

scripts/mod/devicetable-offsets.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
#define COMPILE_OFFSETS
23
#include <linux/kbuild.h>
34
#include <linux/mod_devicetable.h>
45

0 commit comments

Comments
 (0)