diff options
Diffstat (limited to 'patches/binutils-2.19.1')
21 files changed, 1335 insertions, 0 deletions
diff --git a/patches/binutils-2.19.1/generic/gentoo/03_all_binutils-2.15.92.0.2-ppc64-pie.patch b/patches/binutils-2.19.1/generic/gentoo/03_all_binutils-2.15.92.0.2-ppc64-pie.patch new file mode 100644 index 0000000..1e16139 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/03_all_binutils-2.15.92.0.2-ppc64-pie.patch @@ -0,0 +1,22 @@ +--- + bfd/elf64-ppc.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +Index: binutils-2.19.1/bfd/elf64-ppc.c +=================================================================== +--- binutils-2.19.1.orig/bfd/elf64-ppc.c ++++ binutils-2.19.1/bfd/elf64-ppc.c +@@ -11294,7 +11294,12 @@ ppc64_elf_relocate_section (bfd *output_ + else if (!SYMBOL_REFERENCES_LOCAL (info, &h->elf) + && !is_opd + && r_type != R_PPC64_TOC) +- outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type); ++ { ++ outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type); ++ if (h->elf.dynindx == -1 ++ && h->elf.root.type == bfd_link_hash_undefweak) ++ memset (&outrel, 0, sizeof outrel); ++ } + else + { + /* This symbol is local, or marked to become local, diff --git a/patches/binutils-2.19.1/generic/gentoo/04_all_binutils-2.15.92.0.2-place-orphan.patch b/patches/binutils-2.19.1/generic/gentoo/04_all_binutils-2.15.92.0.2-place-orphan.patch new file mode 100644 index 0000000..cfc9b05 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/04_all_binutils-2.15.92.0.2-place-orphan.patch @@ -0,0 +1,22 @@ +2003-08-05 Jakub Jelinek <jakub@redhat.com> + + * emulparams/elf64ppc.sh (OTHER_GOT_RELOC_SECTIONS): Add .rela.opd. + +--- + ld/emulparams/elf64ppc.sh | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +Index: binutils-2.18/ld/emulparams/elf64ppc.sh +=================================================================== +--- binutils-2.18.orig/ld/emulparams/elf64ppc.sh ++++ binutils-2.18/ld/emulparams/elf64ppc.sh +@@ -28,7 +28,8 @@ else + .toc 0 : { *(.toc) }" + fi + OTHER_GOT_RELOC_SECTIONS=" +- .rela.toc ${RELOCATING-0} : { *(.rela.toc) }" ++ .rela.toc ${RELOCATING-0} : { *(.rela.toc) } ++ .rela.opd ${RELOCATING-0} : { *(.rela.opd) }" + OTHER_READWRITE_SECTIONS=" + .toc1 ${RELOCATING-0} :${RELOCATING+ ALIGN(8)} { *(.toc1) } + .opd ${RELOCATING-0} :${RELOCATING+ ALIGN(8)} { KEEP (*(.opd)) } diff --git a/patches/binutils-2.19.1/generic/gentoo/07_all_binutils-2.18-windres.patch b/patches/binutils-2.19.1/generic/gentoo/07_all_binutils-2.18-windres.patch new file mode 100644 index 0000000..659a5a6 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/07_all_binutils-2.18-windres.patch @@ -0,0 +1,18 @@ +http://sourceware.org/bugzilla/show_bug.cgi?id=4987 + +--- + binutils/resrc.c | 1 + + 1 file changed, 1 insertion(+) + +Index: binutils-2.19.1/binutils/resrc.c +=================================================================== +--- binutils-2.19.1.orig/binutils/resrc.c ++++ binutils-2.19.1/binutils/resrc.c +@@ -439,6 +439,7 @@ read_rc_file (const char *filename, cons + if (filename == NULL) + filename = "-"; + /* Setup the default resource import path taken from input file. */ +++ if (filename != NULL && (strchr (filename, '/') != NULL || strchr (filename, '\\') != NULL)) + else if (strchr (filename, '/') != NULL || strchr (filename, '\\') != NULL) + { + char *edit, *dir; diff --git a/patches/binutils-2.19.1/generic/gentoo/08_all_binutils-RPATH_ENVVAR-smack.patch b/patches/binutils-2.19.1/generic/gentoo/08_all_binutils-RPATH_ENVVAR-smack.patch new file mode 100644 index 0000000..ee30e1d --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/08_all_binutils-RPATH_ENVVAR-smack.patch @@ -0,0 +1,19 @@ +http://sourceware.org/ml/binutils/2007-07/msg00401.html +http://sourceware.org/bugzilla/show_bug.cgi?id=4970 + +--- + configure | 1 + + 1 file changed, 1 insertion(+) + +Index: binutils-2.19.1/configure +=================================================================== +--- binutils-2.19.1.orig/configure ++++ binutils-2.19.1/configure +@@ -5430,6 +5430,7 @@ case "${target}" in + md_exec_prefix=/usr/ccs/bin + ;; + esac ++RPATH_ENVVAR="cant_touch_this_nah_nah_nah" + + extra_arflags_for_target= + extra_nmflags_for_target= diff --git a/patches/binutils-2.19.1/generic/gentoo/09_all_binutils-ld-tests-CXXFLAGS.patch b/patches/binutils-2.19.1/generic/gentoo/09_all_binutils-ld-tests-CXXFLAGS.patch new file mode 100644 index 0000000..3d65169 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/09_all_binutils-ld-tests-CXXFLAGS.patch @@ -0,0 +1,33 @@ +http://sourceware.org/ml/binutils/2007-08/msg00411.html + +forcing CFLAGS against C++ builds causes false failures + +--- + ld/testsuite/lib/ld-lib.exp | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +Index: binutils-2.19.1/ld/testsuite/lib/ld-lib.exp +=================================================================== +--- binutils-2.19.1.orig/ld/testsuite/lib/ld-lib.exp ++++ binutils-2.19.1/ld/testsuite/lib/ld-lib.exp +@@ -225,7 +225,11 @@ proc default_ld_compile { cc source obje + remote_file build delete "$object" + remote_file host delete "$object" + +- set flags "-I$srcdir/$subdir" ++ if {[string match "*.cc" $source]} then { ++ set flags "-I$srcdir/$subdir $CXXFLAGS" ++ } else { ++ set flags "-I$srcdir/$subdir $CFLAGS" ++ } + + # If we are compiling with gcc, we want to add gcc_gas_flag to + # flags. Rather than determine this in some complex way, we guess +@@ -1111,6 +1115,7 @@ proc run_ld_link_tests { ldtests } { + global env + global CC + global CFLAGS ++ global CXXFLAGS + + foreach testitem $ldtests { + set testname [lindex $testitem 0] diff --git a/patches/binutils-2.19.1/generic/gentoo/12_all_sh-targets.patch b/patches/binutils-2.19.1/generic/gentoo/12_all_sh-targets.patch new file mode 100644 index 0000000..e79210e --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/12_all_sh-targets.patch @@ -0,0 +1,56 @@ +r10231 | lethal | 2005-05-02 09:58:00 -0400 (Mon, 02 May 2005) | 13 lines + +Likewise, binutils has no idea about any of these new targets either, so we +fix that up too.. now we're able to actually build a real toolchain for +sh2a_nofpu- and other more ineptly named toolchains (and yes, there are more +inept targets than that one, really. Go look, I promise). + +--- + configure | 4 ++-- + configure.ac | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +Index: binutils-2.19.1/configure +=================================================================== +--- binutils-2.19.1.orig/configure ++++ binutils-2.19.1/configure +@@ -2281,7 +2281,7 @@ case "${target}" in + am33_2.0-*-linux*) + noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss" + ;; +- sh-*-linux*) ++ sh*-*-linux*) + noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss" + ;; + sh*-*-pe|mips*-*-pe|*arm-wince-pe) +@@ -2606,7 +2606,7 @@ case "${target}" in + romp-*-*) + noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}" + ;; +- sh-*-* | sh64-*-*) ++ sh*-*-* | sh64-*-*) + case "${host}" in + i[3456789]86-*-vsta) ;; # don't add gprof back in + i[3456789]86-*-go32*) ;; # don't add gprof back in +Index: binutils-2.19.1/configure.ac +=================================================================== +--- binutils-2.19.1.orig/configure.ac ++++ binutils-2.19.1/configure.ac +@@ -530,7 +530,7 @@ case "${target}" in + am33_2.0-*-linux*) + noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss" + ;; +- sh-*-linux*) ++ sh*-*-linux*) + noconfigdirs="$noconfigdirs ${libgcj} target-newlib target-libgloss" + ;; + sh*-*-pe|mips*-*-pe|*arm-wince-pe) +@@ -855,7 +855,7 @@ case "${target}" in + romp-*-*) + noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss ${libgcj}" + ;; +- sh-*-* | sh64-*-*) ++ sh*-*-* | sh64-*-*) + case "${host}" in + i[[3456789]]86-*-vsta) ;; # don't add gprof back in + i[[3456789]]86-*-go32*) ;; # don't add gprof back in diff --git a/patches/binutils-2.19.1/generic/gentoo/18_all_binutils-makeinfo-version.patch b/patches/binutils-2.19.1/generic/gentoo/18_all_binutils-makeinfo-version.patch new file mode 100644 index 0000000..bdbc340 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/18_all_binutils-makeinfo-version.patch @@ -0,0 +1,38 @@ +http://bugs.gentoo.org/195074 + +2007-09-15 Alan Modra <amodra@bigpond.net.au> + + * configure.ac: Correct makeinfo version check. + * configure: Regenerate. + +--- + configure | 2 +- + configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +Index: binutils-2.18/configure.ac +=================================================================== +--- binutils-2.18.orig/configure.ac ++++ binutils-2.18/configure.ac +@@ -2403,7 +2403,7 @@ changequote(,) + # For an installed makeinfo, we require it to be from texinfo 4.4 or + # higher, else we use the "missing" dummy. + if ${MAKEINFO} --version \ +- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then ++ | egrep 'texinfo[^0-9]*(4\.([4-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then + : + else + MAKEINFO="$MISSING makeinfo" +Index: binutils-2.18/configure +=================================================================== +--- binutils-2.18.orig/configure ++++ binutils-2.18/configure +@@ -6129,7 +6129,7 @@ case " $build_configdirs " in + # For an installed makeinfo, we require it to be from texinfo 4.4 or + # higher, else we use the "missing" dummy. + if ${MAKEINFO} --version \ +- | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[4-9]|[5-9])' >/dev/null 2>&1; then ++ | egrep 'texinfo[^0-9]*(4\.([4-9]|[1-9][0-9])|[5-9]|[1-9][0-9])' >/dev/null 2>&1; then + : + else + MAKEINFO="$MISSING makeinfo" diff --git a/patches/binutils-2.19.1/generic/gentoo/25_all_binutils-for-build-flags.patch b/patches/binutils-2.19.1/generic/gentoo/25_all_binutils-for-build-flags.patch new file mode 100644 index 0000000..8c2cf03 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/25_all_binutils-for-build-flags.patch @@ -0,0 +1,23 @@ +only default CFLAGS_FOR_BUILD to host CFLAGS when build and host are the same + +http://bugs.gentoo.org/192959 + +--- + configure | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +Index: binutils-2.18/configure +=================================================================== +--- binutils-2.18.orig/configure ++++ binutils-2.18/configure +@@ -5778,7 +5778,9 @@ esac + + # Allow the user to override the flags for + # our build compiler if desired. +-CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}} ++if test x"${build}" = x"${host}" ; then ++ CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}} ++fi + + # On Canadian crosses, we'll be searching the right directories for + # the previously-installed cross compiler, so don't bother to add diff --git a/patches/binutils-2.19.1/generic/gentoo/30_all_binutils-multitarget-fixup.patch b/patches/binutils-2.19.1/generic/gentoo/30_all_binutils-multitarget-fixup.patch new file mode 100644 index 0000000..70651c4 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/30_all_binutils-multitarget-fixup.patch @@ -0,0 +1,30 @@ +Fix from upstream for --enable-targets=all on an x86_64 multilib system. + +http://sourceware.org/ml/binutils/2007-09/msg00137.html +http://sourceware.org/ml/binutils/2007-09/msg00162.html + +2007-09-14 Alan Modra <amodra@bigpond.net.au> + + * format.c (bfd_check_format_matches): Record matching targets even + when "matching" is NULL to allow bfd_associated_vector matches. + Consolidate error return code. Consolidate ok return code. Always + restore original target and format on error. + +--- + bfd/format.c | 3 +++ + 1 file changed, 3 insertions(+) + +Index: binutils-2.19.1/bfd/format.c +=================================================================== +--- binutils-2.19.1.orig/bfd/format.c ++++ binutils-2.19.1/bfd/format.c +@@ -128,6 +128,9 @@ bfd_check_format_matches (bfd *abfd, bfd + if (matching != NULL) + *matching = NULL; + ++ if (matching != NULL) ++ *matching = NULL; ++ + if (!bfd_read_p (abfd) + || (unsigned int) abfd->format >= (unsigned int) bfd_type_end) + { diff --git a/patches/binutils-2.19.1/generic/gentoo/33_all_binutils-gnu-relro-fixups.patch b/patches/binutils-2.19.1/generic/gentoo/33_all_binutils-gnu-relro-fixups.patch new file mode 100644 index 0000000..2471163 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/33_all_binutils-gnu-relro-fixups.patch @@ -0,0 +1,536 @@ +http://bugs.gentoo.org/192584 +http://sourceware.org/bugzilla/show_bug.cgi?id=5037 +http://sourceware.org/ml/binutils/2007-09/msg00208.html + +bfd/ + +2007-09-16 H.J. Lu <hongjiu.lu@intel.com> + + PR binutils/3281 + PR binutils/5037 + * elf-bfd.h (elf_obj_tdata): Remove relro. + + * elf.c (get_program_header_size): Check info->relro instead + of elf_tdata (abfd)->relro. + (_bfd_elf_map_sections_to_segments): Likewise. + (assign_file_positions_for_load_sections): Don't set + PT_GNU_RELRO segment alignment here. + (assign_file_positions_for_non_load_sections): Properly set up + PT_GNU_RELRO segment for copying executable/shared library. + (rewrite_elf_program_header): Remove PT_GNU_RELRO segment. + (copy_elf_program_header): Set p_size and p_size_valid fields for + PT_GNU_RELRO segment. + +include/elf/ + +2007-09-16 H.J. Lu <hongjiu.lu@intel.com> + + PR binutils/3281 + PR binutils/5037 + * internal.h (elf_segment_map): Add p_size and p_size_valid. + (ELF_IS_SECTION_IN_SEGMENT): Allow SHF_TLS sections in + PT_GNU_RELRO segments. + +ld/ + +2007-09-16 H.J. Lu <hongjiu.lu@intel.com> + + PR binutils/3281 + PR binutils/5037 + * ldexp.h (ldexp_control): Add relro, relro_start_stat and + relro_end_stat. + + * ldexp.c (fold_binary): Set expld.dataseg.relro to + exp_dataseg_relro_start or exp_dataseg_relro_end when + seeing DATA_SEGMENT_ALIGN or DATA_SEGMENT_RELRO_END, + respectively. + + * ldlang.c (lang_size_sections_1): Properly set + expld.dataseg.relro_start_stat and + expld.dataseg.relro_end_stat. + (find_relro_section_callback): New function. + (lang_find_relro_sections_1): Likewise. + (lang_find_relro_sections): Likewise. + (lang_process): Call lang_find_relro_sections for + non-relocatable link. + +ld/testsuite/ + +2007-09-16 H.J. Lu <hongjiu.lu@intel.com> + + PR binutils/3281 + PR binutils/5037 + * ld-elf/binutils.exp: Update "-z relro" tests to use relro1.s. + Add "-z relro" tests with relro2.s. Add "-z relro" tests with + TLS for objcopy. + + * ld-elf/relro1.s: New file. + * ld-elf/relro2.s: Likewise. + +--- + bfd/elf-bfd.h | 3 - + bfd/elf.c | 77 ++++++++++++++++++++++++----- + bfd/elflink.c | 1 + include/elf/internal.h | 10 +++ + ld/ldexp.c | 2 + ld/ldexp.h | 11 ++++ + ld/ldlang.c | 101 +++++++++++++++++++++++++++++++++++++++ + ld/testsuite/ld-elf/binutils.exp | 28 ++++++++-- + ld/testsuite/ld-elf/relro1.s | 14 +++++ + ld/testsuite/ld-elf/relro2.s | 5 + + 10 files changed, 227 insertions(+), 25 deletions(-) + +Index: binutils-2.18/bfd/elf-bfd.h +=================================================================== +--- binutils-2.18.orig/bfd/elf-bfd.h ++++ binutils-2.18/bfd/elf-bfd.h +@@ -1428,9 +1428,6 @@ struct elf_obj_tdata + /* Segment flags for the PT_GNU_STACK segment. */ + unsigned int stack_flags; + +- /* Should the PT_GNU_RELRO segment be emitted? */ +- bfd_boolean relro; +- + /* Symbol version definitions in external objects. */ + Elf_Internal_Verdef *verdef; + +Index: binutils-2.18/bfd/elf.c +=================================================================== +--- binutils-2.18.orig/bfd/elf.c ++++ binutils-2.18/bfd/elf.c +@@ -3321,7 +3321,7 @@ get_program_header_size (bfd *abfd, stru + /* We need a PT_DYNAMIC segment. */ + ++segs; + +- if (elf_tdata (abfd)->relro) ++ if (info->relro) + { + /* We need a PT_GNU_RELRO segment only when there is a + PT_DYNAMIC segment. */ +@@ -3851,7 +3851,7 @@ _bfd_elf_map_sections_to_segments (bfd * + pm = &m->next; + } + +- if (dynsec != NULL && elf_tdata (abfd)->relro) ++ if (dynsec != NULL && info->relro) + { + /* We make a PT_GNU_RELRO segment only when there is a + PT_DYNAMIC segment. */ +@@ -4326,12 +4326,10 @@ assign_file_positions_for_load_sections + p->p_memsz += this_hdr->sh_size; + } + +- if (p->p_type == PT_GNU_RELRO) +- p->p_align = 1; +- else if (align > p->p_align +- && !m->p_align_valid +- && (p->p_type != PT_LOAD +- || (abfd->flags & D_PAGED) == 0)) ++ if (align > p->p_align ++ && !m->p_align_valid ++ && (p->p_type != PT_LOAD ++ || (abfd->flags & D_PAGED) == 0)) + p->p_align = align; + } + +@@ -4480,18 +4478,53 @@ assign_file_positions_for_non_load_secti + if (m->count != 0) + { + if (p->p_type != PT_LOAD +- && (p->p_type != PT_NOTE || bfd_get_format (abfd) != bfd_core)) ++ && (p->p_type != PT_NOTE ++ || bfd_get_format (abfd) != bfd_core)) + { + Elf_Internal_Shdr *hdr; ++ asection *sect; ++ + BFD_ASSERT (!m->includes_filehdr && !m->includes_phdrs); + +- hdr = &elf_section_data (m->sections[m->count - 1])->this_hdr; +- p->p_filesz = (m->sections[m->count - 1]->filepos +- - m->sections[0]->filepos); ++ sect = m->sections[m->count - 1]; ++ hdr = &elf_section_data (sect)->this_hdr; ++ p->p_filesz = sect->filepos - m->sections[0]->filepos; + if (hdr->sh_type != SHT_NOBITS) + p->p_filesz += hdr->sh_size; + +- p->p_offset = m->sections[0]->filepos; ++ if (p->p_type == PT_GNU_RELRO) ++ { ++ /* When we get here, we are copying executable ++ or shared library. But we need to use the same ++ linker logic. */ ++ Elf_Internal_Phdr *lp; ++ ++ for (lp = phdrs; lp < phdrs + count; ++lp) ++ { ++ if (lp->p_type == PT_LOAD ++ && lp->p_paddr == p->p_paddr) ++ break; ++ } ++ ++ if (lp < phdrs + count) ++ { ++ /* We should use p_size if it is valid since it ++ may contain the first few bytes of the next ++ SEC_ALLOC section. */ ++ if (m->p_size_valid) ++ p->p_filesz = m->p_size; ++ else ++ abort (); ++ p->p_vaddr = lp->p_vaddr; ++ p->p_offset = lp->p_offset; ++ p->p_memsz = p->p_filesz; ++ p->p_align = 1; ++ } ++ else ++ abort (); ++ } ++ else ++ p->p_offset = m->sections[0]->filepos; + } + } + else +@@ -5080,7 +5113,12 @@ rewrite_elf_program_header (bfd *ibfd, b + } + + if (segment->p_type != PT_LOAD) +- continue; ++ { ++ /* Remove PT_GNU_RELRO segment. */ ++ if (segment->p_type == PT_GNU_RELRO) ++ segment->p_type = PT_NULL; ++ continue; ++ } + + /* Determine if this segment overlaps any previous segments. */ + for (j = 0, segment2 = elf_tdata (ibfd)->phdr; j < i; j++, segment2 ++) +@@ -5604,6 +5642,17 @@ copy_elf_program_header (bfd *ibfd, bfd + map->p_align_valid = 1; + map->p_vaddr_offset = 0; + ++ if (map->p_type == PT_GNU_RELRO ++ && segment->p_filesz == segment->p_memsz) ++ { ++ /* The PT_GNU_RELRO segment may contain the first a few ++ bytes in the .got.plt section even if the whole .got.plt ++ section isn't in the PT_GNU_RELRO segment. We won't ++ change the size of the PT_GNU_RELRO segment. */ ++ map->p_size = segment->p_filesz; ++ map->p_size_valid = 1; ++ } ++ + /* Determine if this segment contains the ELF file header + and if it contains the program headers themselves. */ + map->includes_filehdr = (segment->p_offset == 0 +Index: binutils-2.18/bfd/elflink.c +=================================================================== +--- binutils-2.18.orig/bfd/elflink.c ++++ binutils-2.18/bfd/elflink.c +@@ -5327,7 +5327,6 @@ bfd_elf_size_dynamic_sections (bfd *outp + return TRUE; + + bed = get_elf_backend_data (output_bfd); +- elf_tdata (output_bfd)->relro = info->relro; + if (info->execstack) + elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; + else if (info->noexecstack) +Index: binutils-2.18/include/elf/internal.h +=================================================================== +--- binutils-2.18.orig/include/elf/internal.h ++++ binutils-2.18/include/elf/internal.h +@@ -239,6 +239,8 @@ struct elf_segment_map + bfd_vma p_vaddr_offset; + /* Program segment alignment. */ + bfd_vma p_align; ++ /* Segment size in file and memory */ ++ bfd_vma p_size; + /* Whether the p_flags field is valid; if not, the flags are based + on the section flags. */ + unsigned int p_flags_valid : 1; +@@ -248,6 +250,9 @@ struct elf_segment_map + /* Whether the p_align field is valid; if not, PT_LOAD segment + alignment is based on the default maximum page size. */ + unsigned int p_align_valid : 1; ++ /* Whether the p_size field is valid; if not, the size are based ++ on the section sizes. */ ++ unsigned int p_size_valid : 1; + /* Whether this segment includes the file header. */ + unsigned int includes_filehdr : 1; + /* Whether this segment includes the program headers. */ +@@ -266,11 +271,12 @@ struct elf_segment_map + || segment->p_type == PT_TLS) ? sec_hdr->sh_size : 0) + + /* Decide if the given sec_hdr is in the given segment. PT_TLS segment +- contains only SHF_TLS sections. Only PT_LOAD and PT_TLS segments +- can contain SHF_TLS sections. */ ++ contains only SHF_TLS sections. Only PT_LOAD, PT_GNU_RELRO and ++ and PT_TLS segments can contain SHF_TLS sections. */ + #define ELF_IS_SECTION_IN_SEGMENT(sec_hdr, segment) \ + (((((sec_hdr->sh_flags & SHF_TLS) != 0) \ + && (segment->p_type == PT_TLS \ ++ || segment->p_type == PT_GNU_RELRO \ + || segment->p_type == PT_LOAD)) \ + || ((sec_hdr->sh_flags & SHF_TLS) == 0 \ + && segment->p_type != PT_TLS)) \ +Index: binutils-2.18/ld/ldexp.c +=================================================================== +--- binutils-2.18.orig/ld/ldexp.c ++++ binutils-2.18/ld/ldexp.c +@@ -390,6 +390,7 @@ fold_binary (etree_type *tree) + break; + + case DATA_SEGMENT_ALIGN: ++ expld.dataseg.relro = exp_dataseg_relro_start; + if (expld.phase != lang_first_phase_enum + && expld.section == bfd_abs_section_ptr + && (expld.dataseg.phase == exp_dataseg_none +@@ -425,6 +426,7 @@ fold_binary (etree_type *tree) + break; + + case DATA_SEGMENT_RELRO_END: ++ expld.dataseg.relro = exp_dataseg_relro_end; + if (expld.phase != lang_first_phase_enum + && (expld.dataseg.phase == exp_dataseg_align_seen + || expld.dataseg.phase == exp_dataseg_adjust +Index: binutils-2.18/ld/ldexp.h +=================================================================== +--- binutils-2.18.orig/ld/ldexp.h ++++ binutils-2.18/ld/ldexp.h +@@ -98,6 +98,8 @@ typedef enum { + lang_final_phase_enum + } lang_phase_type; + ++union lang_statement_union; ++ + struct ldexp_control { + /* Modify expression evaluation depending on this. */ + lang_phase_type phase; +@@ -125,6 +127,15 @@ struct ldexp_control { + } phase; + + bfd_vma base, min_base, relro_end, end, pagesize, maxpagesize; ++ ++ enum { ++ exp_dataseg_relro_none, ++ exp_dataseg_relro_start, ++ exp_dataseg_relro_end, ++ } relro; ++ ++ union lang_statement_union *relro_start_stat; ++ union lang_statement_union *relro_end_stat; + } dataseg; + }; + +Index: binutils-2.18/ld/ldlang.c +=================================================================== +--- binutils-2.18.orig/ld/ldlang.c ++++ binutils-2.18/ld/ldlang.c +@@ -4631,10 +4631,32 @@ lang_size_sections_1 + bfd_vma newdot = dot; + etree_type *tree = s->assignment_statement.exp; + ++ expld.dataseg.relro = exp_dataseg_relro_none; ++ + exp_fold_tree (tree, + output_section_statement->bfd_section, + &newdot); + ++ if (expld.dataseg.relro == exp_dataseg_relro_start) ++ { ++ if (!expld.dataseg.relro_start_stat) ++ expld.dataseg.relro_start_stat = s; ++ else ++ { ++ ASSERT (expld.dataseg.relro_start_stat == s); ++ } ++ } ++ else if (expld.dataseg.relro == exp_dataseg_relro_end) ++ { ++ if (!expld.dataseg.relro_end_stat) ++ expld.dataseg.relro_end_stat = s; ++ else ++ { ++ ASSERT (expld.dataseg.relro_end_stat == s); ++ } ++ } ++ expld.dataseg.relro = exp_dataseg_relro_none; ++ + /* This symbol is relative to this section. */ + if ((tree->type.node_class == etree_provided + || tree->type.node_class == etree_assign) +@@ -5660,6 +5682,81 @@ lang_gc_sections (void) + bfd_gc_sections (output_bfd, &link_info); + } + ++/* Worker for lang_find_relro_sections_1. */ ++ ++static void ++find_relro_section_callback (lang_wild_statement_type *ptr ATTRIBUTE_UNUSED, ++ struct wildcard_list *sec ATTRIBUTE_UNUSED, ++ asection *section, ++ lang_input_statement_type *file ATTRIBUTE_UNUSED, ++ void *data) ++{ ++ /* Discarded, excluded and ignored sections effectively have zero ++ size. */ ++ if (section->output_section != NULL ++ && section->output_section->owner == output_bfd ++ && (section->output_section->flags & SEC_EXCLUDE) == 0 ++ && !IGNORE_SECTION (section) ++ && section->size != 0) ++ { ++ bfd_boolean *has_relro_section = (bfd_boolean *) data; ++ *has_relro_section = TRUE; ++ } ++} ++ ++/* Iterate over sections for relro sections. */ ++ ++static void ++lang_find_relro_sections_1 (lang_statement_union_type *s, ++ bfd_boolean *has_relro_section) ++{ ++ if (*has_relro_section) ++ return; ++ ++ for (; s != NULL; s = s->header.next) ++ { ++ if (s == expld.dataseg.relro_end_stat) ++ break; ++ ++ switch (s->header.type) ++ { ++ case lang_wild_statement_enum: ++ walk_wild (&s->wild_statement, ++ find_relro_section_callback, ++ has_relro_section); ++ break; ++ case lang_constructors_statement_enum: ++ lang_find_relro_sections_1 (constructor_list.head, ++ has_relro_section); ++ break; ++ case lang_output_section_statement_enum: ++ lang_find_relro_sections_1 (s->output_section_statement.children.head, ++ has_relro_section); ++ break; ++ case lang_group_statement_enum: ++ lang_find_relro_sections_1 (s->group_statement.children.head, ++ has_relro_section); ++ break; ++ default: ++ break; ++ } ++ } ++} ++ ++static void ++lang_find_relro_sections (void) ++{ ++ bfd_boolean has_relro_section = FALSE; ++ ++ /* Check all sections in the link script. */ ++ ++ lang_find_relro_sections_1 (expld.dataseg.relro_start_stat, ++ &has_relro_section); ++ ++ if (!has_relro_section) ++ link_info.relro = FALSE; ++} ++ + /* Relax all sections until bfd_relax_section gives up. */ + + static void +@@ -5787,6 +5884,10 @@ lang_process (void) + section positions, since they will affect SIZEOF_HEADERS. */ + lang_record_phdrs (); + ++ /* Check relro sections. */ ++ if (link_info.relro && ! link_info.relocatable) ++ lang_find_relro_sections (); ++ + /* Size up the sections. */ + lang_size_sections (NULL, !command_line.relax); + +Index: binutils-2.18/ld/testsuite/ld-elf/binutils.exp +=================================================================== +--- binutils-2.18.orig/ld/testsuite/ld-elf/binutils.exp ++++ binutils-2.18/ld/testsuite/ld-elf/binutils.exp +@@ -104,24 +104,42 @@ binutils_test strip "-shared" maxpage1 + binutils_test objcopy "" maxpage1 + binutils_test objcopy "-shared" maxpage1 + +-binutils_test strip "-z relro" maxpage1 +-binutils_test strip "-z relro -shared" maxpage1 +-binutils_test objcopy "-z relro" maxpage1 +-binutils_test objcopy "-z relro -shared" maxpage1 ++binutils_test strip "-z relro" relro1 ++binutils_test strip "-z relro -shared" relro1 ++binutils_test objcopy "-z relro" relro1 ++binutils_test objcopy "-z relro -shared" relro1 ++if { ([istarget "i?86-*-elf*"] ++ || ([istarget "i?86-*-linux*"] ++ && ![istarget "*-*-*aout*"] ++ && ![istarget "*-*-*oldld*"]) ++ || [istarget "x86_64-*-linux*"] ++ || [istarget "amd64-*-linux*"]) } { ++ binutils_test strip "-z relro -shared" relro2 ++ binutils_test objcopy "-z relro -shared" relro2 ++} + + binutils_test objcopy "" tbss1 ++binutils_test objcopy "-z relro" tbss1 + binutils_test objcopy "-shared" tbss1 ++binutils_test objcopy "-shared -z relro" tbss1 + binutils_test objcopy "-z max-page-size=0x100000" tbss1 + binutils_test objcopy "-z max-page-size=0x100000 -z common-page-size=0x1000" tbss1 + binutils_test objcopy "" tdata1 ++binutils_test objcopy "-z relro" tdata1 + binutils_test objcopy "-shared" tdata1 ++binutils_test objcopy "-shared -z relro" tdata1 + binutils_test objcopy "-z max-page-size=0x100000" tdata1 + binutils_test objcopy "-z max-page-size=0x100000 -z common-page-size=0x1000" tdata1 + binutils_test objcopy "" tbss2 ++binutils_test objcopy "-z relro" tbss2 + binutils_test objcopy "-shared" tbss2 ++binutils_test objcopy "-shared -z relro" tbss2 + binutils_test objcopy "-z max-page-size=0x100000" tbss2 + binutils_test objcopy "-z max-page-size=0x100000 -z common-page-size=0x1000" tbss2 +-binutils_test objcopy "-z max-page-size=0x100000" tdata2 ++ + binutils_test objcopy "" tdata2 ++binutils_test objcopy "-z relro" tdata2 + binutils_test objcopy "-shared" tdata2 ++binutils_test objcopy "-shared -z relro" tdata2 ++binutils_test objcopy "-z max-page-size=0x100000" tdata2 + binutils_test objcopy "-z max-page-size=0x100000 -z common-page-size=0x1000" tdata2 +Index: binutils-2.18/ld/testsuite/ld-elf/relro1.s +=================================================================== +--- /dev/null ++++ binutils-2.18/ld/testsuite/ld-elf/relro1.s +@@ -0,0 +1,14 @@ ++ .globl main ++ .globl start ++ .globl _start ++ .globl __start ++ .text ++main: ++start: ++_start: ++__start: ++ .long 0 ++ .data ++ .long 0 ++ .section .data.rel.ro,"aw",%progbits ++ .long 0 +Index: binutils-2.18/ld/testsuite/ld-elf/relro2.s +=================================================================== +--- /dev/null ++++ binutils-2.18/ld/testsuite/ld-elf/relro2.s +@@ -0,0 +1,5 @@ ++ .text ++ .globl x ++ .type x, @function ++x: ++ jmp foo@PLT diff --git a/patches/binutils-2.19.1/generic/gentoo/42_all_012_check_ldrunpath_length.patch b/patches/binutils-2.19.1/generic/gentoo/42_all_012_check_ldrunpath_length.patch new file mode 100644 index 0000000..5310741 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/42_all_012_check_ldrunpath_length.patch @@ -0,0 +1,52 @@ +#!/bin/sh -e +## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org> +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for +## DP: cases where -rpath isn't specified. (#151024) + +if [ $# -ne 1 ]; then + echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" + exit 1 +fi + +[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts +patch_opts="${patch_opts:--f --no-backup-if-mismatch}" + +case "$1" in + -patch) patch $patch_opts -p1 < $0;; + -unpatch) patch $patch_opts -p1 -R < $0;; + *) + echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" + exit 1;; +esac + +exit 0 + +@DPATCH@ +--- + ld/emultempl/elf32.em | 4 ++++ + 1 file changed, 4 insertions(+) + +Index: binutils-2.19.1/ld/emultempl/elf32.em +=================================================================== +--- binutils-2.19.1.orig/ld/emultempl/elf32.em ++++ binutils-2.19.1/ld/emultempl/elf32.em +@@ -1219,6 +1219,8 @@ fragment <<EOF + && command_line.rpath == NULL) + { + lib_path = (const char *) getenv ("LD_RUN_PATH"); ++ if ((lib_path) && (strlen (lib_path) == 0)) ++ lib_path = NULL; + if (gld${EMULATION_NAME}_search_needed (lib_path, &n, + force)) + break; +@@ -1404,6 +1406,8 @@ gld${EMULATION_NAME}_before_allocation ( + rpath = command_line.rpath; + if (rpath == NULL) + rpath = (const char *) getenv ("LD_RUN_PATH"); ++ if ((rpath) && (strlen (rpath) == 0)) ++ rpath = NULL; + if (! (bfd_elf_size_dynamic_sections + (link_info.output_bfd, command_line.soname, rpath, + command_line.filter_shlib, diff --git a/patches/binutils-2.19.1/generic/gentoo/66_all_binutils-2.17.50.0.2-warn-textrel.patch b/patches/binutils-2.19.1/generic/gentoo/66_all_binutils-2.17.50.0.2-warn-textrel.patch new file mode 100644 index 0000000..66708be --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/66_all_binutils-2.17.50.0.2-warn-textrel.patch @@ -0,0 +1,66 @@ +textrels are bad for forcing copy-on-write (this affects everyone), +and for security/runtime code generation, this affects security ppl. +But in either case, it doesn't matter who needs textrels, it's +the very fact that they're needed at all. + +2006-06-10 Ned Ludd <solar@gentoo.org>, Mike Frysinger <vapier@gentoo.org> + + * bfd/elflink.c (bfd_elf_final_link): Check all objects for TEXTRELs. + * ld/ldmain.c (main): Change textrel warning default to true. + * ld/testsuite/lib/ld-lib.exp (default_ld_simple_link): Scrub TEXTREL + warnings from ld output. + +--- + bfd/elflink.c | 6 ++---- + ld/ldmain.c | 1 + + ld/testsuite/lib/ld-lib.exp | 4 ++++ + 3 files changed, 7 insertions(+), 4 deletions(-) + +Index: binutils-2.19.1/bfd/elflink.c +=================================================================== +--- binutils-2.19.1.orig/bfd/elflink.c ++++ binutils-2.19.1/bfd/elflink.c +@@ -10802,14 +10802,12 @@ bfd_elf_final_link (bfd *abfd, struct bf + goto error_return; + + /* Check for DT_TEXTREL (late, in case the backend removes it). */ +- if (info->warn_shared_textrel && info->shared) ++ o = bfd_get_section_by_name (dynobj, ".dynamic"); ++ if (info->warn_shared_textrel && o != NULL) + { + bfd_byte *dyncon, *dynconend; + + /* Fix up .dynamic entries. */ +- o = bfd_get_section_by_name (dynobj, ".dynamic"); +- BFD_ASSERT (o != NULL); +- + dyncon = o->contents; + dynconend = o->contents + o->size; + for (; dyncon < dynconend; dyncon += bed->s->sizeof_dyn) +Index: binutils-2.19.1/ld/ldmain.c +=================================================================== +--- binutils-2.19.1.orig/ld/ldmain.c ++++ binutils-2.19.1/ld/ldmain.c +@@ -280,6 +280,7 @@ main (int argc, char **argv) + emulation = get_emulation (argc, argv); + ldemul_choose_mode (emulation); + default_target = ldemul_choose_target (argc, argv); ++ link_info.warn_shared_textrel = TRUE; + lang_init (); + ldemul_before_parse (); + lang_has_input_file = FALSE; +Index: binutils-2.19.1/ld/testsuite/lib/ld-lib.exp +=================================================================== +--- binutils-2.19.1.orig/ld/testsuite/lib/ld-lib.exp ++++ binutils-2.19.1/ld/testsuite/lib/ld-lib.exp +@@ -196,6 +196,10 @@ proc default_ld_simple_link { ld target + # symbol, since the default linker script might use ENTRY. + regsub -all "(^|\n)(\[^\n\]*: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output + ++ # Gentoo tweak: ++ # We want to ignore TEXTREL warnings since we force enable them by default ++ regsub -all "^lt-ld-new: warning: creating a DT_TEXTREL in object\." $exec_output "\\1" exec_output ++ + if [string match "" $exec_output] then { + return 1 + } else { diff --git a/patches/binutils-2.19.1/generic/gentoo/76_all_only-use-new-ld-dtags.patch.disabled b/patches/binutils-2.19.1/generic/gentoo/76_all_only-use-new-ld-dtags.patch.disabled new file mode 100644 index 0000000..0e7fc2c --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/76_all_only-use-new-ld-dtags.patch.disabled @@ -0,0 +1,31 @@ +Don't generate RPATH if we're going to be generating RUNPATH. + +need to ponder what ramifications this has before enabling it + +--- + bfd/elflink.c | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +Index: binutils-2.19.1/bfd/elflink.c +=================================================================== +--- binutils-2.19.1.orig/bfd/elflink.c ++++ binutils-2.19.1/bfd/elflink.c +@@ -5492,11 +5492,15 @@ bfd_elf_size_dynamic_sections (bfd *outp + + indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, rpath, + TRUE); +- if (indx == (bfd_size_type) -1 +- || !_bfd_elf_add_dynamic_entry (info, DT_RPATH, indx)) ++ if (indx == (bfd_size_type) -1) + return FALSE; + +- if (info->new_dtags) ++ if (!info->new_dtags) ++ { ++ if (!_bfd_elf_add_dynamic_entry (info, DT_RPATH, indx)) ++ return FALSE; ++ } ++ else + { + _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, indx); + if (!_bfd_elf_add_dynamic_entry (info, DT_RUNPATH, indx)) diff --git a/patches/binutils-2.19.1/generic/gentoo/91_all_libiberty-pic.patch b/patches/binutils-2.19.1/generic/gentoo/91_all_libiberty-pic.patch new file mode 100644 index 0000000..2dedf3e --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/91_all_libiberty-pic.patch @@ -0,0 +1,16 @@ +--- + libiberty/Makefile.in | 1 + + 1 file changed, 1 insertion(+) + +Index: binutils-2.19.1/libiberty/Makefile.in +=================================================================== +--- binutils-2.19.1.orig/libiberty/Makefile.in ++++ binutils-2.19.1/libiberty/Makefile.in +@@ -227,6 +227,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA + $(AR) $(AR_FLAGS) $(TARGETLIB) \ + $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \ + $(RANLIB) $(TARGETLIB); \ ++ cp $(TARGETLIB) ../ ; \ + cd ..; \ + else true; fi + diff --git a/patches/binutils-2.19.1/generic/gentoo/no_63_all_binutils-2.18-pt-pax-flags-20070828.patch b/patches/binutils-2.19.1/generic/gentoo/no_63_all_binutils-2.18-pt-pax-flags-20070828.patch new file mode 100644 index 0000000..4c0c1a5 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/no_63_all_binutils-2.18-pt-pax-flags-20070828.patch @@ -0,0 +1,263 @@ +--- + bfd/elf-bfd.h | 3 +++ + bfd/elf.c | 27 ++++++++++++++++++++++++++- + bfd/elflink.c | 24 +++++++++++++++++++++--- + binutils/readelf.c | 1 + + include/bfdlink.h | 8 ++++++++ + include/elf/common.h | 16 ++++++++++++++++ + ld/emultempl/elf32.em | 12 ++++++++++++ + ld/ldgram.y | 2 ++ + 8 files changed, 89 insertions(+), 4 deletions(-) + +Index: binutils-2.18/bfd/elf-bfd.h +=================================================================== +--- binutils-2.18.orig/bfd/elf-bfd.h ++++ binutils-2.18/bfd/elf-bfd.h +@@ -1428,6 +1428,9 @@ struct elf_obj_tdata + /* Segment flags for the PT_GNU_STACK segment. */ + unsigned int stack_flags; + ++ /* Segment flags for the PT_PAX_FLAGS segment. */ ++ unsigned int pax_flags; ++ + /* Symbol version definitions in external objects. */ + Elf_Internal_Verdef *verdef; + +Index: binutils-2.18/bfd/elf.c +=================================================================== +--- binutils-2.18.orig/bfd/elf.c ++++ binutils-2.18/bfd/elf.c +@@ -1085,6 +1085,7 @@ get_segment_type (unsigned int p_type) + case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break; + case PT_GNU_STACK: pt = "STACK"; break; + case PT_GNU_RELRO: pt = "RELRO"; break; ++ case PT_PAX_FLAGS: pt = "PAX_FLAGS"; break; + default: pt = NULL; break; + } + return pt; +@@ -2361,6 +2362,9 @@ bfd_section_from_phdr (bfd *abfd, Elf_In + case PT_GNU_RELRO: + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "relro"); + ++ case PT_PAX_FLAGS: ++ return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "pax_flags"); ++ + default: + /* Check for any processor-specific program segment types. */ + bed = get_elf_backend_data (abfd); +@@ -3341,6 +3345,11 @@ get_program_header_size (bfd *abfd, stru + ++segs; + } + ++ { ++ /* We need a PT_PAX_FLAGS segment. */ ++ ++segs; ++ } ++ + for (s = abfd->sections; s != NULL; s = s->next) + { + if ((s->flags & SEC_LOAD) != 0 +@@ -3868,6 +3877,20 @@ _bfd_elf_map_sections_to_segments (bfd * + pm = &m->next; + } + ++ { ++ amt = sizeof (struct elf_segment_map); ++ m = bfd_zalloc (abfd, amt); ++ if (m == NULL) ++ goto error_return; ++ m->next = NULL; ++ m->p_type = PT_PAX_FLAGS; ++ m->p_flags = elf_tdata (abfd)->pax_flags; ++ m->p_flags_valid = 1; ++ ++ *pm = m; ++ pm = &m->next; ++ } ++ + free (sections); + elf_tdata (abfd)->segment_map = mfirst; + } +@@ -5043,7 +5066,8 @@ rewrite_elf_program_header (bfd *ibfd, b + 6. PT_TLS segment includes only SHF_TLS sections. + 7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments. + 8. PT_DYNAMIC should not contain empty sections at the beginning +- (with the possible exception of .dynamic). */ ++ (with the possible exception of .dynamic). ++ 9. PT_PAX_FLAGS segments does not include any sections. */ + #define IS_SECTION_IN_INPUT_SEGMENT(section, segment, bed) \ + ((((segment->p_paddr \ + ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \ +@@ -5051,6 +5075,7 @@ rewrite_elf_program_header (bfd *ibfd, b + && (section->flags & SEC_ALLOC) != 0) \ + || IS_COREFILE_NOTE (segment, section)) \ + && segment->p_type != PT_GNU_STACK \ ++ && segment->p_type != PT_PAX_FLAGS \ + && (segment->p_type != PT_TLS \ + || (section->flags & SEC_THREAD_LOCAL)) \ + && (segment->p_type == PT_LOAD \ +Index: binutils-2.18/bfd/elflink.c +=================================================================== +--- binutils-2.18.orig/bfd/elflink.c ++++ binutils-2.18/bfd/elflink.c +@@ -5327,16 +5327,30 @@ bfd_elf_size_dynamic_sections (bfd *outp + return TRUE; + + bed = get_elf_backend_data (output_bfd); ++ elf_tdata (output_bfd)->pax_flags = PF_NORANDEXEC; ++ ++ if (info->execheap) ++ elf_tdata (output_bfd)->pax_flags |= PF_NOMPROTECT; ++ else if (info->noexecheap) ++ elf_tdata (output_bfd)->pax_flags |= PF_MPROTECT; ++ + if (info->execstack) +- elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; ++ { ++ elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; ++ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP; ++ } + else if (info->noexecstack) +- elf_tdata (output_bfd)->stack_flags = PF_R | PF_W; ++ { ++ elf_tdata (output_bfd)->stack_flags = PF_R | PF_W; ++ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP; ++ } + else + { + bfd *inputobj; + asection *notesec = NULL; + int exec = 0; + ++ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP; + for (inputobj = info->input_bfds; + inputobj; + inputobj = inputobj->link_next) +@@ -5349,7 +5363,11 @@ bfd_elf_size_dynamic_sections (bfd *outp + if (s) + { + if (s->flags & SEC_CODE) +- exec = PF_X; ++ { ++ elf_tdata (output_bfd)->pax_flags &= ~PF_NOEMUTRAMP; ++ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP; ++ exec = PF_X; ++ } + notesec = s; + } + else if (bed->default_execstack) +Index: binutils-2.18/binutils/readelf.c +=================================================================== +--- binutils-2.18.orig/binutils/readelf.c ++++ binutils-2.18/binutils/readelf.c +@@ -2469,6 +2469,7 @@ get_segment_type (unsigned long p_type) + return "GNU_EH_FRAME"; + case PT_GNU_STACK: return "GNU_STACK"; + case PT_GNU_RELRO: return "GNU_RELRO"; ++ case PT_PAX_FLAGS: return "PAX_FLAGS"; + + default: + if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC)) +Index: binutils-2.18/include/bfdlink.h +=================================================================== +--- binutils-2.18.orig/include/bfdlink.h ++++ binutils-2.18/include/bfdlink.h +@@ -321,6 +321,14 @@ struct bfd_link_info + /* TRUE if PT_GNU_RELRO segment should be created. */ + unsigned int relro: 1; + ++ /* TRUE if PT_PAX_FLAGS segment should be created with PF_NOMPROTECT ++ flags. */ ++ unsigned int execheap: 1; ++ ++ /* TRUE if PT_PAX_FLAGS segment should be created with PF_MPROTECT ++ flags. */ ++ unsigned int noexecheap: 1; ++ + /* TRUE if we should warn when adding a DT_TEXTREL to a shared object. */ + unsigned int warn_shared_textrel: 1; + +Index: binutils-2.18/include/elf/common.h +=================================================================== +--- binutils-2.18.orig/include/elf/common.h ++++ binutils-2.18/include/elf/common.h +@@ -309,6 +309,7 @@ + #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME /* Solaris uses the same value */ + #define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */ + #define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */ ++#define PT_PAX_FLAGS (PT_LOOS + 0x5041580) /* PaX flags */ + + /* Program segment permissions, in program header p_flags field. */ + +@@ -319,6 +320,21 @@ + #define PF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */ + #define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */ + ++/* Flags to control PaX behavior. */ ++ ++#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */ ++#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */ ++#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */ ++#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */ ++#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */ ++#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */ ++#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */ ++#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */ ++#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */ ++#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */ ++#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */ ++#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */ ++ + /* Values for section header, sh_type field. */ + + #define SHT_NULL 0 /* Section header table entry unused */ +Index: binutils-2.18/ld/emultempl/elf32.em +=================================================================== +--- binutils-2.18.orig/ld/emultempl/elf32.em ++++ binutils-2.18/ld/emultempl/elf32.em +@@ -2136,6 +2136,16 @@ fragment <<EOF + link_info.noexecstack = TRUE; + link_info.execstack = FALSE; + } ++ else if (strcmp (optarg, "execheap") == 0) ++ { ++ link_info.execheap = TRUE; ++ link_info.noexecheap = FALSE; ++ } ++ else if (strcmp (optarg, "noexecheap") == 0) ++ { ++ link_info.noexecheap = TRUE; ++ link_info.execheap = FALSE; ++ } + EOF + + if test -n "$COMMONPAGESIZE"; then +@@ -2209,6 +2219,7 @@ fragment <<EOF + fprintf (file, _(" -z combreloc\t\tMerge dynamic relocs into one section and sort\n")); + fprintf (file, _(" -z defs\t\tReport unresolved symbols in object files.\n")); + fprintf (file, _(" -z execstack\t\tMark executable as requiring executable stack\n")); ++ fprintf (file, _(" -z execheap\t\tMark executable as requiring executable heap\n")); + fprintf (file, _(" -z initfirst\t\tMark DSO to be initialized first at runtime\n")); + fprintf (file, _(" -z interpose\t\tMark object to interpose all DSOs but executable\n")); + fprintf (file, _(" -z lazy\t\tMark object lazy runtime binding (default)\n")); +@@ -2221,6 +2232,7 @@ fragment <<EOF + fprintf (file, _(" -z nodlopen\t\tMark DSO not available to dlopen\n")); + fprintf (file, _(" -z nodump\t\tMark DSO not available to dldump\n")); + fprintf (file, _(" -z noexecstack\tMark executable as not requiring executable stack\n")); ++ fprintf (file, _(" -z noexecheap\tMark executable as not requiring executable heap\n")); + EOF + + if test -n "$COMMONPAGESIZE"; then +Index: binutils-2.18/ld/ldgram.y +=================================================================== +--- binutils-2.18.orig/ld/ldgram.y ++++ binutils-2.18/ld/ldgram.y +@@ -1099,6 +1099,8 @@ phdr_type: + $$ = exp_intop (0x6474e550); + else if (strcmp (s, "PT_GNU_STACK") == 0) + $$ = exp_intop (0x6474e551); ++ else if (strcmp (s, "PT_PAX_FLAGS") == 0) ++ $$ = exp_intop (0x65041580); + else + { + einfo (_("\ diff --git a/patches/binutils-2.19.1/generic/gentoo/no_76_all_use-new-ld-dtags.patch b/patches/binutils-2.19.1/generic/gentoo/no_76_all_use-new-ld-dtags.patch new file mode 100644 index 0000000..84e20f7 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/no_76_all_use-new-ld-dtags.patch @@ -0,0 +1,10 @@ +--- binutils/ld/ldmain.c ++++ binutils/ld/ldmain.c +@@ -296,6 +296,7 @@ main (int argc, char **argv) + + link_info.allow_undefined_version = TRUE; + link_info.keep_memory = TRUE; ++ link_info.new_dtags = TRUE; + link_info.combreloc = TRUE; + link_info.strip_discarded = TRUE; + link_info.callbacks = &link_callbacks; diff --git a/patches/binutils-2.19.1/generic/gentoo/no_77_all_generate-gnu-hash.patch b/patches/binutils-2.19.1/generic/gentoo/no_77_all_generate-gnu-hash.patch new file mode 100644 index 0000000..eb8da88 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/no_77_all_generate-gnu-hash.patch @@ -0,0 +1,6 @@ +--- binutils/ld/ldmain.c ++++ binutils/ld/ldmain.c +@@ -273,2 +273,3 @@ main (int argc, char **argv) + link_info.emit_hash = TRUE; ++ link_info.emit_gnu_hash = TRUE; + link_info.callbacks = &link_callbacks; diff --git a/patches/binutils-2.19.1/generic/gentoo/no_78_all_use-relro.patch b/patches/binutils-2.19.1/generic/gentoo/no_78_all_use-relro.patch new file mode 100644 index 0000000..abd5187 --- /dev/null +++ b/patches/binutils-2.19.1/generic/gentoo/no_78_all_use-relro.patch @@ -0,0 +1,6 @@ +--- binutils/ld/ldmain.c ++++ binutils/ld/ldmain.c +@@ -293,2 +293,3 @@ main (int argc, char **argv) + link_info.combreloc = TRUE; ++ link_info.relro = TRUE; + link_info.strip_discarded = TRUE; diff --git a/patches/binutils-2.19.1/generic/oe/binutils-2.16.91.0.6-objcopy-rename-errorcode.patch b/patches/binutils-2.19.1/generic/oe/binutils-2.16.91.0.6-objcopy-rename-errorcode.patch new file mode 100644 index 0000000..81f963b --- /dev/null +++ b/patches/binutils-2.19.1/generic/oe/binutils-2.16.91.0.6-objcopy-rename-errorcode.patch @@ -0,0 +1,39 @@ +# strip (and objcopy) fail to set the error code if there is no +# output file name and the rename of the stripped (or copied) file +# fails, yet the command fails to do anything. This fixes both +# objcopy and strip. +# +# modification by bero: Ported to 2.16.91.0.6 +# +#Signed-off-by: John Bowler <jbowler@acm.org> +#Signed-off-by: Bernhard Rosenkraenzer <bero@arklinux.org> +--- +# binutils/objcopy.c | 8 +++++--- +# 1 file changed, 5 insertions(+), 3 deletions(-) +# +Index: binutils-2.19.1/binutils/objcopy.c +=================================================================== +--- binutils-2.19.1.orig/binutils/objcopy.c ++++ binutils-2.19.1/binutils/objcopy.c +@@ -2857,8 +2857,9 @@ strip_main (int argc, char *argv[]) + if (preserve_dates) + set_times (tmpname, &statbuf); + if (output_file != tmpname) +- smart_rename (tmpname, output_file ? output_file : argv[i], +- preserve_dates); ++ if (smart_rename (tmpname, output_file ? output_file : argv[i], ++ preserve_dates)) ++ hold_status = 1; + status = hold_status; + } + else +@@ -3481,7 +3482,8 @@ copy_main (int argc, char *argv[]) + if (preserve_dates) + set_times (tmpname, &statbuf); + if (tmpname != output_filename) +- smart_rename (tmpname, input_filename, preserve_dates); ++ if (smart_rename (tmpname, input_filename, preserve_dates)) ++ status = 1; + } + else + unlink_if_ordinary (tmpname); diff --git a/patches/binutils-2.19.1/generic/series b/patches/binutils-2.19.1/generic/series new file mode 100644 index 0000000..d31c45b --- /dev/null +++ b/patches/binutils-2.19.1/generic/series @@ -0,0 +1,18 @@ +gentoo/03_all_binutils-2.15.92.0.2-ppc64-pie.patch +gentoo/07_all_binutils-2.18-windres.patch +gentoo/08_all_binutils-RPATH_ENVVAR-smack.patch +gentoo/09_all_binutils-ld-tests-CXXFLAGS.patch +gentoo/12_all_sh-targets.patch +gentoo/30_all_binutils-multitarget-fixup.patch +gentoo/42_all_012_check_ldrunpath_length.patch +gentoo/66_all_binutils-2.17.50.0.2-warn-textrel.patch +gentoo/76_all_only-use-new-ld-dtags.patch.disabled +gentoo/91_all_libiberty-pic.patch + +#gentoo/no_76_all_use-new-ld-dtags.patch +#gentoo/no_77_all_generate-gnu-hash.patch +#gentoo/no_78_all_use-relro.patch + +oe/binutils-2.16.91.0.6-objcopy-rename-errorcode.patch + +uclibc/110-arm-eabi-conf.patch diff --git a/patches/binutils-2.19.1/generic/uclibc/110-arm-eabi-conf.patch b/patches/binutils-2.19.1/generic/uclibc/110-arm-eabi-conf.patch new file mode 100644 index 0000000..9ce7898 --- /dev/null +++ b/patches/binutils-2.19.1/generic/uclibc/110-arm-eabi-conf.patch @@ -0,0 +1,31 @@ +--- + configure | 2 +- + configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +Index: binutils-2.19.1/configure +=================================================================== +--- binutils-2.19.1.orig/configure ++++ binutils-2.19.1/configure +@@ -2313,7 +2313,7 @@ case "${target}" in + noconfigdirs="$noconfigdirs target-libffi target-qthreads" + libgloss_dir=arm + ;; +- arm*-*-linux-gnueabi) ++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi) + noconfigdirs="$noconfigdirs target-qthreads" + case ${with_newlib} in + no) noconfigdirs="$noconfigdirs target-newlib target-libgloss" +Index: binutils-2.19.1/configure.ac +=================================================================== +--- binutils-2.19.1.orig/configure.ac ++++ binutils-2.19.1/configure.ac +@@ -562,7 +562,7 @@ case "${target}" in + noconfigdirs="$noconfigdirs target-libffi target-qthreads" + libgloss_dir=arm + ;; +- arm*-*-linux-gnueabi) ++ arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi) + noconfigdirs="$noconfigdirs target-qthreads" + case ${with_newlib} in + no) noconfigdirs="$noconfigdirs target-newlib target-libgloss" |