summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Elliston <bje@au.ibm.com>2006-03-30 00:22:20 +0000
committerBen Elliston <bje@au.ibm.com>2006-03-30 00:22:20 +0000
commit2b80f67f3e6dee85c3263901220382c2ce35dc60 (patch)
tree0a056127ebd88573eb923337ed3c1e02dcd1f13e
parent27b726e1f8f79934f7773c3e6fc119960054e627 (diff)
downloadgdb-2b80f67f3e6dee85c3263901220382c2ce35dc60.tar.gz
PR ld/2267
* elflink.c (elf_fixup_link_order): Ensure `elfsec' is not a special section number that exceeds the number of ELF sections (eg. SHN_MIPS_SCOMMON).
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elflink.c5
2 files changed, 10 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 47d19f729d3..51157c0da72 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2006-03-30 Ben Elliston <bje@au.ibm.com>
+
+ PR ld/2267
+ * elflink.c (elf_fixup_link_order): Ensure `elfsec' is not a
+ special section number that exceeds the number of ELF sections
+ (eg. SHN_MIPS_SCOMMON).
+
2006-03-27 Richard Sandiford <richard@codesourcery.com>
* elfxx-mips.c (mips_got_entry): Add more commentary.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index f0a0e83cada..88e56da54d4 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -7665,7 +7665,7 @@ elf_fixup_link_order (bfd *abfd, asection *o)
struct bfd_link_order *p;
bfd *sub;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
- int elfsec;
+ unsigned elfsec;
struct bfd_link_order **sections;
asection *s, *other_sec, *linkorder_sec;
bfd_vma offset;
@@ -7682,7 +7682,8 @@ elf_fixup_link_order (bfd *abfd, asection *o)
sub = s->owner;
if (bfd_get_flavour (sub) == bfd_target_elf_flavour
&& elf_elfheader (sub)->e_ident[EI_CLASS] == bed->s->elfclass
- && (elfsec = _bfd_elf_section_from_bfd_section (sub, s)) != -1
+ && (elfsec = _bfd_elf_section_from_bfd_section (sub, s))
+ && elfsec < elf_numsections (sub)
&& elf_elfsections (sub)[elfsec]->sh_flags & SHF_LINK_ORDER)
{
seen_linkorder++;