summaryrefslogtreecommitdiffstats
path: root/patches
diff options
context:
space:
mode:
authorRobert Schwebel <r.schwebel@pengutronix.de>2010-08-21 22:27:41 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2011-02-22 11:26:06 +0100
commitd87c37012d9bb33649bcaebd1cf8eeee784cc46b (patch)
tree4bf1a46fcf08621d76688ac720c961a48964b1e9 /patches
parentc453882ee4c97746814d10410062cec0476244bb (diff)
downloadOSELAS.Toolchain-d87c37012d9bb33649bcaebd1cf8eeee784cc46b.tar.gz
OSELAS.Toolchain-d87c37012d9bb33649bcaebd1cf8eeee784cc46b.tar.xz
[binutils] add patches to 2.21
Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
Diffstat (limited to 'patches')
-rw-r--r--patches/binutils-2.21/gentoo/08_all_binutils-RPATH_ENVVAR-smack.patch19
-rw-r--r--patches/binutils-2.21/gentoo/30_all_binutils-multitarget-fixup.patch234
-rw-r--r--patches/binutils-2.21/gentoo/33_all_binutils-gnu-relro-fixups.patch109
-rw-r--r--patches/binutils-2.21/gentoo/42_all_012_check_ldrunpath_length.patch61
-rw-r--r--patches/binutils-2.21/gentoo/66_all_binutils-2.17.50.0.2-warn-textrel.patch75
-rw-r--r--patches/binutils-2.21/gentoo/76_all_only-use-new-ld-dtags.patch.disabled31
-rw-r--r--patches/binutils-2.21/gentoo/91_all_libiberty-pic.patch16
-rw-r--r--patches/binutils-2.21/gentoo/no_63_all_binutils-2.18-pt-pax-flags-20070828.patch263
-rw-r--r--patches/binutils-2.21/gentoo/no_76_all_use-new-ld-dtags.patch10
-rw-r--r--patches/binutils-2.21/gentoo/no_77_all_generate-gnu-hash.patch6
-rw-r--r--patches/binutils-2.21/gentoo/no_78_all_use-relro.patch6
-rw-r--r--patches/binutils-2.21/oe/binutils-2.16.91.0.6-objcopy-rename-errorcode.patch39
-rw-r--r--patches/binutils-2.21/series8
13 files changed, 877 insertions, 0 deletions
diff --git a/patches/binutils-2.21/gentoo/08_all_binutils-RPATH_ENVVAR-smack.patch b/patches/binutils-2.21/gentoo/08_all_binutils-RPATH_ENVVAR-smack.patch
new file mode 100644
index 0000000..63b1c2e
--- /dev/null
+++ b/patches/binutils-2.21/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.21/configure
+===================================================================
+--- binutils-2.21.orig/configure
++++ binutils-2.21/configure
+@@ -5530,6 +5530,7 @@ case $with_host_libstdcxx in
+ as_fn_error "-with-host-libstdcxx needs an argument" "$LINENO" 5
+ ;;
+ esac
++RPATH_ENVVAR="cant_touch_this_nah_nah_nah"
+
+ # Linker flags to use for stage1 or when not boostrapping.
+
diff --git a/patches/binutils-2.21/gentoo/30_all_binutils-multitarget-fixup.patch b/patches/binutils-2.21/gentoo/30_all_binutils-multitarget-fixup.patch
new file mode 100644
index 0000000..ff815e1
--- /dev/null
+++ b/patches/binutils-2.21/gentoo/30_all_binutils-multitarget-fixup.patch
@@ -0,0 +1,234 @@
+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 | 112 ++++++++++++++++++-----------------------------------------
+ 1 file changed, 35 insertions(+), 77 deletions(-)
+
+Index: binutils-2.18/bfd/format.c
+===================================================================
+--- binutils-2.18.orig/bfd/format.c
++++ binutils-2.18/bfd/format.c
+@@ -125,6 +125,9 @@ bfd_check_format_matches (bfd *abfd, bfd
+ int match_count;
+ int ar_match_index;
+
++ if (matching != NULL)
++ *matching = NULL;
++
+ if (!bfd_read_p (abfd)
+ || (unsigned int) abfd->format >= (unsigned int) bfd_type_end)
+ {
+@@ -141,11 +144,10 @@ bfd_check_format_matches (bfd *abfd, bfd
+ match_count = 0;
+ ar_match_index = _bfd_target_vector_entries;
+
+- if (matching)
++ if (matching != NULL || *bfd_associated_vector != NULL)
+ {
+ bfd_size_type amt;
+
+- *matching = NULL;
+ amt = sizeof (*matching_vector) * 2 * _bfd_target_vector_entries;
+ matching_vector = bfd_malloc (amt);
+ if (!matching_vector)
+@@ -162,31 +164,12 @@ bfd_check_format_matches (bfd *abfd, bfd
+ if (!abfd->target_defaulted)
+ {
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) /* rewind! */
+- {
+- if (matching)
+- free (matching_vector);
+- return FALSE;
+- }
++ goto err_ret;
+
+ right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
+
+ if (right_targ)
+- {
+- abfd->xvec = right_targ; /* Set the target as returned. */
+-
+- if (matching)
+- free (matching_vector);
+-
+- /* If the file was opened for update, then `output_has_begun'
+- some time ago when the file was created. Do not recompute
+- sections sizes or alignments in _bfd_set_section_contents.
+- We can not set this flag until after checking the format,
+- because it will interfere with creation of BFD sections. */
+- if (abfd->direction == both_direction)
+- abfd->output_has_begun = TRUE;
+-
+- return TRUE; /* File position has moved, BTW. */
+- }
++ goto ok_ret;
+
+ /* For a long time the code has dropped through to check all
+ targets if the specified target was wrong. I don't know why,
+@@ -201,17 +184,7 @@ bfd_check_format_matches (bfd *abfd, bfd
+ this sort, I changed this test to check only for the binary
+ target. */
+ if (format == bfd_archive && save_targ == &binary_vec)
+- {
+- abfd->xvec = save_targ;
+- abfd->format = bfd_unknown;
+-
+- if (matching)
+- free (matching_vector);
+-
+- bfd_set_error (bfd_error_file_not_recognized);
+-
+- return FALSE;
+- }
++ goto err_unrecog;
+ }
+
+ for (target = bfd_target_vector; *target != NULL; target++)
+@@ -227,11 +200,7 @@ bfd_check_format_matches (bfd *abfd, bfd
+ abfd->xvec = *target; /* Change BFD's target temporarily. */
+
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+- {
+- if (matching)
+- free (matching_vector);
+- return FALSE;
+- }
++ goto err_ret;
+
+ /* If _bfd_check_format neglects to set bfd_error, assume
+ bfd_error_wrong_format. We didn't used to even pay any
+@@ -255,9 +224,8 @@ bfd_check_format_matches (bfd *abfd, bfd
+ break;
+ }
+
+- if (matching)
++ if (matching_vector)
+ matching_vector[match_count] = temp;
+-
+ match_count++;
+ }
+ else if ((err = bfd_get_error ()) == bfd_error_wrong_object_format
+@@ -268,20 +236,12 @@ bfd_check_format_matches (bfd *abfd, bfd
+ no better matches. */
+ if (ar_right_targ != bfd_default_vector[0])
+ ar_right_targ = *target;
+- if (matching)
++ if (matching_vector)
+ matching_vector[ar_match_index] = *target;
+ ar_match_index++;
+ }
+ else if (err != bfd_error_wrong_format)
+- {
+- abfd->xvec = save_targ;
+- abfd->format = bfd_unknown;
+-
+- if (matching)
+- free (matching_vector);
+-
+- return FALSE;
+- }
++ goto err_ret;
+ }
+
+ if (match_count == 0)
+@@ -297,16 +257,14 @@ bfd_check_format_matches (bfd *abfd, bfd
+ {
+ match_count = ar_match_index - _bfd_target_vector_entries;
+
+- if (matching && match_count > 1)
++ if (matching_vector && match_count > 1)
+ memcpy (matching_vector,
+ matching_vector + _bfd_target_vector_entries,
+ sizeof (*matching_vector) * match_count);
+ }
+ }
+
+- if (match_count > 1
+- && bfd_associated_vector != NULL
+- && matching)
++ if (match_count > 1)
+ {
+ const bfd_target * const *assoc = bfd_associated_vector;
+
+@@ -328,11 +286,9 @@ bfd_check_format_matches (bfd *abfd, bfd
+
+ if (match_count == 1)
+ {
++ ok_ret:
+ abfd->xvec = right_targ; /* Change BFD's target permanently. */
+
+- if (matching)
+- free (matching_vector);
+-
+ /* If the file was opened for update, then `output_has_begun'
+ some time ago when the file was created. Do not recompute
+ sections sizes or alignments in _bfd_set_section_contents.
+@@ -341,37 +297,39 @@ bfd_check_format_matches (bfd *abfd, bfd
+ if (abfd->direction == both_direction)
+ abfd->output_has_begun = TRUE;
+
++ if (matching_vector)
++ free (matching_vector);
+ return TRUE; /* File position has moved, BTW. */
+ }
+
+- abfd->xvec = save_targ; /* Restore original target type. */
+- abfd->format = bfd_unknown; /* Restore original format. */
+-
+ if (match_count == 0)
+ {
++ err_unrecog:
+ bfd_set_error (bfd_error_file_not_recognized);
+-
+- if (matching)
++ err_ret:
++ abfd->xvec = save_targ;
++ abfd->format = bfd_unknown;
++ if (matching_vector)
+ free (matching_vector);
++ return FALSE;
+ }
+- else
+- {
+- bfd_set_error (bfd_error_file_ambiguously_recognized);
+
+- if (matching)
++ abfd->xvec = save_targ; /* Restore original target type. */
++ abfd->format = bfd_unknown; /* Restore original format. */
++ bfd_set_error (bfd_error_file_ambiguously_recognized);
++
++ if (matching)
++ {
++ *matching = (char **) matching_vector;
++ matching_vector[match_count] = NULL;
++ /* Return target names. This is a little nasty. Maybe we
++ should do another bfd_malloc? */
++ while (--match_count >= 0)
+ {
+- *matching = (char **) matching_vector;
+- matching_vector[match_count] = NULL;
+- /* Return target names. This is a little nasty. Maybe we
+- should do another bfd_malloc? */
+- while (--match_count >= 0)
+- {
+- const char *name = matching_vector[match_count]->name;
+- *(const char **) &matching_vector[match_count] = name;
+- }
++ const char *name = matching_vector[match_count]->name;
++ *(const char **) &matching_vector[match_count] = name;
+ }
+ }
+-
+ return FALSE;
+ }
+
diff --git a/patches/binutils-2.21/gentoo/33_all_binutils-gnu-relro-fixups.patch b/patches/binutils-2.21/gentoo/33_all_binutils-gnu-relro-fixups.patch
new file mode 100644
index 0000000..b734cfd
--- /dev/null
+++ b/patches/binutils-2.21/gentoo/33_all_binutils-gnu-relro-fixups.patch
@@ -0,0 +1,109 @@
+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.c | 11 +++++++++++
+ ld/ldexp.h | 2 ++
+ 2 files changed, 13 insertions(+)
+
+Index: binutils-2.20.1/bfd/elf.c
+===================================================================
+--- binutils-2.20.1.orig/bfd/elf.c
++++ binutils-2.20.1/bfd/elf.c
+@@ -5398,6 +5398,17 @@ rewrite_elf_program_header (bfd *ibfd, b
+ map->p_paddr_valid = p_paddr_valid;
+ }
+
++ 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.20.1/ld/ldexp.h
+===================================================================
+--- binutils-2.20.1.orig/ld/ldexp.h
++++ binutils-2.20.1/ld/ldexp.h
+@@ -117,6 +117,8 @@ enum relro_enum {
+ exp_dataseg_relro_end,
+ };
+
++union lang_statement_union;
++
+ struct ldexp_control {
+ /* Modify expression evaluation depending on this. */
+ lang_phase_type phase;
diff --git a/patches/binutils-2.21/gentoo/42_all_012_check_ldrunpath_length.patch b/patches/binutils-2.21/gentoo/42_all_012_check_ldrunpath_length.patch
new file mode 100644
index 0000000..b8c8eb6
--- /dev/null
+++ b/patches/binutils-2.21/gentoo/42_all_012_check_ldrunpath_length.patch
@@ -0,0 +1,61 @@
+Subject: Only generate an RPATH if LD_RUN_PATH is not empty
+
+This is http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=151024.
+
+FIXME: Is this patch still necessary?
+
+---
+
+#!/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.21/ld/emultempl/elf32.em
+===================================================================
+--- binutils-2.21.orig/ld/emultempl/elf32.em
++++ binutils-2.21/ld/emultempl/elf32.em
+@@ -1270,6 +1270,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;
+@@ -1497,6 +1499,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;
+
+ for (abfd = link_info.input_bfds; abfd; abfd = abfd->link_next)
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
diff --git a/patches/binutils-2.21/gentoo/66_all_binutils-2.17.50.0.2-warn-textrel.patch b/patches/binutils-2.21/gentoo/66_all_binutils-2.17.50.0.2-warn-textrel.patch
new file mode 100644
index 0000000..ffda581
--- /dev/null
+++ b/patches/binutils-2.21/gentoo/66_all_binutils-2.17.50.0.2-warn-textrel.patch
@@ -0,0 +1,75 @@
+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 | 8 +++-----
+ ld/ldmain.c | 1 +
+ ld/testsuite/lib/ld-lib.exp | 4 ++++
+ 3 files changed, 8 insertions(+), 5 deletions(-)
+
+Index: binutils-2.21/bfd/elflink.c
+===================================================================
+--- binutils-2.21.orig/bfd/elflink.c
++++ binutils-2.21/bfd/elflink.c
+@@ -11080,14 +11080,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)
+@@ -11099,7 +11097,7 @@ bfd_elf_final_link (bfd *abfd, struct bf
+ if (dyn.d_tag == DT_TEXTREL)
+ {
+ info->callbacks->einfo
+- (_("%P: warning: creating a DT_TEXTREL in a shared object.\n"));
++ (_("%P: warning: creating a DT_TEXTREL in object.\n"));
+ break;
+ }
+ }
+Index: binutils-2.21/ld/ldmain.c
+===================================================================
+--- binutils-2.21.orig/ld/ldmain.c
++++ binutils-2.21/ld/ldmain.c
+@@ -287,6 +287,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;
+ config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
+ config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
+ lang_init ();
+Index: binutils-2.21/ld/testsuite/lib/ld-lib.exp
+===================================================================
+--- binutils-2.21.orig/ld/testsuite/lib/ld-lib.exp
++++ binutils-2.21/ld/testsuite/lib/ld-lib.exp
+@@ -199,6 +199,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.21/gentoo/76_all_only-use-new-ld-dtags.patch.disabled b/patches/binutils-2.21/gentoo/76_all_only-use-new-ld-dtags.patch.disabled
new file mode 100644
index 0000000..2560463
--- /dev/null
+++ b/patches/binutils-2.21/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.21/bfd/elflink.c
+===================================================================
+--- binutils-2.21.orig/bfd/elflink.c
++++ binutils-2.21/bfd/elflink.c
+@@ -5629,11 +5629,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.21/gentoo/91_all_libiberty-pic.patch b/patches/binutils-2.21/gentoo/91_all_libiberty-pic.patch
new file mode 100644
index 0000000..f3ab4f1
--- /dev/null
+++ b/patches/binutils-2.21/gentoo/91_all_libiberty-pic.patch
@@ -0,0 +1,16 @@
+---
+ libiberty/Makefile.in | 1 +
+ 1 file changed, 1 insertion(+)
+
+Index: binutils-2.21/libiberty/Makefile.in
+===================================================================
+--- binutils-2.21.orig/libiberty/Makefile.in
++++ binutils-2.21/libiberty/Makefile.in
+@@ -246,6 +246,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.21/gentoo/no_63_all_binutils-2.18-pt-pax-flags-20070828.patch b/patches/binutils-2.21/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.21/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.21/gentoo/no_76_all_use-new-ld-dtags.patch b/patches/binutils-2.21/gentoo/no_76_all_use-new-ld-dtags.patch
new file mode 100644
index 0000000..84e20f7
--- /dev/null
+++ b/patches/binutils-2.21/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.21/gentoo/no_77_all_generate-gnu-hash.patch b/patches/binutils-2.21/gentoo/no_77_all_generate-gnu-hash.patch
new file mode 100644
index 0000000..eb8da88
--- /dev/null
+++ b/patches/binutils-2.21/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.21/gentoo/no_78_all_use-relro.patch b/patches/binutils-2.21/gentoo/no_78_all_use-relro.patch
new file mode 100644
index 0000000..abd5187
--- /dev/null
+++ b/patches/binutils-2.21/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.21/oe/binutils-2.16.91.0.6-objcopy-rename-errorcode.patch b/patches/binutils-2.21/oe/binutils-2.16.91.0.6-objcopy-rename-errorcode.patch
new file mode 100644
index 0000000..1485bf4
--- /dev/null
+++ b/patches/binutils-2.21/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.18/binutils/objcopy.c
+===================================================================
+--- binutils-2.18.orig/binutils/objcopy.c
++++ binutils-2.18/binutils/objcopy.c
+@@ -2787,8 +2787,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
+@@ -3411,7 +3412,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.21/series b/patches/binutils-2.21/series
new file mode 100644
index 0000000..dd28bfc
--- /dev/null
+++ b/patches/binutils-2.21/series
@@ -0,0 +1,8 @@
+# fragwürdig
+gentoo/08_all_binutils-RPATH_ENVVAR-smack.patch
+# still necessary?
+gentoo/42_all_012_check_ldrunpath_length.patch
+# ok
+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