This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [committed, PATCH] Change ch_type in Elf64_External_Chdr to 4 bytes
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Tue, 6 Oct 2015 14:37:12 -0700
- Subject: Re: [committed, PATCH] Change ch_type in Elf64_External_Chdr to 4 bytes
- Authentication-results: sourceware.org; auth=none
- References: <20150921172309 dot GA13367 at intel dot com>
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
On Mon, Sep 21, 2015 at 10:23:09AM -0700, H.J. Lu wrote:
> The ch_type field in Elf64_External_Chdr is 4 bytes, followed by a
> 4-byte padding. This change doesn't introduce any functional change
> since only the lower 32 bits of the ch_type field are used.
>
> * external.h (Elf64_External_Chdr): Change ch_type to 4 bytes
> and add ch_reserved.
It is better to clear the ch_reserved field of Elf64_External_Chdr
in 64-bit output. Checked in.
H.J.
---
* bfd.c (bfd_update_compression_header): Clear the ch_reserved
field in 64-bit output.
(bfd_convert_section_contents): Likewise.
---
bfd/ChangeLog | 6 ++++++
bfd/bfd.c | 2 ++
2 files changed, 8 insertions(+)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index db6fe6b..b2a8855 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ * bfd.c (bfd_update_compression_header): Clear the ch_reserved
+ field in 64-bit output.
+ (bfd_convert_section_contents): Likewise.
+
2015-10-05 H.J. Lu <hongjiu.lu@intel.com>
PR ld/18914
diff --git a/bfd/bfd.c b/bfd/bfd.c
index f68f665..9c4457e 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2001,6 +2001,7 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
Elf64_External_Chdr *echdr
= (Elf64_External_Chdr *) contents;
bfd_put_32 (abfd, ELFCOMPRESS_ZLIB, &echdr->ch_type);
+ bfd_put_32 (abfd, 0, &echdr->ch_reserved);
bfd_put_64 (abfd, sec->size, &echdr->ch_size);
bfd_put_64 (abfd, 1 << sec->alignment_power,
&echdr->ch_addralign);
@@ -2251,6 +2252,7 @@ bfd_convert_section_contents (bfd *ibfd, sec_ptr isec, bfd *obfd,
{
Elf64_External_Chdr *echdr = (Elf64_External_Chdr *) contents;
bfd_put_32 (obfd, ELFCOMPRESS_ZLIB, &echdr->ch_type);
+ bfd_put_32 (obfd, 0, &echdr->ch_reserved);
bfd_put_64 (obfd, chdr.ch_size, &echdr->ch_size);
bfd_put_64 (obfd, chdr.ch_addralign, &echdr->ch_addralign);
}
--
2.4.3