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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

William Tambe
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 ?
Reply | Threaded
Open this post in threaded view
|

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

Richard Sandiford-9
William Tambe <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

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

William Tambe
On Tue, Aug 20, 2019 at 11:44 AM Richard Sandiford
<[hidden email]> wrote:

>
> William Tambe <[hidden email]> 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).

How must "make" be invoked to remake only crtbegin.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
Reply | Threaded
Open this post in threaded view
|

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

Richard Sandiford-9
William Tambe <[hidden email]> writes:

> On Tue, Aug 20, 2019 at 11:44 AM Richard Sandiford
> <[hidden email]> wrote:
>>
>> William Tambe <[hidden email]> 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).
>
> How must "make" be invoked to remake only crtbegin.o ?

Just "rm crtbegin.o ; make crtbegin.o" within the libgcc build
directory should be enough.

Richard