History

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

herman ten brugge committed 5 years ago

Commit 7f898ab1 parent a87dee54 files · +31 −13Browse files

Unified · Split

4 files
  1. libtcc.c +8 −6
  2. tccelf.c +8 −7
  3. tests/Makefile +11 −0
  4. tests/tests2/Makefile +4 −0
libtcc.c+8−6
@@ -1105,23 +1105,25 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 1104 unmodified lines
11051105 /* add libc crt1/crti objects */
11061106 if ((output_type == TCC_OUTPUT_EXE || output_type == TCC_OUTPUT_DLL) &&
11071107 !s->nostdlib) {
1108+#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
11081109 #if TARGETOS_OpenBSD
11091110 if (output_type != TCC_OUTPUT_DLL)
11101111 tcc_add_crt(s, "crt0.o");
1111− if (output_type == TCC_OUTPUT_DLL)
1112− tcc_add_crt(s, "crtbeginS.o");
1113− else
1114− tcc_add_crt(s, "crtbegin.o");
11151112 #elif TARGETOS_FreeBSD
11161113 if (output_type != TCC_OUTPUT_DLL)
11171114 tcc_add_crt(s, "crt1.o");
11181115 tcc_add_crt(s, "crti.o");
1119− tcc_add_crt(s, "crtbegin.o");
11201116 #elif TARGETOS_NetBSD
11211117 if (output_type != TCC_OUTPUT_DLL)
11221118 tcc_add_crt(s, "crt0.o");
11231119 tcc_add_crt(s, "crti.o");
1124− tcc_add_crt(s, "crtbegin.o");
1120+#endif
1121+ if (s->static_link)
1122+ tcc_add_crt(s, "crtbeginT.o");
1123+ else if (output_type == TCC_OUTPUT_DLL)
1124+ tcc_add_crt(s, "crtbeginS.o");
1125+ else
1126+ tcc_add_crt(s, "crtbegin.o");
11251127 #elif !TCC_TARGET_MACHO
11261128 /* Mach-O with LC_MAIN doesn't need any crt startup code. */
11271129 if (output_type != TCC_OUTPUT_DLL)
tccelf.c+8−7
@@ -915,7 +915,7 @@ ST_FUNC void relocate_syms(TCCState *s1, Section *symtab, int do_resolve) · 914 unmodified lines
915915 #if defined TCC_IS_NATIVE && !defined TCC_TARGET_PE
916916 /* dlsym() needs the undecorated name. */
917917 void *addr = dlsym(RTLD_DEFAULT, &name[s1->leading_underscore]);
918−#if TARGETOS_OpenBSD
918+#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
919919 if (addr == NULL) {
920920 int i;
921921 for (i = 0; i < s1->nb_loaded_dlls; i++)
@@ -1460,10 +1460,11 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 538 unmodified lines
14601460 tcc_add_support(s1, TCC_LIBTCC1);
14611461 #if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
14621462 /* add crt end if not memory output */
1463− if (s1->output_type == TCC_OUTPUT_DLL)
1464− tcc_add_crt(s1, "crtendS.o");
1465− else if (s1->output_type != TCC_OUTPUT_MEMORY) {
1466− tcc_add_crt(s1, "crtend.o");
1463+ if (s1->output_type != TCC_OUTPUT_MEMORY) {
1464+ if (s1->output_type == TCC_OUTPUT_DLL)
1465+ tcc_add_crt(s1, "crtendS.o");
1466+ else
1467+ tcc_add_crt(s1, "crtend.o");
14671468 #if TARGETOS_FreeBSD || TARGETOS_NetBSD
14681469 tcc_add_crt(s1, "crtn.o");
14691470 #endif
@@ -2856,8 +2857,8 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 1386 unmodified lines
28562857 sm_table[i].new_section = 1;
28572858 found:
28582859 if (sh->sh_type != s->sh_type) {
2859−#if TARGETOS_OpenBSD
2860− if (strcmp (s->name, ".eh_frame") || sh->sh_type != SHT_PROGBITS)
2860+#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
2861+ if (strcmp (s->name, ".eh_frame"))
28612862 #endif
28622863 {
28632864 tcc_error_noabort("invalid section type");
tests/Makefile+11−0
@@ -64,6 +64,17 @@ endif · 63 unmodified lines
6464 ifeq ($(TARGETOS),OpenBSD)
6565 dlltest: CFLAGS+=-fno-stack-protector
6666 endif
67+ifeq ($(TARGETOS),FreeBSD)
68+ # test3 has dlsym problems
69+ TESTS := $(filter-out test3,$(TESTS))
70+ TESTS += test1
71+endif
72+ifeq ($(TARGETOS),NetBSD)
73+ # test3 has dlsym problems
74+ # dlltest does not allow text relocations
75+ TESTS := $(filter-out test3 dlltest,$(TESTS))
76+ TESTS += test1
77+endif
6778
6879 RUN_TCC = $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS)
6980 DISAS = objdump -d
tests/tests2/Makefile+4−0
@@ -52,6 +52,10 @@ ifneq (,$(filter OpenBSD FreeBSD NetBSD,$(TARGETOS))) · 51 unmodified lines
5252 SKIP += 106_pthread.test # no pthread_condattr_setpshared
5353 SKIP += 114_bound_signal.test # libc problem signal/fork
5454 endif
55+ifeq ($(TARGETOS),NetBSD)
56+ SKIP += 113_btdll.test # text relocations
57+ SKIP += 115_bound_setjmp.test # longjmp renamed to __longjmp14
58+endif
5559
5660 # Some tests might need arguments
5761 ARGS =

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t