weak_alias的定义和作用
定义
/* Define ALIASNAME as a weak alias for NAME. If weak aliases are not available, this defines a strong alias. */ # define weak_alias(name, aliasname) _weak_alias (name, aliasname) # define _weak_alias(name, aliasname) \ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
参考代码:glibc/blob/master/include/libc-symbols.h
int __fork () { __set_errno (ENOSYS); return -1; } libc_hidden_def (__fork) stub_warning (fork)
同时存在弱符号和强符号,优先选择强符号,如果发现不存在强符号,只存在弱符号,则选择弱符号。