public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How to get addresses of all code regions in binary?
@ 2020-12-29  8:46 Kazi Alom
  2021-01-05  1:37 ` Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Kazi Alom @ 2020-12-29  8:46 UTC (permalink / raw)
  To: gcc-help

Hi,

I am trying to get labels for what is code and what is data in the .text section of an ELF file. The dwarfinfo gives low and high addresses for all functions but those bounds include data pointers as well (looking at ARM binaries). Is there a way to just get the addresses for code? Or in other words, how can I begin to instrument the compiler to somehow output bounds on only code?

Thanks for any help.

Kazi Alom

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to get addresses of all code regions in binary?
  2020-12-29  8:46 How to get addresses of all code regions in binary? Kazi Alom
@ 2021-01-05  1:37 ` Jim Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Wilson @ 2021-01-05  1:37 UTC (permalink / raw)
  To: Kazi Alom; +Cc: gcc-help

On Tue, Dec 29, 2020 at 12:47 AM Kazi Alom <alomk@mit.edu> wrote:

> Hi,
>
> I am trying to get labels for what is code and what is data in the .text
> section of an ELF file. The dwarfinfo gives low and high addresses for all
> functions but those bounds include data pointers as well (looking at ARM
> binaries). Is there a way to just get the addresses for code? Or in other
> words, how can I begin to instrument the compiler to somehow output bounds
> on only code?
>

ARM binaries have mapping symbols that mark the boundaries between code and
data.  This is documented in the ARM ABI and is arm specific.  Looks like
they are $a. for ARM code, $t. for thumb code, and $d. for data.  I suggest
checking the ARM ABI docs.  You should be able to use these symbols to
distinguish between code and data.  I think the objdump disassembler uses
them for instance.  This is a problem on ARM because you can have a
constant pool in the middle of a function.  Most other major targets don't
do that, and hence don't have this problem.

Jim

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-05  1:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-29  8:46 How to get addresses of all code regions in binary? Kazi Alom
2021-01-05  1:37 ` Jim Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).