begin using attribute_hidden
Peter S. Mazinger
ps.m at gmx.net
Mon Nov 7 11:04:49 UTC 2005
On Mon, 7 Nov 2005, Joakim Tjernlund wrote:
> > -----Original Message-----
> > From: uclibc-bounces at uclibc.org
> > [mailto:uclibc-bounces at uclibc.org] On Behalf Of Peter S. Mazinger
> > Sent: 07 November 2005 09:59
> > To: uclibc at uclibc.org
> > Subject: RFC: begin using attribute_hidden
> >
> > Hello!
> >
> > What about start using attribute_hidden like:
> >
> > attribute_hidden __x () {
> > }
> >
> > strong_alias(__x,x)
>
> hehe, I just replied to your previous mail, suggesting this :)
Found this in a glibc internal header , could be used here too
/* The following macros are used for PLT bypassing within libc.so
(and if needed other libraries similarly).
First of all, you need to have the function prototyped somewhere,
say in foo/foo.h:
int foo (int __bar);
If calls to foo within libc.so should always go to foo defined in libc.so,
then in include/foo.h you add:
libc_hidden_proto (foo)
line and after the foo function definition:
int foo (int __bar)
{
return __bar;
}
libc_hidden_def (foo)
or
int foo (int __bar)
{
return __bar;
}
libc_hidden_weak (foo)
Simularly for global data. If references to foo within libc.so should
always go to foo defined in libc.so, then in include/foo.h you add:
libc_hidden_proto (foo)
line and after foo's definition:
int foo = INITIAL_FOO_VALUE;
libc_hidden_data_def (foo)
or
int foo = INITIAL_FOO_VALUE;
libc_hidden_data_weak (foo)
If foo is normally just an alias (strong or weak) of some other function,
you should use the normal strong_alias first, then add libc_hidden_def
or libc_hidden_weak:
int baz (int __bar)
{
return __bar;
}
strong_alias (baz, foo)
libc_hidden_weak (foo)
If the function should be internal to multiple objects, say ld.so and
libc.so, the best way is to use:
#if !defined NOT_IN_libc || defined IS_IN_rtld
hidden_proto (foo)
#endif
in include/foo.h and the normal macros at all function definitions
depending on what DSO they belong to.
--
Peter S. Mazinger <ps dot m at gmx dot net> ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08 BB6E C389 975E A5F0 59F2
More information about the uClibc
mailing list