History

bored...

/* 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.

grischka committed 4 years ago

Commit 56481d51 parent 1cd799818 files · +76 −124Browse files

Unified · Split

18 files
  1. .gitignore +1 −1
  2. Makefile +8 −15
  3. arm-asm.c +14 −15
  4. arm-link.c +3 −1
  5. arm64-link.c +4 −2
  6. configure +3 −3
  7. i386-asm.c +1 −0
  8. i386-link.c +3 −1
  9. libtcc.c +4 −42
  10. tcc-doc.texi +1 −1
  11. tcc.c +1 −1
  12. tcc.h +11 −17
  13. tccelf.c +6 −7
  14. tccgen.c +3 −5
  15. tccmacho.c +2 −4
  16. tccpp.c +8 −6
  17. tests/Makefile +1 −1
  18. x86_64-link.c +2 −2
.gitignore+1−1
@@ -28,7 +28,7 @@ c2str · 27 unmodified lines
2828 tags
2929 TAGS
3030 tcc.1
31−tcc.pod
31+*.pod
3232 tcc-doc.html
3333 tcc-doc.info
3434
Makefile+8−15
@@ -8,12 +8,6 @@ ifndef TOP · 7 unmodified lines
88 INCLUDED = no
99 endif
1010
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−
1711 ifeq ($(findstring $(MAKECMDGOALS),clean distclean),)
1812 include $(TOP)/config.mak
1913 endif
@@ -244,7 +238,7 @@ endif · 224 unmodified lines
244238
245239 # convert "include/tccdefs.h" to "tccdefs_.h"
246240 %_.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 $< $@
248242
249243 # target specific object rule
250244 $(X)%.o : %.c $(LIBTCC_INC)
@@ -261,7 +255,7 @@ tcc$(EXESUF): tcc.o $(LIBTCC) · 10 unmodified lines
261255 # Cross Tiny C Compilers
262256 # (the TCCDEFS_H dependency is only necessary for parallel makes,
263257 # 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.
265259 # This forces it to be made only once. Make normally tracks multiple paths
266260 # to the same goals and only remakes it once, but that doesn't work over
267261 # sub-makes like in this target)
@@ -332,6 +326,8 @@ tcc.1 : tcc-doc.pod · 64 unmodified lines
332326 %.pod : %.texi
333327 $(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@)
334328
329+doc : $(TCCDOCS)
330+
335331 # --------------------------------------------------------------------------
336332 # install
337333
@@ -410,10 +406,6 @@ tags : ; ctags $(TAGFILES) · 72 unmodified lines
410406 # cannot have both tags and TAGS on windows
411407 ETAGS : ; etags $(TAGFILES)
412408
413−# documentation
414−doc: tcc-doc.html tcc-doc.info tcc.1
415−
416−
417409 # create release tarball from *current* git branch (including tcc-doc.html
418410 # and converting two files to CRLF)
419411 TCC-VERSION = tcc-$(VERSION)
@@ -443,15 +435,16 @@ testspp.%: · 23 unmodified lines
443435 @$(MAKE) -C tests/pp $@
444436
445437 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
447439 @rm -f *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out *.dylib *_.h
448440 @$(MAKE) -s -C lib $@
449441 @$(MAKE) -s -C tests $@
450442
451443 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)
453446
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
455448
456449 help:
457450 @echo "make"
arm-asm.c+14−15
@@ -77,21 +77,6 @@ static int asm_parse_vfp_regvar(int t, int double_precision) · 76 unmodified lines
7777 return -1;
7878 }
7979
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−
9580 /* Parse a text containing operand and store the result in OP */
9681 static void parse_operand(TCCState *s1, Operand *op)
9782 {
@@ -2240,6 +2225,20 @@ static void asm_floating_point_data_processing_opcode(TCCState *s1, int token) { · 2142 unmodified lines
22402225 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);
22412226 }
22422227
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+
22432242 static void asm_floating_point_status_register_opcode(TCCState* s1, int token)
22442243 {
22452244 uint8_t coprocessor = CP_SINGLE_PRECISION_FLOAT;
arm-link.c+3−1
@@ -28,6 +28,7 @@ enum float_abi { · 27 unmodified lines
2828
2929 #include "tcc.h"
3030
31+#ifdef NEED_RELOC_TYPE
3132 /* Returns 1 for a code relocation, 0 for a data relocation. For unknown
3233 relocations, returns -1. */
3334 int code_reloc (int reloc_type)
@@ -107,7 +108,7 @@ int gotplt_entry_type (int reloc_type) · 73 unmodified lines
107108 return -1;
108109 }
109110
110−#ifndef TCC_TARGET_PE
111+#ifdef NEED_BUILD_GOT
111112 ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)
112113 {
113114 Section *plt = s1->plt;
@@ -177,6 +178,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 63 unmodified lines
177178 }
178179 }
179180 #endif
181+#endif
180182
181183 void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
182184 {
arm64-link.c+4−2
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222
2323 #include "tcc.h"
2424
25+#ifdef NEED_RELOC_TYPE
2526 /* Returns 1 for a code relocation, 0 for a data relocation. For unknown
2627 relocations, returns -1. */
2728 int code_reloc (int reloc_type)
@@ -91,7 +92,7 @@ int gotplt_entry_type (int reloc_type) · 63 unmodified lines
9192 return -1;
9293 }
9394
94−__attribute__((unused))
95+#ifdef NEED_BUILD_GOT
9596 ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)
9697 {
9798 Section *plt = s1->plt;
@@ -111,7 +112,6 @@ ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_ · 13 unmodified lines
111112
112113 /* relocate the PLT: compute addresses and offsets in the PLT now that final
113114 address for PLT and GOT are known (see fill_program_header) */
114−__attribute__((unused))
115115 ST_FUNC void relocate_plt(TCCState *s1)
116116 {
117117 uint8_t *p, *p_end;
@@ -166,6 +166,8 @@ ST_FUNC void relocate_plt(TCCState *s1) · 48 unmodified lines
166166 }
167167 }
168168 }
169+#endif
170+#endif
169171
170172 void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
171173 {
configure+3−3
@@ -27,8 +27,7 @@ mandir="" · 26 unmodified lines
2727 infodir=""
2828 sysroot=""
2929 cross_prefix=""
30−test -z "$CC" && CC="gcc"
31−test -z "$cc" && cc="$CC"
30+cc="gcc"
3231 ar="ar"
3332 bigendian="no"
3433 mingw32="no"
@@ -46,7 +45,7 @@ confvars= · 11 unmodified lines
4645 suggest="yes"
4746 gcc_major=0
4847 gcc_minor=0
49−cc_name="$cc"
48+cc_name="gcc"
5049 ar_set=
5150 darwin=
5251 cpu=
@@ -408,6 +407,7 @@ if test "$cc_name" != "tcc"; then · 355 unmodified lines
408407 OPT1="-Wdeclaration-after-statement -fno-strict-aliasing"
409408 # we want -Wno- but gcc does not always reject unknown -Wno- options
410409 OPT2="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation"
410+ OPT2="$OPT2 -Wstringop-truncation"
411411 if test "$cc_name" = "clang"; then
412412 OPT1="$OPT1 -fheinous-gnu-extensions"
413413 OPT2="$OPT2 -Wstring-plus-int"
i386-asm.c+1−0
@@ -833,6 +833,7 @@ again: · 832 unmodified lines
833833 goto next;
834834 alltypes |= ops[i].type;
835835 }
836+ (void)alltypes; /* maybe unused */
836837 /* all is matching ! */
837838 break;
838839 next: ;
i386-link.c+3−1
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323
2424 #include "tcc.h"
2525
26−#ifndef ELF_OBJ_ONLY
26+#ifdef NEED_RELOC_TYPE
2727 /* Returns 1 for a code relocation, 0 for a data relocation. For unknown
2828 relocations, returns -1. */
2929 int code_reloc (int reloc_type)
@@ -92,6 +92,7 @@ int gotplt_entry_type (int reloc_type) · 62 unmodified lines
9292 return -1;
9393 }
9494
95+#ifdef NEED_BUILD_GOT
9596 ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)
9697 {
9798 Section *plt = s1->plt;
@@ -169,6 +170,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 71 unmodified lines
169170 }
170171 }
171172 #endif
173+#endif
172174
173175 void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
174176 {
libtcc.c+4−42
@@ -836,6 +836,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 835 unmodified lines
836836 tcc_free(s1->tcc_lib_path);
837837 tcc_free(s1->soname);
838838 tcc_free(s1->rpath);
839+ tcc_free(s1->elf_entryname);
839840 tcc_free(s1->init_symbol);
840841 tcc_free(s1->fini_symbol);
841842 tcc_free(s1->outfile);
@@ -1567,23 +1568,6 @@ static const TCCOption tcc_options[] = { · 725 unmodified lines
15671568 { NULL, 0, 0 },
15681569 };
15691570
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−
15871571 typedef struct FlagDef {
15881572 uint16_t offset;
15891573 uint16_t flags;
@@ -1837,9 +1821,6 @@ reparse: · 247 unmodified lines
18371821 break;
18381822 #endif
18391823 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 */
18431824 s->do_debug = 1;
18441825 s->dwarf = DWARF_VERSION;
18451826 if (*optarg == 'd') {
@@ -1847,8 +1828,6 @@ reparse: · 1 unmodified line
18471828 if (!strncmp(optarg,"dwarf-",6))
18481829 s->dwarf = atoi(optarg + 6);
18491830 }
1850− else if (isnum(*optarg))
1851− s->do_debug = atoi(optarg);
18521831 break;
18531832 case TCC_OPTION_c:
18541833 x = TCC_OUTPUT_OBJ;
@@ -1873,21 +1852,8 @@ reparse: · 18 unmodified lines
18731852 s->static_link = 1;
18741853 break;
18751854 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;
18911857 break;
18921858 case TCC_OPTION_shared:
18931859 x = TCC_OUTPUT_DLL;
@@ -2018,11 +1984,7 @@ reparse: · 124 unmodified lines
20181984 s->filetype = x | (s->filetype & ~AFF_TYPE_MASK);
20191985 break;
20201986 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);
20261988 break;
20271989 case TCC_OPTION_print_search_dirs:
20281990 x = OPT_PRINT_DIRS;
tcc-doc.texi+1−1
@@ -349,7 +349,7 @@ Turn on/off linking of all objects in archives. · 348 unmodified lines
349349 Debugger options:
350350
351351 @table @option
352−@item -g[x]
352+@item -g
353353 Generate run time stab debug information so that you get clear run time
354354 error messages: @code{ test.c:68: in function 'test5()': dereferencing
355355 invalid pointer} instead of the laconic @code{Segmentation
tcc.c+1−1
@@ -58,7 +58,7 @@ static const char help[] = · 57 unmodified lines
5858 " -soname set name for shared library to be used at runtime\n"
5959 " -Wl,-opt[=val] set linker option (see tcc -hh)\n"
6060 "Debugger options:\n"
61− " -g[x] generate stab runtime debug info\n"
61+ " -g generate stab runtime debug info\n"
6262 " -gdwarf[-x] generate dwarf runtime debug info\n"
6363 #ifdef CONFIG_TCC_BCHECK
6464 " -b compile with built-in memory and bounds checker (implies -g)\n"
tcc.h+11−17
@@ -258,9 +258,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 257 unmodified lines
258258
259259 /* path to find crt1.o, crti.o and crtn.o */
260260 #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)
264262 #endif
265263
266264 #ifndef CONFIG_USR_INCLUDE
@@ -277,8 +275,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 10 unmodified lines
277275 # define CONFIG_TCC_SYSINCLUDEPATHS \
278276 "{B}/include" \
279277 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
280− ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/include" \
281− ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/include" \
282278 ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE)
283279 # endif
284280 #endif
@@ -290,8 +286,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 5 unmodified lines
290286 # else
291287 # define CONFIG_TCC_LIBPATHS \
292288 ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
293− ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib" \
294− ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/lib" \
295289 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
296290 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
297291 # endif
@@ -826,7 +820,7 @@ struct TCCState { · 528 unmodified lines
826820 char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
827821 char *soname; /* as specified on the command line (-soname) */
828822 char *rpath; /* as specified on the command line (-Wl,-rpath=) */
829−
823+ char *elf_entryname; /* "_start" unless set */
830824 char *init_symbol; /* symbols to call at load-time (not used currently) */
831825 char *fini_symbol; /* symbols to call at unload-time (not used currently) */
832826
@@ -975,8 +969,6 @@ struct TCCState { · 142 unmodified lines
975969 Section *verneed_section;
976970 #endif
977971
978− char *elf_entryname;
979−
980972 #ifdef TCC_IS_NATIVE
981973 const char *runtime_main;
982974 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
15451537 ST_FUNC int tcc_load_archive(TCCState *s1, int fd, int alacarte);
15461538 ST_FUNC void add_array(TCCState *s1, const char *sec, int c);
15471539
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
15511540 ST_FUNC struct sym_attr *get_sym_attr(TCCState *s1, int index, int alloc);
15521541 ST_FUNC addr_t get_sym_addr(TCCState *s, const char *name, int err, int forc);
15531542 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
15701559
15711560 /* ------------ xxx-link.c ------------ */
15721561
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);
15731565 /* Whether to generate a GOT/PLT entry and when. NO_GOTPLT_ENTRY is first so
15741566 that unknown relocation don't create a GOT or PLT entry */
15751567 enum gotplt_entry {
@@ -1578,15 +1570,17 @@ enum gotplt_entry { · 2 unmodified lines
15781570 AUTO_GOTPLT_ENTRY, /* generate if sym is UNDEF */
15791571 ALWAYS_GOTPLT_ENTRY /* always generate (eg. PLTOFF relocs) */
15801572 };
1573+#define NEED_RELOC_TYPE
15811574
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
15861576 ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr);
15871577 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+
15881581 #endif
15891582 #endif
1583+
15901584 ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val);
15911585
15921586 /* ------------ xxx-gen.c ------------ */
tccelf.c+6−7
@@ -671,7 +671,7 @@ version_add (TCCState *s1) · 670 unmodified lines
671671 }
672672 dt_verneednum = nb_entries;
673673 }
674−#endif
674+#endif /* ndef ELF_OBJ_ONLY */
675675
676676 /* add an elf symbol : check if it is already defined and patch
677677 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
11211121 }
11221122 #endif
11231123
1124−#if !defined(ELF_OBJ_ONLY) || (defined(TCC_TARGET_MACHO) && defined TCC_IS_NATIVE)
1124+#ifdef NEED_BUILD_GOT
11251125 static void build_got(TCCState *s1)
11261126 {
11271127 /* if no got, then create it */
@@ -1354,7 +1354,7 @@ redo: · 226 unmodified lines
13541354 s1->plt->reloc->sh_info = s1->got->sh_num;
13551355
13561356 }
1357−#endif
1357+#endif /* def NEED_BUILD_GOT */
13581358
13591359 ST_FUNC int set_global_sym(TCCState *s1, const char *name, Section *sec, addr_t offs)
13601360 {
@@ -1506,7 +1506,7 @@ ST_FUNC void tcc_add_btstub(TCCState *s1) · 145 unmodified lines
15061506 cstr_free(&cstr);
15071507 set_local_sym(s1, &"___rt_info"[!s1->leading_underscore], s, o);
15081508 }
1509−#endif
1509+#endif /* def CONFIG_TCC_BACKTRACE */
15101510
15111511 static void tcc_tcov_add_file(TCCState *s1, const char *filename)
15121512 {
@@ -1615,7 +1615,7 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 102 unmodified lines
16151615 #endif
16161616 }
16171617 }
1618−#endif
1618+#endif /* ndef TCC_TARGET_PE */
16191619
16201620 /* add various standard linker symbols (must be done after the
16211621 sections are filled (for example after allocating common
@@ -1688,7 +1688,6 @@ ST_FUNC void resolve_common_syms(TCCState *s1) · 66 unmodified lines
16881688 }
16891689
16901690 #ifndef ELF_OBJ_ONLY
1691−
16921691 ST_FUNC void fill_got_entry(TCCState *s1, ElfW_Rel *rel)
16931692 {
16941693 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
37713770
37723771 static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed)
37733772 {
3774− char filename[1024], libname[1016];
3773+ char filename[1024], libname[1024];
37753774 int t, group, nblibs = 0, ret = 0;
37763775 char **libs = NULL;
37773776
tccgen.c+3−5
@@ -1380,7 +1380,7 @@ static void tcc_debug_fix_anon(CType *t) · 1379 unmodified lines
13801380 if ((t->t & VT_BTYPE) == VT_STRUCT && t->ref->c != -1)
13811381 for (i = 0; i < n_debug_anon_hash; i++)
13821382 if (t->ref == debug_anon_hash[i].type) {
1383− Sym sym = { .type = *t };
1383+ Sym sym = {0}; sym .type = *t ;
13841384
13851385 debug_type = tcc_get_dwarf_info(s1, &sym);
13861386 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
16281628 debug_type = tcc_debug_find(t, 1);
16291629 if (debug_type == -1) {
16301630 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) ;
16331632
16341633 pos_type = tcc_get_dwarf_info(s1, &sym);
16351634 debug_type = tcc_debug_add(t, 1);
@@ -1705,8 +1704,7 @@ static int tcc_get_dwarf_info(TCCState *s1, Sym *s) · 69 unmodified lines
17051704 }
17061705 else if (type == (VT_PTR | VT_ARRAY)) {
17071706 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 ;
17101708
17111709 sub_type = tcc_get_dwarf_info(s1, &sym);
17121710 i = dwarf_info_section->data_offset;
tccmacho.c+2−4
@@ -262,8 +262,7 @@ static void * add_lc(struct macho *mo, uint32_t cmd, uint32_t cmdsize) · 261 unmodified lines
262262 static struct segment_command_64 * add_segment(struct macho *mo, const char *name)
263263 {
264264 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);
267266 mo->seg2lc[mo->nseg++] = mo->nlc - 1;
268267 return sc;
269268 }
@@ -283,8 +282,7 @@ static int add_section(struct macho *mo, struct segment_command_64 **_seg, const · 13 unmodified lines
283282 seg = tcc_realloc(seg, sizeof(*seg) + seg->nsects * sizeof(*sec));
284283 sec = (struct section_64*)((char*)seg + sizeof(*seg)) + ret;
285284 memset(sec, 0, sizeof(*sec));
286− strncpy(sec->sectname, name, 16-1);
287− sec->sectname[16-1] = '\0';
285+ strncpy(sec->sectname, name, 16);
288286 strncpy(sec->segname, seg->segname, 16);
289287 *_seg = seg;
290288 return ret;
tccpp.c+8−6
@@ -2038,10 +2038,14 @@ include_done: · 2037 unmodified lines
20382038 if (tok == TOK_STR) {
20392039 if (file->true_filename == file->filename)
20402040 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);
20452049 tcc_debug_putfile(s1, buf);
20462050 } else if (parse_flags & PARSE_FLAG_ASM_FILE)
20472051 break;
@@ -3733,8 +3737,6 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) · 1685 unmodified lines
37333737 putdef(cs, "__CHAR_UNSIGNED__");
37343738 if (s1->optimize > 0)
37353739 putdef(cs, "__OPTIMIZE__");
3736− if (s1->optimize == 's')
3737− putdef(cs, "__OPTIMIZE_SIZE__");
37383740 if (s1->option_pthread)
37393741 putdef(cs, "_REENTRANT");
37403742 if (s1->leading_underscore)
tests/Makefile+1−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 TOP = ..
66 include $(TOP)/Makefile
77 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)
99
1010 # what tests to run
1111 TESTS = \
x86_64-link.c+2−2
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323
2424 #include "tcc.h"
2525
26−#if !defined(ELF_OBJ_ONLY) || defined(TCC_TARGET_MACHO)
26+#ifdef NEED_RELOC_TYPE
2727 /* Returns 1 for a code relocation, 0 for a data relocation. For unknown
2828 relocations, returns -1. */
2929 int code_reloc (int reloc_type)
@@ -109,7 +109,7 @@ int gotplt_entry_type (int reloc_type) · 79 unmodified lines
109109 return -1;
110110 }
111111
112−#if !defined(TCC_TARGET_MACHO) || defined TCC_IS_NATIVE
112+#ifdef NEED_BUILD_GOT
113113 ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)
114114 {
115115 Section *plt = s1->plt;

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