improved the alilgnment checking somewhat
This commit is contained in:
parent
4d67ee1150
commit
77bcd64f03
1 changed files with 35 additions and 18 deletions
|
@ -53,6 +53,22 @@ char hdr[HDRSIZE];
|
||||||
|
|
||||||
FILE *output;
|
FILE *output;
|
||||||
|
|
||||||
|
long align(a,b)
|
||||||
|
long a,b;
|
||||||
|
{
|
||||||
|
a += b - 1;
|
||||||
|
return a - a % b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
follows(pa, pb)
|
||||||
|
register struct outsect *pa, *pb;
|
||||||
|
{
|
||||||
|
/* return 1 if pa follows pb */
|
||||||
|
|
||||||
|
return pa->os_base == align(pb->os_base+pb->os_size, pa->os_lign);
|
||||||
|
}
|
||||||
|
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
|
@ -98,45 +114,46 @@ main(argc, argv)
|
||||||
outsect[TEXTSG].os_base) ;
|
outsect[TEXTSG].os_base) ;
|
||||||
if ( outsect[BSSSG].os_flen != 0 )
|
if ( outsect[BSSSG].os_flen != 0 )
|
||||||
fatal("bss space contains initialized data\n") ;
|
fatal("bss space contains initialized data\n") ;
|
||||||
if ( outsect[BSSSG].os_base != outsect[DATASG].os_base+
|
if (! follows(&outsect[BSSSG], &outsect[DATASG]))
|
||||||
outsect[DATASG].os_size )
|
|
||||||
fatal("bss segment must follow data segment\n") ;
|
fatal("bss segment must follow data segment\n") ;
|
||||||
if ( outsect[ROMSG].os_lign == 0x8000 ) {
|
if ( outsect[ROMSG].os_lign == 0x8000 ) {
|
||||||
/* 410 file with ROMSG in data space */
|
/* 410 file with ROMSG in data space */
|
||||||
rom_in_data = 1;
|
rom_in_data = 1;
|
||||||
magic= 0410 ;
|
magic= 0410 ;
|
||||||
textsize= outsect[TEXTSG].os_size ;
|
if (! follows(&outsect[DATASG], &outsect[ROMSG]))
|
||||||
datasize= outsect[ROMSG].os_size + outsect[DATASG].os_size ;
|
|
||||||
if ( outsect[DATASG].os_base != outsect[ROMSG].os_base+
|
|
||||||
outsect[ROMSG].os_size )
|
|
||||||
fatal("data segment must follow rom\n") ;
|
fatal("data segment must follow rom\n") ;
|
||||||
|
textsize= outsect[TEXTSG].os_size ;
|
||||||
|
outsect[ROMSG].os_size = outsect[DATASG].os_base - outsect[ROMSG].os_base;
|
||||||
|
outsect[DATASG].os_size = outsect[BSSSG].os_base - outsect[DATASG].os_base;
|
||||||
|
datasize= outsect[ROMSG].os_size + outsect[DATASG].os_size ;
|
||||||
} else
|
} else
|
||||||
if ( outsect[DATASG].os_lign == 0x8000 ) {
|
if ( outsect[DATASG].os_lign == 0x8000 ) {
|
||||||
/* 410 file with ROMSG in instruction space */
|
/* 410 file with ROMSG in instruction space */
|
||||||
rom_in_data = 0;
|
rom_in_data = 0;
|
||||||
magic= 0410 ;
|
magic= 0410 ;
|
||||||
textsize= outsect[TEXTSG].os_size + outsect[ROMSG].os_size ;
|
if (! follows(&outsect[ROMSG], &outsect[TEXTSG]))
|
||||||
datasize= outsect[DATASG].os_size ;
|
|
||||||
if ( outsect[ROMSG].os_base != outsect[TEXTSG].os_base+
|
|
||||||
outsect[TEXTSG].os_size )
|
|
||||||
fatal("rom segment must follow text\n") ;
|
fatal("rom segment must follow text\n") ;
|
||||||
|
outsect[TEXTSG].os_size = outsect[ROMSG].os_base - outsect[TEXTSG].os_base;
|
||||||
|
textsize= outsect[TEXTSG].os_size + outsect[ROMSG].os_size ;
|
||||||
|
outsect[DATASG].os_size = outsect[BSSSG].os_base - outsect[DATASG].os_base;
|
||||||
|
datasize= outsect[DATASG].os_size ;
|
||||||
} else {
|
} else {
|
||||||
/* Plain 407 file */
|
/* Plain 407 file */
|
||||||
rom_in_data = 1;
|
rom_in_data = 1;
|
||||||
magic= 0407 ;
|
magic= 0407 ;
|
||||||
|
if (! follows(&outsect[ROMSG], &outsect[TEXTSG]))
|
||||||
|
fatal("rom segment must follow text\n") ;
|
||||||
|
if (! follows(&outsect[DATASG], &outsect[ROMSG]))
|
||||||
|
fatal("data segment must follow rom\n") ;
|
||||||
|
outsect[TEXTSG].os_size = outsect[ROMSG].os_base - outsect[TEXTSG].os_base;
|
||||||
|
outsect[ROMSG].os_size = outsect[DATASG].os_base - outsect[ROMSG].os_base;
|
||||||
|
outsect[DATASG].os_size = outsect[BSSSG].os_base - outsect[DATASG].os_base;
|
||||||
textsize= outsect[TEXTSG].os_size ;
|
textsize= outsect[TEXTSG].os_size ;
|
||||||
datasize= outsect[ROMSG].os_size + outsect[DATASG].os_size ;
|
datasize= outsect[ROMSG].os_size + outsect[DATASG].os_size ;
|
||||||
if ( outsect[ROMSG].os_base != outsect[TEXTSG].os_base+
|
|
||||||
outsect[TEXTSG].os_size )
|
|
||||||
fatal("rom segment must follow text\n") ;
|
|
||||||
if ( outsect[DATASG].os_base != outsect[ROMSG].os_base+
|
|
||||||
outsect[ROMSG].os_size )
|
|
||||||
fatal("data segment must follow rom\n") ;
|
|
||||||
}
|
}
|
||||||
bsssize = outsect[BSSSG].os_size;
|
bsssize = outsect[BSSSG].os_size;
|
||||||
if ( outhead.oh_nsect==NSECT ) {
|
if ( outhead.oh_nsect==NSECT ) {
|
||||||
if ( outsect[LSECT].os_base != outsect[BSSSG].os_base+
|
if (! follows(&outsect[LSECT], &outsect[BSSSG]))
|
||||||
outsect[BSSSG].os_size )
|
|
||||||
fatal("end segment must follow bss\n") ;
|
fatal("end segment must follow bss\n") ;
|
||||||
if ( outsect[LSECT].os_size != 0 )
|
if ( outsect[LSECT].os_size != 0 )
|
||||||
fatal("end segment must be empty\n") ;
|
fatal("end segment must be empty\n") ;
|
||||||
|
|
Loading…
Reference in a new issue