Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/conf Fix kernel size inflation for arm and aarch64 (PR t...



details:   https://anonhg.NetBSD.org/src/rev/7b413f2d1bec
branches:  trunk
changeset: 378195:7b413f2d1bec
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Jul 26 03:39:55 2023 +0000

description:
Fix kernel size inflation for arm and aarch64 (PR toolchain/57146)

For some conditions, SYSTEM_LD_TAIL is set for arm and aarch64.
Then, ctfmerge(1) in default SYSTEM_LD_TAIL is unintentionally
skipped, which results in the catastrophic kernel size inflation,
as reported in the PR.

Also, introduce and use OBJCOPY_STRIPFLAGS variable instead of
STRIPFLAGS, as strip(1) is replaced by objcopy(1) during MI
kernel build procedure.

XXX
For Makefile.{arm,aarch64}, weird logic is used to determine how
to handle debug symbols; MKDEBUG{,KERNEL} are taken into account
later in sys/conf/Makefile.kern.inc.

diffstat:

 sys/arch/aarch64/conf/Makefile.aarch64 |  15 ++++++++-------
 sys/arch/arm/conf/Makefile.arm         |  16 ++++++++--------
 sys/conf/Makefile.kern.inc             |   9 ++++++---
 3 files changed, 22 insertions(+), 18 deletions(-)

diffs (90 lines):

diff -r 648f272638e9 -r 7b413f2d1bec sys/arch/aarch64/conf/Makefile.aarch64
--- a/sys/arch/aarch64/conf/Makefile.aarch64    Wed Jul 26 02:31:27 2023 +0000
+++ b/sys/arch/aarch64/conf/Makefile.aarch64    Wed Jul 26 03:39:55 2023 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.aarch64,v 1.23 2021/05/27 06:19:38 ryo Exp $
+#      $NetBSD: Makefile.aarch64,v 1.24 2023/07/26 03:39:55 rin Exp $
 
 # Makefile for NetBSD
 #
@@ -95,13 +95,14 @@ LOADADDRESS?=       0xffffc00000000000
 LINKFLAGS_NORMAL=      -X
 
 # Strip AArch64 mapping symbols from the kernel image, as they interfere
-# with ddb. Do it differently if 'makeoptions DEBUG="-g"' was specified.
-.if !defined(DEBUG) || empty(DEBUG:M-g*)
-SYSTEM_LD_TAIL?=       ${OBJCOPY} -w --strip-symbol='[$$][dx]' \
-                                  --strip-symbol='[$$][dx]\.*' $@ ;\
-                       ${SIZE} $@; chmod 755 $@
+# with ddb, but don't strip them in netbsd.gdb.
+AA64_STRIP_SYMBOLS=    --strip-symbol='[$$][dx]' \
+                       --strip-symbol='[$$][dx]\.*'
+.if (defined(DEBUG) && !empty(DEBUG:M-g*)) || (!defined(DEBUG) && \
+       (${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes"))
+OBJCOPY_STRIPFLAGS=    -g -w ${AA64_STRIP_SYMBOLS}
 .else
-STRIPFLAGS=-g --strip-symbol='$$x' --strip-symbol='$$d'
+SYSTEM_LD_TAIL=                @${OBJCOPY} -w ${AA64_STRIP_SYMBOLS} $@
 .endif
 
 ##
diff -r 648f272638e9 -r 7b413f2d1bec sys/arch/arm/conf/Makefile.arm
--- a/sys/arch/arm/conf/Makefile.arm    Wed Jul 26 02:31:27 2023 +0000
+++ b/sys/arch/arm/conf/Makefile.arm    Wed Jul 26 03:39:55 2023 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.arm,v 1.55 2020/07/10 12:25:09 skrll Exp $
+#      $NetBSD: Makefile.arm,v 1.56 2023/07/26 03:39:55 rin Exp $
 
 # Makefile for NetBSD
 #
@@ -106,14 +106,14 @@ locore.o: ${ARM}/arm32/locore.S assym.h
 LOADADDRESS?=  0xF0000000
 LINKFLAGS_NORMAL=      -X
 # Strip ARM mapping symbols from the kernel image, as they interfere
-# with ddb. Do it differently if 'makeoptions DEBUG="-g"' was specified.
-.if !defined(DEBUG) || empty(DEBUG:M-g*)
-SYSTEM_LD_TAIL?=       ${OBJCOPY} --wildcard --strip-symbol='[$$][atd]' \
-                                   --strip-symbol='[$$][atd]\.*' $@;   \
-                       ${SIZE} $@; chmod 755 $@
+# with ddb, but don't strip them in netbsd.gdb.
+ARM_STRIP_SYMBOLS=     --strip-symbol='[$$][atd]' \
+                       --strip-symbol='[$$][atd]\.*'
+.if (defined(DEBUG) && !empty(DEBUG:M-g*)) || (!defined(DEBUG) && \
+       (${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes"))
+OBJCOPY_STRIPFLAGS=    -g -w ${ARM_STRIP_SYMBOLS}
 .else
-STRIPFLAGS=-g --wildcard --strip-symbol='[$$][atd]' \
-          --strip-symbol='[$$][atd]\.*'
+SYSTEM_LD_TAIL=                @${OBJCOPY} -w ${ARM_STRIP_SYMBOLS} $@
 .endif
 
 ##
diff -r 648f272638e9 -r 7b413f2d1bec sys/conf/Makefile.kern.inc
--- a/sys/conf/Makefile.kern.inc        Wed Jul 26 02:31:27 2023 +0000
+++ b/sys/conf/Makefile.kern.inc        Wed Jul 26 03:39:55 2023 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.kern.inc,v 1.297 2023/06/03 21:26:29 lukem Exp $
+#      $NetBSD: Makefile.kern.inc,v 1.298 2023/07/26 03:39:55 rin Exp $
 #
 # This file contains common `MI' targets and definitions and it is included
 # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
@@ -245,14 +245,17 @@ LINKFLAGS?=       ${LINKFORMAT} ${LINKSCRIPT} 
 LINKFLAGS_DEBUG?=      -X
 KERNEL_CONFIG?=        ${KERNEL_BUILD:T}
 
-SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \
+SYSTEM_LD_TAIL?= @${_MKSHECHO}
+SYSTEM_LD_TAIL+= && ${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \
                ${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@
 SYSTEM_LD_TAIL+= && runit() { echo $$@; $$@; }
 
+OBJCOPY_STRIPFLAGS?= -g
+
 SYSTEM_LD_TAIL_DEBUG?=&& \
        runit mv -f $@ $@.gdb && \
        runit ${OBJCOPY} --only-keep-debug $@.gdb $@-${KERNEL_CONFIG}.debug && \
-       runit ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \
+       runit ${OBJCOPY} ${OBJCOPY_STRIPFLAGS} -p -R .gnu_debuglink \
            --add-gnu-debuglink=$@-${KERNEL_CONFIG}.debug $@.gdb $@ && \
        runit chmod 755 $@ $@.gdb $@-${KERNEL_CONFIG}.debug
 



Home | Main Index | Thread Index | Old Index