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]

PATCH: Avoid setting the bogus section symbol index.


On Mon, Aug 20, 2001 at 04:05:15PM -0700, H . J . Lu wrote:
> On Mon, Aug 20, 2001 at 03:03:28PM -0700, Richard Henderson wrote:
> > On Mon, Aug 20, 2001 at 11:44:19AM -0700, H . J . Lu wrote:
> > >  00000000  200569c000000006 R_ALPHA_GPDISP        bad symbol index: 200569c0
> > > 
> > > How should we fix it?
> > 
> > The symbol for GPDISP is completely irrelevant.  Only the offset
> > is meaningful.  Use the current section symbol rather than a
> > random section symbol.
> > 
> 

Here is a patch to avoid setting the bogus section symbol index. Now,
I am getting:

/export/build/gnu/binutils/build-alpha-linux/binutils/strip-new --strip-debug foo.o -o strip.o
BFD: strip.o: symbol `.debug_line' required but not present

I will check it in shortly if there is no objection.


H.J.
----
2001-08-20  H.J. Lu  <hjl@gnu.org>

	* elf-bfd.h (elf_obj_tdata): Add num_section_syms.
	(elf_num_section_syms): New for num_section_syms.

	* elf.c (elf_map_symbols): Set num_section_syms.
	(_bfd_elf_symbol_from_bfd_symbol): Check num_section_syms for
	the section symbol index.

Index: elf-bfd.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf-bfd.h,v
retrieving revision 1.15
diff -u -p -r1.15 elf-bfd.h
--- elf-bfd.h	2001/08/17 17:56:19	1.15
+++ elf-bfd.h	2001/08/20 23:42:08
@@ -821,6 +821,7 @@ struct elf_obj_tdata
   struct bfd_strtab_hash *strtab_ptr;
   int num_locals;
   int num_globals;
+  int num_section_syms;
   asymbol **section_syms;		/* STT_SECTION symbols for each section */
   Elf_Internal_Shdr symtab_hdr;
   Elf_Internal_Shdr shstrtab_hdr;
@@ -962,6 +963,7 @@ struct elf_obj_tdata
 #define elf_num_locals(bfd)	(elf_tdata(bfd) -> num_locals)
 #define elf_num_globals(bfd)	(elf_tdata(bfd) -> num_globals)
 #define elf_section_syms(bfd)	(elf_tdata(bfd) -> section_syms)
+#define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms)
 #define core_prpsinfo(bfd)	(elf_tdata(bfd) -> prpsinfo)
 #define core_prstatus(bfd)	(elf_tdata(bfd) -> prstatus)
 #define elf_gp(bfd)		(elf_tdata(bfd) -> gp)
Index: elf.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf.c,v
retrieving revision 1.60
diff -u -p -r1.60 elf.c
--- elf.c	2001/08/17 17:56:19	1.60
+++ elf.c	2001/08/20 23:42:08
@@ -2092,6 +2092,7 @@ elf_map_symbols (abfd)
   if (sect_syms == NULL)
     return false;
   elf_section_syms (abfd) = sect_syms;
+  elf_num_section_syms (abfd) = max_index;
 
   for (idx = 0; idx < symcount; idx++)
     {
@@ -3652,7 +3653,8 @@ _bfd_elf_symbol_from_bfd_symbol (abfd, a
 	indx = asym_ptr->section->output_section->index;
       else
 	indx = asym_ptr->section->index;
-      if (elf_section_syms (abfd)[indx])
+      if (indx < elf_num_section_syms (abfd)
+	  && elf_section_syms (abfd)[indx])
 	asym_ptr->udata.i = elf_section_syms (abfd)[indx]->udata.i;
     }
 


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