This is the mail archive of the binutils@sourceware.cygnus.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]

Unique section ids


I'd like to add another field to the asection structure to uniquely
identify input sections.  The reason for this is that the hppa port needs
to create long branch stubs to local symbols, and some means is needed to
make local symbols globally unique so we can use a hash lookup.  I'm
currently using the following:
 
	  if (h == NULL)
	    sprintf (stub_name + len - 10, "_%08x",
		     (int) sym_sec & 0xffffffff);

ie.  We just tack on the address of the asection structure.  This works
quite well, but it has the drawback that the memory address of the
structure is fairly random.  For exactly the same input files, stubs
output via bfd_hash_traverse come in a different order for different
linker builds.  This makes comparison of output files (and debugging the
linker) more difficult.

Has anyone a better idea?  Or can point me to an existing way of uniquely
identifying input sections short of enumerating over input bfds?

Regards, Alan Modra
-- 
Linuxcare.  Support for the Revolution.


--- section.c~	Fri Apr  7 10:54:53 2000
+++ section.c	Thu Jul  6 12:58:25 2000
@@ -178,6 +178,10 @@ CODE_FRAGMENT
 .
 .    CONST char *name;
 .
+.        {* A unique sequence number.  *}
+.
+.    int id;
+.
 .        {* Which section is it; 0..nth.      *}
 .
 .   int index;
@@ -683,6 +687,7 @@ bfd_make_section_anyway (abfd, name)
      bfd *abfd;
      CONST char *name;
 {
+  static int section_id = 0;
   asection *newsect;
   asection **prev = &abfd->sections;
   asection *sect = abfd->sections;
@@ -704,6 +709,7 @@ bfd_make_section_anyway (abfd, name)
     return NULL;
 
   newsect->name = name;
+  newsect->id = section_id++;
   newsect->index = abfd->section_count++;
   newsect->flags = SEC_NO_FLAGS;
 


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