scc

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

commit a64b35f219113878d8021e102df5630841cce9e4
parent e7d954cc351380a9c4fb2de72a585ff849b0fbc1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 19 Jan 2020 15:15:56 +0100

ld: Simplify newsec()

Diffstat:
Msrc/cmd/ld/pass1.c | 19++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/cmd/ld/pass1.c b/src/cmd/ld/pass1.c @@ -41,25 +41,26 @@ newsec(Section *osec, Obj *obj) unsigned long long base; sec = lookupsec(osec->name); - if (sec->type != 'U') { + if (sec->type == 'U') { + sec->type = osec->type; + sec->base = osec->base; + sec->size = osec->size; + sec->flags = osec->flags; + align = 0; + } else { if (sec->type != osec->type || sec->flags != osec->flags - || sec->base != osec->base || sec->align != osec->align) { - error("incompatible definition of section %s", sec->name); + error("incompatible definition of section %s", + sec->name); return; } align = osec->align; align -= sec->size & align-1; grow(sec, align); - rebase(obj, osec->index, sec->size); - } else { - sec->type = osec->type; - sec->base = osec->base; - sec->size = osec->size; - sec->flags = osec->flags; } + rebase(obj, osec->index, sec->size); copy(obj, osec, sec); }