aboutsummaryrefslogtreecommitdiff
path: root/tccelf.c
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2015-04-10 07:37:31 +0300
committerseyko <seyko2@gmail.com>2015-04-10 07:37:31 +0300
commit7e7e6148fdb4adbda936f80b5d4ac3d738908d95 (patch)
tree37bb17e54d38fdb905b79ba8dfa996500f066abe /tccelf.c
parent5cd4393a542ef4c64df7dcbb3fbe3a629666239d (diff)
downloadtinycc-7e7e6148fdb4adbda936f80b5d4ac3d738908d95.tar.gz
tinycc-7e7e6148fdb4adbda936f80b5d4ac3d738908d95.tar.bz2
fix installation amd bcheck for Windows
* define targetos=Windows when --enable-tcc32-mingw, --enable-cygwin, ... * use TARGETOS insteed HOST_OS when selecting PROGS * use "$(tccdir)" insteed $(tccdir) on install (spaces in path) * install tcc.exe too * produce bcheck.o when cross-compiling too (lib/Makefile) * force bcheck.o linking by compiling inside tcc_set_output_type() a dummy program with local array. Otherwise bcheck.o may be not linked. * replace %xz format specifier with %p in bcheck (don't supported on Windows) * call a __bound_init when __bound_ptr_add, __bound_ptr_indir, __bound_new_region, __bound_delete_region called. This is because a __bound_init inside ".init" section is not called on Windows for unknown reason. * print on stderr a message when an illegal pointer is returned: there is no segmentation violation on Windows for a program compiled with "tcc -b" * remove "C:" subdir on clean if $HOST_OS = "Linux" * default CFLAGS="-Wall -g -O0" insteed CFLAGS="-Wall -g -O2" to speed up compilation and more precise debugging.
Diffstat (limited to 'tccelf.c')
-rw-r--r--tccelf.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/tccelf.c b/tccelf.c
index 5ca5089..ac91456 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -1569,9 +1569,6 @@ ST_FUNC void tcc_add_bcheck(TCCState *s1)
{
#ifdef CONFIG_TCC_BCHECK
addr_t *ptr;
- Section *init_section;
- unsigned char *pinit;
- int sym_index;
if (0 == s1->do_bounds_check)
return;
@@ -1585,19 +1582,23 @@ ST_FUNC void tcc_add_bcheck(TCCState *s1)
#ifdef TCC_TARGET_I386
if (s1->output_type != TCC_OUTPUT_MEMORY) {
/* add 'call __bound_init()' in .init section */
- init_section = find_section(s1, ".init");
- pinit = section_ptr_add(init_section, 5);
- pinit[0] = 0xe8;
- put32(pinit + 1, -4);
- sym_index = find_elf_sym(symtab_section, "__bound_init");
- if (!sym_index) {
- tcc_add_support(s1, "bcheck.o");
- sym_index = find_elf_sym(symtab_section, "__bound_init");
- if (!sym_index)
- tcc_error("__bound_init not defined");
- }
- put_elf_reloc(symtab_section, init_section,
+
+ /* XXX not called on MSYS, reason is unknown. For this
+ case a call to __bound_init is performed in bcheck.c
+ when __bound_ptr_add, __bound_new_region,
+ __bound_delete_region called */
+
+ int sym_index = find_elf_sym(symtab_section, "__bound_init");
+ if (sym_index) {
+ Section *init_section = find_section(s1, ".init");
+ unsigned char *pinit = section_ptr_add(init_section, 5);
+ pinit[0] = 0xe8;
+ put32(pinit + 1, -4);
+ put_elf_reloc(symtab_section, init_section,
init_section->data_offset - 4, R_386_PC32, sym_index);
+ }
+ else
+ tcc_warning("__bound_init not defined");
}
#endif
#endif