1616#include "asm/warning.h"
1717
1818#include "error.h"
19+ #include "linkdefs.h"
1920#include "platform.h" // strdup
2021
2122uint8_t fillByte ;
@@ -73,7 +74,7 @@ attr_(warn_unused_result) static bool checkcodesection(void)
7374
7475attr_ (warn_unused_result ) static bool checkSectionSize (struct Section const * sect , uint32_t size )
7576{
76- uint32_t maxSize = maxsize [sect -> type ];
77+ uint32_t maxSize = sectionTypeInfo [sect -> type ]. size ;
7778
7879 // If the new size is reasonable, keep going
7980 if (size <= maxSize )
@@ -232,7 +233,7 @@ static void mergeSections(struct Section *sect, enum SectionType type, uint32_t
232233 unsigned int nbSectErrors = 0 ;
233234
234235 if (type != sect -> type )
235- fail ("Section already exists but with type %s\n" , typeNames [sect -> type ]);
236+ fail ("Section already exists but with type %s\n" , sectionTypeInfo [sect -> type ]. name );
236237
237238 if (sect -> modifier != mod ) {
238239 fail ("Section already declared as %s section\n" , sectionModNames [sect -> modifier ]);
@@ -299,7 +300,7 @@ static struct Section *createSection(char const *name, enum SectionType type,
299300
300301 /* It is only needed to allocate memory for ROM sections. */
301302 if (sect_HasData (type )) {
302- sect -> data = malloc (maxsize [type ]);
303+ sect -> data = malloc (sectionTypeInfo [type ]. size );
303304 if (sect -> data == NULL )
304305 fatalerror ("Not enough memory for section: %s\n" , strerror (errno ));
305306 } else {
@@ -325,14 +326,13 @@ static struct Section *getSection(char const *name, enum SectionType type, uint3
325326 if (type != SECTTYPE_ROMX && type != SECTTYPE_VRAM
326327 && type != SECTTYPE_SRAM && type != SECTTYPE_WRAMX )
327328 error ("BANK only allowed for ROMX, WRAMX, SRAM, or VRAM sections\n" );
328- else if (bank < bankranges [type ][0 ]
329- || bank > bankranges [type ][1 ])
329+ else if (bank < sectionTypeInfo [type ].firstBank || bank > sectionTypeInfo [type ].lastBank )
330330 error ("%s bank value $%04" PRIx32 " out of range ($%04" PRIx32 " to $%04"
331- PRIx32 ")\n" , typeNames [type ], bank ,
332- bankranges [type ][ 0 ], bankranges [type ][ 1 ] );
331+ PRIx32 ")\n" , sectionTypeInfo [type ]. name , bank ,
332+ sectionTypeInfo [type ]. firstBank , sectionTypeInfo [type ]. lastBank );
333333 } else if (nbbanks (type ) == 1 ) {
334334 // If the section type only has a single bank, implicitly force it
335- bank = bankranges [type ][ 0 ] ;
335+ bank = sectionTypeInfo [type ]. firstBank ;
336336 }
337337
338338 if (alignOffset >= 1 << alignment ) {
@@ -342,10 +342,10 @@ static struct Section *getSection(char const *name, enum SectionType type, uint3
342342 }
343343
344344 if (org != (uint32_t )-1 ) {
345- if (org < startaddr [type ] || org > endaddr (type ))
345+ if (org < sectionTypeInfo [type ]. startAddr || org > endaddr (type ))
346346 error ("Section \"%s\"'s fixed address %#" PRIx32
347347 " is outside of range [%#" PRIx16 "; %#" PRIx16 "]\n" ,
348- name , org , startaddr [type ], endaddr (type ));
348+ name , org , sectionTypeInfo [type ]. startAddr , endaddr (type ));
349349 }
350350
351351 if (alignment != 0 ) {
@@ -361,9 +361,9 @@ static struct Section *getSection(char const *name, enum SectionType type, uint3
361361 error ("Section \"%s\"'s fixed address doesn't match its alignment\n" ,
362362 name );
363363 alignment = 0 ; /* Ignore it if it's satisfied */
364- } else if (startaddr [type ] & mask ) {
364+ } else if (sectionTypeInfo [type ]. startAddr & mask ) {
365365 error ("Section \"%s\"'s alignment cannot be attained in %s\n" ,
366- name , typeNames [type ]);
366+ name , sectionTypeInfo [type ]. name );
367367 alignment = 0 ; /* Ignore it if it's unattainable */
368368 org = 0 ;
369369 } else if (alignment == 16 ) {
0 commit comments