align sizes

This commit is contained in:
ceriel 1987-08-06 18:40:02 +00:00
parent fe67243700
commit 45264c9c25
4 changed files with 41 additions and 22 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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;
}
}

View file

@ -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);
}