bug-binutils
[Top][All Lists]
Advanced

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

Re: ld: can't put data into PHDR types other than PT_LOAD


From: Paul Koning
Subject: Re: ld: can't put data into PHDR types other than PT_LOAD
Date: Tue, 30 Nov 2004 15:03:26 -0500

>>>>> "Ian" == Ian Lance Taylor <address@hidden> writes:

 Ian> Paul Koning <address@hidden> writes:
 >> In fact, what I want is a note section that is NOT accessible at
 >> run time.  It's there for a tool to see, but not for the loader to
 >> load.

 Ian> Then you would normally put the data in a section which was not
 Ian> marked allocatable.

 >> I tried to get data into the note section by supplying it from an
 >> object file, and also from data in the script itself.  Either way,
 >> I get the halfway result I mentioned: the length of the phdr
 >> reflects the amount of data I want, but the offset is zero.  When
 >> I don't also put it into the load segment, the note data tends to
 >> be at the end of the file (or rather, between the loadable stuff
 >> and the debug data).  That's fine, but only if the note phdr
 >> points to it, which it refuses to do.

 Ian> Hmmm, this does sound like a bug.

Ok, revised test case:

notedata.S:

        .section        notedata
        .byte   0
        .byte   1
        .byte   42

script:

PHDRS
{
  note PT_NOTE ;
  prog PT_LOAD ;
}

SECTIONS
{
  notedata :
  {
        notedata.o (notedata)
  } :note /*:prog*/
  .text 0x10000 :
  {
        *(.data .text .bss .reginfo)
  } :prog
}

Test run:

address@hidden src]$ gcc -c notedata.S
address@hidden src]$ ld -o test2 -T test.ld notedata.o
address@hidden src]$ objdump -p test2

test2:     file format elf32-i386

Program Header:
    NOTE off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**0
         filesz 0x00000000 memsz 0x00000003 flags r--
    LOAD off    0x00001000 vaddr 0x00010000 paddr 0x00010000 align 2**12
         filesz 0x00000000 memsz 0x00000000 flags r-x

address@hidden src]$ objdump -h test2

test2:     file format elf32-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 notedata      00000003  00000000  00000000  00001000  2**0
                  CONTENTS, READONLY
  1 .text         00000000  00010000  00010000  00001000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE

No link warnings this time.  And the "notedata" section has a
"contents" attribute but not "alloc".

Now the filesz is zero, though the memsz reflects the size I wanted.
That's actually the reverse of what I expected to see -- given that
ALLOC and LOAD aren't set, I wouldn't have expected a memsize.

      paul





reply via email to

[Prev in Thread] Current Thread [Next in Thread]