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]

Weak functions not overridden if overriding file contains only overrides of weak functions


Hi All,

I am trying to defining a weak function so it can be overridden but have
struck an issue with I think is a shortcoming with ld (I hesitate to say
'bug' just yet)


In include_file.h I have:

void fn(ulong addr);


In default_behaviour.c I have:

#include "include_file.h>

void __fn_alias(ulong addr)
{
	/* Default Behaviour */
}
void fn(ulong addr) __attribute__((weak, alias("__weak_fn_alias")));


In overide_behaviour.c I have:

void fn(ulong addr)
{
	/* Overridden Behaviour */
}

However, if this is the only function in overide_behaviour.c, the function
will not get overridden. In order for ld to link in fn() found in
overide_behaviour.c, another (strong) function (which must be called
somewhere in the code) has to be included in overide_behaviour.c

I have heard this is intended behaviour - Is this so? If so, is there an
option which will force ld to override this behaviour?

Thanks for your time,

Graeme


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