strace观察时,可执行程序会多次加载动态库

时间:2018-08-27 14:07:10

标签: c mips strace uclibc

我已经针对uCLibc库和许多其他动态共享库在MIPS中构建了一个复杂的可执行程序。该程序运行良好,但是加载需要20秒钟以上,当我通过“ strace”观察到它时,我发现它一直在打开和关闭一些基本库,例如libm,libc,libgcc等。请查看以下日志:< / p>

open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=477720, ...}) = 0
close(3)                                = 0
open("/lib/libgcc_s.so.1", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=213564, ...}) = 0
close(3)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=477720, ...}) = 0
close(3)                                = 0
open("/lib/libm.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=96616, ...}) = 0
close(3)                                = 0
open("/lib/libgcc_s.so.1", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=213564, ...}) = 0
close(3)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=477720, ...}) = 0
close(3)                                = 0
open("/lib/libdl.so.0", O_RDONLY)       = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=9504, ...}) = 0
close(3)                                = 0
open("/lib/libgcc_s.so.1", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=213564, ...}) = 0
close(3)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=477720, ...}) = 0
close(3)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=477720, ...}) = 0
close(3)

我确信这种持续的打开和关闭操作会使我的程序变慢,我尝试在/ etc下创建ld.so.cache,但是它不起作用,它仍然需要20秒的加载时间。有人有主意吗?谢谢。

0 个答案:

没有答案