Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Jun 2017 00:31:16 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319885 - head/contrib/llvm/tools/lld/ELF
Message-ID:  <201706130031.v5D0VGZ3078005@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Tue Jun 13 00:31:16 2017
New Revision: 319885
URL: https://svnweb.freebsd.org/changeset/base/319885

Log:
  lld: ELF: Fix ICF crash on absolute symbol relocations.
  
  If two sections contained relocations to absolute symbols with the same
  value we would crash when trying to access their sections. Add a check that
  both symbols point to sections before accessing their sections, and treat
  absolute symbols as equal if their values are equal.
  
  Obtained from:	LLD commit r292578
  MFC after:	3 days

Modified:
  head/contrib/llvm/tools/lld/ELF/ICF.cpp

Modified: head/contrib/llvm/tools/lld/ELF/ICF.cpp
==============================================================================
--- head/contrib/llvm/tools/lld/ELF/ICF.cpp	Tue Jun 13 00:22:15 2017	(r319884)
+++ head/contrib/llvm/tools/lld/ELF/ICF.cpp	Tue Jun 13 00:31:16 2017	(r319885)
@@ -245,7 +245,6 @@ bool ICF<ELFT>::variableEq(const InputSection<ELFT> *A
     if (&SA == &SB)
       return true;
 
-    // Or, the two sections must be in the same equivalence class.
     auto *DA = dyn_cast<DefinedRegular<ELFT>>(&SA);
     auto *DB = dyn_cast<DefinedRegular<ELFT>>(&SB);
     if (!DA || !DB)
@@ -253,6 +252,11 @@ bool ICF<ELFT>::variableEq(const InputSection<ELFT> *A
     if (DA->Value != DB->Value)
       return false;
 
+    // Either both symbols must be absolute...
+    if (!DA->Section || !DB->Section)
+      return !DA->Section && !DB->Section;
+
+    // Or the two sections must be in the same equivalence class.
     auto *X = dyn_cast<InputSection<ELFT>>(DA->Section);
     auto *Y = dyn_cast<InputSection<ELFT>>(DB->Section);
     if (!X || !Y)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706130031.v5D0VGZ3078005>