diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs
index 9066b3ebef7ba86fa0ff43b8f7559b915dab06d4..938611738660499c66021cd1fd3c29235d79e524 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)