This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Blackfin: fix crash when linking incompatible objects
- From: Bernd Schmidt <bernds_cb1 at t-online dot de>
- To: binutils at sources dot redhat dot com
- Date: Mon, 11 Feb 2008 17:06:53 +0100
- Subject: Blackfin: fix crash when linking incompatible objects
I'm a little behind applying patches from our local svn tree to the main
binutils tree. Here's the first though, which fixes a crash when
linking incompatible object files (normal vs. FD-PIC), and also cleans
up and fixes the code that detects these mismatches and warns about them.
Committed.
Bernd
--
This footer brought to you by insane German lawmakers.
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif
Index: bfd/ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.4128
diff -c -p -r1.4128 ChangeLog
*** bfd/ChangeLog 11 Feb 2008 13:52:01 -0000 1.4128
--- bfd/ChangeLog 11 Feb 2008 16:03:14 -0000
***************
*** 1,3 ****
--- 1,10 ----
+ 2008-02-11 Bernd Schmidt <bernd.schmidt@analog.com>
+
+ * elf32-bfin.c (bfin_relocate_section): Set up dynobj before using it
+ if necessary.
+ (elf32_bfin_merge_private_bfd_data): Simplify, and ensure object type
+ mismatches are detected.
+
2008-02-11 Daniel Jacobowitz <dan@codesourcery.com>
* cache.c (cache_bread): Set bfd_error_file_truncated if EOF
Index: bfd/elf32-bfin.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-bfin.c,v
retrieving revision 1.26
diff -c -p -r1.26 elf32-bfin.c
*** bfd/elf32-bfin.c 31 Dec 2007 11:01:54 -0000 1.26
--- bfd/elf32-bfin.c 11 Feb 2008 16:03:15 -0000
*************** bfin_relocate_section (bfd * output_bfd,
*** 2924,2929 ****
--- 2924,2937 ----
{
bfd_vma off;
+ if (dynobj == NULL)
+ {
+ /* Create the .got section. */
+ elf_hash_table (info)->dynobj = dynobj = output_bfd;
+ if (!_bfd_elf_create_got_section (dynobj, info))
+ return FALSE;
+ }
+
if (sgot == NULL)
{
sgot = bfd_get_section_by_name (dynobj, ".got");
*************** elf32_bfin_print_private_bfd_data (bfd *
*** 4795,4802 ****
static bfd_boolean
elf32_bfin_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
{
! flagword old_flags, old_partial;
! flagword new_flags, new_partial;
bfd_boolean error = FALSE;
new_flags = elf_elfheader (ibfd)->e_flags;
--- 4803,4809 ----
static bfd_boolean
elf32_bfin_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
{
! flagword old_flags, new_flags;
bfd_boolean error = FALSE;
new_flags = elf_elfheader (ibfd)->e_flags;
*************** elf32_bfin_merge_private_bfd_data (bfd *
*** 4814,4850 ****
if (!elf_flags_init (obfd)) /* First call, no flags set. */
{
elf_flags_init (obfd) = TRUE;
! old_flags = new_flags;
}
! else if (new_flags == old_flags) /* Compatible flags are ok. */
! ;
!
! else /* Possibly incompatible flags. */
! {
! /* We don't have to do anything if the pic flags are the same, or the new
! module(s) were compiled with -mlibrary-pic. */
! new_partial = (new_flags & EF_BFIN_PIC_FLAGS);
! old_partial = (old_flags & EF_BFIN_PIC_FLAGS);
! if (new_partial == old_partial)
! ;
!
! /* If we have mixtures of -fpic and -fPIC, or in both bits. */
! else if (new_partial != 0 && old_partial != 0)
! old_flags |= new_partial;
!
! /* One module was compiled for pic and the other was not, see if we have
! had any relocations that are not pic-safe. */
! else
! old_flags |= new_partial;
!
! }
!
! /* Update the old flags now with changes made above. */
! elf_elfheader (obfd)->e_flags = old_flags;
!
! if (((new_flags & EF_BFIN_FDPIC) == 0)
! != (! IS_FDPIC (ibfd)))
{
error = TRUE;
if (IS_FDPIC (obfd))
--- 4821,4830 ----
if (!elf_flags_init (obfd)) /* First call, no flags set. */
{
elf_flags_init (obfd) = TRUE;
! elf_elfheader (obfd)->e_flags = new_flags;
}
! if (((new_flags & EF_BFIN_FDPIC) == 0) != (! IS_FDPIC (obfd)))
{
error = TRUE;
if (IS_FDPIC (obfd))