public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/link-vmlinux.sh: force error on kallsyms failure
@ 2016-02-04 17:09 Ard Biesheuvel
  2016-02-05  9:58 ` Michal Marek
  0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2016-02-04 17:09 UTC (permalink / raw)
  To: linux-kernel, akpm, linux, arnd; +Cc: rusty, mmarek, Ard Biesheuvel

Since the output of the invocation of scripts/kallsyms is piped directly
into the assembler, error messages it emits are visible on stderr, but
a non-zero return code is ignored, and the build simply proceeds in that
case. However, the resulting kernel is most likely broken, and will crash
at boot. So capture the return code of scripts/kallsyms explicitly (in a
POSIX shell compatible manner), and abort the script if it is non-zero.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 scripts/link-vmlinux.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index b83f918c7830..71882648e064 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -93,9 +93,12 @@ kallsyms()
 	local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL}               \
 		      ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
 
-	${NM} -n ${1} | \
-		scripts/kallsyms ${kallsymopt} | \
-		${CC} ${aflags} -c -o ${2} -x assembler-with-cpp -
+	# capture the return code of scripts/kallsyms in $RC
+	local RC=`(${NM} -n ${1} | \
+		(scripts/kallsyms ${kallsymopt}; echo $? 1>&3) | \
+		${CC} ${aflags} -c -o ${2} -x assembler-with-cpp -) 3>&1`
+
+	[ $RC -eq 0 ]
 }
 
 # Create map file with all symbols from ${1}
-- 
2.5.0

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

* Re: [PATCH] scripts/link-vmlinux.sh: force error on kallsyms failure
  2016-02-04 17:09 [PATCH] scripts/link-vmlinux.sh: force error on kallsyms failure Ard Biesheuvel
@ 2016-02-05  9:58 ` Michal Marek
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Marek @ 2016-02-05  9:58 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: linux-kernel, akpm, linux, arnd, rusty

On 2016-02-04 18:09, Ard Biesheuvel wrote:
> -	${NM} -n ${1} | \
> -		scripts/kallsyms ${kallsymopt} | \
> -		${CC} ${aflags} -c -o ${2} -x assembler-with-cpp -
> +	# capture the return code of scripts/kallsyms in $RC
> +	local RC=`(${NM} -n ${1} | \
> +		(scripts/kallsyms ${kallsymopt}; echo $? 1>&3) | \
> +		${CC} ${aflags} -c -o ${2} -x assembler-with-cpp -) 3>&1`
> +
> +	[ $RC -eq 0 ]

This now ignores errors by the assembler (and makes the function hard to
read). Please change it to use a temporary file.

Michal

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

end of thread, other threads:[~2016-02-05  9:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-04 17:09 [PATCH] scripts/link-vmlinux.sh: force error on kallsyms failure Ard Biesheuvel
2016-02-05  9:58 ` Michal Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox