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.
This commit is contained in:
31
tccelf.c
31
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
|
||||
|
||||
Reference in New Issue
Block a user