Skip to contentSkip to conversation

nm01: Remove prefix zeros of the addresses output by nm before comparing

PATCH New [email protected] 2 participants 3 messages Dec 25, 2019 – Dec 31, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nm01: Remove prefix zeros of the addresses output by nm before comparing

From: He Zhe <[email protected]>

The latest nm v2.33.1.20191208 outputs symbols addresses without prefix zeros for "nm -f posix", which causes the following error.
nm01 5 TFAIL: Got wrong format with -f bsd

Let's remove the prefix zeros before comparing.

---
 testcases/commands/nm/nm01.sh | 3 +++
 1 file changed, 3 insertions(+)
testcases/commands/nm/nm01.sh +3 -0
index 30c41bd..29b6bd7 100755
@@ -84,6 +84,9 @@ test5()
 	EXPECT_PASS $NM -f bsd $TST_DATAROOT/f1 \> nm_bsd.out
 	EXPECT_PASS $NM -f posix $TST_DATAROOT/f1 \> nm_posix.out
 
+	ROD awk '{print gensub(/(0+)([0-9a-fA-F]+)/, "\\2", "g")}' nm_bsd.out \> nm_bsd.out
+	ROD awk '{print gensub(/(0+)([0-9a-fA-F]+)/, "\\2", "g")}' nm_posix.out \> nm_posix.out
+
 	ROD awk '{print $3 $2 $1}' nm_bsd.out \> nm1.out
 	ROD awk '{print $1 $2 $3}' nm_posix.out \> nm2.out
 
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 nm01: Remove prefix zeros of the addresses output by nm before comparing

Hi Zhe,

Quoted 23 lines · On Wed, Dec 25, 2019 at 2:58 PM <[email protected]> wrote:

From: He Zhe <[email protected]>

The latest nm v2.33.1.20191208 outputs symbols addresses without prefix zeros
for "nm -f posix", which causes the following error.
nm01 5 TFAIL: Got wrong format with -f bsd

Let's remove the prefix zeros before comparing.

---
 testcases/commands/nm/nm01.sh | 3 +++
 1 file changed, 3 insertions(+)
testcases/commands/nm/nm01.sh +1 -0
index 30c41bd..29b6bd7 100755
@@ -84,6 +84,9 @@ test5()
        EXPECT_PASS $NM -f bsd $TST_DATAROOT/f1 \> nm_bsd.out
        EXPECT_PASS $NM -f posix $TST_DATAROOT/f1 \> nm_posix.out
 
+       ROD awk '{print gensub(/(0+)([0-9a-fA-F]+)/, "\\2", "g")}'
Quoted 2 lines

nm_bsd.out \> nm_bsd.out

AWK is base on stream editing, maybe we need the output to a new log file.

Quoted 3 lines

+ ROD awk '{print gensub(/(0+)([0-9a-fA-F]+)/, "\\2", "g")}'
nm_posix.out \> nm_posix.out

The regex is not fit for nm_posix.out since this format of address does not start with 0000000000, e.g.

# cat nm_posix.out | grep 40108f
.annobin_init.c t 40108f
.annobin_init.c_end t 40108f
# echo 40108f | awk '{print gensub(/(0+)([0-9a-fA-F]+)/, "\\2", "g")}'
4108f
Quoted 12 lines

+

        ROD awk '{print $3 $2 $1}' nm_bsd.out \> nm1.out
        ROD awk '{print $1 $2 $3}' nm_posix.out \> nm2.out

--
2.7.4

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191230/9a3f1471/attachment.htm>
author
#2 lore raw

PATCH 1/1 nm01: Remove prefix zeros of the addresses output by nm before comparing

Thanks for pointing it out. I'll send v2.

Zhe

Quoted 59 lines · Li Wang

Hi Zhe,

On Wed, Dec 25, 2019 at 2:58 PM <[email protected] <mailto:[email protected]>> wrote:

From: He Zhe <[email protected] <mailto:[email protected]>>

The latest nm v2.33.1.20191208 outputs symbols addresses without prefix zeros for "nm -f posix", which causes the following error.
nm01 5 TFAIL: Got wrong format with -f bsd

Let's remove the prefix zeros before comparing.

Signed-off-by He Zhe <[email protected] <mailto:[email protected]>>

---
?testcases/commands/nm/nm01.sh | 3 +++
?1 file changed, 3 insertions(+)

diff --git a/testcases/commands/nm/nm01.sh b/testcases/commands/nm/nm01.sh index 30c41bd..29b6bd7 100755
--- a/testcases/commands/nm/nm01.sh
+++ b/testcases/commands/nm/nm01.sh
@@ -84,6 +84,9 @@ test5()
? ? ? ? EXPECT_PASS $NM -f bsd $TST_DATAROOT/f1 \> nm_bsd.out ? ? ? ? EXPECT_PASS $NM -f posix $TST_DATAROOT/f1 \> nm_posix.out

+? ? ? ?ROD awk '{print gensub(/(0+)([0-9a-fA-F]+)/, "\\2", "g")}' nm_bsd.out \> nm_bsd.out

AWK is base on stream editing, maybe we need the output to?a new log file.

    +? ? ? ?ROD awk '{print gensub(/(0+)([0-9a-fA-F]+)/, "\\2", "g")}' nm_posix.out \> nm_posix.out

The regex is not fit for nm_posix.out since this format?of address does not start with 0000000000, e.g.

# cat nm_posix.out | grep 40108f
.annobin_init.c t 40108f
.annobin_init.c_end t 40108f?
# echo 40108f |awk '{print gensub(/(0+)([0-9a-fA-F]+)/, "\\2", "g")}'
4108f
?
    +
    ? ? ? ? ROD awk '{print $3 $2 $1}' nm_bsd.out \> nm1.out
    ? ? ? ? ROD awk '{print $1 $2 $3}' nm_posix.out \> nm2.out

    -- 
    2.7.4


    -- 
    Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Regards,
Li Wang