TCC: Add -nobss option to not include BSS sections in output file.

git-svn-id: svn://kolibrios.org@8154 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Magomed Kostoev (mkostoevr) 2020-11-06 20:02:56 +00:00
parent 9c0ca4f346
commit 0fe740bca1
6 changed files with 162 additions and 151 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
CC = kos32-gcc
LD = kos32-ld
SDK_DIR:= $(abspath ../../../contrib/sdk)
SDK_DIR:= $(abspath ../../../../../contrib/sdk)
#gcc 4.8
#LDFLAGS = -static -nostdlib -T $(SDK_DIR)/sources/newlib/static.lds

View File

@ -2038,7 +2038,8 @@ enum {
TCC_OPTION_MD,
TCC_OPTION_MF,
TCC_OPTION_x,
TCC_OPTION_stack
TCC_OPTION_stack,
TCC_OPTION_nobss
};
#define TCC_OPTION_HAS_ARG 0x0001
@ -2100,6 +2101,7 @@ static const TCCOption tcc_options[] = {
{ "MF", TCC_OPTION_MF, TCC_OPTION_HAS_ARG },
{ "x", TCC_OPTION_x, TCC_OPTION_HAS_ARG },
{ "stack", TCC_OPTION_stack, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP},
{ "nobss", TCC_OPTION_nobss, 0 },
{ NULL, 0, 0 },
};
@ -2432,6 +2434,9 @@ ST_FUNC int tcc_parse_args1(TCCState *s, int argc, char **argv)
s->pe_stack_size = strtoul(optarg+1, NULL, 10);
#endif
break;
case TCC_OPTION_nobss:
s->nobss = 1;
break;
default:
if (s->warn_unsupported) {
unsupported_option:

View File

@ -128,6 +128,8 @@ static void help(void)
" -Bdir use 'dir' as tcc internal library and include path\n"
" -MD generate target dependencies for make\n"
" -MF depfile put generated dependencies here\n"
"For KolibriOS only:\n"
" -nobss do not emit BSS section into file\n"
);
}

View File

@ -871,6 +871,7 @@ struct TCCState {
int do_bench; /* option -bench */
int gen_deps; /* option -MD */
char *deps_outfile; /* option -MF */
int nobss; /* option -nobss, omit BSS section (KolibriOS-only) */
ParseArgsState *parse_args_state;
};

View File

@ -273,14 +273,17 @@ int tcc_output_me(TCCState* s1,const char *filename)
fwrite(si->data,1,si->data_size,f);
for (si=me.data_sections;si;si=si->next)
fwrite(si->data,1,si->data_size,f);
for (si=me.bss_sections;si;si=si->next)
if (!s1->nobss)
{
if (si->data == NULL)
for (si=me.bss_sections;si;si=si->next)
{
// printf("\nError! BSS data is NULL! size:%i",(int)si->data_size);
si->data = calloc(si->data_size, 1);
}
fwrite(si->data, 1, si->data_size, f);
if (si->data == NULL)
{
// printf("\nError! BSS data is NULL! size:%i",(int)si->data_size);
si->data = calloc(si->data_size, 1);
}
fwrite(si->data, 1, si->data_size, f);
}
}
/*
if (me.bss_sections) // Siemargl testin, what we lose