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 14:25:04 -0500

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

 Ian> Paul Koning <address@hidden> writes:
 >> 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?

 Ian> No, actually it is right.

 Ian> Allocated data is data which should be accessible at run time.
 Ian> The only segments which the dynamic linker will load into memory
 Ian> are PT_LOAD segments.  Therefore, all allocated data must go
 Ian> into a PT_LOAD segment.  That is why the linker is warning you.

 Ian> Presumably you do want the data to be accessible at run time (a
 Ian> PT_NOTE segment can be either--it is entirely reasonable to have
 Ian> PT_NOTE segments which are not loaded, if they are only read by
 Ian> tools and not by the program itself).  For a runtime-accessible
 Ian> note section, the section should be in both a PT_LOAD segment
 Ian> and a PT_NOTE segment; the PT_NOTE segment would typically be a
 Ian> subset of the PT_LOAD segment.

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.

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.

        paul





reply via email to

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