This is the mail archive of the binutils@sourceware.org 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: linker bug 10515


On Wed, Oct 07, 2009 at 03:50:21PM -0700, H.J. Lu wrote:
> Can we allow FILEHDRS/PHDRS if the previous segment has the same
> headers?

Seems we must.  Sorry Nathan, I got it wrong.  This relaxes the
check.  There may be further unsupported combinations that we
currently don't check for, but I'm not going to worry about that right
now.

	PR ld/10744
	* ldlang.c (lang_new_phdr): Allow FILEHDR/PHDRS on more than the
	first PT_LOAD header.
	* ld.texinfo: Update.

-- 
Alan Modra
Australia Development Lab, IBM
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.321
diff -u -p -r1.321 ldlang.c
--- ld/ldlang.c	7 Oct 2009 07:25:35 -0000	1.321
+++ ld/ldlang.c	8 Oct 2009 00:08:38 -0000
@@ -6779,9 +6779,11 @@ lang_new_phdr (const char *name,
   hdrs = n->type == 1 && (phdrs || filehdr);
 
   for (pp = &lang_phdr_list; *pp != NULL; pp = &(*pp)->next)
-    if (hdrs && (*pp)->type == 1)
+    if (hdrs
+	&& (*pp)->type == 1
+	&& !((*pp)->filehdr || (*pp)->phdrs))
       {
-	einfo (_("%X%P:%S: PHDRS and FILEHDR are only permitted for the first PT_LOAD segment\n"));
+	einfo (_("%X%P:%S: PHDRS and FILEHDR are not supported when prior PT_LOAD headers lack them\n"));
 	hdrs = FALSE;
       }
 
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.249
diff -u -p -r1.249 ld.texinfo
--- ld/ld.texinfo	7 Oct 2009 07:25:35 -0000	1.249
+++ ld/ld.texinfo	8 Oct 2009 00:08:44 -0000
@@ -4740,7 +4740,8 @@ the program header type to further descr
 The @code{FILEHDR} keyword means that the segment should include the ELF
 file header.  The @code{PHDRS} keyword means that the segment should
 include the ELF program headers themselves.  If applied to a loadable
-segment (@code{PT_LOAD}), it must be the first loadable segment.
+segment (@code{PT_LOAD}), all prior loadable segments must have one of
+these keywords.
 
 The @var{type} may be one of the following.  The numbers indicate the
 value of the keyword.


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