How to debug null-pointer function call within __do_global_dtors_aux()

Richard Sandiford richard.sandiford@arm.com
Tue Aug 20 16:44:00 GMT 2019


William Tambe <tambewilliam@gmail.com> writes:
> I am running into an issue with both gcc-8.3.0 and gcc-9.2.0 where a
> null-pointer function call is being done within
> __do_global_dtors_aux() which is defined in crtstuff.c .
>
> I have attempted to build GCC using the following export:
> export CFLAGS_FOR_TARGET="-g -save-temps -fverbose-asm"
> but the assembly file crtstuff.s do not contain the function
> __do_global_dtors_aux() even-though its source file crtstuff.c has its
> definition.
>
> Any idea ?

libgcc is a bit awkward in that it uses the same source file to
compile multiple object files.  E.g. both crtbegin.o and crtend.o
come from crtstuff.c, so which crtstuff.s you end up with depends
on the build order.

You should see the definition if you remake crtbegin.o specifically
(or whichever variant you're looking at, such as crtbeginT.o).

At a guess, the null pointers could come from weak symbols that
weren't defined weak (and so a null check got optimised away),
or from the function pointer table sections have too much alignment
and being padded out with zeros.

Thanks,
Richard



More information about the Gcc-help mailing list