Re: Include binary file?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/20/2010 05:44 PM, Mark Ainsworth wrote:
> Hello, at link time I would like to include the contents of a binary
> file into the output executable, in a separate segment.  In my code I
> would then read this as an array.  I've done this before with other
> compilers / linkers, but not with gcc.  Can you show me the directives
> to do this?

I'm not aware of any gcc directive to do it.  I think objcopy can
read a binary and then make a section of it.  See the  --rename-section
section in the objcopy manual.

Like this:

objcopy -I binary -O elf64-x86-64 --rename-section .data=.mydata,alloc,load,readonly,data,contents file.txt  foo.o

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux