This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

RFC: New macros for bypassing PLT calls


Hi!

ATM glibc uses a couple of different methods for the hidden
function aliases.
Below is what I came up today, I wonder whether you agree with it
before changing it everywhere.
The usage is:
in include/ (ie. glibc private header) add something like:
libc_hidden (int, close, (int __fd));
if you want to all close (fd) calls to bypass PLT inside of libc.so.
Then the only other change is at the actual close function definition.

If the function is originally defined with some other name, say __close
and close used to be just weak or strong alias, then one needs to do:

int __close (int __fd)
{
... function definition
}
strong_alias (__close, close)	// This is what the code already contained
libc_hidden_def (close)		// If the close is supposed to
				// be strong, otherwise libc_hidden_weak (close)

If there were no aliases (or just INTDEF etc.), then only:

int close (int __fd)
{
... function definition
}
libc_hidden_def (close)

One alternative would be to get rid of the prototypes in include/ headers,
ie. just say:
libc_hidden (close);
in include/foo.h.
libc_hidden definition would then have to change slightly:
# define libc_hidden(name) __libc_hidden(name, __GI_##name)
# define __libc_hidden(name, internal) \
  __typeof(name) internal; \
  __typeof(name) __REDIRECT (name, , internal) attribute_hidden

Are there any common cases which should be solved I've missed?

	Jakub

Attachment: libc-hidden.h
Description: Text document

Attachment: libc-symbols.h
Description: Text document

Attachment: x.h
Description: Text document

Attachment: x.c
Description: Text document

Attachment: y.c
Description: Text document


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