• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修订版88739f776b733b0b84600b283417f862a010bb5d (tree)
时间2019-02-19 00:08:57
作者Nick Clifton <nickc@redh...>
CommiterNick Clifton

Log Message

Import patch to fix PR23919 from the mainline.

PR binutils/23919
bfd * bfd.c (bfd_update_compression_header): Explicitly set alignment.
(bfd_check_compression_header): Add uncompressed_alignment_power
argument. Check ch_addralign is a power of 2.
* bfd-in2.h: Regenerated.
* compress.c (bfd_compress_section_contents): Get and set
orig_uncompressed_alignment_pow if section is decompressed.
(bfd_is_section_compressed_with_header): Add and get
uncompressed_align_pow_p argument.
(bfd_is_section_compressed): Add uncompressed_align_power argument
to bfd_is_section_compressed_with_header call.
(bfd_init_section_decompress_status): Get and set
uncompressed_alignment_power.
* elf.c (_bfd_elf_make_section_from_shdr): Add
uncompressed_align_power argument to
bfd_is_section_compressed_with_header call.

* compress.c (bfd_is_section_compressed_with_header): Initialize
* uncompressed_align_pow_p to 0.

binutils* readelf.c (dump_sections_as_strings): Remove bogus addralign check.
(dump_sections_as_bytes): Likewise.
(load_specific_debug_sections): Likewise.
* testsuite/binutils-all/dw2-3.rS: Adjust alignment.
* testsuite/binutils-all/dw2-3.rt: Likewise.

gold * merge.cc (Output_merge_string<Char_type>::do_add_input_section):
Get addralign from decompressed_section_contents.
* object.cc (build_compressed_section_map): Set info.addralign.
(Object::decompressed_section_contents): Add a palign
argument and store p->second.addralign in *palign if it isn't
NULL.
* object.h (Compressed_section_info): Add addralign.
(section_is_compressed): Add a palign argument, default it
to NULL, store p->second.addralign in *palign if it isn't NULL.
(Object::decompressed_section_contents): Likewise.
* output.cc (Output_section::add_input_section): Get addralign
from section_is_compressed.

更改概述

差异

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,31 @@
1+2019-02-18 Nick Clifton <nickc@redhat.com>
2+
3+ Import from the mainline:
4+ 2018-11-27 Mark Wielaard <mark@klomp.org>
5+
6+ PR binutils/23919
7+ * bfd.c (bfd_update_compression_header): Explicitly set alignment.
8+ (bfd_check_compression_header): Add uncompressed_alignment_power
9+ argument. Check ch_addralign is a power of 2.
10+ * bfd-in2.h: Regenerated.
11+ * compress.c (bfd_compress_section_contents): Get and set
12+ orig_uncompressed_alignment_pow if section is decompressed.
13+ (bfd_is_section_compressed_with_header): Add and get
14+ uncompressed_align_pow_p argument.
15+ (bfd_is_section_compressed): Add uncompressed_align_power argument
16+ to bfd_is_section_compressed_with_header call.
17+ (bfd_init_section_decompress_status): Get and set
18+ uncompressed_alignment_power.
19+ * elf.c (_bfd_elf_make_section_from_shdr): Add
20+ uncompressed_align_power argument to
21+ bfd_is_section_compressed_with_header call.
22+
23+ 2018-11-27 H.J. Lu <hongjiu.lu@intel.com>
24+
25+ PR binutils/23919
26+ * compress.c (bfd_is_section_compressed_with_header): Initialize
27+ * uncompressed_align_pow_p to 0.
28+
129 2019-02-10 H.J. Lu <hongjiu.lu@intel.com>
230
331 PR ld/24151
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7279,7 +7279,8 @@ void bfd_update_compression_header
72797279
72807280 bfd_boolean bfd_check_compression_header
72817281 (bfd *abfd, bfd_byte *contents, asection *sec,
7282- bfd_size_type *uncompressed_size);
7282+ bfd_size_type *uncompressed_size,
7283+ unsigned int *uncompressed_alignment_power);
72837284
72847285 int bfd_get_compression_header_size (bfd *abfd, asection *sec);
72857286
@@ -7855,7 +7856,8 @@ void bfd_cache_section_contents
78557856 bfd_boolean bfd_is_section_compressed_with_header
78567857 (bfd *abfd, asection *section,
78577858 int *compression_header_size_p,
7858- bfd_size_type *uncompressed_size_p);
7859+ bfd_size_type *uncompressed_size_p,
7860+ unsigned int *uncompressed_alignment_power_p);
78597861
78607862 bfd_boolean bfd_is_section_compressed
78617863 (bfd *abfd, asection *section);
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2332,6 +2332,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
23322332 bfd_put_32 (abfd, sec->size, &echdr->ch_size);
23332333 bfd_put_32 (abfd, 1 << sec->alignment_power,
23342334 &echdr->ch_addralign);
2335+ /* bfd_log2 (alignof (Elf32_Chdr)). */
2336+ bfd_set_section_alignment (abfd, sec, 2);
23352337 }
23362338 else
23372339 {
@@ -2342,6 +2344,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
23422344 bfd_put_64 (abfd, sec->size, &echdr->ch_size);
23432345 bfd_put_64 (abfd, 1 << sec->alignment_power,
23442346 &echdr->ch_addralign);
2347+ /* bfd_log2 (alignof (Elf64_Chdr)). */
2348+ bfd_set_section_alignment (abfd, sec, 3);
23452349 }
23462350 }
23472351 else
@@ -2354,6 +2358,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
23542358 order. */
23552359 memcpy (contents, "ZLIB", 4);
23562360 bfd_putb64 (sec->size, contents + 4);
2361+ /* No way to keep the original alignment, just use 1 always. */
2362+ bfd_set_section_alignment (abfd, sec, 0);
23572363 }
23582364 }
23592365 }
@@ -2368,12 +2374,15 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
23682374 SYNOPSIS
23692375 bfd_boolean bfd_check_compression_header
23702376 (bfd *abfd, bfd_byte *contents, asection *sec,
2371- bfd_size_type *uncompressed_size);
2377+ bfd_size_type *uncompressed_size,
2378+ unsigned int *uncompressed_alignment_power);
2379+
23722380
23732381 DESCRIPTION
23742382 Check the compression header at CONTENTS of SEC in ABFD and
2375- store the uncompressed size in UNCOMPRESSED_SIZE if the
2376- compression header is valid.
2383+ store the uncompressed size in UNCOMPRESSED_SIZE and the
2384+ uncompressed data alignment in UNCOMPRESSED_ALIGNMENT_POWER
2385+ if the compression header is valid.
23772386
23782387 RETURNS
23792388 Return TRUE if the compression header is valid.
@@ -2382,7 +2391,8 @@ RETURNS
23822391 bfd_boolean
23832392 bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
23842393 asection *sec,
2385- bfd_size_type *uncompressed_size)
2394+ bfd_size_type *uncompressed_size,
2395+ unsigned int *uncompressed_alignment_power)
23862396 {
23872397 if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
23882398 && (elf_section_flags (sec) & SHF_COMPRESSED) != 0)
@@ -2404,9 +2414,10 @@ bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
24042414 chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign);
24052415 }
24062416 if (chdr.ch_type == ELFCOMPRESS_ZLIB
2407- && chdr.ch_addralign == 1U << sec->alignment_power)
2417+ && chdr.ch_addralign == (1U << bfd_log2 (chdr.ch_addralign)))
24082418 {
24092419 *uncompressed_size = chdr.ch_size;
2420+ *uncompressed_alignment_power = bfd_log2 (chdr.ch_addralign);
24102421 return TRUE;
24112422 }
24122423 }
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -84,11 +84,13 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec,
8484 int zlib_size = 0;
8585 int orig_compression_header_size;
8686 bfd_size_type orig_uncompressed_size;
87+ unsigned int orig_uncompressed_alignment_pow;
8788 int header_size = bfd_get_compression_header_size (abfd, NULL);
8889 bfd_boolean compressed
8990 = bfd_is_section_compressed_with_header (abfd, sec,
9091 &orig_compression_header_size,
91- &orig_uncompressed_size);
92+ &orig_uncompressed_size,
93+ &orig_uncompressed_alignment_pow);
9294
9395 /* Either ELF compression header or the 12-byte, "ZLIB" + 8-byte size,
9496 overhead in .zdebug* section. */
@@ -153,6 +155,8 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec,
153155 return 0;
154156 }
155157 free (uncompressed_buffer);
158+ bfd_set_section_alignment (abfd, sec,
159+ orig_uncompressed_alignment_pow);
156160 sec->contents = buffer;
157161 sec->compress_status = COMPRESS_SECTION_DONE;
158162 return orig_uncompressed_size;
@@ -364,20 +368,25 @@ SYNOPSIS
364368 bfd_boolean bfd_is_section_compressed_with_header
365369 (bfd *abfd, asection *section,
366370 int *compression_header_size_p,
367- bfd_size_type *uncompressed_size_p);
371+ bfd_size_type *uncompressed_size_p,
372+ unsigned int *uncompressed_alignment_power_p);
373+
368374
369375 DESCRIPTION
370376 Return @code{TRUE} if @var{section} is compressed. Compression
371- header size is returned in @var{compression_header_size_p} and
372- uncompressed size is returned in @var{uncompressed_size_p}. If
373- compression is unsupported, compression header size is returned
374- with -1 and uncompressed size is returned with 0.
377+ header size is returned in @var{compression_header_size_p},
378+ uncompressed size is returned in @var{uncompressed_size_p}
379+ and the uncompressed data alignement power is returned in
380+ @var{uncompressed_align_pow_p}. If compression is
381+ unsupported, compression header size is returned with -1
382+ and uncompressed size is returned with 0.
375383 */
376384
377385 bfd_boolean
378386 bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec,
379387 int *compression_header_size_p,
380- bfd_size_type *uncompressed_size_p)
388+ bfd_size_type *uncompressed_size_p,
389+ unsigned int *uncompressed_align_pow_p)
381390 {
382391 bfd_byte header[MAX_COMPRESSION_HEADER_SIZE];
383392 int compression_header_size;
@@ -385,6 +394,8 @@ bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec,
385394 unsigned int saved = sec->compress_status;
386395 bfd_boolean compressed;
387396
397+ *uncompressed_align_pow_p = 0;
398+
388399 compression_header_size = bfd_get_compression_header_size (abfd, sec);
389400 if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE)
390401 abort ();
@@ -412,7 +423,8 @@ bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec,
412423 if (compression_header_size != 0)
413424 {
414425 if (!bfd_check_compression_header (abfd, header, sec,
415- uncompressed_size_p))
426+ uncompressed_size_p,
427+ uncompressed_align_pow_p))
416428 compression_header_size = -1;
417429 }
418430 /* Check for the pathalogical case of a debug string section that
@@ -449,9 +461,11 @@ bfd_is_section_compressed (bfd *abfd, sec_ptr sec)
449461 {
450462 int compression_header_size;
451463 bfd_size_type uncompressed_size;
464+ unsigned int uncompressed_align_power;
452465 return (bfd_is_section_compressed_with_header (abfd, sec,
453466 &compression_header_size,
454- &uncompressed_size)
467+ &uncompressed_size,
468+ &uncompressed_align_power)
455469 && compression_header_size >= 0
456470 && uncompressed_size > 0);
457471 }
@@ -480,6 +494,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
480494 int compression_header_size;
481495 int header_size;
482496 bfd_size_type uncompressed_size;
497+ unsigned int uncompressed_alignment_power = 0;
483498
484499 compression_header_size = bfd_get_compression_header_size (abfd, sec);
485500 if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE)
@@ -508,7 +523,8 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
508523 uncompressed_size = bfd_getb64 (header + 4);
509524 }
510525 else if (!bfd_check_compression_header (abfd, header, sec,
511- &uncompressed_size))
526+ &uncompressed_size,
527+ &uncompressed_alignment_power))
512528 {
513529 bfd_set_error (bfd_error_wrong_format);
514530 return FALSE;
@@ -516,6 +532,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
516532
517533 sec->compressed_size = sec->size;
518534 sec->size = uncompressed_size;
535+ bfd_set_section_alignment (abfd, sec, uncompressed_alignment_power);
519536 sec->compress_status = DECOMPRESS_SECTION_SIZED;
520537
521538 return TRUE;
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1177,10 +1177,12 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
11771177 enum { nothing, compress, decompress } action = nothing;
11781178 int compression_header_size;
11791179 bfd_size_type uncompressed_size;
1180+ unsigned int uncompressed_align_power;
11801181 bfd_boolean compressed
11811182 = bfd_is_section_compressed_with_header (abfd, newsect,
11821183 &compression_header_size,
1183- &uncompressed_size);
1184+ &uncompressed_size,
1185+ &uncompressed_align_power);
11841186
11851187 if (compressed)
11861188 {
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,15 @@
1+2019-02-18 Nick Clifton <nickc@redhat.com>
2+
3+ Import from the mainline:
4+ 2018-11-27 Mark Wielaard <mark@klomp.org>
5+
6+ PR binutils/23919
7+ * readelf.c (dump_sections_as_strings): Remove bogus addralign check.
8+ (dump_sections_as_bytes): Likewise.
9+ (load_specific_debug_sections): Likewise.
10+ * testsuite/binutils-all/dw2-3.rS: Adjust alignment.
11+ * testsuite/binutils-all/dw2-3.rt: Likewise.
12+
113 2018-09-12 H.J. Lu <hongjiu.lu@intel.com>
214
315 PR ld/23499
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -13345,12 +13345,6 @@ dump_section_as_strings (Elf_Internal_Shdr * section, Filedata * filedata)
1334513345 printable_section_name (filedata, section), chdr.ch_type);
1334613346 return FALSE;
1334713347 }
13348- else if (chdr.ch_addralign != section->sh_addralign)
13349- {
13350- warn (_("compressed section '%s' is corrupted\n"),
13351- printable_section_name (filedata, section));
13352- return FALSE;
13353- }
1335413348 uncompressed_size = chdr.ch_size;
1335513349 start += compression_header_size;
1335613350 new_size -= compression_header_size;
@@ -13492,12 +13486,6 @@ dump_section_as_bytes (Elf_Internal_Shdr * section,
1349213486 printable_section_name (filedata, section), chdr.ch_type);
1349313487 return FALSE;
1349413488 }
13495- else if (chdr.ch_addralign != section->sh_addralign)
13496- {
13497- warn (_("compressed section '%s' is corrupted\n"),
13498- printable_section_name (filedata, section));
13499- return FALSE;
13500- }
1350113489 uncompressed_size = chdr.ch_size;
1350213490 start += compression_header_size;
1350313491 new_size -= compression_header_size;
@@ -13667,12 +13655,6 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
1366713655 section->name, chdr.ch_type);
1366813656 return FALSE;
1366913657 }
13670- else if (chdr.ch_addralign != sec->sh_addralign)
13671- {
13672- warn (_("compressed section '%s' is corrupted\n"),
13673- section->name);
13674- return FALSE;
13675- }
1367613658 uncompressed_size = chdr.ch_size;
1367713659 start += compression_header_size;
1367813660 size -= compression_header_size;
--- a/binutils/testsuite/binutils-all/dw2-3.rS
+++ b/binutils/testsuite/binutils-all/dw2-3.rS
@@ -1,3 +1,3 @@
11 #...
2- +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +1
2+ +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +(4|8)
33 #pass
--- a/binutils/testsuite/binutils-all/dw2-3.rt
+++ b/binutils/testsuite/binutils-all/dw2-3.rt
@@ -1,6 +1,6 @@
11 #...
22 +\[[ 0-9]+\] .debug_info
3- +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +1
3+ +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +(4|8)
44 +\[0+800\]: COMPRESSED
55 +ZLIB, 0+9d, 1
66 #pass
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,22 @@
1+2019-02-18 Nick Clifton <nickc@redhat.com>
2+
3+ Import from the mainline:
4+ 2018-12-02 H.J. Lu <hongjiu.lu@intel.com>
5+
6+ PR binutils/23919
7+ * merge.cc (Output_merge_string<Char_type>::do_add_input_section):
8+ Get addralign from decompressed_section_contents.
9+ * object.cc (build_compressed_section_map): Set info.addralign.
10+ (Object::decompressed_section_contents): Add a palign
11+ argument and store p->second.addralign in *palign if it isn't
12+ NULL.
13+ * object.h (Compressed_section_info): Add addralign.
14+ (section_is_compressed): Add a palign argument, default it
15+ to NULL, store p->second.addralign in *palign if it isn't NULL.
16+ (Object::decompressed_section_contents): Likewise.
17+ * output.cc (Output_section::add_input_section): Get addralign
18+ from section_is_compressed.
19+
120 2018-08-06 Cary Coutant <ccoutant@gmail.com>
221
322 PR gold/23455
--- a/gold/merge.cc
+++ b/gold/merge.cc
@@ -440,9 +440,11 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
440440 {
441441 section_size_type sec_len;
442442 bool is_new;
443+ uint64_t addralign = this->addralign();
443444 const unsigned char* pdata = object->decompressed_section_contents(shndx,
444445 &sec_len,
445- &is_new);
446+ &is_new,
447+ &addralign);
446448
447449 const Char_type* p = reinterpret_cast<const Char_type*>(pdata);
448450 const Char_type* pend = p + sec_len / sizeof(Char_type);
@@ -494,7 +496,7 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
494496 // aligned, so each string within the section must retain the same
495497 // modulo.
496498 uintptr_t init_align_modulo = (reinterpret_cast<uintptr_t>(pdata)
497- & (this->addralign() - 1));
499+ & (addralign - 1));
498500 bool has_misaligned_strings = false;
499501
500502 while (p < pend)
@@ -503,7 +505,7 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
503505
504506 // Within merge input section each string must be aligned.
505507 if (len != 0
506- && ((reinterpret_cast<uintptr_t>(p) & (this->addralign() - 1))
508+ && ((reinterpret_cast<uintptr_t>(p) & (addralign - 1))
507509 != init_align_modulo))
508510 has_misaligned_strings = true;
509511
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -751,11 +751,13 @@ build_compressed_section_map(
751751 const unsigned char* contents =
752752 obj->section_contents(i, &len, false);
753753 uint64_t uncompressed_size;
754+ Compressed_section_info info;
754755 if (is_zcompressed)
755756 {
756757 // Skip over the ".zdebug" prefix.
757758 name += 7;
758759 uncompressed_size = get_uncompressed_size(contents, len);
760+ info.addralign = shdr.get_sh_addralign();
759761 }
760762 else
761763 {
@@ -763,8 +765,8 @@ build_compressed_section_map(
763765 name += 6;
764766 elfcpp::Chdr<size, big_endian> chdr(contents);
765767 uncompressed_size = chdr.get_ch_size();
768+ info.addralign = chdr.get_ch_addralign();
766769 }
767- Compressed_section_info info;
768770 info.size = convert_to_section_size_type(uncompressed_size);
769771 info.flag = shdr.get_sh_flags();
770772 info.contents = NULL;
@@ -3060,7 +3062,8 @@ const unsigned char*
30603062 Object::decompressed_section_contents(
30613063 unsigned int shndx,
30623064 section_size_type* plen,
3063- bool* is_new)
3065+ bool* is_new,
3066+ uint64_t* palign)
30643067 {
30653068 section_size_type buffer_size;
30663069 const unsigned char* buffer = this->do_section_contents(shndx, &buffer_size,
@@ -3087,6 +3090,8 @@ Object::decompressed_section_contents(
30873090 {
30883091 *plen = uncompressed_size;
30893092 *is_new = false;
3093+ if (palign != NULL)
3094+ *palign = p->second.addralign;
30903095 return p->second.contents;
30913096 }
30923097
@@ -3108,6 +3113,8 @@ Object::decompressed_section_contents(
31083113 // once in this pass.
31093114 *plen = uncompressed_size;
31103115 *is_new = true;
3116+ if (palign != NULL)
3117+ *palign = p->second.addralign;
31113118 return uncompressed_data;
31123119 }
31133120
--- a/gold/object.h
+++ b/gold/object.h
@@ -373,6 +373,7 @@ struct Compressed_section_info
373373 {
374374 section_size_type size;
375375 elfcpp::Elf_Xword flag;
376+ uint64_t addralign;
376377 const unsigned char* contents;
377378 };
378379 typedef std::map<unsigned int, Compressed_section_info> Compressed_section_map;
@@ -808,7 +809,8 @@ class Object
808809
809810 bool
810811 section_is_compressed(unsigned int shndx,
811- section_size_type* uncompressed_size) const
812+ section_size_type* uncompressed_size,
813+ elfcpp::Elf_Xword* palign = NULL) const
812814 {
813815 if (this->compressed_sections_ == NULL)
814816 return false;
@@ -818,6 +820,8 @@ class Object
818820 {
819821 if (uncompressed_size != NULL)
820822 *uncompressed_size = p->second.size;
823+ if (palign != NULL)
824+ *palign = p->second.addralign;
821825 return true;
822826 }
823827 return false;
@@ -828,7 +832,7 @@ class Object
828832 // by the caller.
829833 const unsigned char*
830834 decompressed_section_contents(unsigned int shndx, section_size_type* plen,
831- bool* is_cached);
835+ bool* is_cached, uint64_t* palign = NULL);
832836
833837 // Discard any buffers of decompressed sections. This is done
834838 // at the end of the Add_symbols task.
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -2448,7 +2448,14 @@ Output_section::add_input_section(Layout* layout,
24482448 unsigned int reloc_shndx,
24492449 bool have_sections_script)
24502450 {
2451+ section_size_type input_section_size = shdr.get_sh_size();
2452+ section_size_type uncompressed_size;
24512453 elfcpp::Elf_Xword addralign = shdr.get_sh_addralign();
2454+
2455+ if (object->section_is_compressed(shndx, &uncompressed_size,
2456+ &addralign))
2457+ input_section_size = uncompressed_size;
2458+
24522459 if ((addralign & (addralign - 1)) != 0)
24532460 {
24542461 object->error(_("invalid alignment %lu for section \"%s\""),
@@ -2498,11 +2505,6 @@ Output_section::add_input_section(Layout* layout,
24982505 }
24992506 }
25002507
2501- section_size_type input_section_size = shdr.get_sh_size();
2502- section_size_type uncompressed_size;
2503- if (object->section_is_compressed(shndx, &uncompressed_size))
2504- input_section_size = uncompressed_size;
2505-
25062508 off_t offset_in_section;
25072509
25082510 if (this->has_fixed_layout())