diff options
author | Tavian Barnes | 2019-02-02 20:50:01 -0500 |
---|---|---|
committer | Tavian Barnes | 2019-02-02 20:50:01 -0500 |
commit | 99cef4ba620f3a10cdfbd36920cf49ab5dc832ae (patch) | |
tree | fbee2a591f94184b1b6531c65174f118189b6b94 | |
parent | efc11959bc88c912a65d75b95adb566247e303ea (diff) | |
download | aur-99cef4ba620f3a10cdfbd36920cf49ab5dc832ae.tar.gz |
Bump to 2.31.1-4
-rw-r--r-- | .SRCINFO | 32 | ||||
-rw-r--r-- | 0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch | 29 | ||||
-rw-r--r-- | 0001-PR23428-x86-Add-a-GNU_PROPERTY_X86_ISA_1_USED-note-if-needed.patch | 515 | ||||
-rw-r--r-- | 0002-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch | 145 | ||||
-rw-r--r-- | 0002-PR23460-Close-resource-leaks-in-the-BFD-library-s-plugin-han.patch | 104 | ||||
-rw-r--r-- | 0003-PR22836-r-s-doesnt-work-with-g3-using-GCC-7.patch | 233 | ||||
-rw-r--r-- | 0003-PR23460-Add-a-testcase-for-PR-binutils-23460.patch | 141 | ||||
-rw-r--r-- | 0004-PR23486-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED-x86_64.patch | 78 | ||||
-rw-r--r-- | 0005-PR23486-x86-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED.patch | 583 | ||||
-rw-r--r-- | 0006-PR23428-x86-Properly-add-X86_ISA_1_NEEDED-property.patch | 135 | ||||
-rw-r--r-- | 0007-PR23919-Handle-ELF-compressed-header-alignment.patch | 316 | ||||
-rw-r--r-- | 0008-PR23919-gold-Get-alignment-of-uncompressed-section.patch | 187 | ||||
-rw-r--r-- | PKGBUILD | 50 |
13 files changed, 2114 insertions, 434 deletions
@@ -1,8 +1,8 @@ # Generated by mksrcinfo v8 -# Fri May 11 14:45:55 UTC 2018 +# Sun Feb 3 01:49:56 UTC 2019 pkgbase = arm-linux-gnueabihf-binutils pkgdesc = A set of programs to assemble and manipulate binary and object files (arm-linux-gnueabihf) - pkgver = 2.30 + pkgver = 2.31.1 pkgrel = 4 url = http://www.gnu.org/software/binutils/ arch = i686 @@ -15,16 +15,26 @@ pkgbase = arm-linux-gnueabihf-binutils options = staticlibs options = !distcc options = !ccache - source = http://ftp.gnu.org/gnu/binutils/binutils-2.30.tar.xz - source = http://ftp.gnu.org/gnu/binutils/binutils-2.30.tar.xz.sig - source = 0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch - source = 0002-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch - source = 0003-PR22836-r-s-doesnt-work-with-g3-using-GCC-7.patch - md5sums = ffc476dd46c96f932875d1b2e27e929f + source = http://ftp.gnu.org/gnu/binutils/binutils-2.31.1.tar.xz + source = http://ftp.gnu.org/gnu/binutils/binutils-2.31.1.tar.xz.sig + source = 0001-PR23428-x86-Add-a-GNU_PROPERTY_X86_ISA_1_USED-note-if-needed.patch + source = 0002-PR23460-Close-resource-leaks-in-the-BFD-library-s-plugin-han.patch + source = 0003-PR23460-Add-a-testcase-for-PR-binutils-23460.patch + source = 0004-PR23486-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED-x86_64.patch + source = 0005-PR23486-x86-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED.patch + source = 0006-PR23428-x86-Properly-add-X86_ISA_1_NEEDED-property.patch + source = 0007-PR23919-Handle-ELF-compressed-header-alignment.patch + source = 0008-PR23919-gold-Get-alignment-of-uncompressed-section.patch + md5sums = 5b7c9d4ce96f507d95c1b9a255e52418 md5sums = SKIP - md5sums = 469164f3c93a0e92a697537b60c9806c - md5sums = 0c679b37e90fb23de60a4d28329b956a - md5sums = 53b5682e09c0a27e9994c3efdfe01d29 + md5sums = f2d4f2aee9ec2e25210eb132acdcf1d9 + md5sums = 496e7e2d71fe558b3b85cdc27fb4638e + md5sums = dd2284134542efe8e38137f5c829a371 + md5sums = 5e4aecddbea729fd045d001e8e8db14e + md5sums = 02247a5f1c06f8a9ade689b7e68629ce + md5sums = 2764b8760bdc8d5c20698202d22b7fcf + md5sums = 5db54b24fb9de56d66111f63aea3b809 + md5sums = 201036d5806b7b037eb53bf796219525 pkgname = arm-linux-gnueabihf-binutils diff --git a/0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch b/0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch deleted file mode 100644 index 24c814ecea89..000000000000 --- a/0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch +++ /dev/null @@ -1,29 +0,0 @@ -From eb77f6a4621795367a39cdd30957903af9dbb815 Mon Sep 17 00:00:00 2001 -From: Alan Modra <amodra@gmail.com> -Date: Sat, 27 Jan 2018 08:19:33 +1030 -Subject: [PATCH] PR22741, objcopy segfault on fuzzed COFF object - - PR 22741 - * coffgen.c (coff_pointerize_aux): Ensure auxent tagndx is in - range before converting to a symbol table pointer. ---- - bfd/coffgen.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/bfd/coffgen.c b/bfd/coffgen.c -index b2410873d0..4f90eaddd9 100644 ---- a/bfd/coffgen.c -+++ b/bfd/coffgen.c -@@ -1555,7 +1555,8 @@ coff_pointerize_aux (bfd *abfd, - } - /* A negative tagndx is meaningless, but the SCO 3.2v4 cc can - generate one, so we must be careful to ignore it. */ -- if (auxent->u.auxent.x_sym.x_tagndx.l > 0) -+ if ((unsigned long) auxent->u.auxent.x_sym.x_tagndx.l -+ < obj_raw_syment_count (abfd)) - { - auxent->u.auxent.x_sym.x_tagndx.p = - table_base + auxent->u.auxent.x_sym.x_tagndx.l; --- -2.16.2 - diff --git a/0001-PR23428-x86-Add-a-GNU_PROPERTY_X86_ISA_1_USED-note-if-needed.patch b/0001-PR23428-x86-Add-a-GNU_PROPERTY_X86_ISA_1_USED-note-if-needed.patch new file mode 100644 index 000000000000..62eca2303c66 --- /dev/null +++ b/0001-PR23428-x86-Add-a-GNU_PROPERTY_X86_ISA_1_USED-note-if-needed.patch @@ -0,0 +1,515 @@ +From f49ffdb448c81035e9ab285720cf74d59df2e111 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" <hjl.tools@gmail.com> +Date: Fri, 20 Jul 2018 09:18:47 -0700 +Subject: [PATCH] x86: Add a GNU_PROPERTY_X86_ISA_1_USED note if needed + +When -z separate-code, which is enabled by default for Linux/x86, is +used to create executable, ld won't place any data in the code-only +PT_LOAD segment. If there are no data sections placed before the +code-only PT_LOAD segment, the program headers won't be mapped into +any PT_LOAD segment. When the executable tries to access it (based +on the program header address passed in AT_PHDR), it will lead to +segfault. This patch inserts a GNU_PROPERTY_X86_ISA_1_USED note if +there may be no data sections before the text section so that the +first PT_LOAD segment won't be code-only and will contain the program +header. + +Testcases are adjusted to either pass "-z noseparate-code" to ld or +discard the .note.gnu.property section. A Linux/x86 run-time test is +added. + +bfd/ + + PR ld/23428 + * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): If the + separate code program header is needed, make sure that the first + read-only PT_LOAD segment has no code by adding a + GNU_PROPERTY_X86_ISA_1_USED note. + +ld/ + + PR ld/23428 + * testsuite/ld-elf/linux-x86.S: New file. + * testsuite/ld-elf/linux-x86.exp: Likewise. + * testsuite/ld-elf/pr23428.c: Likewise. + * testsuite/ld-elf/sec64k.exp: Pass "-z noseparate-code" to ld + for Linux/x86 targets. + * testsuite/ld-i386/abs-iamcu.d: Likewise. + * testsuite/ld-i386/abs.d: Likewise. + * testsuite/ld-i386/pr12718.d: Likewise. + * testsuite/ld-i386/pr12921.d: Likewise. + * testsuite/ld-x86-64/abs-k1om.d: Likewise. + * testsuite/ld-x86-64/abs-l1om.d: Likewise. + * testsuite/ld-x86-64/abs.d: Likewise. + * testsuite/ld-x86-64/pr12718.d: Likewise. + * testsuite/ld-x86-64/pr12921.d: Likewise. + * testsuite/ld-linkonce/zeroeh.ld: Discard .note.gnu.property + section. + * testsuite/ld-scripts/print-memory-usage.t: Likewise. + * testsuite/ld-scripts/size-2.t: Likewise. + * testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Use ld + to create executable if language is "asm". +--- + bfd/elfxx-x86.c | 60 ++++++++++++++----- + ld/testsuite/ld-elf/linux-x86.S | 63 ++++++++++++++++++++ + ld/testsuite/ld-elf/linux-x86.exp | 46 ++++++++++++++ + ld/testsuite/ld-elf/pr23428.c | 43 +++++++++++++ + ld/testsuite/ld-elf/sec64k.exp | 2 + + ld/testsuite/ld-i386/abs-iamcu.d | 2 +- + ld/testsuite/ld-i386/abs.d | 2 +- + ld/testsuite/ld-i386/pr12718.d | 2 +- + ld/testsuite/ld-i386/pr12921.d | 2 +- + ld/testsuite/ld-linkonce/zeroeh.ld | 1 + + ld/testsuite/ld-scripts/print-memory-usage.t | 2 + + ld/testsuite/ld-scripts/size-2.t | 1 + + ld/testsuite/ld-x86-64/abs-k1om.d | 2 +- + ld/testsuite/ld-x86-64/abs-l1om.d | 2 +- + ld/testsuite/ld-x86-64/abs.d | 2 +- + ld/testsuite/ld-x86-64/pr12718.d | 2 +- + ld/testsuite/ld-x86-64/pr12921.d | 2 +- + ld/testsuite/lib/ld-lib.exp | 5 +- + 18 files changed, 216 insertions(+), 25 deletions(-) + create mode 100644 ld/testsuite/ld-elf/linux-x86.S + create mode 100644 ld/testsuite/ld-elf/linux-x86.exp + create mode 100644 ld/testsuite/ld-elf/pr23428.c + +diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c +index a2497aab86..2e4ff88f1f 100644 +--- a/bfd/elfxx-x86.c ++++ b/bfd/elfxx-x86.c +@@ -2524,6 +2524,7 @@ _bfd_x86_elf_link_setup_gnu_properties + const struct elf_backend_data *bed; + unsigned int class_align = ABI_64_P (info->output_bfd) ? 3 : 2; + unsigned int got_align; ++ bfd_boolean has_text = FALSE; + + features = 0; + if (info->ibt) +@@ -2538,24 +2539,59 @@ _bfd_x86_elf_link_setup_gnu_properties + if (bfd_get_flavour (pbfd) == bfd_target_elf_flavour + && bfd_count_sections (pbfd) != 0) + { ++ if (!has_text) ++ { ++ /* Check if there is no non-empty text section. */ ++ sec = bfd_get_section_by_name (pbfd, ".text"); ++ if (sec != NULL && sec->size != 0) ++ has_text = TRUE; ++ } ++ + ebfd = pbfd; + + if (elf_properties (pbfd) != NULL) + break; + } + +- if (ebfd != NULL && features) ++ bed = get_elf_backend_data (info->output_bfd); ++ ++ htab = elf_x86_hash_table (info, bed->target_id); ++ if (htab == NULL) ++ return pbfd; ++ ++ if (ebfd != NULL) + { +- /* If features is set, add GNU_PROPERTY_X86_FEATURE_1_IBT and +- GNU_PROPERTY_X86_FEATURE_1_SHSTK. */ +- prop = _bfd_elf_get_property (ebfd, +- GNU_PROPERTY_X86_FEATURE_1_AND, +- 4); +- prop->u.number |= features; +- prop->pr_kind = property_number; ++ prop = NULL; ++ if (features) ++ { ++ /* If features is set, add GNU_PROPERTY_X86_FEATURE_1_IBT and ++ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */ ++ prop = _bfd_elf_get_property (ebfd, ++ GNU_PROPERTY_X86_FEATURE_1_AND, ++ 4); ++ prop->u.number |= features; ++ prop->pr_kind = property_number; ++ } ++ else if (has_text ++ && elf_properties (ebfd) == NULL ++ && elf_tdata (info->output_bfd)->o->build_id.sec == NULL ++ && !htab->elf.dynamic_sections_created ++ && !info->traditional_format ++ && (info->output_bfd->flags & D_PAGED) != 0 ++ && info->separate_code) ++ { ++ /* If the separate code program header is needed, make sure ++ that the first read-only PT_LOAD segment has no code by ++ adding a GNU_PROPERTY_X86_ISA_1_USED note. */ ++ prop = _bfd_elf_get_property (ebfd, ++ GNU_PROPERTY_X86_ISA_1_USED, ++ 4); ++ prop->u.number = GNU_PROPERTY_X86_ISA_1_486; ++ prop->pr_kind = property_number; ++ } + + /* Create the GNU property note section if needed. */ +- if (pbfd == NULL) ++ if (prop != NULL && pbfd == NULL) + { + sec = bfd_make_section_with_flags (ebfd, + NOTE_GNU_PROPERTY_SECTION_NAME, +@@ -2581,12 +2617,6 @@ error_alignment: + + pbfd = _bfd_elf_link_setup_gnu_properties (info); + +- bed = get_elf_backend_data (info->output_bfd); +- +- htab = elf_x86_hash_table (info, bed->target_id); +- if (htab == NULL) +- return pbfd; +- + htab->r_info = init_table->r_info; + htab->r_sym = init_table->r_sym; + +diff --git a/ld/testsuite/ld-elf/linux-x86.S b/ld/testsuite/ld-elf/linux-x86.S +new file mode 100644 +index 0000000000..bdf40c6e01 +--- /dev/null ++++ b/ld/testsuite/ld-elf/linux-x86.S +@@ -0,0 +1,63 @@ ++ .text ++ .globl _start ++ .type _start,@function ++ .p2align 4 ++_start: ++ xorl %ebp, %ebp ++#ifdef __LP64__ ++ popq %rdi ++ movq %rsp, %rsi ++ andq $~15, %rsp ++#elif defined __x86_64__ ++ mov (%rsp),%edi ++ addl $4,%esp ++ movl %esp, %esi ++ andl $~15, %esp ++#else ++ popl %esi ++ movl %esp, %ecx ++ andl $~15, %esp ++ ++ subl $8,%esp ++ pushl %ecx ++ pushl %esi ++#endif ++ ++ call main ++ ++ hlt ++ ++ .type syscall, @function ++ .globl syscall ++ .p2align 4 ++syscall: ++#ifdef __x86_64__ ++ movq %rdi, %rax /* Syscall number -> rax. */ ++ movq %rsi, %rdi /* shift arg1 - arg5. */ ++ movq %rdx, %rsi ++ movq %rcx, %rdx ++ movq %r8, %r10 ++ movq %r9, %r8 ++ movq 8(%rsp),%r9 /* arg6 is on the stack. */ ++ syscall /* Do the system call. */ ++#else ++ push %ebp ++ push %edi ++ push %esi ++ push %ebx ++ mov 0x2c(%esp),%ebp ++ mov 0x28(%esp),%edi ++ mov 0x24(%esp),%esi ++ mov 0x20(%esp),%edx ++ mov 0x1c(%esp),%ecx ++ mov 0x18(%esp),%ebx ++ mov 0x14(%esp),%eax ++ int $0x80 ++ pop %ebx ++ pop %esi ++ pop %edi ++ pop %ebp ++#endif ++ ret /* Return to caller. */ ++ .size syscall, .-syscall ++ .section .note.GNU-stack,"",@progbits +diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp +new file mode 100644 +index 0000000000..36217c6fb4 +--- /dev/null ++++ b/ld/testsuite/ld-elf/linux-x86.exp +@@ -0,0 +1,46 @@ ++# Expect script for simple native Linux/x86 tests. ++# Copyright (C) 2018 Free Software Foundation, Inc. ++# ++# This file is part of the GNU Binutils. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++# MA 02110-1301, USA. ++# ++ ++# Test very simple native Linux/x86 programs with linux-x86.S. ++if { ![isnative] || [which $CC] == 0 \ ++ || (![istarget "i?86-*-linux*"] \ ++ && ![istarget "x86_64-*-linux*"] \ ++ && ![istarget "amd64-*-linux*"]) } { ++ return ++} ++ ++# Add $PLT_CFLAGS if PLT is expected. ++global PLT_CFLAGS ++# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required. ++global NOPIE_CFLAGS NOPIE_LDFLAGS ++ ++run_ld_link_exec_tests [list \ ++ [list \ ++ "Run PR ld/23428 test" \ ++ "--no-dynamic-linker -z separate-code" \ ++ "" \ ++ { linux-x86.S pr23428.c } \ ++ "pr23428" \ ++ "pass.out" \ ++ "$NOPIE_CFLAGS -fno-asynchronous-unwind-tables" \ ++ "asm" \ ++ ] \ ++] +diff --git a/ld/testsuite/ld-elf/pr23428.c b/ld/testsuite/ld-elf/pr23428.c +new file mode 100644 +index 0000000000..3631ed7926 +--- /dev/null ++++ b/ld/testsuite/ld-elf/pr23428.c +@@ -0,0 +1,43 @@ ++#include <unistd.h> ++#include <link.h> ++#include <syscall.h> ++ ++#define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1) ++ ++int ++main (int argc, char **argv) ++{ ++ char **ev = &argv[argc + 1]; ++ char **evp = ev; ++ ElfW(auxv_t) *av; ++ const ElfW(Phdr) *phdr = NULL; ++ size_t phnum = 0; ++ size_t loadnum = 0; ++ int fd = STDOUT_FILENO; ++ size_t i; ++ ++ while (*evp++ != NULL) ++ ; ++ ++ av = (ElfW(auxv_t) *) evp; ++ ++ for (; av->a_type != AT_NULL; ++av) ++ switch (av->a_type) ++ { ++ case AT_PHDR: ++ phdr = (const void *) av->a_un.a_val; ++ break; ++ case AT_PHNUM: ++ phnum = av->a_un.a_val; ++ break; ++ } ++ ++ for (i = 0; i < phnum; i++, phdr++) ++ if (phdr->p_type == PT_LOAD) ++ loadnum++; ++ ++ syscall (SYS_write, fd, STRING_COMMA_LEN ("PASS\n")); ++ ++ syscall (SYS_exit, !loadnum); ++ return 0; ++} +diff --git a/ld/testsuite/ld-elf/sec64k.exp b/ld/testsuite/ld-elf/sec64k.exp +index b58139e9dd..3909c0eaa1 100644 +--- a/ld/testsuite/ld-elf/sec64k.exp ++++ b/ld/testsuite/ld-elf/sec64k.exp +@@ -177,6 +177,8 @@ if { ![istarget "d10v-*-*"] + foreach sfile $sfiles { puts $ofd "#source: $sfile" } + if { [istarget spu*-*-*] } { + puts $ofd "#ld: --local-store 0:0" ++ } elseif { [istarget "i?86-*-linux*"] || [istarget "x86_64-*-linux*"] } { ++ puts $ofd "#ld: -z noseparate-code" + } else { + puts $ofd "#ld:" + } +diff --git a/ld/testsuite/ld-i386/abs-iamcu.d b/ld/testsuite/ld-i386/abs-iamcu.d +index ac9beff2e5..aba7d6b03f 100644 +--- a/ld/testsuite/ld-i386/abs-iamcu.d ++++ b/ld/testsuite/ld-i386/abs-iamcu.d +@@ -2,7 +2,7 @@ + #source: abs.s + #source: zero.s + #as: --32 -march=iamcu +-#ld: -m elf_iamcu ++#ld: -m elf_iamcu -z noseparate-code + #objdump: -rs -j .text + + .*: file format .* +diff --git a/ld/testsuite/ld-i386/abs.d b/ld/testsuite/ld-i386/abs.d +index e660aca524..191ee4456a 100644 +--- a/ld/testsuite/ld-i386/abs.d ++++ b/ld/testsuite/ld-i386/abs.d +@@ -2,7 +2,7 @@ + #as: --32 + #source: abs.s + #source: zero.s +-#ld: -melf_i386 ++#ld: -melf_i386 -z noseparate-code + #objdump: -rs + + .*: file format .* +diff --git a/ld/testsuite/ld-i386/pr12718.d b/ld/testsuite/ld-i386/pr12718.d +index ec51540a42..7eba52d95e 100644 +--- a/ld/testsuite/ld-i386/pr12718.d ++++ b/ld/testsuite/ld-i386/pr12718.d +@@ -1,6 +1,6 @@ + #name: PR ld/12718 + #as: --32 +-#ld: -melf_i386 ++#ld: -melf_i386 -z noseparate-code + #readelf: -S + + There are 5 section headers, starting at offset 0x[0-9a-f]+: +diff --git a/ld/testsuite/ld-i386/pr12921.d b/ld/testsuite/ld-i386/pr12921.d +index e49079b3c8..ea2da3eb51 100644 +--- a/ld/testsuite/ld-i386/pr12921.d ++++ b/ld/testsuite/ld-i386/pr12921.d +@@ -1,6 +1,6 @@ + #name: PR ld/12921 + #as: --32 +-#ld: -melf_i386 ++#ld: -melf_i386 -z noseparate-code + #readelf: -S --wide + + There are 7 section headers, starting at offset 0x[0-9a-f]+: +diff --git a/ld/testsuite/ld-linkonce/zeroeh.ld b/ld/testsuite/ld-linkonce/zeroeh.ld +index b22eaa12c9..f89855a08f 100644 +--- a/ld/testsuite/ld-linkonce/zeroeh.ld ++++ b/ld/testsuite/ld-linkonce/zeroeh.ld +@@ -2,4 +2,5 @@ SECTIONS { + .text 0xa00 : { *(.text); *(.gnu.linkonce.t.*) } + .gcc_except_table 0x2000 : { *(.gcc_except_table) } + .eh_frame 0x4000 : { *(.eh_frame) } ++ /DISCARD/ : { *(.note.gnu.property) } + } +diff --git a/ld/testsuite/ld-scripts/print-memory-usage.t b/ld/testsuite/ld-scripts/print-memory-usage.t +index 5ff057a5e3..6eda1d2dc4 100644 +--- a/ld/testsuite/ld-scripts/print-memory-usage.t ++++ b/ld/testsuite/ld-scripts/print-memory-usage.t +@@ -11,4 +11,6 @@ SECTIONS + *(.data) + *(.rw) + } ++ ++ /DISCARD/ : { *(.note.gnu.property) } + } +diff --git a/ld/testsuite/ld-scripts/size-2.t b/ld/testsuite/ld-scripts/size-2.t +index 723863995e..c3c4eddab4 100644 +--- a/ld/testsuite/ld-scripts/size-2.t ++++ b/ld/testsuite/ld-scripts/size-2.t +@@ -18,4 +18,5 @@ SECTIONS + LONG (SIZEOF (.tdata)) + LONG (SIZEOF (.tbss)) + } :image ++ /DISCARD/ : { *(.note.gnu.property) } + } +diff --git a/ld/testsuite/ld-x86-64/abs-k1om.d b/ld/testsuite/ld-x86-64/abs-k1om.d +index 2c26639fc0..6b0fde0eed 100644 +--- a/ld/testsuite/ld-x86-64/abs-k1om.d ++++ b/ld/testsuite/ld-x86-64/abs-k1om.d +@@ -2,7 +2,7 @@ + #source: ../ld-i386/abs.s + #source: ../ld-i386/zero.s + #as: --64 -march=k1om +-#ld: -m elf_k1om ++#ld: -m elf_k1om -z noseparate-code + #objdump: -rs -j .text + + .*: file format .* +diff --git a/ld/testsuite/ld-x86-64/abs-l1om.d b/ld/testsuite/ld-x86-64/abs-l1om.d +index 1fb96d44b7..f87869f9d0 100644 +--- a/ld/testsuite/ld-x86-64/abs-l1om.d ++++ b/ld/testsuite/ld-x86-64/abs-l1om.d +@@ -2,7 +2,7 @@ + #source: ../ld-i386/abs.s + #source: ../ld-i386/zero.s + #as: --64 -march=l1om +-#ld: -m elf_l1om ++#ld: -m elf_l1om -z noseparate-code + #objdump: -rs -j .text + #target: x86_64-*-linux* + +diff --git a/ld/testsuite/ld-x86-64/abs.d b/ld/testsuite/ld-x86-64/abs.d +index b24b018639..d99ab4685d 100644 +--- a/ld/testsuite/ld-x86-64/abs.d ++++ b/ld/testsuite/ld-x86-64/abs.d +@@ -1,7 +1,7 @@ + #name: Absolute non-overflowing relocs + #source: ../ld-i386/abs.s + #source: ../ld-i386/zero.s +-#ld: ++#ld: -z noseparate-code + #objdump: -rs + + .*: file format .* +diff --git a/ld/testsuite/ld-x86-64/pr12718.d b/ld/testsuite/ld-x86-64/pr12718.d +index 07d17325d0..2c503ffbaa 100644 +--- a/ld/testsuite/ld-x86-64/pr12718.d ++++ b/ld/testsuite/ld-x86-64/pr12718.d +@@ -1,6 +1,6 @@ + #name: PR ld/12718 + #as: --64 +-#ld: -melf_x86_64 ++#ld: -melf_x86_64 -z noseparate-code + #readelf: -S --wide + + There are 5 section headers, starting at offset 0x[0-9a-f]+: +diff --git a/ld/testsuite/ld-x86-64/pr12921.d b/ld/testsuite/ld-x86-64/pr12921.d +index 6fe6abee09..1162d55818 100644 +--- a/ld/testsuite/ld-x86-64/pr12921.d ++++ b/ld/testsuite/ld-x86-64/pr12921.d +@@ -1,6 +1,6 @@ + #name: PR ld/12921 + #as: --64 +-#ld: -melf_x86_64 ++#ld: -melf_x86_64 -z noseparate-code + #readelf: -S --wide + + There are 7 section headers, starting at offset 0x[0-9a-f]+: +diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp +index cfbefe9028..1095091882 100644 +--- a/ld/testsuite/lib/ld-lib.exp ++++ b/ld/testsuite/lib/ld-lib.exp +@@ -1482,7 +1482,10 @@ proc run_ld_link_exec_tests { ldtests args } { + continue + } + +- if { [ string match "c++" $lang ] } { ++ if { [ string match "asm" $lang ] } { ++ set link_proc ld_link ++ set link_cmd $ld ++ } elseif { [ string match "c++" $lang ] } { + set link_proc ld_link + set link_cmd $CXX + } else { +-- +2.18.0 + diff --git a/0002-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch b/0002-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch deleted file mode 100644 index 3b73a6a3e344..000000000000 --- a/0002-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch +++ /dev/null @@ -1,145 +0,0 @@ -From 3b56a1358768563d9cf320559ebdedfb30f122dd Mon Sep 17 00:00:00 2001 -From: Alan Modra <amodra@gmail.com> -Date: Mon, 12 Feb 2018 13:06:07 +1030 -Subject: [PATCH] PR22829, objcopy/strip removes PT_GNU_RELRO from lld binaries - -lld lays out the relro segment differently to GNU ld, not bothering to -include the first few bytes of .got.plt and padding out to a page at -the end of the segment. This patch teaches binutils to recognize the -different (and somewhat inferior) layout as valid. - -bfd/ - PR 22829 - * elf.c (assign_file_positions_for_non_load_sections): Rewrite - PT_GNU_RELRO setup. -ld/ - * testsuite/ld-x86-64/pr14207.d: Adjust relro p_filesz. - -(cherry picked from commit f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f) ---- - bfd/elf.c | 78 ++++++++++++++++++++++++++-------------- - ld/testsuite/ld-x86-64/pr14207.d | 2 +- - 2 files changed, 52 insertions(+), 28 deletions(-) - -diff --git a/bfd/elf.c b/bfd/elf.c -index bbaab26918..f5a230cd77 100644 ---- a/bfd/elf.c -+++ b/bfd/elf.c -@@ -5826,50 +5826,74 @@ assign_file_positions_for_non_load_sections (bfd *abfd, - { - if (p->p_type == PT_GNU_RELRO) - { -- const Elf_Internal_Phdr *lp; -- struct elf_segment_map *lm; -+ bfd_vma start, end; - - if (link_info != NULL) - { - /* During linking the range of the RELRO segment is passed -- in link_info. */ -+ in link_info. Note that there may be padding between -+ relro_start and the first RELRO section. */ -+ start = link_info->relro_start; -+ end = link_info->relro_end; -+ } -+ else if (m->count != 0) -+ { -+ if (!m->p_size_valid) -+ abort (); -+ start = m->sections[0]->vma; -+ end = start + m->p_size; -+ } -+ else -+ { -+ start = 0; -+ end = 0; -+ } -+ -+ if (start < end) -+ { -+ struct elf_segment_map *lm; -+ const Elf_Internal_Phdr *lp; -+ unsigned int i; -+ -+ /* Find a LOAD segment containing a section in the RELRO -+ segment. */ - for (lm = elf_seg_map (abfd), lp = phdrs; - lm != NULL; - lm = lm->next, lp++) - { - if (lp->p_type == PT_LOAD -- && lp->p_vaddr < link_info->relro_end - && lm->count != 0 -- && lm->sections[0]->vma >= link_info->relro_start) -+ && lm->sections[lm->count - 1]->vma >= start -+ && lm->sections[0]->vma < end) - break; - } -- - BFD_ASSERT (lm != NULL); -- } -- else -- { -- /* Otherwise we are copying an executable or shared -- library, but we need to use the same linker logic. */ -- for (lp = phdrs; lp < phdrs + count; ++lp) -+ -+ /* Find the section starting the RELRO segment. */ -+ for (i = 0; i < lm->count; i++) - { -- if (lp->p_type == PT_LOAD -- && lp->p_paddr == p->p_paddr) -+ asection *s = lm->sections[i]; -+ if (s->vma >= start -+ && s->vma < end -+ && s->size != 0) - break; - } -- } -+ BFD_ASSERT (i < lm->count); -+ -+ p->p_vaddr = lm->sections[i]->vma; -+ p->p_paddr = lm->sections[i]->lma; -+ p->p_offset = lm->sections[i]->filepos; -+ p->p_memsz = end - p->p_vaddr; -+ p->p_filesz = p->p_memsz; -+ -+ /* The RELRO segment typically ends a few bytes into -+ .got.plt but other layouts are possible. In cases -+ where the end does not match any loaded section (for -+ instance is in file padding), trim p_filesz back to -+ correspond to the end of loaded section contents. */ -+ if (p->p_filesz > lp->p_vaddr + lp->p_filesz - p->p_vaddr) -+ p->p_filesz = lp->p_vaddr + lp->p_filesz - p->p_vaddr; - -- if (lp < phdrs + count) -- { -- p->p_vaddr = lp->p_vaddr; -- p->p_paddr = lp->p_paddr; -- p->p_offset = lp->p_offset; -- if (link_info != NULL) -- p->p_filesz = link_info->relro_end - lp->p_vaddr; -- else if (m->p_size_valid) -- p->p_filesz = m->p_size; -- else -- abort (); -- p->p_memsz = p->p_filesz; - /* Preserve the alignment and flags if they are valid. The - gold linker generates RW/4 for the PT_GNU_RELRO section. - It is better for objcopy/strip to honor these attributes -diff --git a/ld/testsuite/ld-x86-64/pr14207.d b/ld/testsuite/ld-x86-64/pr14207.d -index f6558e7cd7..41f92b8bd8 100644 ---- a/ld/testsuite/ld-x86-64/pr14207.d -+++ b/ld/testsuite/ld-x86-64/pr14207.d -@@ -13,7 +13,7 @@ Program Headers: - LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0001c8 0x0001c8 R 0x200000 - LOAD 0x000b.8 0x0000000000200b.8 0x0000000000200b.8 0x0004.0 0x000c.8 RW 0x200000 - DYNAMIC 0x000b.0 0x0000000000200b.0 0x0000000000200b.0 0x0001.0 0x0001.0 RW 0x8 -- GNU_RELRO 0x000b.8 0x0000000000200b.8 0x0000000000200b.8 0x0004.8 0x0004.8 R 0x1 -+ GNU_RELRO 0x000b.8 0x0000000000200b.8 0x0000000000200b.8 0x0004.0 0x0004.8 R 0x1 - - Section to Segment mapping: - Segment Sections... --- -2.16.2 - diff --git a/0002-PR23460-Close-resource-leaks-in-the-BFD-library-s-plugin-han.patch b/0002-PR23460-Close-resource-leaks-in-the-BFD-library-s-plugin-han.patch new file mode 100644 index 000000000000..09c9c315db20 --- /dev/null +++ b/0002-PR23460-Close-resource-leaks-in-the-BFD-library-s-plugin-han.patch @@ -0,0 +1,104 @@ +From 29175af7e3859b9892e9113ea9a71e38048552e2 Mon Sep 17 00:00:00 2001 +From: Nick Clifton <nickc@redhat.com> +Date: Wed, 1 Aug 2018 14:34:41 +0100 +Subject: [PATCH] Close resource leaks in the BFD library's plugin handler. + + PR 23460 + * plugin.c (bfd_plugin_open_input): Close file descriptor if the + call to fstat fails. + (try_claim): Always close the file descriptor at the end of the + function. + (try_load_plugin): If a plugin has already been registered, then + skip the dlopen and onload steps and go straight to claiming the + file. If these is an error, close the plugin. +--- + bfd/plugin.c | 26 +++++++++++++++++++------- + 1 file changed, 19 insertions(+), 7 deletions(-) + +diff --git a/bfd/plugin.c b/bfd/plugin.c +index 7c5bba22c7..d9b9e2f174 100644 +--- a/bfd/plugin.c ++++ b/bfd/plugin.c +@@ -124,7 +124,7 @@ message (int level ATTRIBUTE_UNUSED, + } + + /* Register a claim-file handler. */ +-static ld_plugin_claim_file_handler claim_file; ++static ld_plugin_claim_file_handler claim_file = NULL; + + static enum ld_plugin_status + register_claim_file (ld_plugin_claim_file_handler handler) +@@ -186,8 +186,13 @@ bfd_plugin_open_input (bfd *ibfd, struct ld_plugin_input_file *file) + if (iobfd == ibfd) + { + struct stat stat_buf; ++ + if (fstat (file->fd, &stat_buf)) +- return 0; ++ { ++ close(file->fd); ++ return 0; ++ } ++ + file->offset = 0; + file->filesize = stat_buf.st_size; + } +@@ -208,21 +213,24 @@ try_claim (bfd *abfd) + file.handle = abfd; + if (!bfd_plugin_open_input (abfd, &file)) + return 0; +- claim_file (&file, &claimed); +- if (!claimed) +- close (file.fd); ++ if (claim_file) ++ claim_file (&file, &claimed); ++ close (file.fd); + return claimed; + } + + static int + try_load_plugin (const char *pname, bfd *abfd, int *has_plugin_p) + { +- void *plugin_handle; ++ void *plugin_handle = NULL; + struct ld_plugin_tv tv[4]; + int i; + ld_plugin_onload onload; + enum ld_plugin_status status; + ++ if (claim_file) ++ goto have_claim_file; ++ + *has_plugin_p = 0; + + plugin_handle = dlopen (pname, RTLD_NOW); +@@ -257,6 +265,7 @@ try_load_plugin (const char *pname, bfd *abfd, int *has_plugin_p) + if (status != LDPS_OK) + goto err; + ++have_claim_file: + *has_plugin_p = 1; + + abfd->plugin_format = bfd_plugin_no; +@@ -272,6 +281,9 @@ try_load_plugin (const char *pname, bfd *abfd, int *has_plugin_p) + return 1; + + err: ++ if (plugin_handle) ++ dlclose (plugin_handle); ++ register_claim_file (NULL); + return 0; + } + +@@ -362,7 +374,7 @@ load_plugin (bfd *abfd) + int valid_plugin; + + full_name = concat (p, "/", ent->d_name, NULL); +- if (stat(full_name, &s) == 0 && S_ISREG (s.st_mode)) ++ if (stat (full_name, &s) == 0 && S_ISREG (s.st_mode)) + found = try_load_plugin (full_name, abfd, &valid_plugin); + if (has_plugin <= 0) + has_plugin = valid_plugin; +-- +2.18.0 + diff --git a/0003-PR22836-r-s-doesnt-work-with-g3-using-GCC-7.patch b/0003-PR22836-r-s-doesnt-work-with-g3-using-GCC-7.patch deleted file mode 100644 index 2f3c65244bc9..000000000000 --- a/0003-PR22836-r-s-doesnt-work-with-g3-using-GCC-7.patch +++ /dev/null @@ -1,233 +0,0 @@ -From d957f81cb38d7e82ae546cd03265ee3087ba8a85 Mon Sep 17 00:00:00 2001 -From: Alan Modra <amodra@gmail.com> -Date: Tue, 13 Feb 2018 14:09:48 +1030 -Subject: [PATCH] PR22836, "-r -s" doesn't work with -g3 using GCC 7 - -This fixes the case where all of a group is removed with ld -r, the -situation in the PR, and failures where part of a group is removed -that contain relocs. - -bfd/ - PR 22836 - * elf.c (_bfd_elf_fixup_group_sections): Account for removed - relocation sections. If size reduces to just the flag word, - remove that too and mark with SEC_EXCLUDE. - * elflink.c (bfd_elf_final_link): Strip empty group sections. -binutils/ - * testsuite/binutils-all/group-7.s, - * testsuite/binutils-all/group-7a.d, - * testsuite/binutils-all/group-7b.d, - * testsuite/binutils-all/group-7c.d: New tests. - * testsuite/binutils-all/objcopy.exp: Run them. -ld/ - * testsuite/ld-elf/pr22836-2.d, - * testsuite/ld-elf/pr22836-2.s: New test. - -(cherry picked from commit 6e5e9d58c1eeef5677c90886578a895cb8c164c5) ---- - bfd/ChangeLog | 11 +++++++++++ - bfd/elf.c | 25 +++++++++++++++++++++---- - bfd/elflink.c | 7 +++++++ - binutils/ChangeLog | 12 ++++++++++++ - binutils/testsuite/binutils-all/group-7.s | 6 ++++++ - binutils/testsuite/binutils-all/group-7a.d | 16 ++++++++++++++++ - binutils/testsuite/binutils-all/group-7b.d | 19 +++++++++++++++++++ - binutils/testsuite/binutils-all/group-7c.d | 8 ++++++++ - binutils/testsuite/binutils-all/objcopy.exp | 3 +++ - ld/ChangeLog | 9 +++++++++ - ld/testsuite/ld-elf/pr22836-2.d | 7 +++++++ - ld/testsuite/ld-elf/pr22836-2.s | 7 +++++++ - 12 files changed, 126 insertions(+), 4 deletions(-) - create mode 100644 binutils/testsuite/binutils-all/group-7.s - create mode 100644 binutils/testsuite/binutils-all/group-7a.d - create mode 100644 binutils/testsuite/binutils-all/group-7b.d - create mode 100644 binutils/testsuite/binutils-all/group-7c.d - create mode 100644 ld/testsuite/ld-elf/pr22836-2.d - create mode 100644 ld/testsuite/ld-elf/pr22836-2.s - -diff --git a/bfd/elf.c b/bfd/elf.c -index 325bdd5..e95c8a9 100644 ---- a/bfd/elf.c -+++ b/bfd/elf.c -@@ -7579,7 +7579,16 @@ _bfd_elf_fixup_group_sections (bfd *ibfd, asection *discarded) - but the SHT_GROUP section is, then adjust its size. */ - else if (s->output_section == discarded - && isec->output_section != discarded) -- removed += 4; -+ { -+ struct bfd_elf_section_data *elf_sec = elf_section_data (s); -+ removed += 4; -+ if (elf_sec->rel.hdr != NULL -+ && (elf_sec->rel.hdr->sh_flags & SHF_GROUP) != 0) -+ removed += 4; -+ if (elf_sec->rela.hdr != NULL -+ && (elf_sec->rela.hdr->sh_flags & SHF_GROUP) != 0) -+ removed += 4; -+ } - s = elf_next_in_group (s); - if (s == first) - break; -@@ -7589,18 +7598,26 @@ _bfd_elf_fixup_group_sections (bfd *ibfd, asection *discarded) - if (discarded != NULL) - { - /* If we've been called for ld -r, then we need to -- adjust the input section size. This function may -- be called multiple times, so save the original -- size. */ -+ adjust the input section size. */ - if (isec->rawsize == 0) - isec->rawsize = isec->size; - isec->size = isec->rawsize - removed; -+ if (isec->size <= 4) -+ { -+ isec->size = 0; -+ isec->flags |= SEC_EXCLUDE; -+ } - } - else - { - /* Adjust the output section size when called from - objcopy. */ - isec->output_section->size -= removed; -+ if (isec->output_section->size <= 4) -+ { -+ isec->output_section->size = 0; -+ isec->output_section->flags |= SEC_EXCLUDE; -+ } - } - } - } -diff --git a/bfd/elflink.c b/bfd/elflink.c -index 72aa3ac..69cb5ab 100644 ---- a/bfd/elflink.c -+++ b/bfd/elflink.c -@@ -11618,6 +11618,13 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) - else - o->flags |= SEC_EXCLUDE; - } -+ else if ((o->flags & SEC_GROUP) != 0 && o->size == 0) -+ { -+ /* Remove empty group section from linker output. */ -+ o->flags |= SEC_EXCLUDE; -+ bfd_section_list_remove (abfd, o); -+ abfd->section_count--; -+ } - } - - /* Count up the number of relocations we will output for each output -diff --git a/binutils/testsuite/binutils-all/group-7.s b/binutils/testsuite/binutils-all/group-7.s -new file mode 100644 -index 0000000..5028afc ---- /dev/null -+++ b/binutils/testsuite/binutils-all/group-7.s -@@ -0,0 +1,6 @@ -+ .section .data.foo,"awG",%progbits,foo,comdat -+here: -+ .dc.a here -+ -+ .section .data2.foo,"awG",%progbits,foo,comdat -+ .dc.a 0 -diff --git a/binutils/testsuite/binutils-all/group-7a.d b/binutils/testsuite/binutils-all/group-7a.d -new file mode 100644 -index 0000000..fa8db60 ---- /dev/null -+++ b/binutils/testsuite/binutils-all/group-7a.d -@@ -0,0 +1,16 @@ -+#name: copy removing reloc group member -+#source: group-7.s -+#PROG: objcopy -+#DUMPPROG: readelf -+#objcopy: --remove-section .data.foo -+#readelf: -Sg --wide -+ -+#... -+ \[[ 0-9]+\] \.group[ \t]+GROUP[ \t]+.* -+#... -+ \[[ 0-9]+\] \.data2\.foo[ \t]+PROGBITS[ \t0-9a-f]+WAG.* -+#... -+COMDAT group section \[[ 0-9]+\] `\.group' \[foo\] contains 1 section.* -+ \[Index\] Name -+ \[[ 0-9]+\] \.data2\.foo -+#pass -diff --git a/binutils/testsuite/binutils-all/group-7b.d b/binutils/testsuite/binutils-all/group-7b.d -new file mode 100644 -index 0000000..b674545 ---- /dev/null -+++ b/binutils/testsuite/binutils-all/group-7b.d -@@ -0,0 +1,19 @@ -+#name: copy removing non-reloc group member -+#source: group-7.s -+#PROG: objcopy -+#DUMPPROG: readelf -+#objcopy: --remove-section .data2.foo -+#readelf: -Sg --wide -+ -+#... -+ \[[ 0-9]+\] \.group[ \t]+GROUP[ \t]+.* -+#... -+ \[[ 0-9]+\] \.data\.foo[ \t]+PROGBITS[ \t0-9a-f]+WAG.* -+#... -+ \[[ 0-9]+\] \.rela?\.data\.foo[ \t]+RELA?[ \t0-9a-f]+IG.* -+#... -+COMDAT group section \[[ 0-9]+\] `\.group' \[foo\] contains 2 sections: -+ \[Index\] Name -+ \[[ 0-9]+\] \.data\.foo -+ \[[ 0-9]+\] \.rela?\.data\.foo -+#pass -diff --git a/binutils/testsuite/binutils-all/group-7c.d b/binutils/testsuite/binutils-all/group-7c.d -new file mode 100644 -index 0000000..83e9115 ---- /dev/null -+++ b/binutils/testsuite/binutils-all/group-7c.d -@@ -0,0 +1,8 @@ -+#name: copy removing reloc and non-reloc group member -+#source: group-7.s -+#PROG: objcopy -+#DUMPPROG: readelf -+#objcopy: -R .data.foo -R .data2.foo -+#readelf: -g --wide -+ -+There are no section groups in this file\. -diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp -index 377f88c..f4a7692 100644 ---- a/binutils/testsuite/binutils-all/objcopy.exp -+++ b/binutils/testsuite/binutils-all/objcopy.exp -@@ -1051,6 +1051,9 @@ if [is_elf_format] { - objcopy_test_readelf "GNU_MBIND section" mbind1.s - run_dump_test "group-5" - run_dump_test "group-6" -+ run_dump_test "group-7a" -+ run_dump_test "group-7b" -+ run_dump_test "group-7c" - run_dump_test "copy-1" - run_dump_test "note-1" - if [is_elf64 tmpdir/bintest.o] { -diff --git a/ld/testsuite/ld-elf/pr22836-2.d b/ld/testsuite/ld-elf/pr22836-2.d -new file mode 100644 -index 0000000..10133e4 ---- /dev/null -+++ b/ld/testsuite/ld-elf/pr22836-2.d -@@ -0,0 +1,7 @@ -+#source: pr22836-2.s -+#ld: -r -S -+#readelf: -g --wide -+ -+group section \[[ 0-9]+\] `\.group' \[foo\] contains 1 section.* -+ \[Index\] Name -+ \[[ 0-9]+\] \.comment -diff --git a/ld/testsuite/ld-elf/pr22836-2.s b/ld/testsuite/ld-elf/pr22836-2.s -new file mode 100644 -index 0000000..77cd83a ---- /dev/null -+++ b/ld/testsuite/ld-elf/pr22836-2.s -@@ -0,0 +1,7 @@ -+ .section .debug_macro,"G",%progbits,foo -+ .long .LASF0 -+.LASF0: -+ .string "__STDC__ 1" -+ -+ .section .comment,"G",%progbits,foo -+ .asciz "hi" --- -2.9.3 - diff --git a/0003-PR23460-Add-a-testcase-for-PR-binutils-23460.patch b/0003-PR23460-Add-a-testcase-for-PR-binutils-23460.patch new file mode 100644 index 000000000000..e19ae26b769a --- /dev/null +++ b/0003-PR23460-Add-a-testcase-for-PR-binutils-23460.patch @@ -0,0 +1,141 @@ +From 51096b8055c73c9cdbadfa4ad75955eab8ef91a5 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" <hjl.tools@gmail.com> +Date: Thu, 2 Aug 2018 05:00:45 -0700 +Subject: [PATCH] Add a testcase for PR binutils/23460 + +Add a testcase to limit open files to 16 for AR with plugin. Before + +commit 103da91bc083f94769e3758175a96d06cef1f8fe +Author: Nick Clifton <nickc@redhat.com> +Date: Wed Aug 1 14:34:41 2018 +0100 + + Close resource leaks in the BFD library's plugin handler. + +it failed with: + +../binutils/ar: tmpdir/pr23460f.o: plugin needed to handle lto object + + PR binutils/23460 + * testsuite/ld-plugin/lto.exp: Run the PR binutils/23460 test. + * testsuite/ld-plugin/pr23460a.c: New file. + * testsuite/ld-plugin/pr23460b.c: Likewise. + * testsuite/ld-plugin/pr23460c.c: Likewise. + * testsuite/ld-plugin/pr23460d.c: Likewise. + * testsuite/ld-plugin/pr23460e.c: Likewise. + * testsuite/ld-plugin/pr23460f.c: Likewise. +--- + ld/testsuite/ld-plugin/lto.exp | 26 ++++++++++++++++++++++++++ + ld/testsuite/ld-plugin/pr23460a.c | 4 ++++ + ld/testsuite/ld-plugin/pr23460b.c | 4 ++++ + ld/testsuite/ld-plugin/pr23460c.c | 4 ++++ + ld/testsuite/ld-plugin/pr23460d.c | 4 ++++ + ld/testsuite/ld-plugin/pr23460e.c | 4 ++++ + ld/testsuite/ld-plugin/pr23460f.c | 4 ++++ + 7 files changed, 50 insertions(+) + create mode 100644 ld/testsuite/ld-plugin/pr23460a.c + create mode 100644 ld/testsuite/ld-plugin/pr23460b.c + create mode 100644 ld/testsuite/ld-plugin/pr23460c.c + create mode 100644 ld/testsuite/ld-plugin/pr23460d.c + create mode 100644 ld/testsuite/ld-plugin/pr23460e.c + create mode 100644 ld/testsuite/ld-plugin/pr23460f.c + +diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp +index 7c50b0f102..5d354bfa9e 100644 +--- a/ld/testsuite/ld-plugin/lto.exp ++++ b/ld/testsuite/ld-plugin/lto.exp +@@ -556,6 +556,32 @@ if { [at_least_gcc_version 4 7] } { + } { + fail $testname + } ++ ++ run_cc_link_tests [list \ ++ [list \ ++ "Build pr23460*.o" \ ++ "$plug_opt" \ ++ "-O2 -fPIC -flto $lto_no_fat" \ ++ {pr23460a.c pr23460b.c pr23460c.c \ ++ pr23460d.c pr23460e.c pr23460f.c} \ ++ ] \ ++ ] ++ set exec_output [run_host_cmd "sh" \ ++ "-c \"ulimit -n 16; \ ++ $ar -rc $plug_opt \ ++ tmpdir/libpr23460.a \ ++ tmpdir/pr23460a.o \ ++ tmpdir/pr23460b.o \ ++ tmpdir/pr23460c.o \ ++ tmpdir/pr23460d.o \ ++ tmpdir/pr23460e.o \ ++ tmpdir/pr23460f.o\""] ++ set exec_output [prune_warnings $exec_output] ++ if [string match "" $exec_output] then { ++ pass "PR binutils/23460" ++ } else { ++ fail "PR binutils/23460" ++ } + } + + # Run "ld -r" to generate inputs for complex LTO tests. +diff --git a/ld/testsuite/ld-plugin/pr23460a.c b/ld/testsuite/ld-plugin/pr23460a.c +new file mode 100644 +index 0000000000..4a8cd140a2 +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr23460a.c +@@ -0,0 +1,4 @@ ++void ++x1 (void) ++{ ++} +diff --git a/ld/testsuite/ld-plugin/pr23460b.c b/ld/testsuite/ld-plugin/pr23460b.c +new file mode 100644 +index 0000000000..6c178fbc76 +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr23460b.c +@@ -0,0 +1,4 @@ ++void ++x2 (void) ++{ ++} +diff --git a/ld/testsuite/ld-plugin/pr23460c.c b/ld/testsuite/ld-plugin/pr23460c.c +new file mode 100644 +index 0000000000..99b23c5dcd +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr23460c.c +@@ -0,0 +1,4 @@ ++void ++x3 (void) ++{ ++} +diff --git a/ld/testsuite/ld-plugin/pr23460d.c b/ld/testsuite/ld-plugin/pr23460d.c +new file mode 100644 +index 0000000000..432d39b39c +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr23460d.c +@@ -0,0 +1,4 @@ ++void ++x4 (void) ++{ ++} +diff --git a/ld/testsuite/ld-plugin/pr23460e.c b/ld/testsuite/ld-plugin/pr23460e.c +new file mode 100644 +index 0000000000..2809011ee7 +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr23460e.c +@@ -0,0 +1,4 @@ ++void ++x5 (void) ++{ ++} +diff --git a/ld/testsuite/ld-plugin/pr23460f.c b/ld/testsuite/ld-plugin/pr23460f.c +new file mode 100644 +index 0000000000..e500bf5ae6 +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr23460f.c +@@ -0,0 +1,4 @@ ++void ++x6 (void) ++{ ++} +-- +2.18.0 + diff --git a/0004-PR23486-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED-x86_64.patch b/0004-PR23486-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED-x86_64.patch new file mode 100644 index 000000000000..d56d8b7b6fd2 --- /dev/null +++ b/0004-PR23486-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED-x86_64.patch @@ -0,0 +1,78 @@ +From 96027b49650718ebcd20d81bd8d0fbbd36a33558 Mon Sep 17 00:00:00 2001 +From: Cary Coutant <ccoutant@gmail.com> +Date: Tue, 7 Aug 2018 21:35:12 -0700 +Subject: [PATCH] Properly merge GNU_PROPERTY_X86_ISA_1_USED (x86_64). + +gold/ + PR ld/23486 + * x86_64.cc (Target_x86_64::Target_x86_64): Initialize + object_isa_1_used_. + (Target_x86_64::object_isa_1_used_): New data member. + (Target_x86_64::record_gnu_property): Save ISA_1_USED bits for object. + (Target_x86_64::merge_gnu_properties): Merge ISA_1_USED bits. +--- + gold/x86_64.cc | 22 +++++++++++++++++++--- + 1 file changed, 19 insertions(+), 3 deletions(-) + +diff --git a/gold/x86_64.cc b/gold/x86_64.cc +index 27f273d64b..ac958616c6 100644 +--- a/gold/x86_64.cc ++++ b/gold/x86_64.cc +@@ -706,7 +706,8 @@ class Target_x86_64 : public Sized_target<size, false> + rela_irelative_(NULL), copy_relocs_(elfcpp::R_X86_64_COPY), + got_mod_index_offset_(-1U), tlsdesc_reloc_info_(), + tls_base_symbol_defined_(false), isa_1_used_(0), isa_1_needed_(0), +- feature_1_(0), object_feature_1_(0), seen_first_object_(false) ++ feature_1_(0), object_isa_1_used_(0), object_feature_1_(0), ++ seen_first_object_(false) + { } + + // Hook for a new output section. +@@ -1381,6 +1382,11 @@ class Target_x86_64 : public Sized_target<size, false> + uint32_t isa_1_needed_; + uint32_t feature_1_; + // Target-specific properties from the current object. ++ // These bits get ORed into ISA_1_USED_ after all properties for the object ++ // have been processed. But if either is all zeroes (as when the property ++ // is absent from an object), the result should be all zeroes. ++ // (See PR ld/23486.) ++ uint32_t object_isa_1_used_; + // These bits get ANDed into FEATURE_1_ after all properties for the object + // have been processed. + uint32_t object_feature_1_; +@@ -1609,7 +1615,7 @@ Target_x86_64<size>::record_gnu_property( + switch (pr_type) + { + case elfcpp::GNU_PROPERTY_X86_ISA_1_USED: +- this->isa_1_used_ |= val; ++ this->object_isa_1_used_ |= val; + break; + case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED: + this->isa_1_needed_ |= val; +@@ -1627,12 +1633,22 @@ void + Target_x86_64<size>::merge_gnu_properties(const Object*) + { + if (this->seen_first_object_) +- this->feature_1_ &= this->object_feature_1_; ++ { ++ // If any object is missing the ISA_1_USED property, we must omit ++ // it from the output file. ++ if (this->object_isa_1_used_ == 0) ++ this->isa_1_used_ = 0; ++ else if (this->isa_1_used_ != 0) ++ this->isa_1_used_ |= this->object_isa_1_used_; ++ this->feature_1_ &= this->object_feature_1_; ++ } + else + { ++ this->isa_1_used_ = this->object_isa_1_used_; + this->feature_1_ = this->object_feature_1_; + this->seen_first_object_ = true; + } ++ this->object_isa_1_used_ = 0; + this->object_feature_1_ = 0; + } + +-- +2.18.0 + diff --git a/0005-PR23486-x86-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED.patch b/0005-PR23486-x86-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED.patch new file mode 100644 index 000000000000..734d299359d4 --- /dev/null +++ b/0005-PR23486-x86-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED.patch @@ -0,0 +1,583 @@ +From c1bb83b5fbf93b27d6a888486c09dcd34a3672be Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" <hjl.tools@gmail.com> +Date: Wed, 8 Aug 2018 06:09:15 -0700 +Subject: [PATCH] x86: Properly merge GNU_PROPERTY_X86_ISA_1_USED +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Without the GNU_PROPERTY_X86_ISA_1_USED property, all ISAs may be used. +If a bit in the GNU_PROPERTY_X86_ISA_1_USED property is unset, the +corresponding x86 instruction set isn’t used. When merging properties +from 2 input files and one input file doesn't have the +GNU_PROPERTY_X86_ISA_1_USED property, the output file shouldn't have +it neither. This patch removes the GNU_PROPERTY_X86_ISA_1_USED +property if an input file doesn't have it. + +This patch replaces the GNU_PROPERTY_X86_ISA_1_USED property with the +GNU_PROPERTY_X86_ISA_1_NEEDED property which is the minimum ISA +requirement. + +bfd/ + + PR ld/23486 + * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Remove + GNU_PROPERTY_X86_ISA_1_USED if an input file doesn't have it. + (_bfd_x86_elf_link_setup_gnu_properties): Adding the + GNU_PROPERTY_X86_ISA_1_NEEDED, instead of + GNU_PROPERTY_X86_ISA_1_USED, property. + +ld/ + + PR ld/23486 + * testsuite/ld-i386/i386.exp: Run PR ld/23486 tests. + * testsuite/ld-x86-64/x86-64.exp: Likewise. + * testsuite/ld-i386/pr23486a.d: New file. + * testsuite/ld-i386/pr23486b.d: Likewise. + * testsuite/ld-x86-64/pr23486a-x32.d: Likewise. + * testsuite/ld-x86-64/pr23486a.d: Likewise. + * testsuite/ld-x86-64/pr23486a.s: Likewise. + * testsuite/ld-x86-64/pr23486b-x32.d: Likewise. + * testsuite/ld-x86-64/pr23486b.d: Likewise. + * testsuite/ld-x86-64/pr23486b.s: Likewise. + * testsuite/ld-i386/property-3.r: Remove "x86 ISA used". + * testsuite/ld-i386/property-4.r: Likewise. + * testsuite/ld-i386/property-5.r: Likewise. + * testsuite/ld-i386/property-x86-ibt3a.d: Likewise. + * testsuite/ld-i386/property-x86-ibt3b.d: Likewise. + * testsuite/ld-i386/property-x86-shstk3a.d: Likewise. + * testsuite/ld-i386/property-x86-shstk3b.d: Likewise. + * testsuite/ld-x86-64/property-3.r: Likewise. + * testsuite/ld-x86-64/property-4.r: Likewise. + * testsuite/ld-x86-64/property-5.r: Likewise. + * testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise. + * testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise. + * testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise. + * testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise. + * testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise. + * testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise. + * testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise. + * testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise. +--- + bfd/elfxx-x86.c | 25 ++++++++++++---- + ld/testsuite/ld-i386/i386.exp | 2 ++ + ld/testsuite/ld-i386/pr23486a.d | 10 +++++++ + ld/testsuite/ld-i386/pr23486b.d | 10 +++++++ + ld/testsuite/ld-i386/property-3.r | 1 - + ld/testsuite/ld-i386/property-4.r | 1 - + ld/testsuite/ld-i386/property-5.r | 1 - + ld/testsuite/ld-i386/property-x86-ibt3a.d | 5 ++-- + ld/testsuite/ld-i386/property-x86-ibt3b.d | 5 ++-- + ld/testsuite/ld-i386/property-x86-shstk3a.d | 5 ++-- + ld/testsuite/ld-i386/property-x86-shstk3b.d | 5 ++-- + ld/testsuite/ld-x86-64/pr23486a-x32.d | 10 +++++++ + ld/testsuite/ld-x86-64/pr23486a.d | 10 +++++++ + ld/testsuite/ld-x86-64/pr23486a.s | 30 +++++++++++++++++++ + ld/testsuite/ld-x86-64/pr23486b-x32.d | 10 +++++++ + ld/testsuite/ld-x86-64/pr23486b.d | 10 +++++++ + ld/testsuite/ld-x86-64/pr23486b.s | 30 +++++++++++++++++++ + ld/testsuite/ld-x86-64/property-3.r | 1 - + ld/testsuite/ld-x86-64/property-4.r | 1 - + ld/testsuite/ld-x86-64/property-5.r | 1 - + .../ld-x86-64/property-x86-ibt3a-x32.d | 5 ++-- + ld/testsuite/ld-x86-64/property-x86-ibt3a.d | 5 ++-- + .../ld-x86-64/property-x86-ibt3b-x32.d | 5 ++-- + ld/testsuite/ld-x86-64/property-x86-ibt3b.d | 5 ++-- + .../ld-x86-64/property-x86-shstk3a-x32.d | 5 ++-- + ld/testsuite/ld-x86-64/property-x86-shstk3a.d | 5 ++-- + .../ld-x86-64/property-x86-shstk3b-x32.d | 5 ++-- + ld/testsuite/ld-x86-64/property-x86-shstk3b.d | 5 ++-- + ld/testsuite/ld-x86-64/x86-64.exp | 4 +++ + 29 files changed, 170 insertions(+), 47 deletions(-) + create mode 100644 ld/testsuite/ld-i386/pr23486a.d + create mode 100644 ld/testsuite/ld-i386/pr23486b.d + create mode 100644 ld/testsuite/ld-x86-64/pr23486a-x32.d + create mode 100644 ld/testsuite/ld-x86-64/pr23486a.d + create mode 100644 ld/testsuite/ld-x86-64/pr23486a.s + create mode 100644 ld/testsuite/ld-x86-64/pr23486b-x32.d + create mode 100644 ld/testsuite/ld-x86-64/pr23486b.d + create mode 100644 ld/testsuite/ld-x86-64/pr23486b.s + +diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c +index 2e4ff88f1f..7ccfd25815 100644 +--- a/bfd/elfxx-x86.c ++++ b/bfd/elfxx-x86.c +@@ -2407,12 +2407,27 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info, + switch (pr_type) + { + case GNU_PROPERTY_X86_ISA_1_USED: ++ if (aprop == NULL || bprop == NULL) ++ { ++ /* Only one of APROP and BPROP can be NULL. */ ++ if (aprop != NULL) ++ { ++ /* Remove this property since the other input file doesn't ++ have it. */ ++ aprop->pr_kind = property_remove; ++ updated = TRUE; ++ } ++ break; ++ } ++ goto or_property; ++ + case GNU_PROPERTY_X86_ISA_1_NEEDED: + if (aprop != NULL && bprop != NULL) + { ++or_property: + number = aprop->u.number; + aprop->u.number = number | bprop->u.number; +- /* Remove the property if ISA bits are empty. */ ++ /* Remove the property if all bits are empty. */ + if (aprop->u.number == 0) + { + aprop->pr_kind = property_remove; +@@ -2428,14 +2443,14 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info, + { + if (aprop->u.number == 0) + { +- /* Remove APROP if ISA bits are empty. */ ++ /* Remove APROP if all bits are empty. */ + aprop->pr_kind = property_remove; + updated = TRUE; + } + } + else + { +- /* Return TRUE if APROP is NULL and ISA bits of BPROP ++ /* Return TRUE if APROP is NULL and all bits of BPROP + aren't empty to indicate that BPROP should be added + to ABFD. */ + updated = bprop->u.number != 0; +@@ -2582,9 +2597,9 @@ _bfd_x86_elf_link_setup_gnu_properties + { + /* If the separate code program header is needed, make sure + that the first read-only PT_LOAD segment has no code by +- adding a GNU_PROPERTY_X86_ISA_1_USED note. */ ++ adding a GNU_PROPERTY_X86_ISA_1_NEEDED note. */ + prop = _bfd_elf_get_property (ebfd, +- GNU_PROPERTY_X86_ISA_1_USED, ++ GNU_PROPERTY_X86_ISA_1_NEEDED, + 4); + prop->u.number = GNU_PROPERTY_X86_ISA_1_486; + prop->pr_kind = property_number; +diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp +index 6d794fe653..78dad02579 100644 +--- a/ld/testsuite/ld-i386/i386.exp ++++ b/ld/testsuite/ld-i386/i386.exp +@@ -462,6 +462,8 @@ run_dump_test "pr23189" + run_dump_test "pr23194" + run_dump_test "pr23372a" + run_dump_test "pr23372b" ++run_dump_test "pr23486a" ++run_dump_test "pr23486b" + + if { !([istarget "i?86-*-linux*"] + || [istarget "i?86-*-gnu*"] +diff --git a/ld/testsuite/ld-i386/pr23486a.d b/ld/testsuite/ld-i386/pr23486a.d +new file mode 100644 +index 0000000000..41a6dcf7d5 +--- /dev/null ++++ b/ld/testsuite/ld-i386/pr23486a.d +@@ -0,0 +1,10 @@ ++#source: ../ld-x86-64/pr23486a.s ++#source: ../ld-x86-64/pr23486b.s ++#as: --32 ++#ld: -r -m elf_i386 ++#readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++ Owner Data size Description ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586 +diff --git a/ld/testsuite/ld-i386/pr23486b.d b/ld/testsuite/ld-i386/pr23486b.d +new file mode 100644 +index 0000000000..08019b7274 +--- /dev/null ++++ b/ld/testsuite/ld-i386/pr23486b.d +@@ -0,0 +1,10 @@ ++#source: ../ld-x86-64/pr23486b.s ++#source: ../ld-x86-64/pr23486a.s ++#as: --32 ++#ld: -r -m elf_i386 ++#readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++ Owner Data size Description ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586 +diff --git a/ld/testsuite/ld-i386/property-3.r b/ld/testsuite/ld-i386/property-3.r +index 0ed91f5922..d03203c1e5 100644 +--- a/ld/testsuite/ld-i386/property-3.r ++++ b/ld/testsuite/ld-i386/property-3.r +@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 +- x86 ISA used: 586, SSE + x86 ISA needed: i486, 586 + #pass +diff --git a/ld/testsuite/ld-i386/property-4.r b/ld/testsuite/ld-i386/property-4.r +index cb2bc15d9a..da295eb6c7 100644 +--- a/ld/testsuite/ld-i386/property-4.r ++++ b/ld/testsuite/ld-i386/property-4.r +@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 +- x86 ISA used: i486, 586, SSE + x86 ISA needed: i486, 586, SSE + #pass +diff --git a/ld/testsuite/ld-i386/property-5.r b/ld/testsuite/ld-i386/property-5.r +index 552965058c..e4141594b3 100644 +--- a/ld/testsuite/ld-i386/property-5.r ++++ b/ld/testsuite/ld-i386/property-5.r +@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x900000 +- x86 ISA used: i486, 586, SSE + x86 ISA needed: i486, 586, SSE + #pass +diff --git a/ld/testsuite/ld-i386/property-x86-ibt3a.d b/ld/testsuite/ld-i386/property-x86-ibt3a.d +index 4bb35b00fb..0aedea1614 100644 +--- a/ld/testsuite/ld-i386/property-x86-ibt3a.d ++++ b/ld/testsuite/ld-i386/property-x86-ibt3a.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: i486, 586, SSE2, SSE3 +- x86 ISA needed: 586, SSE, SSE3, SSE4_1 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1 +diff --git a/ld/testsuite/ld-i386/property-x86-ibt3b.d b/ld/testsuite/ld-i386/property-x86-ibt3b.d +index 418d58a8f7..bd69ac6478 100644 +--- a/ld/testsuite/ld-i386/property-x86-ibt3b.d ++++ b/ld/testsuite/ld-i386/property-x86-ibt3b.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: i486, 586, SSE2, SSE3 +- x86 ISA needed: 586, SSE, SSE3, SSE4_1 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1 +diff --git a/ld/testsuite/ld-i386/property-x86-shstk3a.d b/ld/testsuite/ld-i386/property-x86-shstk3a.d +index e261038f60..76d2a39f2c 100644 +--- a/ld/testsuite/ld-i386/property-x86-shstk3a.d ++++ b/ld/testsuite/ld-i386/property-x86-shstk3a.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: i486, 586, SSE2, SSE3 +- x86 ISA needed: 586, SSE, SSE3, SSE4_1 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1 +diff --git a/ld/testsuite/ld-i386/property-x86-shstk3b.d b/ld/testsuite/ld-i386/property-x86-shstk3b.d +index 25f3d2361e..e770ecffa5 100644 +--- a/ld/testsuite/ld-i386/property-x86-shstk3b.d ++++ b/ld/testsuite/ld-i386/property-x86-shstk3b.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: i486, 586, SSE2, SSE3 +- x86 ISA needed: 586, SSE, SSE3, SSE4_1 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1 +diff --git a/ld/testsuite/ld-x86-64/pr23486a-x32.d b/ld/testsuite/ld-x86-64/pr23486a-x32.d +new file mode 100644 +index 0000000000..6d9fa68cdb +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr23486a-x32.d +@@ -0,0 +1,10 @@ ++#source: pr23486a.s ++#source: pr23486b.s ++#as: --x32 ++#ld: -r -m elf32_x86_64 ++#readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++ Owner Data size Description ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586 +diff --git a/ld/testsuite/ld-x86-64/pr23486a.d b/ld/testsuite/ld-x86-64/pr23486a.d +new file mode 100644 +index 0000000000..dc2b7bf760 +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr23486a.d +@@ -0,0 +1,10 @@ ++#source: pr23486a.s ++#source: pr23486b.s ++#as: --64 -defsym __64_bit__=1 ++#ld: -r -m elf_x86_64 ++#readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++ Owner Data size Description ++ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586 +diff --git a/ld/testsuite/ld-x86-64/pr23486a.s b/ld/testsuite/ld-x86-64/pr23486a.s +new file mode 100644 +index 0000000000..a07d0c7ced +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr23486a.s +@@ -0,0 +1,30 @@ ++ .section ".note.gnu.property", "a" ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++ .long 1f - 0f /* name length. */ ++ .long 4f - 1f /* data length. */ ++ /* NT_GNU_PROPERTY_TYPE_0 */ ++ .long 5 /* note type. */ ++0: ++ .asciz "GNU" /* vendor name. */ ++1: ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++ /* GNU_PROPERTY_X86_ISA_1_USED */ ++ .long 0xc0000000 /* pr_type. */ ++ .long 3f - 2f /* pr_datasz. */ ++2: ++ .long 0xa ++3: ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++4: +diff --git a/ld/testsuite/ld-x86-64/pr23486b-x32.d b/ld/testsuite/ld-x86-64/pr23486b-x32.d +new file mode 100644 +index 0000000000..0445e69d82 +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr23486b-x32.d +@@ -0,0 +1,10 @@ ++#source: pr23486b.s ++#source: pr23486a.s ++#as: --x32 ++#ld: -r -m elf32_x86_64 ++#readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++ Owner Data size Description ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586 +diff --git a/ld/testsuite/ld-x86-64/pr23486b.d b/ld/testsuite/ld-x86-64/pr23486b.d +new file mode 100644 +index 0000000000..dc2b7bf760 +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr23486b.d +@@ -0,0 +1,10 @@ ++#source: pr23486a.s ++#source: pr23486b.s ++#as: --64 -defsym __64_bit__=1 ++#ld: -r -m elf_x86_64 ++#readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++ Owner Data size Description ++ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586 +diff --git a/ld/testsuite/ld-x86-64/pr23486b.s b/ld/testsuite/ld-x86-64/pr23486b.s +new file mode 100644 +index 0000000000..c5167eeb65 +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/pr23486b.s +@@ -0,0 +1,30 @@ ++ .section ".note.gnu.property", "a" ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++ .long 1f - 0f /* name length. */ ++ .long 4f - 1f /* data length. */ ++ /* NT_GNU_PROPERTY_TYPE_0 */ ++ .long 5 /* note type. */ ++0: ++ .asciz "GNU" /* vendor name. */ ++1: ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++ /* GNU_PROPERTY_X86_ISA_1_NEEDED */ ++ .long 0xc0000001 /* pr_type. */ ++ .long 3f - 2f /* pr_datasz. */ ++2: ++ .long 0x3 ++3: ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++4: +diff --git a/ld/testsuite/ld-x86-64/property-3.r b/ld/testsuite/ld-x86-64/property-3.r +index 0ed91f5922..d03203c1e5 100644 +--- a/ld/testsuite/ld-x86-64/property-3.r ++++ b/ld/testsuite/ld-x86-64/property-3.r +@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 +- x86 ISA used: 586, SSE + x86 ISA needed: i486, 586 + #pass +diff --git a/ld/testsuite/ld-x86-64/property-4.r b/ld/testsuite/ld-x86-64/property-4.r +index cb2bc15d9a..da295eb6c7 100644 +--- a/ld/testsuite/ld-x86-64/property-4.r ++++ b/ld/testsuite/ld-x86-64/property-4.r +@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 +- x86 ISA used: i486, 586, SSE + x86 ISA needed: i486, 586, SSE + #pass +diff --git a/ld/testsuite/ld-x86-64/property-5.r b/ld/testsuite/ld-x86-64/property-5.r +index 552965058c..e4141594b3 100644 +--- a/ld/testsuite/ld-x86-64/property-5.r ++++ b/ld/testsuite/ld-x86-64/property-5.r +@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x900000 +- x86 ISA used: i486, 586, SSE + x86 ISA needed: i486, 586, SSE + #pass +diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d +index 011426f5a4..4cec728dc7 100644 +--- a/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d ++++ b/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 +diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3a.d b/ld/testsuite/ld-x86-64/property-x86-ibt3a.d +index 1b4229a037..a8df49a351 100644 +--- a/ld/testsuite/ld-x86-64/property-x86-ibt3a.d ++++ b/ld/testsuite/ld-x86-64/property-x86-ibt3a.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 +diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d +index 290ed6abf1..c112626711 100644 +--- a/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d ++++ b/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 +diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3b.d b/ld/testsuite/ld-x86-64/property-x86-ibt3b.d +index 1142e03272..f10dffdc2c 100644 +--- a/ld/testsuite/ld-x86-64/property-x86-ibt3b.d ++++ b/ld/testsuite/ld-x86-64/property-x86-ibt3b.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 +diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d b/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d +index 819542d181..0147a3c7b6 100644 +--- a/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d ++++ b/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 +diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3a.d b/ld/testsuite/ld-x86-64/property-x86-shstk3a.d +index 4c5d0e0a18..1f8c2dc929 100644 +--- a/ld/testsuite/ld-x86-64/property-x86-shstk3a.d ++++ b/ld/testsuite/ld-x86-64/property-x86-shstk3a.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 +diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d b/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d +index ba181e0bc5..7ca2539ca5 100644 +--- a/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d ++++ b/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 +diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3b.d b/ld/testsuite/ld-x86-64/property-x86-shstk3b.d +index 5216f385dd..f66a40e449 100644 +--- a/ld/testsuite/ld-x86-64/property-x86-shstk3b.d ++++ b/ld/testsuite/ld-x86-64/property-x86-shstk3b.d +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 +diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp +index 6edb9e86f4..ae21e554ad 100644 +--- a/ld/testsuite/ld-x86-64/x86-64.exp ++++ b/ld/testsuite/ld-x86-64/x86-64.exp +@@ -403,6 +403,10 @@ run_dump_test "pr23372a" + run_dump_test "pr23372a-x32" + run_dump_test "pr23372b" + run_dump_test "pr23372b-x32" ++run_dump_test "pr23486a" ++run_dump_test "pr23486a-x32" ++run_dump_test "pr23486b" ++run_dump_test "pr23486b-x32" + + if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} { + return +-- +2.18.0 + diff --git a/0006-PR23428-x86-Properly-add-X86_ISA_1_NEEDED-property.patch b/0006-PR23428-x86-Properly-add-X86_ISA_1_NEEDED-property.patch new file mode 100644 index 000000000000..d971471e2b04 --- /dev/null +++ b/0006-PR23428-x86-Properly-add-X86_ISA_1_NEEDED-property.patch @@ -0,0 +1,135 @@ +From 03883490b51c3fe7762e73b9e6c3f3e5d71552fd Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" <hjl.tools@gmail.com> +Date: Sat, 11 Aug 2018 06:41:33 -0700 +Subject: [PATCH] x86: Properly add X86_ISA_1_NEEDED property + +Existing properties may be removed during property merging. We avoid +adding X86_ISA_1_NEEDED property only if existing properties won't be +removed. + +bfd/ + + PR ld/23428 + * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't + add X86_ISA_1_NEEDED property only if existing properties won't + be removed. + +ld/ + + PR ld/23428 + * testsuite/ld-elf/dummy.s: New file. + * testsuite/ld-elf/linux-x86.S: Add X86_FEATURE_1_AND property. + * testsuite/ld-elf/linux-x86.exp: Add dummy.s to pr23428. +--- + bfd/elfxx-x86.c | 28 ++++++++++++++++++++++------ + ld/testsuite/ld-elf/dummy.s | 1 + + ld/testsuite/ld-elf/linux-x86.S | 28 ++++++++++++++++++++++++++++ + ld/testsuite/ld-elf/linux-x86.exp | 2 +- + 4 files changed, 52 insertions(+), 7 deletions(-) + create mode 100644 ld/testsuite/ld-elf/dummy.s + +diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c +index 7ccfd25815..2d8f7b640b 100644 +--- a/bfd/elfxx-x86.c ++++ b/bfd/elfxx-x86.c +@@ -2588,7 +2588,6 @@ _bfd_x86_elf_link_setup_gnu_properties + prop->pr_kind = property_number; + } + else if (has_text +- && elf_properties (ebfd) == NULL + && elf_tdata (info->output_bfd)->o->build_id.sec == NULL + && !htab->elf.dynamic_sections_created + && !info->traditional_format +@@ -2598,11 +2597,28 @@ _bfd_x86_elf_link_setup_gnu_properties + /* If the separate code program header is needed, make sure + that the first read-only PT_LOAD segment has no code by + adding a GNU_PROPERTY_X86_ISA_1_NEEDED note. */ +- prop = _bfd_elf_get_property (ebfd, +- GNU_PROPERTY_X86_ISA_1_NEEDED, +- 4); +- prop->u.number = GNU_PROPERTY_X86_ISA_1_486; +- prop->pr_kind = property_number; ++ elf_property_list *list; ++ bfd_boolean need_property = TRUE; ++ ++ for (list = elf_properties (ebfd); list; list = list->next) ++ switch (list->property.pr_type) ++ { ++ case GNU_PROPERTY_STACK_SIZE: ++ case GNU_PROPERTY_NO_COPY_ON_PROTECTED: ++ case GNU_PROPERTY_X86_ISA_1_NEEDED: ++ /* These properties won't be removed during merging. */ ++ need_property = FALSE; ++ break; ++ } ++ ++ if (need_property) ++ { ++ prop = _bfd_elf_get_property (ebfd, ++ GNU_PROPERTY_X86_ISA_1_NEEDED, ++ 4); ++ prop->u.number = GNU_PROPERTY_X86_ISA_1_486; ++ prop->pr_kind = property_number; ++ } + } + + /* Create the GNU property note section if needed. */ +diff --git a/ld/testsuite/ld-elf/dummy.s b/ld/testsuite/ld-elf/dummy.s +new file mode 100644 +index 0000000000..403f98000d +--- /dev/null ++++ b/ld/testsuite/ld-elf/dummy.s +@@ -0,0 +1 @@ ++# Dummy +diff --git a/ld/testsuite/ld-elf/linux-x86.S b/ld/testsuite/ld-elf/linux-x86.S +index bdf40c6e01..d94abc1106 100644 +--- a/ld/testsuite/ld-elf/linux-x86.S ++++ b/ld/testsuite/ld-elf/linux-x86.S +@@ -61,3 +61,31 @@ syscall: + ret /* Return to caller. */ + .size syscall, .-syscall + .section .note.GNU-stack,"",@progbits ++ ++ .section ".note.gnu.property", "a" ++#ifdef __LP64__ ++ .p2align 3 ++#else ++ .p2align 2 ++#endif ++ .long 1f - 0f /* name length */ ++ .long 5f - 2f /* data length */ ++ .long 5 /* note type */ ++0: .asciz "GNU" /* vendor name */ ++1: ++#ifdef __LP64__ ++ .p2align 3 ++#else ++ .p2align 2 ++#endif ++2: .long 0xc0000002 /* pr_type. */ ++ .long 4f - 3f /* pr_datasz. */ ++3: ++ .long 0x2 ++4: ++#ifdef __LP64__ ++ .p2align 3 ++#else ++ .p2align 2 ++#endif ++5: +diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp +index 36217c6fb4..f6f5a80853 100644 +--- a/ld/testsuite/ld-elf/linux-x86.exp ++++ b/ld/testsuite/ld-elf/linux-x86.exp +@@ -37,7 +37,7 @@ run_ld_link_exec_tests [list \ + "Run PR ld/23428 test" \ + "--no-dynamic-linker -z separate-code" \ + "" \ +- { linux-x86.S pr23428.c } \ ++ { linux-x86.S pr23428.c dummy.s } \ + "pr23428" \ + "pass.out" \ + "$NOPIE_CFLAGS -fno-asynchronous-unwind-tables" \ +-- +2.18.0 + diff --git a/0007-PR23919-Handle-ELF-compressed-header-alignment.patch b/0007-PR23919-Handle-ELF-compressed-header-alignment.patch new file mode 100644 index 000000000000..b551c4075a12 --- /dev/null +++ b/0007-PR23919-Handle-ELF-compressed-header-alignment.patch @@ -0,0 +1,316 @@ +commit 4207142d6a5d2359170c5f9a140fc1a2351fbda9 +Author: Mark Wielaard <mark@klomp.org> +Date: Tue Nov 27 11:59:10 2018 +0000 + + Handle ELF compressed header alignment correctly by setting up the section alignment correctly for the Elf32_Chdr or Elf64_Chdr type and respect the ch_addralign field when decompressing the section data. + + PR binutils/23919 + binutils* readelf.c (dump_sections_as_strings): Remove bogus addralign check. + (dump_sections_as_bytes): Likewise. + (load_specific_debug_sections): Likewise. + * testsuite/binutils-all/dw2-3.rS: Adjust alignment. + * testsuite/binutils-all/dw2-3.rt: Likewise. + + bfd * bfd.c (bfd_update_compression_header): Explicitly set alignment. + (bfd_check_compression_header): Add uncompressed_alignment_power + argument. Check ch_addralign is a power of 2. + * bfd-in2.h: Regenerated. + * compress.c (bfd_compress_section_contents): Get and set + orig_uncompressed_alignment_pow if section is decompressed. + (bfd_is_section_compressed_with_header): Add and get + uncompressed_align_pow_p argument. + (bfd_is_section_compressed): Add uncompressed_align_power argument + to bfd_is_section_compressed_with_header call. + (bfd_init_section_decompress_status): Get and set + uncompressed_alignment_power. + * elf.c (_bfd_elf_make_section_from_shdr): Add + uncompressed_align_power argument to + bfd_is_section_compressed_with_header call. + +diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h +index ee8cd7ef0b..6d92c51cb9 100644 +--- a/bfd/bfd-in2.h ++++ b/bfd/bfd-in2.h +@@ -7419,7 +7419,8 @@ void bfd_update_compression_header + + bfd_boolean bfd_check_compression_header + (bfd *abfd, bfd_byte *contents, asection *sec, +- bfd_size_type *uncompressed_size); ++ bfd_size_type *uncompressed_size, ++ unsigned int *uncompressed_alignment_power); + + int bfd_get_compression_header_size (bfd *abfd, asection *sec); + +@@ -8006,7 +8007,8 @@ void bfd_cache_section_contents + bfd_boolean bfd_is_section_compressed_with_header + (bfd *abfd, asection *section, + int *compression_header_size_p, +- bfd_size_type *uncompressed_size_p); ++ bfd_size_type *uncompressed_size_p, ++ unsigned int *uncompressed_alignment_power_p); + + bfd_boolean bfd_is_section_compressed + (bfd *abfd, asection *section); +diff --git a/bfd/bfd.c b/bfd/bfd.c +index 15becd7ae8..2b658298ea 100644 +--- a/bfd/bfd.c ++++ b/bfd/bfd.c +@@ -2332,6 +2332,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents, + bfd_put_32 (abfd, sec->size, &echdr->ch_size); + bfd_put_32 (abfd, 1 << sec->alignment_power, + &echdr->ch_addralign); ++ /* bfd_log2 (alignof (Elf32_Chdr)) */ ++ bfd_set_section_alignment (abfd, sec, 2); + } + else + { +@@ -2342,6 +2344,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents, + bfd_put_64 (abfd, sec->size, &echdr->ch_size); + bfd_put_64 (abfd, 1 << sec->alignment_power, + &echdr->ch_addralign); ++ /* bfd_log2 (alignof (Elf64_Chdr)) */ ++ bfd_set_section_alignment (abfd, sec, 3); + } + } + else +@@ -2354,6 +2358,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents, + order. */ + memcpy (contents, "ZLIB", 4); + bfd_putb64 (sec->size, contents + 4); ++ /* No way to keep the original alignment, just use 1 always. */ ++ bfd_set_section_alignment (abfd, sec, 0); + } + } + } +@@ -2368,12 +2374,14 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents, + SYNOPSIS + bfd_boolean bfd_check_compression_header + (bfd *abfd, bfd_byte *contents, asection *sec, +- bfd_size_type *uncompressed_size); ++ bfd_size_type *uncompressed_size, ++ unsigned int *uncompressed_alignment_power); + + DESCRIPTION + Check the compression header at CONTENTS of SEC in ABFD and +- store the uncompressed size in UNCOMPRESSED_SIZE if the +- compression header is valid. ++ store the uncompressed size in UNCOMPRESSED_SIZE and the ++ uncompressed data alignment in UNCOMPRESSED_ALIGNMENT_POWER ++ if the compression header is valid. + + RETURNS + Return TRUE if the compression header is valid. +@@ -2382,7 +2390,8 @@ RETURNS + bfd_boolean + bfd_check_compression_header (bfd *abfd, bfd_byte *contents, + asection *sec, +- bfd_size_type *uncompressed_size) ++ bfd_size_type *uncompressed_size, ++ unsigned int *uncompressed_alignment_power) + { + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour + && (elf_section_flags (sec) & SHF_COMPRESSED) != 0) +@@ -2404,9 +2413,10 @@ bfd_check_compression_header (bfd *abfd, bfd_byte *contents, + chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign); + } + if (chdr.ch_type == ELFCOMPRESS_ZLIB +- && chdr.ch_addralign == 1U << sec->alignment_power) ++ && chdr.ch_addralign == (1U << bfd_log2 (chdr.ch_addralign))) + { + *uncompressed_size = chdr.ch_size; ++ *uncompressed_alignment_power = bfd_log2 (chdr.ch_addralign); + return TRUE; + } + } +diff --git a/bfd/compress.c b/bfd/compress.c +index 53e566e498..97ea624eb8 100644 +--- a/bfd/compress.c ++++ b/bfd/compress.c +@@ -84,11 +84,13 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec, + int zlib_size = 0; + int orig_compression_header_size; + bfd_size_type orig_uncompressed_size; ++ unsigned int orig_uncompressed_alignment_pow; + int header_size = bfd_get_compression_header_size (abfd, NULL); + bfd_boolean compressed + = bfd_is_section_compressed_with_header (abfd, sec, + &orig_compression_header_size, +- &orig_uncompressed_size); ++ &orig_uncompressed_size, ++ &orig_uncompressed_alignment_pow); + + /* Either ELF compression header or the 12-byte, "ZLIB" + 8-byte size, + overhead in .zdebug* section. */ +@@ -153,6 +155,9 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec, + return 0; + } + free (uncompressed_buffer); ++ bfd_set_section_alignment (abfd, sec, ++ orig_uncompressed_alignment_pow); ++ + sec->contents = buffer; + sec->compress_status = COMPRESS_SECTION_DONE; + return orig_uncompressed_size; +@@ -364,20 +369,24 @@ SYNOPSIS + bfd_boolean bfd_is_section_compressed_with_header + (bfd *abfd, asection *section, + int *compression_header_size_p, +- bfd_size_type *uncompressed_size_p); ++ bfd_size_type *uncompressed_size_p, ++ unsigned int *uncompressed_alignment_power_p); + + DESCRIPTION + Return @code{TRUE} if @var{section} is compressed. Compression +- header size is returned in @var{compression_header_size_p} and +- uncompressed size is returned in @var{uncompressed_size_p}. If +- compression is unsupported, compression header size is returned +- with -1 and uncompressed size is returned with 0. ++ header size is returned in @var{compression_header_size_p}, ++ uncompressed size is returned in @var{uncompressed_size_p} ++ and the uncompressed data alignement power is returned in ++ @var{uncompressed_align_pow_p}. If compression is ++ unsupported, compression header size is returned with -1 ++ and uncompressed size is returned with 0. + */ + + bfd_boolean + bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec, + int *compression_header_size_p, +- bfd_size_type *uncompressed_size_p) ++ bfd_size_type *uncompressed_size_p, ++ unsigned int *uncompressed_align_pow_p) + { + bfd_byte header[MAX_COMPRESSION_HEADER_SIZE]; + int compression_header_size; +@@ -412,7 +421,8 @@ bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec, + if (compression_header_size != 0) + { + if (!bfd_check_compression_header (abfd, header, sec, +- uncompressed_size_p)) ++ uncompressed_size_p, ++ uncompressed_align_pow_p)) + compression_header_size = -1; + } + /* Check for the pathalogical case of a debug string section that +@@ -449,9 +459,11 @@ bfd_is_section_compressed (bfd *abfd, sec_ptr sec) + { + int compression_header_size; + bfd_size_type uncompressed_size; ++ unsigned int uncompressed_align_power; + return (bfd_is_section_compressed_with_header (abfd, sec, + &compression_header_size, +- &uncompressed_size) ++ &uncompressed_size, ++ &uncompressed_align_power) + && compression_header_size >= 0 + && uncompressed_size > 0); + } +@@ -480,6 +492,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec) + int compression_header_size; + int header_size; + bfd_size_type uncompressed_size; ++ unsigned int uncompressed_alignment_power = 0; + + compression_header_size = bfd_get_compression_header_size (abfd, sec); + if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE) +@@ -508,7 +521,8 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec) + uncompressed_size = bfd_getb64 (header + 4); + } + else if (!bfd_check_compression_header (abfd, header, sec, +- &uncompressed_size)) ++ &uncompressed_size, ++ &uncompressed_alignment_power)) + { + bfd_set_error (bfd_error_wrong_format); + return FALSE; +@@ -516,6 +530,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec) + + sec->compressed_size = sec->size; + sec->size = uncompressed_size; ++ bfd_set_section_alignment (abfd, sec, uncompressed_alignment_power); + sec->compress_status = DECOMPRESS_SECTION_SIZED; + + return TRUE; +diff --git a/bfd/elf.c b/bfd/elf.c +index bebda20195..604971dd4c 100644 +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -1177,11 +1177,12 @@ _bfd_elf_make_section_from_shdr (bfd *abfd, + enum { nothing, compress, decompress } action = nothing; + int compression_header_size; + bfd_size_type uncompressed_size; ++ unsigned int uncompressed_align_power; + bfd_boolean compressed + = bfd_is_section_compressed_with_header (abfd, newsect, + &compression_header_size, +- &uncompressed_size); +- ++ &uncompressed_size, ++ &uncompressed_align_power); + if (compressed) + { + /* Compressed section. Check if we should decompress. */ +diff --git a/binutils/readelf.c b/binutils/readelf.c +index 39744009ab..afb039f7b7 100644 +--- a/binutils/readelf.c ++++ b/binutils/readelf.c +@@ -13397,12 +13397,6 @@ dump_section_as_strings (Elf_Internal_Shdr * section, Filedata * filedata) + printable_section_name (filedata, section), chdr.ch_type); + return FALSE; + } +- else if (chdr.ch_addralign != section->sh_addralign) +- { +- warn (_("compressed section '%s' is corrupted\n"), +- printable_section_name (filedata, section)); +- return FALSE; +- } + uncompressed_size = chdr.ch_size; + start += compression_header_size; + new_size -= compression_header_size; +@@ -13544,12 +13538,6 @@ dump_section_as_bytes (Elf_Internal_Shdr * section, + printable_section_name (filedata, section), chdr.ch_type); + return FALSE; + } +- else if (chdr.ch_addralign != section->sh_addralign) +- { +- warn (_("compressed section '%s' is corrupted\n"), +- printable_section_name (filedata, section)); +- return FALSE; +- } + uncompressed_size = chdr.ch_size; + start += compression_header_size; + new_size -= compression_header_size; +@@ -13719,12 +13707,6 @@ load_specific_debug_section (enum dwarf_section_display_enum debug, + section->name, chdr.ch_type); + return FALSE; + } +- else if (chdr.ch_addralign != sec->sh_addralign) +- { +- warn (_("compressed section '%s' is corrupted\n"), +- section->name); +- return FALSE; +- } + uncompressed_size = chdr.ch_size; + start += compression_header_size; + size -= compression_header_size; +diff --git a/binutils/testsuite/binutils-all/dw2-3.rS b/binutils/testsuite/binutils-all/dw2-3.rS +index f1637e9149..86bc73d9a2 100644 +--- a/binutils/testsuite/binutils-all/dw2-3.rS ++++ b/binutils/testsuite/binutils-all/dw2-3.rS +@@ -1,3 +1,3 @@ + #... +- +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +1 ++ +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +(4|8) + #pass +diff --git a/binutils/testsuite/binutils-all/dw2-3.rt b/binutils/testsuite/binutils-all/dw2-3.rt +index f59cbaa22b..74e7f8deca 100644 +--- a/binutils/testsuite/binutils-all/dw2-3.rt ++++ b/binutils/testsuite/binutils-all/dw2-3.rt +@@ -1,6 +1,6 @@ + #... + +\[[ 0-9]+\] .debug_info +- +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +1 ++ +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +(4|8) + +\[0+800\]: COMPRESSED + +ZLIB, 0+9d, 1 + #pass diff --git a/0008-PR23919-gold-Get-alignment-of-uncompressed-section.patch b/0008-PR23919-gold-Get-alignment-of-uncompressed-section.patch new file mode 100644 index 000000000000..3fc3777d8321 --- /dev/null +++ b/0008-PR23919-gold-Get-alignment-of-uncompressed-section.patch @@ -0,0 +1,187 @@ +commit 5f6c22aee74f17393b82934a5682d985672e011a +Author: H.J. Lu <hjl.tools@gmail.com> +Date: Sun Dec 2 05:42:36 2018 -0800 + + gold: Get alignment of uncompressed section from ch_addralign + + The ELF compression header has a field (ch_addralign) that is set to + the alignment of the uncompressed section. This way the section itself + can have a different alignment than the decompressed section. Update + decompress_input_section to get alignment of the decompressed section + and use it when merging decompressed strings. + + PR binutils/23919 + * merge.cc (Output_merge_string<Char_type>::do_add_input_section): + Get addralign from decompressed_section_contents. + * object.cc (build_compressed_section_map): Set info.addralign. + (Object::decompressed_section_contents): Add a palign + argument and store p->second.addralign in *palign if it isn't + NULL. + * object.h (Compressed_section_info): Add addralign. + (section_is_compressed): Add a palign argument, default it + to NULL, store p->second.addralign in *palign if it isn't NULL. + (Object::decompressed_section_contents): Likewise. + * output.cc (Output_section::add_input_section): Get addralign + from section_is_compressed. + +diff --git a/gold/merge.cc b/gold/merge.cc +index de00ee9ae9..d7de11789f 100644 +--- a/gold/merge.cc ++++ b/gold/merge.cc +@@ -440,9 +440,11 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object, + { + section_size_type sec_len; + bool is_new; ++ uint64_t addralign = this->addralign(); + const unsigned char* pdata = object->decompressed_section_contents(shndx, + &sec_len, +- &is_new); ++ &is_new, ++ &addralign); + + const Char_type* p = reinterpret_cast<const Char_type*>(pdata); + const Char_type* pend = p + sec_len / sizeof(Char_type); +@@ -494,7 +496,7 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object, + // aligned, so each string within the section must retain the same + // modulo. + uintptr_t init_align_modulo = (reinterpret_cast<uintptr_t>(pdata) +- & (this->addralign() - 1)); ++ & (addralign - 1)); + bool has_misaligned_strings = false; + + while (p < pend) +@@ -503,7 +505,7 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object, + + // Within merge input section each string must be aligned. + if (len != 0 +- && ((reinterpret_cast<uintptr_t>(p) & (this->addralign() - 1)) ++ && ((reinterpret_cast<uintptr_t>(p) & (addralign - 1)) + != init_align_modulo)) + has_misaligned_strings = true; + +diff --git a/gold/object.cc b/gold/object.cc +index cbeddb9158..7930de66fe 100644 +--- a/gold/object.cc ++++ b/gold/object.cc +@@ -751,11 +751,13 @@ build_compressed_section_map( + const unsigned char* contents = + obj->section_contents(i, &len, false); + uint64_t uncompressed_size; ++ Compressed_section_info info; + if (is_zcompressed) + { + // Skip over the ".zdebug" prefix. + name += 7; + uncompressed_size = get_uncompressed_size(contents, len); ++ info.addralign = shdr.get_sh_addralign(); + } + else + { +@@ -763,8 +765,8 @@ build_compressed_section_map( + name += 6; + elfcpp::Chdr<size, big_endian> chdr(contents); + uncompressed_size = chdr.get_ch_size(); ++ info.addralign = chdr.get_ch_addralign(); + } +- Compressed_section_info info; + info.size = convert_to_section_size_type(uncompressed_size); + info.flag = shdr.get_sh_flags(); + info.contents = NULL; +@@ -3064,7 +3066,8 @@ const unsigned char* + Object::decompressed_section_contents( + unsigned int shndx, + section_size_type* plen, +- bool* is_new) ++ bool* is_new, ++ uint64_t* palign) + { + section_size_type buffer_size; + const unsigned char* buffer = this->do_section_contents(shndx, &buffer_size, +@@ -3091,6 +3094,8 @@ Object::decompressed_section_contents( + { + *plen = uncompressed_size; + *is_new = false; ++ if (palign != NULL) ++ *palign = p->second.addralign; + return p->second.contents; + } + +@@ -3112,6 +3117,8 @@ Object::decompressed_section_contents( + // once in this pass. + *plen = uncompressed_size; + *is_new = true; ++ if (palign != NULL) ++ *palign = p->second.addralign; + return uncompressed_data; + } + +diff --git a/gold/object.h b/gold/object.h +index 0b786a5471..b99548463d 100644 +--- a/gold/object.h ++++ b/gold/object.h +@@ -373,6 +373,7 @@ struct Compressed_section_info + { + section_size_type size; + elfcpp::Elf_Xword flag; ++ uint64_t addralign; + const unsigned char* contents; + }; + typedef std::map<unsigned int, Compressed_section_info> Compressed_section_map; +@@ -808,7 +809,8 @@ class Object + + bool + section_is_compressed(unsigned int shndx, +- section_size_type* uncompressed_size) const ++ section_size_type* uncompressed_size, ++ elfcpp::Elf_Xword* palign = NULL) const + { + if (this->compressed_sections_ == NULL) + return false; +@@ -818,6 +820,8 @@ class Object + { + if (uncompressed_size != NULL) + *uncompressed_size = p->second.size; ++ if (palign != NULL) ++ *palign = p->second.addralign; + return true; + } + return false; +@@ -828,7 +832,7 @@ class Object + // by the caller. + const unsigned char* + decompressed_section_contents(unsigned int shndx, section_size_type* plen, +- bool* is_cached); ++ bool* is_cached, uint64_t* palign = NULL); + + // Discard any buffers of decompressed sections. This is done + // at the end of the Add_symbols task. +diff --git a/gold/output.cc b/gold/output.cc +index 1701db1c99..75ac3bcf97 100644 +--- a/gold/output.cc ++++ b/gold/output.cc +@@ -2448,7 +2448,13 @@ Output_section::add_input_section(Layout* layout, + unsigned int reloc_shndx, + bool have_sections_script) + { ++ section_size_type input_section_size = shdr.get_sh_size(); ++ section_size_type uncompressed_size; + elfcpp::Elf_Xword addralign = shdr.get_sh_addralign(); ++ if (object->section_is_compressed(shndx, &uncompressed_size, ++ &addralign)) ++ input_section_size = uncompressed_size; ++ + if ((addralign & (addralign - 1)) != 0) + { + object->error(_("invalid alignment %lu for section \"%s\""), +@@ -2498,11 +2504,6 @@ Output_section::add_input_section(Layout* layout, + } + } + +- section_size_type input_section_size = shdr.get_sh_size(); +- section_size_type uncompressed_size; +- if (object->section_is_compressed(shndx, &uncompressed_size)) +- input_section_size = uncompressed_size; +- + off_t offset_in_section; + + if (this->has_fixed_layout()) @@ -7,7 +7,7 @@ _target="arm-linux-gnueabihf" pkgname=${_target}-binutils -pkgver=2.30 +pkgver=2.31.1 pkgrel=4 pkgdesc="A set of programs to assemble and manipulate binary and object files (${_target})" arch=(i686 x86_64) @@ -17,15 +17,26 @@ depends=(glibc zlib) checkdepends=(dejagnu bc) options=(staticlibs !distcc !ccache) source=(http://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz{,.sig} - 0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch - 0002-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch - 0003-PR22836-r-s-doesnt-work-with-g3-using-GCC-7.patch) + 0001-PR23428-x86-Add-a-GNU_PROPERTY_X86_ISA_1_USED-note-if-needed.patch + 0002-PR23460-Close-resource-leaks-in-the-BFD-library-s-plugin-han.patch + 0003-PR23460-Add-a-testcase-for-PR-binutils-23460.patch + 0004-PR23486-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED-x86_64.patch + 0005-PR23486-x86-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED.patch + 0006-PR23428-x86-Properly-add-X86_ISA_1_NEEDED-property.patch + 0007-PR23919-Handle-ELF-compressed-header-alignment.patch + 0008-PR23919-gold-Get-alignment-of-uncompressed-section.patch +) validpgpkeys=(3A24BC1E8FB409FA9F14371813FCEF89DD9E3C4F) -md5sums=('ffc476dd46c96f932875d1b2e27e929f' +md5sums=('5b7c9d4ce96f507d95c1b9a255e52418' 'SKIP' - '469164f3c93a0e92a697537b60c9806c' - '0c679b37e90fb23de60a4d28329b956a' - '53b5682e09c0a27e9994c3efdfe01d29') + 'f2d4f2aee9ec2e25210eb132acdcf1d9' + '496e7e2d71fe558b3b85cdc27fb4638e' + 'dd2284134542efe8e38137f5c829a371' + '5e4aecddbea729fd045d001e8e8db14e' + '02247a5f1c06f8a9ade689b7e68629ce' + '2764b8760bdc8d5c20698202d22b7fcf' + '5db54b24fb9de56d66111f63aea3b809' + '201036d5806b7b037eb53bf796219525') prepare() { mkdir -p binutils-build @@ -33,17 +44,24 @@ prepare() { #cd binutils-gdb cd binutils-$pkgver - # hack! - libiberty configure tests for header files using "$CPP $CPPFLAGS" - sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" libiberty/configure + # https://sourceware.org/bugzilla/show_bug.cgi?id=23428 + # https://sourceware.org/bugzilla/show_bug.cgi?id=23486 + patch -Np1 -i ../0001-PR23428-x86-Add-a-GNU_PROPERTY_X86_ISA_1_USED-note-if-needed.patch + patch -Np1 -i ../0004-PR23486-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED-x86_64.patch + patch -Np1 -i ../0005-PR23486-x86-Properly-merge-GNU_PROPERTY_X86_ISA_1_USED.patch + patch -Np1 -i ../0006-PR23428-x86-Properly-add-X86_ISA_1_NEEDED-property.patch - # https://sourceware.org/bugzilla/show_bug.cgi?id=22741 - patch -p1 -i "$srcdir/0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch" + # https://sourceware.org/bugzilla/show_bug.cgi?id=23460 + patch -Np1 -i ../0002-PR23460-Close-resource-leaks-in-the-BFD-library-s-plugin-han.patch + patch -Np1 -i ../0003-PR23460-Add-a-testcase-for-PR-binutils-23460.patch - # https://sourceware.org/bugzilla/show_bug.cgi?id=22829 - patch -p1 -i "$srcdir/0002-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch" + # FS#61151 + # https://sourceware.org/bugzilla/show_bug.cgi?id=23919 + patch -Np1 -i ../0007-PR23919-Handle-ELF-compressed-header-alignment.patch + patch -Np1 -i ../0008-PR23919-gold-Get-alignment-of-uncompressed-section.patch - # https://sourceware.org/bugzilla/show_bug.cgi?id=22836 - patch -p1 -i "$srcdir/0003-PR22836-r-s-doesnt-work-with-g3-using-GCC-7.patch" + # hack! - libiberty configure tests for header files using "$CPP $CPPFLAGS" + sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" libiberty/configure } build() { |