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]

MIPS, strip --only-keep-debug & an infinite loop


While investigating one of the many FAILS in the GDB testsuite on
mips64-unknown-openbsd3.7, I disvovered that GDB was sitting in an
infinite loop while going over the .MIPS.options section of a loaded
file.  The file in question was created using `strip
--only-keep-debug' and was part of a test to check whether loading a
file with seperate debug info works.

I caught GDB in the following loop:

      l = contents;
      lend = contents + hdr->sh_size;
      while (l + sizeof (Elf_External_Options) <= lend)
	{
	  Elf_Internal_Options intopt;

	  [...]

	  l += intopt.size;
	}

with INTOPT.SIZE = 0.  This obviously isn't desirable and since we
cannot guarantee that the user will never pass us an input file that
causes this, we should do something about it.

The obvious solution seems to be to add something like:

         if (intopt.size == 0)
	   return FALSE;

Unfortunately, this makes GDB reject the input file, which makes
loading the seperate debug info impossible.

This is all caused by the fact that `strip --only-keep-debug' doesn't
really completely strip out the .MIPS.options section.  Instead, it
sets the on-disk size of the section to 0 and strips the data from the
file.  This makes BFD replace the contents with all zeroes when we try
to read them, which in turn causes INTOPT.SIZE = 0 in the loop
mentioned above.

The easiest way out of this is silently skip further processing of
.MIPS.options if INTOPT.size = 0 is encountered:

         if (intopt.size == 0)
	   break;

Is there a better way?

Mark


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