Sample Header Ad - 728x90

Extracting the size and origin of all symbols in an ELF

2 votes
2 answers
4238 views
I am trying to estimate the code size of a binary's various components. I have access to the source code and resulting build directory containing all built object files. Of course, I want to include only the symbols that are actually used, so adding the sizes of the all the object file's .text and .data sections will end up overestimating actuals. How can one determine the size and origin of all symbols used to link an ELF file? Something like this would be useful: Symbol Size Origin func1 0x50 ../src/func1.o func2 0x75 ../src/func2.o ... And something similar for all symbols that are .data. The resulting .map file seems to have *some* of this data, but it seems incomplete. Two sections that stand out are: Allocating common symbols Common symbol size file s_Handle 0x8 ../BUILD/src/handle.o _main_obj 0x48 ../BUILD/src/boot.o .... But there are just a few dozen symbols listed here. The following section seems to have far more symbols, but it appears as if they are listed as being "Discarded" at link-time: Discarded input sections .text 0x00000000 0x0 /home/user/.programs/gcc-arm-none-eabi-5_4-2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7e-m/crti.o .data 0x00000000 0x0 /home/user/.programs/gcc-arm-none-eabi-5_4-2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7e-m/crti.o .bss 0x00000000 0x0 /home/user/.programs/gcc-arm-none-eabi-5_4-2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7e-m/crti.o .data 0x00000000 0x0 /home/user/.programs/gcc-arm-none-eabi-5_4-2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/crt0.o .bss 0x00000000 0x0 /home/user/.programs/gcc-arm-none-eabi-5_4-2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/crt0.o .ARM.extab 0x00000000 0x0 /home/user/.programs/gcc-arm-none-eabi-5_4-2016q3/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/crt0.o .text._Z12notify_startv 0x00000000 0x14 ../BUILD/./test_env.o .text._Z30notify_performance_coefficientPKci 0x00000000 0x18 ../BUILD/./test_env.o .text._Z30notify_performance_coefficientPKcj 0x00000000 0x18 ../BUILD/./test_env.o .text._Z30notify_performance_coefficientPKcd 0x00000000 0x20 ../BUILD/./test_env.o .text._Z17notify_completionb 0x00000000 0x64 ../BUILD/./test_env.o .text._Z21notify_completion_strbPc 0x00000000 0x30 ../BUILD/./test_env.o ...
Asked by sherrellbc (2601 rep)
Sep 21, 2017, 04:31 PM
Last activity: May 17, 2019, 05:16 PM