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

Fix MIPS shared library debugging


After talking with Richard Sandiford, I've decided to check in the
attached as an obvious fix.  There is a triple set of problems:

 - We create a DT_DEBUG entry, but glibc does not initialize it.  It
   only initializes DT_MIPS_RLD_MAP.
 - GDB looks for DT_DEBUG or DT_MIPS_RLD_MAP, but stops after the
   first one it finds - initialized or not.
 - Richard's recent patch swapped DT_DEBUG to come first.

I think the glibc and GDB behaviors are both bugs, though I'm not
going to fix them at this moment.  The binutils behavior is the least
buggy of all three causes, but inertia suggests it's the one that
should be fixed; things besides gdb might have the same problem.

Tested by using GDB on relinked mips-linux binaries, and checked in.

-- 
Daniel Jacobowitz
CodeSourcery

2007-04-17  Daniel Jacobowitz  <dan@codesourcery.com>

	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Put
	DT_MIPS_RLD_MAP before DT_DEBUG again.

Index: elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.200
diff -u -p -r1.200 elfxx-mips.c
--- elfxx-mips.c	12 Apr 2007 19:27:35 -0000	1.200
+++ elfxx-mips.c	17 Apr 2007 13:13:11 -0000
@@ -7584,19 +7584,23 @@ _bfd_mips_elf_size_dynamic_sections (bfd
       /* Add some entries to the .dynamic section.  We fill in the
 	 values later, in _bfd_mips_elf_finish_dynamic_sections, but we
 	 must add the entries now so that we get the correct size for
-	 the .dynamic section.  The DT_DEBUG entry is filled in by the
-	 dynamic linker and used by the debugger.  */
-      if (info->executable
-	  && !SGI_COMPAT (output_bfd)
-	  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
-	return FALSE;
+	 the .dynamic section.  */
 
       /* SGI object has the equivalence of DT_DEBUG in the
-	 DT_MIPS_RLD_MAP entry.  */
+	 DT_MIPS_RLD_MAP entry.  This must come first because glibc
+	 only fills in DT_MIPS_RLD_MAP (not DT_DEBUG) and GDB only
+	 looks at the first one it sees.  */
       if (!info->shared
 	  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0))
 	return FALSE;
 
+      /* The DT_DEBUG entry may be filled in by the dynamic linker and
+	 used by the debugger.  */
+      if (info->executable
+	  && !SGI_COMPAT (output_bfd)
+	  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
+	return FALSE;
+
       if (reltext && (SGI_COMPAT (output_bfd) || htab->is_vxworks))
 	info->flags |= DF_TEXTREL;
 


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