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]

Re: PATCH for uninitialized junk in .dynsym


>>>>> "Franz" == Franz Sirl <Franz.Sirl-kernel@lauterbach.com> writes:

    Franz> That didn't help :-(. And I don't think this is correct
    Franz> either. dynindx is checked against -1 all over the
    Franz> place.

That's the for hash-table entries, though, not for sections.  I
believe sections have their dynindices initialized to zero.

    Franz> And AFA I could see dynindx entries containing eg. 2 were
    Franz> zeroed too, decremented by one on every call.

The idea is that the PPC back-end is assigning dynindices to most
sections, in ouput order.  So:
 
          Section Index     Dynamic Index
  section 1                 -1
  section 2                 1
  section 3                 -1
  section 4                 2
  section 5                 3
  ...

Now, if we remove sections with section index 2 and 4, say, section 5,
which used to have dynamic index 3, should now have dynamic index 1.
But, the -1s will make it have dynamic index -1!  

Still, if you say that didn't fix it, I'm not sure what *else* is
causing problems.  But, I am sure the -1 there will conflict with the
assumptions in the code I checked in; either that code is wrong, or
the ppc back-end is, now.  There are indeed other places in the PPC
back-end where -1 is used for sections; these shold be changed to.
Here's one:

      for (s = output_bfd->sections; s != NULL; s = s->next)
	{
	  int indx, dindx;

	  sym.st_value = s->vma;

	  indx = elf_section_data (s)->this_idx;
	  dindx = elf_section_data (s)->dynindx;
	  if (dindx != -1)
	    {
	      BFD_ASSERT(indx > 0);
	      BFD_ASSERT(dindx > 0);

	      if (dindx > maxdindx)
		maxdindx = dindx;

	      sym.st_shndx = indx;

	      bfd_elf32_swap_symbol_out (output_bfd, &sym,
					 (PTR) (((Elf32_External_Sym *)
						 sdynsym->contents)
						+ dindx));
	    }

Make that -1 a zero.  Note that this code implies that zero is not a
valid value; it uses `BFD_ASSERT (dindx > 0)'.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

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