Commit Graph

169 Commits (98afe11c85ad4834c05fffb226d6b9e7926f4f88)

Author SHA1 Message Date
Thomas Preud'homme 361ec4f98e Call fill_got_entry unconditionally
Call fill_got_entry unconditionally from fill_got so as to avoid
warnings on !x86-64 architectures. This can be done since this code path
is only followed by x86-64 architecture anyway.
2014-02-10 21:35:00 +08:00
Thomas Preud'homme e571850d79 Add support of Thumb to ARM branch relocation 2014-02-06 21:38:24 +08:00
Thomas Preud'homme 4aec2902ca Split elf_output_file in smaller functions 2014-02-06 19:38:28 +08:00
Thomas Preud'homme 55f751ac6d Add macro to browse reloc and sym entries
Introduce for_each_elem to browse relocation entries and symbols of a
section.
2014-02-06 19:38:24 +08:00
Thomas Preud'homme 2eb844f8b5 Revert "Add macro to browse reloc and sym entries"
This reverts commit 3cbc7a2dcc.
2014-02-02 20:02:12 +08:00
Thomas Preud'homme e5a706a091 Revert "Split elf_output_file in smaller functions"
This reverts commit b5b82df3e3.
2014-02-02 20:02:11 +08:00
Thomas Preud'homme f62e97e0ed Revert "Add support of Thumb to ARM branch relocation"
This reverts commit 8635939b8d.
2014-02-02 20:02:08 +08:00
Thomas Preud'homme 8635939b8d Add support of Thumb to ARM branch relocation 2014-02-02 17:23:15 +08:00
Thomas Preud'homme b5b82df3e3 Split elf_output_file in smaller functions 2014-02-02 17:23:15 +08:00
Thomas Preud'homme 3cbc7a2dcc Add macro to browse reloc and sym entries
Introduce for_each_elem to browse relocation entries and symbols of a
section.
2014-02-02 17:23:15 +08:00
Thomas Preud'homme 599677a5e2 Give ARM asm mnemonic of PLT entries
Give ARM assembly mnemonic of PLT entries in put_got_entry
2014-02-02 17:23:15 +08:00
Thomas Preud'homme 3d4b57ffe3 Clean tccelf.c
- remove debug printf and commented out code
- remove C++-like comments
- remove whitespace at end of lines
- replace tabs by spaces
2014-02-02 17:23:14 +08:00
Thomas Preud'homme da0601e490 Remove WITHOUT_LIBTCC macro: no more user 2014-01-08 21:32:53 +08:00
Thomas Preud'homme 3352cb8aef Shared libraries also have entry points
This fix commit 32734680cb
2014-01-08 18:10:02 +08:00
Thomas Preud'homme 32734680cb Improve ELF on ARM
* set whether soft or hardfloat calling convention is used
* mark ELF file has having an entry point when there is
2014-01-08 17:59:16 +08:00
Thomas Preud'homme 28f0286479 Update elf.h 2014-01-08 17:38:31 +08:00
Thomas Preud'homme b6247d1f3c Add support for runtime selection of float ABI 2014-01-08 15:00:52 +08:00
grischka 4ad186c5ef i386: use __fixdfdi instead of __tcc_cvt_ftol
Variants __fixsfdi/__fixxfdi are not needed for now because
the value is converted to double always.

Also:
- remove __tcc_fpinit for unix as it seems redundant by the
  __setfpucw call in the startup code
- avoid reference to s->runtime_main in cross compilers
- configure: fix --with-libgcc help
- tcctok.h: cleanup
2014-01-06 19:07:08 +01:00
Thomas Preud'homme 9e79b18bca Use libtcc.a for static link even with USE_LIBGCC
When statically linking, runtime library should be static as well. tcc
could link with libgcc.a but it's in a gcc version specific directory.
Another solution, followed by this patch, is to use libtcc.a when
statically linking, even if USE_LIBGCC was configured.
2014-01-03 18:20:51 +08:00
Thomas Preud'homme 1b606d1884 Allow thumb transition for R_ARM_PC24
Allow bl -> blx conversion in the case of R_ARM_PC24 relocation with
instruction being an unconditional bl. Also make spacing more uniform.
2013-11-18 00:03:38 +08:00
Thomas Preud'homme cf02f920c1 Revert "Add support for thread-local storage variables"
TLS support in tinyCC is absolutely not ready:
- segment register not select in load and store
- no relocation added for computing offset of per-thread symbol
- no support for TLS-specific relocations
- no program header added as per Drepper document about TLS

This reverts commit 1c4afd1350.
2013-11-03 18:55:54 +08:00
Thomas Preud'homme 1c4afd1350 Add support for thread-local storage variables 2013-10-29 22:10:02 +08:00
Urs Janssen 0bdbd49eac add version number to manpage
avoid c++/c99 style comments in preprocessor directives
avoid leadings whitespaces in preprocessor directives
mention implemented variable length arrays in documentation
fixed ambiguous option in texi2html call (Austin English)
2013-02-17 00:48:51 +01:00
grischka 05108a3b0a libtcc: new LIBTCCAPI tcc_set_options(TCCState*, const char*str)
This replaces       -> use instead:
-----------------------------------
- tcc_set_linker    -> tcc_set_options(s, "-Wl,...");
- tcc_set_warning   -> tcc_set_options(s, "-W...");
- tcc_enable_debug  -> tcc_set_options(s, "-g");

parse_args is moved to libtcc.c (now tcc_parse_args).

Also some cleanups:
- reorder TCCState members
- add some comments here and there
- do not use argv's directly, make string copies
- use const char* in tcc_set_linker
- tccpe: use fd instead of fp

tested with -D MEM_DEBUG: 0 bytes left
2013-02-12 19:13:28 +01:00
grischka d6d7686b60 tcc.h: declare CValue.tab[LDOUBLE_SIZE/4]
Should fix some warnings wrt. access out of array bounds.

tccelf.c: fix "static function unused" warning
x86_64-gen.c: fix "ctype.ref uninitialzed" warning and cleanup
tcc-win32.txt: remove obsolete limitation notes.
2013-02-08 19:07:11 +01:00
grischka 7a477d70ca lib/Makefile: use CC, add bcheck to libtcc1.a
Also:
- fix "make tcc_p" (profiling version)
- remove old gcc flags:
  -mpreferred-stack-boundary=2 -march=i386 -falign-functions=0
- remove test "hello" for Darwin (cannot compile to file)
2013-02-06 19:01:07 +01:00
grischka 92024ab07a tccelf: fix debug section relocation
With:
   tcc -g hello.c
   gdb a.out
     b main
gdb refused to know "main" because of broken dwarf info.

This partially reverts commit 0d598aca08.
I don't remember what the problem was but it was the wrong way
to fix it.
2013-02-05 21:18:29 +01:00
grischka e0aee4f455 portability: make tcc_get_symbol() available for non-native
For consistency with tcc_add_symbol().
Use uintptr_t here also.
2013-02-04 20:57:57 +01:00
grischka 82bcbd027f portability: fix void* <-> target address conversion confusion
- #define addr_t as ElfW(Addr)
- replace uplong by addr_t
- #define TCC_HAS_RUNTIME_PLTGOT and use it
2013-02-04 16:24:59 +01:00
Thomas Preud'homme ae33c30b49 Revert "Don't call elf_hash on NULL value"
This reverts commit 505329b5b3.
2013-01-31 13:43:04 +01:00
grischka 2f6b8469cc safety: replace occurrences of strcpy by pstrcpy 2013-01-31 13:23:19 +01:00
Domingo Alvarez Duarte 505329b5b3 Don't call elf_hash on NULL value
Make sur elf_hash is never invoked with a NULL value.

Signed-off-by: Thomas Preud'homme <robotux@celest.fr>
2013-01-31 12:07:20 +01:00
Thomas Preud'homme bcac413c30 Fix overflow detection in ARM relocation
Fix overflow detection for R_ARM_CALL, R_ARM_PC24, R_ARM_JUMP24 and
R_ARM_PLT32 relocations on ARM. 26 bits means 25 bits for positive and
negative offsets !
2013-01-28 19:13:25 +01:00
Thomas Preud'homme f8cde52984 Link STT_GNU_IFUNC into STT_FUNC in executable.
Indirect functions shall have STT_FUNC type in executable dynsym
section. Indeed, a dlsym call following a lazy resolution would pick the
symbol value from the executable dynsym entry. This would contain the
address of the function wanted by the caller of dlsym instead of the
address of the function that would return that address.
2013-01-25 20:06:51 +01:00
Thomas Preud'homme 8c56b0cf90 Revert "Added what I call virtual io to tinycc this way we can make a monolitic executable or library that contains all needed to compile programs, truly tinycc portable."
This reverts commit 59e18aee0e.
tcc is being stabilized now in order to do a new release soon.
Therefore, such a change is not appropriate now.
2013-01-14 17:34:07 +01:00
mingodad 59e18aee0e Added what I call virtual io to tinycc this way we can make a monolitic executable or library that contains all needed to compile programs, truly tinycc portable.
Tested under linux exec the "mk-it" shell script and you'll end up with a portable tinycc executable that doesn't depend on anything else.
2013-01-11 00:04:38 +00:00
Thomas Preud'homme e2212738d4 Generate PLT thumb stub only when necessary
Generate PLT thumb stub for an ARM PLT entry only when at least one
Thumb instruction branches to that entry. This is a rewrite of the
previous patch.
2012-11-17 10:01:11 +01:00
Thomas Preud'homme 1af3bca4ea Revert "Generate PLT thumb stub only when necessary"
Revert commit 891dfcdf3f since it assumes
*all* architectures supported by tcc have GOT offsets aligned on 2. A
rework of this commit is being done since without it all PLT entries
grow by 4 bytes.
2012-11-12 23:14:21 +01:00
Thomas Preud'homme 14c99236da Call to veneers in ARM mode
Since commit c6630ef92a, Call to a veneer
when the final symbol to be reached is thumb is made through a blx
instruction. This is a mistake since veneers are ARM instructions and
should thus be called with a simple bl. This commit prevent the bl ->
blx conversion when a veneer is used.
2012-11-09 10:59:06 +01:00
Thomas Preud'homme 891dfcdf3f Generate PLT thumb stub only when necessary
Generate PLT thumb stub for an ARM PLT entry only when at least one
Thumb instruction branches to that entry.

Warning: To save space, this commit reuses the bit 0 of entries of
got_offsets array. The GOT offset is thus saved in a 31 bit value.
Make sure to divide by 2 (right shift by 1) an offset before storing it
there and conversely to multiply the value by 2 (left shift by 1) before
using it.
2012-11-07 20:51:33 +01:00
Thomas Preud'homme e07802e39d Support R_ARM_THM_JUMP24 relocation to plt
Add thumb stubs switching from thumb mode to arm mode to *all* PLT
entries so that R_ARM_THM_JUMP24 relocations to PLT entries can be
satisfied.
2012-11-07 20:48:14 +01:00
Thomas Preud'homme fad68c9163 Add support for R_ARM_THM_{JUMP24,CALL} relocs
Add support for relocations R_ARM_THM_JUMP24 and R_ARM_THM_CALL. These
are encountered with gcc when compiling for armv6 or greater with
-mthumb flag and a call (conditional or not) is done.
2012-10-28 19:55:12 +01:00
Thomas Preud'homme 9966fd4eae Only use blx if available
Introduce ARM version for the target architecture in order to determine
if blx instruction can be used or not. Availability of blx instruction
allows for more scenarii supported in R_ARM_CALL relocation. It should
also be useful when introducing support for the R_ARM_THM_CALL
relocation.
2012-10-16 00:31:56 +02:00
Thomas Preud'homme c6630ef92a Fix R_ARM_CALL when target fonction is Thumb
With R_ARM_CALL, if target function is to be entered in Thumb mode, the
relocation is supposed to transform bl in blx. This is not the case
actually so this commit is there to fix it.
2012-10-10 00:21:26 +02:00
Thomas Preud'homme 2fe7fd9e87 Support for R_ARM_[THM_]MOV{W,T}_ABS[_NC} relocs
Add support for relocations R_ARM_MOVW_ABS_NC and R_ARM_MOVT_ABS as well
as their Thumb2 counterpart R_ARM_THM_MOVW_ABS_NC and
R_ARM_THM_MOVT_ABS. These are encountered with gcc when compiling for
armv7-a and a data is loaded in a register, either in arm or Thumb2
mode. The first half of the data is loaded with movw ; the second half
is loaded with movt.
2012-10-10 00:19:43 +02:00
Thomas Preud'homme ed9c6b132a Fix R_ARM_REL32 relocation
Add missing break in the code handling R_ARM_REL32 relocation.
2012-07-09 18:41:55 +02:00
Thomas Preud'homme 9a81dcab0a tccelf.c: Add R_ARM_REL32 relocation 2012-06-05 23:09:55 +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 f1b5c2ef4f tcc_realloc: auto "memory full" error 2012-04-18 18:43:55 +02: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