align sizes
This commit is contained in:
		
							parent
							
								
									fe67243700
								
							
						
					
					
						commit
						45264c9c25
					
				
					 4 changed files with 41 additions and 22 deletions
				
			
		|  | @ -4,12 +4,12 @@ | ||||||
| 
 | 
 | ||||||
| #	Definitions for the making programs.
 | #	Definitions for the making programs.
 | ||||||
| 
 | 
 | ||||||
| EM = ../.. | EMHOME = ../.. | ||||||
| LIBDIR= $(EM)/lib | LIBDIR= $(EMHOME)/lib | ||||||
| PREFLAGS=  -I$(EM)/h -DNDEBUG -DNASSERT | PREFLAGS=  -I$(EMHOME)/h -DNDEBUG -DNASSERT | ||||||
| CFLAGS	= $(PREFLAGS) -O | CFLAGS	= $(PREFLAGS) -O | ||||||
| LDFLAGS	= -i | 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) | LINTFLAGS=-phbxa $(PREFLAGS) | ||||||
| PR	= pr | PR	= pr | ||||||
| PRFLAGS	= | PRFLAGS	= | ||||||
|  | @ -28,10 +28,10 @@ led:	$(OFILES) | ||||||
| 	$(CC) $(LDFLAGS) $(OFILES) $(LDLIBS) -o led | 	$(CC) $(LDFLAGS) $(OFILES) $(LDLIBS) -o led | ||||||
| 
 | 
 | ||||||
| install: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 $(LIBDIR)/em_led | ||||||
| 	cp led.6 $(EM)/man/led.6 | 	cp led.6 $(EMHOME)/man/led.6 | ||||||
| 	cp ack.out.5 $(EM)/man/ack.out.5 | 	cp ack.out.5 $(EMHOME)/man/ack.out.5 | ||||||
| 
 | 
 | ||||||
| cmp:	led | cmp:	led | ||||||
| 	cmp led $(LIBDIR)/em_led | 	cmp led $(LIBDIR)/em_led | ||||||
|  |  | ||||||
|  | @ -210,14 +210,14 @@ redefine(new, old) | ||||||
| 		if (!ISCOMMON(new)) | 		if (!ISCOMMON(new)) | ||||||
| 			error("%s: multiply defined", new->on_mptr); | 			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); | 			warning("%s: sections differ", new->on_mptr); | ||||||
| 	} else { | 	} else { | ||||||
| 		/* `Old' is common. */ | 		/* `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 (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) | 			if (new->on_valu > old->on_valu) | ||||||
| 				old->on_valu = new->on_valu; | 				old->on_valu = new->on_valu; | ||||||
| 		} else { | 		} else { | ||||||
|  |  | ||||||
|  | @ -416,31 +416,35 @@ complete_sections() | ||||||
| { | { | ||||||
| 	register long	base = 0; | 	register long	base = 0; | ||||||
| 	register long	foff; | 	register long	foff; | ||||||
|  | 	register struct outsect *sc; | ||||||
| 	register int	sectindex; | 	register int	sectindex; | ||||||
| 
 | 
 | ||||||
| 	foff = SZ_HEAD + outhead.oh_nsect * SZ_SECT; | 	foff = SZ_HEAD + outhead.oh_nsect * SZ_SECT; | ||||||
| 	for (sectindex = 0; sectindex < outhead.oh_nsect; sectindex++) { | 	for (sectindex = 0; sectindex < outhead.oh_nsect; sectindex++) { | ||||||
| 		relorig[sectindex].org_size = (long)0; | 		relorig[sectindex].org_size = (long)0; | ||||||
| 		outsect[sectindex].os_foff = foff; | 		sc = &outsect[sectindex]; | ||||||
| 		foff += outsect[sectindex].os_flen; | 		sc->os_foff = foff; | ||||||
|  | 		foff += sc->os_flen; | ||||||
| 
 | 
 | ||||||
| 		if ((flagword & RFLAG) && !(flagword & CFLAG)) | 		if ((flagword & RFLAG) && !(flagword & CFLAG)) | ||||||
| 			continue; | 			continue; | ||||||
| 
 | 
 | ||||||
| 		outsect[sectindex].os_size += sect_comm[sectindex]; | 		sc->os_size += sect_comm[sectindex]; | ||||||
| 		if (flagword & RFLAG) continue; | 		if (flagword & RFLAG) continue; | ||||||
| 		outsect[sectindex].os_lign = | 		sc->os_lign = | ||||||
| 			tstbit(sectindex, lignmap) ? sect_lign[sectindex] : 1; | 			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)) { | 		if (tstbit(sectindex, basemap)) { | ||||||
| 			base = sect_base[sectindex]; | 			base = sect_base[sectindex]; | ||||||
| 			if (base % outsect[sectindex].os_lign) | 			if (base % sc->os_lign) | ||||||
| 				fatal("base not aligned"); | 				fatal("base not aligned"); | ||||||
| 		} else { | 		} else { | ||||||
| 			base += outsect[sectindex].os_lign - 1; | 			base += sc->os_lign - 1; | ||||||
| 			base -= base % outsect[sectindex].os_lign; | 			base -= base % sc->os_lign; | ||||||
| 		} | 		} | ||||||
| 		outsect[sectindex].os_base = base; | 		sc->os_base = base; | ||||||
| 		base += outsect[sectindex].os_size; | 		base += sc->os_size; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -211,6 +211,7 @@ direct_alloc(head) | ||||||
| 	struct outhead	*head; | 	struct outhead	*head; | ||||||
| { | { | ||||||
| 	ind_t		sectindex = IND_SECT(*head); | 	ind_t		sectindex = IND_SECT(*head); | ||||||
|  | 	register struct outsect *sects; | ||||||
| 	ushort		nsect = head->oh_nsect; | 	ushort		nsect = head->oh_nsect; | ||||||
| 	long		size, rest; | 	long		size, rest; | ||||||
| 	extern ind_t	hard_alloc(); | 	extern ind_t	hard_alloc(); | ||||||
|  | @ -228,7 +229,14 @@ direct_alloc(head) | ||||||
| 	size = modulsize(head) - sizeof(struct outhead) - rest; | 	size = modulsize(head) - sizeof(struct outhead) - rest; | ||||||
| 	if (hard_alloc(ALLOMODL, size) == BADOFF) | 	if (hard_alloc(ALLOMODL, size) == BADOFF) | ||||||
| 		fatal("no space for module"); | 		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; | 	return incore && alloc(ALLOMODL, rest) != BADOFF; | ||||||
| } | } | ||||||
|  | @ -415,7 +423,7 @@ static | ||||||
| read_modul() | read_modul() | ||||||
| { | { | ||||||
| 	struct outhead	*head; | 	struct outhead	*head; | ||||||
| 	struct outsect	*sects; | 	register struct outsect	*sects; | ||||||
| 	struct outname	*names; | 	struct outname	*names; | ||||||
| 	char		*chars; | 	char		*chars; | ||||||
| 	ind_t		sectindex, nameindex, charindex; | 	ind_t		sectindex, nameindex, charindex; | ||||||
|  | @ -446,6 +454,13 @@ read_modul() | ||||||
| 	chars = modulptr(charindex); | 	chars = modulptr(charindex); | ||||||
| 
 | 
 | ||||||
| 	rd_sect(sects, nsect); | 	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_name(names, nname); | ||||||
| 	rd_string(chars, nchar); | 	rd_string(chars, nchar); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue