All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] powerpc: Keep .rela* sections when CONFIG_RELOCATABLE is defined
@ 2020-04-28 13:21 ` H.J. Lu
  0 siblings, 0 replies; 18+ messages in thread
From: H.J. Lu @ 2020-04-28 13:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yu-cheng Yu, Arnd Bergmann, linux-arch, Michael Ellerman,
	Benjamin Herrenschmidt, Paul Mackerras, Kees Cook,
	Borislav Petkov, Naveen N . Rao, linuxppc-dev

arch/powerpc/kernel/vmlinux.lds.S has

 #ifdef CONFIG_RELOCATABLE
 ...
        .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
        {
                __rela_dyn_start = .;
                *(.rela*)
        }
 #endif
 ...
        DISCARDS
        /DISCARD/ : {
                *(*.EMB.apuinfo)
                *(.glink .iplt .plt .rela* .comment)
                *(.gnu.version*)
                *(.gnu.attributes)
                *(.eh_frame)
        }

Since .rela* sections are needed when CONFIG_RELOCATABLE is defined,
don't discard .rela* sections if CONFIG_RELOCATABLE is defined.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
---
 arch/powerpc/kernel/vmlinux.lds.S | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 31a0f201fb6f..4ba07734a210 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -366,9 +366,12 @@ SECTIONS
 	DISCARDS
 	/DISCARD/ : {
 		*(*.EMB.apuinfo)
-		*(.glink .iplt .plt .rela* .comment)
+		*(.glink .iplt .plt .comment)
 		*(.gnu.version*)
 		*(.gnu.attributes)
 		*(.eh_frame)
+#ifndef CONFIG_RELOCATABLE
+		*(.rela*)
+#endif
 	}
 }
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread
* [PATCH 1/2] powerpc: Discard .rela* sections if CONFIG_RELOCATABLE is undefined
@ 2020-04-28  1:48 H.J. Lu
  2020-04-28  1:49   ` H.J. Lu
  0 siblings, 1 reply; 18+ messages in thread
From: H.J. Lu @ 2020-04-28  1:48 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yu-cheng Yu, Arnd Bergmann, linux-arch, Michael Ellerman,
	Benjamin Herrenschmidt, Paul Mackerras, Kees Cook,
	Borislav Petkov, Naveen N . Rao, linuxppc-dev

arch/powerpc/kernel/vmlinux.lds.S has

        DISCARDS
        /DISCARD/ : {
                *(*.EMB.apuinfo)
                *(.glink .iplt .plt .rela* .comment)
                *(.gnu.version*)
                *(.gnu.attributes)
                *(.eh_frame)
        }

Since .rela* sections are needed when CONFIG_RELOCATABLE is defined,
change to discard .rela* sections if CONFIG_RELOCATABLE is undefined.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
---
 arch/powerpc/kernel/vmlinux.lds.S | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 31a0f201fb6f..4ba07734a210 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -366,9 +366,12 @@ SECTIONS
 	DISCARDS
 	/DISCARD/ : {
 		*(*.EMB.apuinfo)
-		*(.glink .iplt .plt .rela* .comment)
+		*(.glink .iplt .plt .comment)
 		*(.gnu.version*)
 		*(.gnu.attributes)
 		*(.eh_frame)
+#ifndef CONFIG_RELOCATABLE
+		*(.rela*)
+#endif
 	}
 }
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 18+ messages in thread
* [PATCH 1/2] Add RUNTIME_DISCARD_EXIT to generic DISCARDS
@ 2020-03-26 19:30 H.J. Lu
  2020-03-26 19:30 ` [PATCH 2/2] Discard .note.gnu.property sections in generic NOTES H.J. Lu
  0 siblings, 1 reply; 18+ messages in thread
From: H.J. Lu @ 2020-03-26 19:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andy Lutomirski, Thomas Gleixner, Kees Cook, Thomas Lendacky,
	Sami Tolvanen, Heiko Carstens, Ingo Molnar, Borislav Petkov,
	H . Peter Anvin, x86, Arnd Bergmann, linux-arch, Yu-cheng Yu

In x86 kernel, .exit.text and .exit.data sections are discarded at
runtime, not by linker.  Add RUNTIME_DISCARD_EXIT to generic DISCARDS
and define it in x86 kernel linker script to keep them.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
---
 arch/x86/kernel/vmlinux.lds.S     |  1 +
 include/asm-generic/vmlinux.lds.h | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index e3296aa028fe..7206e1ac23dd 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -21,6 +21,7 @@
 #define LOAD_OFFSET __START_KERNEL_map
 #endif
 
+#define RUNTIME_DISCARD_EXIT
 #define EMITS_PT_NOTE
 #define RO_EXCEPTION_TABLE_ALIGN	16
 
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index e00f41aa8ec4..6b943fb8c5fd 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -894,10 +894,16 @@
  * section definitions so that such archs put those in earlier section
  * definitions.
  */
+#ifdef RUNTIME_DISCARD_EXIT
+#define EXIT_DISCARDS
+#else
+#define EXIT_DISCARDS							\
+	EXIT_TEXT							\
+	EXIT_DATA
+#endif
 #define DISCARDS							\
 	/DISCARD/ : {							\
-	EXIT_TEXT							\
-	EXIT_DATA							\
+	EXIT_DISCARDS							\
 	EXIT_CALL							\
 	*(.discard)							\
 	*(.discard.*)							\
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-09-19 17:54 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 13:21 [PATCH 1/2] powerpc: Keep .rela* sections when CONFIG_RELOCATABLE is defined H.J. Lu
2020-04-28 13:21 ` H.J. Lu
2020-04-28 13:21 ` [PATCH 2/2] Discard .note.gnu.property sections in generic NOTES H.J. Lu
2020-04-28 13:21   ` H.J. Lu
2022-09-16 19:40   ` Omar Sandoval
2022-09-16 19:40     ` Omar Sandoval
2022-09-17  6:31     ` Christophe Leroy
2022-09-19 17:26       ` Omar Sandoval
2022-09-19 17:26         ` Omar Sandoval
2022-09-19 17:33         ` Mark Brown
2022-09-19 17:33           ` Mark Brown
2022-09-19 17:40           ` Omar Sandoval
2022-09-19 17:40             ` Omar Sandoval
2022-09-19 17:54             ` Mark Brown
2022-09-19 17:54               ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2020-04-28  1:48 [PATCH 1/2] powerpc: Discard .rela* sections if CONFIG_RELOCATABLE is undefined H.J. Lu
2020-04-28  1:49 ` [PATCH 2/2] Discard .note.gnu.property sections in generic NOTES H.J. Lu
2020-04-28  1:49   ` H.J. Lu
2020-03-26 19:30 [PATCH 1/2] Add RUNTIME_DISCARD_EXIT to generic DISCARDS H.J. Lu
2020-03-26 19:30 ` [PATCH 2/2] Discard .note.gnu.property sections in generic NOTES H.J. Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.