From 0c7f0ed312d51afe2e1e2a736d41bcc257e15e38 Mon Sep 17 00:00:00 2001 From: bellard Date: Wed, 15 Jun 2005 22:32:10 +0000 Subject: [PATCH] added -f[no-]leading-underscore --- Changelog | 1 + tccasm.c | 2 +- tcccoff.c | 26 +++++++------------------- tccpe.c | 11 ++++------- 4 files changed, 13 insertions(+), 27 deletions(-) diff --git a/Changelog b/Changelog index 3c5c17ae..bd404725 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ version 0.9.23: - '#pragma pack' support (grischka) - '#include_next' support (Bernhard Fischer) - ignore '-pipe' option +- added -f[no-]leading-underscore version 0.9.22: diff --git a/tccasm.c b/tccasm.c index 864f9468..3339a628 100644 --- a/tccasm.c +++ b/tccasm.c @@ -298,7 +298,7 @@ static void asm_free_labels(TCCState *st) sec = SECTION_ABS; else sec = st->sections[s->r]; - put_extern_sym(s, sec, (long)s->next, 0); + put_extern_sym2(s, sec, (long)s->next, 0, 0); } /* remove label */ table_ident[s->v - TOK_IDENT]->sym_label = NULL; diff --git a/tcccoff.c b/tcccoff.c index 67397973..de7d87c9 100644 --- a/tcccoff.c +++ b/tcccoff.c @@ -507,8 +507,7 @@ int tcc_output_coff(TCCState *s1, FILE *f) AUXEF auxef; int i; Elf32_Sym *p; - char *name; - char _name[MAX_FUNCS]; + const char *name; int nstr; int n = 0; @@ -521,26 +520,15 @@ int tcc_output_coff(TCCState *s1, FILE *f) for (i = 0; i < nb_syms; i++) { - /* don't add underscores for Code Composer Version 2.xx */ - -#define ADD_UNDERSCORE 0 - - name = (char *) symtab_section->link->data + p->st_name; - -#if ADD_UNDERSCORE - _name[0] = '_'; - strcpy(_name + 1, name); -#else - strcpy(_name, name); -#endif + name = symtab_section->link->data + p->st_name; for (k = 0; k < 8; k++) csym._n._n_name[k] = 0; - if (strlen(_name) <= 8) { - strcpy(csym._n._n_name, _name); + if (strlen(name) <= 8) { + strcpy(csym._n._n_name, name); } else { - if (pCoff_str_table - Coff_str_table + strlen(_name) > + if (pCoff_str_table - Coff_str_table + strlen(name) > MAX_STR_TABLE - 1) error("String table too large"); @@ -548,8 +536,8 @@ int tcc_output_coff(TCCState *s1, FILE *f) csym._n._n_n._n_offset = pCoff_str_table - Coff_str_table + 4; - strcpy(pCoff_str_table, _name); - pCoff_str_table += strlen(_name) + 1; // skip over null + strcpy(pCoff_str_table, name); + pCoff_str_table += strlen(name) + 1; // skip over null nstr++; } diff --git a/tccpe.c b/tccpe.c index 5911296c..f1bd0f78 100644 --- a/tccpe.c +++ b/tccpe.c @@ -383,13 +383,10 @@ ST char pe_type; ST int pe_find_import(TCCState * s1, const char *symbol, char *ret) { int sym_index = find_elf_sym(s1->dynsymtab_section, symbol); - if (0 == sym_index) { - /* Hm, maybe it's '_symbol' instead of 'symbol' or '__imp__symbol' */ - char buffer[100]; - if (0 == memcmp(symbol, "__imp__", 7)) - symbol += 6; - else - buffer[0] = '_', strcpy(buffer + 1, symbol), symbol = buffer; + if (0 == sym_index && + !memcmp(symbol, "__imp__", 7)) { + /* Hm, maybe it's '_symbol' instead of '__imp__symbol' */ + symbol += 6; sym_index = find_elf_sym(s1->dynsymtab_section, symbol); } if (ret) -- 2.11.4.GIT