/* Use "-g" as alias for "-g1". Use "-g0" to disable debug */ So not using -g is now the alias for -g0 ?!? This reverts commit 8759b2581d196081e3b152b2ea71ccf1a76412eb. This reverts commit 3ce7bc6efc8079dfa182840a177dbff8199ae1d5. This reverts commit 5fb582ab7f44f8ead28a95e002042e6cb1e72b00. This reverts commit aea68dbb40b544ecf17d90665aaf13ee1e2f905d. This reverts commit fa9c31c3db1898d804db2289a11d9f368da88dd1. This reverts commit b3bebdb20a8910597955f849791f578d42ef178e. This reverts commit ecf8e5a00e5909ae664e1fafb641ddf711210904. This reverts commit fe6b5c08dc68b1bfab6b6ef6b9e29a5af7317262. This reverts commit e2e5377e7b68d57def00acda17ffcfca6dce8b84. This reverts commit 1cd79989057ff937a2bc2b8bdc7afd4f02a91407.
Unified · Split
| @@ -28,7 +28,7 @@ c2str · 27 unmodified lines | ||
| 28 | 28 | tags |
| 29 | 29 | TAGS |
| 30 | 30 | tcc.1 |
| 31 | −tcc.pod | |
| 31 | +*.pod | |
| 32 | 32 | tcc-doc.html |
| 33 | 33 | tcc-doc.info |
| 34 | 34 | |
| @@ -8,12 +8,6 @@ ifndef TOP · 7 unmodified lines | ||
| 8 | 8 | INCLUDED = no |
| 9 | 9 | endif |
| 10 | 10 | |
| 11 | −# Uncomment the next two commands to allow debug this Makefile | |
| 12 | −# When enabled, GNU make will no longer execute commands directly. | |
| 13 | −# All build commands will be executed using the shell. This needs more time | |
| 14 | −#OLD_SHELL := $(SHELL) | |
| 15 | −#SHELL = $(info Building $* $(if $<, (from $<))$(if $?, ($? newer)))$(OLD_SHELL) | |
| 16 | − | |
| 17 | 11 | ifeq ($(findstring $(MAKECMDGOALS),clean distclean),) |
| 18 | 12 | include $(TOP)/config.mak |
| 19 | 13 | endif |
| @@ -244,7 +238,7 @@ endif · 224 unmodified lines | ||
| 244 | 238 | |
| 245 | 239 | # convert "include/tccdefs.h" to "tccdefs_.h" |
| 246 | 240 | %_.h : include/%.h conftest.c |
| 247 | − $S$(CC) -DC2STR $(filter %.c,$^) -o c2str$(EXESUF) && ./c2str$(EXESUF) $< $@ | |
| 241 | + $S$(CC) -DC2STR $(filter %.c,$^) -o c2str.exe && ./c2str.exe $< $@ | |
| 248 | 242 | |
| 249 | 243 | # target specific object rule |
| 250 | 244 | $(X)%.o : %.c $(LIBTCC_INC) |
| @@ -261,7 +255,7 @@ tcc$(EXESUF): tcc.o $(LIBTCC) · 10 unmodified lines | ||
| 261 | 255 | # Cross Tiny C Compilers |
| 262 | 256 | # (the TCCDEFS_H dependency is only necessary for parallel makes, |
| 263 | 257 | # ala 'make -j x86_64-tcc i386-tcc tcc', which would create multiple |
| 264 | −# c2str and tccdefs_.h files in parallel, leading to access errors. | |
| 258 | +# c2str.exe and tccdefs_.h files in parallel, leading to access errors. | |
| 265 | 259 | # This forces it to be made only once. Make normally tracks multiple paths |
| 266 | 260 | # to the same goals and only remakes it once, but that doesn't work over |
| 267 | 261 | # sub-makes like in this target) |
| @@ -332,6 +326,8 @@ tcc.1 : tcc-doc.pod · 64 unmodified lines | ||
| 332 | 326 | %.pod : %.texi |
| 333 | 327 | $(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@) |
| 334 | 328 | |
| 329 | +doc : $(TCCDOCS) | |
| 330 | + | |
| 335 | 331 | # -------------------------------------------------------------------------- |
| 336 | 332 | # install |
| 337 | 333 | |
| @@ -410,10 +406,6 @@ tags : ; ctags $(TAGFILES) · 72 unmodified lines | ||
| 410 | 406 | # cannot have both tags and TAGS on windows |
| 411 | 407 | ETAGS : ; etags $(TAGFILES) |
| 412 | 408 | |
| 413 | −# documentation | |
| 414 | −doc: tcc-doc.html tcc-doc.info tcc.1 | |
| 415 | − | |
| 416 | − | |
| 417 | 409 | # create release tarball from *current* git branch (including tcc-doc.html |
| 418 | 410 | # and converting two files to CRLF) |
| 419 | 411 | TCC-VERSION = tcc-$(VERSION) |
| @@ -443,15 +435,16 @@ testspp.%: · 23 unmodified lines | ||
| 443 | 435 | @$(MAKE) -C tests/pp $@ |
| 444 | 436 | |
| 445 | 437 | clean: |
| 446 | − @rm -f tcc$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tcc.pod tags ETAGS | |
| 438 | + @rm -f tcc$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tags ETAGS *.pod | |
| 447 | 439 | @rm -f *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out *.dylib *_.h |
| 448 | 440 | @$(MAKE) -s -C lib $@ |
| 449 | 441 | @$(MAKE) -s -C tests $@ |
| 450 | 442 | |
| 451 | 443 | distclean: clean |
| 452 | − @rm -fv config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html | |
| 444 | + @rm -fv config.h config.mak config.texi | |
| 445 | + @rm -fv $(TCCDOCS) | |
| 453 | 446 | |
| 454 | −.PHONY: all clean test tar tags ETAGS distclean install uninstall FORCE | |
| 447 | +.PHONY: all clean test tar tags ETAGS doc distclean install uninstall FORCE | |
| 455 | 448 | |
| 456 | 449 | help: |
| 457 | 450 | @echo "make" |
| @@ -77,21 +77,6 @@ static int asm_parse_vfp_regvar(int t, int double_precision) · 76 unmodified lines | ||
| 77 | 77 | return -1; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | −__attribute__((unused)) | |
| 81 | −static int asm_parse_vfp_status_regvar(int t) | |
| 82 | −{ | |
| 83 | − switch (t) { | |
| 84 | − case TOK_ASM_fpsid: | |
| 85 | − return 0; | |
| 86 | − case TOK_ASM_fpscr: | |
| 87 | − return 1; | |
| 88 | − case TOK_ASM_fpexc: | |
| 89 | − return 8; | |
| 90 | − default: | |
| 91 | − return -1; | |
| 92 | − } | |
| 93 | −} | |
| 94 | − | |
| 95 | 80 | /* Parse a text containing operand and store the result in OP */ |
| 96 | 81 | static void parse_operand(TCCState *s1, Operand *op) |
| 97 | 82 | { |
| @@ -2240,6 +2225,20 @@ static void asm_floating_point_data_processing_opcode(TCCState *s1, int token) { · 2142 unmodified lines | ||
| 2240 | 2225 | asm_emit_coprocessor_opcode(condition_code_of_token(token), coprocessor, opcode1, ops[0].reg, (ops[1].type == OP_IM8) ? ops[1].e.v : ops[1].reg, (ops[2].type == OP_IM8) ? ops[2].e.v : ops[2].reg, opcode2, 0); |
| 2241 | 2226 | } |
| 2242 | 2227 | |
| 2228 | +static int asm_parse_vfp_status_regvar(int t) | |
| 2229 | +{ | |
| 2230 | + switch (t) { | |
| 2231 | + case TOK_ASM_fpsid: | |
| 2232 | + return 0; | |
| 2233 | + case TOK_ASM_fpscr: | |
| 2234 | + return 1; | |
| 2235 | + case TOK_ASM_fpexc: | |
| 2236 | + return 8; | |
| 2237 | + default: | |
| 2238 | + return -1; | |
| 2239 | + } | |
| 2240 | +} | |
| 2241 | + | |
| 2243 | 2242 | static void asm_floating_point_status_register_opcode(TCCState* s1, int token) |
| 2244 | 2243 | { |
| 2245 | 2244 | uint8_t coprocessor = CP_SINGLE_PRECISION_FLOAT; |
| @@ -28,6 +28,7 @@ enum float_abi { · 27 unmodified lines | ||
| 28 | 28 | |
| 29 | 29 | #include "tcc.h" |
| 30 | 30 | |
| 31 | +#ifdef NEED_RELOC_TYPE | |
| 31 | 32 | /* Returns 1 for a code relocation, 0 for a data relocation. For unknown |
| 32 | 33 | relocations, returns -1. */ |
| 33 | 34 | int code_reloc (int reloc_type) |
| @@ -107,7 +108,7 @@ int gotplt_entry_type (int reloc_type) · 73 unmodified lines | ||
| 107 | 108 | return -1; |
| 108 | 109 | } |
| 109 | 110 | |
| 110 | −#ifndef TCC_TARGET_PE | |
| 111 | +#ifdef NEED_BUILD_GOT | |
| 111 | 112 | ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr) |
| 112 | 113 | { |
| 113 | 114 | Section *plt = s1->plt; |
| @@ -177,6 +178,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 63 unmodified lines | ||
| 177 | 178 | } |
| 178 | 179 | } |
| 179 | 180 | #endif |
| 181 | +#endif | |
| 180 | 182 | |
| 181 | 183 | void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val) |
| 182 | 184 | { |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | #include "tcc.h" |
| 24 | 24 | |
| 25 | +#ifdef NEED_RELOC_TYPE | |
| 25 | 26 | /* Returns 1 for a code relocation, 0 for a data relocation. For unknown |
| 26 | 27 | relocations, returns -1. */ |
| 27 | 28 | int code_reloc (int reloc_type) |
| @@ -91,7 +92,7 @@ int gotplt_entry_type (int reloc_type) · 63 unmodified lines | ||
| 91 | 92 | return -1; |
| 92 | 93 | } |
| 93 | 94 | |
| 94 | −__attribute__((unused)) | |
| 95 | +#ifdef NEED_BUILD_GOT | |
| 95 | 96 | ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr) |
| 96 | 97 | { |
| 97 | 98 | Section *plt = s1->plt; |
| @@ -111,7 +112,6 @@ ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_ · 13 unmodified lines | ||
| 111 | 112 | |
| 112 | 113 | /* relocate the PLT: compute addresses and offsets in the PLT now that final |
| 113 | 114 | address for PLT and GOT are known (see fill_program_header) */ |
| 114 | −__attribute__((unused)) | |
| 115 | 115 | ST_FUNC void relocate_plt(TCCState *s1) |
| 116 | 116 | { |
| 117 | 117 | uint8_t *p, *p_end; |
| @@ -166,6 +166,8 @@ ST_FUNC void relocate_plt(TCCState *s1) · 48 unmodified lines | ||
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | +#endif | |
| 170 | +#endif | |
| 169 | 171 | |
| 170 | 172 | void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val) |
| 171 | 173 | { |
| @@ -27,8 +27,7 @@ mandir="" · 26 unmodified lines | ||
| 27 | 27 | infodir="" |
| 28 | 28 | sysroot="" |
| 29 | 29 | cross_prefix="" |
| 30 | −test -z "$CC" && CC="gcc" | |
| 31 | −test -z "$cc" && cc="$CC" | |
| 30 | +cc="gcc" | |
| 32 | 31 | ar="ar" |
| 33 | 32 | bigendian="no" |
| 34 | 33 | mingw32="no" |
| @@ -46,7 +45,7 @@ confvars= · 11 unmodified lines | ||
| 46 | 45 | suggest="yes" |
| 47 | 46 | gcc_major=0 |
| 48 | 47 | gcc_minor=0 |
| 49 | −cc_name="$cc" | |
| 48 | +cc_name="gcc" | |
| 50 | 49 | ar_set= |
| 51 | 50 | darwin= |
| 52 | 51 | cpu= |
| @@ -408,6 +407,7 @@ if test "$cc_name" != "tcc"; then · 355 unmodified lines | ||
| 408 | 407 | OPT1="-Wdeclaration-after-statement -fno-strict-aliasing" |
| 409 | 408 | # we want -Wno- but gcc does not always reject unknown -Wno- options |
| 410 | 409 | OPT2="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation" |
| 410 | + OPT2="$OPT2 -Wstringop-truncation" | |
| 411 | 411 | if test "$cc_name" = "clang"; then |
| 412 | 412 | OPT1="$OPT1 -fheinous-gnu-extensions" |
| 413 | 413 | OPT2="$OPT2 -Wstring-plus-int" |
| @@ -833,6 +833,7 @@ again: · 832 unmodified lines | ||
| 833 | 833 | goto next; |
| 834 | 834 | alltypes |= ops[i].type; |
| 835 | 835 | } |
| 836 | + (void)alltypes; /* maybe unused */ | |
| 836 | 837 | /* all is matching ! */ |
| 837 | 838 | break; |
| 838 | 839 | next: ; |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | #include "tcc.h" |
| 25 | 25 | |
| 26 | −#ifndef ELF_OBJ_ONLY | |
| 26 | +#ifdef NEED_RELOC_TYPE | |
| 27 | 27 | /* Returns 1 for a code relocation, 0 for a data relocation. For unknown |
| 28 | 28 | relocations, returns -1. */ |
| 29 | 29 | int code_reloc (int reloc_type) |
| @@ -92,6 +92,7 @@ int gotplt_entry_type (int reloc_type) · 62 unmodified lines | ||
| 92 | 92 | return -1; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | +#ifdef NEED_BUILD_GOT | |
| 95 | 96 | ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr) |
| 96 | 97 | { |
| 97 | 98 | Section *plt = s1->plt; |
| @@ -169,6 +170,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 71 unmodified lines | ||
| 169 | 170 | } |
| 170 | 171 | } |
| 171 | 172 | #endif |
| 173 | +#endif | |
| 172 | 174 | |
| 173 | 175 | void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val) |
| 174 | 176 | { |
| @@ -836,6 +836,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 835 unmodified lines | ||
| 836 | 836 | tcc_free(s1->tcc_lib_path); |
| 837 | 837 | tcc_free(s1->soname); |
| 838 | 838 | tcc_free(s1->rpath); |
| 839 | + tcc_free(s1->elf_entryname); | |
| 839 | 840 | tcc_free(s1->init_symbol); |
| 840 | 841 | tcc_free(s1->fini_symbol); |
| 841 | 842 | tcc_free(s1->outfile); |
| @@ -1567,23 +1568,6 @@ static const TCCOption tcc_options[] = { · 725 unmodified lines | ||
| 1567 | 1568 | { NULL, 0, 0 }, |
| 1568 | 1569 | }; |
| 1569 | 1570 | |
| 1570 | −typedef struct stdvalue { | |
| 1571 | − uint32_t cversion; | |
| 1572 | − const char * name; | |
| 1573 | −} stdvalue; | |
| 1574 | − | |
| 1575 | −/* accepted values for the -std= option */ | |
| 1576 | −static const stdvalue std_values[] = { | |
| 1577 | − { 199901, "c99" }, | |
| 1578 | − { 201112, "c11" }, | |
| 1579 | − { 201710, "c17" }, | |
| 1580 | − { 202000, "c2x" }, | |
| 1581 | − { 199901, "gnu99" }, | |
| 1582 | − { 201112, "gnu11" }, | |
| 1583 | − { 201710, "gnu17" }, | |
| 1584 | − { 202000, "gnu2x" } | |
| 1585 | −}; | |
| 1586 | − | |
| 1587 | 1571 | typedef struct FlagDef { |
| 1588 | 1572 | uint16_t offset; |
| 1589 | 1573 | uint16_t flags; |
| @@ -1837,9 +1821,6 @@ reparse: · 247 unmodified lines | ||
| 1837 | 1821 | break; |
| 1838 | 1822 | #endif |
| 1839 | 1823 | case TCC_OPTION_g: |
| 1840 | − /* Use "-g" as alias for "-g1". Use "-g0" to disable debug */ | |
| 1841 | − /* Other common used values: "-g0", "-g1", "-g2" and "-g3" */ | |
| 1842 | − /* no failure with unsupported options */ | |
| 1843 | 1824 | s->do_debug = 1; |
| 1844 | 1825 | s->dwarf = DWARF_VERSION; |
| 1845 | 1826 | if (*optarg == 'd') { |
| @@ -1847,8 +1828,6 @@ reparse: · 1 unmodified line | ||
| 1847 | 1828 | if (!strncmp(optarg,"dwarf-",6)) |
| 1848 | 1829 | s->dwarf = atoi(optarg + 6); |
| 1849 | 1830 | } |
| 1850 | − else if (isnum(*optarg)) | |
| 1851 | − s->do_debug = atoi(optarg); | |
| 1852 | 1831 | break; |
| 1853 | 1832 | case TCC_OPTION_c: |
| 1854 | 1833 | x = TCC_OUTPUT_OBJ; |
| @@ -1873,21 +1852,8 @@ reparse: · 18 unmodified lines | ||
| 1873 | 1852 | s->static_link = 1; |
| 1874 | 1853 | break; |
| 1875 | 1854 | case TCC_OPTION_std: |
| 1876 | − x = 0; | |
| 1877 | − if (*optarg == '=') { | |
| 1878 | − do { | |
| 1879 | − if (strcmp(std_values[x].name, &optarg[1]) == 0) { | |
| 1880 | − x = std_values[x].cversion; | |
| 1881 | − } | |
| 1882 | − else | |
| 1883 | − ++x; | |
| 1884 | − } while (x < (sizeof(std_values)/sizeof(stdvalue))); | |
| 1885 | − } | |
| 1886 | − if (x > (sizeof(std_values)/sizeof(stdvalue))) | |
| 1887 | − s->cversion = x; | |
| 1888 | − else | |
| 1889 | − goto unsupported_option; | |
| 1890 | − | |
| 1855 | + if (strcmp(optarg, "=c11") == 0) | |
| 1856 | + s->cversion = 201112; | |
| 1891 | 1857 | break; |
| 1892 | 1858 | case TCC_OPTION_shared: |
| 1893 | 1859 | x = TCC_OUTPUT_DLL; |
| @@ -2018,11 +1984,7 @@ reparse: · 124 unmodified lines | ||
| 2018 | 1984 | s->filetype = x | (s->filetype & ~AFF_TYPE_MASK); |
| 2019 | 1985 | break; |
| 2020 | 1986 | case TCC_OPTION_O: |
| 2021 | − /* Use "-O" as alias for "-O1". */ | |
| 2022 | − /* Other common used values: "-O0", "-O1", "-O2", "-O3" and "-Os" */ | |
| 2023 | − /* no failure with unsupported options */ | |
| 2024 | − x = *optarg; | |
| 2025 | − s->optimize = isnum(x) ? atoi(optarg) : (x) ? x : 1; | |
| 1987 | + s->optimize = atoi(optarg); | |
| 2026 | 1988 | break; |
| 2027 | 1989 | case TCC_OPTION_print_search_dirs: |
| 2028 | 1990 | x = OPT_PRINT_DIRS; |
| @@ -349,7 +349,7 @@ Turn on/off linking of all objects in archives. · 348 unmodified lines | ||
| 349 | 349 | Debugger options: |
| 350 | 350 | |
| 351 | 351 | @table @option |
| 352 | −@item -g[x] | |
| 352 | +@item -g | |
| 353 | 353 | Generate run time stab debug information so that you get clear run time |
| 354 | 354 | error messages: @code{ test.c:68: in function 'test5()': dereferencing |
| 355 | 355 | invalid pointer} instead of the laconic @code{Segmentation |
| @@ -58,7 +58,7 @@ static const char help[] = · 57 unmodified lines | ||
| 58 | 58 | " -soname set name for shared library to be used at runtime\n" |
| 59 | 59 | " -Wl,-opt[=val] set linker option (see tcc -hh)\n" |
| 60 | 60 | "Debugger options:\n" |
| 61 | − " -g[x] generate stab runtime debug info\n" | |
| 61 | + " -g generate stab runtime debug info\n" | |
| 62 | 62 | " -gdwarf[-x] generate dwarf runtime debug info\n" |
| 63 | 63 | #ifdef CONFIG_TCC_BCHECK |
| 64 | 64 | " -b compile with built-in memory and bounds checker (implies -g)\n" |
| @@ -258,9 +258,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 257 unmodified lines | ||
| 258 | 258 | |
| 259 | 259 | /* path to find crt1.o, crti.o and crtn.o */ |
| 260 | 260 | #ifndef CONFIG_TCC_CRTPREFIX |
| 261 | −# define CONFIG_TCC_CRTPREFIX \ | |
| 262 | − ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ | |
| 263 | − ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib" | |
| 261 | +# define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) | |
| 264 | 262 | #endif |
| 265 | 263 | |
| 266 | 264 | #ifndef CONFIG_USR_INCLUDE |
| @@ -277,8 +275,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 10 unmodified lines | ||
| 277 | 275 | # define CONFIG_TCC_SYSINCLUDEPATHS \ |
| 278 | 276 | "{B}/include" \ |
| 279 | 277 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \ |
| 280 | − ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/include" \ | |
| 281 | − ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/include" \ | |
| 282 | 278 | ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE) |
| 283 | 279 | # endif |
| 284 | 280 | #endif |
| @@ -290,8 +286,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 5 unmodified lines | ||
| 290 | 286 | # else |
| 291 | 287 | # define CONFIG_TCC_LIBPATHS \ |
| 292 | 288 | ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ |
| 293 | − ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib" \ | |
| 294 | − ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/lib" \ | |
| 295 | 289 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \ |
| 296 | 290 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR) |
| 297 | 291 | # endif |
| @@ -826,7 +820,7 @@ struct TCCState { · 528 unmodified lines | ||
| 826 | 820 | char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */ |
| 827 | 821 | char *soname; /* as specified on the command line (-soname) */ |
| 828 | 822 | char *rpath; /* as specified on the command line (-Wl,-rpath=) */ |
| 829 | − | |
| 823 | + char *elf_entryname; /* "_start" unless set */ | |
| 830 | 824 | char *init_symbol; /* symbols to call at load-time (not used currently) */ |
| 831 | 825 | char *fini_symbol; /* symbols to call at unload-time (not used currently) */ |
| 832 | 826 | |
| @@ -975,8 +969,6 @@ struct TCCState { · 142 unmodified lines | ||
| 975 | 969 | Section *verneed_section; |
| 976 | 970 | #endif |
| 977 | 971 | |
| 978 | − char *elf_entryname; | |
| 979 | − | |
| 980 | 972 | #ifdef TCC_IS_NATIVE |
| 981 | 973 | const char *runtime_main; |
| 982 | 974 | void **runtime_mem; |
| @@ -1545,9 +1537,6 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, int fd, unsigned long file_offset · 562 unmodified lines | ||
| 1545 | 1537 | ST_FUNC int tcc_load_archive(TCCState *s1, int fd, int alacarte); |
| 1546 | 1538 | ST_FUNC void add_array(TCCState *s1, const char *sec, int c); |
| 1547 | 1539 | |
| 1548 | −#if !defined(ELF_OBJ_ONLY) || (defined(TCC_TARGET_MACHO) && defined TCC_IS_NATIVE) | |
| 1549 | −ST_FUNC void build_got_entries(TCCState *s1); | |
| 1550 | −#endif | |
| 1551 | 1540 | ST_FUNC struct sym_attr *get_sym_attr(TCCState *s1, int index, int alloc); |
| 1552 | 1541 | ST_FUNC addr_t get_sym_addr(TCCState *s, const char *name, int err, int forc); |
| 1553 | 1542 | ST_FUNC void list_elf_symbols(TCCState *s, void *ctx, |
| @@ -1570,6 +1559,9 @@ ST_FUNC void tcc_add_runtime(TCCState *s1); · 16 unmodified lines | ||
| 1570 | 1559 | |
| 1571 | 1560 | /* ------------ xxx-link.c ------------ */ |
| 1572 | 1561 | |
| 1562 | +#if !defined ELF_OBJ_ONLY || defined TCC_TARGET_MACHO | |
| 1563 | +ST_FUNC int code_reloc (int reloc_type); | |
| 1564 | +ST_FUNC int gotplt_entry_type (int reloc_type); | |
| 1573 | 1565 | /* Whether to generate a GOT/PLT entry and when. NO_GOTPLT_ENTRY is first so |
| 1574 | 1566 | that unknown relocation don't create a GOT or PLT entry */ |
| 1575 | 1567 | enum gotplt_entry { |
| @@ -1578,15 +1570,17 @@ enum gotplt_entry { · 2 unmodified lines | ||
| 1578 | 1570 | AUTO_GOTPLT_ENTRY, /* generate if sym is UNDEF */ |
| 1579 | 1571 | ALWAYS_GOTPLT_ENTRY /* always generate (eg. PLTOFF relocs) */ |
| 1580 | 1572 | }; |
| 1573 | +#define NEED_RELOC_TYPE | |
| 1581 | 1574 | |
| 1582 | −#if !defined(ELF_OBJ_ONLY) || defined(TCC_TARGET_MACHO) | |
| 1583 | −ST_FUNC int code_reloc (int reloc_type); | |
| 1584 | −ST_FUNC int gotplt_entry_type (int reloc_type); | |
| 1585 | −#if !defined(TCC_TARGET_MACHO) || defined TCC_IS_NATIVE | |
| 1575 | +#if !defined TCC_TARGET_MACHO || defined TCC_IS_NATIVE | |
| 1586 | 1576 | ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr); |
| 1587 | 1577 | ST_FUNC void relocate_plt(TCCState *s1); |
| 1578 | +ST_FUNC void build_got_entries(TCCState *s1); /* in tccelf.c */ | |
| 1579 | +#define NEED_BUILD_GOT | |
| 1580 | + | |
| 1588 | 1581 | #endif |
| 1589 | 1582 | #endif |
| 1583 | + | |
| 1590 | 1584 | ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val); |
| 1591 | 1585 | |
| 1592 | 1586 | /* ------------ xxx-gen.c ------------ */ |
| @@ -671,7 +671,7 @@ version_add (TCCState *s1) · 670 unmodified lines | ||
| 671 | 671 | } |
| 672 | 672 | dt_verneednum = nb_entries; |
| 673 | 673 | } |
| 674 | −#endif | |
| 674 | +#endif /* ndef ELF_OBJ_ONLY */ | |
| 675 | 675 | |
| 676 | 676 | /* add an elf symbol : check if it is already defined and patch |
| 677 | 677 | it. Return symbol index. NOTE that sh_num can be SHN_UNDEF. */ |
| @@ -1121,7 +1121,7 @@ static int prepare_dynamic_rel(TCCState *s1, Section *sr) · 443 unmodified lines | ||
| 1121 | 1121 | } |
| 1122 | 1122 | #endif |
| 1123 | 1123 | |
| 1124 | −#if !defined(ELF_OBJ_ONLY) || (defined(TCC_TARGET_MACHO) && defined TCC_IS_NATIVE) | |
| 1124 | +#ifdef NEED_BUILD_GOT | |
| 1125 | 1125 | static void build_got(TCCState *s1) |
| 1126 | 1126 | { |
| 1127 | 1127 | /* if no got, then create it */ |
| @@ -1354,7 +1354,7 @@ redo: · 226 unmodified lines | ||
| 1354 | 1354 | s1->plt->reloc->sh_info = s1->got->sh_num; |
| 1355 | 1355 | |
| 1356 | 1356 | } |
| 1357 | −#endif | |
| 1357 | +#endif /* def NEED_BUILD_GOT */ | |
| 1358 | 1358 | |
| 1359 | 1359 | ST_FUNC int set_global_sym(TCCState *s1, const char *name, Section *sec, addr_t offs) |
| 1360 | 1360 | { |
| @@ -1506,7 +1506,7 @@ ST_FUNC void tcc_add_btstub(TCCState *s1) · 145 unmodified lines | ||
| 1506 | 1506 | cstr_free(&cstr); |
| 1507 | 1507 | set_local_sym(s1, &"___rt_info"[!s1->leading_underscore], s, o); |
| 1508 | 1508 | } |
| 1509 | −#endif | |
| 1509 | +#endif /* def CONFIG_TCC_BACKTRACE */ | |
| 1510 | 1510 | |
| 1511 | 1511 | static void tcc_tcov_add_file(TCCState *s1, const char *filename) |
| 1512 | 1512 | { |
| @@ -1615,7 +1615,7 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 102 unmodified lines | ||
| 1615 | 1615 | #endif |
| 1616 | 1616 | } |
| 1617 | 1617 | } |
| 1618 | −#endif | |
| 1618 | +#endif /* ndef TCC_TARGET_PE */ | |
| 1619 | 1619 | |
| 1620 | 1620 | /* add various standard linker symbols (must be done after the |
| 1621 | 1621 | sections are filled (for example after allocating common |
| @@ -1688,7 +1688,6 @@ ST_FUNC void resolve_common_syms(TCCState *s1) · 66 unmodified lines | ||
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | 1690 | #ifndef ELF_OBJ_ONLY |
| 1691 | − | |
| 1692 | 1691 | ST_FUNC void fill_got_entry(TCCState *s1, ElfW_Rel *rel) |
| 1693 | 1692 | { |
| 1694 | 1693 | int sym_index = ELFW(R_SYM) (rel->r_info); |
| @@ -3771,7 +3770,7 @@ static int ld_add_file(TCCState *s1, const char filename[]) · 2076 unmodified lines | ||
| 3771 | 3770 | |
| 3772 | 3771 | static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) |
| 3773 | 3772 | { |
| 3774 | − char filename[1024], libname[1016]; | |
| 3773 | + char filename[1024], libname[1024]; | |
| 3775 | 3774 | int t, group, nblibs = 0, ret = 0; |
| 3776 | 3775 | char **libs = NULL; |
| 3777 | 3776 | |
| @@ -1380,7 +1380,7 @@ static void tcc_debug_fix_anon(CType *t) · 1379 unmodified lines | ||
| 1380 | 1380 | if ((t->t & VT_BTYPE) == VT_STRUCT && t->ref->c != -1) |
| 1381 | 1381 | for (i = 0; i < n_debug_anon_hash; i++) |
| 1382 | 1382 | if (t->ref == debug_anon_hash[i].type) { |
| 1383 | − Sym sym = { .type = *t }; | |
| 1383 | + Sym sym = {0}; sym .type = *t ; | |
| 1384 | 1384 | |
| 1385 | 1385 | debug_type = tcc_get_dwarf_info(s1, &sym); |
| 1386 | 1386 | for (j = 0; j < debug_anon_hash[i].n_debug_type; j++) |
| @@ -1628,8 +1628,7 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s) · 241 unmodified lines | ||
| 1628 | 1628 | debug_type = tcc_debug_find(t, 1); |
| 1629 | 1629 | if (debug_type == -1) { |
| 1630 | 1630 | int pos_sib, pos_type; |
| 1631 | − CType ct = { VT_INT | (type & VT_UNSIGNED) , NULL }; | |
| 1632 | − Sym sym = { .type = ct }; | |
| 1631 | + Sym sym = {0}; sym .type.t = VT_INT | (type & VT_UNSIGNED) ; | |
| 1633 | 1632 | |
| 1634 | 1633 | pos_type = tcc_get_dwarf_info(s1, &sym); |
| 1635 | 1634 | debug_type = tcc_debug_add(t, 1); |
| @@ -1705,8 +1704,7 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s) · 69 unmodified lines | ||
| 1705 | 1704 | } |
| 1706 | 1705 | else if (type == (VT_PTR | VT_ARRAY)) { |
| 1707 | 1706 | int sib_pos, sub_type; |
| 1708 | − CType ct = { VT_INT | VT_UNSIGNED , NULL }; | |
| 1709 | − Sym sym = { .type = ct }; | |
| 1707 | + Sym sym = {0}; sym .type.t = VT_INT | VT_UNSIGNED ; | |
| 1710 | 1708 | |
| 1711 | 1709 | sub_type = tcc_get_dwarf_info(s1, &sym); |
| 1712 | 1710 | i = dwarf_info_section->data_offset; |
| @@ -262,8 +262,7 @@ static void * add_lc(struct macho *mo, uint32_t cmd, uint32_t cmdsize) · 261 unmodified lines | ||
| 262 | 262 | static struct segment_command_64 * add_segment(struct macho *mo, const char *name) |
| 263 | 263 | { |
| 264 | 264 | struct segment_command_64 *sc = add_lc(mo, LC_SEGMENT_64, sizeof(*sc)); |
| 265 | − strncpy(sc->segname, name, 16-1); | |
| 266 | − sc->segname[16-1] = '\0'; | |
| 265 | + strncpy(sc->segname, name, 16); | |
| 267 | 266 | mo->seg2lc[mo->nseg++] = mo->nlc - 1; |
| 268 | 267 | return sc; |
| 269 | 268 | } |
| @@ -283,8 +282,7 @@ static int add_section(struct macho *mo, struct segment_command_64 **_seg, const · 13 unmodified lines | ||
| 283 | 282 | seg = tcc_realloc(seg, sizeof(*seg) + seg->nsects * sizeof(*sec)); |
| 284 | 283 | sec = (struct section_64*)((char*)seg + sizeof(*seg)) + ret; |
| 285 | 284 | memset(sec, 0, sizeof(*sec)); |
| 286 | − strncpy(sec->sectname, name, 16-1); | |
| 287 | − sec->sectname[16-1] = '\0'; | |
| 285 | + strncpy(sec->sectname, name, 16); | |
| 288 | 286 | strncpy(sec->segname, seg->segname, 16); |
| 289 | 287 | *_seg = seg; |
| 290 | 288 | return ret; |
| @@ -2038,10 +2038,14 @@ include_done: · 2037 unmodified lines | ||
| 2038 | 2038 | if (tok == TOK_STR) { |
| 2039 | 2039 | if (file->true_filename == file->filename) |
| 2040 | 2040 | file->true_filename = tcc_strdup(file->filename); |
| 2041 | − /* prepend directory from real file */ | |
| 2042 | − pstrcpy(buf, sizeof buf, file->true_filename); | |
| 2043 | − *tcc_basename(buf) = 0; | |
| 2044 | − pstrcat(buf, sizeof buf, (char *)tokc.str.data); | |
| 2041 | + q = (char *)tokc.str.data; | |
| 2042 | + buf[0] = 0; | |
| 2043 | + if (!IS_ABSPATH(q)) { | |
| 2044 | + /* prepend directory from real file */ | |
| 2045 | + pstrcpy(buf, sizeof buf, file->true_filename); | |
| 2046 | + *tcc_basename(buf) = 0; | |
| 2047 | + } | |
| 2048 | + pstrcat(buf, sizeof buf, q); | |
| 2045 | 2049 | tcc_debug_putfile(s1, buf); |
| 2046 | 2050 | } else if (parse_flags & PARSE_FLAG_ASM_FILE) |
| 2047 | 2051 | break; |
| @@ -3733,8 +3737,6 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) · 1685 unmodified lines | ||
| 3733 | 3737 | putdef(cs, "__CHAR_UNSIGNED__"); |
| 3734 | 3738 | if (s1->optimize > 0) |
| 3735 | 3739 | putdef(cs, "__OPTIMIZE__"); |
| 3736 | − if (s1->optimize == 's') | |
| 3737 | − putdef(cs, "__OPTIMIZE_SIZE__"); | |
| 3738 | 3740 | if (s1->option_pthread) |
| 3739 | 3741 | putdef(cs, "_REENTRANT"); |
| 3740 | 3742 | if (s1->leading_underscore) |
| @@ -5,7 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | TOP = .. |
| 6 | 6 | include $(TOP)/Makefile |
| 7 | 7 | VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP) |
| 8 | −CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS) | |
| 8 | +CFLAGS := $(filter-out -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS) | |
| 9 | 9 | |
| 10 | 10 | # what tests to run |
| 11 | 11 | TESTS = \ |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | #include "tcc.h" |
| 25 | 25 | |
| 26 | −#if !defined(ELF_OBJ_ONLY) || defined(TCC_TARGET_MACHO) | |
| 26 | +#ifdef NEED_RELOC_TYPE | |
| 27 | 27 | /* Returns 1 for a code relocation, 0 for a data relocation. For unknown |
| 28 | 28 | relocations, returns -1. */ |
| 29 | 29 | int code_reloc (int reloc_type) |
| @@ -109,7 +109,7 @@ int gotplt_entry_type (int reloc_type) · 79 unmodified lines | ||
| 109 | 109 | return -1; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | −#if !defined(TCC_TARGET_MACHO) || defined TCC_IS_NATIVE | |
| 112 | +#ifdef NEED_BUILD_GOT | |
| 113 | 113 | ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr) |
| 114 | 114 | { |
| 115 | 115 | Section *plt = s1->plt; |