【问题标题】:What does libc_hidden_builtin_def (strspn) mean?libc_hidden_​​builtin_def (strspn) 是什么意思?
【发布时间】:2014-01-24 02:42:22
【问题描述】:
libc_hidden_builtin_def (strspn)

我在glibc-2.18/string/strspn.c 中找到了上面的代码。 有人可以解释这是什么意思。这对其余代码很重要吗? 这里是文件strspn.c的内容:

#include <string.h>

#undef strspn

/* Return the length of the maximum initial segment
   of S which contains only characters in ACCEPT.  */
size_t strspn (s, accept) const char *s; const char *accept; {
  const char *p;
  const char *a;
  size_t count = 0;

  for (p = s; *p != '\0'; ++p) {
      for (a = accept; *a != '\0'; ++a) {
        if (*p == *a)
           break;
        if (*a == '\0')
           return count;
        else
          ++count;
     }
  }

  return count;
}
libc_hidden_builtin_def (strspn)

【问题讨论】:

    标签: c gnu glibc


    【解决方案1】:

    谁能解释一下这是什么意思。

    这是一个#defined 宏,在构建(非共享)libc.a 时扩展为空,并且:

    extern __typeof (strcspn) __EI_strcspn __asm__("" "strcspn");
    extern __typeof (strcspn) __EI_strcspn __attribute__((alias ("" "__GI_strcspn")));
    

    编译 libc.so.6 时。

    这样做是定义一个符号别名__GI_strcspn,它与strcspn 具有相同的值,但不会从libc.so.6 中导出(即它是一个内部符号)。

    这对其余代码重要吗?

    是的:libc.so.6 中的其他代码可能会调用此符号,而无法将其插入例如LD_PRELOADED图书馆。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-12
      • 2017-06-11
      • 2018-03-05
      • 2023-03-27
      • 1970-01-01
      • 2013-03-09
      • 2020-05-01
      相关资源
      最近更新 更多