added __start_x and __stop_x symbol generation - fp_hw fix for dynamic executables
This commit is contained in:
46
tcc.c
46
tcc.c
@ -6962,6 +6962,8 @@ static void tcc_add_runtime(TCCState *s1)
|
|||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
unsigned long *ptr;
|
unsigned long *ptr;
|
||||||
|
int i;
|
||||||
|
Section *s;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.o");
|
snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.o");
|
||||||
tcc_add_file(s1, buf);
|
tcc_add_file(s1, buf);
|
||||||
@ -6999,6 +7001,38 @@ static void tcc_add_runtime(TCCState *s1)
|
|||||||
bss_section->data_offset, 0,
|
bss_section->data_offset, 0,
|
||||||
ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE),
|
ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE),
|
||||||
bss_section->sh_num, "_end");
|
bss_section->sh_num, "_end");
|
||||||
|
/* add start and stop symbols for sections whose name can be
|
||||||
|
expressed in C */
|
||||||
|
for(i = 1; i < nb_sections; i++) {
|
||||||
|
s = sections[i];
|
||||||
|
if (s->sh_type == SHT_PROGBITS &&
|
||||||
|
(s->sh_flags & SHF_ALLOC)) {
|
||||||
|
const char *p;
|
||||||
|
int ch;
|
||||||
|
|
||||||
|
/* check if section name can be expressed in C */
|
||||||
|
p = s->name;
|
||||||
|
for(;;) {
|
||||||
|
ch = *p;
|
||||||
|
if (!ch)
|
||||||
|
break;
|
||||||
|
if (!isid(ch) && !isnum(ch))
|
||||||
|
goto next_sec;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
snprintf(buf, sizeof(buf), "__start_%s", s->name);
|
||||||
|
add_elf_sym(symtab_section,
|
||||||
|
0, 0,
|
||||||
|
ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE),
|
||||||
|
s->sh_num, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "__stop_%s", s->name);
|
||||||
|
add_elf_sym(symtab_section,
|
||||||
|
s->data_offset, 0,
|
||||||
|
ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE),
|
||||||
|
s->sh_num, buf);
|
||||||
|
}
|
||||||
|
next_sec:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add dynamic sections so that the executable is dynamically linked */
|
/* add dynamic sections so that the executable is dynamically linked */
|
||||||
@ -7115,13 +7149,11 @@ int tcc_output_file(TCCState *s1, const char *filename)
|
|||||||
bss_section->data_offset = offset;
|
bss_section->data_offset = offset;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* STT_NOTYPE or STB_WEAK undefined symbols
|
/* STB_WEAK undefined symbols are accepted */
|
||||||
are accepted */
|
/* XXX: _fp_hw seems to be part of the ABI, so we ignore
|
||||||
/* XXX: STT_NOTYPE is only used to exclude the
|
it */
|
||||||
unreferenced '_fp_hw' symbol. need a better
|
if (ELF32_ST_BIND(sym->st_info) == STB_WEAK ||
|
||||||
solution */
|
!strcmp(name, "_fp_hw")) {
|
||||||
if (ELF32_ST_TYPE(sym->st_info) == STT_NOTYPE ||
|
|
||||||
ELF32_ST_BIND(sym->st_info) == STB_WEAK) {
|
|
||||||
} else {
|
} else {
|
||||||
error("undefined symbol '%s'", name);
|
error("undefined symbol '%s'", name);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user