This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/83074] Shared object built with `-pie --coverage' hangs forever
- From: "hjl.tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 20 Nov 2017 22:09:35 +0000
- Subject: [Bug middle-end/83074] Shared object built with `-pie --coverage' hangs forever
- Auto-submitted: auto-generated
- References: <bug-83074-4@http.gcc.gnu.org/bugzilla/>
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?