public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* libbfd examples?
@ 2024-03-09 11:05 Esteve Varela Colominas
  2024-03-09 12:56 ` Andreas Schwab
  2024-03-18 16:18 ` Nick Clifton
  0 siblings, 2 replies; 3+ messages in thread
From: Esteve Varela Colominas @ 2024-03-09 11:05 UTC (permalink / raw)
  To: binutils

Hi,

I'm looking for a library to be able to read and inspect a few
executable formats. All of these are supported by binutils' objdump,
but I want to build different tooling around it, so I figured to look
into the source code here to see if I could reuse anything.

libbfd seems to be the library that I'm looking for for my purposes,
but I'm finding it hard to figure out how to get started with using it.
I'm looking to do something very simple to start with: Grab a windows
PE file, and dump the contents of the .text section into a raw file.

Is this possible using libbfd? Does anyone have any example on doing
this?

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

* Re: libbfd examples?
  2024-03-09 11:05 libbfd examples? Esteve Varela Colominas
@ 2024-03-09 12:56 ` Andreas Schwab
  2024-03-18 16:18 ` Nick Clifton
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2024-03-09 12:56 UTC (permalink / raw)
  To: Esteve Varela Colominas; +Cc: binutils

On Mär 09 2024, Esteve Varela Colominas wrote:

> I'm looking to do something very simple to start with: Grab a windows
> PE file, and dump the contents of the .text section into a raw file.

This is what objcopy --dump-section does.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: libbfd examples?
  2024-03-09 11:05 libbfd examples? Esteve Varela Colominas
  2024-03-09 12:56 ` Andreas Schwab
@ 2024-03-18 16:18 ` Nick Clifton
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2024-03-18 16:18 UTC (permalink / raw)
  To: Esteve Varela Colominas, binutils

Hi Esteve,

> libbfd seems to be the library that I'm looking for for my purposes,

It is.

> but I'm finding it hard to figure out how to get started with using it.
> I'm looking to do something very simple to start with: Grab a windows
> PE file, and dump the contents of the .text section into a raw file.

Have a look in the binutils/ sub-directory of the binutils sources.  There
are quite a few programs in there, some of which are quite simple and can give
you an indication of how to use the bfd library.

For example binutils/size.c is the source for the 'size' program and its
functions display_file() and display_bfd() are a nice simple example of how
to load a file, use the bfd library to scan it and then close things down
afterwards.

Cheers
   Nick






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

end of thread, other threads:[~2024-03-18 16:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-09 11:05 libbfd examples? Esteve Varela Colominas
2024-03-09 12:56 ` Andreas Schwab
2024-03-18 16:18 ` Nick Clifton

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).