[GOLD] Skip R_*_NONE relocation entries with zero r_sym without counting

Message ID CAL-AFs1Xbha3mwc0FiDHfJ=Z-J0ftC5x-TvUBt0A_9u0vuGd+w@mail.gmail.com
State New
Headers show
Series
  • [GOLD] Skip R_*_NONE relocation entries with zero r_sym without counting
Related show

Commit Message

H.J. Lu via Binutils July 18, 2021, 6:44 a.m.
From 5b54759759a2ee7b3cbcd3641c921158db9ffe16 Mon Sep 17 00:00:00 2001
From: Michael Krasnyk <michael.krasnyk@gmail.com>

Date: Sat, 17 Jul 2021 17:35:56 +0200
Subject: [PATCH] [GOLD] PR28098 Skip R_*_NONE relocation entries with zero
 r_sym without counting

---
 gold/ChangeLog | 6 ++++++
 gold/reloc.cc  | 5 ++++-
 gold/reloc.h   | 2 +-
 3 files changed, 11 insertions(+), 2 deletions(-)

-- 
2.27.0

Comments

H.J. Lu via Binutils July 18, 2021, 12:38 p.m. | #1
On Sun, Jul 18, 2021 at 08:44:53AM +0200, Michael Krasnyk via Binutils wrote:
> + PR gold/28098

> + * reloc.cc (Track_relocs::advance): Skip R_*_NONE relocation entries

> + with r_sym of zero without counting in advance method.


Applied, thanks.

-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/gold/ChangeLog b/gold/ChangeLog
index d37902b8d24..6aba1e0e3ec 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,9 @@ 
+2021-07-17  Michael Krasnyk  <michael.krasnyk@gmail.com>
+
+ PR gold/28098
+ * reloc.cc (Track_relocs::advance): Skip R_*_NONE relocation entries
+ with r_sym of zero without counting in advance method.
+
 2021-07-03  Nick Clifton  <nickc@redhat.com>

  * po/gold.pot: Regenerate.
diff --git a/gold/reloc.cc b/gold/reloc.cc
index 34a836f4e6f..82ec6cbcc05 100644
--- a/gold/reloc.cc
+++ b/gold/reloc.cc
@@ -1602,7 +1602,10 @@  Track_relocs<size, big_endian>::advance(off_t offset)
       elfcpp::Rel<size, big_endian> rel(this->prelocs_ + this->pos_);
       if (static_cast<off_t>(rel.get_r_offset()) >= offset)
  break;
-      ++ret;
+      // Skip R_*_NONE relocation entries with r_sym of zero
+      // without counting.
+      if (rel.get_r_info() != 0)
+ ++ret;
       this->pos_ += this->reloc_size_;
     }
   return ret;
diff --git a/gold/reloc.h b/gold/reloc.h
index 5f1d382a707..773e79bdb7b 100644
--- a/gold/reloc.h
+++ b/gold/reloc.h
@@ -1171,7 +1171,7 @@  class Track_relocs
   next_addend() const;

   // Advance to OFFSET within the data section, and return the number
-  // of relocs which would be skipped.
+  // of relocs which would be skipped, excluding r_info==0 relocs.
   int
   advance(off_t offset);