Disable warning softfloat. OpenBSD works fine.
save/restore s0-s15 during memcpy call for structs
update configure script. Works now on raspberry pi/All BSD
Add eabi_mem.. functions in armeabi.c for OpenBSD
Fix fp register in tccrun.c for OpenBSD
Support OpenBSD/FreeBSD/NetBSD on asm.
move PAGESIZE to tcc.h and use _SC_PAGESIZE (netbsd/arm has 8192 pagesize)
arm:
- fix cmp instruction for qemu (raspberry pi works without patch?)
- increase start address/size
- use large plt size
- add return R_ARM_PREL31
- add R_ARM_TARGET1 to prepare_dynamic_rel
- add gcc_s to FreeBSD (unwind code)
- do not use __clear_cache on bsd (sometimes bad system call)
- do stack unwinding on bsd
- test/tcctest.c: use %lld %llu on bsd
- i386: Align first argument on a 16 byte boundary.
- arm64: Support Apple's version of the AArch64 ABI, including zero-
extension of variadic arguments smaller than 32 bits.
- arm64e: Make all indirect branches authenticated, and sign function
pointer values both from the perspective of the C code and when
looking up symbols.
- arm64e: Support signing and stripping pointers.
- Query page size to support text segments larger than 4096 bytes on
i/macOS systems with 16K pages.
- Avoid RWX page allocations on most platforms as they're off limits on
modern Apple platforms.
- Split relocation and marking pages executable to avoid crashing when
marking fails.
Co-authored-by: Francesco Tamagni <mrmacete@protonmail.ch>
As they're off limits on some Apple platforms and we want to have the
same behavior on all platforms supported by Frida.
At some point it would be good to evolve TinyCC to support putting
writable data on separate pages.
- tcc.h: msvc doesn't grok __func__ (reverts previous commit)
- tccgen.c: fortify tcc against bogus code:
- n[sizeof({3;})]; // statement expression outside of function
- f(){"123"4}; // tokens with values following each other
(also, add "type defaults to int" warning for variables)
- tccpe.c: removed a check that caused BSS symbols not to be
exported. Whatever that check was meant to prevent.
- win32/build-tcc.bat: cmd.exe sometimes doesn't grok '-' in labels
- Revert "libtcc: no need to undef"
This reverts commit 2b7aa2a1e1.
- Revert "tcc.h libtcc.c: remove unused defines"
This reverts commit 985d963745.
The point of these "unused defines" is to be unused, that is
to remind people not to use malloc but please to "use_tcc_malloc",
instead.
pretty sure that functions with use_* do not exist
and attempts to use the macros will fail to link
I could rename them to be more up to date like tcc_malloc,
but to me overloading the std calls with macros is
probably taking away control from the programmer,
so for the best is to just get rid of them.
Fixes potential writes past the allocated space with mostly
illegal flex array initializers. (60_errors_and_warnings.c
:test_var_array)
In exchange suspicious precautions such as section_reserve
or checks with sec->data_allocated were removed. (There is
an hard check 'init_assert()' for now but it's meant to be
just temporary)
Also, instead of filling holes, always memset(0) structures
& arrays on stack. Sometimes more efficient, sometimes isn't.
At least we can omit putting null initializers.
About array range inititializers: Reparsing tokens has a
small problem with sideeffects, for example
int c = 0, dd[] = { [0 ... 1] = ++c, [2 ... 3] = ++c };
Also, instead of 'squeeze_multi_relocs()', delete pre-existing
relocations in advance. This works even if secondary initializers
don't even have relocations, as with
[0 ... 7] = &stuff,
[4] = NULL
Also, in tcc.h: new macro "tcc_internal_error()"
Always fine to try out things but not everything must be shown
to the public. ;)
Also, AFAIK pointers must compare equal only if derived directly
from each other (for example by cast to void* and back).
This reverts commit 8f9bf3f223.
Arm has a problem with tls after a fork. The pthread_key_create seems to
be forgotten?
Apple has a problem with the exit(0) code in do_fork(). An IO mutex
is still held after a fork().
While MacOS doesn't natively support the alias attribute, let's support
it with TCC anyway. This means we need to make a decision if the
string in the alias attribute is decorated or not due to the implicit
underscore on MacOS. To make life easier we decide that it's the C name,
i.e. without underscore, and so TCC needs to emit alias names with
underscore handling.
Irrespective of that the test case needs to deal with the underscore
itself for __asm__ renaming which is always requiring the assembler name.
The init range with symbols did only init the first value.
The relocation for all other symbols was missing.
Also see testcase.
tccgen.c:
- New function get_init_string
- Use macro processing in decl_designator for each init string
- Use get_init_string in decl_initializer_alloc
tccelf.c:
- Fix insertion sort in squeeze_multi_relocs
tests/tests2/90_struct-init.c:
- Add test case test_init_ranges
tccgen.c:
- Fix 'tcc -b conftest.s'
- Add offset during bound checking for struct return
lib/bcheck.c:
- Check overlap when reusing vla/alloca
arm-gen.c:
arm64-gen.c:
riscv64-gen.c:
lib/alloca86-bt.S:
- add space for vla/alloca during bound checking
tests/tests2/Makefile:
tests/tests2/121_struct_return:
tests/tests2/122_vla_reuse:
- New test cases with bound checking enabled to test vla and struct return
commit 2a0167a merged alias and asm symbol renaming, but broke
semantics of aliases, see testcase. Basically the difference between
the two is that an asm rename doesn't generate a new symbol, i.e. with
int foo __asm__("bar");
all source reference to 'foo' will be to 'bar', nothing of the name
'foo' will remain in the object file, and for instance reference to
'foo' from other compilation units won't be resolved to this one.
Aliases OTOH create an additional symbol. With:
void target (void) { return; }
void afunc (void) __attribute__((alias("target")));
reference to 'afunc' will remain 'afunc' in the object file. It will
generate two symbols, 'afunc' and 'target' referring to the same entity.
This difference matters if other compilation units make references to
'afunc'.
A side requirement of this is that for alias to work that the target
symbol needs to be defined in the same unit. For TCC we even require a
stricter variant: it must be defined before the alias is created.
Now, with this I merely re-instated the old flow of events before above
commit. It didn't seem useful anymore to place both names in the
asm_label member of attributes, and the asm_label member of Sym now
again only needs the hold the __asm__ rename.
It also follows that tcc_predefs.h can't make use of attribute alias to
e.g. map __builtin_memcpy to __bound_memcpy (simply because the latter
isn't defined in all units), but rather must use __asm__ renaming, which
in turn means that the underscore handling needs to be done by hand.
tccelf.c:
- Check if symbol is in data section and UNDEF. Then generate new
relocation and let dynamic linker solve it.
tests/tests2/42_function_pointer.c:
- Add new test code
The code:
struct bf_SS {unsigned int bit:1,bits31:31; };
void func(void) {
struct bf_SS bf_finit = { .bit = 1 };
}
will not init bits31 to 0.
tccgen.c:
- check_bf: New function to check if bitfield is present in struct/union
- decl_initializer: Call check_bf and set value to 0 is bitfield found
tests/tcctest.c:
- Add struct bitfield test code