Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It would definitely be easier if you could modify the linker script. Since you cannot, it is possible to extract section names, addresses, and sizes from the program binary. For example, here is how one would use libbfd to examine all code sections.</p> <pre><code>#include &lt;bfd.h&gt; bfd *abfd; asection *p; char *filename = "/path/to/my/file"; if ((abfd = bfd_openr(filename, NULL)) == NULL) { /* ... error handling */ } if (!bfd_check_format (abfd, bfd_object)) { /* ... error handling */ } for (p = abfd-&gt;sections; p != NULL; p = p-&gt;next) { bfd_vma base_addr = bfd_section_vma(abfd, p); bfd_size_type size = bfd_section_size (abfd, p); const char *name = bfd_section_name(abfd, p); flagword flags = bfd_get_section_flags(abfd, p); if (flags &amp; SEC_CODE) { printf("%s: addr=%p size=%d\n", name, base_addr, size); } } </code></pre> <p>If you only want to look at the .text segment, you'd strcmp against the section name.</p> <p>The downside of this approach? Libbfd is licensed under the GPL, so your entire project would be encumbered with the GPL. For a commercial project, this might be a non-starter.</p> <p>If your binary is in ELF format, you could use libelf instead. I'm not familiar with how the libelf APIs work, so I can't provide sample code. The Linux libelf is also GPL, but I believe the BSD projects have their own libelf which you could use.</p> <p><b>Edit:</b> as you're working on a DSP in a minimal real-time OS environment, this answer isn't going to work. Sorry, I tried.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload