From: ceriel Date: Thu, 6 Aug 1987 18:40:02 +0000 (+0000) Subject: align sizes X-Git-Tag: release-5-5~3929 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=45264c9c2530a0a37cfb96b7fa917a18667dde63;p=ack.git align sizes --- diff --git a/util/led/Makefile b/util/led/Makefile index fbb3efcca..28888c719 100644 --- a/util/led/Makefile +++ b/util/led/Makefile @@ -4,12 +4,12 @@ # Definitions for the making programs. -EM = ../.. -LIBDIR= $(EM)/lib -PREFLAGS= -I$(EM)/h -DNDEBUG -DNASSERT +EMHOME = ../.. +LIBDIR= $(EMHOME)/lib +PREFLAGS= -I$(EMHOME)/h -DNDEBUG -DNASSERT CFLAGS = $(PREFLAGS) -O LDFLAGS = -i -LDLIBS = $(EM)/modules/lib/libstring.a $(EM)/modules/lib/libobject.a +LDLIBS = $(EMHOME)/modules/lib/libstring.a $(EMHOME)/modules/lib/libobject.a LINTFLAGS=-phbxa $(PREFLAGS) PR = pr PRFLAGS = @@ -28,10 +28,10 @@ led: $(OFILES) $(CC) $(LDFLAGS) $(OFILES) $(LDLIBS) -o led install:led - rm -f $(LIBDIR)/em_led $(EM)/man/led.6 $(EM)/man/ack.out.5 + rm -f $(LIBDIR)/em_led $(EMHOME)/man/led.6 $(EMHOME)/man/ack.out.5 cp led $(LIBDIR)/em_led - cp led.6 $(EM)/man/led.6 - cp ack.out.5 $(EM)/man/ack.out.5 + cp led.6 $(EMHOME)/man/led.6 + cp ack.out.5 $(EMHOME)/man/ack.out.5 cmp: led cmp led $(LIBDIR)/em_led diff --git a/util/led/extract.c b/util/led/extract.c index 9b27ea2db..060f8c39c 100644 --- a/util/led/extract.c +++ b/util/led/extract.c @@ -210,14 +210,14 @@ redefine(new, old) if (!ISCOMMON(new)) error("%s: multiply defined", new->on_mptr); - if ((new->on_type & S_TYP) != (old->on_type & S_TYP)) + else if ((new->on_type & S_TYP) != (old->on_type & S_TYP)) warning("%s: sections differ", new->on_mptr); } else { /* `Old' is common. */ - if ((new->on_type & S_TYP) != (old->on_type & S_TYP)) - warning("%s: sections differ", new->on_mptr); - if (ISCOMMON(new)) { + if ((new->on_type & S_TYP) != (old->on_type & S_TYP)) + warning("%s: sections differ", new->on_mptr); + if (new->on_valu > old->on_valu) old->on_valu = new->on_valu; } else { diff --git a/util/led/main.c b/util/led/main.c index 48d8df369..6e15b8b69 100644 --- a/util/led/main.c +++ b/util/led/main.c @@ -416,31 +416,35 @@ complete_sections() { register long base = 0; register long foff; + register struct outsect *sc; register int sectindex; foff = SZ_HEAD + outhead.oh_nsect * SZ_SECT; for (sectindex = 0; sectindex < outhead.oh_nsect; sectindex++) { relorig[sectindex].org_size = (long)0; - outsect[sectindex].os_foff = foff; - foff += outsect[sectindex].os_flen; + sc = &outsect[sectindex]; + sc->os_foff = foff; + foff += sc->os_flen; if ((flagword & RFLAG) && !(flagword & CFLAG)) continue; - outsect[sectindex].os_size += sect_comm[sectindex]; + sc->os_size += sect_comm[sectindex]; if (flagword & RFLAG) continue; - outsect[sectindex].os_lign = + sc->os_lign = tstbit(sectindex, lignmap) ? sect_lign[sectindex] : 1; + sc->os_size += sc->os_lign - 1; + sc->os_size -= sc->os_size % sc->os_lign; if (tstbit(sectindex, basemap)) { base = sect_base[sectindex]; - if (base % outsect[sectindex].os_lign) + if (base % sc->os_lign) fatal("base not aligned"); } else { - base += outsect[sectindex].os_lign - 1; - base -= base % outsect[sectindex].os_lign; + base += sc->os_lign - 1; + base -= base % sc->os_lign; } - outsect[sectindex].os_base = base; - base += outsect[sectindex].os_size; + sc->os_base = base; + base += sc->os_size; } } diff --git a/util/led/scan.c b/util/led/scan.c index 362e0eb46..712afc2d5 100644 --- a/util/led/scan.c +++ b/util/led/scan.c @@ -211,6 +211,7 @@ direct_alloc(head) struct outhead *head; { ind_t sectindex = IND_SECT(*head); + register struct outsect *sects; ushort nsect = head->oh_nsect; long size, rest; extern ind_t hard_alloc(); @@ -228,7 +229,14 @@ direct_alloc(head) size = modulsize(head) - sizeof(struct outhead) - rest; if (hard_alloc(ALLOMODL, size) == BADOFF) fatal("no space for module"); - rd_sect((struct outsect *)modulptr(sectindex), nsect); + rd_sect(sects = ((struct outsect *)modulptr(sectindex)), nsect); + while (nsect--) { + if (sects->os_lign > 1) { + sects->os_size += sects->os_lign - 1; + sects->os_size -= sects->os_size % sects->os_lign; + } + sects++; + } return incore && alloc(ALLOMODL, rest) != BADOFF; } @@ -415,7 +423,7 @@ static read_modul() { struct outhead *head; - struct outsect *sects; + register struct outsect *sects; struct outname *names; char *chars; ind_t sectindex, nameindex, charindex; @@ -446,6 +454,13 @@ read_modul() chars = modulptr(charindex); rd_sect(sects, nsect); + while (nsect--) { + if (sects->os_lign > 1) { + sects->os_size += sects->os_lign - 1; + sects->os_size -= sects->os_size % sects->os_lign; + } + sects++; + } rd_name(names, nname); rd_string(chars, nchar); }