| @@ -363,7 +363,7 @@ struct pe_info { · 362 unmodified lines |
| 363 | static const char *pe_export_name(TCCState *s1, ElfW(Sym) *sym) | 363 | static const char *pe_export_name(TCCState *s1, ElfW(Sym) *sym) |
| 364 | { | 364 | { |
| 365 | const char *name = symtab_section->link->data + sym->st_name; | 365 | const char *name = symtab_section->link->data + sym->st_name; |
| 366 | if (s1->leading_underscore && name[0] == '_' && !(sym->st_other & 2)) | 366 | if (s1->leading_underscore && name[0] == '_' && !(sym->st_other & ST_PE_STDCALL)) |
| 367 | return name + 1; | 367 | return name + 1; |
| 368 | return name; | 368 | return name; |
| 369 | } | 369 | } |
| @@ -378,7 +378,7 @@ static int pe_find_import(TCCState * s1, ElfW(Sym) *sym) · 8 unmodified lines |
| 378 | s = pe_export_name(s1, sym); | 378 | s = pe_export_name(s1, sym); |
| 379 | if (n) { | 379 | if (n) { |
| 380 | /* second try: */ | 380 | /* second try: */ |
| 381 | if (sym->st_other & 2) { | 381 | if (sym->st_other & ST_PE_STDCALL) { |
| 382 | /* try w/0 stdcall deco (windows API convention) */ | 382 | /* try w/0 stdcall deco (windows API convention) */ |
| 383 | p = strrchr(s, '@'); | 383 | p = strrchr(s, '@'); |
| 384 | if (!p || s[0] != '_') | 384 | if (!p || s[0] != '_') |
| @@ -899,7 +899,7 @@ static void pe_build_exports(struct pe_info *pe) · 514 unmodified lines |
| 899 | for (sym_index = 1; sym_index < sym_end; ++sym_index) { | 899 | for (sym_index = 1; sym_index < sym_end; ++sym_index) { |
| 900 | sym = (ElfW(Sym)*)symtab_section->data + sym_index; | 900 | sym = (ElfW(Sym)*)symtab_section->data + sym_index; |
| 901 | name = pe_export_name(pe->s1, sym); | 901 | name = pe_export_name(pe->s1, sym); |
| 902 | if ((sym->st_other & 1) | 902 | if ((sym->st_other & ST_PE_EXPORT) |
| 903 | /* export only symbols from actually written sections */ | 903 | /* export only symbols from actually written sections */ |
| 904 | && pe->s1->sections[sym->st_shndx]->sh_addr) { | 904 | && pe->s1->sections[sym->st_shndx]->sh_addr) { |
| 905 | p = tcc_malloc(sizeof *p); | 905 | p = tcc_malloc(sizeof *p); |
| @@ -908,9 +908,9 @@ static void pe_build_exports(struct pe_info *pe) · 2 unmodified lines |
| 908 | dynarray_add((void***)&sorted, &sym_count, p); | 908 | dynarray_add((void***)&sorted, &sym_count, p); |
| 909 | } | 909 | } |
| 910 | #if 0 | 910 | #if 0 |
| 911 | if (sym->st_other & 1) | 911 | if (sym->st_other & ST_PE_EXPORT) |
| 912 | printf("export: %s\n", name); | 912 | printf("export: %s\n", name); |
| 913 | if (sym->st_other & 2) | 913 | if (sym->st_other & ST_PE_STDCALL) |
| 914 | printf("stdcall: %s\n", name); | 914 | printf("stdcall: %s\n", name); |
| 915 | #endif | 915 | #endif |
| 916 | } | 916 | } |
| @@ -1282,7 +1282,7 @@ static int pe_check_symbols(struct pe_info *pe) · 365 unmodified lines |
| 1282 | /* patch the original symbol */ | 1282 | /* patch the original symbol */ |
| 1283 | sym->st_value = offset; | 1283 | sym->st_value = offset; |
| 1284 | sym->st_shndx = text_section->sh_num; | 1284 | sym->st_shndx = text_section->sh_num; |
| 1285 | sym->st_other &= ~1; /* do not export */ | 1285 | sym->st_other &= ~ST_PE_EXPORT; /* do not export */ |
| 1286 | continue; | 1286 | continue; |
| 1287 | } | 1287 | } |
| 1288 | | 1288 | |
| @@ -1301,7 +1301,7 @@ static int pe_check_symbols(struct pe_info *pe) · 12 unmodified lines |
| 1301 | } else if (pe->s1->rdynamic | 1301 | } else if (pe->s1->rdynamic |
| 1302 | && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) { | 1302 | && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) { |
| 1303 | /* if -rdynamic option, then export all non local symbols */ | 1303 | /* if -rdynamic option, then export all non local symbols */ |
| 1304 | sym->st_other |= 1; | 1304 | sym->st_other |= ST_PE_EXPORT; |
| 1305 | } | 1305 | } |
| 1306 | } | 1306 | } |
| 1307 | return ret; | 1307 | return ret; |
| @@ -1463,7 +1463,7 @@ ST_FUNC SValue *pe_getimport(SValue *sv, SValue *v2) · 155 unmodified lines |
| 1463 | if (!sym->c) | 1463 | if (!sym->c) |
| 1464 | put_extern_sym(sym, NULL, 0, 0); | 1464 | put_extern_sym(sym, NULL, 0, 0); |
| 1465 | esym = &((ElfW(Sym) *)symtab_section->data)[sym->c]; | 1465 | esym = &((ElfW(Sym) *)symtab_section->data)[sym->c]; |
| 1466 | if (!(esym->st_other & 4)) | 1466 | if (!(esym->st_other & ST_PE_IMPORT)) |
| 1467 | return sv; | 1467 | return sv; |
| 1468 | | 1468 | |
| 1469 | // printf("import %04x %04x %04x %s\n", sv->type.t, sym->type.t, sv->r, get_tok_str(sv->sym->v, NULL)); | 1469 | // printf("import %04x %04x %04x %s\n", sv->type.t, sym->type.t, sv->r, get_tok_str(sv->sym->v, NULL)); |