@@ -316,39 +316,31 @@ static void readSection(FILE *file, struct Section *section, char const *fileNam
316
316
int32_t tmp ;
317
317
uint8_t byte ;
318
318
319
- tryReadstr (section -> name , file , "%s: Cannot read section name: %s" ,
320
- fileName );
321
- tryReadlong (tmp , file , "%s: Cannot read \"%s\"'s' size: %s" ,
322
- fileName , section -> name );
319
+ tryReadstr (section -> name , file , "%s: Cannot read section name: %s" , fileName );
320
+ tryReadlong (tmp , file , "%s: Cannot read \"%s\"'s' size: %s" , fileName , section -> name );
323
321
if (tmp < 0 || tmp > UINT16_MAX )
324
- errx (1 , "\"%s\"'s section size (%" PRId32 ") is invalid" ,
325
- section -> name , tmp );
322
+ errx (1 , "\"%s\"'s section size (%" PRId32 ") is invalid" , section -> name , tmp );
326
323
section -> size = tmp ;
327
324
section -> offset = 0 ;
328
- tryGetc (byte , file , "%s: Cannot read \"%s\"'s type: %s" ,
329
- fileName , section -> name );
325
+ tryGetc (byte , file , "%s: Cannot read \"%s\"'s type: %s" , fileName , section -> name );
330
326
section -> type = byte & 0x3F ;
331
327
if (byte >> 7 )
332
328
section -> modifier = SECTION_UNION ;
333
329
else if (byte >> 6 )
334
330
section -> modifier = SECTION_FRAGMENT ;
335
331
else
336
332
section -> modifier = SECTION_NORMAL ;
337
- tryReadlong (tmp , file , "%s: Cannot read \"%s\"'s org: %s" ,
338
- fileName , section -> name );
333
+ tryReadlong (tmp , file , "%s: Cannot read \"%s\"'s org: %s" , fileName , section -> name );
339
334
section -> isAddressFixed = tmp >= 0 ;
340
335
if (tmp > UINT16_MAX ) {
341
- error (NULL , 0 , "\"%s\"'s org is too large (%" PRId32 ")" ,
342
- section -> name , tmp );
336
+ error (NULL , 0 , "\"%s\"'s org is too large (%" PRId32 ")" , section -> name , tmp );
343
337
tmp = UINT16_MAX ;
344
338
}
345
339
section -> org = tmp ;
346
- tryReadlong (tmp , file , "%s: Cannot read \"%s\"'s bank: %s" ,
347
- fileName , section -> name );
340
+ tryReadlong (tmp , file , "%s: Cannot read \"%s\"'s bank: %s" , fileName , section -> name );
348
341
section -> isBankFixed = tmp >= 0 ;
349
342
section -> bank = tmp ;
350
- tryGetc (byte , file , "%s: Cannot read \"%s\"'s alignment: %s" ,
351
- fileName , section -> name );
343
+ tryGetc (byte , file , "%s: Cannot read \"%s\"'s alignment: %s" , fileName , section -> name );
352
344
if (byte > 16 )
353
345
byte = 16 ;
354
346
section -> isAlignFixed = byte != 0 ;
@@ -367,35 +359,32 @@ static void readSection(FILE *file, struct Section *section, char const *fileNam
367
359
uint8_t * data = malloc (sizeof (* data ) * section -> size + 1 );
368
360
369
361
if (!data )
370
- err (1 , "%s: Unable to read \"%s\"'s data" , fileName ,
371
- section -> name );
362
+ err (1 , "%s: Unable to read \"%s\"'s data" , fileName , section -> name );
372
363
if (section -> size ) {
373
- size_t nbElementsRead = fread (data , sizeof (* data ),
374
- section -> size , file );
364
+ size_t nbElementsRead = fread (data , sizeof (* data ), section -> size , file );
375
365
if (nbElementsRead != section -> size )
376
366
errx (1 , "%s: Cannot read \"%s\"'s data: %s" ,
377
367
fileName , section -> name ,
378
- feof (file ) ? "Unexpected end of file"
379
- : strerror (errno ));
368
+ feof (file ) ? "Unexpected end of file" : strerror (errno ));
380
369
}
381
370
section -> data = data ;
382
371
383
372
tryReadlong (section -> nbPatches , file ,
384
373
"%s: Cannot read \"%s\"'s number of patches: %s" ,
385
374
fileName , section -> name );
386
375
387
- struct Patch * patches =
388
- malloc (sizeof (* patches ) * section -> nbPatches + 1 );
376
+ struct Patch * patches = malloc (sizeof (* patches ) * section -> nbPatches + 1 );
389
377
390
378
if (!patches )
391
- err (1 , "%s: Unable to read \"%s\"'s patches" , fileName ,
392
- section -> name );
379
+ err (1 , "%s: Unable to read \"%s\"'s patches" , fileName , section -> name );
393
380
for (uint32_t i = 0 ; i < section -> nbPatches ; i ++ ) {
394
381
readPatch (file , & patches [i ], fileName , section -> name ,
395
382
i , fileSections , fileNodes );
396
383
}
397
384
section -> patches = patches ;
398
385
}
386
+
387
+ section -> smartLinked = false;
399
388
}
400
389
401
390
/**
@@ -614,6 +603,11 @@ void obj_DoSanityChecks(void)
614
603
sect_DoSanityChecks ();
615
604
}
616
605
606
+ struct Assertion const * obj_GetFirstAssertion (void )
607
+ {
608
+ return assertions ;
609
+ }
610
+
617
611
void obj_CheckAssertions (void )
618
612
{
619
613
patch_CheckAssertions (assertions );
@@ -628,27 +622,6 @@ void obj_Setup(unsigned int nbFiles)
628
622
nodes = malloc (sizeof (* nodes ) * nbFiles );
629
623
}
630
624
631
- static void freeSection (struct Section * section , void * arg )
632
- {
633
- (void )arg ;
634
-
635
- free (section -> name );
636
- if (sect_HasData (section -> type )) {
637
- free (section -> data );
638
- for (int32_t i = 0 ; i < section -> nbPatches ; i ++ )
639
- free (section -> patches [i ].rpnExpression );
640
- free (section -> patches );
641
- }
642
- free (section -> symbols );
643
- free (section );
644
- }
645
-
646
- static void freeSymbol (struct Symbol * symbol )
647
- {
648
- free (symbol -> name );
649
- free (symbol );
650
- }
651
-
652
625
void obj_Cleanup (void )
653
626
{
654
627
for (unsigned int i = 0 ; i < nbObjFiles ; i ++ ) {
@@ -660,16 +633,11 @@ void obj_Cleanup(void)
660
633
}
661
634
free (nodes );
662
635
663
- sym_CleanupSymbols ();
664
-
665
- sect_ForEach (freeSection , NULL );
666
- sect_CleanupSections ();
667
-
668
636
struct SymbolList * list = symbolLists ;
669
637
670
638
while (list ) {
671
639
for (size_t i = 0 ; i < list -> nbSymbols ; i ++ )
672
- freeSymbol (list -> symbolList [i ]);
640
+ sym_FreeSymbol (list -> symbolList [i ]);
673
641
free (list -> symbolList );
674
642
675
643
struct SymbolList * next = list -> next ;
0 commit comments