scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit cb1f1b2d2544c5dd3695e6138794b7bf5272412d
parent 44391250aeae042fa5d3b49303ae1a967d56f28e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 12 Jan 2025 12:27:02 +0100

nm: Use name comparision if no compare in other way

This helps to make more predictable the outout of the command
because the final order is independent of the original order
in the binary file.

Diffstat:
Msrc/cmd/scc-nm.c | 5++---
Mtests/nm/execute/0004-z80-v.sh | 24++++++++++++------------
2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/cmd/scc-nm.c b/src/cmd/scc-nm.c @@ -60,10 +60,9 @@ cmp(const void *p1, const void *p2) return -1; if (sym2->type == 'U') return 1; - return 0; - } else { - return strcmp(sym1->name, sym2->name); } + + return strcmp(sym1->name, sym2->name); } static void diff --git a/tests/nm/execute/0004-z80-v.sh b/tests/nm/execute/0004-z80-v.sh @@ -10,24 +10,24 @@ scc nm -v z80.out > $tmp1 cat <<! > $tmp2 U text6 -0000000000000000 t .text -0000000000000000 d .data 0000000000000000 b .bss -0000000000000000 T text1 -0000000000000000 D data1 +0000000000000000 d .data +0000000000000000 t .text 0000000000000000 B bss1 -0000000000000001 T averylongtext -0000000000000001 D averylongdata +0000000000000000 D data1 +0000000000000000 T text1 0000000000000001 B averylongbss -0000000000000002 t text3 -0000000000000002 d data3 +0000000000000001 D averylongdata +0000000000000001 T averylongtext 0000000000000002 b bss3 -000000000000000a C text4 -000000000000000a C data4 +0000000000000002 d data3 +0000000000000002 t text3 000000000000000a C bss4 -0000000000000012 C text5 -0000000000000012 C data5 +000000000000000a C data4 +000000000000000a C text4 0000000000000012 C bss5 +0000000000000012 C data5 +0000000000000012 C text5 ! diff $tmp1 $tmp2