简体   繁体   English

库代码内存占用量分析

[英]Library code memory footprint analysis

Let's say we have a some library compiled into .a file. 假设我们有一些库编译成.a文件。 After that this library is linked with other code into some executable file .exe. 之后,该库与其他代码链接到一些可执行文件.exe中。 Size of .a file is 6Mb while this size of .exe file is 3Mb. .a文件的大小为6Mb,而.exe文件的大小为3Mb。 Obvious explanation of this is that linker has thrower out unused code from the library. 对此的明显解释是链接器已从库中抛出未使用的代码。 What I want to know is the real library's code footprint in final executable file. 我想知道的是最终可执行文件中真实库的代码占用量。

Check out the linker options. 查看链接器选项。 Linkers usually have an option to generate a map file. 链接程序通常具有生成映射文件的选项。 Which is a list of functions linked into the final image and where they came from. 这是链接到最终图像的功能列表以及它们来自何处。 Sounds like you are using gcc, use the -map option. 听起来好像您正在使用gcc,请使用-map选项。

A library has implementation of a lot of functions. 库具有许多功能的实现。 An exe use some of there. 一个exe使用那里的一些。 The liker add in exe only the code of functions which exe use. Liker仅在exe中添加exe使用的功能代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM