creating binaries by objcopy

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

creating binaries by objcopy

Bahadir Balban
Hi,

The binutils manual says:

"When objcopy generates a raw binary file, it will essentially produce
a memory dump of the contents of the input object file. All symbols
and relocation information will be discarded."

So if I have an ELF file that is defined to be scatter-loaded into
various addresses in memory, and also includes a bss section,

a) If I convert this to a binary via objcopy, does this mean I lose
all the loader-related services to do the scatter-loading, and
allocation of the bss?

b) Do I need to define routines that copy the scattered sections, zero
out the bss etc if I want to have such services of a loader? Is there
a better way to do this? Do RTOSes define their own methods to do
these?

Thanks,
Bahadir
Reply | Threaded
Open this post in threaded view
|

Re: creating binaries by objcopy

Daniel Jacobowitz-2
On Sun, Jun 05, 2005 at 08:41:30PM +0100, Bahadir Balban wrote:

> Hi,
>
> The binutils manual says:
>
> "When objcopy generates a raw binary file, it will essentially produce
> a memory dump of the contents of the input object file. All symbols
> and relocation information will be discarded."
>
> So if I have an ELF file that is defined to be scatter-loaded into
> various addresses in memory, and also includes a bss section,
>
> a) If I convert this to a binary via objcopy, does this mean I lose
> all the loader-related services to do the scatter-loading, and
> allocation of the bss?
>
> b) Do I need to define routines that copy the scattered sections, zero
> out the bss etc if I want to have such services of a loader? Is there
> a better way to do this? Do RTOSes define their own methods to do
> these?

The answers to these questions depend on your target and on your
linker.  It's hard to say.

--
Daniel Jacobowitz
CodeSourcery, LLC
Reply | Threaded
Open this post in threaded view
|

Re: creating binaries by objcopy

Bahadir Balban
On 6/5/05, Daniel Jacobowitz <[hidden email]> wrote:
> The answers to these questions depend on your target and on your
> linker.  It's hard to say.
>
> --
> Daniel Jacobowitz
> CodeSourcery, LLC
>

In fact I am using an arm-elf-gcc toolchain and also arm-none-eabi
from CodeSourcery. The problem is that after I generate a binary,
objdump does not work on it, (fails with a not valid elf file error,
which is expected) so I can't see if the file layout is somewhat what
I want. How else could I find out?

Thanks,
Bahadir
Reply | Threaded
Open this post in threaded view
|

Re: creating binaries by objcopy

Daniel Jacobowitz-2
On Sun, Jun 05, 2005 at 08:53:53PM +0100, Bahadir Balban wrote:

> On 6/5/05, Daniel Jacobowitz <[hidden email]> wrote:
> > The answers to these questions depend on your target and on your
> > linker.  It's hard to say.
> >
> > --
> > Daniel Jacobowitz
> > CodeSourcery, LLC
> >
>
> In fact I am using an arm-elf-gcc toolchain and also arm-none-eabi
> from CodeSourcery. The problem is that after I generate a binary,
> objdump does not work on it, (fails with a not valid elf file error,
> which is expected) so I can't see if the file layout is somewhat what
> I want. How else could I find out?

You can't, really.  But it's going to be all of the sections of the ELF
file which have ALLOC set, and I believe that will include any
NOBITS sections like .bss.  The whole file will expect to be loaded to
a contiguous region of memory at the lowest address of any section with
contents.

--
Daniel Jacobowitz
CodeSourcery, LLC
Reply | Threaded
Open this post in threaded view
|

Re: creating binaries by objcopy

Nick Clifton
In reply to this post by Bahadir Balban
Hi Bahadir,

> The binutils manual says:
>
> "When objcopy generates a raw binary file, it will essentially produce
> a memory dump of the contents of the input object file. All symbols
> and relocation information will be discarded."

First of all, just to be sure that there is no confusion here: when the
binutils manual talks about a "raw binary" file it is talking about a
file in one particular specific format.  It is not talking about any
arbitrary binary file such as an ELF executable file, or an IHEX binary
file.  It is talking about a *raw* binary file where essentially the
only structuring is that the file could be loaded/mapped into memory and
then executed by jumping to an address which the host OS must have found
out through some other means.

> b) Do I need to define routines that copy the scattered sections, zero
> out the bss etc if I want to have such services of a loader?

 > Is there a better way to do this?

Yes - do not use the raw binary format.  Stick with the ELF format.  Or
if you must, choose a simpler format like IHEX or SREC.

Cheers
   Nick