History

added __start_x and __stop_x symbol generation - fp_hw fix for dynamic executables

bellard committed 24 years ago

Commit 519ec301 parent 8264c251 file · +39 −7Browse files

Unified · Split

tcc.c+39−7
@@ -6962,6 +6962,8 @@ static void tcc_add_runtime(TCCState *s1) · 6961 unmodified lines
69626962 {
69636963 char buf[1024];
69646964 unsigned long *ptr;
6965+ int i;
6966+ Section *s;
69656967
69666968 snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.o");
69676969 tcc_add_file(s1, buf);
@@ -6999,6 +7001,38 @@ static void tcc_add_runtime(TCCState *s1) · 31 unmodified lines
69997001 bss_section->data_offset, 0,
70007002 ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE),
70017003 bss_section->sh_num, "_end");
7004+ /* add start and stop symbols for sections whose name can be
7005+ expressed in C */
7006+ for(i = 1; i < nb_sections; i++) {
7007+ s = sections[i];
7008+ if (s->sh_type == SHT_PROGBITS &&
7009+ (s->sh_flags & SHF_ALLOC)) {
7010+ const char *p;
7011+ int ch;
7012+
7013+ /* check if section name can be expressed in C */
7014+ p = s->name;
7015+ for(;;) {
7016+ ch = *p;
7017+ if (!ch)
7018+ break;
7019+ if (!isid(ch) && !isnum(ch))
7020+ goto next_sec;
7021+ p++;
7022+ }
7023+ snprintf(buf, sizeof(buf), "__start_%s", s->name);
7024+ add_elf_sym(symtab_section,
7025+ 0, 0,
7026+ ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE),
7027+ s->sh_num, buf);
7028+ snprintf(buf, sizeof(buf), "__stop_%s", s->name);
7029+ add_elf_sym(symtab_section,
7030+ s->data_offset, 0,
7031+ ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE),
7032+ s->sh_num, buf);
7033+ }
7034+ next_sec:
7035+ }
70027036 }
70037037
70047038 /* add dynamic sections so that the executable is dynamically linked */
@@ -7115,13 +7149,11 @@ int tcc_output_file(TCCState *s1, const char *filename) · 110 unmodified lines
71157149 bss_section->data_offset = offset;
71167150 }
71177151 } else {
7118− /* STT_NOTYPE or STB_WEAK undefined symbols
7119− are accepted */
7120− /* XXX: STT_NOTYPE is only used to exclude the
7121− unreferenced '_fp_hw' symbol. need a better
7122− solution */
7123− if (ELF32_ST_TYPE(sym->st_info) == STT_NOTYPE ||
7124− ELF32_ST_BIND(sym->st_info) == STB_WEAK) {
7152+ /* STB_WEAK undefined symbols are accepted */
7153+ /* XXX: _fp_hw seems to be part of the ABI, so we ignore
7154+ it */
7155+ if (ELF32_ST_BIND(sym->st_info) == STB_WEAK ||
7156+ !strcmp(name, "_fp_hw")) {
71257157 } else {
71267158 error("undefined symbol '%s'", name);
71277159 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t