added -rdynamic support
This commit is contained in:
8
tcc.c
8
tcc.c
@ -398,6 +398,9 @@ struct TCCState {
|
|||||||
/* if true, static linking is performed */
|
/* if true, static linking is performed */
|
||||||
int static_link;
|
int static_link;
|
||||||
|
|
||||||
|
/* if true, all symbols are exported */
|
||||||
|
int rdynamic;
|
||||||
|
|
||||||
/* if true, only link in referenced objects from archive */
|
/* if true, only link in referenced objects from archive */
|
||||||
int alacarte_link;
|
int alacarte_link;
|
||||||
|
|
||||||
@ -9653,7 +9656,7 @@ static const TCCOption tcc_options[] = {
|
|||||||
{ "shared", TCC_OPTION_shared, 0 },
|
{ "shared", TCC_OPTION_shared, 0 },
|
||||||
{ "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },
|
{ "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },
|
||||||
{ "run", TCC_OPTION_run, 0 },
|
{ "run", TCC_OPTION_run, 0 },
|
||||||
{ "rdynamic", TCC_OPTION_rdynamic, 0 }, /* currently ignored */
|
{ "rdynamic", TCC_OPTION_rdynamic, 0 },
|
||||||
{ "r", TCC_OPTION_r, 0 },
|
{ "r", TCC_OPTION_r, 0 },
|
||||||
{ "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
{ "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
||||||
{ "O", TCC_OPTION_O, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
{ "O", TCC_OPTION_O, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
||||||
@ -9838,6 +9841,9 @@ int main(int argc, char **argv)
|
|||||||
goto unsupported_option;
|
goto unsupported_option;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TCC_OPTION_rdynamic:
|
||||||
|
s->rdynamic = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (s->warn_unsupported) {
|
if (s->warn_unsupported) {
|
||||||
unsupported_option:
|
unsupported_option:
|
||||||
|
|||||||
14
tccelf.c
14
tccelf.c
@ -779,7 +779,7 @@ static void tcc_add_runtime(TCCState *s1)
|
|||||||
Section *s;
|
Section *s;
|
||||||
|
|
||||||
if (!s1->nostdlib) {
|
if (!s1->nostdlib) {
|
||||||
snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.o");
|
snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.a");
|
||||||
tcc_add_file(s1, buf);
|
tcc_add_file(s1, buf);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_TCC_BCHECK
|
#ifdef CONFIG_TCC_BCHECK
|
||||||
@ -967,7 +967,7 @@ int tcc_output_file(TCCState *s1, const char *filename)
|
|||||||
unsigned long offset;
|
unsigned long offset;
|
||||||
offset = bss_section->data_offset;
|
offset = bss_section->data_offset;
|
||||||
/* XXX: which alignment ? */
|
/* XXX: which alignment ? */
|
||||||
offset = (offset + 8 - 1) & -8;
|
offset = (offset + 16 - 1) & -16;
|
||||||
index = put_elf_sym(s1->dynsym, offset, esym->st_size,
|
index = put_elf_sym(s1->dynsym, offset, esym->st_size,
|
||||||
esym->st_info, 0,
|
esym->st_info, 0,
|
||||||
bss_section->sh_num, name);
|
bss_section->sh_num, name);
|
||||||
@ -986,6 +986,14 @@ int tcc_output_file(TCCState *s1, const char *filename)
|
|||||||
error_noabort("undefined symbol '%s'", name);
|
error_noabort("undefined symbol '%s'", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (s1->rdynamic &&
|
||||||
|
ELF32_ST_BIND(sym->st_info) != STB_LOCAL) {
|
||||||
|
/* if -rdynamic option, then export all non
|
||||||
|
local symbols */
|
||||||
|
name = symtab_section->link->data + sym->st_name;
|
||||||
|
put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
|
||||||
|
sym->st_info, 0,
|
||||||
|
sym->st_shndx, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1003,6 +1011,8 @@ int tcc_output_file(TCCState *s1, const char *filename)
|
|||||||
name = s1->dynsymtab_section->link->data + esym->st_name;
|
name = s1->dynsymtab_section->link->data + esym->st_name;
|
||||||
sym_index = find_elf_sym(symtab_section, name);
|
sym_index = find_elf_sym(symtab_section, name);
|
||||||
if (sym_index) {
|
if (sym_index) {
|
||||||
|
/* XXX: avoid adding a symbol if already
|
||||||
|
present because of -rdynamic ? */
|
||||||
sym = &((Elf32_Sym *)symtab_section->data)[sym_index];
|
sym = &((Elf32_Sym *)symtab_section->data)[sym_index];
|
||||||
put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
|
put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
|
||||||
sym->st_info, 0,
|
sym->st_info, 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user