This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Improve ELF linker for non-ELF input


The current ELF linker can link in non-ELF input if it doesn't
reference symbols in DSO. This patch improves it a little bit so
that simple function call to DSO works.


H.J.
------
2004-04-22  H.J. Lu  <hongjiu.lu@intel.com>

	* elflink.c (_bfd_elf_link_create_dynamic_sections): Clear
	the ELF_LINK_NON_ELF bit on _DYNAMIC.
	(_bfd_elf_fix_symbol_flags): Increment PLT count for dynamic
	symbols referenced by non-ELF files.

--- bfd/elflink.c.mix	2004-04-22 08:20:09.000000000 -0700
+++ bfd/elflink.c	2004-04-22 10:12:48.000000000 -0700
@@ -218,6 +218,7 @@ _bfd_elf_link_create_dynamic_sections (b
     return FALSE;
   h = (struct elf_link_hash_entry *) bh;
   h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+  h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
   h->type = STT_OBJECT;
 
   if (! info->executable
@@ -2087,6 +2088,17 @@ _bfd_elf_fix_symbol_flags (struct elf_li
 	      eif->failed = TRUE;
 	      return FALSE;
 	    }
+
+	  switch (h->type)
+	    {
+	    case STT_FUNC:
+	      /* We need it to keep the PLT entry.  */
+	      h->plt.refcount++;
+	      break;
+
+	    default:
+	      break;
+	    }
 	}
     }
   else


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]