Commit Graph

1556 Commits

Author SHA1 Message Date
jiang
e20c1eb99e fix test3 for x86_64-gen.c 2014-04-28 19:43:02 +08:00
jiang
89f7aea980 fix abitest.c for x86_64 bug 2014-04-28 14:05:55 +08:00
jiang
deaee6c249 fix tccpp.c 2014-04-28 12:53:18 +08:00
jiang
857f7dbfa6 update static void parse_number(const char *p) for tccpp.c 2014-04-28 12:42:36 +08:00
jiang
4b50557553 add test for abitest.c 2014-04-28 12:28:56 +08:00
grischka
2ac238fc50 tccpe: adjust for new 'hidden' symbols feature
in order to avoid conflicts with windows specific (ab)usage
of the Elf32_Sym -> st_other field.
2014-04-17 17:01:28 +02:00
Thomas Preud'homme
6b7a6fcbc8 Improve efficiency of macro concatenation
As per grischka comment, always output a space after macro concatenation
instead of trying to detect if it's necessary as the current approach
has a huge cost.
2014-04-14 20:49:14 +08:00
Michael Matz
356c6f6293 Remove unused variable 2014-04-14 05:41:57 +02:00
Michael Matz
e69c506617 x86_64: Handle PLT relocs to hidden symbols
For calls to hidden symbols we don't need a PLT slot, rewrite
the reloc into PC32.
2014-04-14 04:58:05 +02:00
Michael Matz
a9fda392a0 Parse assembler .hidden directive
This makes TCCs assembler understand the '.hidden symbol' directive
(and emits a STV_HIDDEN ELF symbol then).
2014-04-14 03:33:50 +02:00
Michael Matz
fbda78aefe Parse and emit hidden visibility
This adds parsing of (GCC compatible) visibility attribute
in order to mark selected global symbols as hidden.  The generated
.o files contain hidden symbols already, the TCC linker doesn't
yet do the right thing.
2014-04-14 02:53:11 +02:00
grischka
112148172b tccpe: speed up .def file loading
The fgets replacement meant to work with "int fd"
was just too slow.
2014-04-13 20:30:46 +02:00
minux
aa255f37f2 tests2: fix and enable 46_grep test. 2014-04-12 14:04:10 -04:00
minux
0a51386960 tests2: fix 30_hanoi test and enable it. 2014-04-12 13:37:37 -04:00
Thomas Preud'homme
0e3d2e0bea Make build CPU detection a tad more flexible 2014-04-12 16:20:12 +08:00
Thomas Preud'homme
6e56bb387d Fix preprocessor concat with empty arg 2014-04-12 16:11:42 +08:00
minux
9714d2e75f build: add initial NetBSD support.
Not able to generate ELF files on NetBSD yet (lacks the note and crt1.o
is actually named crt0.o on NetBSD), but -run works with these extra
defines:
-D__lint__ -D"__symbolrename(x)=asm(#x)" -D__NetBSD__

The -D__lint__ is an ugly hack, TCC should be able to emulate GCC just
fine, but it seems TCC doesn't support __builtin_va_list yet?
	typedef __builtin_va_list __va_list;
/usr/include/sys/ansi.h:72: error: ';' expected (got "__va_list")
2014-04-12 01:42:46 -04:00
minux
469ae3a7e5 build: ignore and properly clean tests/vla_test 2014-04-12 01:10:58 -04:00
minux
b8eb7dd8e8 tcc.h: add ELF interpreter for DragonFly BSD. 2014-04-12 01:10:12 -04:00
minux
8d3e0b3080 tccrun: fix build on DragonFly BSD. 2014-04-12 00:52:20 -04:00
minux
5f7cdd29b6 win32/include/process.h: update prototypes to match mingw.
This eliminates an argument type mismatch warning during tcc
self-compilation on windows.
2014-04-12 00:09:57 -04:00
minux
df0267b287 tcc, libtcc: fix build on windows with latest mingw. 2014-04-11 23:49:53 -04:00
minux
bba1c381f4 tiny_impdef: remove artificial length restriction. 2014-04-11 23:23:05 -04:00
Urs Janssen
822f4630e3 add missing prototypes 2014-04-10 11:53:54 +02:00
Thomas Preud'homme
a715d7143d Prevent ## to appear at start or end of macro 2014-04-08 22:19:48 +08:00
Thomas Preud'homme
91d4db600b Add new tests for macro nesting 2014-04-07 23:30:57 +08:00
Thomas Preud'homme
c2422ba87f Fix test for macro nesting 2014-04-07 21:16:04 +08:00
Vincent Lefevre
3e9a7e9d69 Corrected spelling mistakes in comments and strings 2014-04-07 13:31:00 +02:00
Vincent Lefevre
d09a46d655 corrected a typo 2014-04-07 13:20:49 +02:00
grischka
f90bad0925 tests2: cleanup
- remove -norunsrc switch
  Meaning and usage (-run -norun...???) look sort of screwed.  Also
  general usefulness is unclear, so it was actually to support exactly
  one (not even very interesting) test

This partially reverts e31579b076
2014-04-07 11:20:45 +02:00
grischka
76accfb8d5 win32: libtcc1.a needs to be built with tcc
gcc/mingw produces msvc compatible pecoff objects, tcc only
knows ELF.
2014-04-07 11:16:06 +02:00
Michael Matz
f01373765b stdbool.h: Make conformant to ISOC99
For conformance to ISO C the stdbool.h header has to provide
the macro __bool_true_false_are_defined (defined to 1).  Yep,
that name is really in the standard.
2014-04-07 00:30:31 +02:00
Michael Matz
0961a38493 Declare wint_t in <stddef.h> when needed
Some old glibcs <wctype.h> require <stddef.h> to provide
wint_t, accomodate them.
2014-04-07 00:27:46 +02:00
grischka
0e43f3aef4 win32: warn people about using undeclared WINAPI functions
*** UNCONDITIONALLY ***

Esp. sihce tinycc winapi headers are not as complete as people might
expect this can otherwise lead to obscure problems that are difficult
to debug.

(Originally 'warn_implicit_function_declaration' was set to 1
always for windows but someone must have deleted that line)
2014-04-06 10:59:40 +02:00
Michael Matz
6a947d9d26 ELF: Remove traces of old RUNTIME_PLTGOT code
The last users of it went away, no use in keeping
this code.
2014-04-06 01:59:35 +02:00
Michael Matz
01c0419234 arm: Use proper PLT/GOT for -run.
Same as with x86_64, disable the runtime_plt_and_got hack
for -run on arm as well.  For that we need to handle several
relocations as (potentially) generating PLT slots as well.
Tested with mpfr-3.1.2 and gawk (both using --disable-shared),
there are two resp. five pre-existing problems, so no regressions.

This also works toward enabling real shared libs for arm,
but it's not there yet.
2014-04-06 01:50:35 +02:00
Michael Matz
9750d0b725 x86_64: Create proper PLT and GOT also for -run
This makes us use the normal PLT/GOT codepaths also for -run,
which formerly used an on-the-side blob for the jump tables.
For x86_64 only for now, arm coming up.
2014-04-06 00:30:22 +02:00
Michael Matz
c4427747e6 arm: Provide alloca()
This provides a simple implementation of alloca for ARM (and enables
the associated testcase).  As tcc for ARM doesn't contain an assembler,
we'll have to resort using gcc for compiling it.
2014-04-05 22:54:11 +02:00
Michael Matz
b0f8ca5e03 Git should ignore tests2 executables. 2014-04-05 22:52:17 +02:00
Michael Matz
3d18c9aa64 tests2: Build executables as well
The individual tests in tests2 are checked only with -run.  Build
(and check) executables as well, to test also building executables.
2014-04-05 17:35:00 +02:00
Michael Matz
0688afdd34 arm: Handle R_ARM_NONE relocs
These relocations are used to express a dependency on a certain
symbol (e.g. for EABIs exception handling to the
__aeabi_unwind_cpp_pr{0,1,2} routines).  Just ignore them in
reloc processing.
2014-04-04 23:33:04 +02:00
grischka
5879c854fb tccgen: x86_64: fix garbage in the SValue upper bits
This was going wrong (case TOK_LAND in unary: computed labels)
-        vset(&s->type, VT_CONST | VT_SYM, 0);
-        vtop->sym = s;

This does the right thing and is shorter:

+        vpushsym(&s->type, s);


Test case was:

    int main(int argc, char **argv)
    {
        int x;
        static void *label_return = &&lbl_return;
        printf("label_return = %p\n", label_return);
        goto *label_return; //<<<<< here segfault on linux X86_64 without the memset on vset
        printf("unreachable\n");
    lbl_return:
        return 0;
    }


Also::
- Rename "void* CValue.ptr" to more usable "addr_t ptr_offset"
  and start to use it in obvious cases.

- use __attribute__ ((noreturn)) only with gnu compiler

- Revert CValue memsets ("After several days searching ...")
  commit 4bc83ac393

Doesn't mean that the vsetX/vpush thingy isn't brittle and
there still might be bugs as to differences in how the CValue
union  was set and is then interpreted later on.

However the big memset hammer was just too slow (-3% overall).
2014-04-04 20:20:44 +02:00
Michael Matz
2024c44541 run: Always create .got relocs
When output is memory we applied the correct GOT offset for certain
relocations (e.g. _GOT32), but we forgot to actually fill the got
entries with the final symbol values, so unconditionally create relocs
against .got as well.
2014-04-04 17:54:52 +02:00
Michael Matz
f2c8491fc0 ELF: Make first PT_LOAD cover headers
This makes it so that the first PT_LOAD segment covers
ELF and program header and .interp (contained in the same page anyway,
right before the start of the first loaded section).  binutils
strip creates invalid output otherwise (which strictly is a binutils
bug, but let's be nice anyway).
2014-04-03 18:00:44 +02:00
Michael Matz
a913ee6082 x86-64: Use correct ELF values
The x86-64 uses different segment alignment (2MB) and a different
start address.
2014-04-03 17:59:41 +02:00
Michael Matz
ea2805f097 shared libs: Build libtcc1.a with -fPIC
TCCs runtime library must be compiled as position independend code,
so it can be linked into shared libraries.
2014-04-02 21:27:22 +02:00
Thomas Preud'homme
3e56584223 Allow local redefinition of enumerator 2014-03-31 22:59:10 +08:00
Vincent Lefevre
a620b12dc1 Fixed typo from commit 0ac8aaab1b 2014-03-31 15:24:32 +02:00
Thomas Preud'homme
01cf514e59 Update Changelog from git changelog entries 2014-03-31 19:42:42 +08:00
Michael Matz
0bd1282059 x86-64: shared libs improvement
This correctly resolves local references to global functions from
shared libs to their PLT slot (instead of directly to the target
symbol), so that interposition works.

This is still not 100% conforming (executables don't export symbols
that are also defined in linked shared libs, as they must), but
normal shared lib situations work.
2014-03-31 05:36:12 +02:00