GNU Binutils with patches for OS216
修订版 | 88739f776b733b0b84600b283417f862a010bb5d (tree) |
---|---|
时间 | 2019-02-19 00:08:57 |
作者 | Nick Clifton <nickc@redh...> |
Commiter | Nick Clifton |
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.
@@ -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 | + | |
1 | 29 | 2019-02-10 H.J. Lu <hongjiu.lu@intel.com> |
2 | 30 | |
3 | 31 | PR ld/24151 |
@@ -7279,7 +7279,8 @@ void bfd_update_compression_header | ||
7279 | 7279 | |
7280 | 7280 | bfd_boolean bfd_check_compression_header |
7281 | 7281 | (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); | |
7283 | 7284 | |
7284 | 7285 | int bfd_get_compression_header_size (bfd *abfd, asection *sec); |
7285 | 7286 |
@@ -7855,7 +7856,8 @@ void bfd_cache_section_contents | ||
7855 | 7856 | bfd_boolean bfd_is_section_compressed_with_header |
7856 | 7857 | (bfd *abfd, asection *section, |
7857 | 7858 | 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); | |
7859 | 7861 | |
7860 | 7862 | bfd_boolean bfd_is_section_compressed |
7861 | 7863 | (bfd *abfd, asection *section); |
@@ -2332,6 +2332,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents, | ||
2332 | 2332 | bfd_put_32 (abfd, sec->size, &echdr->ch_size); |
2333 | 2333 | bfd_put_32 (abfd, 1 << sec->alignment_power, |
2334 | 2334 | &echdr->ch_addralign); |
2335 | + /* bfd_log2 (alignof (Elf32_Chdr)). */ | |
2336 | + bfd_set_section_alignment (abfd, sec, 2); | |
2335 | 2337 | } |
2336 | 2338 | else |
2337 | 2339 | { |
@@ -2342,6 +2344,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents, | ||
2342 | 2344 | bfd_put_64 (abfd, sec->size, &echdr->ch_size); |
2343 | 2345 | bfd_put_64 (abfd, 1 << sec->alignment_power, |
2344 | 2346 | &echdr->ch_addralign); |
2347 | + /* bfd_log2 (alignof (Elf64_Chdr)). */ | |
2348 | + bfd_set_section_alignment (abfd, sec, 3); | |
2345 | 2349 | } |
2346 | 2350 | } |
2347 | 2351 | else |
@@ -2354,6 +2358,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents, | ||
2354 | 2358 | order. */ |
2355 | 2359 | memcpy (contents, "ZLIB", 4); |
2356 | 2360 | 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); | |
2357 | 2363 | } |
2358 | 2364 | } |
2359 | 2365 | } |
@@ -2368,12 +2374,15 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents, | ||
2368 | 2374 | SYNOPSIS |
2369 | 2375 | bfd_boolean bfd_check_compression_header |
2370 | 2376 | (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 | + | |
2372 | 2380 | |
2373 | 2381 | DESCRIPTION |
2374 | 2382 | 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. | |
2377 | 2386 | |
2378 | 2387 | RETURNS |
2379 | 2388 | Return TRUE if the compression header is valid. |
@@ -2382,7 +2391,8 @@ RETURNS | ||
2382 | 2391 | bfd_boolean |
2383 | 2392 | bfd_check_compression_header (bfd *abfd, bfd_byte *contents, |
2384 | 2393 | asection *sec, |
2385 | - bfd_size_type *uncompressed_size) | |
2394 | + bfd_size_type *uncompressed_size, | |
2395 | + unsigned int *uncompressed_alignment_power) | |
2386 | 2396 | { |
2387 | 2397 | if (bfd_get_flavour (abfd) == bfd_target_elf_flavour |
2388 | 2398 | && (elf_section_flags (sec) & SHF_COMPRESSED) != 0) |
@@ -2404,9 +2414,10 @@ bfd_check_compression_header (bfd *abfd, bfd_byte *contents, | ||
2404 | 2414 | chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign); |
2405 | 2415 | } |
2406 | 2416 | if (chdr.ch_type == ELFCOMPRESS_ZLIB |
2407 | - && chdr.ch_addralign == 1U << sec->alignment_power) | |
2417 | + && chdr.ch_addralign == (1U << bfd_log2 (chdr.ch_addralign))) | |
2408 | 2418 | { |
2409 | 2419 | *uncompressed_size = chdr.ch_size; |
2420 | + *uncompressed_alignment_power = bfd_log2 (chdr.ch_addralign); | |
2410 | 2421 | return TRUE; |
2411 | 2422 | } |
2412 | 2423 | } |
@@ -84,11 +84,13 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec, | ||
84 | 84 | int zlib_size = 0; |
85 | 85 | int orig_compression_header_size; |
86 | 86 | bfd_size_type orig_uncompressed_size; |
87 | + unsigned int orig_uncompressed_alignment_pow; | |
87 | 88 | int header_size = bfd_get_compression_header_size (abfd, NULL); |
88 | 89 | bfd_boolean compressed |
89 | 90 | = bfd_is_section_compressed_with_header (abfd, sec, |
90 | 91 | &orig_compression_header_size, |
91 | - &orig_uncompressed_size); | |
92 | + &orig_uncompressed_size, | |
93 | + &orig_uncompressed_alignment_pow); | |
92 | 94 | |
93 | 95 | /* Either ELF compression header or the 12-byte, "ZLIB" + 8-byte size, |
94 | 96 | overhead in .zdebug* section. */ |
@@ -153,6 +155,8 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec, | ||
153 | 155 | return 0; |
154 | 156 | } |
155 | 157 | free (uncompressed_buffer); |
158 | + bfd_set_section_alignment (abfd, sec, | |
159 | + orig_uncompressed_alignment_pow); | |
156 | 160 | sec->contents = buffer; |
157 | 161 | sec->compress_status = COMPRESS_SECTION_DONE; |
158 | 162 | return orig_uncompressed_size; |
@@ -364,20 +368,25 @@ SYNOPSIS | ||
364 | 368 | bfd_boolean bfd_is_section_compressed_with_header |
365 | 369 | (bfd *abfd, asection *section, |
366 | 370 | 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 | + | |
368 | 374 | |
369 | 375 | DESCRIPTION |
370 | 376 | 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. | |
375 | 383 | */ |
376 | 384 | |
377 | 385 | bfd_boolean |
378 | 386 | bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec, |
379 | 387 | 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) | |
381 | 390 | { |
382 | 391 | bfd_byte header[MAX_COMPRESSION_HEADER_SIZE]; |
383 | 392 | int compression_header_size; |
@@ -385,6 +394,8 @@ bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec, | ||
385 | 394 | unsigned int saved = sec->compress_status; |
386 | 395 | bfd_boolean compressed; |
387 | 396 | |
397 | + *uncompressed_align_pow_p = 0; | |
398 | + | |
388 | 399 | compression_header_size = bfd_get_compression_header_size (abfd, sec); |
389 | 400 | if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE) |
390 | 401 | abort (); |
@@ -412,7 +423,8 @@ bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec, | ||
412 | 423 | if (compression_header_size != 0) |
413 | 424 | { |
414 | 425 | if (!bfd_check_compression_header (abfd, header, sec, |
415 | - uncompressed_size_p)) | |
426 | + uncompressed_size_p, | |
427 | + uncompressed_align_pow_p)) | |
416 | 428 | compression_header_size = -1; |
417 | 429 | } |
418 | 430 | /* Check for the pathalogical case of a debug string section that |
@@ -449,9 +461,11 @@ bfd_is_section_compressed (bfd *abfd, sec_ptr sec) | ||
449 | 461 | { |
450 | 462 | int compression_header_size; |
451 | 463 | bfd_size_type uncompressed_size; |
464 | + unsigned int uncompressed_align_power; | |
452 | 465 | return (bfd_is_section_compressed_with_header (abfd, sec, |
453 | 466 | &compression_header_size, |
454 | - &uncompressed_size) | |
467 | + &uncompressed_size, | |
468 | + &uncompressed_align_power) | |
455 | 469 | && compression_header_size >= 0 |
456 | 470 | && uncompressed_size > 0); |
457 | 471 | } |
@@ -480,6 +494,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec) | ||
480 | 494 | int compression_header_size; |
481 | 495 | int header_size; |
482 | 496 | bfd_size_type uncompressed_size; |
497 | + unsigned int uncompressed_alignment_power = 0; | |
483 | 498 | |
484 | 499 | compression_header_size = bfd_get_compression_header_size (abfd, sec); |
485 | 500 | if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE) |
@@ -508,7 +523,8 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec) | ||
508 | 523 | uncompressed_size = bfd_getb64 (header + 4); |
509 | 524 | } |
510 | 525 | else if (!bfd_check_compression_header (abfd, header, sec, |
511 | - &uncompressed_size)) | |
526 | + &uncompressed_size, | |
527 | + &uncompressed_alignment_power)) | |
512 | 528 | { |
513 | 529 | bfd_set_error (bfd_error_wrong_format); |
514 | 530 | return FALSE; |
@@ -516,6 +532,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec) | ||
516 | 532 | |
517 | 533 | sec->compressed_size = sec->size; |
518 | 534 | sec->size = uncompressed_size; |
535 | + bfd_set_section_alignment (abfd, sec, uncompressed_alignment_power); | |
519 | 536 | sec->compress_status = DECOMPRESS_SECTION_SIZED; |
520 | 537 | |
521 | 538 | return TRUE; |
@@ -1177,10 +1177,12 @@ _bfd_elf_make_section_from_shdr (bfd *abfd, | ||
1177 | 1177 | enum { nothing, compress, decompress } action = nothing; |
1178 | 1178 | int compression_header_size; |
1179 | 1179 | bfd_size_type uncompressed_size; |
1180 | + unsigned int uncompressed_align_power; | |
1180 | 1181 | bfd_boolean compressed |
1181 | 1182 | = bfd_is_section_compressed_with_header (abfd, newsect, |
1182 | 1183 | &compression_header_size, |
1183 | - &uncompressed_size); | |
1184 | + &uncompressed_size, | |
1185 | + &uncompressed_align_power); | |
1184 | 1186 | |
1185 | 1187 | if (compressed) |
1186 | 1188 | { |
@@ -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 | + | |
1 | 13 | 2018-09-12 H.J. Lu <hongjiu.lu@intel.com> |
2 | 14 | |
3 | 15 | PR ld/23499 |
@@ -13345,12 +13345,6 @@ dump_section_as_strings (Elf_Internal_Shdr * section, Filedata * filedata) | ||
13345 | 13345 | printable_section_name (filedata, section), chdr.ch_type); |
13346 | 13346 | return FALSE; |
13347 | 13347 | } |
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 | - } | |
13354 | 13348 | uncompressed_size = chdr.ch_size; |
13355 | 13349 | start += compression_header_size; |
13356 | 13350 | new_size -= compression_header_size; |
@@ -13492,12 +13486,6 @@ dump_section_as_bytes (Elf_Internal_Shdr * section, | ||
13492 | 13486 | printable_section_name (filedata, section), chdr.ch_type); |
13493 | 13487 | return FALSE; |
13494 | 13488 | } |
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 | - } | |
13501 | 13489 | uncompressed_size = chdr.ch_size; |
13502 | 13490 | start += compression_header_size; |
13503 | 13491 | new_size -= compression_header_size; |
@@ -13667,12 +13655,6 @@ load_specific_debug_section (enum dwarf_section_display_enum debug, | ||
13667 | 13655 | section->name, chdr.ch_type); |
13668 | 13656 | return FALSE; |
13669 | 13657 | } |
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 | - } | |
13676 | 13658 | uncompressed_size = chdr.ch_size; |
13677 | 13659 | start += compression_header_size; |
13678 | 13660 | size -= compression_header_size; |
@@ -1,3 +1,3 @@ | ||
1 | 1 | #... |
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) | |
3 | 3 | #pass |
@@ -1,6 +1,6 @@ | ||
1 | 1 | #... |
2 | 2 | +\[[ 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) | |
4 | 4 | +\[0+800\]: COMPRESSED |
5 | 5 | +ZLIB, 0+9d, 1 |
6 | 6 | #pass |
@@ -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 | + | |
1 | 20 | 2018-08-06 Cary Coutant <ccoutant@gmail.com> |
2 | 21 | |
3 | 22 | PR gold/23455 |
@@ -440,9 +440,11 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object, | ||
440 | 440 | { |
441 | 441 | section_size_type sec_len; |
442 | 442 | bool is_new; |
443 | + uint64_t addralign = this->addralign(); | |
443 | 444 | const unsigned char* pdata = object->decompressed_section_contents(shndx, |
444 | 445 | &sec_len, |
445 | - &is_new); | |
446 | + &is_new, | |
447 | + &addralign); | |
446 | 448 | |
447 | 449 | const Char_type* p = reinterpret_cast<const Char_type*>(pdata); |
448 | 450 | 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, | ||
494 | 496 | // aligned, so each string within the section must retain the same |
495 | 497 | // modulo. |
496 | 498 | uintptr_t init_align_modulo = (reinterpret_cast<uintptr_t>(pdata) |
497 | - & (this->addralign() - 1)); | |
499 | + & (addralign - 1)); | |
498 | 500 | bool has_misaligned_strings = false; |
499 | 501 | |
500 | 502 | while (p < pend) |
@@ -503,7 +505,7 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object, | ||
503 | 505 | |
504 | 506 | // Within merge input section each string must be aligned. |
505 | 507 | if (len != 0 |
506 | - && ((reinterpret_cast<uintptr_t>(p) & (this->addralign() - 1)) | |
508 | + && ((reinterpret_cast<uintptr_t>(p) & (addralign - 1)) | |
507 | 509 | != init_align_modulo)) |
508 | 510 | has_misaligned_strings = true; |
509 | 511 |
@@ -751,11 +751,13 @@ build_compressed_section_map( | ||
751 | 751 | const unsigned char* contents = |
752 | 752 | obj->section_contents(i, &len, false); |
753 | 753 | uint64_t uncompressed_size; |
754 | + Compressed_section_info info; | |
754 | 755 | if (is_zcompressed) |
755 | 756 | { |
756 | 757 | // Skip over the ".zdebug" prefix. |
757 | 758 | name += 7; |
758 | 759 | uncompressed_size = get_uncompressed_size(contents, len); |
760 | + info.addralign = shdr.get_sh_addralign(); | |
759 | 761 | } |
760 | 762 | else |
761 | 763 | { |
@@ -763,8 +765,8 @@ build_compressed_section_map( | ||
763 | 765 | name += 6; |
764 | 766 | elfcpp::Chdr<size, big_endian> chdr(contents); |
765 | 767 | uncompressed_size = chdr.get_ch_size(); |
768 | + info.addralign = chdr.get_ch_addralign(); | |
766 | 769 | } |
767 | - Compressed_section_info info; | |
768 | 770 | info.size = convert_to_section_size_type(uncompressed_size); |
769 | 771 | info.flag = shdr.get_sh_flags(); |
770 | 772 | info.contents = NULL; |
@@ -3060,7 +3062,8 @@ const unsigned char* | ||
3060 | 3062 | Object::decompressed_section_contents( |
3061 | 3063 | unsigned int shndx, |
3062 | 3064 | section_size_type* plen, |
3063 | - bool* is_new) | |
3065 | + bool* is_new, | |
3066 | + uint64_t* palign) | |
3064 | 3067 | { |
3065 | 3068 | section_size_type buffer_size; |
3066 | 3069 | const unsigned char* buffer = this->do_section_contents(shndx, &buffer_size, |
@@ -3087,6 +3090,8 @@ Object::decompressed_section_contents( | ||
3087 | 3090 | { |
3088 | 3091 | *plen = uncompressed_size; |
3089 | 3092 | *is_new = false; |
3093 | + if (palign != NULL) | |
3094 | + *palign = p->second.addralign; | |
3090 | 3095 | return p->second.contents; |
3091 | 3096 | } |
3092 | 3097 |
@@ -3108,6 +3113,8 @@ Object::decompressed_section_contents( | ||
3108 | 3113 | // once in this pass. |
3109 | 3114 | *plen = uncompressed_size; |
3110 | 3115 | *is_new = true; |
3116 | + if (palign != NULL) | |
3117 | + *palign = p->second.addralign; | |
3111 | 3118 | return uncompressed_data; |
3112 | 3119 | } |
3113 | 3120 |
@@ -373,6 +373,7 @@ struct Compressed_section_info | ||
373 | 373 | { |
374 | 374 | section_size_type size; |
375 | 375 | elfcpp::Elf_Xword flag; |
376 | + uint64_t addralign; | |
376 | 377 | const unsigned char* contents; |
377 | 378 | }; |
378 | 379 | typedef std::map<unsigned int, Compressed_section_info> Compressed_section_map; |
@@ -808,7 +809,8 @@ class Object | ||
808 | 809 | |
809 | 810 | bool |
810 | 811 | 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 | |
812 | 814 | { |
813 | 815 | if (this->compressed_sections_ == NULL) |
814 | 816 | return false; |
@@ -818,6 +820,8 @@ class Object | ||
818 | 820 | { |
819 | 821 | if (uncompressed_size != NULL) |
820 | 822 | *uncompressed_size = p->second.size; |
823 | + if (palign != NULL) | |
824 | + *palign = p->second.addralign; | |
821 | 825 | return true; |
822 | 826 | } |
823 | 827 | return false; |
@@ -828,7 +832,7 @@ class Object | ||
828 | 832 | // by the caller. |
829 | 833 | const unsigned char* |
830 | 834 | decompressed_section_contents(unsigned int shndx, section_size_type* plen, |
831 | - bool* is_cached); | |
835 | + bool* is_cached, uint64_t* palign = NULL); | |
832 | 836 | |
833 | 837 | // Discard any buffers of decompressed sections. This is done |
834 | 838 | // at the end of the Add_symbols task. |
@@ -2448,7 +2448,14 @@ Output_section::add_input_section(Layout* layout, | ||
2448 | 2448 | unsigned int reloc_shndx, |
2449 | 2449 | bool have_sections_script) |
2450 | 2450 | { |
2451 | + section_size_type input_section_size = shdr.get_sh_size(); | |
2452 | + section_size_type uncompressed_size; | |
2451 | 2453 | 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 | + | |
2452 | 2459 | if ((addralign & (addralign - 1)) != 0) |
2453 | 2460 | { |
2454 | 2461 | object->error(_("invalid alignment %lu for section \"%s\""), |
@@ -2498,11 +2505,6 @@ Output_section::add_input_section(Layout* layout, | ||
2498 | 2505 | } |
2499 | 2506 | } |
2500 | 2507 | |
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 | - | |
2506 | 2508 | off_t offset_in_section; |
2507 | 2509 | |
2508 | 2510 | if (this->has_fixed_layout()) |