Commit Graph

1055 Commits (40a54c4399cc5e687d93add4b89bc16c19aaddfe)
 

Author SHA1 Message Date
Michael Matz 4c0d70ab07 Fix parsing function macro invocations
If a function macro name is separated from the parentheses in
an macro invocation the substitution doesn't take place.
Fix this by handling comments.
2012-04-18 20:57:13 +02:00
Michael Matz 15f4ac2b1a Fix detection of labels with a typedef name
This needs to be accepted:
  typedef int foo;
  void f (void) { foo: return; }
namespaces for labels and types are different.  The problem is that
the block parser always tries to find a decl first and that routine
doesn't peek enough to detect this case.  Needs some adjustments
to unget_tok() so that we can call it even when we already called
it once, but next() didn't come around restoring the buffer yet.
(It lazily does so not when the buffer becomes empty, but rather
when the next call detects that the buffer is empty, i.e. it requires
two next() calls until the unget buffer gets switched back).
2012-04-18 20:57:13 +02:00
Michael Matz 1d0a5c2515 x86_64: Fix segfault for global data
When offsetted addresses of global non-static data are computed
multiple times in the same statement the x86_64 backend uses
gen_gotpcrel with offset, which implements an add insn on the
register given.  load() uses the R member of the to-be-loaded
value, which doesn't yet have a reg assigned in all cases.

So use the register we're supposed to load the value into as
that register.
2012-04-18 20:57:13 +02:00
Michael Matz 86ac6b9bee x86_64: Fix indirection in struct paramaters
The first loop setting up struct arguments must not remove
elements from the vstack (via vtop--), as gen_reg needs them to
potentially evict some argument still held in registers to stack.

Swapping the arg in question to top (and back to its place) also
simplifies the vstore call itself, as not funny save/restore
or some "non-existing" stack elements need to be done.

Generally for a stack a vop-- operation conceptually clobbers
that element, so further references to it aren't allowed anymore.
2012-04-18 20:57:13 +02:00
Michael Matz 5c0a2366a3 Fix bitfield loads into char/short.
Removes a premature optimization of char/short loads
rewriting the source type.  It did so also for bitfield
loads, thereby removing all the shifts/maskings.
2012-04-18 20:57:13 +02:00
Michael Matz 6471ec0a2b Fix conversion in a?0:ptr.
(cond ? 0 : ptr)->member wasn't handled correctly.  If one arm
is a null pointer constant (which also can be a pointer) the result
type is that of the other arm.
2012-04-18 20:57:13 +02:00
grischka f98c2306a0 libtcc: tcc_get_symbol uses the TCCState parameter
This allows using tcc_get_symbol on some other than the
current TCCState. (Suggested by David Mertens)
2012-04-18 18:48:26 +02:00
grischka 32a411914b support "x86_64-linux-gnu" subdirs with lib & include
suggested for newer ubuntu by Damian Gryski
2012-04-18 18:44:39 +02:00
grischka f1b5c2ef4f tcc_realloc: auto "memory full" error 2012-04-18 18:43:55 +02:00
grischka 3c59f84240 tcc.h: unify multiple #ifdef CONFIG_TCC_BACKTRACE 2012-04-18 18:43:29 +02:00
grischka ab936aeb8c cleanup some partially broken patches
- tests/Makefile:
  fix commit de54586d5b
  This hunk it unrelated to the other changes (which are about MacOSX).
  It is not useful and partially wrong.  Optional tests are meant to
  stay optional, btest would work only for i386

- tcc.h:
  fix commit c52d79605a by unknown
  The message says it's for MINTW but the patch has obviously
  no effect for MINGW (which defines __GNUC__).  However the patch
  seems useful for MSC which however needs _strto(u)i64 with underscore.

- Makefile:
  fix commit 5280293d6b
  Do not build tcc.o with -DONE_SOURCE because we finally build tcc
  from tcc.o and libtcc.a/so
2012-04-18 18:43:09 +02:00
grischka 5aaa067af4 win32: tcc.exe uses libtcc.dll 2012-04-18 18:38:11 +02:00
grischka 4274c44de7 tcc.c: fix previous commit "Use CString to concat linker options"
- remove redunant else branch
- zero-terminate linker_arg
- declare cstr_xxx as PUB_FUNC
  (which are functions used in tcc.c but not in the libtcc API.
   Useful for a tcc(.exe) that uses the libtcc.(so/dll))
- while at it, export PUB_FUNCs from dll
2012-04-18 18:32:37 +02:00
Gabriel Corneanu 214564b1dc Re-enable "Use CString to concat linker options"
This reverts commit 16202e054f.

Changed win32 build to use ONE_SOURCE just like libtcc.dll
Therefore CString can be used again...
2012-04-18 10:01:45 +02:00
Gabriel Corneanu 176876e5de add "nostdlib" option to libtcc 2012-04-18 09:48:57 +02:00
Thomas Preud'homme 16202e054f Revert "Use CString to concat linker options"
This reverts commit 1c11b857fe.

On windows, libtcc.c is compiled with ONE_SOURCE and then tcc.c is
linked to it. Thus tcc.c can only use public functions which cstr_* are
not.
2012-04-10 16:33:39 +02:00
Thomas Preud'homme 1c11b857fe Use CString to concat linker options
As suggested, change type of linker_arg variable to the more appropriate CString
type, since linker_arg is about dynamically grown string.
2012-03-20 16:01:12 +01:00
Thomas Preud'homme 2eee100c37 Fix use after free for linker_arg
elements in linker_arg are used in TCCState structure and must thus not
be freed when option parsing is finished. Declare linker_arg as a global
static variable and free it after tcc_delete has been called on TCCState
structure.

This fix commit 7fb0482a46
2012-03-16 19:23:54 +01:00
unknown c52d79605a fix mingw compliation 2012-03-16 08:54:29 +08:00
Thomas Preud'homme 7fb0482a46 Support linker options passed in several -Wl param
ld support arguments to multiple-letter options being passed in two
ways:
* -opt=arg
* -opt arg

libtool generate command line of the second form. This commit add
support for the second form so that libtool works with tcc. The way it
is done is to concatenate all -Wl options into one and then pass it to
set_linker.
2012-03-15 00:25:40 +01:00
Thomas Preud'homme 1736a71b71 Consider long int constant as 64 bits on x86-64
Quick and dirty hack to consider long int constant (as in 1UL or 1L) as
64 bits integer on x86-64 non Windows systems.
2012-03-14 15:47:42 +01:00
Thomas Preud'homme 53c5715cca Remove vnrott (duplicate vrotb) 2012-03-14 15:39:16 +01:00
Thomas Preud'homme 3d25213c16 Inform user that -b only exists on i386. 2012-03-13 19:43:43 +01:00
Milutin Jovanovic de54586d5b Further changes improving the OSX build. Everything builds. libtest passes.
Other tests still have issues, currently with weak linking.

One of the primary stumbling blocks on OSX is the lack of support for
mach-o binaries. Therefore all tcc usage on OSX has to be limited to elf
binaries, presumably produced by tcc itself.

Therefore I had to enable building of tiny_libmaker for OSX. Then changed
the make to use tcc and tiny_libmaker to compile the tcclib1.

In order to compile the tests, specifically the parts that use weak linking,
I have had to define MACOSX_DEPLOYMENT_TARGET to 10.2, which seems like a
hack, but extensive searching seems to indicate that this is the only way
to make apple gcc allow weak linking. Using any other value, bigger or smaller
breaks weak linking.

Also added _ANSI_SOURCE define required by some OSX headers, and some cosmetic
gitignore changes. I believe these changes should not impact other platforms.
2012-03-06 13:26:36 -05:00
grischka ae191c3a61 x86_64: fix loading of LLOCAL floats
See also commit 9527c4949f

On x86_64 we need to extend the reg_classes array because load()
is called for (at least) R11 too, which was not part of reg_classes
previously.
2012-03-05 20:19:28 +01:00
grischka a35b3059bb tcc.h: define TCC_IS_NATIVE
- disable tccrun feature for non-native (cross-) compilers
- define uplong for target adress size
- fix using -Wl,-Ttext=... for Win64 (tccpe: ADDR3264 imagebase)
2012-03-05 20:15:56 +01:00
Andrew Mulbrook a0db7162af Fix assumption of 32bit long on portions of Elf
Modify tcc to accept convert full 64bits of specified text section
when converting on Win64. Write high bytes to the elf section address
as well. This allows creation of elf binaries located in offsets using
full 64 bit addresses.

Signed-off-by: Andrew Mulbrook <andrew262@gmail.com>
2012-03-03 11:10:15 -06:00
Andrew Mulbrook 5775911dad Revert "Multiple fixes for 64 bit sections"
This reverts commit d7a7c3769d.
2012-03-03 10:12:06 -06:00
Ramsay Jones e343b1dfd4 Add __REDIRECT needed for Large File Support API on linux
Since commit 9b09fc3 ("Add support of asm label for functions",
05-09-2010) tcc has had the capability to rename functions at the
assembly level. This capability was subsequently used by commit
2596273 ("Add support for __REDIRECT_NTH needed with eglibc",
11-09-2010) to redirect long double functions on platforms which
did not support long double.

Here we add the companion macro __REDIRECT which is used (along
with __REDIRECT_NTH) in the glibc headers on Linux to support the
Large File API (when _FILE_OFFSET_BITS is set to 64).

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2012-02-29 16:38:24 +00:00
mob d7a7c3769d Multiple fixes for 64 bit sections
This changeset attempts to fix a few problems when giving using
the high 32bits of a 64bit section offset. There are likely more
issues (or perhaps regressions) lurking in the muck here. In general,
this moves a few data type declarations to use uplong.  Also, add
support for 64bit mingw32 building under cygwin.  Because native
types are used for 64 bit offsets, this won't fix challenges with
cross compiling from 32bit -> 64bit.

Tested under cygwin, against binary compiled with
-Wl,-Ttext=0xffffff8000000000

Signed-off-by: Andrew Mulbrook <andrew262@gmail.com>
2012-02-26 19:02:51 -06:00
Milutin Jovanovic 6e13c35334 Attempt to fix 32 bit OSX build. The fix consists of adding -m32 and -m64
to the appropriate CFLAGS. In addition, memory hooks are very different
on OSX, so build of bcheck.c had to be disabled for now.

Change of the CFLAGS does affect builds on other platforms, and this needs
to be tested.
2012-02-16 11:24:14 -05:00
Milutin Jovanovic 8ca8b08890 Patch attempting to build OSX TinyCC.
Applied patch found on stackoverflow (link below). I also found some
related changes that looked like logically needed. The stackoverflow
changes addressed only two registers which were breaking a compile.
However reading the code in the same file shows two other register
accesses that, while not breaking the build, should have the same fix.

http://stackoverflow.com/questions/3712902/problems-compiling-tcc-on-os-x/3713144#3713144

The test driver was changed by changing 'cp -u' into 'cp' as '-u' is not
supported on mac osx.

I found that osx build required the WITHOUT_LIBTCC define. I suspect the
reason for this is tcc unability to handle mach-o files. In order to
properly address this I had to change 'configure' to propagate target os
name to Makefile.

Current state is that simple tests work, but not the whole 'make test'
suite runs.

To the best of my knowledge, these changes should not impact other
platforms.
2012-02-09 12:53:17 -05:00
Daniel Glöckner 9527c4949f i386: fix loading of LLOCAL floats
These loads clobbered ebx as TinyCC wanted to load the address into st0.
2012-01-23 01:45:11 +01:00
Thomas Preud'homme 3ab269c56a Error out when assigning void value.
tcc should now error out when compiling code like:

VOID ExitProcess(UINT uExitCode);
(…)
retCode = ExitProcess(pi.dwProcessId);
2012-01-22 21:18:38 +01:00
Thomas Preud'homme 9c25ed13b4 s/derefencing/dereferencing/ in i386-gen.c 2012-01-08 18:03:17 +01:00
Thomas Preud'homme 519a9040a1 Compile tccasm.c conditionally (TCC_CONFIG_ASM)
Only compile the content of tccasm.c if inline assembly is supported for
this architecture by testing the presence of macro TCC_CONFIG_ASM.
2012-01-06 18:34:21 +01:00
Thomas Preud'homme 83d57c06f4 Fix linkage of named file in loader script.
Remove the previous logic to link a named file with a loader script by
using tcc_add_dll instead. Hence, all files can be linked, not only
files ending in .so/.def.
2012-01-04 14:40:03 +01:00
Nicolas Limare 5f99fe2ff1 libtcc: add missing tcc_enable_debug() 2011-10-03 22:36:16 +02:00
Thomas Preud'homme 2dd3fb103e Don't define strtold and strtof on *BSD + uClibc
Don't define strtold and strtof on *BSD and uClibc as they are already
defined there since:

* 2001 (FreeBSD 4.4)
* 2009 (OpenBSD 4.5)
* 2009 (DragonFlyBSD)
* 2002 (uClibc)

See
http://lists.nongnu.org/archive/html/tinycc-devel/2011-07/msg00025.html
for a bit more details.
2011-08-12 18:43:37 +02:00
Daniel Glöckner ab7ed48ee8 Fix problem with PLT and GOT relocs on armel.
TinyCC fails to link correctly to libraries when both R_ARM_PLT32 and
R_ARM_GOT32 relocation to a same symbol exist (see
http://lists.nongnu.org/archive/html/tinycc-devel/2010-05/msg00032.html
for more details).
The patch marks all undefined weak symbols found in external libraries
as strong. The value of all remaining weak symbols is set to zero just
before the section is output.

Note by Thomas Preud'homme: it's been 2 months in Debian without any new
bug report, hence commiting.
2011-08-12 18:28:45 +02:00
grischka bf374a5f23 rename error/warning -> tcc_(error/warning) 2011-08-11 17:07:56 +02:00
grischka 74a24d77fd libtcc: minor adjustments
- use {B} to substitute tcc_lih_path (instead of \b)

- expand CONFIG_TCC_CRTPREFIX in CONFIG_TCC_LIBPATHS
  which fixes duplicate CONFIG_SYSROOT.

- put default CONFIG_SYSROOT ("") into tcc.h

- remove hack from commit db6fcce78f
  because $(tccdir)/include is already in sysincludes

- configure: error out for unrecognized options.

- win32/build-tcc.bat: put libtcc into base dir where it will
  find lib/include automatically, and build libtcc_test example.
2011-08-11 16:55:30 +02:00
Gabriel Corneanu fd0cea8895 dll build + small adjustments 2011-08-10 12:42:14 +02:00
grischka e844fb11c2 libtcc: support more than one crtprefix
Looks like gcc has that.  Oh Deer!
2011-08-06 16:49:30 +02:00
grischka e6f3bf7f08 libtcc: cleanup the 'gen_makedeps' stuff 2011-08-06 16:11:58 +02:00
grischka 39a07cca58 tcc: fix -m32/64 & simplify
This cleans up the mess from commit
   8f98573658
and preceeding.

- make tcc -m64 work on windows
- execvp on windows returns 0 always, replace by spawnvp
- remove bizarre support for i386-win32-tcc -m64
2011-08-06 16:11:58 +02:00
grischka 5e5e29f8fd tcctest: switch weak_toolate proto with impl
gcc -O0 didn't like this.
2011-08-06 16:11:57 +02:00
grischka f115c12346 x86-64: fix flags and zero-pad long doubles
This fixes a bug introduced in commit
    8d107d9ffd
that produced wrong code because of interference between
0x10 bits VT_CONST and x86_64-gen.c:TREG_MEM

Also fully zero-pad long doubles on x86-64 to avoid random
bytes in output files which disturb file comparison.
2011-08-06 16:11:56 +02:00
grischka 81cd0cf6fd configure: add switches to set search paths
--sysincludepaths=.. specify system include paths, colon separated"
     Sets CONFIG_TCC_SYSINCLUDEPATHS

   --libpaths=...       specify system library paths, colon separated"
     Sets CONFIG_TCC_LIBPATHS

   --crtprefix=...      specify location of crt?.o"
     Sets CONFIG_TCC_CRTPREFIX

   --elfinterp=...      specify elf interpreter"
     Sets CONFIG_TCC_ELFINTERP

Also the CONFIG_TCC_XXX were renamed to make them look
more consistent.

Also move the elf_interp definitions to tcc.h.
2011-08-06 16:11:12 +02:00
Thomas Preud'homme 9ffd77f18d Remove semicolon in x86-64 va_arg definition. 2011-08-05 20:32:57 +02:00