Skip to contentSkip to conversation

scripts/mksysmap: Fix badly escaped '$'

PATCH In review Pierre-Clément Tosi 2 participants 2 messages Jun 6, 2023 – Jun 7, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/mksysmap: Fix badly escaped '$'

The backslash characters escaping '$' in the command to sed (intended to prevent it from interpreting '$' as "end-of-line") are currently being consumed by the Shell (where they mean that sh should not evaluate what follows '$' as a variable name). This means that

    sed -e "/ \$/d"

executes the script

    / $/d

instead of the intended

    / \$/d

So escape twice in mksysmap any '$' that actually needs to reach sed escaped so that the backslash survives the Shell.

Fixes c4802044a0a7 ("scripts/mksysmap: use sed with in-line comments")
Fixes 320e7c9d4494 ("scripts/kallsyms: move compiler-generated symbol patterns to mksysmap")
---
 scripts/mksysmap | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/mksysmap +2 -2
index cb3b1fff3eee..ec3338526102 100755
@@ -32,7 +32,7 @@ ${NM} -n ${1} | sed >${2} -e "
 #  (do not forget a space before each pattern)
 
 # local symbols for ARM, MIPS, etc.
-/ \$/d
+/ \\$/d
 
 # local labels, .LBB, .Ltmpxxx, .L__unnamed_xx, .LASANPC, etc.
 / \.L/d
@@ -41,7 +41,7 @@ ${NM} -n ${1} | sed >${2} -e "
 / __efistub_/d
 
 # arm64 local symbols in non-VHE KVM namespace
-/ __kvm_nvhe_\$/d
+/ __kvm_nvhe_\\$/d
 / __kvm_nvhe_\.L/d
 
 # arm64 lld
Signature · 5 lines
2.41.0.rc0.172.g3f132b7071-goog


-- 
Pierre
#1 lore raw
Quoted 10 lines · Pierre-Clément Tosi

The backslash characters escaping '$' in the command to sed (intended to prevent it from interpreting '$' as "end-of-line") are currently being consumed by the Shell (where they mean that sh should not evaluate what follows '$' as a variable name). This means that

    sed -e "/ \$/d"

executes the script

Quoted 8 lines
    / $/d

instead of the intended

    / \$/d

So escape twice in mksysmap any '$' that actually needs to reach sed escaped so that the backslash survives the Shell.

You are right. Thanks for catching this bug.

Applied to linux-kbuild. Thanks.

Quoted 36 lines
Fixes c4802044a0a7 ("scripts/mksysmap: use sed with in-line comments")
Fixes 320e7c9d4494 ("scripts/kallsyms: move compiler-generated symbol patterns to mksysmap")
---
 scripts/mksysmap | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/mksysmap +2 -3
index cb3b1fff3eee..ec3338526102 100755
@@ -32,7 +32,7 @@ ${NM} -n ${1} | sed >${2} -e "
 #  (do not forget a space before each pattern)
 
 # local symbols for ARM, MIPS, etc.
-/ \$/d
+/ \\$/d
 
 # local labels, .LBB, .Ltmpxxx, .L__unnamed_xx, .LASANPC, etc.
 / \.L/d
@@ -41,7 +41,7 @@ ${NM} -n ${1} | sed >${2} -e "
 / __efistub_/d
 
 # arm64 local symbols in non-VHE KVM namespace
-/ __kvm_nvhe_\$/d
+/ __kvm_nvhe_\\$/d
 / __kvm_nvhe_\.L/d
 
 # arm64 lld
--

2.41.0.rc0.172.g3f132b7071-goog

--
Pierre

Signature · 2 lines
Best Regards
Masahiro Yamada