如何测量 GCC 链接选项 -Wl,-z,relro,-z,now 对 ARM 上二进制启动的性能影响

Rob*_*oni 5 binary performance gcc startup elf

我正在尝试找到一种方法来衡量在 ARM 平台上使用 relro 和早期绑定链接选项对启动性能的影响。

有人可以建议我如何找到使用该选项编译的二进制文件链接共享库所花费的时间?

非常感谢。


编辑 1:我的机器上没有时间信息。

root@arm:/# LD_DEBUG=统计信息/bin/date

  1470:                      number of relocations: 90
  1470:           number of relocations from cache: 3
  1470:             number of relative relocations: 1207 Thu Jan  1 00:17:00 UTC 1970
  1470:     
  1470:     runtime linker statistics:
  1470:                final number of relocations: 108
  1470:     final number of relocations from cache: 3
Run Code Online (Sandbox Code Playgroud)

Emp*_*ian 3

如果您使用 GLIBC:

$ LD_DEBUG=statistics /bin/date
      4494:
      4494:     runtime linker statistics:
      4494:       total startup time in dynamic loader: 932928 clock cycles
      4494:                 time needed for relocation: 299052 clock cycles (32.0%)
      4494:                      number of relocations: 106
      4494:           number of relocations from cache: 4
      4494:             number of relative relocations: 1276
      4494:                time needed to load objects: 420660 clock cycles (45.0%)
Fri Feb 28 16:40:48 PST 2014
Run Code Online (Sandbox Code Playgroud)

使用和不使用构建二进制文件-z,relro并比较数字。