Commit Graph

108 Commits

Author SHA1 Message Date
grischka
df9cce24a8 Accept colon separated paths with -L and -I
This allows passing colon separated paths to
  tcc_add_library_path
  tcc_add_sysinclude_path
  tcc_add_include_path

Also there are new configure variables
  CONFIG_TCC_LIBPATH
  CONFIG_TCC_SYSINCLUDE_PATHS
which define the lib/sysinclude paths all in one and can
be overridden from configure/make

For TCC_TARGET_PE semicolons (;) are used as separators

Also, \b in the path string is replaced by s->tcc_lib_path
(CONFIG_TCCDIR rsp. -B option)
2011-08-01 01:10:36 +02:00
grischka
aa80e5b1ff tccpe: cleanup ELFW() macros etc. 2011-07-14 19:23:04 +02:00
Thomas Preud'homme
5cf5871aaf Use CONFIG_TCC_LDDIR for ld.so on all linux archs 2011-07-08 11:16:34 +02:00
Thomas Preud'homme
ee06ef9dd3 Remove unused variables
Remove unused local variables and declare them conditionally when they
are used only on some architectures.
2011-05-16 14:15:32 +02:00
Thomas Preud'homme
db9d5f0fa4 Improve weak aliases handling
* Include only the STB_GLOBAL alias symbol in .dynsym section
* Stop the loop when STB_GLOBAL symbol is found
* Reword / simplify comment
2011-05-16 13:49:08 +02:00
Joe Soroka
585027aa96 tccelf: allow multiply defined weak symbols 2011-03-07 12:18:54 -08:00
Changming Xu
c27e76aa2a unlink outfile first
file mode problem if the outfile already exists
2011-03-03 21:09:18 +08:00
Shinichiro Hamaji
45e1ae2896 One more fix for tcc -run
We don't need r_addend for addresses in PLT.
2010-12-28 17:44:51 +09:00
Shinichiro Hamaji
d457addfc3 Fix for the previous commit.
R_X86_64_PLT32 for .so doesn't need DLL relocation.
2010-12-28 16:52:21 +09:00
Shinichiro Hamaji
0ae39f1957 Handle r_addend and R_X86_64_PLT32 properly.
- r_addend should be applied for PLT entries as well
- R_X86_64_PLT32 should be handled just like R_X86_64_PC32
- spec says GLOB_DAT and JUMP_SLOT don't need r_addend (not tested)
  http://www.x86-64.org/documentation/abi.pdf

Now we can -run ELF objects generated by GCC.
2010-12-28 16:14:30 +09:00
grischka
21c2a68aa0 tccelf/tcccoff: fix some type conversion warnings 2010-12-04 16:48:15 +01:00
Henry Kroll III
77e4679aec x86_64: finish biarch path fixup 2010-11-25 10:08:58 -08:00
Henry Kroll III
f1c9f649da x86_64: fix --with-libgcc and simplify biarch paths 2010-11-25 02:57:19 -08:00
Thomas Preud'homme
776364f395 Add support for __FreeBSD_kernel__ kernel
Add support for kfreebsd-i386 and kfreebsd-amd64 Debian arch with
thanks to Pierre Chifflier <chifflier@cpe.fr>.
2010-09-10 21:09:07 +02:00
Thomas Preud'homme
bcc9137a10 Add support for indirect functions as externals.
Add link support to use indirect functions defined in external modules
2010-08-09 20:20:09 +02:00
Daniel Glöckner
a867f42597 don't discard SHT_((PRE)INIT|FINI)_ARRAY sections 2010-05-15 01:26:56 +02:00
Daniel Glöckner
128e46f91b ARM: add support for R_ARM_V4BX 2010-05-15 01:23:34 +02:00
Daniel Glöckner
741841d863 ARM: allow jumps > 32MB on -run
This is needed to reach tinycc's PLT from the compiled program.
2010-05-14 13:07:59 +02:00
Thomas Preud'homme
2220467fcf Don't load libtcc1 on arch where it doesn't exist
ARM architecture doesn't have any libtcc1 implementation but tcc load
libtcc1.a in all case. This patch add a conditional preprocessor
instruction to load libtcc1.a only when there is an implementation for
the target architecture.
2010-05-01 17:20:28 +02:00
Thomas Preud'homme
a28b18fa16 Link alias symbols together
Make sure alias symbols resolve to the same address in program .bss or .data
section. This ensure for example that if a program reference environ (via an
extern char **environ declaration) and the libc change its value via the
__environ alias after the R_ARCH_COPY relocation have been performed, then
the program will see the new value.
2010-05-01 16:45:36 +02:00
Thomas Preud'homme
a64a6f36a0 Replace malloc+strcpy by tcc_strdup in ld_load_file_list 2010-04-20 22:25:16 +02:00
Thomas Preud'homme
6525a15919 Fix "already done" test in libname_to_filename()
if "(libname == '\0')" should be instead "if (libname != '\0')"
2010-04-20 16:21:13 +02:00
Thomas Preud'homme
3ad3168125 Clean changes introduced by 47abdbd
* Replace the save/load_buffer_state by a dynarray approach:
  - Filename and libname are added to a dynarray when first encountered
  - Load repeatedly the files in the dynarray until no new undefined
    symbol are encountered
* Replace snprintf by sprintf in libname_to_filename
* Use tcc_fileextension in filename_to_libname
* Introduce a tcc_strcpy_part fonction to copy only a subset of a
  string
* Move new_undef_syms declaration from tcc.h to tccelf.c
2010-04-20 16:02:42 +02:00
Thomas Preud'homme
47abdbd3d5 Better handle ld scripts
* search file from INPUT and GROUP commands in the library path in
  addition to the current directory
* handle libraries specified by -lfoo options
* Search lib in GROUP command repeatedly
2010-04-15 19:30:00 +02:00
grischka
d2cf970a41 tccelf: fix warning 2010-04-13 18:30:01 +02:00
Ali Gholami Rudi
d63ec6f20d fill got table for static linking 2010-02-05 08:25:48 +03:30
Nikos Mavrogiannopoulos
253bad7993 Added patch to detect and use the paths for 64bit libraries as
used by CentOS (affects X86_64 only).
2010-01-28 08:27:38 +01:00
Detlef Riekenberg
2650584ac4 Recognize -Wl,-Bsymbolic
Without -Bsymbolic, a symbol/function in a *.so can be overridden
by a symbol/function in the main module.
That is the default search order, but not supported by tcc.

With -Bsymbolic, the linker tries to resolve a symbol/function in
the current module first.
The loader in tcc implements this search order.

We do not distinguish -Bsymbolic and -Bsymbolic-function

--
By by ... Detlef
2010-01-26 22:55:14 +01:00
grischka
5299142286 x86-64: use uplong for symbol values 2010-01-14 20:59:42 +01:00
grischka
0de95730ad build from multiple objects: fix other targets 2009-12-20 20:33:41 +01:00
grischka
88a3ccab9f allow tcc be build from separate objects
If you want that, run: make NOTALLINONE=1
2009-12-20 01:53:49 +01:00
grischka
7fa712e00c win32: enable bounds checker & exception handler
exception handler borrowed from k1w1. Thanks.
2009-12-19 22:22:43 +01:00
grischka
e81569bc70 tcc: add "-Wl,-rpath=path" option (library search path) 2009-12-19 22:16:20 +01:00
Luigi Rizzo
55cb2170cd solve tccelf problem on FreeBSD
On Sun, Nov 22, 2009 at 05:43:14PM +0100, Luigi Rizzo wrote:
> Hi,
> there is a well known problem with tcc and FreeBSD in the generation
> of elf objects -- see
> http://lists.gnu.org/archive/html/tinycc-devel/2005-07/msg00070.html
>
> Apparently Sergey Lyubka has tried a partial fix to the problem.
> I was wondering if Sergey or someone can post some more detail on
> what needs to be done so we can try to help fixing this issue

I think i have managed to solve the problem and produce
almost valid elf files on FreeBSD. The two patches attached
address a few problems (trying to explain to the
best of my knowledge; i am not very familiar with ELF and
the FreeBSD ELF conventions):

1. ELF file format
  tcc produces an ELF executable which is good for linux but
  not for FreeBSD. It misses the PHDR section which is almost
  mandatory for shared executables, puts in the .dynsym section
  some relocation info that FreeBSD expects to be in .got,
  and expect the relocation sections to be contiguous.

  patch-tccelf.c tries to address the above problem using
  conditional sections (so hopefully can be imported upstream)
  and also adds the ability to override the name of the dynamic
  loader through an environment variable (this is important to
  debug tcc).

2. predefined macros

  patch-libtcc.c adds/fixes some predefined macros when compiling
  on FreeBSD: these are __FreeBSD__ and the usual set of
  __i386__ and __unix__ variants.
  It also sets __INTEL_COMPILER so we can grab the __aligned
  macro from cdefs.h , otherwise many programs would fail

The resulting elf file is still not 100% correct -- if you strip it,
the program will not run (presumably there is some dangling reference).
Other than that, program do seem to run correctly.

It would be nice to integrate these patches in the main repository.
The FreeBSD specific code is in #ifdef so it should not harm
linux users
	cheers
	luigi
2009-12-01 17:59:28 +01:00
Feret@.(none)
c15e37edad Removed binary executable output support
This broke writing executables.
2009-11-13 18:09:02 +01:00
Frederic Feret
2f73e42d87 various fixes and new options for PE format 2009-11-13 18:09:00 +01:00
Frederic Feret
0d768b9713 added 16-bit x86 assembly support 2009-11-13 18:08:58 +01:00
Frederic Feret
2349efa61b add binary executable output support 2009-11-13 18:08:58 +01:00
grischka
1026ca5888 fix "symbol not defined" if symbol has offset 0 2009-08-24 13:30:01 +02:00
grischka
f88350b611 fix some warning 2009-07-18 22:07:51 +02:00
grischka
c998985c74 cleanup: constify some global data 2009-07-18 22:07:42 +02:00
grischka
1df662c1b0 tccpe: load dll on the fly 2009-07-18 22:07:25 +02:00
grischka
035918ef2f win64: fix pointer <-> unsigned long typecast issues 2009-07-18 22:05:58 +02:00
grischka
3ea4acb9b9 pe32+ target: add in various #define's 2009-07-18 22:05:27 +02:00
grischka
370cdeb628 tccpe: build IAT vector with with -run too
This prepares for x86_64 where we need the vector
for far jumps.  Also, resolve DLL symbols in place
2009-07-18 21:55:15 +02:00
grischka
bba515afe5 tccelf: accept BSS symbol with same name from other module
... such as 'int baz;' in two files at the same time
2009-06-17 02:08:54 +02:00
grischka
68310299b6 ulibc: #define TCC_UCLIBC and load elf_interp 2009-05-16 22:29:40 +02:00
grischka
03c787d6ce fix unused/uninitalized warnings 2009-05-11 18:46:39 +02:00
grischka
40f5ce002e fix warnings with tcc_add/get_symbol 2009-05-11 18:46:25 +02:00
grischka
f9181416f6 move some global variables into TCCState 2009-05-11 18:45:44 +02:00