git: b85b57e0f41f - stable/13 - arm64: Don't rely on host readelf for u-boot booti image generation

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Tue, 25 Jan 2022 01:40:17 UTC
The branch stable/13 has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=b85b57e0f41ff7477c8bcf316fb5b5d545a276bd

commit b85b57e0f41ff7477c8bcf316fb5b5d545a276bd
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2021-12-24 19:25:20 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2022-01-24 23:59:51 +0000

    arm64: Don't rely on host readelf for u-boot booti image generation
    
    readelf is not a bootstrap tool and so cannot be relied upon to exist.
    On macOS there is no system readelf, and even on Linux or FreeBSD where
    it does exist, BUILD_WITH_STRICT_TMPPATH builds won't be able to use it.
    Instead of making it a bootstrap tool, just use nm as that suffices and
    already is a bootstrap tool.
    
    Fixes:          28482babd08a ("arm64: Use new arm_kernel_boothdr script for generating booti images.")
    Reviewed by:    emaste, mmel
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D32734
    
    (cherry picked from commit 1846bbd1b34e0269e0edd829dcff4729b37a149b)
---
 sys/conf/Makefile.arm64          |  2 +-
 sys/tools/arm_kernel_boothdr.awk | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/conf/Makefile.arm64 b/sys/conf/Makefile.arm64
index e75062115121..e8a534dadf5c 100644
--- a/sys/conf/Makefile.arm64
+++ b/sys/conf/Makefile.arm64
@@ -94,7 +94,7 @@ CLEAN+=	${KERNEL_KO}.bin
 ${KERNEL_KO}.bin: ${FULLKERNEL}
 	@${OBJCOPY} --wildcard --strip-symbol='$$[adtx]*' \
 	    --output-target=binary ${.ALLSRC} ${.TARGET}.temp
-	@{ readelf -s ${.ALLSRC} | \
+	@{ ${NM} ${.ALLSRC} | \
 	    ${AWK} -f $S/tools/arm_kernel_boothdr.awk -v hdrtype=v8booti && \
 	    cat ${.TARGET}.temp; \
 	 } > ${.TARGET}
diff --git a/sys/tools/arm_kernel_boothdr.awk b/sys/tools/arm_kernel_boothdr.awk
index f22c6167c7b0..cda56e2225cd 100644
--- a/sys/tools/arm_kernel_boothdr.awk
+++ b/sys/tools/arm_kernel_boothdr.awk
@@ -144,22 +144,22 @@ function write_v8booti() {
 
 /kernbase/ {
 	# If the symbol name is exactly "kernbase" save its address.
-	if ($8 == "kernbase") {
-		gKernbase = hexstr_to_num($2)
+	if ($3 == "kernbase") {
+		gKernbase = hexstr_to_num($1)
 	}
 }
 
 /_start/ {
 	# If the symbol name is exactly "_start" save its address.
-	if ($8 == "_start") {
-		gStart = hexstr_to_num($2)
+	if ($3 == "_start") {
+		gStart = hexstr_to_num($1)
 	}
 }
 
 /_end/ {
 	# If the symbol name is exactly "_end" remember its value.
-	if ($8 == "_end") {
-		gEnd = hexstr_to_num($2)
+	if ($3 == "_end") {
+		gEnd = hexstr_to_num($1)
 	}
 }