From 4100cea361e40b86953629f28dcab4d8d12d5fbe Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 8 Oct 2009 01:00:27 +0000 Subject: [PATCH] PR ld/10744 * ldlang.c (lang_new_phdr): Allow FILEHDR/PHDRS on more than the first PT_LOAD header. * ld.texinfo: Update. --- ld/ChangeLog | 7 +++++++ ld/ld.texinfo | 3 ++- ld/ldlang.c | 6 ++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index fe15c36d17c..5ed952e0a9e 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2009-10-08 Alan Modra + + PR ld/10744 + * ldlang.c (lang_new_phdr): Allow FILEHDR/PHDRS on more than the + first PT_LOAD header. + * ld.texinfo: Update. + 2009-10-06 Nathan Sidwell * ldlang.c (lang_new_phdr): Check PHDRS and FILEHDR in loadable diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 978ae669f1e..21ff9cd6299 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -4740,7 +4740,8 @@ the program header type to further describe the contents of the segment. 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. diff --git a/ld/ldlang.c b/ld/ldlang.c index a46438ed8ee..f1daeb57113 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -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; } -- 2.30.2