diff --git a/.gitignore b/.gitignore index 1cf1fea..5740c58 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ x86_64 HOWTO build-sources +/binutils-2.29.tar.xz diff --git a/binutils-2.20.51.0.10-ppc64-pie.patch b/binutils-2.20.51.0.10-ppc64-pie.patch deleted file mode 100644 index 740c071..0000000 --- a/binutils-2.20.51.0.10-ppc64-pie.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/bfd/elf64-ppc.c 2012-09-11 12:13:00.637448573 +0100 -+++ b/bfd/elf64-ppc.c 2012-09-11 12:13:17.922449052 +0100 -@@ -13523,6 +13523,9 @@ - { - BFD_ASSERT (h->elf.dynindx != -1); - outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type); -+ if (h->elf.dynindx == -1 -+ && h->elf.root.type == bfd_link_hash_undefweak) -+ memset (&outrel, 0, sizeof outrel); - } - else - { diff --git a/binutils-2.26-lto.patch b/binutils-2.26-lto.patch index 3334912..4756e85 100644 --- a/binutils-2.26-lto.patch +++ b/binutils-2.26-lto.patch @@ -2432,7 +2432,7 @@ diff -rup binutils-2.26.orig/ld/testsuite/ld-plugin/lto.exp binutils-2.26/ld/tes +++ binutils-2.28/bfd/opncls.c 2017-03-02 11:23:23.546065945 +0000 @@ -1990,3 +1990,69 @@ bfd_follow_build_id_debuglink (bfd *abfd get_build_id_name, - check_build_id_file); + check_build_id_file, &build_id); } + +/* @@ -2467,7 +2467,7 @@ diff -rup binutils-2.26.orig/ld/testsuite/ld-plugin/lto.exp binutils-2.26/ld/tes + name = make_temp_file (".obj-only.o"); + + /* Open the object-only file. */ -+ file = real_fopen (name, FOPEN_WB); ++ file = _bfd_real_fopen (name, FOPEN_WB); + if (!bfd_get_full_section_contents (abfd, sec, &memhunk)) + { + err = bfd_get_error (); diff --git a/binutils-2.27-ld-buffer-overflow.patch b/binutils-2.27-ld-buffer-overflow.patch deleted file mode 100644 index 54eb649..0000000 --- a/binutils-2.27-ld-buffer-overflow.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff -rup binutils.orig/ld/ldlang.c binutils-2.27/ld/ldlang.c ---- binutils.orig/ld/ldlang.c 2017-01-31 11:08:03.711398839 +0000 -+++ binutils-2.27/ld/ldlang.c 2017-01-31 11:09:31.411347584 +0000 -@@ -2034,14 +2034,11 @@ static void - lang_print_asneeded (void) - { - struct asneeded_minfo *m; -- char buf[100]; - - if (asneeded_list_head == NULL) - return; - -- sprintf (buf, _("\nAs-needed library included " -- "to satisfy reference by file (symbol)\n\n")); -- minfo ("%s", buf); -+ minfo (_("\nAs-needed library included to satisfy reference by file (symbol)\n\n")); - - for (m = asneeded_list_head; m != NULL; m = m->next) - { -diff -rup binutils.orig/ld/ldmain.c binutils-2.27/ld/ldmain.c ---- binutils.orig/ld/ldmain.c 2017-01-31 11:08:03.874396886 +0000 -+++ binutils-2.27/ld/ldmain.c 2017-01-31 11:09:01.393708155 +0000 -@@ -840,11 +840,7 @@ add_archive_element (struct bfd_link_inf - - if (!header_printed) - { -- char buf[100]; -- -- sprintf (buf, _("Archive member included " -- "to satisfy reference by file (symbol)\n\n")); -- minfo ("%s", buf); -+ minfo (_("Archive member included to satisfy reference by file (symbol)\n\n")); - header_printed = TRUE; - } - diff --git a/binutils-2.27-skip-rp14918-test-for-arm.patch b/binutils-2.27-skip-rp14918-test-for-arm.patch deleted file mode 100644 index 6c62b50..0000000 --- a/binutils-2.27-skip-rp14918-test-for-arm.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- binutils-2.27.orig/ld/testsuite/ld-plugin/lto.exp 2016-09-20 14:11:51.866711051 +0100 -+++ binutils-2.27/ld/testsuite/ld-plugin/lto.exp 2016-09-20 14:18:28.528223979 +0100 -@@ -287,11 +287,21 @@ set lto_link_elf_tests [list \ - {dummy.c} {} "pr16746a.exe"] \ - [list "PR ld/16746 (2)" \ - "-O2 -flto -fuse-linker-plugin tmpdir/pr16746c.o tmpdir/pr16746a.o" "-O2 -flto" \ -- {dummy.c} {} "pr16746b.exe"] \ -+ {dummy.c} {} "pr16746b.exe"] \ -+] -+ -+# PR 14918 checks that libgcc is not spuriously included in a shared link of -+# an empty program. The ARM crt1.o startup code however calls __libc_csu_init -+# in /usr/lib/libc_nonshared.a(elf-init.oS). This in turn needs -+# __aeabi_unwind_cpp_pr0@@GCC_3.5 which is provided by libgcc_s.so.1, so the -+# test fails. Hence this code to skip the test. -+if { ! [istarget "arm*-*-*"] } { -+ set lto_link_elf_tests [concat $lto_link_elf_tests [list \ - [list "PR ld/14918" \ - "-flto" "-flto" \ - {pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"] \ --] -+ ]] -+} - - # Check final symbols in executables. - set lto_link_symbol_tests [list \ diff --git a/binutils-2.28-DW_AT_export_symbols.patch b/binutils-2.28-DW_AT_export_symbols.patch deleted file mode 100644 index e15b3d4..0000000 --- a/binutils-2.28-DW_AT_export_symbols.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- binutils.orig/include/dwarf2.def 2017-07-20 09:05:22.616764282 +0100 -+++ binutils-2.28/include/dwarf2.def 2017-07-20 09:05:59.168330104 +0100 -@@ -310,6 +310,11 @@ DW_AT (DW_AT_enum_class, 0x6d) - DW_AT (DW_AT_linkage_name, 0x6e) - /* DWARF 5. */ - DW_AT (DW_AT_noreturn, 0x87) -+DW_AT (DW_AT_alignment, 0x88) -+DW_AT (DW_AT_export_symbols, 0x89) -+DW_AT (DW_AT_deleted, 0x8a) -+DW_AT (DW_AT_defaulted, 0x8b) -+DW_AT (DW_AT_loclists_base, 0x8c) - - DW_AT_DUP (DW_AT_lo_user, 0x2000) /* Implementation-defined range start. */ - DW_AT_DUP (DW_AT_hi_user, 0x3fff) /* Implementation-defined range end. */ diff --git a/binutils-2.28-aarch64-copy-relocs.patch b/binutils-2.28-aarch64-copy-relocs.patch deleted file mode 100644 index 65a4645..0000000 --- a/binutils-2.28-aarch64-copy-relocs.patch +++ /dev/null @@ -1,414 +0,0 @@ -diff -rupN binutils.orig/bfd/elfnn-aarch64.c binutils-2.28/bfd/elfnn-aarch64.c ---- binutils.orig/bfd/elfnn-aarch64.c 2017-06-08 09:11:46.364977859 +0100 -+++ binutils-2.28/bfd/elfnn-aarch64.c 2017-06-08 09:15:46.901961364 +0100 -@@ -246,7 +246,7 @@ - || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC \ - || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_OFF_G1) - --#define ELIMINATE_COPY_RELOCS 0 -+#define ELIMINATE_COPY_RELOCS 1 - - /* Return size of a relocation entry. HTAB is the bfd's - elf_aarch64_link_hash_entry. */ -@@ -5152,12 +5152,25 @@ elfNN_aarch64_final_link_relocate (reloc - /* When generating a shared object or relocatable executable, these - relocations are copied into the output file to be resolved at - run time. */ -- if (((bfd_link_pic (info) == TRUE) -- || globals->root.is_relocatable_executable) -- && (input_section->flags & SEC_ALLOC) -- && (h == NULL -- || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT -- || h->root.type != bfd_link_hash_undefweak)) -+ if (((bfd_link_pic (info) -+ || globals->root.is_relocatable_executable) -+ && (input_section->flags & SEC_ALLOC) -+ && (h == NULL -+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT -+ || h->root.type != bfd_link_hash_undefweak)) -+ /* Or we are creating an executable, we may need to keep relocations -+ for symbols satisfied by a dynamic library if we manage to avoid -+ copy relocs for the symbol. */ -+ || (ELIMINATE_COPY_RELOCS -+ && !bfd_link_pic (info) -+ && h != NULL -+ && (input_section->flags & SEC_ALLOC) -+ && h->dynindx != -1 -+ && !h->non_got_ref -+ && ((h->def_dynamic -+ && !h->def_regular) -+ || h->root.type == bfd_link_hash_undefweak -+ || h->root.type == bfd_link_hash_undefined))) - { - Elf_Internal_Rela outrel; - bfd_byte *loc; -@@ -6822,6 +6835,25 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd, - return TRUE; - } - -+/* Return true if we have dynamic relocs against EH or any of its weak -+ aliases, that apply to read-only sections. */ -+ -+static bfd_boolean -+alias_readonly_dynrelocs (struct elf_aarch64_link_hash_entry *eh) -+{ -+ struct elf_dyn_relocs *p; -+ asection *s; -+ -+ for (p = eh->dyn_relocs; p != NULL; p = p->next) -+ { -+ s = p->sec->output_section; -+ if (s != NULL && (s->flags & SEC_READONLY) != 0) -+ return TRUE; -+ } -+ -+ return FALSE; -+} -+ - /* Adjust a symbol defined by a dynamic object and referenced by a - regular object. The current definition is in some section of the - dynamic object, but we're not including those sections. We have to -@@ -6895,6 +6927,19 @@ elfNN_aarch64_adjust_dynamic_symbol (str - return TRUE; - } - -+ if (ELIMINATE_COPY_RELOCS) -+ { -+ struct elf_aarch64_link_hash_entry *eh; -+ /* If we didn't find any dynamic relocs in read-only sections, then -+ we'll be keeping the dynamic relocs and avoiding the copy reloc. */ -+ eh = (struct elf_aarch64_link_hash_entry *) h; -+ if (eh->dyn_relocs && !alias_readonly_dynrelocs (eh)) -+ { -+ h->non_got_ref = 0; -+ return TRUE; -+ } -+ } -+ - /* We must allocate the symbol in our .dynbss section, which will - become part of the .bss section of the executable. There will be - an entry for this symbol in the .dynsym section. The dynamic -@@ -7167,7 +7212,16 @@ elfNN_aarch64_check_relocs (bfd *abfd, s - - /* No need to do anything if we're not creating a shared - object. */ -- if (! bfd_link_pic (info)) -+ if (!(bfd_link_pic (info) -+ /* If on the other hand, we are creating an executable, we -+ may need to keep relocations for symbols satisfied by a -+ dynamic library if we manage to avoid copy relocs for the -+ symbol. */ -+ || (ELIMINATE_COPY_RELOCS -+ && !bfd_link_pic (info) -+ && h != NULL -+ && (h->root.type == bfd_link_hash_defweak -+ || !h->def_regular)))) - break; - - { -diff -rupN binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp binutils-2.28/ld/testsuite/ld-aarch64/aarch64-elf.exp ---- binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp 2017-06-08 09:11:54.845871503 +0100 -+++ binutils-2.28/ld/testsuite/ld-aarch64/aarch64-elf.exp 2017-06-08 09:16:34.984358379 +0100 -@@ -323,6 +323,8 @@ set aarch64elflinktests { - {} "copy-reloc-so.so"} - {"ld-aarch64/exe with copy relocation" "-e0 tmpdir/copy-reloc-so.so" "" "" - {copy-reloc-exe.s} {{objdump -R copy-reloc.d}} "copy-reloc"} -+ {"ld-aarch64/exe with copy relocation elimination" "-e0 tmpdir/copy-reloc-so.so" "" "" -+ {copy-reloc-exe-eliminate.s} {{objdump -R copy-reloc-eliminate.d}} "copy-reloc-elimination"} - } - - run_ld_link_tests $aarch64elflinktests -diff -rupN binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-eliminate.d binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-eliminate.d ---- binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-eliminate.d 1970-01-01 01:00:00.000000000 +0100 -+++ binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-eliminate.d 2017-06-08 09:12:10.191679056 +0100 -@@ -0,0 +1,4 @@ -+.* -+DYNAMIC RELOCATION RECORDS -+OFFSET.*TYPE.*VALUE.* -+.*R_AARCH64_ABS64.*global_a -diff -rupN binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-exe-eliminate.s binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-exe-eliminate.s ---- binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-exe-eliminate.s 1970-01-01 01:00:00.000000000 +0100 -+++ binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-exe-eliminate.s 2017-06-08 09:12:10.191679056 +0100 -@@ -0,0 +1,7 @@ -+ .global p -+ .section .data.rel.ro,"aw",%progbits -+ .align 3 -+ .type p, %object -+ .size p, 8 -+p: -+ .xword global_a -diff -rupN binutils.orig/bfd/elfnn-aarch64.c binutils-2.28/bfd/elfnn-aarch64.c ---- binutils.orig/bfd/elfnn-aarch64.c 2017-06-15 15:12:31.038471300 +0100 -+++ binutils-2.28/bfd/elfnn-aarch64.c 2017-06-15 15:12:52.797218241 +0100 -@@ -6812,15 +6812,22 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd, - h->plt.refcount -= 1; - break; - -+ case BFD_RELOC_AARCH64_ADD_LO12: - case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: - case BFD_RELOC_AARCH64_ADR_HI21_PCREL: - case BFD_RELOC_AARCH64_ADR_LO21_PCREL: -+ case BFD_RELOC_AARCH64_LDST128_LO12: -+ case BFD_RELOC_AARCH64_LDST16_LO12: -+ case BFD_RELOC_AARCH64_LDST32_LO12: -+ case BFD_RELOC_AARCH64_LDST64_LO12: -+ case BFD_RELOC_AARCH64_LDST8_LO12: -+ case BFD_RELOC_AARCH64_LD_LO19_PCREL: - case BFD_RELOC_AARCH64_MOVW_G0_NC: - case BFD_RELOC_AARCH64_MOVW_G1_NC: - case BFD_RELOC_AARCH64_MOVW_G2_NC: - case BFD_RELOC_AARCH64_MOVW_G3: - case BFD_RELOC_AARCH64_NN: -- if (h != NULL && bfd_link_executable (info)) -+ if (h != NULL && !bfd_link_pic (info)) - { - if (h->plt.refcount > 0) - h->plt.refcount -= 1; -@@ -6835,18 +6842,24 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd, - return TRUE; - } - --/* Return true if we have dynamic relocs against EH or any of its weak -- aliases, that apply to read-only sections. */ -+/* Return true if we need copy relocation against EH. */ - - static bfd_boolean --alias_readonly_dynrelocs (struct elf_aarch64_link_hash_entry *eh) -+need_copy_relocation_p (struct elf_aarch64_link_hash_entry *eh) - { - struct elf_dyn_relocs *p; - asection *s; - - for (p = eh->dyn_relocs; p != NULL; p = p->next) - { -+ /* If there is any pc-relative reference, we need to keep copy relocation -+ to avoid propagating the relocation into runtime that current glibc -+ does not support. */ -+ if (p->pc_count) -+ return TRUE; -+ - s = p->sec->output_section; -+ /* Need copy relocation if it's against read-only section. */ - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return TRUE; - } -@@ -6933,7 +6946,7 @@ elfNN_aarch64_adjust_dynamic_symbol (str - /* If we didn't find any dynamic relocs in read-only sections, then - we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - eh = (struct elf_aarch64_link_hash_entry *) h; -- if (eh->dyn_relocs && !alias_readonly_dynrelocs (eh)) -+ if (!need_copy_relocation_p (eh)) - { - h->non_got_ref = 0; - return TRUE; -@@ -7194,6 +7207,41 @@ elfNN_aarch64_check_relocs (bfd *abfd, s - - switch (bfd_r_type) - { -+ case BFD_RELOC_AARCH64_MOVW_G0_NC: -+ case BFD_RELOC_AARCH64_MOVW_G1_NC: -+ case BFD_RELOC_AARCH64_MOVW_G2_NC: -+ case BFD_RELOC_AARCH64_MOVW_G3: -+ if (bfd_link_pic (info)) -+ { -+ int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; -+ _bfd_error_handler -+ /* xgettext:c-format */ -+ (_("%B: relocation %s against `%s' can not be used when making " -+ "a shared object; recompile with -fPIC"), -+ abfd, elfNN_aarch64_howto_table[howto_index].name, -+ (h) ? h->root.root.string : "a local symbol"); -+ bfd_set_error (bfd_error_bad_value); -+ return FALSE; -+ } -+ /* Fall through. */ -+ -+ case BFD_RELOC_AARCH64_16_PCREL: -+ case BFD_RELOC_AARCH64_32_PCREL: -+ case BFD_RELOC_AARCH64_64_PCREL: -+ case BFD_RELOC_AARCH64_ADD_LO12: -+ case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: -+ case BFD_RELOC_AARCH64_ADR_HI21_PCREL: -+ case BFD_RELOC_AARCH64_ADR_LO21_PCREL: -+ case BFD_RELOC_AARCH64_LDST128_LO12: -+ case BFD_RELOC_AARCH64_LDST16_LO12: -+ case BFD_RELOC_AARCH64_LDST32_LO12: -+ case BFD_RELOC_AARCH64_LDST64_LO12: -+ case BFD_RELOC_AARCH64_LDST8_LO12: -+ case BFD_RELOC_AARCH64_LD_LO19_PCREL: -+ if (h == NULL || bfd_link_pic (info)) -+ break; -+ /* Fall through. */ -+ - case BFD_RELOC_AARCH64_NN: - - /* We don't need to handle relocs into sections not going into -@@ -7216,7 +7264,17 @@ elfNN_aarch64_check_relocs (bfd *abfd, s - /* If on the other hand, we are creating an executable, we - may need to keep relocations for symbols satisfied by a - dynamic library if we manage to avoid copy relocs for the -- symbol. */ -+ symbol. -+ -+ NOTE: Currently, there is no support of copy relocs -+ elimination on pc-relative relocation types, because there is -+ no dynamic relocation support for them in glibc. We still -+ record the dynamic symbol reference for them. This is -+ because one symbol may be referenced by both absolute -+ relocation (for example, BFD_RELOC_AARCH64_NN) and -+ pc-relative relocation. We need full symbol reference -+ information to make correct decision later in -+ elfNN_aarch64_adjust_dynamic_symbol. */ - || (ELIMINATE_COPY_RELOCS - && !bfd_link_pic (info) - && h != NULL -@@ -7227,6 +7285,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, s - { - struct elf_dyn_relocs *p; - struct elf_dyn_relocs **head; -+ int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; - - /* We must copy these reloc types into the output file. - Create a reloc section in dynobj and make room for -@@ -7290,6 +7349,8 @@ elfNN_aarch64_check_relocs (bfd *abfd, s - - p->count += 1; - -+ if (elfNN_aarch64_howto_table[howto_index].pc_relative) -+ p->pc_count += 1; - } - break; - -@@ -7393,44 +7454,6 @@ elfNN_aarch64_check_relocs (bfd *abfd, s - break; - } - -- case BFD_RELOC_AARCH64_MOVW_G0_NC: -- case BFD_RELOC_AARCH64_MOVW_G1_NC: -- case BFD_RELOC_AARCH64_MOVW_G2_NC: -- case BFD_RELOC_AARCH64_MOVW_G3: -- if (bfd_link_pic (info)) -- { -- int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; -- _bfd_error_handler -- /* xgettext:c-format */ -- (_("%B: relocation %s against `%s' can not be used when making " -- "a shared object; recompile with -fPIC"), -- abfd, elfNN_aarch64_howto_table[howto_index].name, -- (h) ? h->root.root.string : "a local symbol"); -- bfd_set_error (bfd_error_bad_value); -- return FALSE; -- } -- /* Fall through. */ -- -- case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: -- case BFD_RELOC_AARCH64_ADR_HI21_PCREL: -- case BFD_RELOC_AARCH64_ADR_LO21_PCREL: -- if (h != NULL && bfd_link_executable (info)) -- { -- /* If this reloc is in a read-only section, we might -- need a copy reloc. We can't check reliably at this -- stage whether the section is read-only, as input -- sections have not yet been mapped to output sections. -- Tentatively set the flag for now, and correct in -- adjust_dynamic_symbol. */ -- h->non_got_ref = 1; -- h->plt.refcount += 1; -- h->pointer_equality_needed = 1; -- } -- /* FIXME:: RR need to handle these in shared libraries -- and essentially bomb out as these being non-PIC -- relocations in shared libraries. */ -- break; -- - case BFD_RELOC_AARCH64_CALL26: - case BFD_RELOC_AARCH64_JUMP26: - /* If this is a local symbol then we resolve it -diff -rupN binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp binutils-2.28/ld/testsuite/ld-aarch64/aarch64-elf.exp ---- binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp 2017-06-15 15:12:31.263468684 +0100 -+++ binutils-2.28/ld/testsuite/ld-aarch64/aarch64-elf.exp 2017-06-15 15:12:52.797218241 +0100 -@@ -323,6 +323,8 @@ set aarch64elflinktests { - {} "copy-reloc-so.so"} - {"ld-aarch64/exe with copy relocation" "-e0 tmpdir/copy-reloc-so.so" "" "" - {copy-reloc-exe.s} {{objdump -R copy-reloc.d}} "copy-reloc"} -+ {"ld-aarch64/exe with copy relocation 2" "-e0 tmpdir/copy-reloc-so.so" "" "" -+ {copy-reloc-exe-2.s} {{objdump -R copy-reloc-2.d}} "copy-reloc-2"} - {"ld-aarch64/exe with copy relocation elimination" "-e0 tmpdir/copy-reloc-so.so" "" "" - {copy-reloc-exe-eliminate.s} {{objdump -R copy-reloc-eliminate.d}} "copy-reloc-elimination"} - } -diff -rupN binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-2.d binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-2.d ---- binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-2.d 1970-01-01 01:00:00.000000000 +0100 -+++ binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-2.d 2017-06-15 15:12:52.797218241 +0100 -@@ -0,0 +1,7 @@ -+.* -+DYNAMIC RELOCATION RECORDS -+OFFSET.*TYPE.*VALUE.* -+.*R_AARCH64_COPY.*global_[abcd] -+.*R_AARCH64_COPY.*global_[abcd] -+.*R_AARCH64_COPY.*global_[abcd] -+.*R_AARCH64_COPY.*global_[abcd] -diff -rupN binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-exe-2.s binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-exe-2.s ---- binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-exe-2.s 1970-01-01 01:00:00.000000000 +0100 -+++ binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-exe-2.s 2017-06-15 15:12:52.797218241 +0100 -@@ -0,0 +1,32 @@ -+ # expect copy relocation for all these scenarios. -+ .global p -+ .global q -+ .global r -+ .section .data.rel.ro,"aw",%progbits -+ .align 3 -+ .type p, %object -+ .size p, 8 -+p: -+ .xword global_a -+ -+ .type q, %object -+ .size q, 8 -+q: -+ .xword global_b -+ -+ .type r, %object -+ .size r, 8 -+r: -+ # Any pc-rel relocation as no dynamic linker support on AArch64. -+ .xword global_c - . -+ -+ .text -+ .global main -+main: -+ # Symbols are referenced by any other relocation against read-only -+ # section. -+ movz x0, :abs_g0_nc:global_a -+ adrp x1, global_b -+ # pc-rel. -+ adrp x2, global_d -+ add x2, x2, #:lo12:global_c -diff -rupN binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-so.s binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-so.s ---- binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-so.s 2017-06-15 15:12:31.263468684 +0100 -+++ binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-so.s 2017-06-15 15:12:52.797218241 +0100 -@@ -1,6 +1,25 @@ - .global global_a - .type global_a, %object - .size global_a, 4 -+ -+ .global global_b -+ .type global_b, %object -+ .size global_b, 4 -+ -+ .global global_c -+ .type global_c, %object -+ .size global_c, 4 -+ -+ .global global_d -+ .type global_d, %object -+ .size global_d, 4 -+ - .data - global_a: - .word 0xcafedead -+global_b: -+ .word 0xcafecafe -+global_c: -+ .word 0xdeadcafe -+global_d: -+ .word 0xdeaddead diff --git a/binutils-2.28-gas-comp_dir.patch b/binutils-2.28-gas-comp_dir.patch deleted file mode 100644 index a0f3912..0000000 --- a/binutils-2.28-gas-comp_dir.patch +++ /dev/null @@ -1,209 +0,0 @@ -commit 49fced1206db40c71208c201165d65f92c69cebe -Author: Mark Wielaard -Date: Sun Mar 5 23:37:54 2017 +0100 - - gas: Emit name, comp_dir and producer strings in .debug_str. - - Putting the name, comp_dir and producer strings in the .debug_str section - makes it possible to share them across CUs. This saves a small amount of - space (about ~20K on a glibc libc.so.6 build with debuginfo). And makes - it easier for tools like rpm debugedit to adjust the source paths when - generating separate debuginfo files. - - gas/ - * dwarf2dbg.c (out_debug_abbrev): Use DW_FORM_strp instead of - DW_FORM_string for DW_AT_name, DW_AT_comp_dir and DW_AT_producer. - (out_debug_info): Accept symbols to name, comp_dir and producer - in the .debug_str section and emit those offsets not full strings. - (out_debug_str): New function that outputs the strings for name, - comp_dir and producer in .debug_str and generates symbols to - those strings. - (out_debug_line): Create a .debug_str section if necessary and - call out_debug_str before calling out_debug_info. - * testsuite/gas/aarch64/dwarf.d: Add extra section symbol to - expected output. - -diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c -index 4bb658b..e02b6e8 100644 ---- a/gas/dwarf2dbg.c -+++ b/gas/dwarf2dbg.c -@@ -1726,9 +1726,9 @@ out_debug_abbrev (segT abbrev_seg, - else - out_abbrev (DW_AT_ranges, DW_FORM_data8); - } -- out_abbrev (DW_AT_name, DW_FORM_string); -- out_abbrev (DW_AT_comp_dir, DW_FORM_string); -- out_abbrev (DW_AT_producer, DW_FORM_string); -+ out_abbrev (DW_AT_name, DW_FORM_strp); -+ out_abbrev (DW_AT_comp_dir, DW_FORM_strp); -+ out_abbrev (DW_AT_producer, DW_FORM_strp); - out_abbrev (DW_AT_language, DW_FORM_data2); - out_abbrev (0, 0); - -@@ -1739,15 +1739,11 @@ out_debug_abbrev (segT abbrev_seg, - /* Emit a description of this compilation unit for .debug_info. */ - - static void --out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg) -+out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg, -+ symbolS *name_sym, symbolS *comp_dir_sym, symbolS *producer_sym) - { -- char producer[128]; -- const char *comp_dir; -- const char *dirname; - expressionS exp; - symbolS *info_end; -- char *p; -- int len; - int sizeof_offset; - - sizeof_offset = out_header (info_seg, &exp); -@@ -1798,10 +1794,38 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg) - TC_DWARF2_EMIT_OFFSET (section_symbol (ranges_seg), sizeof_offset); - } - -+ /* DW_AT_name, DW_AT_comp_dir and DW_AT_producer. Symbols in .debug_str -+ setup in out_debug_str below. */ -+ TC_DWARF2_EMIT_OFFSET (name_sym, sizeof_offset); -+ TC_DWARF2_EMIT_OFFSET (comp_dir_sym, sizeof_offset); -+ TC_DWARF2_EMIT_OFFSET (producer_sym, sizeof_offset); -+ -+ /* DW_AT_language. Yes, this is probably not really MIPS, but the -+ dwarf2 draft has no standard code for assembler. */ -+ out_two (DW_LANG_Mips_Assembler); -+ -+ symbol_set_value_now (info_end); -+} -+ -+/* Emit the three debug strings needed in .debug_str and setup symbols -+ to them for use in out_debug_info. */ -+static void -+out_debug_str (segT str_seg, symbolS **name_sym, symbolS **comp_dir_sym, -+ symbolS **producer_sym) -+{ -+ char producer[128]; -+ const char *comp_dir; -+ const char *dirname; -+ char *p; -+ int len; -+ -+ subseg_set (str_seg, 0); -+ - /* DW_AT_name. We don't have the actual file name that was present - on the command line, so assume files[1] is the main input file. - We're not supposed to get called unless at least one line number - entry was emitted, so this should always be defined. */ -+ *name_sym = symbol_temp_new_now (); - if (files_in_use == 0) - abort (); - if (files[1].dir) -@@ -1823,22 +1847,18 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg) - memcpy (p, files[1].filename, len); - - /* DW_AT_comp_dir */ -+ *comp_dir_sym = symbol_temp_new_now (); - comp_dir = remap_debug_filename (getpwd ()); - len = strlen (comp_dir) + 1; - p = frag_more (len); - memcpy (p, comp_dir, len); - - /* DW_AT_producer */ -+ *producer_sym = symbol_temp_new_now (); - sprintf (producer, "GNU AS %s", VERSION); - len = strlen (producer) + 1; - p = frag_more (len); - memcpy (p, producer, len); -- -- /* DW_AT_language. Yes, this is probably not really MIPS, but the -- dwarf2 draft has no standard code for assembler. */ -- out_two (DW_LANG_Mips_Assembler); -- -- symbol_set_value_now (info_end); - } - - void -@@ -1907,19 +1927,22 @@ dwarf2_finish (void) - out_debug_line (line_seg); - - /* If this is assembler generated line info, and there is no -- debug_info already, we need .debug_info and .debug_abbrev -- sections as well. */ -+ debug_info already, we need .debug_info, .debug_abbrev and -+ .debug_str sections as well. */ - if (emit_other_sections) - { - segT abbrev_seg; - segT aranges_seg; - segT ranges_seg; -+ segT str_seg; -+ symbolS *name_sym, *comp_dir_sym, *producer_sym; - - gas_assert (all_segs); - - info_seg = subseg_new (".debug_info", 0); - abbrev_seg = subseg_new (".debug_abbrev", 0); - aranges_seg = subseg_new (".debug_aranges", 0); -+ str_seg = subseg_new (".debug_str", 0); - - bfd_set_section_flags (stdoutput, info_seg, - SEC_READONLY | SEC_DEBUGGING); -@@ -1927,6 +1950,10 @@ dwarf2_finish (void) - SEC_READONLY | SEC_DEBUGGING); - bfd_set_section_flags (stdoutput, aranges_seg, - SEC_READONLY | SEC_DEBUGGING); -+ bfd_set_section_flags (stdoutput, str_seg, -+ (SEC_READONLY | SEC_DEBUGGING -+ | SEC_MERGE | SEC_STRINGS)); -+ str_seg->entsize = 1; - - record_alignment (aranges_seg, ffs (2 * sizeof_address) - 1); - -@@ -1943,6 +1970,8 @@ dwarf2_finish (void) - - out_debug_aranges (aranges_seg, info_seg); - out_debug_abbrev (abbrev_seg, info_seg, line_seg); -- out_debug_info (info_seg, abbrev_seg, line_seg, ranges_seg); -+ out_debug_str (str_seg, &name_sym, &comp_dir_sym, &producer_sym); -+ out_debug_info (info_seg, abbrev_seg, line_seg, ranges_seg, -+ name_sym, comp_dir_sym, producer_sym); - } - } -diff --git a/gas/testsuite/gas/aarch64/dwarf.d b/gas/testsuite/gas/aarch64/dwarf.d -index 005f1d5..2a75e0b 100644 ---- a/gas/testsuite/gas/aarch64/dwarf.d -+++ b/gas/testsuite/gas/aarch64/dwarf.d -@@ -1,7 +1,7 @@ - #readelf: -s --debug-dump=aranges - #as: -g - --Symbol table '.symtab' contains 10 entries: -+Symbol table '.symtab' contains 11 entries: - Num:[ ]+Value[ ]+Size[ ]+Type[ ]+Bind[ ]+Vis[ ]+Ndx[ ]+Name - 0: 0+ 0 NOTYPE LOCAL DEFAULT UND[ ]+ - 1: 0+ 0 SECTION LOCAL DEFAULT 1[ ]+ -@@ -11,8 +11,9 @@ Symbol table '.symtab' contains 10 entries: - 5: 0+ 0 SECTION LOCAL DEFAULT 6[ ]+ - 6: 0+ 0 SECTION LOCAL DEFAULT 8[ ]+ - 7: 0+ 0 SECTION LOCAL DEFAULT 4[ ]+ -- 8: 0+ 0 SECTION LOCAL DEFAULT 9[ ]+ -- 9: 0+ 8 FUNC GLOBAL DEFAULT 1 testfunc -+ 8: 0+ 0 SECTION LOCAL DEFAULT 11[ ]+ -+ 9: 0+ 0 SECTION LOCAL DEFAULT 9[ ]+ -+ 10: 0+ 8 FUNC GLOBAL DEFAULT 1 testfunc - Contents of the .debug_aranges section: - - Length: (44|28) ---- binutils.orig/gas/config/tc-s390.c 2017-07-19 15:24:06.295642817 +0100 -+++ binutils-2.28/gas/config/tc-s390.c 2017-07-19 15:24:39.085277066 +0100 -@@ -2135,8 +2135,9 @@ md_pcrel_from_section (fixS *fixp, segT - int - tc_s390_fix_adjustable (fixS *fixP) - { -- /* Don't adjust references to merge sections. */ -- if ((S_GET_SEGMENT (fixP->fx_addsy)->flags & SEC_MERGE) != 0) -+ /* Don't adjust pc-relative references to merge sections. */ -+ if (fixP->fx_pcrel -+ && (S_GET_SEGMENT (fixP->fx_addsy)->flags & SEC_MERGE) != 0) - return 0; - /* adjust_reloc_syms doesn't know about the GOT. */ - if ( fixP->fx_r_type == BFD_RELOC_16_GOTOFF diff --git a/binutils-2.28-libiberty-bugfixes.patch b/binutils-2.28-libiberty-bugfixes.patch deleted file mode 100644 index 2b8723b..0000000 --- a/binutils-2.28-libiberty-bugfixes.patch +++ /dev/null @@ -1,104 +0,0 @@ -diff -rup binutils-2.28/libiberty/configure /work/sources/binutils/current/libiberty/configure ---- binutils-2.28/libiberty/configure 2017-03-02 11:41:42.254309307 +0000 -+++ /work/sources/binutils/current/libiberty/configure 2017-01-04 16:01:24.944939339 +0000 -@@ -5097,7 +5097,7 @@ case "${host}" in - # If we are using a compiler supporting mdynamic-no-pic - # and the option has been tested as safe to add, then cancel - # it here, since the code generated is incompatible with shared -- # libs. -+ # libs. - *-mdynamic-no-pic*) PICFLAG='-fno-common -mno-dynamic-no-pic' ;; - *) PICFLAG=-fno-common ;; - esac -diff -rup binutils-2.28/libiberty/cp-demangle.c /work/sources/binutils/current/libiberty/cp-demangle.c ---- binutils-2.28/libiberty/cp-demangle.c 2017-03-02 08:28:19.000000000 +0000 -+++ /work/sources/binutils/current/libiberty/cp-demangle.c 2017-03-01 14:37:20.557586479 +0000 -@@ -2595,7 +2594,11 @@ cplus_demangle_type (struct d_info *di) - /* auto */ - ret = d_make_name (di, "auto", 4); - break; -- -+ case 'c': -+ /* decltype(auto) */ -+ ret = d_make_name (di, "decltype(auto)", 14); -+ break; -+ - case 'f': - /* 32-bit decimal floating point */ - ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[26]); -diff -rup binutils-2.28/libiberty/Makefile.in /work/sources/binutils/current/libiberty/Makefile.in ---- binutils-2.28/libiberty/Makefile.in 2016-12-23 08:40:18.000000000 +0000 -+++ /work/sources/binutils/current/libiberty/Makefile.in 2017-01-04 16:01:24.943939351 +0000 -@@ -1,9 +1,7 @@ - # Makefile for the libiberty library. - # Originally written by K. Richard Pixley . - # --# Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, --# 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, --# 2012, 2014, 2015 Free Software Foundation -+# Copyright (C) 1990-2017 Free Software Foundation, Inc. - # - # This file is part of the libiberty library. - # Libiberty is free software; you can redistribute it and/or -@@ -484,7 +482,8 @@ configure_deps = $(srcdir)/aclocal.m4 \ - $(srcdir)/../config/acx.m4 \ - $(srcdir)/../config/no-executables.m4 \ - $(srcdir)/../config/override.m4 \ -- $(srcdir)/../config/warnings.m4 \ -+ $(srcdir)/../config/picflag.m4 \ -+ $(srcdir)/../config/warnings.m4 - - $(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(configure_deps) - cd $(srcdir) && $(AUTOCONF) -diff -rup binutils-2.28/libiberty/strndup.c /work/sources/binutils/current/libiberty/strndup.c ---- binutils-2.28/libiberty/strndup.c 2013-11-04 15:33:40.000000000 +0000 -+++ /work/sources/binutils/current/libiberty/strndup.c 2017-01-04 16:01:24.950939263 +0000 -@@ -33,7 +33,7 @@ memory was available. The result is alw - #include "ansidecl.h" - #include - --extern size_t strlen (const char*); -+extern size_t strnlen (const char *s, size_t maxlen); - extern PTR malloc (size_t); - extern PTR memcpy (PTR, const PTR, size_t); - -@@ -41,10 +41,7 @@ char * - strndup (const char *s, size_t n) - { - char *result; -- size_t len = strlen (s); -- -- if (n < len) -- len = n; -+ size_t len = strnlen (s, n); - - result = (char *) malloc (len + 1); - if (!result) -diff -rup binutils-2.28/libiberty/testsuite/demangle-expected /work/sources/binutils/current/libiberty/testsuite/demangle-expected ---- binutils-2.28/libiberty/testsuite/demangle-expected 2017-03-02 08:28:19.000000000 +0000 -+++ /work/sources/binutils/current/libiberty/testsuite/demangle-expected 2017-03-01 14:37:55.295138174 +0000 -@@ -4200,6 +4200,9 @@ decltype (new auto({parm#1})) f(int - _Z1fIiERDaRKT_S1_ - auto& f(int const&, int) - --format=gnu-v3 -+_Z1gIiEDcRKT_S0_ -+decltype(auto) g(int const&, int) -+--format=gnu-v3 - _Z1gILi1EEvR1AIXT_EER1BIXscbT_EE - void g<1>(A<1>&, B(1)>&) - --format=gnu-v3 -diff -rup binutils-2.28/libiberty/xstrndup.c /work/sources/binutils/current/libiberty/xstrndup.c ---- binutils-2.28/libiberty/xstrndup.c 2013-11-04 15:33:40.000000000 +0000 -+++ /work/sources/binutils/current/libiberty/xstrndup.c 2017-01-04 16:01:24.951939251 +0000 -@@ -48,10 +48,7 @@ char * - xstrndup (const char *s, size_t n) - { - char *result; -- size_t len = strlen (s); -- -- if (n < len) -- len = n; -+ size_t len = strnlen (s, n); - - result = XNEWVEC (char, len + 1); - diff --git a/binutils-2.28-ppc-dynamic-relocs.patch b/binutils-2.28-ppc-dynamic-relocs.patch deleted file mode 100644 index 2017dae..0000000 --- a/binutils-2.28-ppc-dynamic-relocs.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- binutils.orig/bfd/elf64-ppc.c 2017-03-08 15:44:25.132804697 +0000 -+++ binutils-2.28/bfd/elf64-ppc.c 2017-03-08 15:44:54.596440794 +0000 -@@ -14798,8 +14798,10 @@ ppc64_elf_relocate_section (bfd *output_ - break; - - if (bfd_link_pic (info) -- ? ((h != NULL && pc_dynrelocs (h)) -- || must_be_dyn_reloc (info, r_type)) -+ ? ((h == NULL -+ || h->dyn_relocs != NULL) -+ && ((h != NULL && pc_dynrelocs (h)) -+ || must_be_dyn_reloc (info, r_type))) - : (h != NULL - ? h->dyn_relocs != NULL - : ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)) diff --git a/binutils-2.27-filename-in-error-messages.patch b/binutils-2.29-filename-in-error-messages.patch similarity index 70% rename from binutils-2.27-filename-in-error-messages.patch rename to binutils-2.29-filename-in-error-messages.patch index 19654c7..ee1963b 100644 --- a/binutils-2.27-filename-in-error-messages.patch +++ b/binutils-2.29-filename-in-error-messages.patch @@ -1,7 +1,7 @@ ---- binutils-2.27.orig/binutils/readelf.c 2017-01-16 11:51:05.043922264 +0000 -+++ binutils-2.27/binutils/readelf.c 2017-01-16 12:01:34.389053872 +0000 -@@ -16733,39 +16733,49 @@ process_archive (char * file_name, FILE - static int +--- binutils.orig/binutils/readelf.c 2017-07-24 15:27:09.859116315 +0100 ++++ binutils-2.29/binutils/readelf.c 2017-07-24 15:30:33.557770525 +0100 +@@ -18414,39 +18414,49 @@ process_archive (char * file_name, FILE + static bfd_boolean process_file (char * file_name) { + char * name; @@ -9,9 +9,8 @@ FILE * file; struct stat statbuf; char armag[SARMAG]; -- int ret; -+ int ret = 1; -+ + bfd_boolean ret = TRUE; + + /* Overload program_name to include file_name. Doing this means + that warning/error messages will positively identify the file + concerned even when multiple instances of readelf are running. */ @@ -19,7 +18,7 @@ + sprintf (name, "%s: %s", program_name, file_name); + saved_program_name = program_name; + program_name = name; - ++ if (stat (file_name, &statbuf) < 0) { if (errno == ENOENT) @@ -28,7 +27,7 @@ else - error (_("Could not locate '%s'. System error message: %s\n"), - file_name, strerror (errno)); -- return 1; +- return FALSE; + error (_("Could not locate file. System error message: %s\n"), + strerror (errno)); + goto done; @@ -37,7 +36,7 @@ if (! S_ISREG (statbuf.st_mode)) { - error (_("'%s' is not an ordinary file\n"), file_name); -- return 1; +- return FALSE; + error (_("Not an ordinary file\n")); + goto done; } @@ -46,7 +45,7 @@ if (file == NULL) { - error (_("Input file '%s' is not readable.\n"), file_name); -- return 1; +- return FALSE; + error (_("Not readable\n")); + goto done; } @@ -56,29 +55,19 @@ - error (_("%s: Failed to read file's magic number\n"), file_name); + error (_("Failed to read file's magic number\n")); fclose (file); -- return 1; +- return FALSE; + goto done; } current_file_size = (bfd_size_type) statbuf.st_size; -@@ -16777,8 +16787,7 @@ process_file (char * file_name) - else - { - if (do_archive_index) -- error (_("File %s is not an archive so its index cannot be displayed.\n"), -- file_name); -+ error (_("Not an archive so its index cannot be displayed\n")); - - rewind (file); - archive_file_size = archive_file_offset = 0; -@@ -16787,7 +16796,10 @@ process_file (char * file_name) +@@ -18474,7 +18484,10 @@ process_file (char * file_name) + } fclose (file); - + done: current_file_size = 0; + free (program_name); + program_name = saved_program_name; + return ret; } - diff --git a/binutils-2.29-skip-rp14918-test-for-arm.patch b/binutils-2.29-skip-rp14918-test-for-arm.patch new file mode 100644 index 0000000..d3efc7c --- /dev/null +++ b/binutils-2.29-skip-rp14918-test-for-arm.patch @@ -0,0 +1,32 @@ +--- binutils.orig/ld/testsuite/ld-plugin/lto.exp 2017-07-24 15:24:18.365091235 +0100 ++++ binutils-2.29/ld/testsuite/ld-plugin/lto.exp 2017-07-24 15:25:25.567317336 +0100 +@@ -301,9 +301,6 @@ set lto_link_elf_tests [list \ + [list "PR ld/16746 (2)" \ + "-O2 -flto -fuse-linker-plugin tmpdir/pr16746c.o tmpdir/pr16746a.o" "-O2 -flto" \ + {dummy.c} {} "pr16746b.exe"] \ +- [list "PR ld/14918" \ +- "-flto" "-flto" \ +- {pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"] \ + [list "Build pr21382a.o" \ + "" "-O2 -flto" \ + {pr21382a.c} {} "" "c"] \ +@@ -312,6 +309,19 @@ set lto_link_elf_tests [list \ + {pr21382b.c} {} "pr21382.so" "c"] \ + ] + ++# PR 14918 checks that libgcc is not spuriously included in a shared link of ++# an empty program. The ARM crt1.o startup code however calls __libc_csu_init ++# in /usr/lib/libc_nonshared.a(elf-init.oS). This in turn needs ++# __aeabi_unwind_cpp_pr0@@GCC_3.5 which is provided by libgcc_s.so.1, so the ++# test fails. Hence this code to skip the test. ++if { ! [istarget "arm*-*-*"] } { ++ set lto_link_elf_tests [concat $lto_link_elf_tests [list \ ++ [list "PR ld/14918" \ ++ "-flto" "-flto" \ ++ {pr14918.c} {{"readelf" {-d --wide} "pr14918.d"}} "pr14918.exe" "c"] \ ++ ]] ++} ++ + # Check final symbols in executables. + set lto_link_symbol_tests [list \ + [list "LTO 3 symbol" \ diff --git a/binutils-gnu-build-notes.patch b/binutils-gnu-build-notes.patch deleted file mode 100644 index 00f6294..0000000 --- a/binutils-gnu-build-notes.patch +++ /dev/null @@ -1,1983 +0,0 @@ -diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.28/binutils/doc/binutils.texi ---- binutils.orig/binutils/doc/binutils.texi 2017-03-20 17:03:56.166605442 +0000 -+++ binutils-2.28/binutils/doc/binutils.texi 2017-03-20 17:04:07.688408917 +0000 -@@ -1140,6 +1140,7 @@ objcopy [@option{-F} @var{bfdname}|@opti - [@option{--compress-debug-sections}] - [@option{--decompress-debug-sections}] - [@option{--elf-stt-common=@var{val}}] -+ [@option{--merge-notes}] - [@option{-v}|@option{--verbose}] - [@option{-V}|@option{--version}] - [@option{--help}] [@option{--info}] -@@ -1956,6 +1957,10 @@ converted to the @code{STT_COMMON} or @c - @code{STT_COMMON}. @option{--elf-stt-common=no} converts common symbol - type to @code{STT_OBJECT}. - -+@item --merge-notes -+For ELF files, attempt to reduce the size of any SHT_NOTE type -+sections by removing duplicate notes. -+ - @item -V - @itemx --version - Show the version number of @command{objcopy}. -diff -rup binutils.orig/binutils/NEWS binutils-2.28/binutils/NEWS ---- binutils.orig/binutils/NEWS 2017-03-20 17:03:56.167605425 +0000 -+++ binutils-2.28/binutils/NEWS 2017-03-20 17:04:07.688408917 +0000 -@@ -1,5 +1,8 @@ - -*- text -*- - -+* Add --merge-notes options to objcopy to reduce the size of notes in -+ a binary file by merging and deleting redundant notes. -+ - Changes in 2.28: - - * Add support for locating separate debug info files using the build-id -diff -rup binutils.orig/binutils/objcopy.c binutils-2.28/binutils/objcopy.c ---- binutils.orig/binutils/objcopy.c 2017-03-20 17:03:56.167605425 +0000 -+++ binutils-2.28/binutils/objcopy.c 2017-03-20 17:04:07.718408405 +0000 -@@ -30,6 +30,7 @@ - #include "elf-bfd.h" - #include "coff/internal.h" - #include "libcoff.h" -+#include "safe-ctype.h" - - /* FIXME: See bfd/peXXigen.c for why we include an architecture specific - header in generic PE code. */ -@@ -96,6 +97,10 @@ static bfd_boolean preserve_dates; /* Pr - static int deterministic = -1; /* Enable deterministic archives. */ - static int status = 0; /* Exit status. */ - -+static bfd_boolean merge_notes = FALSE; /* Merge note sections. */ -+static bfd_byte * merged_notes = NULL; /* Contents on note section undergoing a merge. */ -+static bfd_size_type merged_size = 0; /* New, smaller size of the merged note section. */ -+ - enum strip_action - { - STRIP_UNDEF, -@@ -315,6 +320,7 @@ enum command_line_switch - OPTION_LOCALIZE_HIDDEN, - OPTION_LOCALIZE_SYMBOLS, - OPTION_LONG_SECTION_NAMES, -+ OPTION_MERGE_NOTES, - OPTION_NO_CHANGE_WARNINGS, - OPTION_ONLY_KEEP_DEBUG, - OPTION_PAD_TO, -@@ -436,6 +442,7 @@ static struct option copy_options[] = - {"localize-symbol", required_argument, 0, 'L'}, - {"localize-symbols", required_argument, 0, OPTION_LOCALIZE_SYMBOLS}, - {"long-section-names", required_argument, 0, OPTION_LONG_SECTION_NAMES}, -+ {"merge-notes", no_argument, 0, 'M'}, - {"no-adjust-warnings", no_argument, 0, OPTION_NO_CHANGE_WARNINGS}, - {"no-change-warnings", no_argument, 0, OPTION_NO_CHANGE_WARNINGS}, - {"only-keep-debug", no_argument, 0, OPTION_ONLY_KEEP_DEBUG}, -@@ -634,6 +641,7 @@ copy_usage (FILE *stream, int exit_statu - --decompress-debug-sections Decompress DWARF debug sections using zlib\n\ - --elf-stt-common=[yes|no] Generate ELF common symbols with STT_COMMON\n\ - type\n\ -+ -M --merge-notes Remove redundant entries in note sections\n\ - -v --verbose List all object files modified\n\ - @ Read options from \n\ - -V --version Display this program's version number\n\ -@@ -1201,6 +1209,24 @@ is_update_section (bfd *abfd ATTRIBUTE_U - return FALSE; - } - -+static bfd_boolean -+is_merged_note_section (bfd * abfd, asection * sec) -+{ -+ if (merge_notes -+ && bfd_get_flavour (abfd) == bfd_target_elf_flavour -+ && elf_section_data (sec)->this_hdr.sh_type == SHT_NOTE -+ /* FIXME: We currently only support merging GNU_BUILD_NOTEs. -+ We should add support for more note types. */ -+ && ((elf_section_data (sec)->this_hdr.sh_flags & SHF_GNU_BUILD_NOTE) != 0 -+ /* Old versions of GAS (prior to 2.27) could not set the section -+ flags to OS-specific values, so we also accept sections with the -+ expected name. */ -+ || (strcmp (sec->name, GNU_BUILD_ATTRS_SECTION_NAME) == 0))) -+ return TRUE; -+ -+ return FALSE; -+} -+ - /* See if a non-group section is being removed. */ - - static bfd_boolean -@@ -1818,6 +1844,255 @@ copy_unknown_object (bfd *ibfd, bfd *obf - return TRUE; - } - -+/* Merge the notes on SEC, removing redundant entries. -+ Returns the new, smaller size of the section upon success. */ -+ -+static bfd_size_type -+merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte * contents) -+{ -+ Elf_Internal_Note * pnotes_end; -+ Elf_Internal_Note * pnotes; -+ Elf_Internal_Note * pnote; -+ bfd_size_type remain = size; -+ unsigned version_notes_seen = 0; -+ bfd_boolean duplicate_found = FALSE; -+ const char * err = NULL; -+ bfd_byte * in = contents; -+ -+ /* Make a copy of the notes. -+ Minimum size of a note is 12 bytes. */ -+ pnote = pnotes = (Elf_Internal_Note *) xmalloc ((size / 12) * sizeof (Elf_Internal_Note)); -+ while (remain >= 12) -+ { -+ pnote->namesz = (bfd_get_32 (abfd, in ) + 3) & ~3; -+ pnote->descsz = (bfd_get_32 (abfd, in + 4) + 3) & ~3; -+ pnote->type = bfd_get_32 (abfd, in + 8); -+ -+ if (pnote->type != NT_GNU_BUILD_ATTRIBUTE_OPEN -+ && pnote->type != NT_GNU_BUILD_ATTRIBUTE_FUNC) -+ { -+ err = _("corrupt GNU build attribute note: wrong note type"); -+ goto done; -+ } -+ -+ if (pnote->namesz + pnote->descsz + 12 > remain) -+ { -+ err = _("corrupt GNU build attribute note: note too big"); -+ goto done; -+ } -+ -+ if (pnote->namesz < 2) -+ { -+ err = _("corrupt GNU build attribute note: name too small"); -+ goto done; -+ } -+ -+ if (pnote->descsz != 0 -+ && pnote->descsz != 4 -+ && pnote->descsz != 8) -+ { -+ err = _("corrupt GNU build attribute note: bad description size"); -+ goto done; -+ } -+ -+ pnote->namedata = (char *)(in + 12); -+ pnote->descdata = (char *)(in + 12 + pnote->namesz); -+ -+ remain -= 12 + pnote->namesz + pnote->descsz; -+ in += 12 + pnote->namesz + pnote->descsz; -+ -+ if (pnote->namesz > 1 && pnote->namedata[1] == GNU_BUILD_ATTRIBUTE_VERSION) -+ ++ version_notes_seen; -+ pnote ++; -+ } -+ -+ pnotes_end = pnote; -+ -+ /* Check that the notes are valid. */ -+ if (remain != 0) -+ { -+ err = _("corrupt GNU build attribute notes: data at end"); -+ goto done; -+ } -+ -+ if (version_notes_seen == 0) -+ { -+ err = _("bad GNU build attribute notes: no version note"); -+ goto done; -+ } -+ -+ /* Merging is only needed if there is more than one version note... */ -+ if (version_notes_seen == 1) -+ goto done; -+ -+ /* The first note should be the first version note. */ -+ if (pnotes[0].namedata[1] != GNU_BUILD_ATTRIBUTE_VERSION) -+ { -+ err = _("bad GNU build attribute notes: first note not version note"); -+ goto done; -+ } -+ -+ if (pnotes[0].namedata[0] != GNU_BUILD_ATTRIBUTE_TYPE_STRING -+ || pnotes[0].namedata[2] != '1') -+ { -+ err = _("bad GNU build attribute notes: version note not v1"); -+ goto done; -+ } -+ -+ /* Now merge the notes. The rules are: -+ 1. Preserve the ordering of the notes. -+ 2. Preserve any NT_GNU_BUILD_ATTRIBUTE_FUNC notes. -+ 3. Eliminate any NT_GNU_BUILD_ATTRIBUTE_OPEN notes that have the same -+ full name field as the immediately preceeding note with the same type -+ of name. -+ 4. If an NT_GNU_BUILD_ATTRIBUTE_OPEN note is going to be preserved and -+ its description field is empty then the nearest preceeding OPEN note -+ with a non-empty description field must also be preserved *OR* the -+ description field of the note must be changed to contain the starting -+ address to which it refers. */ -+ for (pnote = pnotes + 1; pnote < pnotes_end; pnote ++) -+ { -+ Elf_Internal_Note * back; -+ Elf_Internal_Note * prev_open = NULL; -+ -+ if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC) -+ continue; -+ -+ /* Scan for duplicates. Clear the type field of any found - but do not -+ delete them just yet. */ -+ for (back = pnote - 1; back >= pnotes; back --) -+ { -+ if (back->descsz > 0 -+ && back->type != NT_GNU_BUILD_ATTRIBUTE_FUNC -+ && prev_open == NULL) -+ prev_open = back; -+ -+ if (back->type == pnote->type -+ && back->namedata[1] == pnote->namedata[1]) -+ { -+ if (back->namesz == pnote->namesz -+ && memcmp (back->namedata, pnote->namedata, back->namesz) == 0) -+ { -+ duplicate_found = TRUE; -+ pnote->type = 0; -+ break; -+ } -+ -+ /* If we have found an attribute match then stop searching backwards. */ -+ if (! ISPRINT (back->namedata[1]) -+ || strcmp (back->namedata + 2, pnote->namedata + 2) == 0) -+ { -+ /* Since we are keeping this note we must check to see if its -+ description refers back to an earlier OPEN note. If so -+ then we must make sure that version note is also preserved. */ -+ if (pnote->descsz == 0 -+ && prev_open != NULL -+ && prev_open->type == 0) -+ prev_open->type = NT_GNU_BUILD_ATTRIBUTE_FUNC; -+ -+ break; -+ } -+ } -+ } -+ } -+ -+ if (duplicate_found) -+ { -+ bfd_byte * new_contents; -+ bfd_byte * old; -+ bfd_byte * new; -+ bfd_size_type new_size; -+ arelent ** relpp = NULL; -+ long relsize; -+ long relcount = 0; -+ -+ relsize = bfd_get_reloc_upper_bound (abfd, sec); -+ if (relsize > 0) -+ { -+ /* If there are relocs associated with this section then we may -+ have to adjust them as well, as we remove notes. */ -+ relpp = (arelent **) xmalloc (relsize); -+ relcount = bfd_canonicalize_reloc (abfd, sec, relpp, isympp); -+ if (relcount < 0) -+ /* Do not bother complaining here - copy_relocations_in_section -+ will do that for us. */ -+ relcount = 0; -+ } -+ -+ /* Eliminate the duplicates. */ -+ new = new_contents = xmalloc (size); -+ for (pnote = pnotes, old = contents; -+ pnote < pnotes_end; -+ pnote ++) -+ { -+ bfd_size_type note_size = 12 + pnote->namesz + pnote->descsz; -+ -+ if (pnote->type == 0) -+ { -+ if (relcount > 0) -+ { -+ arelent ** rel; -+ -+ /* If there is a reloc at the current offset, delete it. -+ Adjust the location of any relocs above the current -+ location downwards by the size of the note being deleted. -+ FIXME: We could optimize this loop by retaining a pointer to -+ the last reloc below the current note. */ -+ for (rel = relpp; rel < relpp + relcount; rel ++) -+ { -+ if ((* rel)->howto == NULL) -+ continue; -+ if ((* rel)->address < (bfd_vma) (new - new_contents)) -+ continue; -+ if ((* rel)->address >= (bfd_vma) ((new + note_size) - new_contents)) -+ (* rel)->address -= note_size; -+ else -+ (* rel)->howto = NULL; -+ } -+ } -+ } -+ else -+ { -+ memcpy (new, old, note_size); -+ new += note_size; -+ } -+ -+ old += note_size; -+ } -+ -+ new_size = new - new_contents; -+ memcpy (contents, new_contents, new_size); -+ size = new_size; -+ free (new_contents); -+ -+ if (relcount > 0) -+ { -+ arelent ** rel; -+ -+ for (rel = relpp; rel < relpp + relcount; rel ++) -+ if ((* rel)->howto == NULL) -+ { -+ /* Delete eliminated relocs. -+ FIXME: There are better ways to do this. */ -+ memmove (rel, rel + 1, ((relcount - (rel - relpp)) - 1) * sizeof (* rel)); -+ relcount --; -+ } -+ bfd_set_reloc (abfd, sec, relpp, relcount); -+ } -+ } -+ -+ done: -+ if (err) -+ { -+ bfd_set_error (bfd_error_bad_value); -+ bfd_nonfatal_message (NULL, abfd, sec, err); -+ status = 1; -+ } -+ -+ free (pnotes); -+ return size; -+} -+ - /* Copy object file IBFD onto OBFD. - Returns TRUE upon success, FALSE otherwise. */ - -@@ -2145,6 +2420,57 @@ copy_object (bfd *ibfd, bfd *obfd, const - } - } - -+ if (merge_notes) -+ { -+ asection *osec; -+ -+ /* This palaver is necessary because we must set the output -+ section size first, before its contents are ready. */ -+ osec = bfd_get_section_by_name (ibfd, GNU_BUILD_ATTRS_SECTION_NAME); -+ if (osec && is_merged_note_section (ibfd, osec)) -+ { -+ bfd_size_type size; -+ -+ size = bfd_get_section_size (osec); -+ if (size == 0) -+ { -+ bfd_nonfatal_message (NULL, ibfd, osec, _("warning: note section is empty")); -+ merge_notes = FALSE; -+ } -+ else if (! bfd_get_full_section_contents (ibfd, osec, & merged_notes)) -+ { -+ bfd_nonfatal_message (NULL, ibfd, osec, _("warning: could not load note section")); -+ free (merged_notes); -+ merged_notes = NULL; -+ merge_notes = FALSE; -+ } -+ else -+ { -+ merged_size = merge_gnu_build_notes (ibfd, osec, size, merged_notes); -+ if (merged_size == size) -+ { -+ /* Merging achieves nothing. */ -+ free (merged_notes); -+ merged_notes = NULL; -+ merge_notes = FALSE; -+ merged_size = 0; -+ } -+ else -+ { -+ if (osec->output_section == NULL -+ || ! bfd_set_section_size (obfd, osec->output_section, merged_size)) -+ { -+ bfd_nonfatal_message (NULL, obfd, osec, _("warning: failed to set merged notes size")); -+ free (merged_notes); -+ merged_notes = NULL; -+ merge_notes = FALSE; -+ merged_size = 0; -+ } -+ } -+ } -+ } -+ } -+ - if (dump_sections != NULL) - { - struct section_add * pdump; -@@ -2454,6 +2780,24 @@ copy_object (bfd *ibfd, bfd *obfd, const - } - } - -+ if (merge_notes) -+ { -+ asection * osec = bfd_get_section_by_name (obfd, GNU_BUILD_ATTRS_SECTION_NAME); -+ if (osec && is_merged_note_section (obfd, osec)) -+ { -+ if (! bfd_set_section_contents (obfd, osec, merged_notes, 0, merged_size)) -+ { -+ bfd_nonfatal_message (NULL, obfd, osec, _("error: failed to copy merged notes into output")); -+ return FALSE; -+ } -+ } -+ else -+ bfd_nonfatal_message (NULL, obfd, osec, _("ICE: lost merged note section")); -+ free (merged_notes); -+ merged_notes = NULL; -+ merge_notes = FALSE; -+ } -+ - if (gnu_debuglink_filename != NULL) - { - if (! bfd_fill_in_gnu_debuglink_section -@@ -3179,7 +3523,7 @@ setup_section (bfd *ibfd, sec_ptr isecti - /* Return TRUE if input section ISECTION should be skipped. */ - - static bfd_boolean --skip_section (bfd *ibfd, sec_ptr isection) -+skip_section (bfd *ibfd, sec_ptr isection, bfd_boolean skip_copy) - { - sec_ptr osection; - bfd_size_type size; -@@ -3199,6 +3543,11 @@ skip_section (bfd *ibfd, sec_ptr isectio - if (is_update_section (ibfd, isection)) - return TRUE; - -+ /* When merging a note section we skip the copying of the contents, -+ but not the copying of the relocs associated with the contents. */ -+ if (skip_copy && is_merged_note_section (ibfd, isection)) -+ return TRUE; -+ - flags = bfd_get_section_flags (ibfd, isection); - if ((flags & SEC_GROUP) != 0) - return TRUE; -@@ -3265,7 +3614,7 @@ copy_relocations_in_section (bfd *ibfd, - long relcount; - sec_ptr osection; - -- if (skip_section (ibfd, isection)) -+ if (skip_section (ibfd, isection, FALSE)) - return; - - osection = isection->output_section; -@@ -3354,7 +3703,7 @@ copy_section (bfd *ibfd, sec_ptr isectio - sec_ptr osection; - bfd_size_type size; - -- if (skip_section (ibfd, isection)) -+ if (skip_section (ibfd, isection, TRUE)) - return; - - osection = isection->output_section; -@@ -4010,7 +4359,7 @@ copy_main (int argc, char *argv[]) - struct stat statbuf; - const bfd_arch_info_type *input_arch = NULL; - -- while ((c = getopt_long (argc, argv, "b:B:i:I:j:K:N:s:O:d:F:L:G:R:SpgxXHhVvW:wDU", -+ while ((c = getopt_long (argc, argv, "b:B:i:I:j:K:MN:s:O:d:F:L:G:R:SpgxXHhVvW:wDU", - copy_options, (int *) 0)) != EOF) - { - switch (c) -@@ -4104,6 +4453,10 @@ copy_main (int argc, char *argv[]) - add_specific_symbol (optarg, keep_specific_htab); - break; - -+ case 'M': -+ merge_notes = TRUE; -+ break; -+ - case 'N': - add_specific_symbol (optarg, strip_specific_htab); - break; -diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c ---- binutils.orig/binutils/readelf.c 2017-03-20 17:03:56.164605476 +0000 -+++ binutils-2.28/binutils/readelf.c 2017-03-20 17:06:13.368265213 +0000 -@@ -15557,6 +15557,10 @@ get_note_type (unsigned e_type) - return _("NT_VERSION (version)"); - case NT_ARCH: - return _("NT_ARCH (architecture)"); -+ case NT_GNU_BUILD_ATTRIBUTE_OPEN: -+ return _("NT_GNU_BUILD_ATTRIBUTE_OPEN"); -+ case NT_GNU_BUILD_ATTRIBUTE_FUNC: -+ return _("NT_GNU_BUILD_ATTRIBUTE_FUNC"); - default: - break; - } -@@ -15665,6 +15669,12 @@ get_gnu_elf_note_type (unsigned e_type) - return _("NT_GNU_BUILD_ID (unique build ID bitstring)"); - case NT_GNU_GOLD_VERSION: - return _("NT_GNU_GOLD_VERSION (gold version)"); -+ case NT_GNU_PROPERTY_TYPE_0: -+ return _("NT_GNU_PROPERTY_TYPE_0"); -+ case NT_GNU_BUILD_ATTRIBUTE_OPEN: -+ return _("NT_GNU_BUILD_ATTRIBUTE_OPEN"); -+ case NT_GNU_BUILD_ATTRIBUTE_FUNC: -+ return _("NT_GNU_BUILD_ATTRIBUTE_FUNC"); - default: - { - static char buff[64]; -@@ -15675,6 +15685,155 @@ get_gnu_elf_note_type (unsigned e_type) - } - } - -+static void -+decode_x86_isa (unsigned int bitmask) -+{ -+ while (bitmask) -+ { -+ unsigned int bit = bitmask & (- bitmask); -+ -+ bitmask &= ~ bit; -+ switch (bit) -+ { -+ case GNU_PROPERTY_X86_ISA_1_486: printf ("i486"); break; -+ case GNU_PROPERTY_X86_ISA_1_586: printf ("586"); break; -+ case GNU_PROPERTY_X86_ISA_1_686: printf ("686"); break; -+ case GNU_PROPERTY_X86_ISA_1_SSE: printf ("SSE"); break; -+ case GNU_PROPERTY_X86_ISA_1_SSE2: printf ("SSE2"); break; -+ case GNU_PROPERTY_X86_ISA_1_SSE3: printf ("SSE3"); break; -+ case GNU_PROPERTY_X86_ISA_1_SSSE3: printf ("SSSE3"); break; -+ case GNU_PROPERTY_X86_ISA_1_SSE4_1: printf ("SSE4_1"); break; -+ case GNU_PROPERTY_X86_ISA_1_SSE4_2: printf ("SSE4_2"); break; -+ case GNU_PROPERTY_X86_ISA_1_AVX: printf ("AVX"); break; -+ case GNU_PROPERTY_X86_ISA_1_AVX2: printf ("AVX2"); break; -+ case GNU_PROPERTY_X86_ISA_1_AVX512F: printf ("AVX512F"); break; -+ case GNU_PROPERTY_X86_ISA_1_AVX512CD: printf ("AVX512CD"); break; -+ case GNU_PROPERTY_X86_ISA_1_AVX512ER: printf ("AVX512ER"); break; -+ case GNU_PROPERTY_X86_ISA_1_AVX512PF: printf ("AVX512PF"); break; -+ case GNU_PROPERTY_X86_ISA_1_AVX512VL: printf ("AVX512VL"); break; -+ case GNU_PROPERTY_X86_ISA_1_AVX512DQ: printf ("AVX512DQ"); break; -+ case GNU_PROPERTY_X86_ISA_1_AVX512BW: printf ("AVX512BW"); break; -+ default: printf (_(""), bit); break; -+ } -+ if (bitmask) -+ printf (", "); -+ } -+} -+ -+static void -+print_gnu_property_note (Elf_Internal_Note * pnote) -+{ -+ unsigned char * ptr = (unsigned char *) pnote->descdata; -+ unsigned char * ptr_end = ptr + pnote->descsz; -+ unsigned int size = is_32bit_elf ? 4 : 8; -+ -+ printf (_(" Properties: ")); -+ -+ if (pnote->descsz < 8 || (pnote->descsz % size) != 0) -+ { -+ printf (_("\n"), pnote->descsz); -+ return; -+ } -+ -+ while (1) -+ { -+ unsigned int j; -+ unsigned int type = byte_get (ptr, 4); -+ unsigned int datasz = byte_get (ptr + 4, 4); -+ -+ ptr += 8; -+ -+ if ((ptr + datasz) > ptr_end) -+ { -+ printf (_("\n"), -+ type, datasz); -+ break; -+ } -+ -+ if (type >= GNU_PROPERTY_LOPROC && type <= GNU_PROPERTY_HIPROC) -+ { -+ if (elf_header.e_machine == EM_X86_64 -+ || elf_header.e_machine == EM_IAMCU -+ || elf_header.e_machine == EM_386) -+ { -+ switch (type) -+ { -+ case GNU_PROPERTY_X86_ISA_1_USED: -+ printf ("x86 ISA used: "); -+ if (datasz != 4) -+ printf (_(" "), datasz); -+ else -+ decode_x86_isa (byte_get (ptr, 4)); -+ goto next; -+ -+ case GNU_PROPERTY_X86_ISA_1_NEEDED: -+ printf ("x86 ISA needed: "); -+ if (datasz != 4) -+ printf (_(" "), datasz); -+ else -+ decode_x86_isa (byte_get (ptr, 4)); -+ goto next; -+ -+ default: -+ break; -+ } -+ } -+ } -+ else -+ { -+ switch (type) -+ { -+ case GNU_PROPERTY_STACK_SIZE: -+ printf (_("stack size: ")); -+ if (datasz != size) -+ printf (_(" "), datasz); -+ else -+ printf ("%#lx", (unsigned long) byte_get (ptr, size)); -+ goto next; -+ -+ case GNU_PROPERTY_NO_COPY_ON_PROTECTED: -+ printf ("no copy on protected "); -+ if (datasz) -+ printf (_(" "), datasz); -+ goto next; -+ -+ default: -+ break; -+ } -+ } -+ -+ if (type < GNU_PROPERTY_LOPROC) -+ printf (_(""); -+ -+next: -+ ptr += ((datasz + (size - 1)) & ~ (size - 1)); -+ if (ptr == ptr_end) -+ break; -+ else -+ { -+ if (do_wide) -+ printf (", "); -+ else -+ printf ("\n\t"); -+ } -+ -+ if (ptr > (ptr_end - 8)) -+ { -+ printf (_("\n"), pnote->descsz); -+ break; -+ } -+ } -+ -+ printf ("\n"); -+} -+ - static int - print_gnu_note (Elf_Internal_Note *pnote) - { -@@ -15775,6 +15934,10 @@ print_gnu_note (Elf_Internal_Note *pnote - } - break; - -+ case NT_GNU_PROPERTY_TYPE_0: -+ print_gnu_property_note (pnote); -+ break; -+ - default: - /* Handle unrecognised types. An error message should have already been - created by get_gnu_elf_note_type(), so all that we need to do is to -@@ -16164,15 +16327,370 @@ print_ia64_vms_note (Elf_Internal_Note * - return 1; - } - -+/* Print the name of the symbol associated with a build attribute -+ that is attached to address OFFSET. */ -+ -+static bfd_boolean -+print_symbol_for_build_attribute (FILE * file, -+ unsigned long offset, -+ bfd_boolean is_open_attr) -+{ -+ static FILE * saved_file = NULL; -+ static char * strtab; -+ static unsigned long strtablen; -+ static Elf_Internal_Sym * symtab; -+ static unsigned long nsyms; -+ Elf_Internal_Sym * saved_sym = NULL; -+ Elf_Internal_Sym * sym; -+ -+ if (saved_file == NULL || file != saved_file) -+ { -+ Elf_Internal_Shdr * symsec; -+ -+ /* Load the symbol and string sections. */ -+ for (symsec = section_headers; -+ symsec < section_headers + elf_header.e_shnum; -+ symsec ++) -+ { -+ if (symsec->sh_type == SHT_SYMTAB) -+ { -+ symtab = GET_ELF_SYMBOLS (file, symsec, & nsyms); -+ -+ if (symsec->sh_link < elf_header.e_shnum) -+ { -+ Elf_Internal_Shdr * strtab_sec = section_headers + symsec->sh_link; -+ -+ strtab = (char *) get_data (NULL, file, strtab_sec->sh_offset, -+ 1, strtab_sec->sh_size, -+ _("string table")); -+ strtablen = strtab != NULL ? strtab_sec->sh_size : 0; -+ } -+ } -+ } -+ saved_file = file; -+ } -+ -+ if (symtab == NULL || strtab == NULL) -+ { -+ printf ("\n"); -+ return FALSE; -+ } -+ -+ /* Find a symbol whose value matches offset. */ -+ for (sym = symtab; sym < symtab + nsyms; sym ++) -+ if (sym->st_value == offset) -+ { -+ if (sym->st_name >= strtablen) -+ /* Huh ? This should not happen. */ -+ continue; -+ -+ if (strtab[sym->st_name] == 0) -+ continue; -+ -+ if (is_open_attr) -+ { -+ /* For OPEN attributes we prefer GLOBAL over LOCAL symbols -+ and FILE or OBJECT symbols over NOTYPE symbols. We skip -+ FUNC symbols entirely. */ -+ switch (ELF_ST_TYPE (sym->st_info)) -+ { -+ case STT_FILE: -+ saved_sym = sym; -+ /* We can stop searching now. */ -+ sym = symtab + nsyms; -+ continue; -+ -+ case STT_OBJECT: -+ saved_sym = sym; -+ continue; -+ -+ case STT_FUNC: -+ /* Ignore function symbols. */ -+ continue; -+ -+ default: -+ break; -+ } -+ -+ switch (ELF_ST_BIND (sym->st_info)) -+ { -+ case STB_GLOBAL: -+ if (saved_sym == NULL -+ || ELF_ST_TYPE (saved_sym->st_info) != STT_OBJECT) -+ saved_sym = sym; -+ break; -+ -+ case STB_LOCAL: -+ if (saved_sym == NULL) -+ saved_sym = sym; -+ break; -+ -+ default: -+ break; -+ } -+ } -+ else -+ { -+ if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) -+ continue; -+ -+ saved_sym = sym; -+ break; -+ } -+ } -+ -+ printf (" (%s: %s)\n", -+ is_open_attr ? _("file") : _("func"), -+ saved_sym ? strtab + saved_sym->st_name : _(")")); -+ return TRUE; -+} -+ -+static bfd_boolean -+print_gnu_build_attribute_description (Elf_Internal_Note * pnote, -+ FILE * file) -+{ -+ static unsigned long global_offset = 0; -+ unsigned long offset; -+ unsigned int desc_size = is_32bit_elf ? 4 : 8; -+ bfd_boolean is_open_attr = pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN; -+ -+ if (pnote->descsz == 0) -+ { -+ if (is_open_attr) -+ { -+ printf (_(" Applies from offset %#lx\n"), global_offset); -+ return TRUE; -+ } -+ else -+ { -+ printf (_(" Applies to func at %#lx"), global_offset); -+ return print_symbol_for_build_attribute (file, global_offset, is_open_attr); -+ } -+ } -+ -+ if (pnote->descsz != desc_size) -+ { -+ error (_(" \n"), pnote->descsz); -+ printf (_(" ")); -+ return FALSE; -+ } -+ -+ offset = byte_get ((unsigned char *) pnote->descdata, desc_size); -+ -+ if (is_open_attr) -+ { -+ printf (_(" Applies from offset %#lx"), offset); -+ global_offset = offset; -+ } -+ else -+ { -+ printf (_(" Applies to func at %#lx"), offset); -+ } -+ -+ return print_symbol_for_build_attribute (file, offset, is_open_attr); -+} -+ -+static bfd_boolean -+print_gnu_build_attribute_name (Elf_Internal_Note * pnote) -+{ -+ char name_type; -+ char name_attribute; -+ char * expected_types; -+ const char * name = pnote->namedata; -+ const char * text; -+ int left; -+ -+ if (name == NULL || pnote->namesz < 2) -+ { -+ error (_("corrupt name field in GNU build attribute note: size = %ld\n"), pnote->namesz); -+ print_symbol (-20, _(" ")); -+ return FALSE; -+ } -+ -+ switch ((name_type = * name)) -+ { -+ case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: -+ case GNU_BUILD_ATTRIBUTE_TYPE_STRING: -+ case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE: -+ case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE: -+ printf ("%c", * name); -+ break; -+ default: -+ error (_("unrecognised attribute type in name field: %d\n"), name_type); -+ print_symbol (-20, _("")); -+ return FALSE; -+ } -+ -+ left = 19; -+ ++ name; -+ text = NULL; -+ -+ switch ((name_attribute = * name)) -+ { -+ case GNU_BUILD_ATTRIBUTE_VERSION: -+ text = _(""); -+ expected_types = "$"; -+ ++ name; -+ break; -+ case GNU_BUILD_ATTRIBUTE_STACK_PROT: -+ text = _(""); -+ expected_types = "!+*"; -+ ++ name; -+ break; -+ case GNU_BUILD_ATTRIBUTE_RELRO: -+ text = _(""); -+ expected_types = "!+"; -+ ++ name; -+ break; -+ case GNU_BUILD_ATTRIBUTE_STACK_SIZE: -+ text = _(""); -+ expected_types = "*"; -+ ++ name; -+ break; -+ case GNU_BUILD_ATTRIBUTE_TOOL: -+ text = _(""); -+ expected_types = "$"; -+ ++ name; -+ break; -+ case GNU_BUILD_ATTRIBUTE_ABI: -+ text = _(""); -+ expected_types = "$*"; -+ ++ name; -+ break; -+ case GNU_BUILD_ATTRIBUTE_PIC: -+ text = _(""); -+ expected_types = "*"; -+ ++ name; -+ break; -+ case GNU_BUILD_ATTRIBUTE_SHORT_ENUM: -+ text = _(""); -+ expected_types = "!+"; -+ ++ name; -+ break; -+ -+ default: -+ if (ISPRINT (* name)) -+ { -+ int len = strnlen (name, pnote->namesz - (name - pnote->namedata)) + 1; -+ -+ if (len > left && ! do_wide) -+ len = left; -+ printf ("%.*s:", len, name); -+ left -= len; -+ name += len; -+ } -+ else -+ { -+ error (_("unexpected character in name field\n")); -+ print_symbol (- left, _("")); -+ return 0; -+ } -+ expected_types = "*$!+"; -+ break; -+ } -+ -+ if (text) -+ { -+ printf ("%s", text); -+ left -= strlen (text); -+ } -+ -+ if (strchr (expected_types, name_type) == NULL) -+ warn (_("attribute does not have an expected type (%c)\n"), name_type); -+ -+ if ((unsigned long)(name - pnote->namedata) > pnote->namesz) -+ { -+ error (_("corrupt name field: namesz: %lu but parsing gets to %ld\n"), -+ (unsigned long) pnote->namesz, -+ (long) (name - pnote->namedata)); -+ return FALSE; -+ } -+ -+ if (left < 1 && ! do_wide) -+ return TRUE; -+ -+ switch (name_type) -+ { -+ case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: -+ { -+ unsigned int bytes = pnote->namesz - (name - pnote->namedata); -+ unsigned long val = 0; -+ unsigned int shift = 0; -+ char * decoded = NULL; -+ -+ while (bytes --) -+ { -+ unsigned long byte = (* name ++) & 0xff; -+ -+ val |= byte << shift; -+ shift += 8; -+ } -+ -+ switch (name_attribute) -+ { -+ case GNU_BUILD_ATTRIBUTE_PIC: -+ switch (val) -+ { -+ case 0: decoded = "static"; break; -+ case 1: decoded = "pic"; break; -+ case 2: decoded = "PIC"; break; -+ case 3: decoded = "pie"; break; -+ case 4: decoded = "PIE"; break; -+ default: break; -+ } -+ break; -+ case GNU_BUILD_ATTRIBUTE_STACK_PROT: -+ switch (val) -+ { -+ /* Based upon the SPCT_FLAG_xxx enum values in gcc/cfgexpand.c. */ -+ case 0: decoded = "off"; break; -+ case 1: decoded = "on"; break; -+ case 2: decoded = "all"; break; -+ case 3: decoded = "strong"; break; -+ case 4: decoded = "explicit"; break; -+ default: break; -+ } -+ break; -+ default: -+ break; -+ } -+ -+ if (decoded != NULL) -+ print_symbol (-left, decoded); -+ else -+ { -+ if (do_wide) -+ left -= printf ("0x%lx", val); -+ else -+ left -= printf ("0x%-.*lx", left, val); -+ } -+ } -+ break; -+ case GNU_BUILD_ATTRIBUTE_TYPE_STRING: -+ left -= print_symbol (- left, name); -+ break; -+ case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE: -+ left -= print_symbol (- left, "true"); -+ break; -+ case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE: -+ left -= print_symbol (- left, "false"); -+ break; -+ } -+ -+ if (do_wide && left > 0) -+ printf ("%-*s", left, " "); -+ -+ return TRUE; -+} -+ - /* Note that by the ELF standard, the name field is already null byte - terminated, and namesz includes the terminating null byte. - I.E. the value of namesz for the name "FSF" is 4. - - If the value of namesz is zero, there is no name present. */ - static int --process_note (Elf_Internal_Note * pnote, -- FILE * file ATTRIBUTE_UNUSED, -- Elf_Internal_Shdr * section ATTRIBUTE_UNUSED) -+process_note (Elf_Internal_Note * pnote, -+ FILE * file) - { - const char * name = pnote->namesz ? pnote->namedata : "(NONE)"; - const char * nt; -@@ -16218,8 +16736,17 @@ process_note (Elf_Internal_Note * pnote, - nt = get_note_type (pnote->type); - - printf (" "); -- print_symbol (-20, name); -- printf (" 0x%08lx\t%s\n", pnote->descsz, nt); -+ -+ if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN -+ || pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC) -+ print_gnu_build_attribute_name (pnote); -+ else -+ print_symbol (-20, name); -+ -+ if (do_wide) -+ printf (" 0x%08lx\t%s\t", pnote->descsz, nt); -+ else -+ printf (" 0x%08lx\t%s\n", pnote->descsz, nt); - - if (const_strneq (pnote->namedata, "IPF/VMS")) - return print_ia64_vms_note (pnote); -@@ -16229,17 +16756,22 @@ process_note (Elf_Internal_Note * pnote, - return print_stapsdt_note (pnote); - else if (const_strneq (pnote->namedata, "CORE")) - return print_core_note (pnote); -+ else if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN -+ || pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC) -+ return print_gnu_build_attribute_description (pnote, file); - -- else if (pnote->descsz) -+ if (pnote->descsz) - { - unsigned long i; - - printf (_(" description data: ")); - for (i = 0; i < pnote->descsz; i++) - printf ("%02x ", pnote->descdata[i]); -- printf ("\n"); - } - -+ if (do_wide) -+ printf ("\n"); -+ - return 1; - } - -@@ -16369,14 +16901,14 @@ process_notes_at (FILE * fi - break; - } - -- strncpy (temp, inote.namedata, inote.namesz); -+ memcpy (temp, inote.namedata, inote.namesz); - temp[inote.namesz] = 0; - - /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */ - inote.namedata = temp; - } - -- res &= process_note (& inote, file, section); -+ res &= process_note (& inote, file); - - if (temp != NULL) - { -Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-32.d -Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-32.s -Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-64.d -Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-64.s -diff -rup binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.28/binutils/testsuite/binutils-all/objcopy.exp ---- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2017-03-20 17:03:56.174605306 +0000 -+++ binutils-2.28/binutils/testsuite/binutils-all/objcopy.exp 2017-03-20 17:04:07.721408353 +0000 -@@ -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" -diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h ---- binutils.orig/include/elf/common.h 2017-03-20 17:03:56.417601161 +0000 -+++ binutils-2.28/include/elf/common.h 2017-03-20 17:04:07.733408149 +0000 -@@ -538,6 +538,7 @@ - - /* #define SHF_MASKOS 0x0F000000 *//* OS-specific semantics */ - #define SHF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */ -+#define SHF_GNU_BUILD_NOTE (1 << 20) /* Section contains GNU BUILD ATTRIBUTE notes. */ - #define SHF_MASKPROC 0xF0000000 /* Processor-specific semantics */ - - /* This used to be implemented as a processor specific section flag. -@@ -669,6 +670,62 @@ - #define NT_GNU_HWCAP 2 /* Used by ld.so and kernel vDSO. */ - #define NT_GNU_BUILD_ID 3 /* Generated by ld --build-id. */ - #define NT_GNU_GOLD_VERSION 4 /* Generated by gold. */ -+#define NT_GNU_PROPERTY_TYPE_0 5 /* Generated by gcc. */ -+ -+#define NT_GNU_BUILD_ATTRIBUTE_OPEN 0x100 -+#define NT_GNU_BUILD_ATTRIBUTE_FUNC 0x101 -+ -+#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 1 -+#define GNU_BUILD_ATTRIBUTE_STACK_PROT 2 -+#define GNU_BUILD_ATTRIBUTE_RELRO 3 -+#define GNU_BUILD_ATTRIBUTE_STACK_SIZE 4 -+#define GNU_BUILD_ATTRIBUTE_TOOL 5 -+#define GNU_BUILD_ATTRIBUTE_ABI 6 -+#define GNU_BUILD_ATTRIBUTE_PIC 7 -+#define GNU_BUILD_ATTRIBUTE_SHORT_ENUM 8 -+ -+#define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property" -+#define GNU_BUILD_ATTRS_SECTION_NAME ".gnu.build.attributes" -+ -+/* Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0). */ -+#define GNU_PROPERTY_STACK_SIZE 1 -+#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2 -+ -+/* Processor-specific semantics, lo */ -+#define GNU_PROPERTY_LOPROC 0xc0000000 -+/* Processor-specific semantics, hi */ -+#define GNU_PROPERTY_HIPROC 0xdfffffff -+/* Application-specific semantics, lo */ -+#define GNU_PROPERTY_LOUSER 0xe0000000 -+/* Application-specific semantics, hi */ -+#define GNU_PROPERTY_HIUSER 0xffffffff -+ -+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000 -+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001 -+ -+#define GNU_PROPERTY_X86_ISA_1_486 (1U << 0) -+#define GNU_PROPERTY_X86_ISA_1_586 (1U << 1) -+#define GNU_PROPERTY_X86_ISA_1_686 (1U << 2) -+#define GNU_PROPERTY_X86_ISA_1_SSE (1U << 3) -+#define GNU_PROPERTY_X86_ISA_1_SSE2 (1U << 4) -+#define GNU_PROPERTY_X86_ISA_1_SSE3 (1U << 5) -+#define GNU_PROPERTY_X86_ISA_1_SSSE3 (1U << 6) -+#define GNU_PROPERTY_X86_ISA_1_SSE4_1 (1U << 7) -+#define GNU_PROPERTY_X86_ISA_1_SSE4_2 (1U << 8) -+#define GNU_PROPERTY_X86_ISA_1_AVX (1U << 9) -+#define GNU_PROPERTY_X86_ISA_1_AVX2 (1U << 10) -+#define GNU_PROPERTY_X86_ISA_1_AVX512F (1U << 11) -+#define GNU_PROPERTY_X86_ISA_1_AVX512CD (1U << 12) -+#define GNU_PROPERTY_X86_ISA_1_AVX512ER (1U << 13) -+#define GNU_PROPERTY_X86_ISA_1_AVX512PF (1U << 14) -+#define GNU_PROPERTY_X86_ISA_1_AVX512VL (1U << 15) -+#define GNU_PROPERTY_X86_ISA_1_AVX512DQ (1U << 16) -+#define GNU_PROPERTY_X86_ISA_1_AVX512BW (1U << 17) - - /* Values used in GNU .note.ABI-tag notes (NT_GNU_ABI_TAG). */ - #define GNU_ABI_TAG_LINUX 0 ---- /dev/null 2017-03-20 08:02:04.287194455 +0000 -+++ binutils-2.28/binutils/testsuite/binutils-all/note-2-32.s 2017-03-20 17:16:18.922951480 +0000 -@@ -0,0 +1,95 @@ -+ .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: -+ .type func1, STT_FUNC -+func1: -+ .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 -+ -+ ---- /dev/null 2017-03-20 08:02:04.287194455 +0000 -+++ binutils-2.28/binutils/testsuite/binutils-all/note-2-32.d 2017-03-20 17:16:18.922951480 +0000 -@@ -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 -+[ ]+\$1[ ]+0x00000004[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 \(file: note1.s\) -+[ ]+\$gcc 7.0.1[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 -+[ ]+\+true[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 -+[ ]+\*static[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 -+[ ]+\*0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 -+[ ]+\$1[ ]+0x00000004[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\) -+[ ]+!false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. -+[ ]+\*pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies to func at 0x10. \(func: func1\) -+#... ---- /dev/null 2017-03-20 08:02:04.287194455 +0000 -+++ binutils-2.28/binutils/testsuite/binutils-all/note-2-64.d 2017-03-20 17:16:18.922951480 +0000 -@@ -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 -+[ ]+\$1[ ]+0x00000008[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 \(file: note1.s\) -+[ ]+\$gcc 7.0.1[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 -+[ ]+\+true[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 -+[ ]+\*static[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 -+[ ]+\*0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 -+[ ]+\$1[ ]+0x00000008[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\) -+[ ]+!false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. -+[ ]+\*pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies to func at 0x10. \(func: func1\) -+#... ---- /dev/null 2017-03-20 08:02:04.287194455 +0000 -+++ binutils-2.28/binutils/testsuite/binutils-all/note-2-64.s 2017-03-20 17:16:18.922951480 +0000 -@@ -0,0 +1,97 @@ -+ .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: -+ .global func1 -+ .type func1, STT_FUNC -+func1: -+ .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 -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c ---- binutils.orig/binutils/readelf.c 2017-05-15 17:12:12.760814593 +0100 -+++ binutils-2.28/binutils/readelf.c 2017-05-15 17:26:46.142293641 +0100 -@@ -4130,7 +4130,18 @@ get_section_type_name (unsigned int sh_t - if (elf_header.e_ident[EI_OSABI] == ELFOSABI_SOLARIS) - result = get_solaris_section_type (sh_type); - else -- result = NULL; -+ { -+ switch (sh_type) -+ { -+ case SHT_GNU_INCREMENTAL_INPUTS: result = "GNU_INCREMENTAL_INPUTS"; break; -+ case SHT_GNU_ATTRIBUTES: result = "GNU_ATTRIBUTES"; break; -+ case SHT_GNU_HASH: result = "GNU_HASH"; break; -+ case SHT_GNU_LIBLIST: result = "GNU_LIBLIST"; break; -+ default: -+ result = NULL; -+ break; -+ } -+ } - break; - } - -@@ -15928,8 +15939,8 @@ print_gnu_note (Elf_Internal_Note *pnote - printf (_(" Hardware Capabilities: ")); - if (pnote->descsz < 8) - { -- printf (_("\n")); -- break; -+ error (_("\n")); -+ return 0; - } - num_entries = byte_get ((unsigned char *) pnote->descdata, 4); - mask = byte_get ((unsigned char *) pnote->descdata + 4, 4); -@@ -16347,7 +16358,8 @@ print_symbol_for_build_attribute (FILE * - Elf_Internal_Sym * saved_sym = NULL; - Elf_Internal_Sym * sym; - -- if (saved_file == NULL || file != saved_file) -+ if (section_headers != NULL -+ && (saved_file == NULL || file != saved_file)) - { - Elf_Internal_Shdr * symsec; - -@@ -16497,9 +16509,12 @@ print_gnu_build_attribute_description (E - static bfd_boolean - print_gnu_build_attribute_name (Elf_Internal_Note * pnote) - { -+ static const char string_expected [2] = { GNU_BUILD_ATTRIBUTE_TYPE_STRING, 0 }; -+ static const char number_expected [2] = { GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC, 0 }; -+ static const char bool_expected [3] = { GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE, GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE, 0 }; - char name_type; - char name_attribute; -- char * expected_types; -+ const char * expected_types; - const char * name = pnote->namedata; - const char * text; - int left; -@@ -16507,7 +16522,7 @@ print_gnu_build_attribute_name (Elf_Inte - if (name == NULL || pnote->namesz < 2) - { - error (_("corrupt name field in GNU build attribute note: size = %ld\n"), pnote->namesz); -- print_symbol (-20, _(" ")); -+ print_symbol (-20, _(" ")); - return FALSE; - } - -@@ -16533,7 +16548,7 @@ print_gnu_build_attribute_name (Elf_Inte - { - case GNU_BUILD_ATTRIBUTE_VERSION: - text = _(""); -- expected_types = "$"; -+ expected_types = string_expected; - ++ name; - break; - case GNU_BUILD_ATTRIBUTE_STACK_PROT: -@@ -16543,17 +16558,17 @@ print_gnu_build_attribute_name (Elf_Inte - break; - case GNU_BUILD_ATTRIBUTE_RELRO: - text = _(""); -- expected_types = "!+"; -+ expected_types = bool_expected; - ++ name; - break; - case GNU_BUILD_ATTRIBUTE_STACK_SIZE: - text = _(""); -- expected_types = "*"; -+ expected_types = number_expected; - ++ name; - break; - case GNU_BUILD_ATTRIBUTE_TOOL: - text = _(""); -- expected_types = "$"; -+ expected_types = string_expected; - ++ name; - break; - case GNU_BUILD_ATTRIBUTE_ABI: -@@ -16563,12 +16578,12 @@ print_gnu_build_attribute_name (Elf_Inte - break; - case GNU_BUILD_ATTRIBUTE_PIC: - text = _(""); -- expected_types = "*"; -+ expected_types = number_expected; - ++ name; - break; - case GNU_BUILD_ATTRIBUTE_SHORT_ENUM: - text = _(""); -- expected_types = "!+"; -+ expected_types = bool_expected; - ++ name; - break; - -@@ -16585,9 +16600,11 @@ print_gnu_build_attribute_name (Elf_Inte - } - else - { -- error (_("unexpected character in name field\n")); -- print_symbol (- left, _("")); -- return 0; -+ static char tmpbuf [128]; -+ error (_("unrecognised byte in name field: %d\n"), * name); -+ sprintf (tmpbuf, _(""), * name); -+ text = tmpbuf; -+ name ++; - } - expected_types = "*$!+"; - break; -@@ -16617,11 +16634,29 @@ print_gnu_build_attribute_name (Elf_Inte - { - case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: - { -- unsigned int bytes = pnote->namesz - (name - pnote->namedata); -- unsigned long val = 0; -+ unsigned int bytes; -+ unsigned long long val = 0; - unsigned int shift = 0; - char * decoded = NULL; - -+ bytes = pnote->namesz - (name - pnote->namedata); -+ if (bytes > 0) -+ /* The -1 is because the name field is always 0 terminated, and we -+ want to be able to ensure that the shift in the while loop below -+ will not overflow. */ -+ -- bytes; -+ -+ if (bytes > sizeof (val)) -+ { -+ fprintf (stderr, "namesz %lx name %p namedata %p\n", -+ pnote->namesz, name, pnote->namedata); -+ error (_("corrupt numeric name field: too many bytes in the value: %x\n"), -+ bytes); -+ bytes = sizeof (val); -+ } -+ /* We do not bother to warn if bytes == 0 as this can -+ happen with some early versions of the gcc plugin. */ -+ - while (bytes --) - { - unsigned long byte = (* name ++) & 0xff; -@@ -16660,13 +16695,21 @@ print_gnu_build_attribute_name (Elf_Inte - } - - if (decoded != NULL) -- print_symbol (-left, decoded); -+ { -+ print_symbol (-left, decoded); -+ left = 0; -+ } -+ else if (val == 0) -+ { -+ printf ("0x0"); -+ left -= 3; -+ } - else - { - if (do_wide) -- left -= printf ("0x%lx", val); -+ left -= printf ("0x%llx", val); - else -- left -= printf ("0x%-.*lx", left, val); -+ left -= printf ("0x%-.*llx", left, val); - } - } - break; -diff -rup binutils.orig/binutils/objcopy.c binutils-2.28/binutils/objcopy.c ---- binutils.orig/binutils/objcopy.c 2017-06-28 15:28:35.859154073 +0100 -+++ binutils-2.28/binutils/objcopy.c 2017-06-28 15:33:35.093694480 +0100 -@@ -1854,14 +1854,17 @@ merge_gnu_build_notes (bfd * abfd, asect - Elf_Internal_Note * pnotes; - Elf_Internal_Note * pnote; - bfd_size_type remain = size; -- unsigned version_notes_seen = 0; -+ unsigned version_1_seen = 0; -+ unsigned version_2_seen = 0; - bfd_boolean duplicate_found = FALSE; - const char * err = NULL; - bfd_byte * in = contents; -+ int attribute_type_byte; -+ int val_start; - - /* Make a copy of the notes. - Minimum size of a note is 12 bytes. */ -- pnote = pnotes = (Elf_Internal_Note *) xmalloc ((size / 12) * sizeof (Elf_Internal_Note)); -+ pnote = pnotes = (Elf_Internal_Note *) xcalloc ((size / 12), sizeof (Elf_Internal_Note)); - while (remain >= 12) - { - pnote->namesz = (bfd_get_32 (abfd, in ) + 3) & ~3; -@@ -1901,8 +1904,24 @@ merge_gnu_build_notes (bfd * abfd, asect - remain -= 12 + pnote->namesz + pnote->descsz; - in += 12 + pnote->namesz + pnote->descsz; - -- if (pnote->namesz > 1 && pnote->namedata[1] == GNU_BUILD_ATTRIBUTE_VERSION) -- ++ version_notes_seen; -+ if (pnote->namedata[pnote->namesz - 1] != 0) -+ { -+ err = _("corrupt GNU build attribute note: name not NUL terminated"); -+ goto done; -+ } -+ -+ if (pnote->namesz > 2 -+ && pnote->namedata[0] == '$' -+ && pnote->namedata[1] == GNU_BUILD_ATTRIBUTE_VERSION -+ && pnote->namedata[2] == '1') -+ ++ version_1_seen; -+ else if (pnote->namesz > 4 -+ && pnote->namedata[0] == 'G' -+ && pnote->namedata[1] == 'A' -+ && pnote->namedata[2] == '$' -+ && pnote->namedata[3] == GNU_BUILD_ATTRIBUTE_VERSION -+ && pnote->namedata[4] == '2') -+ ++ version_2_seen; - pnote ++; - } - -@@ -1911,41 +1930,45 @@ merge_gnu_build_notes (bfd * abfd, asect - /* Check that the notes are valid. */ - if (remain != 0) - { -- err = _("corrupt GNU build attribute notes: data at end"); -+ err = _("corrupt GNU build attribute notes: excess data at end"); -+ goto done; -+ } -+ -+ if (version_1_seen == 0 && version_2_seen == 0) -+ { -+ err = _("bad GNU build attribute notes: no known versions detected"); - goto done; - } - -- if (version_notes_seen == 0) -+ if (version_1_seen > 0 && version_2_seen > 0) - { -- err = _("bad GNU build attribute notes: no version note"); -+ err = _("bad GNU build attribute notes: multiple different versions"); - goto done; - } - - /* Merging is only needed if there is more than one version note... */ -- if (version_notes_seen == 1) -+ if (version_1_seen == 1 || version_2_seen == 1) - goto done; - -+ attribute_type_byte = version_1_seen ? 1 : 3; -+ val_start = attribute_type_byte + 1; -+ - /* The first note should be the first version note. */ -- if (pnotes[0].namedata[1] != GNU_BUILD_ATTRIBUTE_VERSION) -+ if (pnotes[0].namedata[attribute_type_byte] != GNU_BUILD_ATTRIBUTE_VERSION) - { - err = _("bad GNU build attribute notes: first note not version note"); - goto done; - } - -- if (pnotes[0].namedata[0] != GNU_BUILD_ATTRIBUTE_TYPE_STRING -- || pnotes[0].namedata[2] != '1') -- { -- err = _("bad GNU build attribute notes: version note not v1"); -- goto done; -- } -- - /* Now merge the notes. The rules are: - 1. Preserve the ordering of the notes. - 2. Preserve any NT_GNU_BUILD_ATTRIBUTE_FUNC notes. - 3. Eliminate any NT_GNU_BUILD_ATTRIBUTE_OPEN notes that have the same - full name field as the immediately preceeding note with the same type - of name. -- 4. If an NT_GNU_BUILD_ATTRIBUTE_OPEN note is going to be preserved and -+ 4. Combine the numeric value of any NT_GNU_BUILD_ATTRIBUTE_OPEN notes -+ of type GNU_BUILD_ATTRIBUTE_STACK_SIZE. -+ 5. If an NT_GNU_BUILD_ATTRIBUTE_OPEN note is going to be preserved and - its description field is empty then the nearest preceeding OPEN note - with a non-empty description field must also be preserved *OR* the - description field of the note must be changed to contain the starting -@@ -1968,8 +1991,63 @@ merge_gnu_build_notes (bfd * abfd, asect - prev_open = back; - - if (back->type == pnote->type -- && back->namedata[1] == pnote->namedata[1]) -+ && back->namedata[attribute_type_byte] == pnote->namedata[attribute_type_byte]) - { -+ if (back->namedata[attribute_type_byte] == GNU_BUILD_ATTRIBUTE_STACK_SIZE) -+ { -+ unsigned char * name; -+ unsigned long note_val; -+ unsigned long back_val; -+ unsigned int shift; -+ unsigned int bytes; -+ unsigned long byte; -+ -+ for (shift = 0, note_val = 0, -+ bytes = pnote->namesz - val_start, -+ name = (unsigned char *) pnote->namedata + val_start; -+ bytes--;) -+ { -+ byte = (* name ++) & 0xff; -+ note_val |= byte << shift; -+ shift += 8; -+ } -+ -+ for (shift = 0, back_val = 0, -+ bytes = back->namesz - val_start, -+ name = (unsigned char *) back->namedata + val_start; -+ bytes--;) -+ { -+ byte = (* name ++) & 0xff; -+ back_val |= byte << shift; -+ shift += 8; -+ } -+ -+ back_val += note_val; -+ if (num_bytes (back_val) >= back->namesz - val_start) -+ { -+ /* We have a problem - the new value requires more bytes of -+ storage in the name field than are available. Currently -+ we have no way of fixing this, so we just preserve both -+ notes. */ -+ continue; -+ } -+ -+ /* Write the new val into back. */ -+ name = (unsigned char *) back->namedata + val_start; -+ while (name < (unsigned char *) back->namedata + back->namesz) -+ { -+ byte = back_val & 0xff; -+ * name ++ = byte; -+ if (back_val == 0) -+ break; -+ back_val >>= 8; -+ } -+ -+ duplicate_found = TRUE; -+ pnote->type = 0; -+ break; -+ } -+ - if (back->namesz == pnote->namesz - && memcmp (back->namedata, pnote->namedata, back->namesz) == 0) - { -@@ -1979,11 +2057,12 @@ merge_gnu_build_notes (bfd * abfd, asect - } - - /* If we have found an attribute match then stop searching backwards. */ -- if (! ISPRINT (back->namedata[1]) -- || strcmp (back->namedata + 2, pnote->namedata + 2) == 0) -+ if (! ISPRINT (back->namedata[attribute_type_byte]) -+ /* Names are NUL terminated, so this is safe. */ -+ || strcmp (back->namedata + val_start, pnote->namedata + val_start) == 0) - { - /* Since we are keeping this note we must check to see if its -- description refers back to an earlier OPEN note. If so -+ description refers back to an earlier OPEN version note. If so - then we must make sure that version note is also preserved. */ - if (pnote->descsz == 0 - && prev_open != NULL -@@ -2067,15 +2146,18 @@ merge_gnu_build_notes (bfd * abfd, asect - - if (relcount > 0) - { -- arelent ** rel; -+ arelent **rel = relpp; - -- for (rel = relpp; rel < relpp + relcount; rel ++) -- if ((* rel)->howto == NULL) -+ while (rel < relpp + relcount) -+ if ((*rel)->howto != NULL) -+ rel++; -+ else - { - /* Delete eliminated relocs. - FIXME: There are better ways to do this. */ -- memmove (rel, rel + 1, ((relcount - (rel - relpp)) - 1) * sizeof (* rel)); -- relcount --; -+ memmove (rel, rel + 1, -+ ((relcount - (rel - relpp)) - 1) * sizeof (*rel)); -+ relcount--; - } - bfd_set_reloc (abfd, sec, relpp, relcount); - } -diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c ---- binutils.orig/binutils/readelf.c 2017-06-28 15:28:35.868153969 +0100 -+++ binutils-2.28/binutils/readelf.c 2017-06-28 15:35:01.500695487 +0100 -@@ -16517,7 +16517,7 @@ print_gnu_build_attribute_name (Elf_Inte - const char * expected_types; - const char * name = pnote->namedata; - const char * text; -- int left; -+ signed int left; - - if (name == NULL || pnote->namesz < 2) - { -@@ -16526,6 +16526,16 @@ print_gnu_build_attribute_name (Elf_Inte - return FALSE; - } - -+ left = 20; -+ -+ /* Version 2 of the spec adds a "GA" prefix to the name field. */ -+ if (name[0] == 'G' && name[1] == 'A') -+ { -+ printf ("GA"); -+ name += 2; -+ left -= 2; -+ } -+ - switch ((name_type = * name)) - { - case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: -@@ -16533,6 +16543,7 @@ print_gnu_build_attribute_name (Elf_Inte - case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE: - case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE: - printf ("%c", * name); -+ left --; - break; - default: - error (_("unrecognised attribute type in name field: %d\n"), name_type); -@@ -16540,7 +16551,6 @@ print_gnu_build_attribute_name (Elf_Inte - return FALSE; - } - -- left = 19; - ++ name; - text = NULL; - -@@ -16586,7 +16596,6 @@ print_gnu_build_attribute_name (Elf_Inte - expected_types = bool_expected; - ++ name; - break; -- - default: - if (ISPRINT (* name)) - { -@@ -16601,6 +16610,7 @@ print_gnu_build_attribute_name (Elf_Inte - else - { - static char tmpbuf [128]; -+ - error (_("unrecognised byte in name field: %d\n"), * name); - sprintf (tmpbuf, _(""), * name); - text = tmpbuf; -@@ -16611,10 +16621,7 @@ print_gnu_build_attribute_name (Elf_Inte - } - - if (text) -- { -- printf ("%s", text); -- left -= strlen (text); -- } -+ left -= printf ("%s", text); - - if (strchr (expected_types, name_type) == NULL) - warn (_("attribute does not have an expected type (%c)\n"), name_type); -@@ -16634,10 +16641,10 @@ print_gnu_build_attribute_name (Elf_Inte - { - case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: - { -- unsigned int bytes; -- unsigned long long val = 0; -- unsigned int shift = 0; -- char * decoded = NULL; -+ unsigned int bytes; -+ unsigned long long val = 0; -+ unsigned int shift = 0; -+ char * decoded = NULL; - - bytes = pnote->namesz - (name - pnote->namedata); - if (bytes > 0) -@@ -16735,6 +16742,7 @@ print_gnu_build_attribute_name (Elf_Inte - I.E. the value of namesz for the name "FSF" is 4. - - If the value of namesz is zero, there is no name present. */ -+ - static int - process_note (Elf_Internal_Note * pnote, - FILE * file) ---- fred/binutils/objcopy.c 2017-06-28 15:39:09.627826773 +0100 -+++ binutils-2.28/binutils/objcopy.c 2017-06-28 15:39:29.117601441 +0100 -@@ -1844,6 +1844,22 @@ copy_unknown_object (bfd *ibfd, bfd *obf - return TRUE; - } - -+/* Returns the number of bytes needed to store VAL. */ -+ -+static inline unsigned int -+num_bytes (unsigned long val) -+{ -+ unsigned int count = 0; -+ -+ /* FIXME: There must be a faster way to do this. */ -+ while (val) -+ { -+ count ++; -+ val >>= 8; -+ } -+ return count; -+} -+ - /* Merge the notes on SEC, removing redundant entries. - Returns the new, smaller size of the section upon success. */ - diff --git a/binutils.spec b/binutils.spec index 793a707..edc2dd4 100644 --- a/binutils.spec +++ b/binutils.spec @@ -42,8 +42,8 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} -Version: 2.28 -Release: 14%{?dist} +Version: 2.29 +Release: 1%{?dist} License: GPLv3+ Group: Development/Tools URL: http://sources.redhat.com/binutils @@ -52,49 +52,32 @@ URL: http://sources.redhat.com/binutils # many controversial patches so we stick with the official FSF version # instead. -Source: http://ftp.gnu.org/gnu/binutils/binutils-%{version}.tar.bz2 +Source: http://ftp.gnu.org/gnu/binutils/binutils-%{version}.tar.xz Source2: binutils-2.19.50.0.1-output-format.sed Patch01: binutils-2.20.51.0.2-libtool-lib64.patch -Patch02: binutils-2.20.51.0.10-ppc64-pie.patch -Patch03: binutils-2.25-version.patch -Patch04: binutils-2.25-set-long-long.patch -Patch05: binutils-2.20.51.0.10-sec-merge-emit.patch +Patch02: binutils-2.25-version.patch +Patch03: binutils-2.25-set-long-long.patch +Patch04: binutils-2.20.51.0.10-sec-merge-emit.patch # Enable -zrelro by default: BZ #621983 -Patch06: binutils-2.22.52.0.1-relro-on-by-default.patch +Patch05: binutils-2.22.52.0.1-relro-on-by-default.patch # Local patch - export demangle.h with the binutils-devel rpm. -Patch07: binutils-2.22.52.0.1-export-demangle.h.patch +Patch06: binutils-2.22.52.0.1-export-demangle.h.patch # Disable checks that config.h has been included before system headers. BZ #845084 -Patch08: binutils-2.22.52.0.4-no-config-h-check.patch +Patch07: binutils-2.22.52.0.4-no-config-h-check.patch # Fix detections little endian PPC shared libraries -Patch09: binutils-2.24-ldforcele.patch -Patch10: binutils-2.25.1-cleansweep.patch -Patch11: binutils-2.26-fix-compile-warnings.patch +Patch08: binutils-2.24-ldforcele.patch +Patch09: binutils-2.25.1-cleansweep.patch +Patch10: binutils-2.26-fix-compile-warnings.patch # Import H.J.Lu's Kernel LTO patch. -Patch12: binutils-2.26-lto.patch +Patch11: binutils-2.26-lto.patch # Skip PR14918 linker test for ARM native targets. -Patch13: binutils-2.27-skip-rp14918-test-for-arm.patch +Patch12: binutils-2.29-skip-rp14918-test-for-arm.patch # Include the filename concerned in readelf error messages. -Patch14: binutils-2.27-filename-in-error-messages.patch -# Fix a couple of buffer overflows when printing messages in translated strings. -Patch15: binutils-2.27-ld-buffer-overflow.patch -# Sync libiberty sources with FSF GCC mainline. -Patch16: binutils-2.28-libiberty-bugfixes.patch -# Add support for GNU BUILD NOTEs. -Patch17: binutils-gnu-build-notes.patch -# GAS: Emit name, comp_dir and producer strings in .debug_str. -Patch18: binutils-2.28-gas-comp_dir.patch -# Import fix for PR 21124 and 20519 -Patch19: binutils-2.28-ppc-dynamic-relocs.patch -# Have readelf skip checks of the dynamic section when its type is SHT_NOBITS. -Patch20: binutils-2.28-dynamic-section-warning.patch -# Fix incorrect generation of copy relocs on AArch64. -Patch21: binutils-2.28-aarch64-copy-relocs.patch +Patch13: binutils-2.29-filename-in-error-messages.patch # Ignore duplicate indirect symbols generated by GOLD. -Patch22: binutils-2.28-ignore-gold-duplicates.patch -# Add support for displaying new DWARF5 tags including DW_AT_export_symbols. -Patch23: binutils-2.28-DW_AT_export_symbols.patch +Patch14: binutils-2.28-ignore-gold-duplicates.patch Provides: bundled(libiberty) @@ -213,32 +196,21 @@ using libelf instead of BFD. %prep %setup -q -n binutils-%{version} %patch01 -p1 -b .libtool-lib64~ -%patch02 -p1 -b .ppc64-pie~ -%patch03 -p1 -b .version~ -%patch04 -p1 -b .set-long-long~ -%patch05 -p1 -b .sec-merge-emit~ -%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7 -%patch06 -p1 -b .relro~ -%endif -%patch07 -p1 -b .export-demangle-h~ -%patch08 -p1 -b .no-config-h-check~ +%patch02 -p1 -b .version~ +%patch03 -p1 -b .set-long-long~ +%patch04 -p1 -b .sec-merge-emit~ +%patch05 -p1 -b .relro~ +%patch06 -p1 -b .export-demangle-h~ +%patch07 -p1 -b .no-config-h-check~ %ifarch ppc64le -%patch09 -p1 -b .ldforcele~ +%patch08 -p1 -b .ldforcele~ %endif -%patch10 -p0 +%patch09 -p0 +%patch10 -p1 %patch11 -p1 %patch12 -p1 %patch13 -p1 %patch14 -p1 -%patch15 -p1 -%patch16 -p1 -%patch17 -p1 -%patch18 -p1 -%patch19 -p1 -%patch20 -p1 -%patch21 -p1 -%patch22 -p1 -%patch23 -p1 # We cannot run autotools as there is an exact requirement of autoconf-2.59. @@ -605,6 +577,18 @@ exit 0 %endif # %{isnative} %changelog +* Mon Jul 24 2017 Nick Clifton 2.29-1 +- Rebase on FSF binutils 2.29. +- Retire: binutils-2.20.51.0.10-ppc64-pie.patch +- Retire: binutils-2.27-ld-buffer-overflow.patch +- Retire: binutils-2.28-libiberty-bugfixes.patch +- Retire: binutils-gnu-build-notes.patch +- Retire: binutils-2.28-gas-comp_dir.patch +- Retire: binutils-2.28-ppc-dynamic-relocs.patch +- Retire: binutils-2.28-dynamic-section-warning.patch +- Retire: binutils-2.28-aarch64-copy-relocs.patch +- Retire: binutils-2.28-DW_AT_export_symbols.patch + * Thu Jul 20 2017 Nick Clifton 2.28-14 - Remove -flto compile time option accidentally added to CFLAGS. diff --git a/sources b/sources index 59a30a1..2bbe70c 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (binutils-2.28.tar.bz2) = ede2e4e59a800260eea8c14eafbaee94e30abadafd5c419a3370f9f62213cf027d6400a1d4970b6958bd4d220e675dcd483a708107016e7abd5c99d7392ba8fd +SHA512 (binutils-2.29.tar.xz) = bb227c7af65133a61bbde8be4104a543f4185fce8c8e7be22c36d92d121d28b5413d42f18c7e987d035d6312c542d0e2aaca8930386a4ce26d7c9d7248145398