This avoids 'exit(1)' with errors outside of compilation
(nasty in particular with libtcc usage)
As a sideeffect multiple errors can be seen for linker
errors (such as undefined symbols, relocation errors, ...)
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
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.
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.
lldb now works with this push.
In tccmacho.c add S_ATTR_DEBUG to all debug sections.
Add __DWARF section and rearange struct skinfo.
In tccdbg.c The first filename in dwarf_line can not be used.
Also had to fix structure/union/lexical_block/subroutine to
allow empty childs.
dwarfdump --verify complained about this.
The problem is that %n in *printf functions require a format string
that is in a read only section. See man page.
So added __DATA_CONST segment and mapped rodata_section into this segment.
Also added __got to this segment.
Change maxprot of segments to the same values used by clang.
Fix for external functions as pointers in data section.
See testcase 119 and tccmacho.c in check_relocs.
Make bind/rebase code faster in bind_rebase_import.
- Move reloc check out of loop
- Because relocs are sorted we can do bind/rebase by page.
Change name head into seq in trie code.
Remove unused code in bind_rebase.
I removed the FIXME for generating trie code with working code.
I also fixed a problem where:
cc -g -c a.c; cc -o a a.o
created a bind/rebase error because the second cc did not use -g
and .debug sections where not checked correctly.
I also removed the elfinterp printout in tcc.c when
TCC_TARGET_MACHO is set.
Add --config-codesign option to run codesign on apple to sign executables.
See configure and Makefile
In tccmacho.c use codesign option to call codesign application.
Add build_version/source_version
Sort sections in __LINKEDIT the same way as llvm does.
Add simple support for trie code. Need some more attention.
Fix rebase/bind error.
Apple has a new object format that uses chained fixups.
I have implemented this with a configure option '--config-new_macho'
See configure and Makefile
tccmacho.c contains the biggest change.
I split the lazy_bind_rebase structure into lazy_bind and rebase for the
old format.
Under the macro CONFIG_NEW_MACHO there is the new macho format code.
In arm64-gen.c we do not need to push all registers on stack for
variadic functions. variadic parameters are pushed on stack for apple.
There is still one open isue. The export trie is empty.
This only effects dlsym when a local symbol is used.
tested on apple x86_64(10.5) and arm64(12.3).
The apple m1 uses position independent executables (pie).
I have implemented this in tccmacho.c
Apple also uses the stack different for var_args.
Also characters are signed instead of unsigned.
This is implemented in arm64-gen.c/tccdefs.h
Add bounds checking lib to lib/Makefile.
Add underscore support in lib/atomic.S and lib/fetch_and_add.S
Disable __clear_cache in lib/lib-arm64.c (Use system version).
I will try to fix this in future push.
Disable test_asm_call in tests/tcctest.c. Clang does not support @plt.
Also disable weak symbols test.
I will try to fix weak support in future push.
Disable tests/tests2/124_atomic_counter.c for 64BITS.
This is a bug in the atomic code and will be fixed in future push.
You have to use --dwarf configure option. stabs only works with -run.
tested on apple x86_64(10.5) and arm64(12.3).
libtcc.c:
- integrate find_dllref loop into tcc_add_dllref()
tccelf.c:
- make sure a DT_NEEDED tag is put for versions even
when the dll was not previously loaded.
Related commit 4c82b00342
48 insertions(+), 77 deletions(-)
/* Use "-g" as alias for "-g1". Use "-g0" to disable debug */
So not using -g is now the alias for -g0 ?!?
This reverts commit 8759b2581d.
This reverts commit 3ce7bc6efc.
This reverts commit 5fb582ab7f.
This reverts commit aea68dbb40.
This reverts commit fa9c31c3db.
This reverts commit b3bebdb20a.
This reverts commit ecf8e5a00e.
This reverts commit fe6b5c08dc.
This reverts commit e2e5377e7b.
This reverts commit 1cd7998905.
Currently used only with 'tcc_compile_sem' to protect
tcc_compile(), but can be used with other semaphores
Also fix deadlock when tcc_enter_state() is called
recursively for the same state, for example with
tcc_warning() from #pragma comment(option,"...")
Also:
- libtcc.c: error1(): use cstr_[v]printf()
- tcc.h: set TCC_USING_DOUBLE_FOR_LDOUBLE for macho-arm64
(rather than for macho-X86_64)
- tcc.h: define TCC_TARGET_MACHO on __APPLE__ by default
- tcc.h: cleanup TCCState, move DEFASM token stuff to tcctok.h
- tccgen.c: more static
- Makefile/tcc.c: review githash
- tccpe/tcctools: use read() instead of fgets() in pe_load_def()
(all files opened by tcc for reading are now read via 'int fd')
- configure/win32: don't preset CONFIG_TCCDIR (to allow to override it)
- tcc.c -bench: do not include output/run-time
configure:
- re-enable apple M1-arm64
- however, with --cpu=x86_64, set -arch in CFLAGS/LDFLAGS too
(assume rosetta)
Makefile:
- re-enable osx cross-test (Please do not disable tests)
tcc.h
- set TCC_IS_NATIVE for TCC_TARGET_MACHO on __APPLE__
- apply TCC_USING_DOUBLE_FOR_LDOUBLE for x86_64-osx
libtcc.c:
- cleanup tcc_add_file_internal()
- new function char *tcc_load_text(int fd); and use it for tbd files
Supports linking using .tbd definitions found in the default installed
command-line tools SDK or Xcode.app SDK. Only for creating executables
(not yet for `tcc -run`).
libtcc.c: add -Wwrite-strings to -Wall
tccgen.c: ro float-consts, string-consts, ro arrays if base type is
tccpe.c: merge IAT with rodata
tccrun.c: mprotect rodata accordingly. free section data after copy
x86_64.c: do not use got for static data.
tcc -bench: show data.rw/ro
Probably STB_LOCAL should never get to put_got_entry(), and currently
it doesn't seem to happen (See "Hack Alarm" there)
Other files: use more ro-data in tinycc
- tccpe.c: commit "tidy support for helper function" created
STT_NOTYPE symbols and hence relied on ad-hoc detection which
didn't work for x86_64 (as reported by Christian Jullien)
- tccgen.c: However to be more safe the helper symbols are
now made STT_FUNC anyway (via new VT_ASM_FUNC).
Also:
- tcc.h: minor reorder
- riscv64-*, arm64-*, tccmacho.c: avoid some gcc format-warnings
(mingw-gcc complains about "%llx" being "unknown conversion",
although it does work since Vista or so)
tested on win32/64 to pass the tests when enabled
- libtcc.c :
let tcc define __leading_underscore if enabled
tcc_add_symbol() : add _ automatically
- tccelf.c : remove tcc_get_symbol_err(), find_c_sym()
currently symbol length is limited to 256 in several
places, so we can use a fixed local buffer for now as well.
- win32/lib/crtinit.c : new file for init/fini
- lib/*.S, tests7* : use __leading_underscore
- bt-log.c: this file wont work relibaly if compiled with gcc
- configure/Makefile : cleanup, really use CC_NAME
- tccasm.c : remove C99 construct that MSVC doesn't compile
- arm-gen.c, x86_64-gen.c, riscv64-gen.c, tccmacho.c : ditto
- arm64-gen.c: commit 383acf8eff wrote:
"Instead of a cast, it would be better to pass the exact type."
It is true that there are better solutions but it is not
passing the exact type (I think).
- tcctest.c: revert "fix cast test for clang" 03646ad46f
this obviously wants to test non-portable conversions
- 114_bound_signal.test: clock_nanosleep is too new for older
linuxes, just use sleep() instead