public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Recognize -1 as a tombstone value in .debug_line
@ 2020-07-01 19:50 Fangrui Song
  0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2020-07-01 19:50 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a8caed5d7faa639a1e6769eba551d15d8ddd9510

commit a8caed5d7faa639a1e6769eba551d15d8ddd9510
Author: Fangrui Song <maskray@google.com>
Date:   Wed Jul 1 12:31:44 2020 -0700

    Recognize -1 as a tombstone value in .debug_line
    
    LLD from 11 onwards (https://reviews.llvm.org/D81784) uses -1 to
    represent a relocation in .debug_line referencing a discarded symbol.
    Recognize -1 to fix gdb.base/break-on-linker-gcd-function.exp when the
    linker is a newer LLD.
    
    gdb/ChangeLog:
    
            * dwarf2/read.c (lnp_state_machine::check_line_address): Test -1.

Diff:
---
 gdb/ChangeLog     |  4 ++++
 gdb/dwarf2/read.c | 13 +++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 404ee406678..007798135e5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2020-07-01  Fangrui Song  <maskray@google.com>
+
+	* dwarf2/read.c (lnp_state_machine::check_line_address): Test -1.
+
 2020-07-01  Alok Kumar Sharma  <AlokKumar.Sharma@amd.com>
 
 	* dwarf2/read.c (set_die_type): Removed conditions to restrict
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 4622d14a05c..405b5fb3348 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -19983,7 +19983,7 @@ public:
      we're processing the end of a sequence.  */
   void record_line (bool end_sequence);
 
-  /* Check ADDRESS is zero and less than UNRELOCATED_LOWPC and if true
+  /* Check ADDRESS is -1, or zero and less than UNRELOCATED_LOWPC, and if true
      nop-out rest of the lines in this sequence.  */
   void check_line_address (struct dwarf2_cu *cu,
 			   const gdb_byte *line_ptr,
@@ -20377,12 +20377,13 @@ lnp_state_machine::check_line_address (struct dwarf2_cu *cu,
 				       const gdb_byte *line_ptr,
 				       CORE_ADDR unrelocated_lowpc, CORE_ADDR address)
 {
-  /* If ADDRESS < UNRELOCATED_LOWPC then it's not a usable value, it's outside
-     the pc range of the CU.  However, we restrict the test to only ADDRESS
-     values of zero to preserve GDB's previous behaviour which is to handle
-     the specific case of a function being GC'd by the linker.  */
+  /* Linkers resolve a symbolic relocation referencing a GC'd function to 0 or
+     -1.  If ADDRESS is 0, ignoring the opcode will err if the text section is
+     located at 0x0.  In this case, additionally check that if
+     ADDRESS < UNRELOCATED_LOWPC.  */
 
-  if (address == 0 && address < unrelocated_lowpc)
+  if ((address == 0 && address < unrelocated_lowpc)
+      || address == (CORE_ADDR) -1)
     {
       /* This line table is for a function which has been
 	 GCd by the linker.  Ignore it.  PR gdb/12528 */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-01 19:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01 19:50 [binutils-gdb] Recognize -1 as a tombstone value in .debug_line Fangrui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).