diff --git a/include/link/main.h b/include/link/main.h index 3f1e32f3..d3975251 100644 --- a/include/link/main.h +++ b/include/link/main.h @@ -7,11 +7,4 @@ extern void usage(void); extern SLONG fillchar; extern char smartlinkstartsymbol[256]; -enum eOutputType { - OUTPUT_GBROM, - OUTPUT_PSION2 -}; - -extern enum eOutputType outputtype; - #endif diff --git a/src/link/assign.c b/src/link/assign.c index f53254e0..5abe7753 100644 --- a/src/link/assign.c +++ b/src/link/assign.c @@ -170,7 +170,7 @@ AssignCodeSections(void) } void -GBROM_AssignSections(void) +AssignSections(void) { SLONG i; struct sSection *pSection; @@ -442,61 +442,6 @@ GBROM_AssignSections(void) AssignCodeSections(); } -void -PSION2_AssignSections(void) -{ - struct sSection *pSection; - - BankFree[0] = malloc(sizeof *BankFree[0]); - if (!BankFree[0]) - errx(5, "Out of memory!"); - - BankFree[0]->nOrg = 0x0000; - BankFree[0]->nSize = 0x10000; - MaxAvail[0] = 0x10000; - BankFree[0]->pPrev = NULL; - BankFree[0]->pNext = NULL; - - pSection = pSections; - while (pSection) { - if (pSection->oAssigned == 0 - && pSection->Type == SECT_CODE) { - pSection->oAssigned = 1; - pSection->nBank = 0; - pSection->nOrg = BankFree[0]->nOrg; - BankFree[0]->nOrg += pSection->nByteSize; - BankFree[0]->nSize -= pSection->nByteSize; - } - pSection = pSection->pNext; - } - - pSection = pSections; - while (pSection) { - if (pSection->oAssigned == 0 - && pSection->Type == SECT_BSS) { - pSection->oAssigned = 1; - pSection->nBank = 0; - pSection->nOrg = BankFree[0]->nOrg; - BankFree[0]->nOrg += pSection->nByteSize; - BankFree[0]->nSize -= pSection->nByteSize; - } - pSection = pSection->pNext; - } -} - -void -AssignSections(void) -{ - switch (outputtype) { - case OUTPUT_GBROM: - GBROM_AssignSections(); - break; - case OUTPUT_PSION2: - PSION2_AssignSections(); - break; - } -} - void CreateSymbolTable(void) { diff --git a/src/link/main.c b/src/link/main.c index b98f2c9c..37036695 100644 --- a/src/link/main.c +++ b/src/link/main.c @@ -30,7 +30,6 @@ enum eBlockType { SLONG options = 0; SLONG fillchar = 0; -enum eOutputType outputtype = OUTPUT_GBROM; char smartlinkstartsymbol[256]; /* @@ -44,7 +43,7 @@ usage(void) printf("xLink v" LINK_VERSION " (part of ASMotor " ASMOTOR_VERSION ")\n\n"); printf("usage: xlink [-l library] [-m mapfile] [-n symfile] [-o outfile] [-s symbol]\n"); - printf("\t [-t [g | s | p]] [-z pad_value] objectfile [...]\n"); + printf("\t [-t [g | s ] [-z pad_value] objectfile [...]\n"); exit(EX_USAGE); } @@ -141,15 +140,10 @@ main(int argc, char *argv[]) break; case 't': switch (optarg[0]) { - case 'g': - outputtype = OUTPUT_GBROM; - break; case 's': - outputtype = OUTPUT_GBROM; options |= OPT_SMALL; - break; - case 'p': - outputtype = OUTPUT_PSION2; + /* FALLTHROUGH */ + case 'g': break; default: errx(EX_USAGE, "Invalid argument to option t"); diff --git a/src/link/output.c b/src/link/output.c index 5eabed35..cac431e5 100644 --- a/src/link/output.c +++ b/src/link/output.c @@ -80,7 +80,7 @@ out_Setname(char *tzOutputfile) } void -GBROM_Output(void) +Output(void) { SLONG i; FILE *f; @@ -105,101 +105,3 @@ GBROM_Output(void) MapfileCloseBank(area_Avail(i)); } } - -void -PSION2_Output(void) -{ - FILE *f; - - if ((f = fopen(tzOutname, "wb"))) { - struct sSection *pSect; - UBYTE *mem; - ULONG size = MaxAvail[0] - area_Avail(0); - ULONG relocpatches; - - fputc(size >> 24, f); - fputc(size >> 16, f); - fputc(size >> 8, f); - fputc(size, f); - - if ((mem = malloc(MaxAvail[0] - area_Avail(0)))) { - MapfileInitBank(0); - - pSect = pSections; - while (pSect) { - if (pSect->Type == SECT_CODE) { - memcpy(mem + pSect->nOrg, pSect->pData, - pSect->nByteSize); - MapfileWriteSection(pSect); - } else { - memset(mem + pSect->nOrg, 0, - pSect->nByteSize); - } - pSect = pSect->pNext; - } - - MapfileCloseBank(area_Avail(0)); - - fwrite(mem, 1, MaxAvail[0] - area_Avail(0), f); - free(mem); - } - relocpatches = 0; - pSect = pSections; - while (pSect) { - struct sPatch *pPatch; - - pPatch = pSect->pPatches; - - while (pPatch) { - if (pPatch->oRelocPatch) { - relocpatches += 1; - } - pPatch = pPatch->pNext; - } - pSect = pSect->pNext; - } - - fputc(relocpatches >> 24, f); - fputc(relocpatches >> 16, f); - fputc(relocpatches >> 8, f); - fputc(relocpatches, f); - - pSect = pSections; - while (pSect) { - struct sPatch *pPatch; - - pPatch = pSect->pPatches; - - while (pPatch) { - if (pPatch->oRelocPatch) { - ULONG address; - - address = pPatch->nOffset + pSect->nOrg; - fputc(address >> 24, f); - fputc(address >> 16, f); - fputc(address >> 8, f); - fputc(address, f); - } - pPatch = pPatch->pNext; - } - pSect = pSect->pNext; - } - - fclose(f); - } -} - -void -Output(void) -{ - if (oOutput) { - switch (outputtype) { - case OUTPUT_GBROM: - GBROM_Output(); - break; - case OUTPUT_PSION2: - PSION2_Output(); - break; - } - } -}