From 714da62f64ef5527a22a3e897f7e21f69e442ade Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 17 Aug 2017 14:49:01 +0100 Subject: [PATCH 1/1] Add test of V2 GNU build attribute notes. * 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 | 11 ++++ binutils/readelf.c | 3 +- binutils/testsuite/binutils-all/note-3-32.d | 18 ++++++ binutils/testsuite/binutils-all/note-3-32.s | 57 ++++++++++++++++++ binutils/testsuite/binutils-all/note-3-64.d | 18 ++++++ binutils/testsuite/binutils-all/note-3-64.s | 57 ++++++++++++++++++ binutils/testsuite/binutils-all/note-3.32.s | 67 +++++++++++++++++++++ binutils/testsuite/binutils-all/objcopy.exp | 2 + 8 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 binutils/testsuite/binutils-all/note-3-32.d create mode 100644 binutils/testsuite/binutils-all/note-3-32.s create mode 100644 binutils/testsuite/binutils-all/note-3-64.d create mode 100644 binutils/testsuite/binutils-all/note-3-64.s create mode 100644 binutils/testsuite/binutils-all/note-3.32.s diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 1e37ac6df7..3467f09d9f 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,14 @@ +2017-08-17 Nick Clifton + + * 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 * readelf.c (get_note_type): Handle PPC note types available 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\$2p1[ ]+0x0000000.[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 \(file: note_1.s\) +[ ]+GA\$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\*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[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 +[ ]+GA\!false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 +[ ]+GA\*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\$2p1[ ]+0x0000000.[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 \(file: note_1.s\) +[ ]+GA\$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\*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[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 +[ ]+GA\!false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 +[ ]+GA\*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" } } -- 2.34.1