Make RGBLINK able to link SDCC object files

This requires a LOT of tricky code, mostly due to the format itself being,
er, not the most straightforward.
Everything is converted to existing RGBLINK concepts (sections, patches,
etc.), so the core code is essentially unchanged.
(A couple of genuine RGBLINK bugs were uncovered along the way, so some of
the core code *is* changed, notably regarding `SECTION FRAGMENT`s.)

All of this code was clean-roomed, so SDCC's GPLv2 license does not apply.
This commit is contained in:
ISSOtm
2022-07-10 10:50:33 +02:00
committed by Eldred Habert
parent 1c2965467d
commit 828b2adcdf
16 changed files with 922 additions and 71 deletions

View File

@@ -11,11 +11,13 @@
#define RGBDS_LINK_SCRIPT_H
#include <stdint.h>
#include "linkdefs.h"
extern FILE * linkerScript;
struct SectionPlacement {
struct Section *section;
enum SectionType type;
uint16_t org;
uint32_t bank;
};

19
include/link/sdas_obj.h Normal file
View File

@@ -0,0 +1,19 @@
/*
* This file is part of RGBDS.
*
* Copyright (c) 2022, Eldred Habert and RGBDS contributors.
*
* SPDX-License-Identifier: MIT
*/
/* Assigning all sections a place */
#ifndef RGBDS_LINK_SDAS_OBJ_H
#define RGBDS_LINK_SDAS_OBJ_H
#include <stdio.h>
struct FileStackNode;
void sdobj_ReadFile(struct FileStackNode const *fileName, FILE *file);
#endif /* RGBDS_LINK_SDAS_OBJ_H */

View File

@@ -48,6 +48,8 @@ struct Section {
enum SectionType type;
enum SectionModifier modifier;
bool isAddressFixed;
// This `struct`'s address in ROM.
// Importantly for fragments, this does not include `offset`!
uint16_t org;
bool isBankFixed;
uint32_t bank;
@@ -60,7 +62,7 @@ struct Section {
/* Extra info computed during linking */
struct Symbol **fileSymbols;
uint32_t nbSymbols;
struct Symbol const **symbols;
struct Symbol **symbols;
struct Section *nextu; /* The next "component" of this unionized sect */
};

View File

@@ -27,6 +27,7 @@ struct Symbol {
int32_t lineNo;
int32_t sectionID;
union {
// Both types must be identical
int32_t offset;
int32_t value;
};