glibc标准库中的libc_hidden_proto是什么作用?

6
我试图查找unistd.hgetpgrp()函数的原型,但找不到。该文件中唯一包含getpgrp的行是libc_hidden_proto (tcgetpgrp),我认为这是一个宏,但我不知道它的作用。
我在谷歌上搜索,但找不到有关libc_hidden_proto实际作用的解释。如果您能提供有关glibc中此宏的目的的任何解释,将不胜感激。

你正在使用什么版本的glibc?我没有找到任何libc_hidden_proto,但我还记得它是从以前的时候...... - o11c
很奇怪。我正在使用glibc 2.19,但我也在查看glibc 2.18、2.20、2.21和2.23中的unistd.h头文件,并且我在所有这些版本中都看到了libc_hidden_proto。 - Jerry Marbas
1个回答

6
你不小心看了内部副本(include/unistd.h),而不是公共副本(posix/unistd.h)。我也不知道glibc的源代码是如何组织的。
来自include/libc-symbols.h:https://code.woboq.org/userspace/glibc/include/libc-symbols.h.html#317
   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)

谢谢。我已经阅读了libc-symbols.h中的内容,但我不理解PLT是什么,所以在我的问题中没有提到libc-symbols。但还是要给你点赞。现在我要去阅读关于PLT、GOT、ELF文件、链接器、动态加载和其他我不知道的数百万个东西的内容了:P - Jerry Marbas
@jerry 基本上,这就像是针对那些符号的“-fsemantic-interposition”。而且它只在glibc内部工作,因为他们做了所有其他疯狂的事情。 - o11c

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接