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: [RFA] MIPS_TEXT symbols should be associated to .text section?


Joel Brobecker wrote:
[snip]
> So this leaves us with 2 options:
> 
>   1. Do a search for the .text and .data sections by name
> 
>   2. Find a place somewhere where we can set these fields before we
>      need to use them. If we have a hook for instance after we've
>      read the ELF header, or while iterating over the different sections
>      (I don't know the code, so I'm just tossing ideas).
>      
>      Or another approach would be to check that field, and if null
>      then do the lookup by name and store it in elf_tdata
>      (abfd)->elf_text_section for all the following symbols.
>      This is just an optimized variation of 1, really.

I prefer the first. Please test this patch.


Thiemo


Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.106
diff -u -p -r1.106 elfxx-mips.c
--- bfd/elfxx-mips.c	1 Jul 2004 14:53:40 -0000	1.106
+++ bfd/elfxx-mips.c	30 Jul 2004 18:53:18 -0000
@@ -4192,15 +4192,37 @@ _bfd_mips_elf_symbol_processing (bfd *ab
       asym->section = bfd_und_section_ptr;
       break;
 
-#if 0 /* for SGI_COMPAT */
     case SHN_MIPS_TEXT:
-      asym->section = mips_elf_text_section_ptr;
+      {
+	asection *section = bfd_get_section_by_name (abfd, ".text");
+
+	BFD_ASSERT (SGI_COMPAT (abfd));
+	if (section != NULL)
+	  {
+	    asym->section = section;
+	    /* MIPS_TEXT is a bit special, the address is not an offset
+	       to the base of the .text section.  So substract the section
+	       base address to make it an offset.  */
+	    asym->value -= section->vma;
+	  }
+      }
       break;
 
     case SHN_MIPS_DATA:
-      asym->section = mips_elf_data_section_ptr;
+      {
+	asection *section = bfd_get_section_by_name (abfd, ".data");
+
+	BFD_ASSERT (SGI_COMPAT (abfd));
+	if (section != NULL)
+	  {
+	    asym->section = section;
+	    /* MIPS_DATA is a bit special, the address is not an offset
+	       to the base of the .data section.  So substract the section
+	       base address to make it an offset.  */
+	    asym->value -= section->vma;
+	  }
+      }
       break;
-#endif
     }
 }
 


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