]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Set BFD_DECOMPRESS to decompress debug sections
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 28 Jan 2016 21:29:53 +0000 (13:29 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 15 Mar 2016 00:39:06 +0000 (17:39 -0700)
We should set BFD_DECOMPRESS to decompress debug sections when reading in
DWARF debug sections.

Backport from master

bfd/

PR binutils/19523
* dwarf2.c (_bfd_dwarf2_slurp_debug_info): Set BFD_DECOMPRESS to
decompress debug sections.

binutils/

PR binutils/19523
* Makefile.am (check-DEJAGNU): Pass CC and CC_FOR_BUILD to
runtest.
* Makefile.in: Regenerated.
* testsuite/binutils-all/compress.exp (test_gnu_debuglink): New
proc.
Run test_gnu_debuglink for native ELF build.

bfd/ChangeLog
bfd/dwarf2.c
binutils/ChangeLog
binutils/Makefile.am
binutils/Makefile.in
binutils/testsuite/binutils-all/compress.exp

index a8beeccbdbacc347283e03b9e2118ea2ab82e052..7b2b0013d330dcc008f7352e076790bd2e61affa 100644 (file)
@@ -1,3 +1,12 @@
+2016-03-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from master
+       2016-01-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/19523
+       * dwarf2.c (_bfd_dwarf2_slurp_debug_info): Set BFD_DECOMPRESS to
+       decompress debug sections.
+
 2016-03-09  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/19579
index 176f018add29632259aad5f30e9013d6489bed33..64cfe9b9cbc773bc824225bb43f947a756be9d16 100644 (file)
@@ -3706,8 +3706,10 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd,
           fail more quickly.  */
        return FALSE;
 
+      /* Set BFD_DECOMPRESS to decompress debug sections.  */
       if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
-         || ! bfd_check_format (debug_bfd, bfd_object)
+         || !(debug_bfd->flags |= BFD_DECOMPRESS,
+              bfd_check_format (debug_bfd, bfd_object))
          || (msec = find_debug_info (debug_bfd,
                                      debug_sections, NULL)) == NULL
          || !bfd_generic_link_read_symbols (debug_bfd))
index b04c745d4a29c867a5ad927a4e17f021e67b09c6..0a8dcd8cc86df4c2867093d369a9023ebffe966b 100644 (file)
@@ -1,3 +1,16 @@
+2016-03-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from master
+       2016-01-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/19523
+       * Makefile.am (check-DEJAGNU): Pass CC and CC_FOR_BUILD to
+       runtest.
+       * Makefile.in: Regenerated.
+       * testsuite/binutils-all/compress.exp (test_gnu_debuglink): New
+       proc.
+       Run test_gnu_debuglink for native ELF build.
+
 2016-03-09  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/19775
index 17350227b33bebc634662894ee0552d3e1847cf4..4f618cee5ab1a5a2dc2c1c6e2354750c428e11fb 100644 (file)
@@ -192,6 +192,7 @@ check-DEJAGNU: site.exp
        EXPECT=$(EXPECT); export EXPECT; \
        runtest=$(RUNTEST); \
        if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+         CC="$(CC)" CC_FOR_BUILD="$(CC_FOR_BUILD)" \
          CC_FOR_TARGET="$(CC_FOR_TARGET)" CFLAGS_FOR_TARGET="$(CFLAGS)" \
                $$runtest --tool $(DEJATOOL) --srcdir $${srcdir}/testsuite \
                        $(RUNTESTFLAGS); \
index 5642925a8485ee85b73b1bfe3850e40e93095e69..eddd6175e83a68355854e4b28b309c26c676592d 100644 (file)
@@ -1290,6 +1290,7 @@ check-DEJAGNU: site.exp
        EXPECT=$(EXPECT); export EXPECT; \
        runtest=$(RUNTEST); \
        if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+         CC="$(CC)" CC_FOR_BUILD="$(CC_FOR_BUILD)" \
          CC_FOR_TARGET="$(CC_FOR_TARGET)" CFLAGS_FOR_TARGET="$(CFLAGS)" \
                $$runtest --tool $(DEJATOOL) --srcdir $${srcdir}/testsuite \
                        $(RUNTESTFLAGS); \
index 4dac503c782f8d0af1d6a56949cb6cc69c4f6485..ac24812955c5db64cb7f7803c52320b34a5eda5b 100644 (file)
@@ -667,4 +667,97 @@ if { ([istarget "x86_64-*-elf*"]
 
     set testname "Convert x32 object to x86-64 (3)"
     convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gnu"
- }
+}
+
+proc test_gnu_debuglink {} {
+    global srcdir
+    global subdir
+    global env
+    global CC_FOR_TARGET
+    global STRIP
+    global OBJCOPY
+    global OBJDUMP
+
+    set test "gnu-debuglink"
+    if {![info exists CC_FOR_TARGET]} {
+       set CC_FOR_TARGET $env(CC)
+    }
+    if { $CC_FOR_TARGET == "" } {
+       unsupported $test
+       return
+    }
+
+    if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog exectuable debug] != "" } {
+       fail "$test (build)"
+       return
+    }
+    set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.dump"]
+    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+       fail "$test (objcopy dump)"
+       return
+    }
+    if { [binutils_run $STRIP "--strip-debug --remove-section=.comment --remove-section=.note tmpdir/testprog -o tmpdir/testprog.strip"] != "" } {
+       fail "$test (strip)"
+       return
+    }
+    if { [binutils_run $OBJCOPY "--only-keep-debug --decompress-debug-sections tmpdir/testprog tmpdir/testprog.decompress"] != "" } {
+       fail "$test (objcopy decompress)"
+       return
+    }
+    if { [binutils_run $OBJCOPY "--only-keep-debug --compress-debug-sections tmpdir/testprog tmpdir/testprog.compress"] != "" } {
+       fail "$test (objcopy compress)"
+       return
+    }
+    if { [binutils_run $OBJCOPY "--add-gnu-debuglink=tmpdir/testprog.decompress tmpdir/testprog.strip tmpdir/testprog"] != "" } {
+       fail "$test (objcopy link decompress)"
+       return
+    }
+    set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.decompress.dump"]
+    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+       fail "$test (objcopy dump decompress)"
+       return
+    }
+    if { [binutils_run $OBJCOPY "--add-gnu-debuglink=tmpdir/testprog.compress tmpdir/testprog.strip tmpdir/testprog"] != "" } {
+       fail "$test (objcopy link compress)"
+       return
+    }
+    set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.compress.dump"]
+    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+       fail "$test (objcopy dump compress)"
+       return
+    }
+
+    set src1 tmpdir/testprog.dump
+    set src2 tmpdir/testprog.compress.dump
+    send_log "cmp ${src1} ${src2}\n"
+    verbose "cmp ${src1} ${src2}"
+    set status [remote_exec build cmp "${src1} ${src2}"]
+    set exec_output [lindex $status 1]
+    set exec_output [prune_warnings $exec_output]
+    if ![string match "" $exec_output] then {
+       send_log "$exec_output\n"
+       verbose "$exec_output" 1
+       fail "$test (objdump 1)"
+    } else {
+       pass "$test (objdump 1)"
+    }
+
+    set src1 tmpdir/testprog.decompress.dump
+    set src2 tmpdir/testprog.compress.dump
+    send_log "cmp ${src1} ${src2}\n"
+    verbose "cmp ${src1} ${src2}"
+    set status [remote_exec build cmp "${src1} ${src2}"]
+    set exec_output [lindex $status 1]
+    set exec_output [prune_warnings $exec_output]
+    if ![string match "" $exec_output] then {
+       send_log "$exec_output\n"
+       verbose "$exec_output" 1
+       fail "$test (objdump 2)"
+    } else {
+       pass "$test (objdump 2)"
+    }
+}
+
+if {[isnative] && [is_elf_format]} then {
+    test_gnu_debuglink
+}