aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-01-12 16:56:54 +0000
committerNick Clifton <nickc@redhat.com>2017-01-12 16:56:54 +0000
commit2425a30e406a0523020b7e70abb864a06a45bb97 (patch)
treed6b5cb440da8e0b7123051e3d35c0b4773e7d8ab /binutils
parent620214f742f7816e2844e1bb7f78a7a684431927 (diff)
downloadfsf-binutils-gdb-2425a30e406a0523020b7e70abb864a06a45bb97.zip
fsf-binutils-gdb-2425a30e406a0523020b7e70abb864a06a45bb97.tar.gz
fsf-binutils-gdb-2425a30e406a0523020b7e70abb864a06a45bb97.tar.bz2
Add support for locating separate debug info files via the build-id method.
PR binutils/20876 bfd * opncls.c (find_separate_debug_file): Add include_dirs parameter. Only include the directory part of the bfd's filename in search paths if include_dirs is true. Add a couple of extra locations for looking for debug files. ( bfd_follow_gnu_debuglink): Update invocation of find_separate_debug_file. (bfd_follow_gnu_debugaltlink): Likewise. (get_build_id): New function: Finds the build-id of the given bfd. (get_build_id_name): New function: Computes the name of the separate debug info file for a bfd, based upon its build-id. (check_build_id_file): New function: Checks to see if a separate debug info file exists at the given location, and that its build-id matches that of the original bfd. (bfd_follow_build_id_debuglink): New function: Finds a separate debug info file for a given bfd by using the build-id method. * dwarf2.c (_bfd_dwarf2_slurp_debug_info): Try using the build-id method of locating a separate debug info file before using the debuglink method. * bfd-in2.h: Regenerate. binutils * NEWS: Mention the new feature. * testsuite/binutils-all/objdump.exp (test_build_id_debuglink): New proc to test the location of separate debug info files using the build-id method.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog8
-rw-r--r--binutils/NEWS4
-rw-r--r--binutils/testsuite/binutils-all/objdump.exp80
3 files changed, 92 insertions, 0 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 38d033e..16e9c60 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,11 @@
+2017-01-12 Nick Clifton <nickc@redhat.com>
+
+ PR binutils/20876
+ * NEWS: Mention the new feature.
+ * testsuite/binutils-all/objdump.exp (test_build_id_debuglink):
+ New proc to test the location of separate debug info files using
+ the build-id method.
+
2017-01-10 Nick Clifton <nickc@redhat.com>
PR 21034
diff --git a/binutils/NEWS b/binutils/NEWS
index 00675f7..b425901 100644
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -1,5 +1,9 @@
-*- text -*-
+* Add support for locating separate debug info files using the build-id
+ method, where the separate file has a name based upon the build-id of
+ the original file.
+
Changes in 2.28:
* This version of binutils fixes a problem with PowerPC VLE 16A and 16D
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index 67fc8aa..c29965b 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -273,6 +273,86 @@ if { ![is_elf_format] } then {
}
}
+proc test_build_id_debuglink {} {
+ global srcdir
+ global subdir
+ global env
+ global CC_FOR_TARGET
+ global STRIP
+ global OBJCOPY
+ global OBJDUMP
+ global CFLAGS_FOR_TARGET
+
+ set test "build-id-debuglink"
+ if {![info exists CC_FOR_TARGET]} {
+ set CC_FOR_TARGET $env(CC)
+ }
+ if { $CC_FOR_TARGET == "" } {
+ unsupported $test
+ return
+ }
+
+ # Use a fixed build-id.
+ set CFLAGS_FOR_TARGET "-g -Wl,--build-id=0x12345678abcdef01"
+
+ if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog exectuable debug] != "" } {
+ fail "$test (build)"
+ return
+ }
+
+ # FIXME: Do we need to restore CFLAGS_FOR_TARGET to its old value ?
+
+ if { [binutils_run $STRIP "--strip-debug --remove-section=.comment tmpdir/testprog -o tmpdir/testprog.strip"] != "" } {
+ fail "$test (strip debug info)"
+ return
+ }
+
+ if { [binutils_run $OBJCOPY "--only-keep-debug tmpdir/testprog tmpdir/testprog.debug"] != "" } {
+ fail "$test (create separate debug info file)"
+ return
+ }
+
+ set got [remote_exec host "mkdir -p .build-id/12" ]
+ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ fail "$test (make debug directory)"
+ return
+ }
+
+ set got [remote_exec host "cp tmpdir/testprog.debug .build-id/12/345678abcdef01.debug"]
+ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ fail "$test (copy debug info into debug directory)"
+ return
+ }
+
+ set got [remote_exec host "$OBJDUMP -Sl tmpdir/testprog.strip" "" "/dev/null" "tmpdir/testprog.strip.dump"]
+ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ fail "$test (post strip dump)"
+ return
+ }
+
+ set src2 tmpdir/testprog.strip.dump
+ verbose " grep -e testprog.c ${src2}"
+ set status [remote_exec build grep "-e testprog.c ${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 (grepping for source file name in disassembly output)"
+ } else {
+ pass "$test"
+ # Cleanup...
+ set got [remote_exec host "rm .build-id/12/345678abcdef01.debug"]
+ set got [remote_exec host "rmdir -p .build-id/12" ]
+ set got [remote_exec host "rm tmpdir/testprog.strip.dump"]
+ set got [remote_exec host "rm tmpdir/testprog.debug"]
+ set got [remote_exec host "rm tmpdir/testprog.strip"]
+ }
+}
+
+if {[isnative] && [is_elf_format]} then {
+ test_build_id_debuglink
+}
# Options which are not tested: -a -d -D -R -T -x -l --stabs
# I don't see any generic way to test any of these other than -a.