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] Add SHF_COMPRESSED support to gas and objcopy


On Thu, Apr 9, 2015 at 9:00 AM, Hans-Peter Nilsson
<hans-peter.nilsson@axis.com> wrote:
>> From: "H.J. Lu" <hongjiu.lu@intel.com>
>> Date: Mon, 6 Apr 2015 21:32:08 +0200
>
>> Any comments, suggestions or objections?
>
>> binutils/testsuite/
>>
>>         * compress.exp: Add tests for
>>         --compress-debug-sections=3D{none|zlib|zlib-gnu|zlib-gabi}.
>>         * binutils-all/dw2-3.rS: New file.
>>         * binutils-all/dw2-3.rt: Likewise.
>>         * binutils-all/libdw2-compressedgabi.out: Likewise.
>
> The new tests fail for cris-elf, cris-linux:
>
> Running /tmp/hpautotest-binutils/bsrc/src/binutils/testsuite/binutils-all/compress.exp ...
> FAIL: objcopy (objcopy compress debug sections with zlib-gabi)
>
> In binutils.log:
>
> Executing on host: /tmp/hpautotest-binutils/cris-axis-elf/binutils/objcopy --compress-debug-sections=zlib-gabi tmpdir/dw
> 2-1.o tmpdir/debug_str.copygabi.o   (timeout = 300)
> spawn /tmp/hpautotest-binutils/cris-axis-elf/binutils/objcopy --compress-debug-sections=zlib-gabi tmpdir/dw2-1.o tmpdir/debug_str.copygabi.o
> /tmp/hpautotest-binutils/cris-axis-elf/binutils/objcopy: --compress-debug-sections=[zlib|zlib-gnu|zlib-gabi] is unsupported for `a.out-cris'
> /tmp/hpautotest-binutils/cris-axis-elf/binutils/objcopy: --compress-debug-sections=[zlib|zlib-gnu|zlib-gabi] is unsupported for `a.out-cris'
>
> FAIL: objcopy (objcopy compress debug sections with zlib-gabi)
>
> There's not a.out-cris object involved; the object format is
> misinterpreted supposedly in the presence of the compressed
> debug.  (I checked the files.)
>

I checked in this patch to fix it.


-- 
H.J.
From cd6faa73f8e3b888ee8b73a733382a5587aca202 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 9 Apr 2015 10:56:28 -0700
Subject: [PATCH] Properly check --compress-debug-sections=XXX

We can't check if input is ELF in copy_file since some targets may only
set xvec after bfd_check_format_matches is called.  This patch moves
this check to copy_object.

bfd/

	* elfxx-target.h (TARGET_BIG_SYM): Add BFD_COMPRESS_GABI to
	object_flags.
	(TARGET_LITTLE_SYM): Likewise.

binutils/

	* objcopy.c (do_debug_sections): Use bit patterns.
	(copy_object): Return FALSE for compress_zlib, compress_gnu_zlib
	and compress_gabi_zlib on non-ELF input.
	(copy_file): Don't check non-ELF input here.
---
 bfd/ChangeLog      |  6 ++++++
 bfd/elfxx-target.h |  6 ++++--
 binutils/ChangeLog |  7 +++++++
 binutils/objcopy.c | 33 +++++++++++++++++++--------------
 4 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9e91490..47e5024 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elfxx-target.h (TARGET_BIG_SYM): Add BFD_COMPRESS_GABI to
+	object_flags.
+	(TARGET_LITTLE_SYM): Likewise.
+
 2015-04-09  Max Filippov  <jcmvbkbc@gmail.com>
 
 	* elf32-xtensa.c (splay-tree.h): include header.
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 5623662..0085d6c 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -835,7 +835,8 @@ const bfd_target TARGET_BIG_SYM =
 
   /* object_flags: mask of all file flags */
   (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
-   | DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS),
+   | DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS
+   | BFD_COMPRESS_GABI),
 
   /* section_flags: mask of all section flags */
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY
@@ -933,7 +934,8 @@ const bfd_target TARGET_LITTLE_SYM =
 
   /* object_flags: mask of all file flags */
   (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
-   | DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS),
+   | DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS
+   | BFD_COMPRESS_GABI),
 
   /* section_flags: mask of all section flags */
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index b2a81e5..bd2c715 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2015-04-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* objcopy.c (do_debug_sections): Use bit patterns.
+	(copy_object): Return FALSE for compress_zlib, compress_gnu_zlib
+	and compress_gabi_zlib on non-ELF input.
+	(copy_file): Don't check non-ELF input here.
+
 2015-04-09  Nick Clifton  <nickc@redhat.com>
 
 	* readelf.c (get_machine_flags): Report the setting of the string
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index a0452c9..f7fc814 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -202,12 +202,12 @@ static bfd_boolean convert_debugging = FALSE;
 /* Whether to compress/decompress DWARF debug sections.  */
 static enum
 {
-  nothing,
-  compress,
-  compress_zlib,
-  compress_gnu_zlib,
-  compress_gabi_zlib,
-  decompress
+  nothing = 0,
+  compress = 1 << 0,
+  compress_zlib = compress | 1 << 1,
+  compress_gnu_zlib = compress | 1 << 2,
+  compress_gabi_zlib = compress | 1 << 3,
+  decompress = 1 << 4
 } do_debug_sections = nothing;
 
 /* Whether to change the leading character in symbol names.  */
@@ -1664,6 +1664,15 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
       return FALSE;
     }
 
+  if ((do_debug_sections & compress) != 0
+      && do_debug_sections != compress
+      && ibfd->xvec->flavour != bfd_target_elf_flavour)
+    {
+      non_fatal (_("--compress-debug-sections=[zlib|zlib-gnu|zlib-gabi] is unsupported on `%s'"),
+		 bfd_get_archive_filename (ibfd));
+      return FALSE;
+    }
+
   if (verbose)
     printf (_("copy from `%s' [%s] to `%s' [%s]\n"),
 	    bfd_get_archive_filename (ibfd), bfd_get_target (ibfd),
@@ -2596,14 +2605,10 @@ copy_file (const char *input_filename, const char *output_filename,
     case compress_gnu_zlib:
     case compress_gabi_zlib:
       ibfd->flags |= BFD_COMPRESS;
-      if (do_debug_sections != compress)
-	{
-	  if (ibfd->xvec->flavour != bfd_target_elf_flavour)
-	    fatal (_("--compress-debug-sections=[zlib|zlib-gnu|zlib-gabi] is unsupported for `%s'"),
-		   bfd_get_target (ibfd));
-	  if (do_debug_sections == compress_gabi_zlib)
-	    ibfd->flags |= BFD_COMPRESS_GABI;
-	}
+      /* Don't check if input is ELF here since this information is
+	 only available after bfd_check_format_matches is called.  */
+      if (do_debug_sections == compress_gabi_zlib)
+	ibfd->flags |= BFD_COMPRESS_GABI;
       break;
     case decompress:
       ibfd->flags |= BFD_DECOMPRESS;
-- 
1.9.3


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