mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 11/15] scripts: link-barebox: kallsyms allow 3-pass generation
Date: Thu, 29 Nov 2018 12:30:44 +0100	[thread overview]
Message-ID: <20181129113048.31857-12-s.trumtrar@pengutronix.de> (raw)
In-Reply-To: <20181129113048.31857-1-s.trumtrar@pengutronix.de>

Based on linux v4.10 patch: 7e2b37c971a2a20ec8a311a195a626c16c774031

    kbuild: kallsyms allow 3-pass generation if symbols size has changed

    kallsyms generation is not foolproof, due to some linkers adding
    symbols (e.g., branch trampolines) when a binary size changes.
    Have it attempt a 3rd pass automatically if the kallsyms size changes
    in the 2nd pass.

    This allows powerpc64 allyesconfig to build without adding another
    pass when it's not required.

    This can be solved other ways by directing the linker not to add labels
    on branch stubs, or to move kallsyms near the end of the image. The
    former is undesirable for debugging/tracing, and the latter is a more
    significant change that requires more testing and review.

    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michal Marek <mmarek@suse.com>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 scripts/link-barebox.sh | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/scripts/link-barebox.sh b/scripts/link-barebox.sh
index a783dd6d5532..34fa1944002c 100755
--- a/scripts/link-barebox.sh
+++ b/scripts/link-barebox.sh
@@ -200,7 +200,14 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
 	# 2a) We may use an extra pass as this has been necessary to
 	#     woraround some alignment related bugs.
 	#     KALLSYMS_EXTRA_PASS=1 is used to trigger this.
-	# 3)  The correct ${kallsymso} is linked into the final barebox.
+	# 3)  That link may have expanded the kernel image enough that
+	#     more linker branch stubs / trampolines had to be added, which
+	#     introduces new names, which further expands kallsyms. Do another
+	#     pass if that is the case. In theory it's possible this results
+	#     in even more stubs, but unlikely.
+	#     KALLSYMS_EXTRA_PASS=1 may also used to debug or work around
+	#     other bugs.
+	# 4)  The correct ${kallsymso} is linked into the final vmlinux.
 	#
 	# a)  Verify that the System.map from barebox matches the map from
 	#     ${kallsymso}.
@@ -216,8 +223,11 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
 	barebox_link .tmp_kallsyms1.o .tmp_barebox2
 	kallsyms .tmp_barebox2 .tmp_kallsyms2.o
 
-	# step 2a
-	if [ -n "${CONFIG_KALLSYMS_EXTRA_PASS}" ]; then
+	# step 3
+	size1=$(stat -c "%s" .tmp_kallsyms1.o)
+	size2=$(stat -c "%s" .tmp_kallsyms2.o)
+
+	if [ $size1 -ne $size2 ] || [ -n "${CONFIG_KALLSYMS_EXTRA_PASS}" ]; then
 		kallsymso=.tmp_kallsyms3.o
 		kallsyms_barebox=.tmp_barebox3
 
-- 
2.19.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2018-11-29 11:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 01/15] Makefile: replace LINUXINCLUDE with BAREBOXINCLUDE Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 02/15] Makefile: Correctly deal with make options which contain an "s" Steffen Trumtrar
2018-12-09 23:07   ` Roland Hieber
2018-11-29 11:30 ` [PATCH 03/15] scripts/Kbuild.include: Fix portability problem of "echo -e" Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 04/15] scripts/Kbuild.include: replace KBUILD_CPPFLAGS with CPPFLAGS Steffen Trumtrar
2018-12-05 12:22   ` Masahiro Yamada
2018-12-05 12:26     ` Masahiro Yamada
2018-12-06  7:54     ` Sascha Hauer
2018-11-29 11:30 ` [PATCH 05/15] debug: Add CONFIG_DEBUG_READABLE_ASM Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 06/15] Makefile: improve line wrapping Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 07/15] Makefile: link of barebox moved to script Steffen Trumtrar
2018-11-30  7:17   ` Sascha Hauer
2018-12-03  4:49   ` Sam Ravnborg
2018-12-04  7:56     ` Sascha Hauer
2018-11-29 11:30 ` [PATCH 08/15] scripts: link-barebox: fix bash-ism Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 09/15] scripts: link-barebox: force error on kallsyms failure Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 10/15] scripts: link-barebox: allow architectures to use thin archives instead of ld -r Steffen Trumtrar
2018-11-29 11:30 ` Steffen Trumtrar [this message]
2018-11-29 11:30 ` [PATCH 12/15] scripts: link-barebox: minor improvement for thin archives build Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 13/15] scripts: link-barebox: close thin archives --whole-archives option Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 14/15] scripts: link-barebox: thin archives use P option to ar Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 15/15] ARM: Kconfig: select THIN_ARCHIVES for ARM Steffen Trumtrar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181129113048.31857-12-s.trumtrar@pengutronix.de \
    --to=s.trumtrar@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox