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
28tags28tags
29TAGS29TAGS
30tcc.130tcc.1
31tcc.pod31*.pod
32tcc-doc.html32tcc-doc.html
33tcc-doc.info33tcc-doc.info
34 34
Makefile+8−15
@@ -8,12 +8,6 @@ ifndef TOP · 7 unmodified lines
8 INCLUDED = no8 INCLUDED = no
9endif9endif
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
17ifeq ($(findstring $(MAKECMDGOALS),clean distclean),)11ifeq ($(findstring $(MAKECMDGOALS),clean distclean),)
18 include $(TOP)/config.mak12 include $(TOP)/config.mak
19endif13endif
@@ -244,7 +238,7 @@ endif · 224 unmodified lines
244 238
245# convert "include/tccdefs.h" to "tccdefs_.h"239# convert "include/tccdefs.h" to "tccdefs_.h"
246%_.h : include/%.h conftest.c240%_.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# target specific object rule243# target specific object rule
250$(X)%.o : %.c $(LIBTCC_INC)244$(X)%.o : %.c $(LIBTCC_INC)
@@ -261,7 +255,7 @@ tcc$(EXESUF): tcc.o $(LIBTCC) · 10 unmodified lines
261# Cross Tiny C Compilers255# Cross Tiny C Compilers
262# (the TCCDEFS_H dependency is only necessary for parallel makes,256# (the TCCDEFS_H dependency is only necessary for parallel makes,
263# ala 'make -j x86_64-tcc i386-tcc tcc', which would create multiple257# 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# This forces it to be made only once. Make normally tracks multiple paths259# This forces it to be made only once. Make normally tracks multiple paths
266# to the same goals and only remakes it once, but that doesn't work over260# to the same goals and only remakes it once, but that doesn't work over
267# sub-makes like in this target)261# sub-makes like in this target)
@@ -332,6 +326,8 @@ tcc.1 : tcc-doc.pod · 64 unmodified lines
332%.pod : %.texi326%.pod : %.texi
333 $(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@)327 $(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@)
334 328
329doc : $(TCCDOCS)
330
335# --------------------------------------------------------------------------331# --------------------------------------------------------------------------
336# install332# install
337 333
@@ -410,10 +406,6 @@ tags : ; ctags $(TAGFILES) · 72 unmodified lines
410# cannot have both tags and TAGS on windows406# cannot have both tags and TAGS on windows
411ETAGS : ; etags $(TAGFILES)407ETAGS : ; etags $(TAGFILES)
412 408
413# documentation
414doc: tcc-doc.html tcc-doc.info tcc.1
415
416
417# create release tarball from *current* git branch (including tcc-doc.html409# create release tarball from *current* git branch (including tcc-doc.html
418# and converting two files to CRLF)410# and converting two files to CRLF)
419TCC-VERSION = tcc-$(VERSION)411TCC-VERSION = tcc-$(VERSION)
@@ -443,15 +435,16 @@ testspp.%: · 23 unmodified lines
443 @$(MAKE) -C tests/pp $@435 @$(MAKE) -C tests/pp $@
444 436
445clean:437clean:
446 @rm -f tcc$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tcc.pod tags ETAGS438 @rm -f tcc$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tags ETAGS *.pod
447 @rm -f *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out *.dylib *_.h439 @rm -f *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out *.dylib *_.h
448 @$(MAKE) -s -C lib $@440 @$(MAKE) -s -C lib $@
449 @$(MAKE) -s -C tests $@441 @$(MAKE) -s -C tests $@
450 442
451distclean: clean443distclean: clean
452 @rm -fv config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html444 @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 FORCE447.PHONY: all clean test tar tags ETAGS doc distclean install uninstall FORCE
455 448
456help:449help:
457 @echo "make"450 @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
77 return -1;77 return -1;
78}78}
79 79
80__attribute__((unused))
81static 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/* Parse a text containing operand and store the result in OP */80/* Parse a text containing operand and store the result in OP */
96static void parse_operand(TCCState *s1, Operand *op)81static 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 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);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
2228static 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
2243static void asm_floating_point_status_register_opcode(TCCState* s1, int token)2242static void asm_floating_point_status_register_opcode(TCCState* s1, int token)
2244{2243{
2245 uint8_t coprocessor = CP_SINGLE_PRECISION_FLOAT;2244 uint8_t coprocessor = CP_SINGLE_PRECISION_FLOAT;
arm-link.c+3−1
@@ -28,6 +28,7 @@ enum float_abi { · 27 unmodified lines
28 28
29#include "tcc.h"29#include "tcc.h"
30 30
31#ifdef NEED_RELOC_TYPE
31/* Returns 1 for a code relocation, 0 for a data relocation. For unknown32/* Returns 1 for a code relocation, 0 for a data relocation. For unknown
32 relocations, returns -1. */33 relocations, returns -1. */
33int code_reloc (int reloc_type)34int code_reloc (int reloc_type)
@@ -107,7 +108,7 @@ int gotplt_entry_type (int reloc_type) · 73 unmodified lines
107 return -1;108 return -1;
108}109}
109 110
110#ifndef TCC_TARGET_PE111#ifdef NEED_BUILD_GOT
111ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)112ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)
112{113{
113 Section *plt = s1->plt;114 Section *plt = s1->plt;
@@ -177,6 +178,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 63 unmodified lines
177 }178 }
178}179}
179#endif180#endif
181#endif
180 182
181void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)183void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
182{184{
arm64-link.c+4−2
@@ -22,6 +22,7 @@ · 21 unmodified lines
22 22
23#include "tcc.h"23#include "tcc.h"
24 24
25#ifdef NEED_RELOC_TYPE
25/* Returns 1 for a code relocation, 0 for a data relocation. For unknown26/* Returns 1 for a code relocation, 0 for a data relocation. For unknown
26 relocations, returns -1. */27 relocations, returns -1. */
27int code_reloc (int reloc_type)28int code_reloc (int reloc_type)
@@ -91,7 +92,7 @@ int gotplt_entry_type (int reloc_type) · 63 unmodified lines
91 return -1;92 return -1;
92}93}
93 94
94__attribute__((unused))95#ifdef NEED_BUILD_GOT
95ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)96ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)
96{97{
97 Section *plt = s1->plt;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/* relocate the PLT: compute addresses and offsets in the PLT now that final113/* relocate the PLT: compute addresses and offsets in the PLT now that final
113 address for PLT and GOT are known (see fill_program_header) */114 address for PLT and GOT are known (see fill_program_header) */
114__attribute__((unused))
115ST_FUNC void relocate_plt(TCCState *s1)115ST_FUNC void relocate_plt(TCCState *s1)
116{116{
117 uint8_t *p, *p_end;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
170void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)172void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
171{173{
configure+3−3
@@ -27,8 +27,7 @@ mandir="" · 26 unmodified lines
27infodir=""27infodir=""
28sysroot=""28sysroot=""
29cross_prefix=""29cross_prefix=""
30test -z "$CC" && CC="gcc"30cc="gcc"
31test -z "$cc" && cc="$CC"
32ar="ar"31ar="ar"
33bigendian="no"32bigendian="no"
34mingw32="no"33mingw32="no"
@@ -46,7 +45,7 @@ confvars= · 11 unmodified lines
46suggest="yes"45suggest="yes"
47gcc_major=046gcc_major=0
48gcc_minor=047gcc_minor=0
49cc_name="$cc"48cc_name="gcc"
50ar_set=49ar_set=
51darwin=50darwin=
52cpu=51cpu=
@@ -408,6 +407,7 @@ if test "$cc_name" != "tcc"; then · 355 unmodified lines
408 OPT1="-Wdeclaration-after-statement -fno-strict-aliasing"407 OPT1="-Wdeclaration-after-statement -fno-strict-aliasing"
409 # we want -Wno- but gcc does not always reject unknown -Wno- options408 # we want -Wno- but gcc does not always reject unknown -Wno- options
410 OPT2="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation"409 OPT2="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation"
410 OPT2="$OPT2 -Wstringop-truncation"
411 if test "$cc_name" = "clang"; then411 if test "$cc_name" = "clang"; then
412 OPT1="$OPT1 -fheinous-gnu-extensions"412 OPT1="$OPT1 -fheinous-gnu-extensions"
413 OPT2="$OPT2 -Wstring-plus-int"413 OPT2="$OPT2 -Wstring-plus-int"
i386-asm.c+1−0
@@ -833,6 +833,7 @@ again: · 832 unmodified lines
833 goto next;833 goto next;
834 alltypes |= ops[i].type;834 alltypes |= ops[i].type;
835 }835 }
836 (void)alltypes; /* maybe unused */
836 /* all is matching ! */837 /* all is matching ! */
837 break;838 break;
838 next: ;839 next: ;
i386-link.c+3−1
@@ -23,7 +23,7 @@ · 22 unmodified lines
23 23
24#include "tcc.h"24#include "tcc.h"
25 25
26#ifndef ELF_OBJ_ONLY26#ifdef NEED_RELOC_TYPE
27/* Returns 1 for a code relocation, 0 for a data relocation. For unknown27/* Returns 1 for a code relocation, 0 for a data relocation. For unknown
28 relocations, returns -1. */28 relocations, returns -1. */
29int code_reloc (int reloc_type)29int code_reloc (int reloc_type)
@@ -92,6 +92,7 @@ int gotplt_entry_type (int reloc_type) · 62 unmodified lines
92 return -1;92 return -1;
93}93}
94 94
95#ifdef NEED_BUILD_GOT
95ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)96ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)
96{97{
97 Section *plt = s1->plt;98 Section *plt = s1->plt;
@@ -169,6 +170,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 71 unmodified lines
169 }170 }
170}171}
171#endif172#endif
173#endif
172 174
173void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)175void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
174{176{
libtcc.c+4−42
@@ -836,6 +836,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 835 unmodified lines
836 tcc_free(s1->tcc_lib_path);836 tcc_free(s1->tcc_lib_path);
837 tcc_free(s1->soname);837 tcc_free(s1->soname);
838 tcc_free(s1->rpath);838 tcc_free(s1->rpath);
839 tcc_free(s1->elf_entryname);
839 tcc_free(s1->init_symbol);840 tcc_free(s1->init_symbol);
840 tcc_free(s1->fini_symbol);841 tcc_free(s1->fini_symbol);
841 tcc_free(s1->outfile);842 tcc_free(s1->outfile);
@@ -1567,23 +1568,6 @@ static const TCCOption tcc_options[] = { · 725 unmodified lines
1567 { NULL, 0, 0 },1568 { NULL, 0, 0 },
1568};1569};
1569 1570
1570typedef struct stdvalue {
1571 uint32_t cversion;
1572 const char * name;
1573} stdvalue;
1574
1575/* accepted values for the -std= option */
1576static 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
1587typedef struct FlagDef {1571typedef struct FlagDef {
1588 uint16_t offset;1572 uint16_t offset;
1589 uint16_t flags;1573 uint16_t flags;
@@ -1837,9 +1821,6 @@ reparse: · 247 unmodified lines
1837 break;1821 break;
1838#endif1822#endif
1839 case TCC_OPTION_g: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 s->do_debug = 1;1824 s->do_debug = 1;
1844 s->dwarf = DWARF_VERSION;1825 s->dwarf = DWARF_VERSION;
1845 if (*optarg == 'd') {1826 if (*optarg == 'd') {
@@ -1847,8 +1828,6 @@ reparse: · 1 unmodified line
1847 if (!strncmp(optarg,"dwarf-",6))1828 if (!strncmp(optarg,"dwarf-",6))
1848 s->dwarf = atoi(optarg + 6);1829 s->dwarf = atoi(optarg + 6);
1849 }1830 }
1850 else if (isnum(*optarg))
1851 s->do_debug = atoi(optarg);
1852 break;1831 break;
1853 case TCC_OPTION_c:1832 case TCC_OPTION_c:
1854 x = TCC_OUTPUT_OBJ;1833 x = TCC_OUTPUT_OBJ;
@@ -1873,21 +1852,8 @@ reparse: · 18 unmodified lines
1873 s->static_link = 1;1852 s->static_link = 1;
1874 break;1853 break;
1875 case TCC_OPTION_std:1854 case TCC_OPTION_std:
1876 x = 0;1855 if (strcmp(optarg, "=c11") == 0)
1877 if (*optarg == '=') {1856 s->cversion = 201112;
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
1891 break;1857 break;
1892 case TCC_OPTION_shared:1858 case TCC_OPTION_shared:
1893 x = TCC_OUTPUT_DLL;1859 x = TCC_OUTPUT_DLL;
@@ -2018,11 +1984,7 @@ reparse: · 124 unmodified lines
2018 s->filetype = x | (s->filetype & ~AFF_TYPE_MASK);1984 s->filetype = x | (s->filetype & ~AFF_TYPE_MASK);
2019 break;1985 break;
2020 case TCC_OPTION_O:1986 case TCC_OPTION_O:
2021 /* Use "-O" as alias for "-O1". */1987 s->optimize = atoi(optarg);
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;
2026 break;1988 break;
2027 case TCC_OPTION_print_search_dirs:1989 case TCC_OPTION_print_search_dirs:
2028 x = OPT_PRINT_DIRS;1990 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
349Debugger options:349Debugger options:
350 350
351@table @option351@table @option
352@item -g[x]352@item -g
353Generate run time stab debug information so that you get clear run time353Generate run time stab debug information so that you get clear run time
354error messages: @code{ test.c:68: in function 'test5()': dereferencing354error messages: @code{ test.c:68: in function 'test5()': dereferencing
355invalid pointer} instead of the laconic @code{Segmentation355invalid pointer} instead of the laconic @code{Segmentation
tcc.c+1−1
@@ -58,7 +58,7 @@ static const char help[] = · 57 unmodified lines
58 " -soname set name for shared library to be used at runtime\n"58 " -soname set name for shared library to be used at runtime\n"
59 " -Wl,-opt[=val] set linker option (see tcc -hh)\n"59 " -Wl,-opt[=val] set linker option (see tcc -hh)\n"
60 "Debugger options:\n"60 "Debugger options:\n"
61 " -g[x] generate stab runtime debug info\n"61 " -g generate stab runtime debug info\n"
62 " -gdwarf[-x] generate dwarf runtime debug info\n"62 " -gdwarf[-x] generate dwarf runtime debug info\n"
63#ifdef CONFIG_TCC_BCHECK63#ifdef CONFIG_TCC_BCHECK
64 " -b compile with built-in memory and bounds checker (implies -g)\n"64 " -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
258 258
259/* path to find crt1.o, crti.o and crtn.o */259/* path to find crt1.o, crti.o and crtn.o */
260#ifndef CONFIG_TCC_CRTPREFIX260#ifndef CONFIG_TCC_CRTPREFIX
261# define CONFIG_TCC_CRTPREFIX \261# define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR)
262 ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
263 ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib"
264#endif262#endif
265 263
266#ifndef CONFIG_USR_INCLUDE264#ifndef CONFIG_USR_INCLUDE
@@ -277,8 +275,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 10 unmodified lines
277# define CONFIG_TCC_SYSINCLUDEPATHS \275# define CONFIG_TCC_SYSINCLUDEPATHS \
278 "{B}/include" \276 "{B}/include" \
279 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \277 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
280 ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/include" \
281 ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/include" \
282 ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE)278 ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE)
283# endif279# endif
284#endif280#endif
@@ -290,8 +286,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 5 unmodified lines
290# else286# else
291# define CONFIG_TCC_LIBPATHS \287# define CONFIG_TCC_LIBPATHS \
292 ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \288 ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
293 ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib" \
294 ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/lib" \
295 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \289 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
296 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)290 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
297# endif291# endif
@@ -826,7 +820,7 @@ struct TCCState { · 528 unmodified lines
826 char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */820 char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
827 char *soname; /* as specified on the command line (-soname) */821 char *soname; /* as specified on the command line (-soname) */
828 char *rpath; /* as specified on the command line (-Wl,-rpath=) */822 char *rpath; /* as specified on the command line (-Wl,-rpath=) */
829 823 char *elf_entryname; /* "_start" unless set */
830 char *init_symbol; /* symbols to call at load-time (not used currently) */824 char *init_symbol; /* symbols to call at load-time (not used currently) */
831 char *fini_symbol; /* symbols to call at unload-time (not used currently) */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 Section *verneed_section;969 Section *verneed_section;
976#endif970#endif
977 971
978 char *elf_entryname;
979
980#ifdef TCC_IS_NATIVE972#ifdef TCC_IS_NATIVE
981 const char *runtime_main;973 const char *runtime_main;
982 void **runtime_mem;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
1545ST_FUNC int tcc_load_archive(TCCState *s1, int fd, int alacarte);1537ST_FUNC int tcc_load_archive(TCCState *s1, int fd, int alacarte);
1546ST_FUNC void add_array(TCCState *s1, const char *sec, int c);1538ST_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)
1549ST_FUNC void build_got_entries(TCCState *s1);
1550#endif
1551ST_FUNC struct sym_attr *get_sym_attr(TCCState *s1, int index, int alloc);1540ST_FUNC struct sym_attr *get_sym_attr(TCCState *s1, int index, int alloc);
1552ST_FUNC addr_t get_sym_addr(TCCState *s, const char *name, int err, int forc);1541ST_FUNC addr_t get_sym_addr(TCCState *s, const char *name, int err, int forc);
1553ST_FUNC void list_elf_symbols(TCCState *s, void *ctx,1542ST_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/* ------------ xxx-link.c ------------ */1560/* ------------ xxx-link.c ------------ */
1572 1561
1562#if !defined ELF_OBJ_ONLY || defined TCC_TARGET_MACHO
1563ST_FUNC int code_reloc (int reloc_type);
1564ST_FUNC int gotplt_entry_type (int reloc_type);
1573/* Whether to generate a GOT/PLT entry and when. NO_GOTPLT_ENTRY is first so1565/* Whether to generate a GOT/PLT entry and when. NO_GOTPLT_ENTRY is first so
1574 that unknown relocation don't create a GOT or PLT entry */1566 that unknown relocation don't create a GOT or PLT entry */
1575enum gotplt_entry {1567enum gotplt_entry {
@@ -1578,15 +1570,17 @@ enum gotplt_entry { · 2 unmodified lines
1578 AUTO_GOTPLT_ENTRY, /* generate if sym is UNDEF */1570 AUTO_GOTPLT_ENTRY, /* generate if sym is UNDEF */
1579 ALWAYS_GOTPLT_ENTRY /* always generate (eg. PLTOFF relocs) */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)1575#if !defined TCC_TARGET_MACHO || defined TCC_IS_NATIVE
1583ST_FUNC int code_reloc (int reloc_type);
1584ST_FUNC int gotplt_entry_type (int reloc_type);
1585#if !defined(TCC_TARGET_MACHO) || defined TCC_IS_NATIVE
1586ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr);1576ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr);
1587ST_FUNC void relocate_plt(TCCState *s1);1577ST_FUNC void relocate_plt(TCCState *s1);
1578ST_FUNC void build_got_entries(TCCState *s1); /* in tccelf.c */
1579#define NEED_BUILD_GOT
1580
1588#endif1581#endif
1589#endif1582#endif
1583
1590ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val);1584ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val);
1591 1585
1592/* ------------ xxx-gen.c ------------ */1586/* ------------ xxx-gen.c ------------ */
tccelf.c+6−7
@@ -671,7 +671,7 @@ version_add (TCCState *s1) · 670 unmodified lines
671 }671 }
672 dt_verneednum = nb_entries;672 dt_verneednum = nb_entries;
673}673}
674#endif674#endif /* ndef ELF_OBJ_ONLY */
675 675
676/* add an elf symbol : check if it is already defined and patch676/* add an elf symbol : check if it is already defined and patch
677 it. Return symbol index. NOTE that sh_num can be SHN_UNDEF. */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#endif1122#endif
1123 1123
1124#if !defined(ELF_OBJ_ONLY) || (defined(TCC_TARGET_MACHO) && defined TCC_IS_NATIVE)1124#ifdef NEED_BUILD_GOT
1125static void build_got(TCCState *s1)1125static void build_got(TCCState *s1)
1126{1126{
1127 /* if no got, then create it */1127 /* if no got, then create it */
@@ -1354,7 +1354,7 @@ redo: · 226 unmodified lines
1354 s1->plt->reloc->sh_info = s1->got->sh_num;1354 s1->plt->reloc->sh_info = s1->got->sh_num;
1355 1355
1356}1356}
1357#endif1357#endif /* def NEED_BUILD_GOT */
1358 1358
1359ST_FUNC int set_global_sym(TCCState *s1, const char *name, Section *sec, addr_t offs)1359ST_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 cstr_free(&cstr);1506 cstr_free(&cstr);
1507 set_local_sym(s1, &"___rt_info"[!s1->leading_underscore], s, o);1507 set_local_sym(s1, &"___rt_info"[!s1->leading_underscore], s, o);
1508}1508}
1509#endif1509#endif /* def CONFIG_TCC_BACKTRACE */
1510 1510
1511static void tcc_tcov_add_file(TCCState *s1, const char *filename)1511static 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#endif1615#endif
1616 }1616 }
1617}1617}
1618#endif1618#endif /* ndef TCC_TARGET_PE */
1619 1619
1620/* add various standard linker symbols (must be done after the1620/* add various standard linker symbols (must be done after the
1621 sections are filled (for example after allocating common1621 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#ifndef ELF_OBJ_ONLY1690#ifndef ELF_OBJ_ONLY
1691
1692ST_FUNC void fill_got_entry(TCCState *s1, ElfW_Rel *rel)1691ST_FUNC void fill_got_entry(TCCState *s1, ElfW_Rel *rel)
1693{1692{
1694 int sym_index = ELFW(R_SYM) (rel->r_info);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
3772static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed)3771static 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 int t, group, nblibs = 0, ret = 0;3774 int t, group, nblibs = 0, ret = 0;
3776 char **libs = NULL;3775 char **libs = NULL;
3777 3776
tccgen.c+3−5
@@ -1380,7 +1380,7 @@ static void tcc_debug_fix_anon(CType *t) · 1379 unmodified lines
1380 if ((t->t & VT_BTYPE) == VT_STRUCT && t->ref->c != -1)1380 if ((t->t & VT_BTYPE) == VT_STRUCT && t->ref->c != -1)
1381 for (i = 0; i < n_debug_anon_hash; i++)1381 for (i = 0; i < n_debug_anon_hash; i++)
1382 if (t->ref == debug_anon_hash[i].type) {1382 if (t->ref == debug_anon_hash[i].type) {
1383 Sym sym = { .type = *t };1383 Sym sym = {0}; sym .type = *t ;
1384 1384
1385 debug_type = tcc_get_dwarf_info(s1, &sym);1385 debug_type = tcc_get_dwarf_info(s1, &sym);
1386 for (j = 0; j < debug_anon_hash[i].n_debug_type; j++)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 debug_type = tcc_debug_find(t, 1);1628 debug_type = tcc_debug_find(t, 1);
1629 if (debug_type == -1) {1629 if (debug_type == -1) {
1630 int pos_sib, pos_type;1630 int pos_sib, pos_type;
1631 CType ct = { VT_INT | (type & VT_UNSIGNED) , NULL };1631 Sym sym = {0}; sym .type.t = VT_INT | (type & VT_UNSIGNED) ;
1632 Sym sym = { .type = ct };
1633 1632
1634 pos_type = tcc_get_dwarf_info(s1, &sym);1633 pos_type = tcc_get_dwarf_info(s1, &sym);
1635 debug_type = tcc_debug_add(t, 1);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 else if (type == (VT_PTR | VT_ARRAY)) {1705 else if (type == (VT_PTR | VT_ARRAY)) {
1707 int sib_pos, sub_type;1706 int sib_pos, sub_type;
1708 CType ct = { VT_INT | VT_UNSIGNED , NULL };1707 Sym sym = {0}; sym .type.t = VT_INT | VT_UNSIGNED ;
1709 Sym sym = { .type = ct };
1710 1708
1711 sub_type = tcc_get_dwarf_info(s1, &sym);1709 sub_type = tcc_get_dwarf_info(s1, &sym);
1712 i = dwarf_info_section->data_offset;1710 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
262static struct segment_command_64 * add_segment(struct macho *mo, const char *name)262static struct segment_command_64 * add_segment(struct macho *mo, const char *name)
263{263{
264 struct segment_command_64 *sc = add_lc(mo, LC_SEGMENT_64, sizeof(*sc));264 struct segment_command_64 *sc = add_lc(mo, LC_SEGMENT_64, sizeof(*sc));
265 strncpy(sc->segname, name, 16-1);265 strncpy(sc->segname, name, 16);
266 sc->segname[16-1] = '\0';
267 mo->seg2lc[mo->nseg++] = mo->nlc - 1;266 mo->seg2lc[mo->nseg++] = mo->nlc - 1;
268 return sc;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 seg = tcc_realloc(seg, sizeof(*seg) + seg->nsects * sizeof(*sec));282 seg = tcc_realloc(seg, sizeof(*seg) + seg->nsects * sizeof(*sec));
284 sec = (struct section_64*)((char*)seg + sizeof(*seg)) + ret;283 sec = (struct section_64*)((char*)seg + sizeof(*seg)) + ret;
285 memset(sec, 0, sizeof(*sec));284 memset(sec, 0, sizeof(*sec));
286 strncpy(sec->sectname, name, 16-1);285 strncpy(sec->sectname, name, 16);
287 sec->sectname[16-1] = '\0';
288 strncpy(sec->segname, seg->segname, 16);286 strncpy(sec->segname, seg->segname, 16);
289 *_seg = seg;287 *_seg = seg;
290 return ret;288 return ret;
tccpp.c+8−6
@@ -2038,10 +2038,14 @@ include_done: · 2037 unmodified lines
2038 if (tok == TOK_STR) {2038 if (tok == TOK_STR) {
2039 if (file->true_filename == file->filename)2039 if (file->true_filename == file->filename)
2040 file->true_filename = tcc_strdup(file->filename);2040 file->true_filename = tcc_strdup(file->filename);
2041 /* prepend directory from real file */2041 q = (char *)tokc.str.data;
2042 pstrcpy(buf, sizeof buf, file->true_filename);2042 buf[0] = 0;
2043 *tcc_basename(buf) = 0;2043 if (!IS_ABSPATH(q)) {
2044 pstrcat(buf, sizeof buf, (char *)tokc.str.data);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 tcc_debug_putfile(s1, buf);2049 tcc_debug_putfile(s1, buf);
2046 } else if (parse_flags & PARSE_FLAG_ASM_FILE)2050 } else if (parse_flags & PARSE_FLAG_ASM_FILE)
2047 break;2051 break;
@@ -3733,8 +3737,6 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) · 1685 unmodified lines
3733 putdef(cs, "__CHAR_UNSIGNED__");3737 putdef(cs, "__CHAR_UNSIGNED__");
3734 if (s1->optimize > 0)3738 if (s1->optimize > 0)
3735 putdef(cs, "__OPTIMIZE__");3739 putdef(cs, "__OPTIMIZE__");
3736 if (s1->optimize == 's')
3737 putdef(cs, "__OPTIMIZE_SIZE__");
3738 if (s1->option_pthread)3740 if (s1->option_pthread)
3739 putdef(cs, "_REENTRANT");3741 putdef(cs, "_REENTRANT");
3740 if (s1->leading_underscore)3742 if (s1->leading_underscore)
tests/Makefile+1−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
5TOP = ..5TOP = ..
6include $(TOP)/Makefile6include $(TOP)/Makefile
7VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP)7VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP)
8CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS)8CFLAGS := $(filter-out -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS)
9 9
10# what tests to run10# what tests to run
11TESTS = \11TESTS = \
x86_64-link.c+2−2
@@ -23,7 +23,7 @@ · 22 unmodified lines
23 23
24#include "tcc.h"24#include "tcc.h"
25 25
26#if !defined(ELF_OBJ_ONLY) || defined(TCC_TARGET_MACHO)26#ifdef NEED_RELOC_TYPE
27/* Returns 1 for a code relocation, 0 for a data relocation. For unknown27/* Returns 1 for a code relocation, 0 for a data relocation. For unknown
28 relocations, returns -1. */28 relocations, returns -1. */
29int code_reloc (int reloc_type)29int code_reloc (int reloc_type)
@@ -109,7 +109,7 @@ int gotplt_entry_type (int reloc_type) · 79 unmodified lines
109 return -1;109 return -1;
110}110}
111 111
112#if !defined(TCC_TARGET_MACHO) || defined TCC_IS_NATIVE112#ifdef NEED_BUILD_GOT
113ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)113ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)
114{114{
115 Section *plt = s1->plt;115 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