mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Merge branch 'export-all-2' of https://github.com/Sanqui/rgbds
This commit is contained in:
@@ -9,6 +9,7 @@ struct sOptions {
|
|||||||
SLONG fillchar;
|
SLONG fillchar;
|
||||||
bool verbose;
|
bool verbose;
|
||||||
bool haltnop;
|
bool haltnop;
|
||||||
|
bool exportall;
|
||||||
//-1 == random
|
//-1 == random
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ struct sSymbol {
|
|||||||
* not be changed during linking */
|
* not be changed during linking */
|
||||||
|
|
||||||
ULONG calchash(char *s);
|
ULONG calchash(char *s);
|
||||||
|
void sym_SetExportAll(BBOOL set);
|
||||||
void sym_PrepPass1(void);
|
void sym_PrepPass1(void);
|
||||||
void sym_PrepPass2(void);
|
void sym_PrepPass2(void);
|
||||||
void sym_AddLocalReloc(char *tzSym);
|
void sym_AddLocalReloc(char *tzSym);
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ static void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"Usage: rgbasm [-hv] [-b chars] [-Dname[=value]] [-g chars] [-i path]\n"
|
"Usage: rgbasm [-hvE] [-b chars] [-Dname[=value]] [-g chars] [-i path]\n"
|
||||||
" [-o outfile] [-p pad_value] file.asm\n");
|
" [-o outfile] [-p pad_value] file.asm\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -296,12 +296,13 @@ main(int argc, char *argv[])
|
|||||||
DefaultOptions.fillchar = 0;
|
DefaultOptions.fillchar = 0;
|
||||||
DefaultOptions.verbose = false;
|
DefaultOptions.verbose = false;
|
||||||
DefaultOptions.haltnop = true;
|
DefaultOptions.haltnop = true;
|
||||||
|
DefaultOptions.exportall = false;
|
||||||
|
|
||||||
opt_SetCurrentOptions(&DefaultOptions);
|
opt_SetCurrentOptions(&DefaultOptions);
|
||||||
|
|
||||||
newopt = CurrentOptions;
|
newopt = CurrentOptions;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "b:D:g:hi:o:p:v")) != -1) {
|
while ((ch = getopt(argc, argv, "b:D:g:hi:o:p:vE")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'b':
|
case 'b':
|
||||||
if (strlen(optarg) == 2) {
|
if (strlen(optarg) == 2) {
|
||||||
@@ -348,6 +349,9 @@ main(int argc, char *argv[])
|
|||||||
case 'v':
|
case 'v':
|
||||||
newopt.verbose = true;
|
newopt.verbose = true;
|
||||||
break;
|
break;
|
||||||
|
case 'E':
|
||||||
|
newopt.exportall = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@@ -379,6 +383,7 @@ main(int argc, char *argv[])
|
|||||||
nPass = 1;
|
nPass = 1;
|
||||||
nErrors = 0;
|
nErrors = 0;
|
||||||
sym_PrepPass1();
|
sym_PrepPass1();
|
||||||
|
sym_SetExportAll(CurrentOptions.exportall);
|
||||||
fstk_Init(tzMainfile);
|
fstk_Init(tzMainfile);
|
||||||
opt_ParseDefines();
|
opt_ParseDefines();
|
||||||
|
|
||||||
|
|||||||
@@ -243,9 +243,15 @@ writesymbol(struct sSymbol * pSym, FILE * f)
|
|||||||
offset = 0;
|
offset = 0;
|
||||||
sectid = -1;
|
sectid = -1;
|
||||||
type = SYM_IMPORT;
|
type = SYM_IMPORT;
|
||||||
} else if (pSym->nType & SYMF_EXPORT) {
|
} else {
|
||||||
/* Symbol should be exported */
|
if (pSym->nType & SYMF_LOCAL) {
|
||||||
|
strcpy(symname, pSym->pScope->tzName);
|
||||||
|
strcat(symname, pSym->tzName);
|
||||||
|
} else
|
||||||
strcpy(symname, pSym->tzName);
|
strcpy(symname, pSym->tzName);
|
||||||
|
|
||||||
|
if (pSym->nType & SYMF_EXPORT) {
|
||||||
|
/* Symbol should be exported */
|
||||||
type = SYM_EXPORT;
|
type = SYM_EXPORT;
|
||||||
offset = pSym->nValue;
|
offset = pSym->nValue;
|
||||||
if (pSym->nType & SYMF_CONST)
|
if (pSym->nType & SYMF_CONST)
|
||||||
@@ -254,15 +260,11 @@ writesymbol(struct sSymbol * pSym, FILE * f)
|
|||||||
sectid = getsectid(pSym->pSection);
|
sectid = getsectid(pSym->pSection);
|
||||||
} else {
|
} else {
|
||||||
/* Symbol is local to this file */
|
/* Symbol is local to this file */
|
||||||
if (pSym->nType & SYMF_LOCAL) {
|
|
||||||
strcpy(symname, pSym->pScope->tzName);
|
|
||||||
strcat(symname, pSym->tzName);
|
|
||||||
} else
|
|
||||||
strcpy(symname, pSym->tzName);
|
|
||||||
type = SYM_LOCAL;
|
type = SYM_LOCAL;
|
||||||
offset = pSym->nValue;
|
offset = pSym->nValue;
|
||||||
sectid = getsectid(pSym->pSection);
|
sectid = getsectid(pSym->pSection);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fputstring(symname, f);
|
fputstring(symname, f);
|
||||||
fputc(type, f);
|
fputc(type, f);
|
||||||
@@ -283,6 +285,7 @@ addsymbol(struct sSymbol * pSym)
|
|||||||
static ULONG nextID = 0;
|
static ULONG nextID = 0;
|
||||||
ULONG hash;
|
ULONG hash;
|
||||||
|
|
||||||
|
|
||||||
hash = calchash(pSym->tzName);
|
hash = calchash(pSym->tzName);
|
||||||
ppPSym = &(tHashedPatchSymbols[hash]);
|
ppPSym = &(tHashedPatchSymbols[hash]);
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ When padding an image, pad with this value.
|
|||||||
The default is 0x00.
|
The default is 0x00.
|
||||||
.It Fl v
|
.It Fl v
|
||||||
Be verbose.
|
Be verbose.
|
||||||
|
.It Fl E
|
||||||
|
Export all relocable symbols by default.
|
||||||
.El
|
.El
|
||||||
.Sh EXAMPLES
|
.Sh EXAMPLES
|
||||||
Assembling a basic source file is simple:
|
Assembling a basic source file is simple:
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ char *currentmacroargs[MAXMACROARGS + 1];
|
|||||||
char *newmacroargs[MAXMACROARGS + 1];
|
char *newmacroargs[MAXMACROARGS + 1];
|
||||||
char SavedTIME[256];
|
char SavedTIME[256];
|
||||||
char SavedDATE[256];
|
char SavedDATE[256];
|
||||||
|
bool exportall;
|
||||||
|
|
||||||
SLONG
|
SLONG
|
||||||
Callback_NARG(struct sSymbol * sym)
|
Callback_NARG(struct sSymbol * sym)
|
||||||
@@ -575,6 +576,9 @@ sym_AddLocalReloc(char *tzSym)
|
|||||||
nsym->nValue = nPC;
|
nsym->nValue = nPC;
|
||||||
nsym->nType |=
|
nsym->nType |=
|
||||||
SYMF_RELOC | SYMF_LOCAL | SYMF_DEFINED;
|
SYMF_RELOC | SYMF_LOCAL | SYMF_DEFINED;
|
||||||
|
if (exportall) {
|
||||||
|
nsym->nType |= SYMF_EXPORT;
|
||||||
|
}
|
||||||
nsym->pScope = pScope;
|
nsym->pScope = pScope;
|
||||||
nsym->pSection = pCurrentSection;
|
nsym->pSection = pCurrentSection;
|
||||||
}
|
}
|
||||||
@@ -604,6 +608,9 @@ sym_AddReloc(char *tzSym)
|
|||||||
if (nsym) {
|
if (nsym) {
|
||||||
nsym->nValue = nPC;
|
nsym->nValue = nPC;
|
||||||
nsym->nType |= SYMF_RELOC | SYMF_DEFINED;
|
nsym->nType |= SYMF_RELOC | SYMF_DEFINED;
|
||||||
|
if (exportall) {
|
||||||
|
nsym->nType |= SYMF_EXPORT;
|
||||||
|
}
|
||||||
nsym->pScope = NULL;
|
nsym->pScope = NULL;
|
||||||
nsym->pSection = pCurrentSection;
|
nsym->pSection = pCurrentSection;
|
||||||
}
|
}
|
||||||
@@ -709,6 +716,13 @@ sym_AddMacro(char *tzSym)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set whether to export all relocable symbols by default
|
||||||
|
*/
|
||||||
|
void sym_SetExportAll(BBOOL set) {
|
||||||
|
exportall = set;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare for pass #1
|
* Prepare for pass #1
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user