加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在Unix上执行共享库

发布时间:2020-12-15 19:07:44 所属栏目:安全 来源:网络整理
导读:某些Unix共享库在从命令行调用时提供输出,就像它们是可执行文件一样。例如: $ /lib/libc.so.6 GNU C Library stable release version 2.13,by Roland McGrath et al.Copyright (C) 2011 Free Software Foundation,Inc.This is free software; see the sour
某些Unix共享库在从命令行调用时提供输出,就像它们是可执行文件一样。例如:
$ /lib/libc.so.6 
GNU C Library stable release version 2.13,by Roland McGrath et al.
Copyright (C) 2011 Free Software Foundation,Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.5.2.
Compiled on a Linux 2.6.37 system on 2011-01-18.
[...]

在我自己写的C中的共享库中,我如何提供这个输出?我现在执行了一个我刚刚创建的一个库,我得到一个段错误。

注意:我以前在unix.stackechange.com上问过
https://unix.stackexchange.com/questions/7066/executing-a-shared-library

下面的主要定义是负责打印您看到的输出。它在glibc的源码的csu / version.c中定义。我希望这有帮助。
#ifdef HAVE_ELF
/* This function is the entry point for the shared object.
   Running the library as a program will get here.  */

extern void __libc_main (void) __attribute__ ((noreturn));
void
__libc_main (void)
{
  __libc_print_version ();
  _exit (0);
}
#endif

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读