[PATCH] arm64: Change the location of DISCARDS

From: Youling Tang
Date: Wed Nov 04 2020 - 05:49:12 EST


In the include/asm-generic/vmlinux.lds.h file, the "must be the last"
comment indicates that DISCARDS should be placed in the last position
of SECTIONS, like x86, mips, riscv, etc.

Signed-off-by: Youling Tang <tangyouling@xxxxxxxxxxx>
---
arch/arm64/kernel/vmlinux.lds.S | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index 1bda604..bf31074 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -109,12 +109,6 @@ SECTIONS
* matching the same input section name. There is no documented
* order of matching.
*/
- DISCARDS
- /DISCARD/ : {
- *(.interp .dynamic)
- *(.dynsym .dynstr .hash .gnu.hash)
- }
-
. = KIMAGE_VADDR;

.head.text : {
@@ -284,6 +278,13 @@ SECTIONS

.data.rel.ro : { *(.data.rel.ro) }
ASSERT(SIZEOF(.data.rel.ro) == 0, "Unexpected RELRO detected!")
+
+ /* Sections to be discarded */
+ DISCARDS
+ /DISCARD/ : {
+ *(.interp .dynamic)
+ *(.dynsym .dynstr .hash .gnu.hash)
+ }
}

#include "image-vars.h"
--
2.1.0