aboutsummaryrefslogtreecommitdiff
path: root/tcc.c
diff options
context:
space:
mode:
authorbellard <bellard>2005-06-15 22:32:29 +0000
committerbellard <bellard>2005-06-15 22:32:29 +0000
commitf6db2edc40adc87779190fbc2e9bd58fbf81f835 (patch)
tree8e789b62b5603c3f54298e44169a992e437ebc4b /tcc.c
parent0c7f0ed312d51afe2e1e2a736d41bcc257e15e38 (diff)
downloadtinycc-f6db2edc40adc87779190fbc2e9bd58fbf81f835.tar.gz
tinycc-f6db2edc40adc87779190fbc2e9bd58fbf81f835.tar.bz2
added -f[no-]leading-underscore - '@' symbol for asm
Diffstat (limited to 'tcc.c')
-rw-r--r--tcc.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/tcc.c b/tcc.c
index 2a59808..a7b5a58 100644
--- a/tcc.c
+++ b/tcc.c
@@ -460,7 +460,8 @@ struct TCCState {
/* C language options */
int char_is_unsigned;
-
+ int leading_underscore;
+
/* warning switches */
int warn_write_strings;
int warn_unsupported;
@@ -1216,12 +1217,14 @@ Section *find_section(TCCState *s1, const char *name)
/* update sym->c so that it points to an external symbol in section
'section' with value 'value' */
-static void put_extern_sym(Sym *sym, Section *section,
- unsigned long value, unsigned long size)
+static void put_extern_sym2(Sym *sym, Section *section,
+ unsigned long value, unsigned long size,
+ int can_add_underscore)
{
int sym_type, sym_bind, sh_num, info;
Elf32_Sym *esym;
const char *name;
+ char buf1[256];
if (section == NULL)
sh_num = SHN_UNDEF;
@@ -1268,6 +1271,11 @@ static void put_extern_sym(Sym *sym, Section *section,
}
}
#endif
+ if (tcc_state->leading_underscore && can_add_underscore) {
+ buf1[0] = '_';
+ pstrcpy(buf1 + 1, sizeof(buf1) - 1, name);
+ name = buf1;
+ }
info = ELF32_ST_INFO(sym_bind, sym_type);
sym->c = add_elf_sym(symtab_section, value, size, info, 0, sh_num, name);
} else {
@@ -1278,6 +1286,12 @@ static void put_extern_sym(Sym *sym, Section *section,
}
}
+static void put_extern_sym(Sym *sym, Section *section,
+ unsigned long value, unsigned long size)
+{
+ put_extern_sym2(sym, section, value, size, 1);
+}
+
/* add a new relocation entry to symbol 'sym' in section 's' */
static void greloc(Section *s, Sym *sym, unsigned long offset, int type)
{
@@ -3854,6 +3868,7 @@ static inline void next_nomacro1(void)
case '?':
case '~':
case '$': /* only used in assembler */
+ case '@': /* dito */
tok = c;
p++;
break;
@@ -9732,6 +9747,9 @@ TCCState *tcc_new(void)
#ifdef CHAR_IS_UNSIGNED
s->char_is_unsigned = 1;
#endif
+#ifdef TCC_TARGET_PE
+ s->leading_underscore = 1;
+#endif
return s;
}
@@ -10109,6 +10127,7 @@ static const FlagDef flag_defs[] = {
{ offsetof(TCCState, char_is_unsigned), 0, "unsigned-char" },
{ offsetof(TCCState, char_is_unsigned), FD_INVERT, "signed-char" },
{ offsetof(TCCState, nocommon), FD_INVERT, "common" },
+ { offsetof(TCCState, leading_underscore), 0, "leading-underscore" },
};
/* set/reset a flag */