16:08:02 open("/lib/libncurses.so.5",O_RDONLY) = 3 <0.000046>16:08:02 read(3,"\x7f\"...,512) = 512 <0.000048>16:08:02 fstat64(3,{st_dev=makedev(202,0),st_ino=16548,st_mode=S_IFREG|0644,st_nlink=1,st_uID=0,st_gID=0,st_blksize=4096,st_blocks=464,st_size=231576,st_atime=2011/02/06-15:37:43,st_mtime=2011/01/04-06:05:23,st_ctime=2011/02/06-15:37:43}) = 0 <0.000038>
通过读取前512个字节获得了什么?看起来这种模式在共享库中很常见.
更新:我刚刚得到一个great answer,它澄清了512字节的长度.具体来自elf / dl-load.c中的注释:
解决方法 前512个字节包含标识文件类型,目标平台,版本等所需的标头.读取标头后,代码将跳转到此特定类型文件的处理程序. 总结The ELF header 32-bit files is 52 bytes long and in 64-bit files is 64 bytes long. Each program header entry is again 32 and 56 bytes long respectively. I.e.,even with a file which has 10 program header entrIEs we only have to read 372B/624B respectively. Add to this a bit of margin for program notes and reading 512B and 832B for 32-bit and 64-bit files respecitvely is enough.
以上是内存溢出为你收集整理的linux – 为什么strace打开,读取512字节,然后是fstat libncurses?全部内容,希望文章能够帮你解决linux – 为什么strace打开,读取512字节,然后是fstat libncurses?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)