1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/patches/binutils/2.20/170-warn-textrel.patch Tue Oct 27 20:06:46 2009 +0100
1.3 @@ -0,0 +1,59 @@
1.4 +textrels are bad for forcing copy-on-write (this affects everyone),
1.5 +and for security/runtime code generation, this affects security ppl.
1.6 +But in either case, it doesn't matter who needs textrels, it's
1.7 +the very fact that they're needed at all.
1.8 +
1.9 +2006-06-10 Ned Ludd <solar@gentoo.org>, Mike Frysinger <vapier@gentoo.org>
1.10 +
1.11 + * bfd/elflink.c (bfd_elf_final_link): Check all objects for TEXTRELs.
1.12 + * ld/ldmain.c (main): Change textrel warning default to true.
1.13 + * ld/testsuite/lib/ld-lib.exp (default_ld_simple_link): Scrub TEXTREL
1.14 + warnings from ld output.
1.15 +
1.16 +--- bfd/elflink.c
1.17 ++++ bfd/elflink.c
1.18 +@@ -8652,14 +8652,12 @@
1.19 + goto error_return;
1.20 +
1.21 + /* Check for DT_TEXTREL (late, in case the backend removes it). */
1.22 +- if (info->warn_shared_textrel && info->shared)
1.23 ++ o = bfd_get_section_by_name (dynobj, ".dynamic");
1.24 ++ if (info->warn_shared_textrel && o != NULL)
1.25 + {
1.26 + bfd_byte *dyncon, *dynconend;
1.27 +
1.28 + /* Fix up .dynamic entries. */
1.29 +- o = bfd_get_section_by_name (dynobj, ".dynamic");
1.30 +- BFD_ASSERT (o != NULL);
1.31 +-
1.32 + dyncon = o->contents;
1.33 + dynconend = o->contents + o->size;
1.34 + for (; dyncon < dynconend; dyncon += bed->s->sizeof_dyn)
1.35 +@@ -8702,7 +8702,7 @@ bfd_elf_final_link (bfd *abfd, struct bf
1.36 + if (dyn.d_tag == DT_TEXTREL)
1.37 + {
1.38 + info->callbacks->einfo
1.39 +- (_("%P: warning: creating a DT_TEXTREL in a shared object.\n"));
1.40 ++ (_("%P: warning: creating a DT_TEXTREL in object.\n"));
1.41 + break;
1.42 + }
1.43 + }
1.44 +--- ld/ldmain.c
1.45 ++++ ld/ldmain.c
1.46 +@@ -282,2 +282,3 @@ main (int argc, char **argv)
1.47 + link_info.spare_dynamic_tags = 5;
1.48 ++ link_info.warn_shared_textrel = TRUE;
1.49 + link_info.sharable_sections = FALSE;
1.50 +--- ld/testsuite/lib/ld-lib.exp
1.51 ++++ ld/testsuite/lib/ld-lib.exp
1.52 +@@ -181,6 +181,10 @@ proc default_ld_simple_link { ld target
1.53 + # symbol, since the default linker script might use ENTRY.
1.54 + regsub -all "(^|\n)(\[^\n\]*: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
1.55 +
1.56 ++ # Gentoo tweak:
1.57 ++ # We want to ignore TEXTREL warnings since we force enable them by default
1.58 ++ regsub -all "^lt-ld-new: warning: creating a DT_TEXTREL in object\." $exec_output "\\1" exec_output
1.59 ++
1.60 + if [string match "" $exec_output] then {
1.61 + return 1
1.62 + } else {