77c4286
diff -rup binutils.orig/bfd/bfd.c binutils-2.31.1/bfd/bfd.c
77c4286
--- binutils.orig/bfd/bfd.c	2019-02-18 11:53:32.155652114 +0000
77c4286
+++ binutils-2.31.1/bfd/bfd.c	2019-02-18 12:03:21.591459682 +0000
77c4286
@@ -2332,6 +2332,8 @@ bfd_update_compression_header (bfd *abfd
77c4286
 		  bfd_put_32 (abfd, sec->size, &echdr->ch_size);
77c4286
 		  bfd_put_32 (abfd, 1 << sec->alignment_power,
77c4286
 			      &echdr->ch_addralign);
77c4286
+		  /* bfd_log2 (alignof (Elf32_Chdr)).  */
77c4286
+		  bfd_set_section_alignment (abfd, sec, 2);
77c4286
 		}
77c4286
 	      else
77c4286
 		{
77c4286
@@ -2342,6 +2344,8 @@ bfd_update_compression_header (bfd *abfd
77c4286
 		  bfd_put_64 (abfd, sec->size, &echdr->ch_size);
77c4286
 		  bfd_put_64 (abfd, 1 << sec->alignment_power,
77c4286
 			      &echdr->ch_addralign);
77c4286
+		  /* bfd_log2 (alignof (Elf64_Chdr)).  */
77c4286
+		  bfd_set_section_alignment (abfd, sec, 3);
77c4286
 		}
77c4286
 	    }
77c4286
 	  else
77c4286
@@ -2354,6 +2358,8 @@ bfd_update_compression_header (bfd *abfd
77c4286
 		 order.  */
77c4286
 	      memcpy (contents, "ZLIB", 4);
77c4286
 	      bfd_putb64 (sec->size, contents + 4);
77c4286
+	      /* No way to keep the original alignment, just use 1 always.  */
77c4286
+	      bfd_set_section_alignment (abfd, sec, 0);
77c4286
 	    }
77c4286
 	}
77c4286
     }
77c4286
@@ -2368,12 +2374,15 @@ bfd_update_compression_header (bfd *abfd
77c4286
    SYNOPSIS
77c4286
 	bfd_boolean bfd_check_compression_header
77c4286
 	  (bfd *abfd, bfd_byte *contents, asection *sec,
77c4286
-	  bfd_size_type *uncompressed_size);
77c4286
+          bfd_size_type *uncompressed_size,
77c4286
+          unsigned int *uncompressed_alignment_power);
77c4286
+
77c4286
 
77c4286
 DESCRIPTION
77c4286
 	Check the compression header at CONTENTS of SEC in ABFD and
77c4286
-	store the uncompressed size in UNCOMPRESSED_SIZE if the
77c4286
-	compression header is valid.
77c4286
+        store the uncompressed size in UNCOMPRESSED_SIZE and the
77c4286
+        uncompressed data alignment in UNCOMPRESSED_ALIGNMENT_POWER
77c4286
+        if the compression header is valid.
77c4286
 
77c4286
 RETURNS
77c4286
 	Return TRUE if the compression header is valid.
77c4286
@@ -2382,7 +2391,8 @@ RETURNS
77c4286
 bfd_boolean
77c4286
 bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
77c4286
 			      asection *sec,
77c4286
-			      bfd_size_type *uncompressed_size)
77c4286
+			      bfd_size_type *uncompressed_size,
77c4286
+			      unsigned int *uncompressed_alignment_power)
77c4286
 {
77c4286
   if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
77c4286
       && (elf_section_flags (sec) & SHF_COMPRESSED) != 0)
77c4286
@@ -2404,9 +2414,10 @@ bfd_check_compression_header (bfd *abfd,
77c4286
 	  chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign);
77c4286
 	}
77c4286
       if (chdr.ch_type == ELFCOMPRESS_ZLIB
77c4286
-	  && chdr.ch_addralign == 1U << sec->alignment_power)
77c4286
+	  && chdr.ch_addralign == (1U << bfd_log2 (chdr.ch_addralign)))
77c4286
 	{
77c4286
 	  *uncompressed_size = chdr.ch_size;
77c4286
+	  *uncompressed_alignment_power = bfd_log2 (chdr.ch_addralign);
77c4286
 	  return TRUE;
77c4286
 	}
77c4286
     }
77c4286
diff -rup binutils.orig/bfd/bfd-in2.h binutils-2.31.1/bfd/bfd-in2.h
77c4286
--- binutils.orig/bfd/bfd-in2.h	2019-02-18 11:53:32.156652107 +0000
77c4286
+++ binutils-2.31.1/bfd/bfd-in2.h	2019-02-18 12:00:23.849723903 +0000
77c4286
@@ -7274,7 +7274,8 @@ void bfd_update_compression_header
77c4286
 
77c4286
 bfd_boolean bfd_check_compression_header
77c4286
    (bfd *abfd, bfd_byte *contents, asection *sec,
77c4286
-    bfd_size_type *uncompressed_size);
77c4286
+    bfd_size_type *uncompressed_size,
77c4286
+    unsigned int *uncompressed_alignment_power);
77c4286
 
77c4286
 int bfd_get_compression_header_size (bfd *abfd, asection *sec);
77c4286
 
77c4286
@@ -7850,7 +7851,8 @@ void bfd_cache_section_contents
77c4286
 bfd_boolean bfd_is_section_compressed_with_header
77c4286
    (bfd *abfd, asection *section,
77c4286
     int *compression_header_size_p,
77c4286
-    bfd_size_type *uncompressed_size_p);
77c4286
+    bfd_size_type *uncompressed_size_p,
77c4286
+    unsigned int *uncompressed_alignment_power_p);
77c4286
 
77c4286
 bfd_boolean bfd_is_section_compressed
77c4286
    (bfd *abfd, asection *section);
77c4286
diff -rup binutils.orig/bfd/compress.c binutils-2.31.1/bfd/compress.c
77c4286
--- binutils.orig/bfd/compress.c	2019-02-18 11:53:32.153652128 +0000
77c4286
+++ binutils-2.31.1/bfd/compress.c	2019-02-18 12:11:44.899886376 +0000
77c4286
@@ -84,11 +84,13 @@ bfd_compress_section_contents (bfd *abfd
77c4286
   int zlib_size = 0;
77c4286
   int orig_compression_header_size;
77c4286
   bfd_size_type orig_uncompressed_size;
77c4286
+  unsigned int orig_uncompressed_alignment_pow;
77c4286
   int header_size = bfd_get_compression_header_size (abfd, NULL);
77c4286
   bfd_boolean compressed
77c4286
     = bfd_is_section_compressed_with_header (abfd, sec,
77c4286
 					     &orig_compression_header_size,
77c4286
-					     &orig_uncompressed_size);
77c4286
+					     &orig_uncompressed_size,
77c4286
+					     &orig_uncompressed_alignment_pow);
77c4286
 
77c4286
   /* Either ELF compression header or the 12-byte, "ZLIB" + 8-byte size,
77c4286
      overhead in .zdebug* section.  */
77c4286
@@ -153,6 +155,8 @@ bfd_compress_section_contents (bfd *abfd
77c4286
 	      return 0;
77c4286
 	    }
77c4286
 	  free (uncompressed_buffer);
77c4286
+	  bfd_set_section_alignment (abfd, sec,
77c4286
+				     orig_uncompressed_alignment_pow);
77c4286
 	  sec->contents = buffer;
77c4286
 	  sec->compress_status = COMPRESS_SECTION_DONE;
77c4286
 	  return orig_uncompressed_size;
77c4286
@@ -364,20 +368,25 @@ SYNOPSIS
77c4286
 	bfd_boolean bfd_is_section_compressed_with_header
77c4286
 	  (bfd *abfd, asection *section,
77c4286
 	  int *compression_header_size_p,
77c4286
-	  bfd_size_type *uncompressed_size_p);
77c4286
+	  bfd_size_type *uncompressed_size_p,
77c4286
+	  unsigned int *uncompressed_alignment_power_p);
77c4286
+
77c4286
 
77c4286
 DESCRIPTION
77c4286
 	Return @code{TRUE} if @var{section} is compressed.  Compression
77c4286
-	header size is returned in @var{compression_header_size_p} and
77c4286
-	uncompressed size is returned in @var{uncompressed_size_p}.  If
77c4286
-	compression is unsupported, compression header size is returned
77c4286
-	with -1 and uncompressed size is returned with 0.
77c4286
+	header size is returned in @var{compression_header_size_p},
77c4286
+        uncompressed size is returned in @var{uncompressed_size_p}
77c4286
+        and the uncompressed data alignement power is returned in
77c4286
+        @var{uncompressed_align_pow_p}.  If compression is
77c4286
+        unsupported, compression header size is returned with -1
77c4286
+        and uncompressed size is returned with 0.
77c4286
 */
77c4286
 
77c4286
 bfd_boolean
77c4286
 bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec,
77c4286
 				       int *compression_header_size_p,
77c4286
-				       bfd_size_type *uncompressed_size_p)
77c4286
+				       bfd_size_type *uncompressed_size_p,
77c4286
+				       unsigned int *uncompressed_align_pow_p)
77c4286
 {
77c4286
   bfd_byte header[MAX_COMPRESSION_HEADER_SIZE];
77c4286
   int compression_header_size;
77c4286
@@ -385,6 +394,8 @@ bfd_is_section_compressed_with_header (b
77c4286
   unsigned int saved = sec->compress_status;
77c4286
   bfd_boolean compressed;
77c4286
 
77c4286
+  *uncompressed_align_pow_p = 0;
77c4286
+
77c4286
   compression_header_size = bfd_get_compression_header_size (abfd, sec);
77c4286
   if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE)
77c4286
     abort ();
77c4286
@@ -412,7 +423,8 @@ bfd_is_section_compressed_with_header (b
77c4286
       if (compression_header_size != 0)
77c4286
 	{
77c4286
 	  if (!bfd_check_compression_header (abfd, header, sec,
77c4286
-					     uncompressed_size_p))
77c4286
+					     uncompressed_size_p,
77c4286
+					     uncompressed_align_pow_p))
77c4286
 	    compression_header_size = -1;
77c4286
 	}
77c4286
       /* Check for the pathalogical case of a debug string section that
77c4286
@@ -449,9 +461,11 @@ bfd_is_section_compressed (bfd *abfd, se
77c4286
 {
77c4286
   int compression_header_size;
77c4286
   bfd_size_type uncompressed_size;
77c4286
+  unsigned int uncompressed_align_power;
77c4286
   return (bfd_is_section_compressed_with_header (abfd, sec,
77c4286
 						 &compression_header_size,
77c4286
-						 &uncompressed_size)
77c4286
+						 &uncompressed_size,
77c4286
+						 &uncompressed_align_power)
77c4286
 	  && compression_header_size >= 0
77c4286
 	  && uncompressed_size > 0);
77c4286
 }
77c4286
@@ -480,6 +494,7 @@ bfd_init_section_decompress_status (bfd
77c4286
   int compression_header_size;
77c4286
   int header_size;
77c4286
   bfd_size_type uncompressed_size;
77c4286
+  unsigned int uncompressed_alignment_power = 0;
77c4286
 
77c4286
   compression_header_size = bfd_get_compression_header_size (abfd, sec);
77c4286
   if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE)
77c4286
@@ -508,7 +523,8 @@ bfd_init_section_decompress_status (bfd
77c4286
       uncompressed_size = bfd_getb64 (header + 4);
77c4286
     }
77c4286
   else if (!bfd_check_compression_header (abfd, header, sec,
77c4286
-					 &uncompressed_size))
77c4286
+					  &uncompressed_size,
77c4286
+					  &uncompressed_alignment_power))
77c4286
     {
77c4286
       bfd_set_error (bfd_error_wrong_format);
77c4286
       return FALSE;
77c4286
@@ -516,6 +532,7 @@ bfd_init_section_decompress_status (bfd
77c4286
 
77c4286
   sec->compressed_size = sec->size;
77c4286
   sec->size = uncompressed_size;
77c4286
+  bfd_set_section_alignment (abfd, sec, uncompressed_alignment_power);
77c4286
   sec->compress_status = DECOMPRESS_SECTION_SIZED;
77c4286
 
77c4286
   return TRUE;
77c4286
diff -rup binutils.orig/bfd/elf.c binutils-2.31.1/bfd/elf.c
77c4286
--- binutils.orig/bfd/elf.c	2019-02-18 11:53:32.161652071 +0000
77c4286
+++ binutils-2.31.1/bfd/elf.c	2019-02-18 12:08:52.135108638 +0000
77c4286
@@ -1177,10 +1177,12 @@ _bfd_elf_make_section_from_shdr (bfd *ab
77c4286
       enum { nothing, compress, decompress } action = nothing;
77c4286
       int compression_header_size;
77c4286
       bfd_size_type uncompressed_size;
77c4286
+      unsigned int uncompressed_align_power;
77c4286
       bfd_boolean compressed
77c4286
 	= bfd_is_section_compressed_with_header (abfd, newsect,
77c4286
 						 &compression_header_size,
77c4286
-						 &uncompressed_size);
77c4286
+						 &uncompressed_size,
77c4286
+						 &uncompressed_align_power);
77c4286
 
77c4286
       if (compressed)
77c4286
 	{
77c4286
diff -rup binutils.orig/binutils/readelf.c binutils-2.31.1/binutils/readelf.c
77c4286
--- binutils.orig/binutils/readelf.c	2019-02-18 11:53:32.947646480 +0000
77c4286
+++ binutils-2.31.1/binutils/readelf.c	2019-02-18 12:10:13.142535034 +0000
77c4286
@@ -13366,12 +13366,6 @@ dump_section_as_strings (Elf_Internal_Sh
77c4286
 		    printable_section_name (filedata, section), chdr.ch_type);
77c4286
 	      return FALSE;
77c4286
 	    }
77c4286
-	  else if (chdr.ch_addralign != section->sh_addralign)
77c4286
-	    {
77c4286
-	      warn (_("compressed section '%s' is corrupted\n"),
77c4286
-		    printable_section_name (filedata, section));
77c4286
-	      return FALSE;
77c4286
-	    }
77c4286
 	  uncompressed_size = chdr.ch_size;
77c4286
 	  start += compression_header_size;
77c4286
 	  new_size -= compression_header_size;
77c4286
@@ -13513,12 +13507,6 @@ dump_section_as_bytes (Elf_Internal_Shdr
77c4286
 		    printable_section_name (filedata, section), chdr.ch_type);
77c4286
 	      return FALSE;
77c4286
 	    }
77c4286
-	  else if (chdr.ch_addralign != section->sh_addralign)
77c4286
-	    {
77c4286
-	      warn (_("compressed section '%s' is corrupted\n"),
77c4286
-		    printable_section_name (filedata, section));
77c4286
-	      return FALSE;
77c4286
-	    }
77c4286
 	  uncompressed_size = chdr.ch_size;
77c4286
 	  start += compression_header_size;
77c4286
 	  new_size -= compression_header_size;
77c4286
@@ -13688,12 +13676,6 @@ load_specific_debug_section (enum dwarf_
77c4286
 		    section->name, chdr.ch_type);
77c4286
 	      return FALSE;
77c4286
 	    }
77c4286
-	  else if (chdr.ch_addralign != sec->sh_addralign)
77c4286
-	    {
77c4286
-	      warn (_("compressed section '%s' is corrupted\n"),
77c4286
-		    section->name);
77c4286
-	      return FALSE;
77c4286
-	    }
77c4286
 	  uncompressed_size = chdr.ch_size;
77c4286
 	  start += compression_header_size;
77c4286
 	  size -= compression_header_size;
77c4286
diff -rup binutils.orig/binutils/testsuite/binutils-all/dw2-3.rS binutils-2.31.1/binutils/testsuite/binutils-all/dw2-3.rS
77c4286
--- binutils.orig/binutils/testsuite/binutils-all/dw2-3.rS	2019-02-18 11:53:32.908646758 +0000
77c4286
+++ binutils-2.31.1/binutils/testsuite/binutils-all/dw2-3.rS	2019-02-18 12:10:40.884338917 +0000
77c4286
@@ -1,3 +1,3 @@
77c4286
 #...
77c4286
- +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +1
77c4286
+ +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +(4|8)
77c4286
 #pass
77c4286
diff -rup binutils.orig/binutils/testsuite/binutils-all/dw2-3.rt binutils-2.31.1/binutils/testsuite/binutils-all/dw2-3.rt
77c4286
--- binutils.orig/binutils/testsuite/binutils-all/dw2-3.rt	2019-02-18 11:53:32.905646779 +0000
77c4286
+++ binutils-2.31.1/binutils/testsuite/binutils-all/dw2-3.rt	2019-02-18 12:11:13.476108521 +0000
77c4286
@@ -1,6 +1,6 @@
77c4286
 #...
77c4286
  +\[[ 0-9]+\] .debug_info
77c4286
- +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +1
77c4286
+ +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +(4|8)
77c4286
  +\[0+800\]: COMPRESSED
77c4286
  +ZLIB, 0+9d, 1
77c4286
 #pass
77c4286
diff -rup binutils.orig/gold/merge.cc binutils-2.31.1/gold/merge.cc
77c4286
--- binutils.orig/gold/merge.cc	2019-02-18 11:53:32.210651723 +0000
77c4286
+++ binutils-2.31.1/gold/merge.cc	2019-02-18 12:12:59.027362334 +0000
77c4286
@@ -440,9 +440,11 @@ Output_merge_string<Char_type>::do_add_i
77c4286
 {
77c4286
   section_size_type sec_len;
77c4286
   bool is_new;
77c4286
+  uint64_t addralign = this->addralign();
77c4286
   const unsigned char* pdata = object->decompressed_section_contents(shndx,
77c4286
 								     &sec_len,
77c4286
-								     &is_new);
77c4286
+								     &is_new,
77c4286
+								     &addralign);
77c4286
 
77c4286
   const Char_type* p = reinterpret_cast<const Char_type*>(pdata);
77c4286
   const Char_type* pend = p + sec_len / sizeof(Char_type);
77c4286
@@ -494,7 +496,7 @@ Output_merge_string<Char_type>::do_add_i
77c4286
   // aligned, so each string within the section must retain the same
77c4286
   // modulo.
77c4286
   uintptr_t init_align_modulo = (reinterpret_cast<uintptr_t>(pdata)
77c4286
-				 & (this->addralign() - 1));
77c4286
+				 & (addralign - 1));
77c4286
   bool has_misaligned_strings = false;
77c4286
 
77c4286
   while (p < pend)
77c4286
@@ -503,7 +505,7 @@ Output_merge_string<Char_type>::do_add_i
77c4286
 
77c4286
       // Within merge input section each string must be aligned.
77c4286
       if (len != 0
77c4286
-	  && ((reinterpret_cast<uintptr_t>(p) & (this->addralign() - 1))
77c4286
+	  && ((reinterpret_cast<uintptr_t>(p) & (addralign - 1))
77c4286
 	      != init_align_modulo))
77c4286
 	  has_misaligned_strings = true;
77c4286
 
77c4286
diff -rup binutils.orig/gold/object.cc binutils-2.31.1/gold/object.cc
77c4286
--- binutils.orig/gold/object.cc	2019-02-18 11:53:32.208651737 +0000
77c4286
+++ binutils-2.31.1/gold/object.cc	2019-02-18 12:16:35.938828914 +0000
77c4286
@@ -751,11 +751,13 @@ build_compressed_section_map(
77c4286
 	      const unsigned char* contents =
77c4286
 		  obj->section_contents(i, &len, false);
77c4286
 	      uint64_t uncompressed_size;
77c4286
+	      Compressed_section_info info;
77c4286
 	      if (is_zcompressed)
77c4286
 		{
77c4286
 		  // Skip over the ".zdebug" prefix.
77c4286
 		  name += 7;
77c4286
 		  uncompressed_size = get_uncompressed_size(contents, len);
77c4286
+		  info.addralign = shdr.get_sh_addralign();
77c4286
 		}
77c4286
 	      else
77c4286
 		{
77c4286
@@ -763,8 +765,8 @@ build_compressed_section_map(
77c4286
 		  name += 6;
77c4286
 		  elfcpp::Chdr<size, big_endian> chdr(contents);
77c4286
 		  uncompressed_size = chdr.get_ch_size();
77c4286
+		  info.addralign = chdr.get_ch_addralign();
77c4286
 		}
77c4286
-	      Compressed_section_info info;
77c4286
 	      info.size = convert_to_section_size_type(uncompressed_size);
77c4286
 	      info.flag = shdr.get_sh_flags();
77c4286
 	      info.contents = NULL;
77c4286
@@ -3060,7 +3062,8 @@ const unsigned char*
77c4286
 Object::decompressed_section_contents(
77c4286
     unsigned int shndx,
77c4286
     section_size_type* plen,
77c4286
-    bool* is_new)
77c4286
+    bool* is_new,
77c4286
+    uint64_t* palign)
77c4286
 {
77c4286
   section_size_type buffer_size;
77c4286
   const unsigned char* buffer = this->do_section_contents(shndx, &buffer_size,
77c4286
@@ -3087,6 +3090,8 @@ Object::decompressed_section_contents(
77c4286
     {
77c4286
       *plen = uncompressed_size;
77c4286
       *is_new = false;
77c4286
+      if (palign != NULL)
77c4286
+	*palign = p->second.addralign;
77c4286
       return p->second.contents;
77c4286
     }
77c4286
 
77c4286
@@ -3108,6 +3113,8 @@ Object::decompressed_section_contents(
77c4286
   // once in this pass.
77c4286
   *plen = uncompressed_size;
77c4286
   *is_new = true;
77c4286
+  if (palign != NULL)
77c4286
+    *palign = p->second.addralign;
77c4286
   return uncompressed_data;
77c4286
 }
77c4286
 
77c4286
diff -rup binutils.orig/gold/object.h binutils-2.31.1/gold/object.h
77c4286
--- binutils.orig/gold/object.h	2019-02-18 11:53:32.210651723 +0000
77c4286
+++ binutils-2.31.1/gold/object.h	2019-02-18 12:17:50.625300926 +0000
77c4286
@@ -373,6 +373,7 @@ struct Compressed_section_info
77c4286
 {
77c4286
   section_size_type size;
77c4286
   elfcpp::Elf_Xword flag;
77c4286
+  uint64_t addralign;
77c4286
   const unsigned char* contents;
77c4286
 };
77c4286
 typedef std::map<unsigned int, Compressed_section_info> Compressed_section_map;
77c4286
@@ -808,7 +809,8 @@ class Object
77c4286
 
77c4286
   bool
77c4286
   section_is_compressed(unsigned int shndx,
77c4286
-			section_size_type* uncompressed_size) const
77c4286
+			section_size_type* uncompressed_size,
77c4286
+			elfcpp::Elf_Xword* palign = NULL) const
77c4286
   {
77c4286
     if (this->compressed_sections_ == NULL)
77c4286
       return false;
77c4286
@@ -818,6 +820,8 @@ class Object
77c4286
       {
77c4286
 	if (uncompressed_size != NULL)
77c4286
 	  *uncompressed_size = p->second.size;
77c4286
+	if (palign != NULL)
77c4286
+	  *palign = p->second.addralign;
77c4286
 	return true;
77c4286
       }
77c4286
     return false;
77c4286
@@ -828,7 +832,7 @@ class Object
77c4286
   // by the caller.
77c4286
   const unsigned char*
77c4286
   decompressed_section_contents(unsigned int shndx, section_size_type* plen,
77c4286
-				bool* is_cached);
77c4286
+				bool* is_cached, uint64_t* palign = NULL);
77c4286
 
77c4286
   // Discard any buffers of decompressed sections.  This is done
77c4286
   // at the end of the Add_symbols task.
77c4286
diff -rup binutils.orig/gold/output.cc binutils-2.31.1/gold/output.cc
77c4286
--- binutils.orig/gold/output.cc	2019-02-18 11:53:32.209651729 +0000
77c4286
+++ binutils-2.31.1/gold/output.cc	2019-02-18 12:18:39.729953797 +0000
77c4286
@@ -2448,7 +2448,14 @@ Output_section::add_input_section(Layout
77c4286
 				  unsigned int reloc_shndx,
77c4286
 				  bool have_sections_script)
77c4286
 {
77c4286
+  section_size_type input_section_size = shdr.get_sh_size();
77c4286
+  section_size_type uncompressed_size;
77c4286
   elfcpp::Elf_Xword addralign = shdr.get_sh_addralign();
77c4286
+
77c4286
+  if (object->section_is_compressed(shndx, &uncompressed_size,
77c4286
+                                   &addralign))
77c4286
+    input_section_size = uncompressed_size;
77c4286
+
77c4286
   if ((addralign & (addralign - 1)) != 0)
77c4286
     {
77c4286
       object->error(_("invalid alignment %lu for section \"%s\""),
77c4286
@@ -2498,11 +2505,6 @@ Output_section::add_input_section(Layout
77c4286
 	}
77c4286
     }
77c4286
 
77c4286
-  section_size_type input_section_size = shdr.get_sh_size();
77c4286
-  section_size_type uncompressed_size;
77c4286
-  if (object->section_is_compressed(shndx, &uncompressed_size))
77c4286
-    input_section_size = uncompressed_size;
77c4286
-
77c4286
   off_t offset_in_section;
77c4286
 
77c4286
   if (this->has_fixed_layout())