From a46313352280d6c28ee505e0f63ade11077ef7c6 Mon Sep 17 00:00:00 2001
From: Szymon Nowicki-Korgol <myszon@fb.com>
Date: Sun, 3 Nov 2019 10:12:56 -0800
Subject: [PATCH] Set correct length of DWARF .debug_aranges section (fixes
 #17428)

---
 compiler/nativeGen/Dwarf/Types.hs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs
index 9066b3ebef7b..938611738660 100644
--- a/compiler/nativeGen/Dwarf/Types.hs
+++ b/compiler/nativeGen/Dwarf/Types.hs
@@ -230,7 +230,8 @@ pprDwarfARanges arngs unitU = sdocWithPlatform $ \plat ->
       -- entry is 8 bytes (32-bit platform) or 16 bytes (64-bit platform).
       -- pad such that first entry begins at multiple of entry size.
       pad n = vcat $ replicate n $ pprByte 0
-      initialLength = 8 + paddingSize + 2*2*wordSize
+      -- Fix for #17428
+      initialLength = 8 + paddingSize + (1 + length arngs) * 2 * wordSize
   in pprDwWord (ppr initialLength)
      $$ pprHalf 2
      $$ sectionOffset (ppr $ mkAsmTempLabel $ unitU)
-- 
GitLab