This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Is there a way to detect a null reference function pointer during assembly or linking ?
- From: Florian Weimer <fweimer at redhat dot com>
- To: William Tambe <tambewilliam at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Mon, 02 Dec 2019 14:58:39 +0100
- Subject: Re: Is there a way to detect a null reference function pointer during assembly or linking ?
- References: <CAF8i9mPL59876dxgHAM81AV7P8T4dBuQ1tOj2N=sPK8FWE3GLQ@mail.gmail.com> <CAF8i9mMSq1CLEasVz6kVMCRKrYhsyDSpe3_R++TGm6w-+e5cAg@mail.gmail.com>
* William Tambe:
> To supplement my previous question, a null reference function pointer
> can occur when using a weak function for which there is no definition;
> ie:
>
> extern void func (void) __attribute__((weak));
>
> int main () {
> if (func)
> func();
> }
>
> In the above example, func will be null if there is no default
> implementation.
Historically, many targets have problems with such checks because they
the func call creates something that causes the func check to succeed
becase it the symbol is no longer null. This kind of check only works
if the availability of the symbol can be determined by the link editor.
Thanks,
Florian