Skip to contentSkip to conversation

vmlinux.lds.h: improve BOUNDED_SECTION macros

PATCH In review Jim Cromie 1 participant 2 messages Nov 11, 2022 Generic include/asm header files

lore
Share & tools
lore

Jim Cromie

author
#0 lore raw

PATCH 1/1 vmlinux.lds.h: improve BOUNDED_SECTION macros

1- replace _s_ & _e_ with the more visibly obvious _BEGIN_ & _END_.

2- add a new _HDR_ linker symbol before the KEEP(*(.gnu.linkonce.##_sec_)).
This gives the optional header record an extern'd name/address, which is "_hdr_", b4/after the _sec_/_label_.

3- move existing _BEGIN_ linker symbol after the KEEP.
This insures the extern'd name always points at the data, independent of whether a header has been defined.

NOTE: if (start - hdr) { /* section has a header record */ }

---
 include/asm-generic/vmlinux.lds.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
include/asm-generic/vmlinux.lds.h +9 -7
index cfad4511cd68..c9b204b0364c 100644
@@ -199,20 +199,22 @@
 # endif
 #endif
 
-#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _s_, _e_)		\
-	_s_##_label_ = .;						\
+#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
+	_HDR_##_label_ = .;						\
 	KEEP(*(.gnu.linkonce.##_sec_))					\
+	_BEGIN_##_label_ = .;						\
 	KEEP(*(_sec_))							\
-	_e_##_label_ = .;
+	_END_##_label_ = .;
 
-#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _s_, _e_)		\
-	_label_##_s_ = .;						\
+#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
+	_label_##_HDR_ = .;						\
 	KEEP(*(.gnu.linkonce.##_sec_))					\
+	_label_##_BEGIN_ = .;						\
 	KEEP(*(_sec_))							\
-	_label_##_e_ = .;
+	_label_##_END_ = .;
 
 #define BOUNDED_SECTION_BY(_sec_, _label_)				\
-	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
+	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop, _hdr_)
 
 #define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
 
Signature · 1 line
2.38.1
#1 lore raw

crap, missed something. lemme fix and resend.

Quoted 55 lines · Jim Cromie

1- replace _s_ & _e_ with the more visibly obvious _BEGIN_ & _END_.

2- add a new _HDR_ linker symbol before the KEEP(*(.gnu.linkonce.##_sec_)).
This gives the optional header record an extern'd name/address, which is "_hdr_", b4/after the _sec_/_label_.

3- move existing _BEGIN_ linker symbol after the KEEP.
This insures the extern'd name always points at the data, independent of whether a header has been defined.

NOTE: if (start - hdr) { /* section has a header record */ }

---
 include/asm-generic/vmlinux.lds.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
include/asm-generic/vmlinux.lds.h +9 -8
index cfad4511cd68..c9b204b0364c 100644
@@ -199,20 +199,22 @@
 # endif
 #endif
 
-#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _s_, _e_)            \
-       _s_##_label_ = .;                                               \
+#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
+       _HDR_##_label_ = .;                                             \
        KEEP(*(.gnu.linkonce.##_sec_))                                  \
+       _BEGIN_##_label_ = .;                                           \
        KEEP(*(_sec_))                                                  \
-       _e_##_label_ = .;
+       _END_##_label_ = .;
 
-#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _s_, _e_)           \
-       _label_##_s_ = .;                                               \
+#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
+       _label_##_HDR_ = .;                                             \
        KEEP(*(.gnu.linkonce.##_sec_))                                  \
+       _label_##_BEGIN_ = .;                                           \
        KEEP(*(_sec_))                                                  \
-       _label_##_e_ = .;
+       _label_##_END_ = .;
 
 #define BOUNDED_SECTION_BY(_sec_, _label_)                             \
-       BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
+       BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop, _hdr_)
 
 #define BOUNDED_SECTION(_sec)   BOUNDED_SECTION_BY(_sec, _sec)
 
--

2.38.1