PATCH: ld/2008: Segfault on IA64, something to do with Unwind and section ordering
H. J. Lu
hjl@lucon.org
Mon Dec 12 19:45:00 GMT 2005
On Mon, Dec 12, 2005 at 06:59:56AM -0800, H. J. Lu wrote:
> PR 1991 may leave bogus valus in the sh_link field, which leads to
> PR 2008 where linker will segfault. This patch bails out if the section
> which the sh_link field points to doesn't have an output section.
>
>
Here is an update. I moved the check from elf_get_linked_section_vma
to _bfd_elf_setup_sections.
Does anyone know why bfd_check_format_matches checks the default
target twice? This patch also removed the duplicate.
H.J.
----
2005-12-12 H.J. Lu <hongjiu.lu@intel.com>
PR ld/2008
* elf.c (_bfd_elf_setup_sections): Return FALSE if
elf_linked_to_section will be set to NULL.
* format.c (bfd_check_format_matches): Don't check the default
target twice.
--- bfd/elf.c.bad 2005-12-08 07:06:37.000000000 -0800
+++ bfd/elf.c 2005-12-12 11:04:26.000000000 -0800
@@ -654,8 +654,23 @@ _bfd_elf_setup_sections (bfd *abfd)
}
else
{
+ asection *link;
+
this_hdr = elf_elfsections (abfd)[elfsec];
- elf_linked_to_section (s) = this_hdr->bfd_section;
+
+ /* PR 1991, 2008:
+ Some strip/objcopy may leave an incorrect value in
+ sh_link. We don't want to proceed. */
+ link = this_hdr->bfd_section;
+ if (link == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%B: sh_link [%d] in section `%A' is incorrect"),
+ s->owner, s, elfsec);
+ result = FALSE;
+ }
+
+ elf_linked_to_section (s) = link;
}
}
}
--- bfd/format.c.bad 2005-10-07 13:47:31.000000000 -0700
+++ bfd/format.c 2005-12-12 11:14:20.000000000 -0800
@@ -217,7 +217,9 @@ bfd_check_format_matches (bfd *abfd, bfd
const bfd_target *temp;
bfd_error_type err;
- if (*target == &binary_vec)
+ /* Don't check the default target twice. */
+ if (*target == &binary_vec
+ || (!abfd->target_defaulted && *target == save_targ))
continue;
abfd->xvec = *target; /* Change BFD's target temporarily. */
More information about the Binutils
mailing list