History

added -f[no-]leading-underscore - '@' symbol for asm

bellard committed 21 years ago

Commit f6db2ed1 parent 0c7f0ed1 file · +22 −3Browse files

Unified · Split

tcc.c+22−3
@@ -460,7 +460,8 @@ struct TCCState { · 459 unmodified lines
460460
461461 /* C language options */
462462 int char_is_unsigned;
463−
463+ int leading_underscore;
464+
464465 /* warning switches */
465466 int warn_write_strings;
466467 int warn_unsupported;
@@ -1216,12 +1217,14 @@ Section *find_section(TCCState *s1, const char *name) · 749 unmodified lines
12161217
12171218 /* update sym->c so that it points to an external symbol in section
12181219 'section' with value 'value' */
1219−static void put_extern_sym(Sym *sym, Section *section,
1220− unsigned long value, unsigned long size)
1220+static void put_extern_sym2(Sym *sym, Section *section,
1221+ unsigned long value, unsigned long size,
1222+ int can_add_underscore)
12211223 {
12221224 int sym_type, sym_bind, sh_num, info;
12231225 Elf32_Sym *esym;
12241226 const char *name;
1227+ char buf1[256];
12251228
12261229 if (section == NULL)
12271230 sh_num = SHN_UNDEF;
@@ -1268,6 +1271,11 @@ static void put_extern_sym(Sym *sym, Section *section, · 40 unmodified lines
12681271 }
12691272 }
12701273 #endif
1274+ if (tcc_state->leading_underscore && can_add_underscore) {
1275+ buf1[0] = '_';
1276+ pstrcpy(buf1 + 1, sizeof(buf1) - 1, name);
1277+ name = buf1;
1278+ }
12711279 info = ELF32_ST_INFO(sym_bind, sym_type);
12721280 sym->c = add_elf_sym(symtab_section, value, size, info, 0, sh_num, name);
12731281 } else {
@@ -1278,6 +1286,12 @@ static void put_extern_sym(Sym *sym, Section *section, · 4 unmodified lines
12781286 }
12791287 }
12801288
1289+static void put_extern_sym(Sym *sym, Section *section,
1290+ unsigned long value, unsigned long size)
1291+{
1292+ put_extern_sym2(sym, section, value, size, 1);
1293+}
1294+
12811295 /* add a new relocation entry to symbol 'sym' in section 's' */
12821296 static void greloc(Section *s, Sym *sym, unsigned long offset, int type)
12831297 {
@@ -3854,6 +3868,7 @@ static inline void next_nomacro1(void) · 2570 unmodified lines
38543868 case '?':
38553869 case '~':
38563870 case '$': /* only used in assembler */
3871+ case '@': /* dito */
38573872 tok = c;
38583873 p++;
38593874 break;
@@ -9731,6 +9746,9 @@ TCCState *tcc_new(void) · 5871 unmodified lines
97319746
97329747 #ifdef CHAR_IS_UNSIGNED
97339748 s->char_is_unsigned = 1;
9749+#endif
9750+#ifdef TCC_TARGET_PE
9751+ s->leading_underscore = 1;
97349752 #endif
97359753 return s;
97369754 }
@@ -10109,6 +10127,7 @@ static const FlagDef flag_defs[] = { · 372 unmodified lines
1010910127 { offsetof(TCCState, char_is_unsigned), 0, "unsigned-char" },
1011010128 { offsetof(TCCState, char_is_unsigned), FD_INVERT, "signed-char" },
1011110129 { offsetof(TCCState, nocommon), FD_INVERT, "common" },
10130+ { offsetof(TCCState, leading_underscore), 0, "leading-underscore" },
1011210131 };
1011310132
1011410133 /* set/reset a flag */

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