[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] OpenBSD/amd64 build failure

From: Christian Jullien
Subject: Re: [Tinycc-devel] OpenBSD/amd64 build failure
Date: Wed, 2 Jan 2019 07:47:09 +0100

Hi Alexander,

The similar segfault was related to  wrong configuration detection.
The "fix" was to supply the right options to configure (like ./configure
--triplet=arm-linux-gnueabihf --prefix=/usr --crtprefix=/usr/lib)
Could it be also the root of your problem?

-----Original Message-----
From: Tinycc-devel [mailto:address@hidden
On Behalf Of Alexander Mueller
Sent: mardi 1 janvier 2019 18:02
To: address@hidden
Subject: [Tinycc-devel] OpenBSD/amd64 build failure

Hi, tcc people!

I tried compiling tcc on openbsd and have run into a few problems.
For one, openbsd doesn't seem to provide crt{i,n}.o and uses crt0.o
instead of crt1.o.

Sadly my c-fu isn't strong enough to continue the port, but I wanted
to share the problem I've run into, since I saw that there that
someone started a port to OpenBSD and that someone else recently
mentioned a similar segfault (on a different arch/os).


---8<---8<---8<--- git diff output
diff --git a/libtcc.c b/libtcc.c
index df7adab..d211449 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -973,7 +973,11 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s,
int output_type)
     if ((output_type == TCC_OUTPUT_EXE || output_type == TCC_OUTPUT_DLL) &&
         !s->nostdlib) {
         if (output_type != TCC_OUTPUT_DLL)
+# if defined(__OpenBSD__)
+            tcc_add_crt(s, "crt0.o");
+# else
             tcc_add_crt(s, "crt1.o");
+# endif
         tcc_add_crt(s, "crti.o");
diff --git a/tccrun.c b/tccrun.c
index 155c8dd..d48221a 100644
--- a/tccrun.c
+++ b/tccrun.c
@@ -626,6 +626,8 @@ static int rt_get_caller_pc(addr_t *paddr,
ucontext_t *uc, int level)
         *paddr = uc->uc_mcontext.mc_rip;
 #elif defined(__NetBSD__)
         *paddr = uc->uc_mcontext.__gregs[_REG_RIP];
+#elif defined(__OpenBSD__)
+        *paddr = uc->sc_rip;
         *paddr = uc->uc_mcontext.gregs[REG_RIP];
@@ -637,6 +639,8 @@ static int rt_get_caller_pc(addr_t *paddr,
ucontext_t *uc, int level)
         fp = uc->uc_mcontext.mc_rbp;
 #elif defined(__NetBSD__)
         fp = uc->uc_mcontext.__gregs[_REG_RBP];
+#elif defined(__OpenBSD__)
+        fp = uc->sc_rbp;
         fp = uc->uc_mcontext.gregs[REG_RBP];

---8<---8<---8<--- gdb backtrace
This GDB was configured as "amd64-unknown-openbsd6.4"...
(gdb) run -run examples/ex1.c
Starting program: /home/dondy/Downloads/tinycc/build/bin/tcc -run

Program received signal SIGSEGV, Segmentation fault.
0x000004c0cf0ec277 in tcc_load_object_file (s1=0x4c3bf3d5800, fd=6,
    file_offset=3280140) at tccelf.c:2467
2467                s->sh_info = sm_table[sh->sh_info].s->sh_num;
(gdb) bt
#0  0x000004c0cf0ec277 in tcc_load_object_file (s1=0x4c3bf3d5800, fd=6,
    file_offset=3280140) at tccelf.c:2467
#1  0x000004c0cf0ec79a in tcc_load_alacarte (s1=0x4c3bf3d5800, fd=6,
size=Variable "size" is not available.
    at tccelf.c:2625
#2  0x000004c0cf0eca3d in tcc_load_archive (s1=0x4c3bf3d5800, fd=6,
    at tccelf.c:2676
#3  0x000004c0cf0d3b8c in tcc_add_file_internal (s1=0x4c3bf3d5800,
    filename=0x7f7ffffc8dd0 "/usr/lib/libc.a", flags=1) at libtcc.c:1047
#4  0x000004c0cf0d3c75 in tcc_add_library_internal (s=0x4c3bf3d5800,
    fmt=0x4c0cf0c22e0 "%s/lib%s.a", filename=0x4c0cf0c3303 "c",
flags=Variable "flags" is not available.
    at libtcc.c:1109
#5  0x000004c0cf0d3d3f in tcc_add_library (s=0x4c3bf3d5800,
    libraryname=0x4c0cf0c3303 "c") at libtcc.c:1146
#6  0x000004c0cf0d3d86 in tcc_add_library_err (s=Variable "s" is not
) at libtcc.c:1156
#7  0x000004c0cf0ecbef in tcc_add_runtime (s1=0x4c3bf3d5800) at
#8  0x000004c0cf0f2260 in tcc_relocate_ex (s1=0x4c3bf3d5800, ptr=0x0,
    ptr_diff=0) at tccrun.c:193
#9  0x000004c0cf0f22d5 in tcc_relocate (s1=0x4c3bf3d5800, ptr=Variable
"ptr" is not available.
) at tccrun.c:67
#10 0x000004c0cf0f239e in tcc_run (s1=0x4c3bf3d5800, argc=1,
    argv=0x7f7ffffc9cc8) at tccrun.c:123
#11 0x000004c0cf0d23b1 in main (argc0=3, argv0=0x7f7ffffc9cb8) at tcc.c:351
(gdb) quit

Tinycc-devel mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]