aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-08-09 04:29:43 -0700
committerH.J. Lu <hjl.tools@gmail.com>2018-08-10 08:14:24 -0700
commit9c973a29df61c411e24ce51b13401333c6f6e0e7 (patch)
tree76959877a0940f58891ab88cef1ac2d44e351bcb /bfd
parent11459a79d97842a64961a35472bb8d67ed0fcf22 (diff)
downloadgdb-9c973a29df61c411e24ce51b13401333c6f6e0e7.zip
gdb-9c973a29df61c411e24ce51b13401333c6f6e0e7.tar.gz
gdb-9c973a29df61c411e24ce51b13401333c6f6e0e7.tar.bz2
Always use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE
For GNU_PROPERTY_STACK_SIZE, pr_datasz is the same as align_size, which is 8 bytes for 64-bit ELF binaries and 4 bytes for 32-bit ELF binaries, Use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE to convert .note.gnu.property section. bfd/ PR binutils/23494 * elf-properties.c (elf_get_gnu_property_section_size): Always use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE. (elf_write_gnu_properties): Likewise. binutils/ PR binutils/23494 * testsuite/binutils-all/x86-64/pr23494c.s: New file. * testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elf-properties.c22
2 files changed, 22 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index d4bed23..20aa4f3 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2018-08-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/23494
+ * elf-properties.c (elf_get_gnu_property_section_size): Always
+ use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE.
+ (elf_write_gnu_properties): Likewise.
+
2018-08-08 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/23494
diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c
index 0ac0555..f58bdc0 100644
--- a/bfd/elf-properties.c
+++ b/bfd/elf-properties.c
@@ -320,7 +320,12 @@ elf_get_gnu_property_section_size (elf_property_list *list,
for (; list != NULL; list = list->next)
{
/* There are 4 byte type + 4 byte datasz for each property. */
- size += 4 + 4 + list->property.pr_datasz;
+ unsigned int datasz;
+ if (list->property.pr_type == GNU_PROPERTY_STACK_SIZE)
+ datasz = align_size;
+ else
+ datasz = list->property.pr_datasz;
+ size += 4 + 4 + datasz;
/* Align each property. */
size = (size + (align_size - 1)) & ~(align_size - 1);
}
@@ -336,6 +341,7 @@ elf_write_gnu_properties (bfd *abfd, bfd_byte *contents,
unsigned int align_size)
{
unsigned int descsz;
+ unsigned int datasz;
Elf_External_Note *e_note;
e_note = (Elf_External_Note *) contents;
@@ -350,17 +356,19 @@ elf_write_gnu_properties (bfd *abfd, bfd_byte *contents,
for (; list != NULL; list = list->next)
{
/* There are 4 byte type + 4 byte datasz for each property. */
- bfd_h_put_32 (abfd, list->property.pr_type,
- contents + size);
- bfd_h_put_32 (abfd, list->property.pr_datasz,
- contents + size + 4);
+ if (list->property.pr_type == GNU_PROPERTY_STACK_SIZE)
+ datasz = align_size;
+ else
+ datasz = list->property.pr_datasz;
+ bfd_h_put_32 (abfd, list->property.pr_type, contents + size);
+ bfd_h_put_32 (abfd, datasz, contents + size + 4);
size += 4 + 4;
/* Write out property value. */
switch (list->property.pr_kind)
{
case property_number:
- switch (list->property.pr_datasz)
+ switch (datasz)
{
default:
/* Never should happen. */
@@ -385,7 +393,7 @@ elf_write_gnu_properties (bfd *abfd, bfd_byte *contents,
/* Never should happen. */
abort ();
}
- size += list->property.pr_datasz;
+ size += datasz;
/* Align each property. */
size = (size + (align_size - 1)) & ~ (align_size - 1);