public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug gold/28098] R_*_NONE entries in rela.eh_frame cause an empty eh_frame_hdr section
@ 2021-07-18  6:10 Michael Krasnyk
  0 siblings, 0 replies; only message in thread
From: Michael Krasnyk @ 2021-07-18  6:10 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]

Hi,

please consider a patch that fixes generation empty .eh_frame_hdr sections
linking with libraries that have R_*_NONE relocation entries with zero
r_sym in rela.eh_frame sections.

Result values of Reloc::advance are used at five places
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gold/ehframe.cc;h=8a19b21055924ae17c40f9f7c2ac4e421bf58392;hb=HEAD#l665
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gold/ehframe.cc;h=8a19b21055924ae17c40f9f7c2ac4e421bf58392;hb=HEAD#l688
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gold/ehframe.cc;h=8a19b21055924ae17c40f9f7c2ac4e421bf58392;hb=HEAD#l889
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gold/ehframe.cc;h=8a19b21055924ae17c40f9f7c2ac4e421bf58392;hb=HEAD#l922
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gold/ehframe.cc;h=8a19b21055924ae17c40f9f7c2ac4e421bf58392;hb=HEAD#l1018

 for early termination of do_add_ehframe_input_section and at one place
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gold/ehframe.cc;h=8a19b21055924ae17c40f9f7c2ac4e421bf58392;hb=HEAD#l919
in an assertion, so this change should not change behavior but prevent
earlier termination if the relocation section has an entry with r_info = 0.

Related issue https://sourceware.org/bugzilla/show_bug.cgi?id=28098

Kind regards,
Michael Krasnyk

[-- Attachment #2: 0001-GOLD-PR28098-Skip-R_-_NONE-relocation-entries-with-z.patch --]
[-- Type: text/x-patch, Size: 1764 bytes --]

From 5b54759759a2ee7b3cbcd3641c921158db9ffe16 Mon Sep 17 00:00:00 2001
From: Michael Krasnyk <mkrasnyk@argo.ai>
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(-)

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);
 
-- 
2.27.0


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

only message in thread, other threads:[~2021-07-18  6:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-18  6:10 [Bug gold/28098] R_*_NONE entries in rela.eh_frame cause an empty eh_frame_hdr section Michael Krasnyk

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).