This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Call of weakly referenced functions


On Wed, Jul 17, 2013 at 12:37 PM, Sebastian Huber
<sebastian.huber@embedded-brains.de> wrote:
> Hello,
>
> I have a question regarding the call of weakly referenced functions.  On ARM
> for example we have this:
>
> extern void weak(void);
>
> __attribute__((weak)) extern void weak(void);
>
> void _start(void)
> {
>     weak();
> }
>
> GCC output:
>
>         .global _start
>         .type   _start, %function
> _start:
>         @ Function supports interworking.
>         @ args = 0, pretend = 0, frame = 0
>         @ frame_needed = 0, uses_anonymous_args = 0
>         stmfd   sp!, {r3, lr}
>         bl      weak
>         ldmfd   sp!, {r3, lr}
>         bx      lr
>         .size   _start, .-_start
>         .weak   weak
>
> Linker output:
>
> 00008444 <_start>:
>     8444:       e92d4008        push    {r3, lr}
>     8448:       e1a00000        nop                     ; (mov r0, r0)
>     844c:       e8bd4008        pop     {r3, lr}
>     8450:       e12fff1e        bx      lr
>
> So this looks really nice.  Does this work on all ELF targets supported by
> the GNU linker?

This behavior is specific to ARM because the arm linker does it:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0474c/CACCEEIF.html

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51643

So if I read comment #4 correctly, it is required by the ABI of
AARCH32 but it is invalid for the other targets relocations.
Which means the linker cannot do it for the other targets.

Thanks,
Andrew Pinski


>
> --
> Sebastian Huber, embedded brains GmbH
>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone   : +49 89 189 47 41-16
> Fax     : +49 89 189 47 41-09
> E-Mail  : sebastian.huber@embedded-brains.de
> PGP     : Public key available on request.
>
> Diese Nachricht ist keine geschÃftliche Mitteilung im Sinne des EHUG.
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]