bug-binutils
[Top][All Lists]
Advanced

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

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


From: Paul Koning
Subject: ld: can't put data into PHDR types other than PT_LOAD
Date: Tue, 30 Nov 2004 14:10:58 -0500

It seems pretty pointless to have PHDRS if you can't put any data into
them, but it appears that this is how they work.  Only PT_LOAD
sections seem to accept data.

If you do try to put stuff into, say, a PT_NOTE section, you get a
linker warning.  You also get a rather bizarre combination of values
in the headers, which suggest that the linker tried to put some data
into the PT_NOTE header but decided against it at the last minute.
Specifically, you get the expected length (not zero) but you don't get
the load address filled in.

I can work around this by dropping the data in question into two
PHDRs, but surely this isn't right?

This simple script demonstrates the problem.  It works the same in
several versions, 2.13 through 2.15.

PHDRS
{
  note PT_NOTE ;
  prog PT_LOAD ;
}

SECTIONS
{
  .text 0x10000 :
  {
    *(*)
  } :prog
  notedata :
  {
    BYTE(0) BYTE(1)
  } :note /*:prog*/
}

Sample run:

address@hidden src]$ ld -o test2 -T test.ld test2.o
ld: test2: warning: allocated section `notedata' not in segment
address@hidden src]$ mipsel-netbsdelf-objdump -h test

test:     file format elf32-littlemips

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000060  00010000  00010000  00001000  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 notedata      00000002  00010060  00010060  00001060  2**0
                  CONTENTS, ALLOC, LOAD, DATA
address@hidden src]$ objdump -p test2

test2:     file format elf32-i386

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


         paul





reply via email to

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