linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Stripped binary insertion with the GNU Linker suggestions (fwd)
@ 2003-07-11 15:19 Jon Masters
  2003-07-11 15:35 ` Larry McVoy
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Masters @ 2003-07-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: jcm

Hi,

I have a linker script which amongst other things contains:

MEMORY
{
  sdram_linux    : ORIGIN = 0x00500000, LENGTH = 4M
}

SECTIONS {

.linux    :
{ linux_kernel } > sdram_linux

}

What I have is a stripped kernel image which I want to shove in to a
section in the output elf file though the Linker complains it does not
recognise the file format (as it perhaps should). I realise that the
above is not the correct way to do this - suggestions are very welcome.

I have seen other nasty ways to do this involving converting the image to
byte values in very large arrays or inserting literal byte values in to
the output file but there just has to be a generic method for inserting
an image in to the middle of an output file.

Cheers,

Jon.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Stripped binary insertion with the GNU Linker suggestions (fwd)
  2003-07-11 15:19 Stripped binary insertion with the GNU Linker suggestions (fwd) Jon Masters
@ 2003-07-11 15:35 ` Larry McVoy
  2003-07-11 16:00   ` Jon Masters
  0 siblings, 1 reply; 5+ messages in thread
From: Larry McVoy @ 2003-07-11 15:35 UTC (permalink / raw)
  To: Jon Masters; +Cc: linux-kernel, jcm

On Fri, Jul 11, 2003 at 04:19:55PM +0100, Jon Masters wrote:
> I have seen other nasty ways to do this involving converting the image to
> byte values in very large arrays or inserting literal byte values in to
> the output file but there just has to be a generic method for inserting
> an image in to the middle of an output file.

No, there isn't, at least I haven't found one.  The BK installer does 
exactly what you want (and you can have the source if you like, BSD 
license) on the platforms listed below.  We had to play some nasty 
games to make this work, I believe it was HP-UX which "knew" that your
array was full of zeros and did not allocate it, it did it at runtime.
Any sort of predictable pattern it figured out, the following fools it
for now:

unsigned char data_data[3866327] = {
        255,
        6,
        1,
        2,
        3,
        4,
        255,
        3,
        9,
        62,
        255,
        10,
        4,
        61,
        255,
};

platforms that this technique works on:

    alpha-glibc22-linux
    alpha-osf5.1
    arm-glibc21-linux
    hppa-glibc22-linux
    hppa-hpux
    ia64-glibc22-linux
    mips-glibc22-linux
    mips-irix
    mipsel-glibc20-linux
    powerpc-aix
    powerpc-darwin6.6
    powerpc-glibc21-linux
    sparc-glibc21-linux
    sparc-solaris
    x86-freebsd2.2.8
    x86-freebsd3.2
    x86-freebsd4.1
    x86-glibc20-linux
    x86-glibc21-linux
    x86-glibc22-linux
    x86-netbsd
    x86-openbsd
    x86-sco3.2v5.0.7
    x86-solaris

-- 
---
Larry McVoy              lm at bitmover.com          http://www.bitmover.com/lm

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Stripped binary insertion with the GNU Linker suggestions (fwd)
  2003-07-11 15:35 ` Larry McVoy
@ 2003-07-11 16:00   ` Jon Masters
  2003-07-11 16:37     ` Hollis Blanchard
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Masters @ 2003-07-11 16:00 UTC (permalink / raw)
  To: Larry McVoy; +Cc: Jon Masters, linux-kernel, jcm

On Fri, 11 Jul 2003, Larry McVoy wrote:

> On Fri, Jul 11, 2003 at 04:19:55PM +0100, Jon Masters wrote:
> > I have seen other nasty ways to do this involving converting the image to
> > byte values in very large arrays or inserting literal byte values in to
> > the output file but there just has to be a generic method for inserting
> > an image in to the middle of an output file.
> 
> No, there isn't, at least I haven't found one.

Arrgh! :-).

In that case I might take you up on the BK idea or write something using
bfd to munge the elf content - odd that it does not exist already.

The reason I want it is that I am creating a single elf output file which
is loaded in to SDRAM by a SystemACE chip and in order for that to work
correctly I need to give the appropriate tools a single elf input
containing everything where I want it to be loaded in memory.

Fun for the weekend I suppose... :-).

Jon.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Stripped binary insertion with the GNU Linker suggestions (fwd)
  2003-07-11 16:00   ` Jon Masters
@ 2003-07-11 16:37     ` Hollis Blanchard
  2003-07-12  1:14       ` Jon Masters
  0 siblings, 1 reply; 5+ messages in thread
From: Hollis Blanchard @ 2003-07-11 16:37 UTC (permalink / raw)
  To: Jon Masters; +Cc: Larry McVoy, linux-kernel, jcm

On Friday, Jul 11, 2003, at 11:00 US/Central, Jon Masters wrote:
>
> The reason I want it is that I am creating a single elf output file 
> which
> is loaded in to SDRAM by a SystemACE chip and in order for that to work
> correctly I need to give the appropriate tools a single elf input
> containing everything where I want it to be loaded in memory.

Not sure I understand the problem exactly, but I believe ppc32 kernels 
do exactly what you want. Have a look at arch/ppc/boot/ld.script and 
see __{image,ramdisk,sysmap}_begin . Also see how e.g. 
arch/ppc/boot/prep/Makefile uses objcopy 
--add-section=.image=vmlinux.gz .

The end result is taking an arbitrary file and stuffing it into an ELF 
section, then using a linker script to provide the start and end 
addresses of the file data.

-- 
Hollis Blanchard
IBM Linux Technology Center


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Stripped binary insertion with the GNU Linker suggestions (fwd)
  2003-07-11 16:37     ` Hollis Blanchard
@ 2003-07-12  1:14       ` Jon Masters
  0 siblings, 0 replies; 5+ messages in thread
From: Jon Masters @ 2003-07-12  1:14 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: Jon Masters, Larry McVoy, linux-kernel, jcm

On Fri, 11 Jul 2003, Hollis Blanchard wrote:

> Not sure I understand the problem exactly, but I believe ppc32 kernels 
> do exactly what you want. Have a look at arch/ppc/boot/ld.script and 
> see __{image,ramdisk,sysmap}_begin . Also see how e.g. 
> arch/ppc/boot/prep/Makefile uses objcopy 
> --add-section=.image=vmlinux.gz .

I had another look at this tonight on the train and agree that this was
after all exactly what I want and I will need to use this "dummy" method
to force the kernel in to a single section before shoving it in to the
final ELF output image.

Jon.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-07-12  1:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-11 15:19 Stripped binary insertion with the GNU Linker suggestions (fwd) Jon Masters
2003-07-11 15:35 ` Larry McVoy
2003-07-11 16:00   ` Jon Masters
2003-07-11 16:37     ` Hollis Blanchard
2003-07-12  1:14       ` Jon Masters

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).