diff --git a/SOURCES/dwz-rh1949185.patch b/SOURCES/dwz-rh1949185.patch
new file mode 100644
index 0000000..4af623a
--- /dev/null
+++ b/SOURCES/dwz-rh1949185.patch
@@ -0,0 +1,44 @@
+X-Git-Url: https://sourceware.org/git/?p=dwz.git;a=blobdiff_plain;f=dwz.c;h=9e39824d0f1fec950c811357c62e6a0caa1880d7;hp=6f34a0c7f84d00aa74750ea7d60c882967d252c0;hb=4a89e2c78e57b1b05ff71a8e32b2219e02d30425;hpb=815ac613209fa8cbcdda57302a0a1ab0366923ad
+
+diff --git a/dwz.c b/dwz.c
+index 6f34a0c..9e39824 100644
+--- a/dwz.c
++++ b/dwz.c
+@@ -2357,10 +2357,33 @@ checksum_die (DSO *dso, dw_cu_ref cu, dw_die_ref top_die, dw_die_ref die)
+ 		}
+ 	      if (unlikely (op_multifile) && ref->die_collapsed_child)
+ 		ref = ref->die_parent;
+-	      assert (((!op_multifile && !rd_multifile && !fi_multifile)
+-		       || cu != die_cu (ref))
+-		      && (!op_multifile
+-			  || cu->cu_chunk == die_cu (ref)->cu_chunk));
++	      if (cu == die_cu (ref))
++		{
++		  /* The reference was encoded using a section-relative
++		     encoding, while if it could have been encoded using
++		     CU-relative encoding.  Typically, the latter is used,
++		     because:
++		     - it's potentially smaller, and
++		     - it doesn't require a link-time relocation.  */
++
++		  /* Assert that the multifile only contains section-relative
++		     encoding when necessary.  */
++		  assert (!op_multifile && !rd_multifile);
++
++		  if (fi_multifile)
++		    {
++		      /* It's possible that the input DWARF contains this
++			 sub-optimal reference.  We currently don't optimize
++			 this during single-file optimization, so it will still
++			 be there during finalize_multifile.  Bail out to handle
++			 this conservatively.  */
++		      die->die_ck_state = CK_BAD;
++		      return 0;
++		    }
++		}
++	      /* Assert that during op_multifile, die belongs to the same object
++		 as ref.  */
++	      assert (!op_multifile || cu->cu_chunk == die_cu (ref)->cu_chunk);
+ 	      handled = true;
+ 	      break;
+ 	    }
diff --git a/SPECS/dwz.spec b/SPECS/dwz.spec
index 880021e..ceade37 100644
--- a/SPECS/dwz.spec
+++ b/SPECS/dwz.spec
@@ -1,7 +1,7 @@
 Summary: DWARF optimization and duplicate removal tool
 Name: dwz
 Version: 0.12
-Release: 9%{?dist}
+Release: 10%{?dist}
 License: GPLv2+ and GPLv3+
 Group: Development/Tools
 # git archive --format=tar --remote=git://sourceware.org/git/dwz.git \
@@ -10,6 +10,8 @@ Group: Development/Tools
 Source: %{name}-%{version}.tar.bz2
 BuildRequires: gcc, elfutils-libelf-devel
 
+Patch1: dwz-rh1949185.patch
+
 %description
 The dwz package contains a program that attempts to optimize DWARF
 debugging information contained in ELF shared libraries and ELF executables
@@ -21,6 +23,7 @@ and using DW_TAG_imported_unit to import it into each CU that needs it.
 
 %prep
 %setup -q
+%patch1 -p1 -b .rh1949185~
 
 %build
 make %{?_smp_mflags} CFLAGS='%{optflags}' LDFLAGS='%{build_ldflags}' \
@@ -37,6 +40,9 @@ make DESTDIR=%{buildroot} prefix=%{_prefix} mandir=%{_mandir} bindir=%{_bindir} 
 %{_mandir}/man1/dwz.1*
 
 %changelog
+* Wed May  5 2021 Marek Polacek <polacek@redhat.com> 0.12-10
+- handle intra-CU DW_FORM_ref_addr reference (#1949185)
+
 * Tue Aug  7 2018 Marek Polacek <polacek@redhat.com> 0.12-9
 - don't use arched BuildRequires (#1545773)
 - remove %defattr