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]

Re: MIPS multi-got link support


On Jan 19, 2003, Hans-Peter Nilsson <hp@bitrange.com> wrote:

>> However, I'd appreciate suggestions on what fields of a bfd to use to
>> compute its hash code.  There doesn't seem to be a bfd unique
>> identifier,

> Then let's add one!  Sections have it, so it's only fair.

Here's a patch that adds an unique id to every bfd that is created.
Ok to install?  The idea is to tweak the multi-got patch so as to use
bfd->id instead of htab_hash_pointer (bfd) all over.

Index: bfd/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* bfd.c (struct _bfd): Added id field.
	* opncls.c (_bfd_id_counter): New static variable.
	(_bfd_new_bfd): Use it.
	* bfd-in2.h: Rebuilt.

Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.194
diff -u -p -r1.194 bfd-in2.h
--- bfd/bfd-in2.h 24 Jan 2003 23:44:44 -0000 1.194
+++ bfd/bfd-in2.h 26 Jan 2003 04:13:27 -0000
@@ -3536,6 +3536,9 @@ bfd_copy_private_symbol_data PARAMS ((bf
 /* Extracted from bfd.c.  */
 struct _bfd
 {
+  /* A unique identifier of the BFD  */
+  unsigned int id;
+
   /* The filename the application opened the BFD with.  */
   const char *filename;
 
Index: bfd/bfd.c
===================================================================
RCS file: /cvs/src/src/bfd/bfd.c,v
retrieving revision 1.44
diff -u -p -r1.44 bfd.c
--- bfd/bfd.c 30 Nov 2002 08:39:34 -0000 1.44
+++ bfd/bfd.c 26 Jan 2003 04:13:27 -0000
@@ -36,6 +36,9 @@ CODE_FRAGMENT
 .
 .struct _bfd
 .{
+.  {* A unique identifier of the BFD  *}
+.  unsigned int id;
+.
 .  {* The filename the application opened the BFD with.  *}
 .  const char *filename;
 .
Index: bfd/opncls.c
===================================================================
RCS file: /cvs/src/src/bfd/opncls.c,v
retrieving revision 1.12
diff -u -p -r1.12 opncls.c
--- bfd/opncls.c 30 Nov 2002 08:39:40 -0000 1.12
+++ bfd/opncls.c 26 Jan 2003 04:13:28 -0000
@@ -36,6 +36,10 @@
 #define S_IXOTH 0001	/* Execute by others.  */
 #endif
 
+/* Counter used to initialize the bfd identifier.  */
+
+static unsigned int _bfd_id_counter = 0;
+
 /* fdopen is a loser -- we should use stdio exclusively.  Unfortunately
    if we do that we can't use fcntl.  */
 
@@ -49,6 +53,8 @@ _bfd_new_bfd ()
   nbfd = (bfd *) bfd_zmalloc ((bfd_size_type) sizeof (bfd));
   if (nbfd == NULL)
     return NULL;
+
+  nbfd->id = _bfd_id_counter++;
 
   nbfd->memory = (PTR) objalloc_create ();
   if (nbfd->memory == NULL)
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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