Module Name:    src
Committed By:   martin
Date:           Mon Sep 11 13:35:38 UTC 2023

Modified Files:
        src/sys/arch/aarch64/conf [netbsd-10]: Makefile.aarch64
        src/sys/arch/alpha/conf [netbsd-10]: Makefile.alpha
        src/sys/arch/arm/conf [netbsd-10]: Makefile.arm
        src/sys/arch/cats/conf [netbsd-10]: Makefile.cats.inc
        src/sys/arch/mips/conf [netbsd-10]: Makefile.mips
        src/sys/arch/riscv/conf [netbsd-10]: Makefile.riscv
        src/sys/arch/shark/conf [netbsd-10]: Makefile.shark.inc
        src/sys/conf [netbsd-10]: Makefile.kern.inc

Log Message:
Pull up following revision(s) (requested by rin in ticket #363):

        sys/arch/aarch64/conf/Makefile.aarch64: revision 1.24
        sys/arch/aarch64/conf/Makefile.aarch64: revision 1.25
        sys/arch/shark/conf/Makefile.shark.inc: revision 1.28
        sys/arch/alpha/conf/Makefile.alpha: revision 1.88
        sys/arch/mips/conf/Makefile.mips: revision 1.73
        sys/conf/Makefile.kern.inc: revision 1.298
        sys/conf/Makefile.kern.inc: revision 1.299
        sys/arch/cats/conf/Makefile.cats.inc: revision 1.37
        sys/arch/arm/conf/Makefile.arm: revision 1.56
        sys/arch/arm/conf/Makefile.arm: revision 1.57
        sys/arch/riscv/conf/Makefile.riscv: revision 1.10

Always use arm-elf2aout; no a.out support both for binutils{,.old}

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.

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.

Use OBJCOPY_STRIPFLAGS instead of STRIPFLAGS.
Simplify fix for PR toolchain/57146

Introduce ARCH_STRIP_SYMBOLS variable to centralize logic for debug
symbols from MD Makefile's to Makefile.kern.inc.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.23.12.1 src/sys/arch/aarch64/conf/Makefile.aarch64
cvs rdiff -u -r1.87 -r1.87.14.1 src/sys/arch/alpha/conf/Makefile.alpha
cvs rdiff -u -r1.55 -r1.55.20.1 src/sys/arch/arm/conf/Makefile.arm
cvs rdiff -u -r1.36 -r1.36.30.1 src/sys/arch/cats/conf/Makefile.cats.inc
cvs rdiff -u -r1.72 -r1.72.14.1 src/sys/arch/mips/conf/Makefile.mips
cvs rdiff -u -r1.8 -r1.8.4.1 src/sys/arch/riscv/conf/Makefile.riscv
cvs rdiff -u -r1.27 -r1.27.30.1 src/sys/arch/shark/conf/Makefile.shark.inc
cvs rdiff -u -r1.295 -r1.295.4.1 src/sys/conf/Makefile.kern.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/conf/Makefile.aarch64
diff -u src/sys/arch/aarch64/conf/Makefile.aarch64:1.23 src/sys/arch/aarch64/conf/Makefile.aarch64:1.23.12.1
--- src/sys/arch/aarch64/conf/Makefile.aarch64:1.23	Thu May 27 06:19:38 2021
+++ src/sys/arch/aarch64/conf/Makefile.aarch64	Mon Sep 11 13:35:37 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.aarch64,v 1.23 2021/05/27 06:19:38 ryo Exp $
+#	$NetBSD: Makefile.aarch64,v 1.23.12.1 2023/09/11 13:35:37 martin Exp $
 
 # Makefile for NetBSD
 #
@@ -95,14 +95,9 @@ 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 $@
-.else
-STRIPFLAGS=-g --strip-symbol='$$x' --strip-symbol='$$d'
-.endif
+# with ddb, but don't strip them in netbsd.gdb. See Makefile.kern.inc.
+ARCH_STRIP_SYMBOLS=	--strip-symbol='[$$][dx]' \
+			--strip-symbol='[$$][dx]\.*'
 
 ##
 ## (6) port specific target dependencies

Index: src/sys/arch/alpha/conf/Makefile.alpha
diff -u src/sys/arch/alpha/conf/Makefile.alpha:1.87 src/sys/arch/alpha/conf/Makefile.alpha:1.87.14.1
--- src/sys/arch/alpha/conf/Makefile.alpha:1.87	Wed May  5 15:39:39 2021
+++ src/sys/arch/alpha/conf/Makefile.alpha	Mon Sep 11 13:35:37 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.alpha,v 1.87 2021/05/05 15:39:39 thorpej Exp $
+#	$NetBSD: Makefile.alpha,v 1.87.14.1 2023/09/11 13:35:37 martin Exp $
 
 # Makefile for NetBSD
 #
@@ -65,7 +65,7 @@ TEXTADDR?=	fffffc0000a00000
 ENTRYPOINT=	__transfer
 KERNLDSCRIPT?=	${ALPHA}/conf/kern.ldscript
 EXTRA_LINKFLAGS=	-G 4
-STRIPFLAGS=	-g -X
+OBJCOPY_STRIPFLAGS=	-g -X
 
 ##
 ## (6) port specific target dependencies

Index: src/sys/arch/arm/conf/Makefile.arm
diff -u src/sys/arch/arm/conf/Makefile.arm:1.55 src/sys/arch/arm/conf/Makefile.arm:1.55.20.1
--- src/sys/arch/arm/conf/Makefile.arm:1.55	Fri Jul 10 12:25:09 2020
+++ src/sys/arch/arm/conf/Makefile.arm	Mon Sep 11 13:35:38 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.arm,v 1.55 2020/07/10 12:25:09 skrll Exp $
+#	$NetBSD: Makefile.arm,v 1.55.20.1 2023/09/11 13:35:38 martin Exp $
 
 # Makefile for NetBSD
 #
@@ -106,15 +106,9 @@ 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 $@
-.else
-STRIPFLAGS=-g --wildcard --strip-symbol='[$$][atd]' \
-	   --strip-symbol='[$$][atd]\.*'
-.endif
+# with ddb, but don't strip them in netbsd.gdb. See Makefile.kern.inc.
+ARCH_STRIP_SYMBOLS=	--strip-symbol='[$$][atd]' \
+			--strip-symbol='[$$][atd]\.*'
 
 ##
 ## (6) port specific target dependencies

Index: src/sys/arch/cats/conf/Makefile.cats.inc
diff -u src/sys/arch/cats/conf/Makefile.cats.inc:1.36 src/sys/arch/cats/conf/Makefile.cats.inc:1.36.30.1
--- src/sys/arch/cats/conf/Makefile.cats.inc:1.36	Mon Dec 31 13:30:17 2018
+++ src/sys/arch/cats/conf/Makefile.cats.inc	Mon Sep 11 13:35:38 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.cats.inc,v 1.36 2018/12/31 13:30:17 christos Exp $
+#	$NetBSD: Makefile.cats.inc,v 1.36.30.1 2023/09/11 13:35:38 martin Exp $
 
 MACHINE_ARCH?=	arm
 CPPFLAGS+=	-D${MACHINE}
@@ -27,14 +27,8 @@ ${KERNLDSCRIPT}: \
 	  OBJDUMP=${OBJDUMP} ${HOST_SH} $S/conf/mkldscript.sh \
 		${SYSTEM_OBJ} ; \
 	  cat ${ARM}/conf/kern.ldscript.tail ) > $@
-.if ${HAVE_BINUTILS} == 227
-SYSTEM_LD_TAIL_EXTRA+=; \
-	echo "${OBJCOPY} ${OBJCOPY_ELF2AOUT_FLAGS} $@ $@.aout"; \
-	${OBJCOPY} ${OBJCOPY_ELF2AOUT_FLAGS} $@ $@.aout
-.else
 SYSTEM_LD_TAIL_EXTRA+=; \
 	echo "${ARM_ELF2AOUT} $@ $@.aout"; \
 	${ARM_ELF2AOUT} $@ $@.aout
 .endif
-.endif
 

Index: src/sys/arch/mips/conf/Makefile.mips
diff -u src/sys/arch/mips/conf/Makefile.mips:1.72 src/sys/arch/mips/conf/Makefile.mips:1.72.14.1
--- src/sys/arch/mips/conf/Makefile.mips:1.72	Mon Apr 26 00:28:01 2021
+++ src/sys/arch/mips/conf/Makefile.mips	Mon Sep 11 13:35:37 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.mips,v 1.72 2021/04/26 00:28:01 christos Exp $
+#	$NetBSD: Makefile.mips,v 1.72.14.1 2023/09/11 13:35:37 martin Exp $
 
 # Makefile for NetBSD
 #
@@ -105,7 +105,7 @@ KERNLDSCRIPT?=		${MIPS}/conf/kern.ldscri
 # some mips ports specify a "magic" format
 EXTRA_LINKFLAGS=	${GP} ${LDOPTS}
 LINKFLAGS_NORMAL=	-X
-STRIPFLAGS=		-g -X
+OBJCOPY_STRIPFLAGS=	-g -X
 
 ##
 ## (6) port specific target dependencies

Index: src/sys/arch/riscv/conf/Makefile.riscv
diff -u src/sys/arch/riscv/conf/Makefile.riscv:1.8 src/sys/arch/riscv/conf/Makefile.riscv:1.8.4.1
--- src/sys/arch/riscv/conf/Makefile.riscv:1.8	Wed Sep 28 05:02:02 2022
+++ src/sys/arch/riscv/conf/Makefile.riscv	Mon Sep 11 13:35:38 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.riscv,v 1.8 2022/09/28 05:02:02 skrll Exp $
+#	$NetBSD: Makefile.riscv,v 1.8.4.1 2023/09/11 13:35:38 martin Exp $
 
 # Makefile for NetBSD
 #
@@ -76,7 +76,7 @@ TEXTADDR?=		0x80200000
 KERNLDSCRIPT?=		${RISCV}/conf/kern.ldscript
 EXTRA_LINKFLAGS=	${LDOPTS} --relax
 LINKFLAGS_NORMAL=	-X
-STRIPFLAGS=		-g -X
+OBJCOPY_STRIPFLAGS=	-g -X
 
 # Set the physical load address (aka LMA) to the address that OpenSBI's
 # fw_jump jumps to.  This allows us to load the kernel with the -kernel flag

Index: src/sys/arch/shark/conf/Makefile.shark.inc
diff -u src/sys/arch/shark/conf/Makefile.shark.inc:1.27 src/sys/arch/shark/conf/Makefile.shark.inc:1.27.30.1
--- src/sys/arch/shark/conf/Makefile.shark.inc:1.27	Mon Dec 31 13:37:07 2018
+++ src/sys/arch/shark/conf/Makefile.shark.inc	Mon Sep 11 13:35:37 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.shark.inc,v 1.27 2018/12/31 13:37:07 christos Exp $
+#	$NetBSD: Makefile.shark.inc,v 1.27.30.1 2023/09/11 13:35:37 martin Exp $
 
 CPPFLAGS+=		-D${MACHINE}
 CFLAGS+=		-fno-unwind-tables
@@ -22,14 +22,8 @@ ldscript: \
 		${SYSTEM_OBJ} ; \
 	  cat ${ARM}/conf/kern.ldscript.tail ) > ldscript
 
-.if ${HAVE_BINUTILS} == 227
-SYSTEM_LD_TAIL_EXTRA+=; \
-	echo "${OBJCOPY} ${OBJCOPY_ELF2AOUT_FLAGS} $@ $@.aout"; \
-	${OBJCOPY} ${OBJCOPY_ELF2AOUT_FLAGS} $@ $@.aout
-.else
 SYSTEM_LD_TAIL_EXTRA+=; \
 	echo "${ARM_ELF2AOUT} $@ $@.aout"; \
 	${ARM_ELF2AOUT} $@ $@.aout
-.endif
 
 KERNIMAGES=	netbsd netbsd.aout

Index: src/sys/conf/Makefile.kern.inc
diff -u src/sys/conf/Makefile.kern.inc:1.295 src/sys/conf/Makefile.kern.inc:1.295.4.1
--- src/sys/conf/Makefile.kern.inc:1.295	Sat Aug 27 20:37:49 2022
+++ src/sys/conf/Makefile.kern.inc	Mon Sep 11 13:35:37 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.kern.inc,v 1.295 2022/08/27 20:37:49 rillig Exp $
+#	$NetBSD: Makefile.kern.inc,v 1.295.4.1 2023/09/11 13:35:37 martin 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,27 @@ 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 && \
-		${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@
-SYSTEM_LD_TAIL+= && runit() { echo $$@; $$@; }
+SYSTEM_LD_TAIL?=	@${_MKSHECHO}
+OBJCOPY_STRIPFLAGS?=	-g
+
+# Strip some architecture-defined symbols from kernel image, while
+# keep them in netbsd.gdb.
+.if defined(ARCH_STRIP_SYMBOLS)
+.if empty(DEBUG:M-g*)
+SYSTEM_LD_TAIL+=	&& ${OBJCOPY} -w ${ARCH_STRIP_SYMBOLS} $@
+.endif
+OBJCOPY_STRIPFLAGS+=	-w ${ARCH_STRIP_SYMBOLS}
+.endif
+
+SYSTEM_LD_TAIL+= && ${TOOL_SED} \
+	'/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \
+	${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@ && \
+	runit() { echo $$@; $$@; }
 
 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
 

Reply via email to