This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Commit: Add test of v2 GNU build attribute notes.
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sourceware dot org
- Date: Thu, 17 Aug 2017 14:48:44 +0100
- Subject: Commit: Add test of v2 GNU build attribute notes.
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=nickc at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EF313750C9
Hi Guys,
Alan pointed out that I had not added a test of the version 2 GNU build
attribute notes, so I am checking in the patch below to do just that.
Whilst testing the patch I found that readelf was not recognising the
R_SPARC_64 reloc, so I have also included a quick fix for that.
Cheers
Nick
binutils/ChangeLog
2017-08-17 Nick Clifton <nickc@redhat.com>
* testsuite/binutils-all/note-3-64.s: New test. Checks assembly
and decoding of version 2 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.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 4bd68f2881..1992126bbb 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -12296,7 +12296,8 @@ is_64bit_abs_reloc (unsigned int reloc_type)
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:
diff --git a/binutils/testsuite/binutils-all/note-3-32.d b/binutils/testsuite/binutils-all/note-3-32.d
new file mode 100644
index 0000000000..fa571b0a38
--- /dev/null
+++ b/binutils/testsuite/binutils-all/note-3-32.d
@@ -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
index 0000000000..4dbbebea2b
--- /dev/null
+++ b/binutils/testsuite/binutils-all/note-3-32.s
@@ -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$2p1"
+ .dc.l note_1.s
+
+ .dc.l 23
+ .dc.l 0
+ .dc.l 0x100
+ .asciz "GA$gcc 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
index 0000000000..f048e8b86f
--- /dev/null
+++ b/binutils/testsuite/binutils-all/note-3-64.d
@@ -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
index 0000000000..42f3e48422
--- /dev/null
+++ b/binutils/testsuite/binutils-all/note-3-64.s
@@ -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$2p1"
+ .8byte note_1.s
+
+ .dc.l 23
+ .dc.l 0
+ .dc.l 0x100
+ .asciz "GA$gcc 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
index 0000000000..84d8c89da0
--- /dev/null
+++ b/binutils/testsuite/binutils-all/note-3.32.s
@@ -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$2p1"
+ .quad note_1.s
+
+ .dc.l 23
+ .dc.l 0
+ .dc.l 0x100
+ .asciz "GA$gcc 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
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index 14e8f1d09f..ef62edfe5d 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -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-3-64"
} else {
run_dump_test "note-2-32"
+ run_dump_test "note-3-32"
}
}