Fedora 30 and atexit results in error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Fedora 30 and atexit results in error

C.J. Wagenius
Hi

Trying to compile a program that uses atexit in Fedora 30 (gcc version 9.1.1 20190503, glibc 2.29), results in a tcc error.
---
tcc: error: undefined symbol '__dso_handle'

Regards
/cjw

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Fedora 30 and atexit results in error

Rob-255
In writing my own compiler, I found this on recent debian versions too
- it seems that glibc requires it as a symbol in each dso now (unless
you link against gcc's crtbegin.o). I haven't looked into it too much,
but for reference, this was mentioned on this mailing list in the past
- https://lists.nongnu.org/archive/html/tinycc-devel/2018-07/msg00000.html

Personally, I made the symbol weak too -
https://github.com/bobrippling/ucc-c-compiler/blob/master/src/rt/dsohandle.c

hth,
Rob


On Sun, 16 Jun 2019 at 16:18, C.J. Wagenius <[hidden email]> wrote:

>
> Hi
>
> Trying to compile a program that uses atexit in Fedora 30 (gcc version 9.1.1 20190503, glibc 2.29), results in a tcc error.
> ---
> tcc: error: undefined symbol '__dso_handle'
>
> Regards
> /cjw
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Fedora 30 and atexit results in error

C.J. Wagenius
In reply to this post by C.J. Wagenius
Compiling with -shared makes tcc compile ok but the binary segfaults.

Including crtbegin.o (for symbol __dso_handle) and crtend.o (for symbol __TMC_END__) makes tcc compile ok and the binary works.

$ tcc ../atexit.c /usr/lib/gcc/x86_64-redhat-linux/9/crtbegin.o /usr/lib/gcc/x86_64-redhat-linux/9/crtend.o

I don't know the right way to fix this in tcc.

/cjw

16 juni 2019 17:12 av [hidden email]:

> Hi
>
> Trying to compile a program that uses atexit in Fedora 30 (gcc version 9.1.1 20190503, glibc 2.29), results in a tcc error.
> ---
> tcc: error: undefined symbol '__dso_handle'
>
> Regards
> /cjw
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

crtbegin.o (3K) Download Attachment
crtend.o (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fedora 30 and atexit results in error

Michael Matz-4
Hi,

On Thu, 20 Jun 2019, C.J. Wagenius wrote:

> Compiling with -shared makes tcc compile ok but the binary segfaults.
>
> Including crtbegin.o (for symbol __dso_handle) and crtend.o (for symbol
> __TMC_END__) makes tcc compile ok and the binary works.
>
> $ tcc ../atexit.c /usr/lib/gcc/x86_64-redhat-linux/9/crtbegin.o
> /usr/lib/gcc/x86_64-redhat-linux/9/crtend.o
>
> I don't know the right way to fix this in tcc.

Okay, let's bite the bullet and provide it from libtcc1.a on glibc
systems.  I've made it so in mob, so your example should work now.


Ciao,
Michael.

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Fedora 30 and atexit results in error

C.J. Wagenius

22 juni 2019 01:43 av [hidden email]:

> Hi,
>
> On Thu, 20 Jun 2019, C.J. Wagenius wrote:
>
>> Compiling with -shared makes tcc compile ok but the binary segfaults.
>>
>> Including crtbegin.o (for symbol __dso_handle) and crtend.o (for symbol __TMC_END__) makes tcc compile ok and the binary works.
>>
>> $ tcc ../atexit.c /usr/lib/gcc/x86_64-redhat-linux/9/crtbegin.o /usr/lib/gcc/x86_64-redhat-linux/9/crtend.o
>>
>> I don't know the right way to fix this in tcc.
>>
>
> Okay, let's bite the bullet and provide it from libtcc1.a on glibc systems.  I've made it so in mob, so your example should work now.
>
It compiles ok now, but the binary is complaining.

$ ./tcc ~/Temp/atexit.c -o atexit
$ ./atexit
./atexit: symbol lookup error: ./atexit: undefined symbol: __dso_handle

Thamks for looking into this.

/cjw

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Fedora 30 and atexit results in error

C.J. Wagenius
In reply to this post by Michael Matz-4



22 juni 2019 06:09 av [hidden email]:

>
> 22 juni 2019 01:43 av [hidden email]:
>
>> Hi,
>>
>> On Thu, 20 Jun 2019, C.J. Wagenius wrote:
>>
>>> Compiling with -shared makes tcc compile ok but the binary segfaults.
>>>
>>> Including crtbegin.o (for symbol __dso_handle) and crtend.o (for symbol __TMC_END__) makes tcc compile ok and the binary works.
>>>
>>> $ tcc ../atexit.c /usr/lib/gcc/x86_64-redhat-linux/9/crtbegin.o /usr/lib/gcc/x86_64-redhat-linux/9/crtend.o
>>>
>>> I don't know the right way to fix this in tcc.
>>>
>>
>> Okay, let's bite the bullet and provide it from libtcc1.a on glibc systems.  I've made it so in mob, so your example should work now.
>>
> It compiles ok now, but the binary is complaining.
>
> $ ./tcc ~/Temp/atexit.c -o atexit
> $ ./atexit
> ./atexit: symbol lookup error: ./atexit: undefined symbol: __dso_handle
>
> Thamks for looking into this.
>
>
Never mind. It works fine. My bad. There is still some problem with -run though.

$ tcc -run -g atexit.c
Runtime error: dereferencing invalid pointer
Segmentation fault (core dumped)


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel