diff options
author | Nick Clifton <nickc@redhat.com> | 2017-03-01 11:09:46 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2017-03-01 11:09:46 +0000 |
commit | 9ef920e933bf2ea228c909cf81636e6d9577e51e (patch) | |
tree | c6118c4b931f1d68528ca12ec38e31af6e3b1d46 /binutils/testsuite | |
parent | a7e8b06b8901309632fad842ffd7d90a81447c80 (diff) | |
download | gdb-9ef920e933bf2ea228c909cf81636e6d9577e51e.zip gdb-9ef920e933bf2ea228c909cf81636e6d9577e51e.tar.gz gdb-9ef920e933bf2ea228c909cf81636e6d9577e51e.tar.bz2 |
Add support for displaying and merging GNU_BUILD_NOTEs.
include * elf/common.h (SHF_GNU_BUILD_NOTE): Define.
(NT_GNU_PROPERTY_TYPE_0): Define.
(NT_GNU_BUILD_ATTRIBUTE_OPEN): Define.
(NT_GNU_BUILD_ATTRIBUTE_FUN): Define.
(GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC): Define.
(GNU_BUILD_ATTRIBUTE_TYPE_STRING): Define.
(GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE): Define.
(GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE): Define.
(GNU_BUILD_ATTRIBUTE_VERSION): Define.
(GNU_BUILD_ATTRIBUTE_STACK_PROT): Define.
(GNU_BUILD_ATTRIBUTE_RELRO): Define.
(GNU_BUILD_ATTRIBUTE_STACK_SIZE): Define.
(GNU_BUILD_ATTRIBUTE_TOOL): Define.
(GNU_BUILD_ATTRIBUTE_ABI): Define.
(GNU_BUILD_ATTRIBUTE_PIC): Define.
(NOTE_GNU_PROPERTY_SECTION_NAME): Define.
(GNU_BUILD_ATTRS_SECTION_NAME): Define.
(GNU_PROPERTY_STACK_SIZE): Define.
(GNU_PROPERTY_NO_COPY_ON_PROTECTED): Define.
(GNU_PROPERTY_X86_ISA_1_USED): Define.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Define.
(GNU_PROPERTY_X86_ISA_1_486): Define.
(GNU_PROPERTY_X86_ISA_1_586): Define.
(GNU_PROPERTY_X86_ISA_1_686): Define.
(GNU_PROPERTY_X86_ISA_1_SSE): Define.
(GNU_PROPERTY_X86_ISA_1_SSE2): Define.
(GNU_PROPERTY_X86_ISA_1_SSE3): Define.
(GNU_PROPERTY_X86_ISA_1_SSSE3): Define.
(GNU_PROPERTY_X86_ISA_1_SSE4_1): Define.
(GNU_PROPERTY_X86_ISA_1_SSE4_2): Define.
(GNU_PROPERTY_X86_ISA_1_AVX): Define.
(GNU_PROPERTY_X86_ISA_1_AVX2): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512F): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512CD): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512ER): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512PF): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512VL): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512DQ): Define.
(GNU_PROPERTY_X86_ISA_1_AVX512BW): Define.
binutils* readelf.c (get_note_type): Add support for GNU_BUILD_NOTEs.
(get_gnu_elf_note_type): Add support for GNU_PROPERTY_NOTEs.
(decode_x86_isa): New function.
(print_gnu_property_note): New function.
(print_gnu_note): Handle GNU_PROPERTY_NOTEs.
(print_gnu_build_attribute_description): New function.
(print_gnu_build_attribute_name): New function.
(process_note): Add support for GNU_BUILD_NOTEs.
* objcopy.c (--merge-notes): New command line option.
(copy_options): Add merge-notes.
(copy_usage): Likewise.
(is_merge_note_section): New function.
(merge_gnu_build_notes): New function.
(copy_object): Merge note sections if asked to do so.
(skip_section): Add skip_copy parameter. Add support for skipping
merged note sections.
(copy_relocations_in_section): Update call to skip_section.
(copy_section): Likewise.
(copy_main): Add support for merge-notes option.
* doc/binutils.texi: Document the new option to objcopy.
* NEWS: Mention the new feature.
* testsuite/binutils-all/note-2-32.d: New test. Checks note
merging on 32-bit targets.
* testsuite/binutils-all/note-2-32.s: New test source file.
* testsuite/binutils-all/note-2-64.d: New test. Like note-2-32.d
but for 64-bit targets.
* testsuite/binutils-all/note-2-64.s: New test source file.
* testsuite/binutils-all/objcopy.exp: Run the new test.
Diffstat (limited to 'binutils/testsuite')
-rw-r--r-- | binutils/testsuite/binutils-all/note-2-32.d | 17 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/note-2-32.s | 93 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/note-2-64.d | 17 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/note-2-64.s | 94 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objcopy.exp | 5 |
5 files changed, 226 insertions, 0 deletions
diff --git a/binutils/testsuite/binutils-all/note-2-32.d b/binutils/testsuite/binutils-all/note-2-32.d new file mode 100644 index 0000000..0c0974c --- /dev/null +++ b/binutils/testsuite/binutils-all/note-2-32.d @@ -0,0 +1,17 @@ +#PROG: objcopy +#readelf: --notes --wide +#objcopy: --merge-notes +#name: merge notes section (32-bits) +#source: note-2-32.s + +#... + 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 from offset 0x10. +#... diff --git a/binutils/testsuite/binutils-all/note-2-32.s b/binutils/testsuite/binutils-all/note-2-32.s new file mode 100644 index 0000000..8d9f53a --- /dev/null +++ b/binutils/testsuite/binutils-all/note-2-32.s @@ -0,0 +1,93 @@ + .text + .org 0x100 + .global note1.s +note1.s: + .word 0 + + .pushsection .gnu.build.attributes, "0x100000", %note + .balign 4 + .dc.l 4 + .dc.l 4 + .dc.l 0x100 + .asciz "$1" + .dc.l note1.s + + .dc.l 12 + .dc.l 0 + .dc.l 0x100 + .asciz "$gcc 7.0.1" + + .dc.l 2 + .dc.l 0 + .dc.l 0x100 + .dc.b 0x2b, 0x2 + .dc.b 0, 0 + + .dc.l 3 + .dc.l 0 + .dc.l 0x100 + .dc.b 0x2a, 0x7, 0 + .dc.b 0 + + .dc.l 3 + .dc.l 0 + .dc.l 0x100 + .dc.b 0x2a, 0x6, 0 + .dc.b 0 + .popsection + + + .global note2.s +note2.s: + .word 0x100 + + .pushsection .gnu.build.attributes, "0x100000", %note + .dc.l 4 + .dc.l 4 + .dc.l 0x100 + .asciz "$1" + .dc.l note2.s + + .dc.l 12 + .dc.l 0 + .dc.l 0x100 + .asciz "$gcc 7.0.1" + + .dc.l 2 + .dc.l 0 + .dc.l 0x100 + .dc.b 0x21, 0x2 + .dc.b 0, 0 + + .dc.l 3 + .dc.l 0 + .dc.l 0x101 + .dc.b 0x2a, 0x7, 1 + .dc.b 0 + + .dc.l 3 + .dc.l 0 + .dc.l 0x100 + .dc.b 0x2a, 0x6, 0 + .dc.b 0 + .popsection + + .global note3.s +note3.s: + .word 0x100 + + .pushsection .gnu.build.attributes, "0x100000", %note + .dc.l 4 + .dc.l 4 + .dc.l 0x100 + .asciz "$1" + .dc.l note3.s + + .dc.l 12 + .dc.l 0 + .dc.l 0x100 + .asciz "$gcc 7.0.1" + + .popsection + + diff --git a/binutils/testsuite/binutils-all/note-2-64.d b/binutils/testsuite/binutils-all/note-2-64.d new file mode 100644 index 0000000..3dd4582 --- /dev/null +++ b/binutils/testsuite/binutils-all/note-2-64.d @@ -0,0 +1,17 @@ +#PROG: objcopy +#readelf: --notes --wide +#objcopy: --merge-notes +#name: merge notes section (64-bits) +#source: note-2-64.s + +#... + 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 from offset 0x10. +#... diff --git a/binutils/testsuite/binutils-all/note-2-64.s b/binutils/testsuite/binutils-all/note-2-64.s new file mode 100644 index 0000000..51317c8 --- /dev/null +++ b/binutils/testsuite/binutils-all/note-2-64.s @@ -0,0 +1,94 @@ + .text + .org 0x100 + .global note1.s +note1.s: + .word 0 + + .pushsection .gnu.build.attributes, "0x100000", %note + .balign 4 + .dc.l 4 + .dc.l 8 + .dc.l 0x100 + .asciz "$1" + .8byte note1.s + + .dc.l 12 + .dc.l 0 + .dc.l 0x100 + .asciz "$gcc 7.0.1" + + .dc.l 2 + .dc.l 0 + .dc.l 0x100 + .dc.b 0x2b, 0x2 + .dc.b 0, 0 + + .dc.l 3 + .dc.l 0 + .dc.l 0x100 + .dc.b 0x2a, 0x7, 0 + .dc.b 0 + + .dc.l 3 + .dc.l 0 + .dc.l 0x100 + .dc.b 0x2a, 0x6, 0 + .dc.b 0 + .popsection + + + .global note2.s +note2.s: + .word 0x100 + + .pushsection .gnu.build.attributes, "0x100000", %note + .dc.l 4 + .dc.l 8 + .dc.l 0x100 + .asciz "$1" + .8byte note2.s + + .dc.l 12 + .dc.l 0 + .dc.l 0x100 + .asciz "$gcc 7.0.1" + + .dc.l 2 + .dc.l 0 + .dc.l 0x100 + .dc.b 0x21, 0x2 + .dc.b 0, 0 + + .dc.l 3 + .dc.l 0 + .dc.l 0x101 + .dc.b 0x2a, 0x7, 1 + .dc.b 0 + + .dc.l 3 + .dc.l 0 + .dc.l 0x100 + .dc.b 0x2a, 0x6, 0 + .dc.b 0 + .popsection + + + .global note3.s +note3.s: + .word 0x100 + + .pushsection .gnu.build.attributes, "0x100000", %note + .dc.l 4 + .dc.l 8 + .dc.l 0x100 + .asciz "$1" + .8byte note3.s + + .dc.l 12 + .dc.l 0 + .dc.l 0x100 + .asciz "$gcc 7.0.1" + + .popsection + + diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index 91e0b65..7ecc0d5 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -1053,6 +1053,11 @@ if [is_elf_format] { run_dump_test "group-6" run_dump_test "copy-1" run_dump_test "note-1" + if [is_elf64 tmpdir/bintest.o] { + run_dump_test "note-2-64" + } else { + run_dump_test "note-2-32" + } } run_dump_test "copy-2" |