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
1105 /* add libc crt1/crti objects */1105 /* add libc crt1/crti objects */
1106 if ((output_type == TCC_OUTPUT_EXE || output_type == TCC_OUTPUT_DLL) &&1106 if ((output_type == TCC_OUTPUT_EXE || output_type == TCC_OUTPUT_DLL) &&
1107 !s->nostdlib) {1107 !s->nostdlib) {
1108#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
1108#if TARGETOS_OpenBSD1109#if TARGETOS_OpenBSD
1109 if (output_type != TCC_OUTPUT_DLL)1110 if (output_type != TCC_OUTPUT_DLL)
1110 tcc_add_crt(s, "crt0.o");1111 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");
1115#elif TARGETOS_FreeBSD1112#elif TARGETOS_FreeBSD
1116 if (output_type != TCC_OUTPUT_DLL)1113 if (output_type != TCC_OUTPUT_DLL)
1117 tcc_add_crt(s, "crt1.o");1114 tcc_add_crt(s, "crt1.o");
1118 tcc_add_crt(s, "crti.o");1115 tcc_add_crt(s, "crti.o");
1119 tcc_add_crt(s, "crtbegin.o");
1120#elif TARGETOS_NetBSD1116#elif TARGETOS_NetBSD
1121 if (output_type != TCC_OUTPUT_DLL)1117 if (output_type != TCC_OUTPUT_DLL)
1122 tcc_add_crt(s, "crt0.o");1118 tcc_add_crt(s, "crt0.o");
1123 tcc_add_crt(s, "crti.o");1119 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");
1125#elif !TCC_TARGET_MACHO1127#elif !TCC_TARGET_MACHO
1126 /* Mach-O with LC_MAIN doesn't need any crt startup code. */1128 /* Mach-O with LC_MAIN doesn't need any crt startup code. */
1127 if (output_type != TCC_OUTPUT_DLL)1129 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
915#if defined TCC_IS_NATIVE && !defined TCC_TARGET_PE915#if defined TCC_IS_NATIVE && !defined TCC_TARGET_PE
916 /* dlsym() needs the undecorated name. */916 /* dlsym() needs the undecorated name. */
917 void *addr = dlsym(RTLD_DEFAULT, &name[s1->leading_underscore]);917 void *addr = dlsym(RTLD_DEFAULT, &name[s1->leading_underscore]);
918#if TARGETOS_OpenBSD918#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
919 if (addr == NULL) {919 if (addr == NULL) {
920 int i;920 int i;
921 for (i = 0; i < s1->nb_loaded_dlls; i++)921 for (i = 0; i < s1->nb_loaded_dlls; i++)
@@ -1460,10 +1460,11 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 538 unmodified lines
1460 tcc_add_support(s1, TCC_LIBTCC1);1460 tcc_add_support(s1, TCC_LIBTCC1);
1461#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD1461#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
1462 /* add crt end if not memory output */1462 /* add crt end if not memory output */
1463 if (s1->output_type == TCC_OUTPUT_DLL)1463 if (s1->output_type != TCC_OUTPUT_MEMORY) {
1464 tcc_add_crt(s1, "crtendS.o");1464 if (s1->output_type == TCC_OUTPUT_DLL)
1465 else if (s1->output_type != TCC_OUTPUT_MEMORY) {1465 tcc_add_crt(s1, "crtendS.o");
1466 tcc_add_crt(s1, "crtend.o");1466 else
1467 tcc_add_crt(s1, "crtend.o");
1467#if TARGETOS_FreeBSD || TARGETOS_NetBSD1468#if TARGETOS_FreeBSD || TARGETOS_NetBSD
1468 tcc_add_crt(s1, "crtn.o");1469 tcc_add_crt(s1, "crtn.o");
1469#endif1470#endif
@@ -2856,8 +2857,8 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 1386 unmodified lines
2856 sm_table[i].new_section = 1;2857 sm_table[i].new_section = 1;
2857 found:2858 found:
2858 if (sh->sh_type != s->sh_type) {2859 if (sh->sh_type != s->sh_type) {
2859#if TARGETOS_OpenBSD2860#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD
2860 if (strcmp (s->name, ".eh_frame") || sh->sh_type != SHT_PROGBITS)2861 if (strcmp (s->name, ".eh_frame"))
2861#endif2862#endif
2862 {2863 {
2863 tcc_error_noabort("invalid section type");2864 tcc_error_noabort("invalid section type");
tests/Makefile+11−0
@@ -64,6 +64,17 @@ endif · 63 unmodified lines
64ifeq ($(TARGETOS),OpenBSD)64ifeq ($(TARGETOS),OpenBSD)
65dlltest: CFLAGS+=-fno-stack-protector65dlltest: CFLAGS+=-fno-stack-protector
66endif66endif
67ifeq ($(TARGETOS),FreeBSD)
68 # test3 has dlsym problems
69 TESTS := $(filter-out test3,$(TESTS))
70 TESTS += test1
71endif
72ifeq ($(TARGETOS),NetBSD)
73 # test3 has dlsym problems
74 # dlltest does not allow text relocations
75 TESTS := $(filter-out test3 dlltest,$(TESTS))
76 TESTS += test1
77endif
67 78
68RUN_TCC = $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS)79RUN_TCC = $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS)
69DISAS = objdump -d80DISAS = objdump -d
tests/tests2/Makefile+4−0
@@ -52,6 +52,10 @@ ifneq (,$(filter OpenBSD FreeBSD NetBSD,$(TARGETOS))) · 51 unmodified lines
52 SKIP += 106_pthread.test # no pthread_condattr_setpshared52 SKIP += 106_pthread.test # no pthread_condattr_setpshared
53 SKIP += 114_bound_signal.test # libc problem signal/fork53 SKIP += 114_bound_signal.test # libc problem signal/fork
54endif54endif
55ifeq ($(TARGETOS),NetBSD)
56 SKIP += 113_btdll.test # text relocations
57 SKIP += 115_bound_setjmp.test # longjmp renamed to __longjmp14
58endif
55 59
56# Some tests might need arguments60# Some tests might need arguments
57ARGS =61ARGS =

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