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]

Re: PATCH: Don't display bits only used for BFD in abfd->flags.


On Wed, Nov 03, 2010 at 07:46:53AM -0700, H.J. Lu wrote:
> On Wed, Nov 3, 2010 at 7:40 AM, Alan Modra <amodra@gmail.com> wrote:
> >[about orphan compressed debug sections]
> > A possible fix is to rename input sections when decompressing.
> 
> I tried it, which lead to other problems. People will run into this problem
> only if they compress debug sections.  If they do that, they should
> update their linker scripts.

The only other problems I see is the need to remove some asserts that
are no longer true.  Was there something else that bothered you?

bfd/
	* elf.c (_bfd_elf_make_section_from_shdr): Rename input sections
	when compressing or decompressing.  Don't assert name match.
	* elf64-hppa.c (get_reloc_section): Don't assert name match.
	* elfxx-ia64.c (get_reloc_section): Likewise.
binutils/
	* objcopy.c (copy_main): No need to rename sections when compressing
	or decompressing.
binutils/testsuite/
	* binutils-all/objdump.W: Adjust expected result for debug section
	rename.

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.524
diff -u -p -r1.524 elf.c
--- bfd/elf.c	29 Oct 2010 12:10:24 -0000	1.524
+++ bfd/elf.c	5 Nov 2010 03:02:50 -0000
@@ -822,11 +822,7 @@ _bfd_elf_make_section_from_shdr (bfd *ab
   const struct elf_backend_data *bed;
 
   if (hdr->bfd_section != NULL)
-    {
-      BFD_ASSERT (strcmp (name,
-			  bfd_get_section_name (abfd, hdr->bfd_section)) == 0);
-      return TRUE;
-    }
+    return TRUE;
 
   newsect = bfd_make_section_anyway (abfd, name);
   if (newsect == NULL)
@@ -1042,6 +1038,17 @@ _bfd_elf_make_section_from_shdr (bfd *ab
 		 abfd, name);
 	      return FALSE;
 	    }
+	  if (name[1] != 'z')
+	    {
+	      unsigned int len = strlen (name);
+	      char *new_name = bfd_alloc (abfd, len + 2);
+	      if (new_name == NULL)
+		return FALSE;
+	      new_name[0] = '.';
+	      new_name[1] = 'z';
+	      memcpy (new_name + 2, name + 1, len);
+	      newsect->name = new_name;
+	    }
 	  break;
 	case decompress:
 	  if (!bfd_init_section_decompress_status (abfd, newsect))
@@ -1051,6 +1058,16 @@ _bfd_elf_make_section_from_shdr (bfd *ab
 		 abfd, name);
 	      return FALSE;
 	    }
+	  if (name[1] == 'z')
+	    {
+	      unsigned int len = strlen (name);
+	      char *new_name = bfd_alloc (abfd, len);
+	      if (new_name == NULL)
+		return FALSE;
+	      new_name[0] = '.';
+	      memcpy (new_name + 1, name + 2, len - 1);
+	      newsect->name = new_name;
+	    }
 	  break;
 	}
     }
Index: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.101
diff -u -p -r1.101 elf64-hppa.c
--- bfd/elf64-hppa.c	25 Oct 2010 15:54:15 -0000	1.101
+++ bfd/elf64-hppa.c	5 Nov 2010 03:02:57 -0000
@@ -411,13 +411,6 @@ get_reloc_section (bfd *abfd,
   if (srel_name == NULL)
     return FALSE;
 
-  BFD_ASSERT ((CONST_STRNEQ (srel_name, ".rela")
-	       && strcmp (bfd_get_section_name (abfd, sec),
-			  srel_name + 5) == 0)
-	      || (CONST_STRNEQ (srel_name, ".rel")
-		  && strcmp (bfd_get_section_name (abfd, sec),
-			     srel_name + 4) == 0));
-
   dynobj = hppa_info->root.dynobj;
   if (!dynobj)
     hppa_info->root.dynobj = dynobj = abfd;
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.228
diff -u -p -r1.228 elfxx-ia64.c
--- bfd/elfxx-ia64.c	25 Oct 2010 15:54:16 -0000	1.228
+++ bfd/elfxx-ia64.c	5 Nov 2010 03:03:03 -0000
@@ -2602,13 +2602,6 @@ get_reloc_section (bfd *abfd,
   if (srel_name == NULL)
     return NULL;
 
-  BFD_ASSERT ((CONST_STRNEQ (srel_name, ".rela")
-	       && strcmp (bfd_get_section_name (abfd, sec),
-			  srel_name+5) == 0)
-	      || (CONST_STRNEQ (srel_name, ".rel")
-		  && strcmp (bfd_get_section_name (abfd, sec),
-			     srel_name+4) == 0));
-
   dynobj = ia64_info->root.dynobj;
   if (!dynobj)
     ia64_info->root.dynobj = dynobj = abfd;
Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.147
diff -u -p -r1.147 objcopy.c
--- binutils/objcopy.c	29 Oct 2010 12:10:25 -0000	1.147
+++ binutils/objcopy.c	5 Nov 2010 03:03:11 -0000
@@ -3196,7 +3196,6 @@ copy_main (int argc, char *argv[])
   struct section_list *p;
   struct stat statbuf;
   const bfd_arch_info_type *input_arch = NULL;
-  struct dwarf_debug_section *d;
 
   while ((c = getopt_long (argc, argv, "b:B:i:I:j:K:N:s:O:d:F:L:G:R:SpgxXHhVvW:w",
 			   copy_options, (int *) 0)) != EOF)
@@ -3912,22 +3911,6 @@ copy_main (int argc, char *argv[])
     fatal (_("warning: could not create temporary file whilst copying '%s', (error: %s)"),
 	   input_filename, strerror (errno));
 
-  switch (do_debug_sections)
-    {
-    case compress:
-      for (d = dwarf_debug_sections; d->uncompressed_name; d++)
-	add_section_rename (d->uncompressed_name, d->compressed_name,
-			    (flagword) -1);
-      break;
-    case decompress:
-      for (d = dwarf_debug_sections; d->uncompressed_name; d++)
-	add_section_rename (d->compressed_name, d->uncompressed_name,
-			    (flagword) -1);
-      break;
-    default:
-      break;
-    }
-
   copy_file (input_filename, tmpname, input_target, output_target, input_arch);
   if (status == 0)
     {
Index: binutils/testsuite/binutils-all/objdump.W
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/objdump.W,v
retrieving revision 1.7
diff -u -p -r1.7 objdump.W
--- binutils/testsuite/binutils-all/objdump.W	3 Sep 2010 15:54:31 -0000	1.7
+++ binutils/testsuite/binutils-all/objdump.W	5 Nov 2010 03:03:13 -0000
@@ -73,7 +73,7 @@ Raw dump of debug contents of section .d
   Extended opcode 1: End of Sequence
 
 
-Contents of the .zdebug_abbrev section:
+Contents of the .debug_abbrev section:
 
   Number TAG
    1      DW_TAG_compile_unit    \[has children\]


-- 
Alan Modra
Australia Development Lab, IBM


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