scc

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

commit fc7ec1b82a89eb33fa5b11077c6491fa22876dd0
parent e33fbe2d881dd3035d91e75c59065a5d4fe02034
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 12 Dec 2017 10:48:58 +0000

[as] Preserve order of the symbols in the output file

It is a bit annoying to have the symbols in inverse
state, and for this reason the link insertion strategy
is changed.

Diffstat:
Mas/symbol.c | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/as/symbol.c b/as/symbol.c @@ -41,7 +41,7 @@ int pass; static Symbol *hashtbl[HASHSIZ]; static Alloc *tmpalloc; -Symbol *linesym, *symlist; +Symbol *linesym, *symlist, *symlast; #ifndef NDEBUG void @@ -95,9 +95,16 @@ lookup(char *name, int type) sym->value = 0; sym->section = cursec; sym->hash = *list; - sym->next = symlist; + sym->next = NULL; - return symlist = *list = sym; + *list = sym; + if (symlast) + symlast->next = sym; + symlast = sym; + if (!symlist) + symlist = sym; + + return sym; } Symbol *