Search code examples
cglibcunistd.h

What does libc_hidden_proto in the glibc standard libraries do?


I was trying to look up the prototype for the getpgrp() function in unistd.h but couldnt find it. The only line containing getpgrp in that file was the line libc_hidden_proto (tcgetpgrp) and I'm assuming this is a macro, but I dont know what it does.

I googled but couldn't find any explanations on the web for what libc_hidden_proto actually does. Any explanation about what the purpose of that macro is in glibc would be appreciated.


Solution

  • You've accidentally looked at the internal copy (include/unistd.h) instead of the public copy (posix/unistd.h). No, I don't understand how glibc's source is organized either.

    From include/libc-symbols.h:

       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)