This is the mail archive of the 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]
Other format: [Raw text]

Re: Generating an ELF file with PT_NOTE before PT_LOAD

On Monday 26 February 2018 at 11:22:14 +0100, Andreas Schwab wrote:
> On Feb 23 2018, Mike Crowe <> wrote:
> > I think that I've done that by modifying the script to say:
> >
> > --8<--
> > cat > <<EOF
> > {
> >     .note : {
> >         *(
> >     } :note

I added ":load" to the end of that line.

> >     .text : {
> >     	*(
> You are just duplicating the (input) section, but not
> putting the .note (output) section into the load segment.  Note that you
> can put (output) sections into multiple segments.

Thanks. That does seem to generate a file with the note that the beginning.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  NOTE           0x000074 0x4007f000 0x4007f000 0x00020 0x00020 R   0x4
  LOAD           0x000074 0x4007f000 0x4007f000 0x100020 0x100020 R E 0x4

Unfortunately, because the segments now overlap, the loader that reads
directly from the compressed file now fails because it can't rewind. :(

Is there a way to do this that keeps the segments separate? Or do I need to
post-process the file myself (which is admittedly much easier to do now the
segment contents are in the right places.)


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