Commit Graph

1396 Commits (fbda78aefeaaa97182658bb81b5a6f215cc24b17)
 

Author SHA1 Message Date
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
Michael Matz 080ad7e62a x86-64: Add basic shared lib support
Initial support for shared libraries on x86-64.
2014-03-31 03:45:35 +02:00
mingodad 5a5fee867a Add __attribute__ ((noreturn)) to tcc_error and expect functions.
This make use of static analysis tools like scan-build report less false positives.
2014-03-30 10:18:18 +01:00
Thomas Preud'homme 80811671d4 Add tests for previous fixes
Add tests for the fixes made in commits
76cb1144ef,
a465b7f58f,
0f522fb32a,
82969f045c and
673befd2d7.
2014-03-30 12:56:55 +08:00
Thomas Preud'homme fdc31e152b Update Changelog from git changelog entries 2014-03-30 12:35:22 +08:00
Daniel Glöckner 3900b235e0 x86_64: pass va_list as pointer
The ABI requires that va_list is passed as a pointer although its
contents is a kept in a structure. Therefore make it a single element
array.
2014-03-30 00:13:58 +01:00
grischka 0ac8aaab1b tccpp: reorder some tokens
... and make future reordering possibly easier

related to 9a6ee577f6
2014-03-29 19:37:26 +01:00
Daniel Glöckner 1075087241 ARM: Fix passing arrays to varadic functions
TinyCC miscompiled

void g(int,...);

void f(void)
{
        char b[4000];
        g(1, 2, 3, 4, b);
}

in two ways:
 1. It didn't align the stack to 8 bytes before the call
 2. It added sizeof(b) to the stack pointer after the call
2014-03-29 17:50:40 +01:00
Thomas Preud'homme f272407353 Fix typo in code added by b018bac9c8 2014-03-29 14:57:59 +08:00
Thomas Preud'homme b018bac9c8 Fix again GOT32 + PLT32 reloc commit
Fix commit aa561d7011 by setting
has_plt_entry once the plt has been created, not before.
2014-03-29 14:46:26 +08:00
Thomas Preud'homme b125743323 Create bcheck region for argv and arge argument
For program manipulating argv or arge as pointer with construct such as:

(while *argv++) {
  do_something_with_argv;
}

it is necessary to have argv and arge inside a region. This patch create
regions argv and arge) if main is declared with those parameters.
2014-03-29 14:46:26 +08:00