Add test of V2 GNU build attribute notes.
authorNick Clifton <nickc@redhat.com>
Thu, 17 Aug 2017 13:49:01 +0000 (14:49 +0100)
committerNick Clifton <nickc@redhat.com>
Thu, 17 Aug 2017 13:51:31 +0000 (14:51 +0100)
* testsuite/binutils-all/note-3-64.s: New test.  Checks assembly
and decoding of version2 GNU build attribute notes.
* testsuite/binutils-all/note-3-32.s: New test.  32-bit version of
the above test.
* testsuite/binutils-all/note-3-64.d: New test driver.
* testsuite/binutils-all/note-3-32.d: New test driver.
* testsuite/binutils-all/objcopy.exp: Run the new test.
* readelf.c (is_64bit_abs_reloc): Add R_SPARC_64.

binutils/ChangeLog
binutils/readelf.c
binutils/testsuite/binutils-all/note-3-32.d [new file with mode: 0644]
binutils/testsuite/binutils-all/note-3-32.s [new file with mode: 0644]
binutils/testsuite/binutils-all/note-3-64.d [new file with mode: 0644]
binutils/testsuite/binutils-all/note-3-64.s [new file with mode: 0644]
binutils/testsuite/binutils-all/note-3.32.s [new file with mode: 0644]
binutils/testsuite/binutils-all/objcopy.exp

index 1e37ac6..3467f09 100644 (file)
@@ -1,3 +1,14 @@
+2017-08-17  Nick Clifton  <nickc@redhat.com>
+
+       * testsuite/binutils-all/note-3-64.s: New test.  Checks assembly
+       and decoding of version2 GNU build attribute notes.
+       * testsuite/binutils-all/note-3-32.s: New test.  32-bit version of
+       the above test.
+       * testsuite/binutils-all/note-3-64.d: New test driver.
+       * testsuite/binutils-all/note-3-32.d: New test driver.
+       * testsuite/binutils-all/objcopy.exp: Run the new test.
+       * readelf.c (is_64bit_abs_reloc): Add R_SPARC_64.
+
 2017-08-14  Gustavo Romero  <gromero@linux.vnet.ibm.com>
 
        * readelf.c (get_note_type): Handle PPC note types available
 2017-08-14  Gustavo Romero  <gromero@linux.vnet.ibm.com>
 
        * readelf.c (get_note_type): Handle PPC note types available
index 4bd68f2..1992126 100644 (file)
@@ -12296,7 +12296,8 @@ is_64bit_abs_reloc (unsigned int reloc_type)
     case EM_SPARC32PLUS:
     case EM_SPARCV9:
     case EM_SPARC:
     case EM_SPARC32PLUS:
     case EM_SPARCV9:
     case EM_SPARC:
-      return reloc_type == 54; /* R_SPARC_UA64.  */
+      return reloc_type == 32 /* R_SPARC_64.  */
+       || reloc_type == 54; /* R_SPARC_UA64.  */
     case EM_X86_64:
     case EM_L1OM:
     case EM_K1OM:
     case EM_X86_64:
     case EM_L1OM:
     case EM_K1OM:
diff --git a/binutils/testsuite/binutils-all/note-3-32.d b/binutils/testsuite/binutils-all/note-3-32.d
new file mode 100644 (file)
index 0000000..fa571b0
--- /dev/null
@@ -0,0 +1,18 @@
+#PROG: objcopy
+#readelf: --notes --wide
+#objcopy: --merge-notes
+#name: v2 gnu build attribute notes (32-bit)
+#source: note-3-32.s
+
+#...
+Displaying notes found in: .gnu.build.attributes
+[      ]+Owner[        ]+Data size[    ]+Description
+[      ]+GA\$<version>2p1[     ]+0x0000000.[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100 \(file: note_1.s\)
+[      ]+GA\$<tool>gcc 6.3.1 20161221[         ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\*GOW:0x700[        ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\*<stack prot>off[  ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\*FORTIFY:0xff[     ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\*<PIC>PIC[         ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\!<short enum>false[        ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\*<ABI>0x[0-9a-f]+[         ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+#...
diff --git a/binutils/testsuite/binutils-all/note-3-32.s b/binutils/testsuite/binutils-all/note-3-32.s
new file mode 100644 (file)
index 0000000..4dbbebe
--- /dev/null
@@ -0,0 +1,57 @@
+       .text
+       .org 0x100
+       .global note_1.s
+note_1.s:
+       .word 0
+       
+       .pushsection .gnu.build.attributes, "", %note
+       .balign 4
+
+       .dc.l 8
+       .dc.l 4
+       .dc.l 0x100
+       .asciz "GA$\ 12p1"
+       .dc.l note_1.s
+
+       .dc.l 23
+       .dc.l 0
+       .dc.l 0x100
+       .asciz "GA$\ 5gcc 6.3.1 20161221"
+       .dc.b 0
+
+       .dc.l 10
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x47, 0x4f, 0x57, 0, 0, 0x7, 0
+       .dc.b 0, 0
+
+       .dc.l 6
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0
+       .dc.b 0, 0
+
+       .dc.l 13
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x46, 0x4f, 0x52, 0x54, 0x49, 0x46, 0x59, 0, 0xff, 0
+       .dc.b 0, 0, 0
+
+       .dc.l 6
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x7, 0x2, 0
+       .dc.b 0, 0
+
+       .dc.l 5
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x21, 0x8, 0
+       .dc.b 0, 0, 0
+
+       .dc.l 13
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x6, 0xf2, 0x3, 0x38, 0xee, 0xce, 0xfa, 0x5e, 0x3c, 0
+       .dc.b 0, 0, 0
+       .popsection
diff --git a/binutils/testsuite/binutils-all/note-3-64.d b/binutils/testsuite/binutils-all/note-3-64.d
new file mode 100644 (file)
index 0000000..f048e8b
--- /dev/null
@@ -0,0 +1,18 @@
+#PROG: objcopy
+#readelf: --notes --wide
+#objcopy: --merge-notes
+#name: v2 gnu build attribute notes (64-bit)
+#source: note-3-64.s
+
+#...
+Displaying notes found in: .gnu.build.attributes
+[      ]+Owner[        ]+Data size[    ]+Description
+[      ]+GA\$<version>2p1[     ]+0x0000000.[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100 \(file: note_1.s\)
+[      ]+GA\$<tool>gcc 6.3.1 20161221[         ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\*GOW:0x700[        ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\*<stack prot>off[  ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\*FORTIFY:0xff[     ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\*<PIC>PIC[         ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\!<short enum>false[        ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+[      ]+GA\*<ABI>0x[0-9a-f]+[         ]+0x00000000[   ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[  ]+Applies from offset 0x100
+#...
diff --git a/binutils/testsuite/binutils-all/note-3-64.s b/binutils/testsuite/binutils-all/note-3-64.s
new file mode 100644 (file)
index 0000000..42f3e48
--- /dev/null
@@ -0,0 +1,57 @@
+       .text
+       .org 0x100
+       .global note_1.s
+note_1.s:
+       .word 0
+       
+       .pushsection .gnu.build.attributes, "", %note
+       .balign 4
+
+       .dc.l 8
+       .dc.l 8
+       .dc.l 0x100
+       .asciz "GA$\ 12p1"
+       .8byte note_1.s
+
+       .dc.l 23
+       .dc.l 0
+       .dc.l 0x100
+       .asciz "GA$\ 5gcc 6.3.1 20161221"
+       .dc.b 0
+
+       .dc.l 10
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x47, 0x4f, 0x57, 0, 0, 0x7, 0
+       .dc.b 0, 0
+
+       .dc.l 6
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0
+       .dc.b 0, 0
+
+       .dc.l 13
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x46, 0x4f, 0x52, 0x54, 0x49, 0x46, 0x59, 0, 0xff, 0
+       .dc.b 0, 0, 0
+
+       .dc.l 6
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x7, 0x2, 0
+       .dc.b 0, 0
+
+       .dc.l 5
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x21, 0x8, 0
+       .dc.b 0, 0, 0
+
+       .dc.l 13
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x6, 0xf2, 0x3, 0x38, 0xee, 0xce, 0xfa, 0x5e, 0x3c, 0
+       .dc.b 0, 0, 0
+       .popsection
diff --git a/binutils/testsuite/binutils-all/note-3.32.s b/binutils/testsuite/binutils-all/note-3.32.s
new file mode 100644 (file)
index 0000000..84d8c89
--- /dev/null
@@ -0,0 +1,67 @@
+       .text
+       .org 0x100
+       .global note1.s
+note1.s:
+       .word 0
+       
+       .pushsection .gnu.build.attributes, "", %note
+       .balign 4
+
+       .dc.l 8
+       .dc.l 8
+       .dc.l 0x100
+       .asciz "GA$\ 12p1"
+       .quad note_1.s
+
+       .dc.l 23
+       .dc.l 0
+       .dc.l 0x100
+       .asciz "GA$\ 5gcc 6.3.1 20161221"
+       .dc.b 0
+
+       .dc.l 10
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x47, 0x4f, 0x57, 0, 0, 0x7, 0
+       .dc.b 0, 0
+
+       .dc.l 6
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0
+       .dc.b 0, 0
+
+       .dc.l 13
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x46, 0x4f, 0x52, 0x54, 0x49, 0x46, 0x59, 0, 0xff, 0
+       .dc.b 0, 0, 0
+
+       .dc.l 6
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x7, 0x2, 0
+       .dc.b 0, 0
+
+       .dc.l 5
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x21, 0x8, 0
+       .dc.b 0, 0, 0
+
+       .dc.l 13
+       .dc.l 0
+       .dc.l 0x100
+       .dc.b 0x47, 0x41, 0x2a, 0x6, 0xf2, 0x3, 0x38, 0xee, 0xce, 0xfa, 0x5e, 0x3c, 0
+       .dc.b 0, 0, 0
+
+       .pushsection .note.gnu.property, "a", %note
+       .balign 4
+       .dc.l 4
+       .dc.l 32
+       .dc.l 0x5
+       .asciz "GNU"
+       .dc.b 0, 0, 0, 0xc0, 0x4, 0, 0, 0
+       .dc.b 0, 0x6, 0, 0, 0, 0, 0, 0
+       .dc.b 0x1, 0, 0, 0xc0, 0x4, 0, 0, 0
+       .dc.b 0, 0x6, 0, 0, 0, 0, 0, 0
index 14e8f1d..ef62edf 100644 (file)
@@ -1056,8 +1056,10 @@ if [is_elf_format] {
     run_dump_test "note-1"
     if [is_elf64 tmpdir/bintest.o] {
        run_dump_test "note-2-64"
     run_dump_test "note-1"
     if [is_elf64 tmpdir/bintest.o] {
        run_dump_test "note-2-64"
+       run_dump_test "note-3-64"
     } else {
        run_dump_test "note-2-32"
     } else {
        run_dump_test "note-2-32"
+       run_dump_test "note-3-32"
     }
 }
 
     }
 }