[prev in list] [next in list] [prev in thread] [next in thread] 

List:       binutils
Subject:    [PATCH] gold: Get linkonce/comdate sections for debugging sections
From:       "H.J. Lu via Binutils" <binutils () sourceware ! org>
Date:       2020-11-25 15:11:47
Message-ID: 20201125151147.843814-1-hjl.tools () gmail ! com
[Download RAW message or body]

Sized_relobj_file::map_to_kept_section is used only for relocations in
debugging sections.  Get the section index for linkonce section and also
check the single comdat section.

	PR gold/26937
	* object.cc (Sized_relobj_file::map_to_kept_section): Get the
	section index for linkonce section.  Also check the single
	comdat section.
---
 gold/object.cc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/gold/object.cc b/gold/object.cc
index 498e58e2b0..61aed805c2 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -2998,17 +2998,20 @@ Sized_relobj_file<size, big_endian>::map_to_kept_section(
         {
 	  // The kept section is a linkonce section.
 	  if (sh_size == kept_section->linkonce_size())
-	    found = true;
+	    {
+	      kept_shndx = kept_section->shndx();
+	      found = true;
+	    }
         }
       else
 	{
+	  uint64_t kept_size = 0;
 	  if (is_comdat)
 	    {
 	      // Find the corresponding kept section.
 	      // Since we're using this mapping for relocation processing,
 	      // we don't want to match sections unless they have the same
 	      // size.
-	      uint64_t kept_size = 0;
 	      if (kept_section->find_comdat_section(section_name, &kept_shndx,
 						    &kept_size))
 		{
@@ -3016,9 +3019,8 @@ Sized_relobj_file<size, big_endian>::map_to_kept_section(
 		    found = true;
 		}
 	    }
-	  else
+	  if (!found)
 	    {
-	      uint64_t kept_size = 0;
 	      if (kept_section->find_single_comdat_section(&kept_shndx,
 							   &kept_size)
 		  && sh_size == kept_size)
-- 
2.28.0

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic