This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: gas .incbin pseudo-op
- To: Alan Modra <amodra at bigpond dot net dot au>
- Subject: Re: PATCH: gas .incbin pseudo-op
- From: Anders Norlander <anorland at synergenix dot se>
- Date: 06 Jul 2001 10:29:20 +0200
- Cc: Binutils List <binutils at sources dot redhat dot com>
- References: <993829827.23471.10.camel@localhost> <20010705234829.U16275@bubble.sa.bigpond.net.au>
On 05 Jul 2001 23:48:29 +0930, Alan Modra wrote:
> On Fri, Jun 29, 2001 at 05:52:34PM +0200, Anders Norlander wrote:
> >
> > this patch adds a .incbin directive to gas to include files
> > verbatim at the current location, as found in many other assemblers.
> > I'm a bit surprised this has not come up before, but the archives
> > didn't reveal anything.
>
> Hi Anders,
> It's already possible to include binary files using the linker, which
> is probably why no one has found this feature necessary.
Yeah, that's possible but not as flexible. With .incbin you can do
it directly from C (or whatever), like this
#define INCBIN(symname, filename) \
__asm__ (".section .rodata ; .align 2; .globl " symname); \
__asm__ (symname ":\n.incbin \"" filename "\""); \
extern unsigned char symname[];
INCBIN(resource, "resource.dat");
This can be extremely useful to include graphics/sound/tables etc.
and have full control over symbols, sections and data included
from the file without having to modify your linker command and/or
linker script. Many people use objcopy to convert the binary into
a real object file, but that adds an extra conversion step to the
procedure, so I think it can be really useful.
-Anders