Skip to content

Commit e390f9a

Browse files
jpoimboeIngo Molnar
authored andcommitted
objtool, modules: Discard objtool annotation sections for modules
The '__unreachable' and '__func_stack_frame_non_standard' sections are only used at compile time. They're discarded for vmlinux but they should also be discarded for modules. Since this is a recurring pattern, prefix the section names with ".discard.". It's a nice convention and vmlinux.lds.h already discards such sections. Also remove the 'a' (allocatable) flag from the __unreachable section since it doesn't make sense for a discarded section. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Jessica Yu <jeyu@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Fixes: d1091c7 ("objtool: Improve detection of BUG() and other dead ends") Link: http://lkml.kernel.org/r/20170301180444.lhd53c5tibc4ns77@treble Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 55149d0 commit e390f9a

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

arch/x86/kernel/vmlinux.lds.S

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,6 @@ SECTIONS
345345
DISCARDS
346346
/DISCARD/ : {
347347
*(.eh_frame)
348-
*(__func_stack_frame_non_standard)
349-
*(__unreachable)
350348
}
351349
}
352350

include/linux/compiler-gcc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
#ifdef CONFIG_STACK_VALIDATION
201201
#define annotate_unreachable() ({ \
202202
asm("%c0:\t\n" \
203-
".pushsection __unreachable, \"a\"\t\n" \
203+
".pushsection .discard.unreachable\t\n" \
204204
".long %c0b - .\t\n" \
205205
".popsection\t\n" : : "i" (__LINE__)); \
206206
})

include/linux/frame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* For more information, see tools/objtool/Documentation/stack-validation.txt.
1212
*/
1313
#define STACK_FRAME_NON_STANDARD(func) \
14-
static void __used __section(__func_stack_frame_non_standard) \
14+
static void __used __section(.discard.func_stack_frame_non_standard) \
1515
*__func_stack_frame_non_standard_##func = func
1616

1717
#else /* !CONFIG_STACK_VALIDATION */

scripts/mod/modpost.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ static const char *const section_white_list[] =
854854
".cmem*", /* EZchip */
855855
".fmt_slot*", /* EZchip */
856856
".gnu.lto*",
857+
".discard.*",
857858
NULL
858859
};
859860

scripts/module-common.lds

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
* combine them automatically.
55
*/
66
SECTIONS {
7-
/DISCARD/ : { *(.discard) }
7+
/DISCARD/ : {
8+
*(.discard)
9+
*(.discard.*)
10+
}
811

912
__ksymtab 0 : { *(SORT(___ksymtab+*)) }
1013
__ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }

tools/objtool/builtin-check.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,13 @@ static int add_dead_ends(struct objtool_file *file)
339339
struct instruction *insn;
340340
bool found;
341341

342-
sec = find_section_by_name(file->elf, ".rela__unreachable");
342+
sec = find_section_by_name(file->elf, ".rela.discard.unreachable");
343343
if (!sec)
344344
return 0;
345345

346346
list_for_each_entry(rela, &sec->rela_list, list) {
347347
if (rela->sym->type != STT_SECTION) {
348-
WARN("unexpected relocation symbol type in .rela__unreachable");
348+
WARN("unexpected relocation symbol type in %s", sec->name);
349349
return -1;
350350
}
351351
insn = find_insn(file, rela->sym->sec, rela->addend);
@@ -1272,7 +1272,7 @@ int cmd_check(int argc, const char **argv)
12721272

12731273
INIT_LIST_HEAD(&file.insn_list);
12741274
hash_init(file.insn_hash);
1275-
file.whitelist = find_section_by_name(file.elf, "__func_stack_frame_non_standard");
1275+
file.whitelist = find_section_by_name(file.elf, ".discard.func_stack_frame_non_standard");
12761276
file.rodata = find_section_by_name(file.elf, ".rodata");
12771277
file.ignore_unreachables = false;
12781278
file.c_file = find_section_by_name(file.elf, ".comment");

0 commit comments

Comments
 (0)