Sym.sym_scope and Sym.f (FuncAttr) share space, so blindly setting
one clobbers the other. Right now this only leads to missing errors
on incompatible typedefs (see testcase), which this commit fixes.
But it points to a larger problem:
Generally we can only manipulate Sym.f for anonymous and field symbols,
not for anything that has a top-level name (basically any proper decl),
because the latter use sym_scope. Luckily the functions type always
contains an anonymous symbol (in sym->type.ref), so we can use that.
But some of the functions attributes actually _do_ apply to the decl,
not the type (e.g. always_inline), so we still have a problem possibly,
when we update an pre-existing type that may already be shared with
another decl.
Would need untangling and perhaps using accessor functions that check
that Sym.f and Sym.sym_scope aren't used for the same symbol.
I have a testfile created by YARPGen (seed=9), which displayed
a negative bss size without this patch.
* tcc needs also a bigger VSTACK_SIZE (i used 512)
--
bye bye ... Detlef
I have a testfile created by YARPGen (seed=9), which displayed
a negative bss size without this patch.
* tcc needs also a bigger VSTACK_SIZE (i used 512)
--
bye bye ... Detlef
The last commit was not a problem with macos.
The problem was that dwarf version < 5 uses different indexes for
files and directories.
They start at 1 for dwarf version < 5 and 0 for dwarf version >= 5.
In tcc_load_object_file use unsigned long for size/offset.
This avoids strange sizes of sections in case of overflow.
The sections that are now larger then 4G may not work.
This avoids a hang on macos in realloc.
On macos we cannot use the ar because is does not support elf files
and then does not generate a symbol table.
The solution is to use 'tcc -ar'. The problem now is that some
pacages first built an archive with 'tcc -ar c' and later extracts
the archive with 'tcc -ar x' and built with this a dylib file.
The 'tcc -ar x' failed. So I implemented it. I also added the t
option because it was simple to do,
With these option I can now built several packages without problem.
There are a lot of options we can add so I tried to implement the
minumum.
Add the following options:
dynamiclib same as -shared
flat_namespace default/ignored
two_levelnamespace ignored
undefined default/ignored
install_name name of dynmic lib
compatibility_version version dynamic lib
current_version version version dynamic lib
-Wl options:
all_load same as whole-archive
force_load same as whole-archive with lib
single_module ignored
Export now all global symbols in export trie instead of only text
symbols.
I wrote too much data into dylib file because I did not check
for sk_unknown/sk_discard/sk_uw_info.
Simplified code in tccrun.c
Needed when using ...libtcc1-usegcc=yes in lib/Makefile.
lib/bcheck.c: Add __clang__ for pragma diagnostic
lib/bt-log.c: Add pragma diagnostic as in lib/bcheck.c
lib/builtin.c: Add a lot of alias code to allow building with gcc/clang
lib/stdatomic.c: Same as lib/builtin.c
lib/tcov.c: Avoid clang compiler warning
Update configure and remove dll=no for Darwin.
Also removed dwarf=$dwarf because this is not a config option.
In tccelf.c only add __PAGEZERO if stabs and executable.
In tccrun.c correct rt_printline_dwarf code for dll.
In tests/Makefile disable dlltest with PIC for Darwin because object
format of .o file is still in elf.
In tccmacho.c add dll support and and rpath support.
Corrected trie code. For some reason symbol 'xx' should be after 'xx1'.
Corrected weak symbol support for old macho code.
Used R_JMP_SLOT instead of R_DATA_PTR in check_relocs.
I tested on macos 10, 11, 12 and 13 that old and new macho code work.
I do not know when this new format is introduced but it is now
available on a lot of versions. So make it the default.
Also default to dwarf=4 because stabs and dwarf=5 is not supported.
The test failed because atexit/on_exit code was not correct.
Make it look more like the g_exit_context.
Added a sleep to libtcc_test_mt to allow overlap of threads to
detect this problem.
The last commit only worked on arm64.
The problem was that the new __DWARF segment was empty.
I now remove the __DWARF segment if it is not needed.
This resolves the rebase problem on x86_64.
Update tccrun.c to detect rebase for dwarf debug info.
Enabled testcase 126 on macos.
Add prologue_end/epilogue_begin supoort in tcc.h, tccdbg.c, tccgen.c.