]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
vmlinux.lds.h: fix BOUNDED_SECTION_(PRE|POST)_LABEL macros
authorJim Cromie <jim.cromie@gmail.com>
Thu, 17 Nov 2022 17:16:32 +0000 (10:16 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Nov 2022 18:37:04 +0000 (19:37 +0100)
Commit 2f465b921bb8 ("vmlinux.lds.h: place optional header space in BOUNDED_SECTION")

added BOUNDED_SECTION_(PRE|POST)_LABEL macros, encapsulating the basic
boilerplate to KEEP/pack records into a section, and to mark the begin
and end of the section with linker-symbols.

But it tried to do extra, adding KEEP(*(.gnu.linkonce.##_sec_)) to
optionally reserve a header record in front of the data.  It wrongly
placed the KEEP after the linker-symbol starting the section,
so if a header was added, it would wind up in the data.

Moving the KEEP to the "correct" place proved brittle, and too clever
by half.  The obvious safe fix is to remove the KEEP and restore the
plain old boilerplate.  The header can be added later, with separate
macros.

Also, the macro var-names: _s_, _e_ are nearly invisible, change them
to more obvious names: _BEGIN_, _END_

Fixes: 2f465b921bb8 ("vmlinux.lds.h: place optional header space in BOUNDED_SECTION")
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Link: https://lore.kernel.org/r/20221117171633.923628-2-jim.cromie@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/asm-generic/vmlinux.lds.h

index b3ca56ac163f7c1887d678f31941f937a3437801..c17f94785253020e54f47f8ae890bad977e5a6da 100644 (file)
 # endif
 #endif
 
-#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _s_, _e_)            \
-       _s_##_label_ = .;                                               \
-       KEEP(*(.gnu.linkonce.##_sec_))                                  \
+#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)      \
+       _BEGIN_##_label_ = .;                                           \
        KEEP(*(_sec_))                                                  \
-       _e_##_label_ = .;
+       _END_##_label_ = .;
 
-#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _s_, _e_)           \
-       _label_##_s_ = .;                                               \
-       KEEP(*(.gnu.linkonce.##_sec_))                                  \
+#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)     \
+       _label_##_BEGIN_ = .;                                           \
        KEEP(*(_sec_))                                                  \
-       _label_##_e_ = .;
+       _label_##_END_ = .;
 
 #define BOUNDED_SECTION_BY(_sec_, _label_)                             \
        BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)