public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Mumit Khan <khan@xraylith.wisc.EDU>
To: binutils@sourceware.cygnus.com
Subject: take 2: pe-dll fix for exporting common symbols
Date: Thu, 01 Jul 1999 00:00:00 -0000	[thread overview]
Message-ID: <199906251512.KAA18471@mercury.xraylith.wisc.edu> (raw)
In-Reply-To: <199906250019.UAA24786@envy.delorie.com>

DJ Delorie <dj@delorie.com> writes:
> 
> You can't build the export table in ldemul_finish because building the
> export table produces yet another section that must be linked in (the
> reloc section is a mess because of this, but at least it's one of the
> last sections in the dll so has less ramifications if its size
> changes).  Perhaps just the part about filling in the final values can
> be shifted to the later stage?

Ok, I finally have the right offsets in the test cases (and this time
real ones with lots of commons, both exported and local variety), and
all the addresses agree with dllwrap (multiple gcc/ld passes) created
DLLs.

The code is essentially the same as before, except that we lookup the
just exported symbol offsets after the commons are laid out. The only
offsets to change are the ones that were previous bfd_hash_link_common
type.

Fri Jun 25 10:07:41 1999  Mumit Khan  <khan@xraylith.wisc.edu>

	* pe-dll.c (process_def_file): Move the offset lookup from here to
	(fill_exported_offsets): here. New static function.
	(fill_edata): Use.

Index: pe-dll.c
===================================================================
RCS file: /cvs/binutils/binutils/ld/pe-dll.c,v
retrieving revision 1.2
diff -u -3 -p -r1.2 pe-dll.c
--- pe-dll.c	1999/05/11 21:06:48	1.2
+++ pe-dll.c	1999/06/25 16:14:14
@@ -383,13 +383,21 @@ process_def_file (abfd, info)
 				   name,
 				   false, false, true);
 
-      if (blhe && (blhe->type == bfd_link_hash_defined))
+      if (blhe 
+          && (blhe->type == bfd_link_hash_defined
+	      || (blhe->type == bfd_link_hash_common)))
 	{
 	  count_exported++;
 	  if (!pe_def_file->exports[i].flag_noname)
 	    count_exported_byname++;
-	  exported_symbol_offsets[i] = blhe->u.def.value;
-	  exported_symbol_sections[i] = blhe->u.def.section;
+
+	  /* Only fill in the sections. The actual offsets are computed
+	     in fill_exported_offsets() after common symbols are laid
+	     out.  */
+          if (blhe->type == bfd_link_hash_defined)
+	    exported_symbol_sections[i] = blhe->u.def.section;
+	  else
+	    exported_symbol_sections[i] = blhe->u.c.p->section;
 	  if (pe_def_file->exports[i].ordinal != -1)
 	    {
 	      if (max_ordinal < pe_def_file->exports[i].ordinal)
@@ -571,7 +579,44 @@ generate_edata (abfd, info)
 	      + name_table_size + strlen (dll_name) + 1);
 }
 
+/* Fill the exported symbol offsets. The preliminary work has already 
+   been done in process_def_file().  */
+
 static void
+fill_exported_offsets (abfd, info)
+     bfd *abfd;
+     struct bfd_link_info *info;
+{
+  int i, j;
+  struct bfd_link_hash_entry *blhe;
+  bfd *b;
+  struct sec *s;
+  def_file_export *e=0;
+
+  for (i = 0; i < pe_def_file->num_exports; i++)
+    {
+      char *name = (char *) xmalloc (strlen (pe_def_file->exports[i].internal_name) + 2);
+      if (pe_details->underscored)
+	{
+	  *name = '_';
+	  strcpy (name + 1, pe_def_file->exports[i].internal_name);
+	}
+      else
+	strcpy (name, pe_def_file->exports[i].internal_name);
+
+      blhe = bfd_link_hash_lookup (info->hash,
+				   name,
+				   false, false, true);
+
+      if (blhe && (blhe->type == bfd_link_hash_defined))
+	{
+	  exported_symbol_offsets[i] = blhe->u.def.value;
+        }
+      free (name);
+    }
+}
+
+static void
 fill_edata (abfd, info)
      bfd *abfd;
      struct bfd_link_info *info;
@@ -613,6 +658,8 @@ fill_edata (abfd, info)
   bfd_put_32 (abfd, ERVA (eaddresses), edata_d + 28);
   bfd_put_32 (abfd, ERVA (enameptrs), edata_d + 32);
   bfd_put_32 (abfd, ERVA (eordinals), edata_d + 36);
+
+  fill_exported_offsets (abfd, info);
 
   /* Ok, now for the filling in part */
   hint = 0;

      reply	other threads:[~1999-07-01  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-01  0:00 (fixed patch) " Mumit Khan
1999-07-01  0:00 ` Ian Lance Taylor
1999-07-01  0:00   ` Mumit Khan
1999-07-01  0:00     ` Ian Lance Taylor
1999-07-01  0:00       ` Mumit Khan
1999-07-01  0:00         ` DJ Delorie
1999-07-01  0:00           ` Mumit Khan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199906251512.KAA18471@mercury.xraylith.wisc.edu \
    --to=khan@xraylith.wisc.edu \
    --cc=binutils@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).