aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-08-08 21:00:04 -0700
committerH.J. Lu <hjl.tools@gmail.com>2018-08-08 21:00:18 -0700
commit6404ab993797d1d6cd3d9e97cc281e3cb6226c12 (patch)
treeeee63602c3e8fdeca481656be671146ad4bbbaf1 /binutils
parentf40f4a11d12025d18be2b0f9072f6ddcc94d3cdb (diff)
downloadgdb-6404ab993797d1d6cd3d9e97cc281e3cb6226c12.zip
gdb-6404ab993797d1d6cd3d9e97cc281e3cb6226c12.tar.gz
gdb-6404ab993797d1d6cd3d9e97cc281e3cb6226c12.tar.bz2
Convert .note.gnu.property section between ELF32 and ELF64
.note.gnu.property section has different alignments and section sizes for 32-bit and 64-bit ELF binaries. This patch updated bfd_convert_section_size and bfd_convert_section_contents to properly convert .note.gnu.property section between 32-bit and 64-bit ELF binaries. bfd/ PR binutils/23494 * bfd.c (bfd_convert_section_size): Check BFD_DECOMPRESS after calling _bfd_elf_convert_gnu_property_size to convert .note.gnu.property section size. (bfd_convert_section_contents): Check BFD_DECOMPRESS after calling _bfd_elf_convert_gnu_properties to convert .note.gnu.property section. * elf-bfd.h (_bfd_elf_convert_gnu_property_size): New prototype. (_bfd_elf_convert_gnu_properties): Likewise. * elf-properties.c (elf_get_gnu_property_section_size): New function. (elf_write_gnu_properties): Likewise. (_bfd_elf_convert_gnu_property_size): Likewise. (_bfd_elf_convert_gnu_properties): Likewise. (_bfd_elf_link_setup_gnu_properties): Use elf_get_gnu_property_section_size and elf_write_gnu_properties. binutils/ PR binutils/23494 * testsuite/binutils-all/x86-64/pr23494a-x32.d: New file. * testsuite/binutils-all/x86-64/pr23494a.d: Likewise. * testsuite/binutils-all/x86-64/pr23494a.s: Likewise. * testsuite/binutils-all/x86-64/pr23494b-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494b.d: Likewise. * testsuite/binutils-all/x86-64/pr23494b.s: Likewise. * testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494c.d: Likewise. * testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise. * testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog14
-rw-r--r--binutils/testsuite/binutils-all/x86-64/pr23494a-x32.d11
-rw-r--r--binutils/testsuite/binutils-all/x86-64/pr23494a.d11
-rw-r--r--binutils/testsuite/binutils-all/x86-64/pr23494a.s92
-rw-r--r--binutils/testsuite/binutils-all/x86-64/pr23494b-x32.d5
-rw-r--r--binutils/testsuite/binutils-all/x86-64/pr23494b.d5
-rw-r--r--binutils/testsuite/binutils-all/x86-64/pr23494b.s30
-rw-r--r--binutils/testsuite/binutils-all/x86-64/pr23494c-x32.d10
-rw-r--r--binutils/testsuite/binutils-all/x86-64/pr23494c.d10
-rw-r--r--binutils/testsuite/binutils-all/x86-64/pr23494d-x32.d11
-rw-r--r--binutils/testsuite/binutils-all/x86-64/pr23494d.d11
11 files changed, 210 insertions, 0 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 6ed758b..8dd2d78 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,17 @@
+2018-08-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/23494
+ * testsuite/binutils-all/x86-64/pr23494a-x32.d: New file.
+ * testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
+ * testsuite/binutils-all/x86-64/pr23494a.s: Likewise.
+ * testsuite/binutils-all/x86-64/pr23494b-x32.d: Likewise.
+ * testsuite/binutils-all/x86-64/pr23494b.d: Likewise.
+ * testsuite/binutils-all/x86-64/pr23494b.s: Likewise.
+ * testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
+ * testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
+ * testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
+ * testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
+
2018-08-08 Kevin Buettner <kevinb@redhat.com>
* dwarf.c (decode_location_expresion): Add case for
diff --git a/binutils/testsuite/binutils-all/x86-64/pr23494a-x32.d b/binutils/testsuite/binutils-all/x86-64/pr23494a-x32.d
new file mode 100644
index 0000000..6171e3c
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr23494a-x32.d
@@ -0,0 +1,11 @@
+#source: pr23494a.s
+#PROG: objcopy
+#as: --x32
+#objcopy: -O elf64-x86-64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
+ x86 ISA needed: SSE3, SSE4_1
diff --git a/binutils/testsuite/binutils-all/x86-64/pr23494a.d b/binutils/testsuite/binutils-all/x86-64/pr23494a.d
new file mode 100644
index 0000000..5e8b0b6
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr23494a.d
@@ -0,0 +1,11 @@
+#source: pr23494a.s
+#PROG: objcopy
+#as: --64 -defsym __64_bit__=1
+#objcopy: -O elf32-x86-64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
+ x86 ISA needed: SSE3, SSE4_1
diff --git a/binutils/testsuite/binutils-all/x86-64/pr23494a.s b/binutils/testsuite/binutils-all/x86-64/pr23494a.s
new file mode 100644
index 0000000..77185bd
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr23494a.s
@@ -0,0 +1,92 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length. */
+ .long 3f - 1f /* data length. */
+ /* NT_GNU_PROPERTY_TYPE_0 */
+ .long 5 /* note type. */
+0:
+ .asciz "GNU" /* vendor name. */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ /* GNU_PROPERTY_X86_ISA_1_USED */
+ .long 0xc0000000 /* pr_type. */
+ .long 5f - 4f /* pr_datasz. */
+4:
+ .long 0xa
+5:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+3:
+
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length. */
+ .long 3f - 1f /* data length. */
+ /* NT_GNU_PROPERTY_TYPE_0 */
+ .long 5 /* note type. */
+0:
+ .asciz "GNU" /* vendor name. */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ /* GNU_PROPERTY_X86_ISA_1_NEEDED */
+ .long 0xc0000001 /* pr_type. */
+ .long 5f - 4f /* pr_datasz. */
+4:
+ .long 0xa0
+5:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+3:
+
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length. */
+ .long 3f - 1f /* data length. */
+ /* NT_GNU_PROPERTY_TYPE_0 */
+ .long 5 /* note type. */
+0:
+ .asciz "GNU" /* vendor name. */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ /* GNU_PROPERTY_X86_ISA_1_USED */
+ .long 0xc0000000 /* pr_type. */
+ .long 5f - 4f /* pr_datasz. */
+4:
+ .long 0xa0
+5:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+3:
diff --git a/binutils/testsuite/binutils-all/x86-64/pr23494b-x32.d b/binutils/testsuite/binutils-all/x86-64/pr23494b-x32.d
new file mode 100644
index 0000000..e0b351b
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr23494b-x32.d
@@ -0,0 +1,5 @@
+#source: pr23494a.s
+#PROG: objcopy
+#as: --x32
+#objcopy: -O elf64-x86-64 -R .note.gnu.property
+#readelf: -n
diff --git a/binutils/testsuite/binutils-all/x86-64/pr23494b.d b/binutils/testsuite/binutils-all/x86-64/pr23494b.d
new file mode 100644
index 0000000..69c5340
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr23494b.d
@@ -0,0 +1,5 @@
+#source: pr23494a.s
+#PROG: objcopy
+#as: --64 -defsym __64_bit__=1
+#objcopy: -O elf32-x86-64 -R .note.gnu.property
+#readelf: -n
diff --git a/binutils/testsuite/binutils-all/x86-64/pr23494b.s b/binutils/testsuite/binutils-all/x86-64/pr23494b.s
new file mode 100644
index 0000000..239477b
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr23494b.s
@@ -0,0 +1,30 @@
+ .section ".note.gnu.property", "a"
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ .long 1f - 0f /* name length. */
+ .long 3f - 1f /* data length. */
+ /* NT_GNU_PROPERTY_TYPE_0 */
+ .long 5 /* note type. */
+0:
+ .asciz "GNU" /* vendor name. */
+1:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+ /* GNU_PROPERTY_X86_ISA_1_USED */
+ .long 0xc0000000 /* pr_type. */
+ .long 5f - 4f /* pr_datasz. */
+4:
+ .long 0xa
+5:
+.ifdef __64_bit__
+ .p2align 3
+.else
+ .p2align 2
+.endif
+3:
diff --git a/binutils/testsuite/binutils-all/x86-64/pr23494c-x32.d b/binutils/testsuite/binutils-all/x86-64/pr23494c-x32.d
new file mode 100644
index 0000000..3f213dc
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr23494c-x32.d
@@ -0,0 +1,10 @@
+#source: pr23494b.s
+#PROG: objcopy
+#as: --x32
+#objcopy: -O elf64-x86-64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: 586, SSE
diff --git a/binutils/testsuite/binutils-all/x86-64/pr23494c.d b/binutils/testsuite/binutils-all/x86-64/pr23494c.d
new file mode 100644
index 0000000..62500a8
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr23494c.d
@@ -0,0 +1,10 @@
+#source: pr23494b.s
+#PROG: objcopy
+#as: --64 -defsym __64_bit__=1
+#objcopy: -O elf32-x86-64
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: 586, SSE
diff --git a/binutils/testsuite/binutils-all/x86-64/pr23494d-x32.d b/binutils/testsuite/binutils-all/x86-64/pr23494d-x32.d
new file mode 100644
index 0000000..106e6c0
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr23494d-x32.d
@@ -0,0 +1,11 @@
+#PROG: objcopy
+#source: pr23494a.s
+#as: --x32
+#objcopy: -O elf64-x86-64 --decompress-debug-sections
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
+ x86 ISA needed: SSE3, SSE4_1
diff --git a/binutils/testsuite/binutils-all/x86-64/pr23494d.d b/binutils/testsuite/binutils-all/x86-64/pr23494d.d
new file mode 100644
index 0000000..bcbcbc5
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr23494d.d
@@ -0,0 +1,11 @@
+#PROG: objcopy
+#source: pr23494a.s
+#as: --64 -defsym __64_bit__=1
+#objcopy: -O elf32-x86-64 --decompress-debug-sections
+#readelf: -n
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0
+ Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
+ x86 ISA needed: SSE3, SSE4_1