为什么proc/ID/maps有多个共享库条目 [英] why proc/ID/maps has multiple entries for shared libraries

查看:106
本文介绍了为什么proc/ID/maps有多个共享库条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看嵌入式Linux下的proc/ID/maps, 而且我注意到一些共享库在进程的内存映射中出现了几次 为什么会这样?

I'm looking at proc/ID/maps under embedded Linux, And I've noticed that some shared libraries appear few times at the memory map of a process why is it so ?

40094000-400d9000 r-xp 00000000 b3:09 723        /system/lib/libc.so
400d9000-400da000 ---p 00000000 00:00 0 
400da000-400dc000 r-xp 00045000 b3:09 723        /system/lib/libc.so
400dc000-400de000 rwxp 00047000 b3:09 723        /system/lib/libc.so
400de000-400e9000 rwxp 00000000 00:00 0 
400e9000-400ed000 r-xp 00000000 b3:09 770        /system/lib/libgccdemangle.so
400ed000-400ee000 ---p 00000000 00:00 0 
400ee000-400ef000 r-xp 00004000 b3:09 770        /system/lib/libgccdemangle.so
400ef000-400f0000 rwxp 00005000 b3:09 770        /system/lib/libgccdemangle.so
40102000-40103000 r-xp 00000000 b3:09 869        /system/lib/libstdc++.so
40103000-40104000 r-xp 00000000 b3:09 869        /system/lib/libstdc++.so
40104000-40105000 rwxp 00001000 b3:09 869        /system/lib/libstdc++.so
40105000-40112000 r-xp 00000000 b3:09 738        /system/lib/libcutils.so
40112000-40113000 r-xp 0000c000 b3:09 738        /system/lib/libcutils.so
40113000-40114000 rwxp 0000d000 b3:09 738        /system/lib/libcutils.so

推荐答案

因为共享了 ELF 库像可执行文件一样,具有几个段:通常是文本" 只读段(它是mmap -ed共享的,因此使用该段的所有进程都共享一些物理RAM),而数据" 读/写段(用于静态或全局"变量,也许还有PLT ...),对于每个进程都是私有的.

Because an ELF shared library has, like an executable, several segments: often a "text" read only segment (which is mmap -ed shared, so all processes using that segment share some physical RAM), and a "data" read write segment (for static or "global" variables, and perhaps also the PLT...), private to each process.

这在 Drepper的论文中进行了详细解释:如何编写共享库

这篇关于为什么proc/ID/maps有多个共享库条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆