This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PHDRS in ld script
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sourceware dot org
- Date: Fri, 31 Aug 2007 10:09:27 +0930
- Subject: PHDRS in ld script
If someone specifies PHDRS in a ld script, but doesn't assign any
sections to the phdrs, we hit a segfault in lang_record_phdrs.
* ldlang.c (lang_record_phdrs): Give a fatal error if no sections
assigned to phdrs. Avoid multiple forward scans for a section
with phdr assignment.
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.269
diff -u -p -r1.269 ldlang.c
--- ld/ldlang.c 28 Aug 2007 13:21:57 -0000 1.269
+++ ld/ldlang.c 31 Aug 2007 00:18:35 -0000
@@ -6263,9 +6263,7 @@ lang_record_phdrs (void)
|| (os->bfd_section->flags & SEC_ALLOC) == 0)
continue;
- if (last)
- pl = last;
- else
+ if (last == NULL)
{
lang_output_section_statement_type * tmp_os;
@@ -6279,9 +6277,14 @@ lang_record_phdrs (void)
http://sourceware.org/ml/binutils/2007-02/msg00291.html */
for (tmp_os = os; tmp_os; tmp_os = tmp_os->next)
if (tmp_os->phdrs)
- break;
- pl = tmp_os->phdrs;
+ {
+ last = tmp_os->phdrs;
+ break;
+ }
+ if (last == NULL)
+ einfo (_("%F%P: no sections assigned to phdrs\n"));
}
+ pl = last;
}
if (os->bfd_section == NULL)
--
Alan Modra
Australia Development Lab, IBM