+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
 
     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:
 
--- /dev/null
+#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
+#...
 
--- /dev/null
+       .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
 
--- /dev/null
+#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
+#...
 
--- /dev/null
+       .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
 
--- /dev/null
+       .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
 
     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"
+       run_dump_test "note-3-32"
     }
 }