Cool, this was not my mistake, patch TCC again.
Admin, please look what's happened with build server, GCC needs a missing library? git-svn-id: svn://kolibrios.org@8157 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
ffcd3a73e0
commit
c369f06816
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
CC = kos32-gcc
|
CC = kos32-gcc
|
||||||
LD = kos32-ld
|
LD = kos32-ld
|
||||||
|
|
||||||
SDK_DIR:= $(abspath ../../../contrib/sdk)
|
SDK_DIR:= $(abspath ../../../../../contrib/sdk)
|
||||||
|
|
||||||
#gcc 4.8
|
#gcc 4.8
|
||||||
#LDFLAGS = -static -nostdlib -T $(SDK_DIR)/sources/newlib/static.lds
|
#LDFLAGS = -static -nostdlib -T $(SDK_DIR)/sources/newlib/static.lds
|
||||||
|
@ -1890,7 +1890,7 @@ static char *copy_linker_arg(const char *p)
|
|||||||
|
|
||||||
/* set linker options */
|
/* set linker options */
|
||||||
static int tcc_set_linker(TCCState *s, const char *option)
|
static int tcc_set_linker(TCCState *s, const char *option)
|
||||||
{
|
{
|
||||||
while (option && *option) {
|
while (option && *option) {
|
||||||
|
|
||||||
const char *p = option;
|
const char *p = option;
|
||||||
@ -2038,7 +2038,8 @@ enum {
|
|||||||
TCC_OPTION_MD,
|
TCC_OPTION_MD,
|
||||||
TCC_OPTION_MF,
|
TCC_OPTION_MF,
|
||||||
TCC_OPTION_x,
|
TCC_OPTION_x,
|
||||||
TCC_OPTION_stack
|
TCC_OPTION_stack,
|
||||||
|
TCC_OPTION_nobss
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TCC_OPTION_HAS_ARG 0x0001
|
#define TCC_OPTION_HAS_ARG 0x0001
|
||||||
@ -2100,6 +2101,7 @@ static const TCCOption tcc_options[] = {
|
|||||||
{ "MF", TCC_OPTION_MF, TCC_OPTION_HAS_ARG },
|
{ "MF", TCC_OPTION_MF, TCC_OPTION_HAS_ARG },
|
||||||
{ "x", TCC_OPTION_x, TCC_OPTION_HAS_ARG },
|
{ "x", TCC_OPTION_x, TCC_OPTION_HAS_ARG },
|
||||||
{ "stack", TCC_OPTION_stack, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP},
|
{ "stack", TCC_OPTION_stack, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP},
|
||||||
|
{ "nobss", TCC_OPTION_nobss, 0 },
|
||||||
{ NULL, 0, 0 },
|
{ NULL, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2428,9 +2430,12 @@ ST_FUNC int tcc_parse_args1(TCCState *s, int argc, char **argv)
|
|||||||
/* ignored */
|
/* ignored */
|
||||||
break;
|
break;
|
||||||
case TCC_OPTION_stack:
|
case TCC_OPTION_stack:
|
||||||
#ifdef TCC_TARGET_MEOS
|
#ifdef TCC_TARGET_MEOS
|
||||||
s->pe_stack_size = strtoul(optarg+1, NULL, 10);
|
s->pe_stack_size = strtoul(optarg+1, NULL, 10);
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
|
case TCC_OPTION_nobss:
|
||||||
|
s->nobss = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (s->warn_unsupported) {
|
if (s->warn_unsupported) {
|
||||||
|
@ -128,6 +128,8 @@ static void help(void)
|
|||||||
" -Bdir use 'dir' as tcc internal library and include path\n"
|
" -Bdir use 'dir' as tcc internal library and include path\n"
|
||||||
" -MD generate target dependencies for make\n"
|
" -MD generate target dependencies for make\n"
|
||||||
" -MF depfile put generated dependencies here\n"
|
" -MF depfile put generated dependencies here\n"
|
||||||
|
"For KolibriOS only:\n"
|
||||||
|
" -nobss do not emit BSS section into file\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,6 +871,7 @@ struct TCCState {
|
|||||||
int do_bench; /* option -bench */
|
int do_bench; /* option -bench */
|
||||||
int gen_deps; /* option -MD */
|
int gen_deps; /* option -MD */
|
||||||
char *deps_outfile; /* option -MF */
|
char *deps_outfile; /* option -MF */
|
||||||
|
int nobss; /* option -nobss, omit BSS section (KolibriOS-only) */
|
||||||
ParseArgsState *parse_args_state;
|
ParseArgsState *parse_args_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -180,11 +180,11 @@ void assign_addresses(me_info* me)
|
|||||||
{
|
{
|
||||||
si->sh_addr=addr;
|
si->sh_addr=addr;
|
||||||
addr+=si->data_size;
|
addr+=si->data_size;
|
||||||
}
|
}
|
||||||
if (me->s1->pe_stack_size < 4096)
|
if (me->s1->pe_stack_size < 4096)
|
||||||
addr+=4096;
|
addr+=4096;
|
||||||
else
|
else
|
||||||
addr += me->s1->pe_stack_size;
|
addr += me->s1->pe_stack_size;
|
||||||
addr=(addr+4)&(~3);
|
addr=(addr+4)&(~3);
|
||||||
me->header.stack=addr;
|
me->header.stack=addr;
|
||||||
me->header.memory_size=addr;
|
me->header.memory_size=addr;
|
||||||
@ -272,21 +272,24 @@ int tcc_output_me(TCCState* s1,const char *filename)
|
|||||||
for(si=me.code_sections;si;si=si->next)
|
for(si=me.code_sections;si;si=si->next)
|
||||||
fwrite(si->data,1,si->data_size,f);
|
fwrite(si->data,1,si->data_size,f);
|
||||||
for (si=me.data_sections;si;si=si->next)
|
for (si=me.data_sections;si;si=si->next)
|
||||||
fwrite(si->data,1,si->data_size,f);
|
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);
|
if (si->data == NULL)
|
||||||
si->data = calloc(si->data_size, 1);
|
{
|
||||||
}
|
// printf("\nError! BSS data is NULL! size:%i",(int)si->data_size);
|
||||||
fwrite(si->data, 1, si->data_size, f);
|
si->data = calloc(si->data_size, 1);
|
||||||
}
|
}
|
||||||
/*
|
fwrite(si->data, 1, si->data_size, f);
|
||||||
if (me.bss_sections) // Siemargl testin, what we lose
|
}
|
||||||
{
|
}
|
||||||
|
/*
|
||||||
|
if (me.bss_sections) // Siemargl testin, what we lose
|
||||||
|
{
|
||||||
tcc_error_noabort("We lose .BSS section when linking KOS32 executable");
|
tcc_error_noabort("We lose .BSS section when linking KOS32 executable");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
@ -314,73 +317,73 @@ char *getcwd(char *buf, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static FILE *src_file;
|
static FILE *src_file;
|
||||||
static int next_src_line;
|
static int next_src_line;
|
||||||
|
|
||||||
void close_source_file()
|
void close_source_file()
|
||||||
{
|
{
|
||||||
if (src_file)
|
if (src_file)
|
||||||
fclose(src_file);
|
fclose(src_file);
|
||||||
src_file = NULL;
|
src_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_source_file(char *fname)
|
void load_source_file(char *fname)
|
||||||
{
|
{
|
||||||
close_source_file();
|
close_source_file();
|
||||||
src_file = fopen(fname,"rt");
|
src_file = fopen(fname,"rt");
|
||||||
if (!src_file) return;
|
if (!src_file) return;
|
||||||
next_src_line = 1;
|
next_src_line = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_src_lines(char *buf, int sz, int start, int end)
|
int get_src_lines(char *buf, int sz, int start, int end)
|
||||||
// 1 if read
|
// 1 if read
|
||||||
{
|
{
|
||||||
char line[255], *ch;
|
char line[255], *ch;
|
||||||
strcpy(buf, "");
|
strcpy(buf, "");
|
||||||
if (!src_file) return 0;
|
if (!src_file) return 0;
|
||||||
while (next_src_line < start) // skip
|
while (next_src_line < start) // skip
|
||||||
{
|
{
|
||||||
ch = fgets(line, sizeof line, src_file);
|
ch = fgets(line, sizeof line, src_file);
|
||||||
if (!ch) return 0;
|
if (!ch) return 0;
|
||||||
next_src_line++;
|
next_src_line++;
|
||||||
}
|
}
|
||||||
while (next_src_line <= end)
|
while (next_src_line <= end)
|
||||||
{
|
{
|
||||||
ch = fgets(line, sizeof line, src_file);
|
ch = fgets(line, sizeof line, src_file);
|
||||||
if (!ch) return 0;
|
if (!ch) return 0;
|
||||||
next_src_line++;
|
next_src_line++;
|
||||||
strncat(buf, line, sz - strlen(buf) - 1);
|
strncat(buf, line, sz - strlen(buf) - 1);
|
||||||
}
|
}
|
||||||
// remove newlines
|
// remove newlines
|
||||||
for (ch = buf; *ch; ch++)
|
for (ch = buf; *ch; ch++)
|
||||||
if (strchr("\t\n\r", *ch)) *ch = ' ';
|
if (strchr("\t\n\r", *ch)) *ch = ' ';
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tcc_output_dbgme(const char *filename, me_info* me)
|
int tcc_output_dbgme(const char *filename, me_info* me)
|
||||||
// by Siemargl. Writes filename.dbg file for source code level debuggin with MTDBG
|
// by Siemargl. Writes filename.dbg file for source code level debuggin with MTDBG
|
||||||
// return 1 on error
|
// return 1 on error
|
||||||
{
|
{
|
||||||
FILE *fdbg;
|
FILE *fdbg;
|
||||||
char fname[400],
|
char fname[400],
|
||||||
buf[80]; // no more fits in mtdbg string
|
buf[80]; // no more fits in mtdbg string
|
||||||
|
|
||||||
strcpy(fname, filename);
|
strcpy(fname, filename);
|
||||||
strcat(fname, ".dbg");
|
strcat(fname, ".dbg");
|
||||||
fdbg = fopen(fname,"wt");
|
fdbg = fopen(fname,"wt");
|
||||||
if (!fdbg) return 1;
|
if (!fdbg) return 1;
|
||||||
|
|
||||||
meos_section_info *si, *ss;
|
meos_section_info *si, *ss;
|
||||||
fputs(".text\n", fdbg); // just for mtbg
|
fputs(".text\n", fdbg); // just for mtbg
|
||||||
|
|
||||||
// print symbol table with resolved addresses
|
// print symbol table with resolved addresses
|
||||||
Elf32_Sym* esym;
|
Elf32_Sym* esym;
|
||||||
for (esym = (Elf32_Sym*)symtab_section->data; esym <= (Elf32_Sym*)(symtab_section->data + symtab_section->data_offset); esym++)
|
for (esym = (Elf32_Sym*)symtab_section->data; esym <= (Elf32_Sym*)(symtab_section->data + symtab_section->data_offset); esym++)
|
||||||
{
|
{
|
||||||
if (esym->st_info == 0 || esym->st_info == 4) continue;
|
if (esym->st_info == 0 || esym->st_info == 4) continue;
|
||||||
int sect = esym->st_shndx;
|
int sect = esym->st_shndx;
|
||||||
ss = findsection(me, sect);
|
ss = findsection(me, sect);
|
||||||
const char *sym_name = strtab_section->data + esym->st_name;
|
const char *sym_name = strtab_section->data + esym->st_name;
|
||||||
@ -390,82 +393,82 @@ int tcc_output_dbgme(const char *filename, me_info* me)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fprintf(fdbg, "0x%X %s\n", ss->sh_addr + esym->st_value, sym_name); // removed type(%d) esym->st_info
|
fprintf(fdbg, "0x%X %s\n", ss->sh_addr + esym->st_value, sym_name); // removed type(%d) esym->st_info
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs(".text source code links\n", fdbg); // just for mtbg
|
fputs(".text source code links\n", fdbg); // just for mtbg
|
||||||
// print symbol table with resolved addresses
|
// print symbol table with resolved addresses
|
||||||
Stab_Sym *stab;
|
Stab_Sym *stab;
|
||||||
char *str = "", *cur_file = "???", cur_fun[255];
|
char *str = "", *cur_file = "???", cur_fun[255];
|
||||||
int cur_line = 0, cur_fun_addr = 0, fun_flag = 0;
|
int cur_line = 0, cur_fun_addr = 0, fun_flag = 0;
|
||||||
strcpy(cur_fun, "fn???");
|
strcpy(cur_fun, "fn???");
|
||||||
for (stab = (Stab_Sym*)stab_section->data; stab <= (Stab_Sym*)(stab_section->data + stab_section->data_offset); stab++)
|
for (stab = (Stab_Sym*)stab_section->data; stab <= (Stab_Sym*)(stab_section->data + stab_section->data_offset); stab++)
|
||||||
{
|
{
|
||||||
str = "";
|
str = "";
|
||||||
switch(stab->n_type)
|
switch(stab->n_type)
|
||||||
{
|
{
|
||||||
case 100: // source file, or path
|
case 100: // source file, or path
|
||||||
if (stab->n_strx)
|
if (stab->n_strx)
|
||||||
{
|
{
|
||||||
cur_file = stabstr_section->data + stab->n_strx;
|
cur_file = stabstr_section->data + stab->n_strx;
|
||||||
load_source_file(cur_file);
|
load_source_file(cur_file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cur_file = "???";
|
cur_file = "???";
|
||||||
strcpy(cur_fun, "fn???");
|
strcpy(cur_fun, "fn???");
|
||||||
cur_line = 0;
|
cur_line = 0;
|
||||||
cur_fun_addr = 0;
|
cur_fun_addr = 0;
|
||||||
fun_flag = 0;
|
fun_flag = 0;
|
||||||
break;
|
break;
|
||||||
case 36: // func
|
case 36: // func
|
||||||
cur_fun_addr = 0;
|
cur_fun_addr = 0;
|
||||||
if (stab->n_strx)
|
if (stab->n_strx)
|
||||||
{
|
{
|
||||||
strcpy(cur_fun, stabstr_section->data + stab->n_strx);
|
strcpy(cur_fun, stabstr_section->data + stab->n_strx);
|
||||||
str = strchr(cur_fun, ':');
|
str = strchr(cur_fun, ':');
|
||||||
if (str) *str = '\0';
|
if (str) *str = '\0';
|
||||||
cur_fun_addr = tcc_find_symbol_me(me, cur_fun);
|
cur_fun_addr = tcc_find_symbol_me(me, cur_fun);
|
||||||
cur_line = stab->n_desc;
|
cur_line = stab->n_desc;
|
||||||
fun_flag = 1;
|
fun_flag = 1;
|
||||||
//fprintf(fdbg, "0x%X %s() line(%d)\n", cur_fun_addr, cur_fun, cur_line); // commented as conflicted with direct address
|
//fprintf(fdbg, "0x%X %s() line(%d)\n", cur_fun_addr, cur_fun, cur_line); // commented as conflicted with direct address
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strcpy(cur_fun, "fn???");
|
strcpy(cur_fun, "fn???");
|
||||||
break;
|
break;
|
||||||
case 68: // N_SLINE
|
case 68: // N_SLINE
|
||||||
if (stab->n_value == 0 ) continue; // skip zero offset line
|
if (stab->n_value == 0 ) continue; // skip zero offset line
|
||||||
if (fun_flag) // skip string {, as duplicates address
|
if (fun_flag) // skip string {, as duplicates address
|
||||||
{
|
{
|
||||||
fun_flag = 0;
|
fun_flag = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int line;
|
int line;
|
||||||
if (stab->n_desc > cur_line)
|
if (stab->n_desc > cur_line)
|
||||||
line = cur_line + 1;
|
line = cur_line + 1;
|
||||||
else
|
else
|
||||||
line = cur_line;
|
line = cur_line;
|
||||||
//fprintf(fdbg, "0x%X LINES %d-%d \n", cur_fun_addr + stab->n_value, line, stab->n_desc);
|
//fprintf(fdbg, "0x%X LINES %d-%d \n", cur_fun_addr + stab->n_value, line, stab->n_desc);
|
||||||
if (get_src_lines(buf, sizeof buf, line, stab->n_desc))
|
if (get_src_lines(buf, sizeof buf, line, stab->n_desc))
|
||||||
fprintf(fdbg, "0x%X %s\n", cur_fun_addr + stab->n_value, buf);
|
fprintf(fdbg, "0x%X %s\n", cur_fun_addr + stab->n_value, buf);
|
||||||
|
|
||||||
cur_line = stab->n_desc;
|
cur_line = stab->n_desc;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if (stab->n_strx)
|
if (stab->n_strx)
|
||||||
str = stabstr_section->data + stab->n_strx;
|
str = stabstr_section->data + stab->n_strx;
|
||||||
fprintf(fdbg, "0x%X type(%d) str(%s) desc(%d)\n", stab->n_value, stab->n_type, str, stab->n_desc);
|
fprintf(fdbg, "0x%X type(%d) str(%s) desc(%d)\n", stab->n_value, stab->n_type, str, stab->n_desc);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for(; si; si = si->next)
|
/* for(; si; si = si->next)
|
||||||
{
|
{
|
||||||
Section *sr;
|
Section *sr;
|
||||||
Elf32_Rel *rel, *rel_end;
|
Elf32_Rel *rel, *rel_end;
|
||||||
for(sr = me->s1->sections[si->sec_num]->reloc; sr; )
|
for(sr = me->s1->sections[si->sec_num]->reloc; sr; )
|
||||||
{
|
{
|
||||||
for (rel = (Elf32_Rel *) sr->data, rel_end = (Elf32_Rel *) (sr->data + sr->data_offset); rel < rel_end; rel++)
|
for (rel = (Elf32_Rel *) sr->data, rel_end = (Elf32_Rel *) (sr->data + sr->data_offset); rel < rel_end; rel++)
|
||||||
{
|
{
|
||||||
int type = ELF32_R_TYPE(rel->r_info);
|
int type = ELF32_R_TYPE(rel->r_info);
|
||||||
@ -487,8 +490,8 @@ int tcc_output_dbgme(const char *filename, me_info* me)
|
|||||||
fprintf(fdbg, "\t0x%X %s\n", ss->sh_addr + esym->st_value, sym_name);
|
fprintf(fdbg, "\t0x%X %s\n", ss->sh_addr + esym->st_value, sym_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
close_source_file();
|
close_source_file();
|
||||||
fclose(fdbg);
|
fclose(fdbg);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user