delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/02/13/22:20:21

X-Authentication-Warning: larry.ztnet.com: Host cm-24-25-151-140.nycap.rr.com [24.25.151.140] claimed to be shady
Message-ID: <00b901c09635$8fca3240$8c971918@nycap.rr.com>
From: "Matthew Conte" <zeus AT nofrendo DOT org>
To: <djgpp-workers AT delorie DOT com>
Subject: possible objcopy problem.
Date: Tue, 13 Feb 2001 22:23:49 -0500
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
Reply-To: djgpp-workers AT delorie DOT com

Hello, djgpp-workers.  I'm having a bit of trouble with objcopy, and I'm not
quite sure if I should take this to the binutils mailing list, so I thought
I might present the problem here.  I apologize if this is a bit off-topic,
but I was directed here by someone on comp.os.msdos.djgpp.

I use the ARM/elf port of the GNU tools for my software development at work,
and I've been a long-time user of gcc and djgpp at home.  As I work in the
games industry, I routinely need to include large binary files (graphics,
sound, etc.) into my programs at work.  When I used to work in purely ASM,
this was easy, as most assemblers simply allow you to include binary files.
Moving to C/C++ made it a tad harder, but I found a way to use objcopy to do
my dirty work.

Taking a raw chunk of binary data, 'input.bin', and issuing the following
command (for ARM7):

$ objcopy -v -I binary -O elf32-little input.bin output.o

generates an object file with with the entirety of the file in the .data
section, and the following symbols defined:

    extern const char _binary_input_bin_start[];
    extern const char _binary_input_bin_end[];
    extern const char _binary_input_bin_size[];

This object file can simply linked into the executable and used out of the
box.

I tried the same thing with djgpp, and I'm running into trouble.

$ objcopy -v -I binary -O coff-go32 input.bin output.o

Now, objcopy gives me a *warning* here, but for the books, I get the same
warning when using the elf32-little port:

> copy from input.bin(binary) to output.o(coff-go32)
> c:/djgpp/bin/objcopy.exe: Warning: Output file cannot represent
architecture UNKNOWN!

Running 'nm' on this file generates:

$ nm output.o
> c:/djgpp/bin/nm.exe: output.o: File format not recognized

Even though I can clearly see (in a hex editor) the ".data" section tag, and
the debug symbol names (the aforementioned const char []'s).

Can anyone offer any kind of explanation as to what is going wrong?  Is the
djgpp port broken, or the elf32-little port, or neither?

Thank you very much in advance; all help appreciated.

Regards,
Matthew Conte.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019