summaryrefslogtreecommitdiff
path: root/binutils/testsuite
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2018-01-03 10:28:33 +0000
committerNick Clifton <nickc@redhat.com>2018-01-03 10:30:07 +0000
commit6f156d7a4ad1c245b357dc50f63f3564d397839e (patch)
treea247aad883eb6ba6eeb0c9715c218527fc25c869 /binutils/testsuite
parent9f757bf7fcb8834ead780e0c4a76d6029b1402c2 (diff)
Add support for v3 binary annotation notes.
I am checking in the attached patch which updates the binutils support for version 3 binary annotation notes. (Version 3 adds an end address to the ranges covered by the notes, so that it is possible to detect gaps in the coverage). This patch also stops the note merging feature of objcopy from executing if the notes have relocations against them. This makes the code simpler, and prevents the problems with architectures which have unusual relocation management issues. * objcopy.c (objcopy_internal_note): New structure. (gap_exists): New function. (is_open_note): New function. (is_func_note): New function. (is_64bit): New function. (merge_gnu_build_notes): Handle v3 notes. Do not merge if there are relocations against the notes. * readelf.c (get_note_type): Use short names for build attribute notes. (print_symbol_for_build_attribute): Rename to get_symbol_for_build_attribute. Returns the found symbol rather than printing it. (print_gnu_build_attribute_description): Maintain address ranges for function notes as well as global notes. Handle v3 notes. (print_gnu_build_attribute_name): Use more space for printing the name in wide mode. * testsuite/binutils-all/note-2-32.s: Use .dc.l instead of .word. Eliminate symbol references in order to remove the need for relocations. * testsuite/binutils-all/note-2-64.s: Likewise. * testsuite/binutils-all/note-3-32.s: Add a size to the note_1 symbol. * testsuite/binutils-all/note-3-64.s: Likewise. * testsuite/binutils-all/mips/mips-note-2r-n32.d: Update expected output. * testsuite/binutils-all/mips/mips-note-2r-n64.d: Likewise. * testsuite/binutils-all/mips/mips-note-2r.d: Likewise. * testsuite/binutils-all/note-2-32.d: Likewise. * testsuite/binutils-all/note-2-64.d: Likewise. * testsuite/binutils-all/note-3-32.d: Likewise. * testsuite/binutils-all/note-3-64.d: Likewise. * testsuite/binutils-all/note-4-64.s: New test. Checks v3 notes. * testsuite/binutils-all/note-4-32.s: New test. * testsuite/binutils-all/note-4-64.d: New test result file. * testsuite/binutils-all/note-4-32.d: New test result file.
Diffstat (limited to 'binutils/testsuite')
-rw-r--r--binutils/testsuite/binutils-all/mips/mips-note-2r-n32.d6
-rw-r--r--binutils/testsuite/binutils-all/mips/mips-note-2r-n64.d10
-rw-r--r--binutils/testsuite/binutils-all/mips/mips-note-2r.d6
-rw-r--r--binutils/testsuite/binutils-all/note-2-32.d16
-rw-r--r--binutils/testsuite/binutils-all/note-2-32.s18
-rw-r--r--binutils/testsuite/binutils-all/note-2-64.d16
-rw-r--r--binutils/testsuite/binutils-all/note-2-64.s15
-rw-r--r--binutils/testsuite/binutils-all/note-3-32.d16
-rw-r--r--binutils/testsuite/binutils-all/note-3-32.s1
-rw-r--r--binutils/testsuite/binutils-all/note-3-64.d16
-rw-r--r--binutils/testsuite/binutils-all/note-3-64.s1
-rw-r--r--binutils/testsuite/binutils-all/note-4-32.d19
-rw-r--r--binutils/testsuite/binutils-all/note-4-32.s74
-rw-r--r--binutils/testsuite/binutils-all/note-4-64.d19
-rw-r--r--binutils/testsuite/binutils-all/note-4-64.s78
-rw-r--r--binutils/testsuite/binutils-all/objcopy.exp2
16 files changed, 250 insertions, 63 deletions
diff --git a/binutils/testsuite/binutils-all/mips/mips-note-2r-n32.d b/binutils/testsuite/binutils-all/mips/mips-note-2r-n32.d
index caf99722a1..e76466eb94 100644
--- a/binutils/testsuite/binutils-all/mips/mips-note-2r-n32.d
+++ b/binutils/testsuite/binutils-all/mips/mips-note-2r-n32.d
@@ -5,7 +5,5 @@
#as: -n32 -mips3
#source: ../note-2-32.s
-Relocation section '\.rela\.gnu\.build\.attributes' at offset .* contains 2 entries:
- Offset Info Type Sym\.Value Sym\. Name \+ Addend
-00000010 ......02 R_MIPS_32 00000100 note1\.s \+ 0
-0000006c ......02 R_MIPS_32 00000104 note2\.s \+ 0
+There are no relocations in this file.
+#...
diff --git a/binutils/testsuite/binutils-all/mips/mips-note-2r-n64.d b/binutils/testsuite/binutils-all/mips/mips-note-2r-n64.d
index 0fbcc390a8..033dd9b5b0 100644
--- a/binutils/testsuite/binutils-all/mips/mips-note-2r-n64.d
+++ b/binutils/testsuite/binutils-all/mips/mips-note-2r-n64.d
@@ -5,11 +5,5 @@
#as: -64 -mips3
#source: ../note-2-64.s
-Relocation section '\.rela\.gnu\.build\.attributes' at offset .* contains 2 entries:
- Offset Info Type Sym\. Value Sym\. Name \+ Addend
-000000000010 ....00000012 R_MIPS_64 0000000000000100 note1\.s \+ 0
- Type2: R_MIPS_NONE
- Type3: R_MIPS_NONE
-000000000070 ....00000012 R_MIPS_64 0000000000000104 note2\.s \+ 0
- Type2: R_MIPS_NONE
- Type3: R_MIPS_NONE
+There are no relocations in this file.
+#...
diff --git a/binutils/testsuite/binutils-all/mips/mips-note-2r.d b/binutils/testsuite/binutils-all/mips/mips-note-2r.d
index c025727cf6..c130528936 100644
--- a/binutils/testsuite/binutils-all/mips/mips-note-2r.d
+++ b/binutils/testsuite/binutils-all/mips/mips-note-2r.d
@@ -5,7 +5,5 @@
#as: -32
#source: ../note-2-32.s
-Relocation section '\.rel\.gnu\.build\.attributes' at offset .* contains 2 entries:
- Offset Info Type Sym\.Value Sym\. Name
-00000010 ......02 R_MIPS_32 00000100 note1\.s
-0000006c ......02 R_MIPS_32 00000104 note2\.s
+There are no relocations in this file.
+#...
diff --git a/binutils/testsuite/binutils-all/note-2-32.d b/binutils/testsuite/binutils-all/note-2-32.d
index 8deb7f6c93..a6840322e0 100644
--- a/binutils/testsuite/binutils-all/note-2-32.d
+++ b/binutils/testsuite/binutils-all/note-2-32.d
@@ -6,12 +6,12 @@
#...
Owner Data size Description
-[ ]+\$<version>1[ ]+0x00000004[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 \(file: note1.s\)
-[ ]+\$<tool>gcc 7.0.1[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
-[ ]+\+<stack prot>true[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
-[ ]+\*<PIC>static[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
-[ ]+\*<ABI>0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
-[ ]+\$<version>1[ ]+0x00000004[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\)
-[ ]+!<stack prot>false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10.
-[ ]+\*<PIC>pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies to func at 0x10. \(func: func1\)
+[ ]+\$<version>1[ ]+0x00000004[ ]+OPEN[ ]+Applies to region from 0x100 \(note1.s\)
+[ ]+\$<tool>gcc 7.0.1[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100
+[ ]+\+<stack prot>true[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100
+[ ]+\*<PIC>static[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100
+[ ]+\*<ABI>0x0[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100
+[ ]+\$<version>1[ ]+0x00000004[ ]+OPEN[ ]+Applies to region from 0x104 \(note2.s\)
+[ ]+!<stack prot>false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x104
+[ ]+\*<PIC>pic[ ]+0x00000004[ ]+func[ ]+Applies to region from 0x104 \(func1\)
#...
diff --git a/binutils/testsuite/binutils-all/note-2-32.s b/binutils/testsuite/binutils-all/note-2-32.s
index 9aed3df346..7b025ae8de 100644
--- a/binutils/testsuite/binutils-all/note-2-32.s
+++ b/binutils/testsuite/binutils-all/note-2-32.s
@@ -2,7 +2,7 @@
.org 0x100
.global note1.s
note1.s:
- .word 0
+ .dc.l 0
.pushsection .gnu.build.attributes, "0x100000", %note
.balign 4
@@ -10,7 +10,7 @@ note1.s:
.dc.l 4
.dc.l 0x100
.asciz "$1"
- .dc.l note1.s
+ .dc.l 0x100
.dc.l 12
.dc.l 0
@@ -39,14 +39,14 @@ note1.s:
note2.s:
.type func1, STT_FUNC
func1:
- .word 0x100
+ .dc.l 0x100
.pushsection .gnu.build.attributes, "0x100000", %note
.dc.l 4
.dc.l 4
.dc.l 0x100
.asciz "$1"
- .dc.l note2.s
+ .dc.l 0x104
.dc.l 12
.dc.l 0
@@ -60,26 +60,28 @@ func1:
.dc.b 0
.dc.l 4
- .dc.l 0
+ .dc.l 4
.dc.l 0x101
.dc.b 0x2a, 0x7, 1, 0
-
+ .dc.l 0x104
+
.dc.l 4
.dc.l 0
.dc.l 0x100
.dc.b 0x2a, 0x6, 0, 0
.popsection
+
.global note3.s
note3.s:
- .word 0x100
+ .dc.l 0x100
.pushsection .gnu.build.attributes, "0x100000", %note
.dc.l 4
.dc.l 4
.dc.l 0x100
.asciz "$1"
- .dc.l note3.s
+ .dc.l 0x108
.dc.l 12
.dc.l 0
diff --git a/binutils/testsuite/binutils-all/note-2-64.d b/binutils/testsuite/binutils-all/note-2-64.d
index f9be89756a..17917d59c6 100644
--- a/binutils/testsuite/binutils-all/note-2-64.d
+++ b/binutils/testsuite/binutils-all/note-2-64.d
@@ -10,12 +10,12 @@
#...
Owner Data size Description
-[ ]+\$<version>1[ ]+0x00000008[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 \(file: note1.s\)
-[ ]+\$<tool>gcc 7.0.1[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
-[ ]+\+<stack prot>true[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
-[ ]+\*<PIC>static[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
-[ ]+\*<ABI>0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
-[ ]+\$<version>1[ ]+0x00000008[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\)
-[ ]+!<stack prot>false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10.
-[ ]+\*<PIC>pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies to func at 0x10. \(func: func1\)
+[ ]+\$<version>1[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x100 \(note1.s\)
+[ ]+\$<tool>gcc 7.0.1[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100
+[ ]+\+<stack prot>true[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100
+[ ]+\*<PIC>static[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100
+[ ]+\*<ABI>0x0[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100
+[ ]+\$<version>1[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x104 \(note2.s\)
+[ ]+!<stack prot>false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x104
+[ ]+\*<PIC>pic[ ]+0x00000008[ ]+func[ ]+Applies to region from 0x104 \(func1\)
#...
diff --git a/binutils/testsuite/binutils-all/note-2-64.s b/binutils/testsuite/binutils-all/note-2-64.s
index 885e947760..02b84e4371 100644
--- a/binutils/testsuite/binutils-all/note-2-64.s
+++ b/binutils/testsuite/binutils-all/note-2-64.s
@@ -2,7 +2,7 @@
.org 0x100
.global note1.s
note1.s:
- .word 0
+ .dc.l 0
.pushsection .gnu.build.attributes, "0x100000", %note
.balign 4
@@ -10,7 +10,7 @@ note1.s:
.dc.l 8
.dc.l 0x100
.asciz "$1"
- .8byte note1.s
+ .8byte 0x100
.dc.l 12
.dc.l 0
@@ -40,14 +40,14 @@ note2.s:
.global func1
.type func1, STT_FUNC
func1:
- .word 0x100
+ .dc.l 0x100
.pushsection .gnu.build.attributes, "0x100000", %note
.dc.l 4
.dc.l 8
.dc.l 0x100
.asciz "$1"
- .8byte note2.s
+ .8byte 0x104
.dc.l 12
.dc.l 0
@@ -61,9 +61,10 @@ func1:
.dc.b 0
.dc.l 4
- .dc.l 0
+ .dc.l 8
.dc.l 0x101
.dc.b 0x2a, 0x7, 1, 0
+ .8byte 0x104
.dc.l 4
.dc.l 0
@@ -74,14 +75,14 @@ func1:
.global note3.s
note3.s:
- .word 0x100
+ .dc.l 0x100
.pushsection .gnu.build.attributes, "0x100000", %note
.dc.l 4
.dc.l 8
.dc.l 0x100
.asciz "$1"
- .8byte note3.s
+ .8byte 0x108
.dc.l 12
.dc.l 0
diff --git a/binutils/testsuite/binutils-all/note-3-32.d b/binutils/testsuite/binutils-all/note-3-32.d
index fa571b0a38..e35e9cc270 100644
--- a/binutils/testsuite/binutils-all/note-3-32.d
+++ b/binutils/testsuite/binutils-all/note-3-32.d
@@ -7,12 +7,12 @@
#...
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
+[ ]+GA\$<version>2p1[ ]+0x0000000.[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 \(note_1.s\)
+[ ]+GA\$<tool>gcc 6.3.1 20161221[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\*<stack prot>off[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\*<PIC>PIC[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\!<short enum>false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\*<ABI>0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
#...
diff --git a/binutils/testsuite/binutils-all/note-3-32.s b/binutils/testsuite/binutils-all/note-3-32.s
index 4dbbebea2b..e2e06f9c79 100644
--- a/binutils/testsuite/binutils-all/note-3-32.s
+++ b/binutils/testsuite/binutils-all/note-3-32.s
@@ -1,6 +1,7 @@
.text
.org 0x100
.global note_1.s
+ .size note_1.s, 0x22
note_1.s:
.word 0
diff --git a/binutils/testsuite/binutils-all/note-3-64.d b/binutils/testsuite/binutils-all/note-3-64.d
index f048e8b86f..9899ea1609 100644
--- a/binutils/testsuite/binutils-all/note-3-64.d
+++ b/binutils/testsuite/binutils-all/note-3-64.d
@@ -7,12 +7,12 @@
#...
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
+[ ]+GA\$<version>2p1[ ]+0x0000000.[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122 \(note_1.s\)
+[ ]+GA\$<tool>gcc 6.3.1 20161221[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\*<stack prot>off[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\*<PIC>PIC[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\!<short enum>false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
+[ ]+GA\*<ABI>0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x122
#...
diff --git a/binutils/testsuite/binutils-all/note-3-64.s b/binutils/testsuite/binutils-all/note-3-64.s
index 42f3e48422..e7d27d28de 100644
--- a/binutils/testsuite/binutils-all/note-3-64.s
+++ b/binutils/testsuite/binutils-all/note-3-64.s
@@ -1,6 +1,7 @@
.text
.org 0x100
.global note_1.s
+ .size note_1.s, 0x22
note_1.s:
.word 0
diff --git a/binutils/testsuite/binutils-all/note-4-32.d b/binutils/testsuite/binutils-all/note-4-32.d
new file mode 100644
index 0000000000..567af908f2
--- /dev/null
+++ b/binutils/testsuite/binutils-all/note-4-32.d
@@ -0,0 +1,19 @@
+#PROG: objcopy
+#readelf: --notes --wide
+#objcopy: --merge-notes
+#name: v3 gnu build attribute notes (32-bit)
+#source: note-4-32.s
+
+#...
+Displaying notes found in: .gnu.build.attributes
+[ ]+Owner[ ]+Data size[ ]+Description
+[ ]+GA\$<version>3p3[ ]+0x00000008[ ]+OPEN[ ]+Applies to region from 0x100 to 0x110 \(note_4.s\)
+[ ]+GA\$<tool>gcc 7.2.1 20170915[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x110
+[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x110
+[ ]+GA\*<stack prot>off[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x110
+[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x110
+[ ]+GA\*<PIC>PIC[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x110
+[ ]+GA\!<short enum>false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x110
+[ ]+GA\*<ABI>0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x110
+[ ]+GA\*<stack prot>strong[ ]+0x00000008[ ]+func[ ]+Applies to region from 0x108 to 0x10c.*
+#...
diff --git a/binutils/testsuite/binutils-all/note-4-32.s b/binutils/testsuite/binutils-all/note-4-32.s
new file mode 100644
index 0000000000..09c5652f1c
--- /dev/null
+++ b/binutils/testsuite/binutils-all/note-4-32.s
@@ -0,0 +1,74 @@
+ .text
+ .org 0x100
+note_4.s:
+ .dc.l 0
+ .dc.l 0
+
+ .type bar, STT_FUNC
+bar:
+ .dc.l 0
+bar_end:
+ .dc.l 0
+note_4.s_end:
+
+ .pushsection .gnu.build.attributes, "", %note
+ .balign 4
+
+ .dc.l 8
+ .dc.l 8
+ .dc.l 0x100
+ .asciz "GA$3p3"
+ .dc.l note_4.s
+ .dc.l note_4.s_end
+
+ .dc.l 23
+ .dc.l 0
+ .dc.l 0x100
+ .asciz "GA$gcc 7.2.1 20170915"
+ .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
+
+ .dc.l 6
+ .dc.l 8
+ .dc.l 0x101
+ .dc.b 0x47, 0x41, 0x2a, 0x2, 0x3, 0
+ .dc.b 0, 0
+ .dc.l bar
+ .dc.l bar_end
+
+ .popsection
diff --git a/binutils/testsuite/binutils-all/note-4-64.d b/binutils/testsuite/binutils-all/note-4-64.d
new file mode 100644
index 0000000000..f81c9c41b9
--- /dev/null
+++ b/binutils/testsuite/binutils-all/note-4-64.d
@@ -0,0 +1,19 @@
+#PROG: objcopy
+#readelf: --notes --wide
+#objcopy: --merge-notes
+#name: v3 gnu build attribute notes (64-bit)
+#source: note-4-64.s
+
+#...
+Displaying notes found in: .gnu.build.attributes
+[ ]+Owner[ ]+Data size[ ]+Description
+[ ]+GA\$<version>3p3[ ]+0x00000010[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120 \(note_4.s\)
+[ ]+GA\$<tool>gcc 7.2.1 20170915[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120
+[ ]+GA\*GOW:0x700[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120
+[ ]+GA\*<stack prot>off[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120
+[ ]+GA\*FORTIFY:0xff[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120
+[ ]+GA\*<PIC>PIC[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120
+[ ]+GA\!<short enum>false[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120
+[ ]+GA\*<ABI>0x[0-9a-f]+[ ]+0x00000000[ ]+OPEN[ ]+Applies to region from 0x100 to 0x120
+[ ]+GA\*<stack prot>strong[ ]+0x00000010[ ]+func[ ]+Applies to region from 0x110 to 0x11c.*
+#...
diff --git a/binutils/testsuite/binutils-all/note-4-64.s b/binutils/testsuite/binutils-all/note-4-64.s
new file mode 100644
index 0000000000..4f532986b7
--- /dev/null
+++ b/binutils/testsuite/binutils-all/note-4-64.s
@@ -0,0 +1,78 @@
+ .text
+ .org 0x100
+note_4.s:
+ .dc.l 0
+ .dc.l 0
+ .dc.l 0
+ .dc.l 0
+
+ .type bar, @function
+bar:
+ .dc.l 0
+ .dc.l 0
+ .dc.l 0
+bar_end:
+ .dc.l 0
+note_4.s_end:
+
+ .pushsection .gnu.build.attributes, "", %note
+ .balign 4
+
+ .dc.l 8
+ .dc.l 16
+ .dc.l 0x100
+ .asciz "GA$3p3"
+ .8byte note_4.s
+ .8byte note_4.s_end
+
+ .dc.l 23
+ .dc.l 0
+ .dc.l 0x100
+ .asciz "GA$gcc 7.2.1 20170915"
+ .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
+
+ .dc.l 6
+ .dc.l 16
+ .dc.l 0x101
+ .dc.b 0x47, 0x41, 0x2a, 0x2, 0x3, 0
+ .dc.b 0, 0
+ .8byte bar
+ .8byte bar_end
+
+ .popsection
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index 8308adcb03..377f88c0e1 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -1056,9 +1056,11 @@ if [is_elf_format] {
if [is_elf64 tmpdir/bintest.o] {
run_dump_test "note-2-64"
run_dump_test "note-3-64"
+ run_dump_test "note-4-64"
} else {
run_dump_test "note-2-32"
run_dump_test "note-3-32"
+ run_dump_test "note-4-32"
}
}