Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH][gdb/testsuite] Make fission use shared_abbrev in dwarf assembler
Date: Thu, 5 Nov 2020 17:39:52 +0100	[thread overview]
Message-ID: <20201105163951.GA26325@delia> (raw)

Hi,

When using dwarf assembly to generate multiple fission CUs, each CU
gets its own abbreviation table, starting at a generated label.

That doesn't work however, the labels are silently ignored and instead
constant 0 is used.  For more details, see PRs:
- gcc PR97713 - "[gsplit-dwarf] label generated for .debug_abbrev.dwo offset,
  corresponding relocation ignored by objcopy --extract-dwo"
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97713
- binutils PR26841 - "objcopy --extract-dwo silently drops relocation"
  https://sourceware.org/bugzilla/show_bug.cgi?id=26841

Fix this by forcing shared_abbrev for fission CUs in the dwarf assembler.

Any comments?

Thanks,
- Tom

[gdb/testsuite] Make fission use shared_abbrev in dwarf assembler

gdb/testsuite/ChangeLog:

2020-11-05  Tom de Vries  <tdevries@suse.de>

	* lib/dwarf.exp (cu): Add first/last values to fission option.
	Make fission imply share_abbrev.

---
 gdb/testsuite/lib/dwarf.exp | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 40d0648826..7bb745c71d 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -1041,7 +1041,10 @@ namespace eval Dwarf {
     #                default = 4
     # addr_size n  - the size of addresses in bytes: 4, 8, or default
     #                default = default
-    # fission 0|1  - boolean indicating if generating Fission debug info
+    # fission 0|first|1|last
+    #              - non-zero indicating generation of Fission debug info.
+    #                The first and last CU in the series are marked
+    #                using first and last.
     #                default = 0
     # share_abbrev 0|first|1|last
     #              - non-zero indicating that a series of CUs shares the same
@@ -1065,6 +1068,7 @@ namespace eval Dwarf {
 	set _cu_version 4
 	set _cu_addr_size default
 	set fission 0
+	set fission_mode 0
 	set share_abbrev 0
 	set section ".debug_info"
 	set _abbrev_section ".debug_abbrev"
@@ -1075,7 +1079,12 @@ namespace eval Dwarf {
 		is_64 { set is_64 $value }
 		version { set _cu_version $value }
 		addr_size { set _cu_addr_size $value }
-		fission { set fission $value }
+		fission {
+		    if { ![string eq $value 0] } {
+			set fission 1
+			set fission_mode $value
+		    }
+		}
 		share_abbrev { set share_abbrev $value }
 		default { error "unknown option $name" }
 	    }
@@ -1097,6 +1106,17 @@ namespace eval Dwarf {
 
 	set cu_num [incr _cu_count]
 
+	# Any _abbrev_label in a .dwo file resolves to an abbrev offset of '0'
+	# (See binutils PR26841 - "objcopy --extract-dwo silently drops
+	# relocation").  So, we need to either:
+	# - count the abbrev table size for each CU and emit a constant abbrev
+	#   offset, or
+	# - have all the fission CUs share the same abbrev table
+	# We do the latter here.
+	if { $fission } {
+	    set share_abbrev $fission_mode
+	}
+
 	set init_abbrev \
 	    [expr [string equal $share_abbrev 0] \
 		 || [string equal $share_abbrev first]]
@@ -1104,8 +1124,16 @@ namespace eval Dwarf {
 	    [expr [string equal $share_abbrev 0] \
 		 || [string equal $share_abbrev last]]
 
+
 	if { $init_abbrev } {
-	    set _abbrev_label [_compute_label "abbrev${cu_num}_begin"]
+	    if { $fission } {
+		# Labels in dwo files currently don't work (see binutils
+		# PR26841), and resolve to a 0 offset.  To make that clear,
+		# use a hardcoded 0 instead of a label.
+		set _abbrev_label 0
+	    } else {
+		set _abbrev_label [_compute_label "abbrev${cu_num}_begin"]
+	    }
 	    set _abbrev_num 1
 	}
 
@@ -1125,7 +1153,7 @@ namespace eval Dwarf {
 	_op .${_cu_offset_size}byte $_abbrev_label Abbrevs
 	_op .byte $_cu_addr_size "Pointer size"
 
-	if { $init_abbrev } {
+	if { $init_abbrev && $_abbrev_label != 0 } {
 	    _defer_output $_abbrev_section {
 		define_label $_abbrev_label
 	    }

                 reply	other threads:[~2020-11-05 16:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201105163951.GA26325@delia \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox