https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83074

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Martin Liška from comment #1)
> Hi.
> 
> Thanks for the report. I isolated the issue and it's related to how
> constructors are called and hang in GCOV is just demonstration of the
> problem.
> 
> Please consider this:
> 
> $ cat foo.c
> __attribute__ ((constructor)) static void
> ctor2 ()
> {
>   static int c2 = 0;
>   __builtin_printf ("ctor2 called\n");
>   if (c2++ != 0)
>     __builtin_abort ();
> }
> 
> int
> main (void)
> {
> }
> 
> $ cat bar.c
> __attribute__((constructor))
> static void ctor1() {
>   static int c1 = 0;
>   __builtin_printf ("ctor1 called\n");
>   if (c1++ != 0)
>     __builtin_abort ();
> }
> 
> int main(void)
> {
> }
> 
> Then running:
> 
> $ gcc -g -I. -fPIC -c foo.c -o foo.o 
> $ gcc -g -I. -c bar.c -o bar.o 
> $ gcc -Wl,-L. -Wl,--export-dynamic -pie foo.o -o foo.so

Why do you expect you can use a PIE as a shared library?

Reply via email to