This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: gas .incbin pseudo-op


On Fri, Jul 06, 2001 at 10:29:20AM +0200, Anders Norlander wrote:
> 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.

I'll add another use for this - one which would be properly solved
elsewhere, but this would at least be a convenient workaround.  Many
ELF flags are set only by gas, and checked by the linker; objcopy has
no way to specify them.  A good example are the e_flags ABI bits on
MIPS.  It's tricky to link a piece of binary data into a -mips2 kernel;
we do it currently by editing the flags by hand.  This would let us
leverage gas's command line to set them.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]