Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22001

GCC Linker : how to generate a report of per file contribution on output sections

$
0
0

Recently I meet a problem when trying to link my program. It report .text can't fit in specified memory region. Obviously the source code grows too large to be linked in limited memory region.

What I want to do now is to analyze which file contribute most significantly to the ".text" section so that follow up code optimization can be performed. I tried many ways but don't make it.

  • nm -s output.elf gives size of each symbol, but don't group the symbol under each source file.
  • nm -s file.obj go through every object file don't work because -fdata-section-ffunction-section-Wl are specified, so not all content in an object file will get linked to final output
  • readelf -s output.elf gives information from file to file, but it simply list symbols under each file and their size. A script can be written to sum all the size under a file, but the total value seems wrong, an obvious error here is some symbols may point to the same memory location, so the same memory region may be calculated many times.

When gcc link do its work, it should know all the details of what is extracted from a object file and put to the output section, but seems it don't provide a switch to generate a detail report (Or am I missing something?)

Is there any tool which can do this job?


Viewing all articles
Browse latest Browse all 22001

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>