Commit Graph

2998 Commits

Author SHA1 Message Date
Danny Milosavljevic
9d302620c2
arm-asm: Remove asm_error 2021-01-03 02:34:10 +01:00
Danny Milosavljevic
b10824dcdc
arm-asm: Update copyright header 2021-01-03 02:34:10 +01:00
Danny Milosavljevic
f88ded6c2d
arm-asm: Implement asm_parse_regvar and asm_clobber 2021-01-03 02:34:10 +01:00
Danny Milosavljevic
4a6fb47b8d
arm-asm: Publish g, gen_le16, gen_le32 in tcc.h 2021-01-03 02:34:10 +01:00
herman ten brugge
3221cc4a5a Align next section after gnu_ro to pagesize
To allow remapping the ro section the next section must start
on a new page.
2021-01-02 15:17:25 +01:00
Christian Jullien
b147a37c23 Remove useless [u]intN_t definitions from stddef.h 2021-01-02 11:23:26 +01:00
Christian Jullien
c9fe8fe470 Yet another int64_t/uint64_t definition fix. For wine this time. 2021-01-02 05:58:46 +01:00
herman ten brugge
2633c30fb4 riscv64 update
implement load/store to constant address
use VT_LLONG instead of VT_PTR in register passing
fix bound checking problem with small structs
enable riscv tests in tests/tcctest.c and tests/tests2/119_random_stuff.c
2021-01-01 20:36:57 +01:00
Christian Jullien
9a2a05ba1e *BSD: fix extra #endif 2021-01-01 16:01:03 +01:00
Christian Jullien
33257c6439 *BSD: protect against incompatible redefinitions of int64_t/uint64_t. 2021-01-01 08:50:13 +01:00
herman ten brugge
8db839cc85 FreeBSD32 struct return 2020-12-31 06:48:14 +01:00
herman ten brugge
9d49883895 update clang warning 2020-12-31 06:39:56 +01:00
grischka
ea82d0826d tccpp: cleanup target-os defines
moved target_machine defines to the <target>-gen.c files.

Also:
- c2str.c moved into conftest.c
- tccdefs.h ; defined(__TINYC__) && !defined(_LOCORE) removed
  (in tinycc __TINYC__ is always defined and _LO... is never.)
- stddef.h : too many #ifdefs, removed
- tccgen.c:stabs: support win32 long doubles aka doubles.
- win32: math.h/tcc_libm.h: fix pointer mismatch in modfl
- tccpp.c: increment include_stack_ptr after the file was
  actually found otherwise it would print
  "in file included from <itself>: file not found..."
2020-12-31 02:03:31 +01:00
Michael Matz
d784b28877 No need for sm_table.size entry
the sh_size input member is reliable, we don't need to duplicate
it in the section mapping info.
2020-12-31 01:21:52 +01:00
Michael Matz
b117088a91 Explain some reloc hackery
just changes a comment; it's not specific to __dso_handle, but general
to all hidden defined symbols for shared libraries.
2020-12-31 00:54:00 +01:00
Michael Matz
60eac659d4 fix cross compiler compilation
{l,}bounds_section is only conditionally defined.
2020-12-31 00:16:23 +01:00
herman ten brugge
cf10c1db66 Fix clang warnings 2020-12-30 19:12:05 +01:00
herman ten brugge
85b6efbf0c Real fix include SHT_NOTE sections everywhere
Thinko in last commit
2020-12-30 18:23:43 +01:00
herman ten brugge
766bd82032 Fix include SHT_NOTE sections everywhere 2020-12-30 16:24:15 +01:00
herman ten brugge
0821940e26 text relocation for netbsd
netbsd does not allow text relocations in text segment.

tcc.h:
- Add data_ro_section
- Fix typo rela.plt

tccelf.c:
- Add data_ro_section
- Make bounds_section/lbounds_section rw
- Add GNU_RELRO section for data_ro_section/bounds_section/lbounds_section
- Fix relocation for __dso_handle in atexit()

tccgen.c:
- Use data_ro_section

x86_64-gen.c:
- Use R_X86_64_PC32 instead of R_X86_64_64 for bounds checking

tests/Makefile, tests/tests2/Makefile
- Enable dll tests for netbsd
2020-12-30 14:08:06 +01:00
Christian Jullien
c13c434383 Fix warnings detected by clang when compiling c2str. 2020-12-30 08:57:30 +01:00
Michael Matz
cc40305a12 Fix errors with parallel make
seen when doing 'make -j i386-tcc tcc', as explained in the comment.
2020-12-25 02:10:43 +01:00
Christian Jullien
16ed67537c NetBSD: longjmp(jmp_buf, 0) is not supported. 2020-12-24 09:29:25 +01:00
Christian Jullien
b9db7c90ee NetBSD: arm64 prevent use of __asm. 2020-12-24 07:31:52 +01:00
Michael Matz
1032e7175a ELF: include SHT_NOTE sections everywhere
... not just on the BSDs.  Sometimes e.g. .note.ABI-tag is allocated
and other sections might contain relocations referring to symbols in
them.  TCC doesn't do any special processing to them, like merging
or somesuch, it just pastes them all together in normal link-editing
behaviour.

(Seen on a recent openSUSE with glibc 2.32, when the crt1.o file
contains debug information)
2020-12-24 07:01:04 +01:00
Christian Jullien
b56099aeb4 NetBSD: arm64 fix int64_t/uint64_t definitions. 2020-12-24 06:50:48 +01:00
Christian Jullien
63e29113ab NetBSD: arm64 requires at least gcc 4.1 to work 2020-12-23 20:52:25 +01:00
Christian Jullien
ba61c7bb37 NetBSD: arm64 is curiously detected as evbarm. Struct uc_mcontext is once again different. 2020-12-23 20:08:26 +01:00
herman ten brugge
f7d2d04d96 Fix include/tccdefs.h
Remove __amd64__ for FreeBD (32 bits version did not work any more)
Add __APPLE__ at HAVE MALLOC_REDIR so bound checking works on apple
2020-12-22 18:53:29 +01:00
herman ten brugge
0352c41a07 add R_ARM_GOT_PREL for clang 2020-12-22 14:31:09 +01:00
grischka
9f6b65230a include/tccdefs.h: moved and use it
tcc_define_symbol(): now only for -D on command line
include/tccdefs.h: converted to strings and compiled into
the tcc executable.  Can be disabled with
    ./configure --config-predefs=no
In this case include/tccdefs.h is loaded at runtime.  This is
default for other build-methods (build-tcc.bat) also (to avoid
some complexity).

Also:
- lib/Makefile: fix typo
- tcc.h : avoid _strto(u)i64 (for TCC on WIN98/2K)
- tccpp.h:cstr_printf() : workaround incompatible vsnprintf's
  (generally faster too)
2020-12-22 11:06:19 +01:00
herman ten brugge
8f8abcc756 more bsd updates
This implements support for FreeBSD on aarch64
This partial implements support on FreeBSD(32). This still needs fixing
i386_gen.c because small structures on this target are passed in registers.

Add aligned 16 to __int128_t for FreeBSD
Support __i386__ on FreeBSD/NetBSD
Fix testcase 115 on FreeBSD/NetBSD
Disable testcase 116 on *BSD* because TLS_FUNC/TLS_VAR not set in bcheck.c
Remove FreeBSD/FreeBSD_kernel code from tccelf.c
2020-12-22 07:02:47 +01:00
Christian Jullien
888f4fd982 FreeBSD (aarch64): fix relocation error. 2020-12-22 05:52:45 +01:00
Christian Jullien
6cc87629b4 NetBSD: define __amd64__ which is sometimes used in headers. 2020-12-20 14:19:55 +01:00
Christian Jullien
a493fbb1fa *BSD: mention all BSD ports in README. 2020-12-20 10:50:07 +01:00
Christian Jullien
d4a4ee798b FreeBSD: Fix multiple ctype inline definitions 2020-12-20 09:45:16 +01:00
Christian Jullien
ac470a49d5 *BSD: Add few __builtin_ math missing definitions. 2020-12-20 07:26:04 +01:00
herman ten brugge
7eea5306e9 rename testcase 106 2020-12-19 21:02:44 +01:00
herman ten brugge
7f898abb82 bsd update
Fix crtbegin/crtend
Use dlsym on all bsd targets
Check .eh_frame on all bsd targets
Disable test3 on FreeBSD and NetBSD and use test1 instead because dlsym not working (WIP)
Disable dlltest and 113_btdll on NetBSD because text relocations are not allowed
Disable 115_bound_setjmp on NetBSD because longjmp is renamed into __longjmp14
2020-12-19 20:55:52 +01:00
herman ten brugge
a87dee588b dlltest_arm
This fixes the dlltest_arm on arm(32)
2020-12-19 20:33:36 +01:00
herman ten brugge
50b4f320dc lazy binding
Currently tcc does not use lazy binding. It puts all relocations in the RELX
section and solve them all at startup.
This was not working on bsd.

tcc.h:
- New RELPLT_SECTION_FMT for plt relocations
- New entry relocplt in struct Section

tccelf.c:
- put_elf_reloca: put R_JMP_SLOT in relocplt section
- build_got_entries*: Use two passes because R_JMP_SLOT and R_GLOB_DAT
                      can not be intermixed on some targets (arm, arm64)
- layout_sections: Calculate correct size relocplt section for DT_ values.
                   Make sure relocplt is last
- fill_dynamic: Add DT_ values when got is filled
                move DT_VERSYM because dynamic linker cannot handle it standone
- Add note section for NetBSD

arm-link.c/arm64-link.c/i386-link.c/riscv64-link.c/x86_64-link.c:
- fill got table with pointer to plt section or symbol value in case
  of TCC_OUTPUT_MEMORY

arm-link.c/arm64-link.c:
- fix offset first plt entry

i386-link.c/x86_64-link.c:
- use correct reloc entry
- use relofs - sizeof (ElfW_Rel) because the reloc is already done

lib/bcheck.c:
- no __libc_freeres on FreeBSD and NetBSD

tests/Makefile:
- Add -fno-stack-protector for OpenBSD

tests/tests2/Makefile:
- disable 106_pthread/114_bound_signal
2020-12-18 15:24:32 +01:00
grischka
e2e62fcb8b replace native platform macros in the compiler
- The compiler should not use these
- However tccrun.c & libtcc1.a files should use these
Also:
- use s1->loaded_dlls for loaded dlls instead of dlopens
- alpine musl: fully supported now and tested
- ./configure ...
   --config-backtrace=no : disable backtraces
   --config-bcheck=no : disable bcheck
- tests:dlltest: enable by default
- tccrun.c : simplify mmaps
- __builtin_alloca : always use asm-alias (instead of #define)
- tccpe.c : use write32le
2020-12-17 12:39:16 +01:00
Christian Jullien
02f61d5b49 riscv64: mention this supported cpu in README. 2020-12-17 09:10:00 +01:00
Christian Jullien
d5519c929c OpenBSD: mention this port on README 2020-12-17 06:22:10 +01:00
herman ten brugge
6eef0e35b4 OpenBSD: testcases
Fix all testcases for openbsd except dlltest.

Remember dlopen calls and use them to fix openbsd dlsym problem
Use crtbeginS.o/crtendS.o for DLL for bsd
Do not include -ldl for __NetBSD__
Redirect malloc, realloc, ..., free for bsd
Align stack in tests/asm-c-connect-*.c for x86_64
Remove -B in tests/pp/Makefile (not supported on bsd)
2020-12-16 17:52:59 +01:00
Christian Jullien
f48a9ed001 FreeBSD (on arm64): partial support, only -run works - WIP 2020-12-13 11:08:44 +01:00
Christian Jullien
eab324a7cf NetBSD (on arm64): reorder cpu detection to detect aarch64 target when cpu is arm64 2020-12-13 10:22:15 +01:00
Christian Jullien
c32cfc1113 NetBSD: predefine __ELF__ macro which is tested by some standard headers 2020-12-13 07:24:01 +01:00
Christian Jullien
f233cb182c NetBSD: reintroduce NetBSD support. Currently, -run works but executable has an incorrect format. 2020-12-11 14:26:26 +01:00
grischka
8ff705554d tcc_enter/exit_state(): do not use!
tcc_enter/exit_state() are meant exclusively to protect
the tcc_compile() and its sub-functions in tccpp.c,
tccgen.c, tccasm.c and xxx-gen.c.

Other files that are part of libtcc simply must not use global
variables.

- riscv64/last_hi: move to TCCState
  from 72250bece2

- tccrun.c: Using a fixed address would not work anyway
  ("tcc -run tcc.c -run ..." for example)
  from baacb0f52a

- tests/Makefile: support for a platform doesn't make sense if
  it doesn't pass our basic tests.
  from 591feda103
Also:
- tccgen: cleanup "duplicate member" (only 2 passes,
  avoids additional TokenSym field)
  from 170be79a42
2020-12-08 19:57:57 +01:00