- tccgen.c/tcc.h: allow function declaration after use: int f() { return g(); } int g() { return 1; } may be a warning but not an error see also 76cb1144ef91924c53c57ea71e6f67ce73ce1cc6 - tccgen.c: redundant code related to inline functions removed (functions used anywhere have sym->c set automatically) - tccgen.c: make 32bit llop non-equal test portable (probably not on C67) - dynarray_add: change prototype to possibly avoid aliasing problems or at least warnings - lib/alloca*.S: ".section .note.GNU-stack,"",%progbits" removed (has no effect) - tccpe: set SizeOfCode field (for correct upx decompression) - libtcc.c: fixed alternative -run invocation tcc "-run -lxxx ..." file.c (meant to load the library after file). Also supported now: tcc files ... options ... -run @ arguments ...
Unified · Split
| @@ -341,7 +341,7 @@ void stuff_const_harder(uint32_t op, uint32_t v) { · 340 unmodified lines | ||
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | −ST_FUNC uint32_t encbranch(int pos, int addr, int fail) | |
| 344 | +uint32_t encbranch(int pos, int addr, int fail) | |
| 345 | 345 | { |
| 346 | 346 | addr-=pos+8; |
| 347 | 347 | addr/=4; |
| @@ -70,9 +70,6 @@ enum { · 69 unmodified lines | ||
| 70 | 70 | /* maximum alignment (for aligned attribute support) */ |
| 71 | 71 | #define MAX_ALIGN 8 |
| 72 | 72 | |
| 73 | −/* generate jmp to a label */ | |
| 74 | −#define gjmp2(instr,lbl) oad(instr,lbl) | |
| 75 | − | |
| 76 | 73 | /******************************************************/ |
| 77 | 74 | #else /* ! TARGET_DEFS_ONLY */ |
| 78 | 75 | /******************************************************/ |
| @@ -148,7 +145,7 @@ ST_FUNC void gsym(int t) · 69 unmodified lines | ||
| 148 | 145 | } |
| 149 | 146 | |
| 150 | 147 | /* instruction + 4 bytes data. Return the address of the data */ |
| 151 | −ST_FUNC int oad(int c, int s) | |
| 148 | +static int oad(int c, int s) | |
| 152 | 149 | { |
| 153 | 150 | int t; |
| 154 | 151 | if (nocode_wanted) |
| @@ -159,6 +156,9 @@ ST_FUNC int oad(int c, int s) · 4 unmodified lines | ||
| 159 | 156 | return t; |
| 160 | 157 | } |
| 161 | 158 | |
| 159 | +/* generate jmp to a label */ | |
| 160 | +#define gjmp2(instr,lbl) oad(instr,lbl) | |
| 161 | + | |
| 162 | 162 | /* output constant with relocation if 'r & VT_SYM' is true */ |
| 163 | 163 | ST_FUNC void gen_addr32(int r, Sym *sym, long c) |
| 164 | 164 | { |
| @@ -8,4 +8,3 @@ alloca: · 7 unmodified lines | ||
| 8 | 8 | mov r0, sp |
| 9 | 9 | mov pc, lr |
| 10 | 10 | .size alloca, .-alloca |
| 11 | − .section .note.GNU-stack,"",%progbits | |
| @@ -28,8 +28,4 @@ p3: · 27 unmodified lines | ||
| 28 | 28 | push %edx |
| 29 | 29 | ret |
| 30 | 30 | |
| 31 | −/* mark stack as nonexecutable */ | |
| 32 | −#if defined __ELF__ && defined __linux__ | |
| 33 | − .section .note.GNU-stack,"",@progbits | |
| 34 | −#endif | |
| 35 | 31 | /* ---------------------------------------------- */ |
| @@ -53,8 +53,4 @@ p3: · 52 unmodified lines | ||
| 53 | 53 | ret |
| 54 | 54 | #endif |
| 55 | 55 | |
| 56 | −/* mark stack as nonexecutable */ | |
| 57 | −#if defined __ELF__ && defined __linux__ | |
| 58 | − .section .note.GNU-stack,"",@progbits | |
| 59 | −#endif | |
| 60 | 56 | /* ---------------------------------------------- */ |
| @@ -35,8 +35,4 @@ p3: · 34 unmodified lines | ||
| 35 | 35 | push %rdx |
| 36 | 36 | ret |
| 37 | 37 | |
| 38 | −/* mark stack as nonexecutable */ | |
| 39 | −#if defined __ELF__ && defined __linux__ | |
| 40 | − .section .note.GNU-stack,"",@progbits | |
| 41 | −#endif | |
| 42 | 38 | /* ---------------------------------------------- */ |
| @@ -403,13 +403,13 @@ PUB_FUNC void tcc_memstats(int bench) · 402 unmodified lines | ||
| 403 | 403 | /********************************************************/ |
| 404 | 404 | /* dynarrays */ |
| 405 | 405 | |
| 406 | −ST_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data) | |
| 406 | +ST_FUNC void dynarray_add(void *ptab, int *nb_ptr, void *data) | |
| 407 | 407 | { |
| 408 | 408 | int nb, nb_alloc; |
| 409 | 409 | void **pp; |
| 410 | 410 | |
| 411 | 411 | nb = *nb_ptr; |
| 412 | − pp = *ptab; | |
| 412 | + pp = *(void ***)ptab; | |
| 413 | 413 | /* every power of two we double array size */ |
| 414 | 414 | if ((nb & (nb - 1)) == 0) { |
| 415 | 415 | if (!nb) |
| @@ -417,7 +417,7 @@ ST_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data) · 1 unmodified line | ||
| 417 | 417 | else |
| 418 | 418 | nb_alloc = nb * 2; |
| 419 | 419 | pp = tcc_realloc(pp, nb_alloc * sizeof(void *)); |
| 420 | − *ptab = pp; | |
| 420 | + *(void***)ptab = pp; | |
| 421 | 421 | } |
| 422 | 422 | pp[nb++] = data; |
| 423 | 423 | *nb_ptr = nb; |
| @@ -1013,7 +1013,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 589 unmodified lines | ||
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | /* update target deps */ |
| 1016 | − dynarray_add((void ***)&s1->target_deps, &s1->nb_target_deps, | |
| 1016 | + dynarray_add(&s1->target_deps, &s1->nb_target_deps, | |
| 1017 | 1017 | tcc_strdup(filename)); |
| 1018 | 1018 | |
| 1019 | 1019 | parse_flags = 0; |
| @@ -1586,7 +1586,7 @@ static void args_parser_add_file(TCCState *s, const char* filename, int filetype · 566 unmodified lines | ||
| 1586 | 1586 | struct filespec *f = tcc_malloc(sizeof *f + strlen(filename)); |
| 1587 | 1587 | f->type = filetype; |
| 1588 | 1588 | strcpy(f->name, filename); |
| 1589 | − dynarray_add((void ***)&s->files, &s->nb_files, f); | |
| 1589 | + dynarray_add(&s->files, &s->nb_files, f); | |
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | 1592 | /* read list file */ |
| @@ -1611,8 +1611,8 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 18 unmodified lines | ||
| 1611 | 1611 | { |
| 1612 | 1612 | const TCCOption *popt; |
| 1613 | 1613 | const char *optarg, *r; |
| 1614 | + const char *run = NULL; | |
| 1614 | 1615 | int optind = 0; |
| 1615 | − int run = 0; | |
| 1616 | 1616 | int x; |
| 1617 | 1617 | int last_o = -1; |
| 1618 | 1618 | CString linker_arg; /* collect -Wl options */ |
| @@ -1631,8 +1631,10 @@ reparse: · 12 unmodified lines | ||
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | 1633 | if (r[0] != '-' || r[1] == '\0') { |
| 1634 | − args_parser_add_file(s, r, s->filetype); | |
| 1634 | + if (r[0] != '@') /* allow "tcc file(s) -run @ args ..." */ | |
| 1635 | + args_parser_add_file(s, r, s->filetype); | |
| 1635 | 1636 | if (run) { |
| 1637 | + tcc_set_options(s, run); | |
| 1636 | 1638 | optind--; |
| 1637 | 1639 | /* argv[0] will be this file */ |
| 1638 | 1640 | break; |
| @@ -1753,7 +1755,7 @@ reparse: · 114 unmodified lines | ||
| 1753 | 1755 | tcc_add_sysinclude_path(s, buf); |
| 1754 | 1756 | break; |
| 1755 | 1757 | case TCC_OPTION_include: |
| 1756 | − dynarray_add((void ***)&s->cmd_include_files, | |
| 1758 | + dynarray_add(&s->cmd_include_files, | |
| 1757 | 1759 | &s->nb_cmd_include_files, tcc_strdup(optarg)); |
| 1758 | 1760 | break; |
| 1759 | 1761 | case TCC_OPTION_nostdinc: |
| @@ -1769,8 +1771,7 @@ reparse: · 9 unmodified lines | ||
| 1769 | 1771 | #ifndef TCC_IS_NATIVE |
| 1770 | 1772 | tcc_error("-run is not available in a cross compiler"); |
| 1771 | 1773 | #endif |
| 1772 | − tcc_set_options(s, optarg); | |
| 1773 | − run = 1; | |
| 1774 | + run = optarg; | |
| 1774 | 1775 | x = TCC_OUTPUT_MEMORY; |
| 1775 | 1776 | goto set_output_type; |
| 1776 | 1777 | case TCC_OPTION_v: |
| @@ -1903,7 +1904,7 @@ LIBTCCAPI int tcc_set_options(TCCState *s, const char *r) · 126 unmodified lines | ||
| 1903 | 1904 | } |
| 1904 | 1905 | cstr_ccat(&str, 0); |
| 1905 | 1906 | //printf("<%s>\n", str.data), fflush(stdout); |
| 1906 | − dynarray_add((void ***)&argv, &argc, tcc_strdup(str.data)); | |
| 1907 | + dynarray_add(&argv, &argc, tcc_strdup(str.data)); | |
| 1907 | 1908 | cstr_free(&str); |
| 1908 | 1909 | } |
| 1909 | 1910 | ret = tcc_parse_args(s, argc, argv); |
| @@ -388,7 +388,7 @@ struct Attribute { · 387 unmodified lines | ||
| 388 | 388 | func_export : 1, |
| 389 | 389 | func_import : 1, |
| 390 | 390 | func_args : 5, |
| 391 | − func_proto : 1, | |
| 391 | + func_body : 1, | |
| 392 | 392 | mode : 4, |
| 393 | 393 | weak : 1, |
| 394 | 394 | visibility : 2, |
| @@ -1096,7 +1096,7 @@ PUB_FUNC NORETURN void tcc_error(const char *fmt, ...); · 701 unmodified lines | ||
| 1096 | 1096 | PUB_FUNC void tcc_warning(const char *fmt, ...); |
| 1097 | 1097 | |
| 1098 | 1098 | /* other utilities */ |
| 1099 | −ST_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data); | |
| 1099 | +ST_FUNC void dynarray_add(void *ptab, int *nb_ptr, void *data); | |
| 1100 | 1100 | ST_FUNC void dynarray_reset(void *pp, int *n); |
| 1101 | 1101 | ST_INLN void cstr_ccat(CString *cstr, int ch); |
| 1102 | 1102 | ST_FUNC void cstr_cat(CString *cstr, const char *str, int len); |
| @@ -1486,7 +1486,6 @@ static inline void add64le(unsigned char *p, int64_t x) { · 383 unmodified lines | ||
| 1486 | 1486 | /* ------------ i386-gen.c ------------ */ |
| 1487 | 1487 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 |
| 1488 | 1488 | ST_FUNC void g(int c); |
| 1489 | −ST_FUNC int oad(int c, int s); | |
| 1490 | 1489 | ST_FUNC void gen_le16(int c); |
| 1491 | 1490 | ST_FUNC void gen_le32(int c); |
| 1492 | 1491 | ST_FUNC void gen_addr32(int r, Sym *sym, long c); |
| @@ -1510,7 +1509,6 @@ ST_FUNC void gen_opl(int op); · 17 unmodified lines | ||
| 1510 | 1509 | ST_FUNC char *default_elfinterp(struct TCCState *s); |
| 1511 | 1510 | #endif |
| 1512 | 1511 | ST_FUNC void arm_init(struct TCCState *s); |
| 1513 | −ST_FUNC uint32_t encbranch(int pos, int addr, int fail); | |
| 1514 | 1512 | ST_FUNC void gen_cvt_itof1(int t); |
| 1515 | 1513 | #endif |
| 1516 | 1514 | |
| @@ -49,7 +49,7 @@ static int new_undef_sym = 0; /* Is there a new undefined sym since last new_und · 48 unmodified lines | ||
| 49 | 49 | ST_FUNC void tccelf_new(TCCState *s) |
| 50 | 50 | { |
| 51 | 51 | /* no section zero */ |
| 52 | − dynarray_add((void ***)&s->sections, &s->nb_sections, NULL); | |
| 52 | + dynarray_add(&s->sections, &s->nb_sections, NULL); | |
| 53 | 53 | |
| 54 | 54 | /* create standard sections */ |
| 55 | 55 | text_section = new_section(s, ".text", SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR); |
| @@ -153,10 +153,10 @@ ST_FUNC Section *new_section(TCCState *s1, const char *name, int sh_type, int sh · 97 unmodified lines | ||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | if (sh_flags & SHF_PRIVATE) { |
| 156 | − dynarray_add((void ***)&s1->priv_sections, &s1->nb_priv_sections, sec); | |
| 156 | + dynarray_add(&s1->priv_sections, &s1->nb_priv_sections, sec); | |
| 157 | 157 | } else { |
| 158 | 158 | sec->sh_num = s1->nb_sections; |
| 159 | − dynarray_add((void ***)&s1->sections, &s1->nb_sections, sec); | |
| 159 | + dynarray_add(&s1->sections, &s1->nb_sections, sec); | |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | return sec; |
| @@ -1896,7 +1896,7 @@ static int tcc_write_elf_file(TCCState *s1, const char *filename, int phnum, · 1733 unmodified lines | ||
| 1896 | 1896 | static int elf_output_file(TCCState *s1, const char *filename) |
| 1897 | 1897 | { |
| 1898 | 1898 | int i, ret, phnum, shnum, file_type, file_offset, *sec_order; |
| 1899 | − struct dyn_inf dyninf; | |
| 1899 | + struct dyn_inf dyninf = {0}; | |
| 1900 | 1900 | ElfW(Phdr) *phdr; |
| 1901 | 1901 | ElfW(Sym) *sym; |
| 1902 | 1902 | Section *strsec, *interp, *dynamic, *dynstr; |
| @@ -1912,7 +1912,6 @@ static int elf_output_file(TCCState *s1, const char *filename) · 9 unmodified lines | ||
| 1912 | 1912 | phdr = NULL; |
| 1913 | 1913 | sec_order = NULL; |
| 1914 | 1914 | interp = dynamic = dynstr = NULL; /* avoid warning */ |
| 1915 | − dyninf.dyn_rel_off = 0; /* avoid warning */ | |
| 1916 | 1915 | |
| 1917 | 1916 | if (file_type != TCC_OUTPUT_OBJ) { |
| 1918 | 1917 | relocate_common_syms(); |
| @@ -2595,7 +2594,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level) · 676 unmodified lines | ||
| 2595 | 2594 | dllref = tcc_mallocz(sizeof(DLLReference) + strlen(soname)); |
| 2596 | 2595 | dllref->level = level; |
| 2597 | 2596 | strcpy(dllref->name, soname); |
| 2598 | − dynarray_add((void ***)&s1->loaded_dlls, &s1->nb_loaded_dlls, dllref); | |
| 2597 | + dynarray_add(&s1->loaded_dlls, &s1->nb_loaded_dlls, dllref); | |
| 2599 | 2598 | |
| 2600 | 2599 | /* add dynamic symbols in dynsym_section */ |
| 2601 | 2600 | for(i = 1, sym = dynsym + 1; i < nb_syms; i++, sym++) { |
| @@ -2825,9 +2824,9 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) · 223 unmodified lines | ||
| 2825 | 2824 | goto lib_parse_error; |
| 2826 | 2825 | if (group) { |
| 2827 | 2826 | /* Add the filename *and* the libname to avoid future conversions */ |
| 2828 | − dynarray_add((void ***) &libs, &nblibs, tcc_strdup(filename)); | |
| 2827 | + dynarray_add(&libs, &nblibs, tcc_strdup(filename)); | |
| 2829 | 2828 | if (libname[0] != '\0') |
| 2830 | − dynarray_add((void ***) &libs, &nblibs, tcc_strdup(libname)); | |
| 2829 | + dynarray_add(&libs, &nblibs, tcc_strdup(libname)); | |
| 2831 | 2830 | } |
| 2832 | 2831 | } |
| 2833 | 2832 | } |
| @@ -1608,23 +1608,15 @@ static void gen_opl(int op) · 1607 unmodified lines | ||
| 1608 | 1608 | a = 0; |
| 1609 | 1609 | b = 0; |
| 1610 | 1610 | gen_op(op1); |
| 1611 | − if (op1 != TOK_NE) { | |
| 1611 | + if (op == TOK_NE) { | |
| 1612 | + b = gvtst(0, 0); | |
| 1613 | + } else { | |
| 1612 | 1614 | a = gvtst(1, 0); |
| 1613 | − } | |
| 1614 | − if (op != TOK_EQ) { | |
| 1615 | − /* generate non equal test */ | |
| 1616 | − /* XXX: NOT PORTABLE yet */ | |
| 1617 | − if (op1 == TOK_NE) { | |
| 1615 | + if (op != TOK_EQ) { | |
| 1616 | + /* generate non equal test */ | |
| 1617 | + vpushi(TOK_NE); | |
| 1618 | + vtop->r = VT_CMP; | |
| 1618 | 1619 | b = gvtst(0, 0); |
| 1619 | − } else { | |
| 1620 | −#if defined(TCC_TARGET_I386) | |
| 1621 | − b = gjmp2(0x850f, 0); | |
| 1622 | −#elif defined(TCC_TARGET_ARM) | |
| 1623 | − b = ind; | |
| 1624 | − o(0x1A000000 | encbranch(ind, 0, 1)); | |
| 1625 | −#else | |
| 1626 | − tcc_error("not implemented"); | |
| 1627 | −#endif | |
| 1628 | 1620 | } |
| 1629 | 1621 | } |
| 1630 | 1622 | /* compare low. Always unsigned */ |
| @@ -4724,23 +4716,13 @@ ST_FUNC void unary(void) · 3093 unmodified lines | ||
| 4724 | 4716 | tcc_warning("implicit declaration of function '%s'", name); |
| 4725 | 4717 | s = external_global_sym(t, &func_old_type, 0); |
| 4726 | 4718 | } |
| 4727 | − if ((s->type.t & (VT_STATIC | VT_INLINE | VT_BTYPE)) == | |
| 4728 | − (VT_STATIC | VT_INLINE | VT_FUNC)) { | |
| 4729 | − /* if referencing an inline function, then we generate a | |
| 4730 | − symbol to it if not already done. It will have the | |
| 4731 | − effect to generate code for it at the end of the | |
| 4732 | − compilation unit. Inline function as always | |
| 4733 | − generated in the text section. */ | |
| 4734 | − if (!s->c && !nocode_wanted) | |
| 4735 | − put_extern_sym(s, text_section, 0, 0); | |
| 4736 | − r = VT_SYM | VT_CONST; | |
| 4737 | − } else { | |
| 4738 | − r = s->r; | |
| 4739 | − /* A symbol that has a register is a local register variable, | |
| 4740 | − which starts out as VT_LOCAL value. */ | |
| 4741 | − if ((r & VT_VALMASK) < VT_CONST) | |
| 4742 | − r = (r & ~VT_VALMASK) | VT_LOCAL; | |
| 4743 | − } | |
| 4719 | + | |
| 4720 | + r = s->r; | |
| 4721 | + /* A symbol that has a register is a local register variable, | |
| 4722 | + which starts out as VT_LOCAL value. */ | |
| 4723 | + if ((r & VT_VALMASK) < VT_CONST) | |
| 4724 | + r = (r & ~VT_VALMASK) | VT_LOCAL; | |
| 4725 | + | |
| 4744 | 4726 | vset(&s->type, r, s->c); |
| 4745 | 4727 | /* Point to s as backpointer (even without r&VT_SYM). |
| 4746 | 4728 | Will be used by at least the x86 inline asm parser for |
| @@ -4822,7 +4804,7 @@ ST_FUNC void unary(void) · 75 unmodified lines | ||
| 4822 | 4804 | s = vtop->type.ref; |
| 4823 | 4805 | next(); |
| 4824 | 4806 | sa = s->next; /* first parameter */ |
| 4825 | − nb_args = 0; | |
| 4807 | + nb_args = regsize = 0; | |
| 4826 | 4808 | ret.r2 = VT_CONST; |
| 4827 | 4809 | /* compute first implicit argument if a structure is returned */ |
| 4828 | 4810 | if ((s->type.t & VT_BTYPE) == VT_STRUCT) { |
| @@ -5849,7 +5831,7 @@ static void block(int *bsym, int *csym, int is_expr) · 1020 unmodified lines | ||
| 5849 | 5831 | tcc_warning("empty case range"); |
| 5850 | 5832 | } |
| 5851 | 5833 | cr->sym = ind; |
| 5852 | − dynarray_add((void***) &cur_switch->p, &cur_switch->n, cr); | |
| 5834 | + dynarray_add(&cur_switch->p, &cur_switch->n, cr); | |
| 5853 | 5835 | skip(':'); |
| 5854 | 5836 | is_expr = 0; |
| 5855 | 5837 | goto block_after_label; |
| @@ -6897,7 +6879,6 @@ static void gen_inline_functions(TCCState *s) · 1041 unmodified lines | ||
| 6897 | 6879 | fn->sym = NULL; |
| 6898 | 6880 | if (file) |
| 6899 | 6881 | pstrcpy(file->filename, sizeof file->filename, fn->filename); |
| 6900 | − sym->r = VT_SYM | VT_CONST; | |
| 6901 | 6882 | sym->type.t &= ~VT_INLINE; |
| 6902 | 6883 | |
| 6903 | 6884 | begin_macro(fn->func_str, 1); |
| @@ -7038,8 +7019,6 @@ static int decl0(int l, int is_for_loop_init) · 134 unmodified lines | ||
| 7038 | 7019 | goto func_error1; |
| 7039 | 7020 | |
| 7040 | 7021 | ref = sym->type.ref; |
| 7041 | − if (0 == ref->a.func_proto) | |
| 7042 | − tcc_error("redefinition of '%s'", get_tok_str(v, NULL)); | |
| 7043 | 7022 | |
| 7044 | 7023 | /* use func_call from prototype if not defined */ |
| 7045 | 7024 | if (ref->a.func_call != FUNC_CDECL |
| @@ -7064,15 +7043,20 @@ static int decl0(int l, int is_for_loop_init) · 18 unmodified lines | ||
| 7064 | 7043 | tcc_error("incompatible types for redefinition of '%s'", |
| 7065 | 7044 | get_tok_str(v, NULL)); |
| 7066 | 7045 | } |
| 7067 | − type.ref->a.func_proto = 0; | |
| 7046 | + if (ref->a.func_body) | |
| 7047 | + tcc_error("redefinition of '%s'", get_tok_str(v, NULL)); | |
| 7068 | 7048 | /* if symbol is already defined, then put complete type */ |
| 7069 | 7049 | sym->type = type; |
| 7050 | + | |
| 7070 | 7051 | } else { |
| 7071 | 7052 | /* put function symbol */ |
| 7072 | 7053 | sym = global_identifier_push(v, type.t, 0); |
| 7073 | 7054 | sym->type.ref = type.ref; |
| 7074 | 7055 | } |
| 7075 | 7056 | |
| 7057 | + sym->type.ref->a.func_body = 1; | |
| 7058 | + sym->r = VT_SYM | VT_CONST; | |
| 7059 | + | |
| 7076 | 7060 | /* static inline functions are just recorded as a kind |
| 7077 | 7061 | of macro. Their code will be emitted at the end of |
| 7078 | 7062 | the compilation unit only if they are used */ |
| @@ -7106,14 +7090,13 @@ static int decl0(int l, int is_for_loop_init) · 27 unmodified lines | ||
| 7106 | 7090 | } |
| 7107 | 7091 | tok_str_add(fn->func_str, -1); |
| 7108 | 7092 | tok_str_add(fn->func_str, 0); |
| 7109 | − dynarray_add((void ***)&tcc_state->inline_fns, &tcc_state->nb_inline_fns, fn); | |
| 7093 | + dynarray_add(&tcc_state->inline_fns, &tcc_state->nb_inline_fns, fn); | |
| 7110 | 7094 | |
| 7111 | 7095 | } else { |
| 7112 | 7096 | /* compute text section */ |
| 7113 | 7097 | cur_text_section = ad.section; |
| 7114 | 7098 | if (!cur_text_section) |
| 7115 | 7099 | cur_text_section = text_section; |
| 7116 | − sym->r = VT_SYM | VT_CONST; | |
| 7117 | 7100 | gen_function(sym); |
| 7118 | 7101 | } |
| 7119 | 7102 | break; |
| @@ -7138,7 +7121,6 @@ static int decl0(int l, int is_for_loop_init) · 18 unmodified lines | ||
| 7138 | 7121 | if ((type.t & VT_BTYPE) == VT_FUNC) { |
| 7139 | 7122 | /* external function definition */ |
| 7140 | 7123 | /* specific case for func_call attribute */ |
| 7141 | − ad.a.func_proto = 1; | |
| 7142 | 7124 | type.ref->a = ad.a; |
| 7143 | 7125 | } else if (!(type.t & VT_ARRAY)) { |
| 7144 | 7126 | /* not lvalue if array */ |
| @@ -691,6 +691,10 @@ static int pe_write(struct pe_info *pe) · 690 unmodified lines | ||
| 691 | 691 | psh->PointerToRawData = file_offset; |
| 692 | 692 | file_offset = pe_file_align(pe, file_offset + si->data_size); |
| 693 | 693 | psh->SizeOfRawData = file_offset - psh->PointerToRawData; |
| 694 | + if (si->cls == sec_text) | |
| 695 | + pe_header.opthdr.SizeOfCode += psh->SizeOfRawData; | |
| 696 | + else | |
| 697 | + pe_header.opthdr.SizeOfInitializedData += psh->SizeOfRawData; | |
| 694 | 698 | } |
| 695 | 699 | } |
| 696 | 700 | |
| @@ -753,7 +757,7 @@ static struct import_symbol *pe_add_import(struct pe_info *pe, int sym_index) · 56 unmodified lines | ||
| 753 | 757 | } |
| 754 | 758 | p = tcc_mallocz(sizeof *p); |
| 755 | 759 | p->dll_index = dll_index; |
| 756 | − dynarray_add((void***)&pe->imp_info, &pe->imp_count, p); | |
| 760 | + dynarray_add(&pe->imp_info, &pe->imp_count, p); | |
| 757 | 761 | |
| 758 | 762 | found_dll: |
| 759 | 763 | i = dynarray_assoc ((void**)p->symbols, p->sym_count, sym_index); |
| @@ -761,7 +765,7 @@ found_dll: · 1 unmodified line | ||
| 761 | 765 | return p->symbols[i]; |
| 762 | 766 | |
| 763 | 767 | s = tcc_mallocz(sizeof *s); |
| 764 | − dynarray_add((void***)&p->symbols, &p->sym_count, s); | |
| 768 | + dynarray_add(&p->symbols, &p->sym_count, s); | |
| 765 | 769 | s->sym_index = sym_index; |
| 766 | 770 | return s; |
| 767 | 771 | } |
| @@ -904,7 +908,7 @@ static void pe_build_exports(struct pe_info *pe) · 136 unmodified lines | ||
| 904 | 908 | p = tcc_malloc(sizeof *p); |
| 905 | 909 | p->index = sym_index; |
| 906 | 910 | p->name = name; |
| 907 | − dynarray_add((void***)&sorted, &sym_count, p); | |
| 911 | + dynarray_add(&sorted, &sym_count, p); | |
| 908 | 912 | } |
| 909 | 913 | #if 0 |
| 910 | 914 | if (sym->st_other & ST_PE_EXPORT) |
| @@ -1515,7 +1519,7 @@ static int add_dllref(TCCState *s1, const char *dllname) · 604 unmodified lines | ||
| 1515 | 1519 | return i + 1; |
| 1516 | 1520 | dllref = tcc_mallocz(sizeof(DLLReference) + strlen(dllname)); |
| 1517 | 1521 | strcpy(dllref->name, dllname); |
| 1518 | − dynarray_add((void ***) &s1->loaded_dlls, &s1->nb_loaded_dlls, dllref); | |
| 1522 | + dynarray_add(&s1->loaded_dlls, &s1->nb_loaded_dlls, dllref); | |
| 1519 | 1523 | return s1->nb_loaded_dlls; |
| 1520 | 1524 | } |
| 1521 | 1525 | |
| @@ -1566,7 +1566,7 @@ static CachedInclude *search_cached_include(TCCState *s1, const char *filename, · 1565 unmodified lines | ||
| 1566 | 1566 | e = tcc_malloc(sizeof(CachedInclude) + strlen(filename)); |
| 1567 | 1567 | strcpy(e->filename, filename); |
| 1568 | 1568 | e->ifndef_macro = e->once = 0; |
| 1569 | − dynarray_add((void ***)&s1->cached_includes, &s1->nb_cached_includes, e); | |
| 1569 | + dynarray_add(&s1->cached_includes, &s1->nb_cached_includes, e); | |
| 1570 | 1570 | /* add in hash table */ |
| 1571 | 1571 | e->hash_next = s1->cached_includes_hash[h]; |
| 1572 | 1572 | s1->cached_includes_hash[h] = s1->nb_cached_includes; |
| @@ -1665,7 +1665,7 @@ static void pragma_parse(TCCState *s1) · 92 unmodified lines | ||
| 1665 | 1665 | if (tok != TOK_STR) |
| 1666 | 1666 | goto pragma_err; |
| 1667 | 1667 | file = tcc_strdup((char *)tokc.str.data); |
| 1668 | − dynarray_add((void ***)&s1->pragma_libs, &s1->nb_pragma_libs, file); | |
| 1668 | + dynarray_add(&s1->pragma_libs, &s1->nb_pragma_libs, file); | |
| 1669 | 1669 | next(); |
| 1670 | 1670 | if (tok != ')') |
| 1671 | 1671 | goto pragma_err; |
| @@ -1820,7 +1820,7 @@ ST_FUNC void preprocess(int is_bof) · 148 unmodified lines | ||
| 1820 | 1820 | printf("%s: including %s\n", file->prev->filename, file->filename); |
| 1821 | 1821 | #endif |
| 1822 | 1822 | /* update target deps */ |
| 1823 | − dynarray_add((void ***)&s1->target_deps, &s1->nb_target_deps, | |
| 1823 | + dynarray_add(&s1->target_deps, &s1->nb_target_deps, | |
| 1824 | 1824 | tcc_strdup(buf1)); |
| 1825 | 1825 | /* push current file in stack */ |
| 1826 | 1826 | ++s1->include_stack_ptr; |
| @@ -224,7 +224,7 @@ static int is64_type(int t) · 223 unmodified lines | ||
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /* instruction + 4 bytes data. Return the address of the data */ |
| 227 | −ST_FUNC int oad(int c, int s) | |
| 227 | +static int oad(int c, int s) | |
| 228 | 228 | { |
| 229 | 229 | int t; |
| 230 | 230 | if (nocode_wanted) |