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

--- Comment #3 from Jim Wilson <wilson at gcc dot gnu.org> ---
I figured out that I wasn't fully rebuilding and relinking all libraries while
trying to debug this with printf, and that sent me down the wrong path.

Trying this again, correctly, I see that we have a loop in unwind, because the
return address for _start is pointing at _start.  This works by accident when
static linking, because crt1.o is included before crtbegin.o, crtbegin.o
registers FDEs starting from a label it adds to the eh_frame section, and hence
the FDE for _start in crt1.o gets lost.  When unwinding, we see that there is
no FDE for _start, and it isn't an exception frame, so that terminates
unwinding.  When dynamic linking, we use PT_GNU_EH_FRAME which uses eh_frame
section addresses and hence finds every FDE, including the one for _start, so
we try to unwind through _start, get a return address pointing at _start, and
go into an infinite loop.

This requires a glibc patch to fix.  Just setting the return address in _start
to 0 works.

Reply via email to