summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/binutils/binutils/binutils-poison.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/binutils/binutils/binutils-poison.patch')
-rw-r--r--meta/recipes-devtools/binutils/binutils/binutils-poison.patch259
1 files changed, 259 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils/binutils-poison.patch b/meta/recipes-devtools/binutils/binutils/binutils-poison.patch
new file mode 100644
index 0000000..996c023
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/binutils-poison.patch
@@ -0,0 +1,259 @@
1Upstream-Status: Inappropriate [distribution: codesourcery]
2
3Patch originally created by Mark Hatle, forward-ported to
4binutils 2.21 by Scott Garman.
5
6purpose: warn for uses of system directories when cross linking
7
8Code Merged from Sourcery G++ binutils 2.19 - 4.4-277
9
102008-07-02 Joseph Myers <joseph@codesourcery.com>
11
12 ld/
13 * ld.h (args_type): Add error_poison_system_directories.
14 * ld.texinfo (--error-poison-system-directories): Document.
15 * ldfile.c (ldfile_add_library_path): Check
16 command_line.error_poison_system_directories.
17 * ldmain.c (main): Initialize
18 command_line.error_poison_system_directories.
19 * lexsup.c (enum option_values): Add
20 OPTION_ERROR_POISON_SYSTEM_DIRECTORIES.
21 (ld_options): Add --error-poison-system-directories.
22 (parse_args): Handle new option.
23
242007-06-13 Joseph Myers <joseph@codesourcery.com>
25
26 ld/
27 * config.in: Regenerate.
28 * ld.h (args_type): Add poison_system_directories.
29 * ld.texinfo (--no-poison-system-directories): Document.
30 * ldfile.c (ldfile_add_library_path): Check
31 command_line.poison_system_directories.
32 * ldmain.c (main): Initialize
33 command_line.poison_system_directories.
34 * lexsup.c (enum option_values): Add
35 OPTION_NO_POISON_SYSTEM_DIRECTORIES.
36 (ld_options): Add --no-poison-system-directories.
37 (parse_args): Handle new option.
38
392007-04-20 Joseph Myers <joseph@codesourcery.com>
40
41 Merge from Sourcery G++ binutils 2.17:
42
43 2007-03-20 Joseph Myers <joseph@codesourcery.com>
44 Based on patch by Mark Hatle <mark.hatle@windriver.com>.
45 ld/
46 * configure.in (--enable-poison-system-directories): New option.
47 * configure, config.in: Regenerate.
48 * ldfile.c (ldfile_add_library_path): If
49 ENABLE_POISON_SYSTEM_DIRECTORIES defined, warn for use of /lib,
50 /usr/lib, /usr/local/lib or /usr/X11R6/lib.
51
52Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
53Signed-off-by: Scott Garman <scott.a.garman@intel.com>
54
55Index: binutils-2.24/ld/config.in
56===================================================================
57--- binutils-2.24.orig/ld/config.in 2013-12-15 11:46:17.000000000 -0800
58+++ binutils-2.24/ld/config.in 2013-12-15 11:46:59.810435651 -0800
59@@ -11,6 +11,9 @@
60 language is requested. */
61 #undef ENABLE_NLS
62
63+/* Define to warn for use of native system library directories */
64+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
65+
66 /* Additional extension a shared object might have. */
67 #undef EXTRA_SHLIB_EXTENSION
68
69Index: binutils-2.24/ld/configure
70===================================================================
71--- binutils-2.24.orig/ld/configure 2013-12-15 11:46:17.000000000 -0800
72+++ binutils-2.24/ld/configure 2013-12-15 11:46:59.810435651 -0800
73@@ -777,6 +777,7 @@
74 enable_targets
75 enable_64_bit_bfd
76 with_sysroot
77+enable_poison_system_directories
78 enable_gold
79 enable_got
80 enable_werror
81@@ -1433,6 +1434,8 @@
82 (and sometimes confusing) to the casual installer
83 --enable-targets alternative target configurations
84 --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)
85+ --enable-poison-system-directories
86+ warn for use of native system library directories
87 --enable-gold[=ARG] build gold [ARG={default,yes,no}]
88 --enable-got=<type> GOT handling scheme (target, single, negative,
89 multigot)
90@@ -4345,7 +4348,18 @@
91 fi
92
93
94+# Check whether --enable-poison-system-directories was given.
95+if test "${enable_poison_system_directories+set}" = set; then :
96+ enableval=$enable_poison_system_directories;
97+else
98+ enable_poison_system_directories=no
99+fi
100+
101+if test "x${enable_poison_system_directories}" = "xyes"; then
102
103+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
104+
105+fi
106
107 # Check whether --enable-got was given.
108 if test "${enable_got+set}" = set; then :
109Index: binutils-2.24/ld/configure.in
110===================================================================
111--- binutils-2.24.orig/ld/configure.in 2013-12-15 11:46:17.000000000 -0800
112+++ binutils-2.24/ld/configure.in 2013-12-15 11:46:59.810435651 -0800
113@@ -87,6 +87,16 @@
114 AC_SUBST(TARGET_SYSTEM_ROOT)
115 AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
116
117+AC_ARG_ENABLE([poison-system-directories],
118+ AS_HELP_STRING([--enable-poison-system-directories],
119+ [warn for use of native system library directories]),,
120+ [enable_poison_system_directories=no])
121+if test "x${enable_poison_system_directories}" = "xyes"; then
122+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
123+ [1],
124+ [Define to warn for use of native system library directories])
125+fi
126+
127 dnl Use --enable-gold to decide if this linker should be the default.
128 dnl "install_as_default" is set to false if gold is the default linker.
129 dnl "installed_linker" is the installed BFD linker name.
130Index: binutils-2.24/ld/ldfile.c
131===================================================================
132--- binutils-2.24.orig/ld/ldfile.c 2013-12-15 11:46:17.000000000 -0800
133+++ binutils-2.24/ld/ldfile.c 2013-12-15 11:46:59.813768989 -0800
134@@ -116,6 +116,23 @@
135 new_dirs->name = concat (ld_sysroot, name + 1, (const char *) NULL);
136 else
137 new_dirs->name = xstrdup (name);
138+
139+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
140+ if (command_line.poison_system_directories
141+ && ((!strncmp (name, "/lib", 4))
142+ || (!strncmp (name, "/usr/lib", 8))
143+ || (!strncmp (name, "/usr/local/lib", 14))
144+ || (!strncmp (name, "/usr/X11R6/lib", 14))))
145+ {
146+ if (command_line.error_poison_system_directories)
147+ einfo (_("%X%P: error: library search path \"%s\" is unsafe for "
148+ "cross-compilation\n"), name);
149+ else
150+ einfo (_("%P: warning: library search path \"%s\" is unsafe for "
151+ "cross-compilation\n"), name);
152+ }
153+#endif
154+
155 }
156
157 /* Try to open a BFD for a lang_input_statement. */
158Index: binutils-2.24/ld/ld.h
159===================================================================
160--- binutils-2.24.orig/ld/ld.h 2013-12-15 11:46:17.000000000 -0800
161+++ binutils-2.24/ld/ld.h 2013-12-15 11:46:59.813768989 -0800
162@@ -180,6 +180,14 @@
163 /* If TRUE we'll just print the default output on stdout. */
164 bfd_boolean print_output_format;
165
166+ /* If TRUE (the default) warn for uses of system directories when
167+ cross linking. */
168+ bfd_boolean poison_system_directories;
169+
170+ /* If TRUE (default FALSE) give an error for uses of system
171+ directories when cross linking instead of a warning. */
172+ bfd_boolean error_poison_system_directories;
173+
174 /* Big or little endian as set on command line. */
175 enum endian_enum endian;
176
177Index: binutils-2.24/ld/ldmain.c
178===================================================================
179--- binutils-2.24.orig/ld/ldmain.c 2013-12-15 11:46:17.000000000 -0800
180+++ binutils-2.24/ld/ldmain.c 2013-12-15 11:48:12.087101740 -0800
181@@ -266,6 +266,8 @@
182 command_line.warn_mismatch = TRUE;
183 command_line.warn_search_mismatch = TRUE;
184 command_line.check_section_addresses = -1;
185+ command_line.poison_system_directories = TRUE;
186+ command_line.error_poison_system_directories = FALSE;
187
188 /* We initialize DEMANGLING based on the environment variable
189 COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
190Index: binutils-2.24/ld/ld.texinfo
191===================================================================
192--- binutils-2.24.orig/ld/ld.texinfo 2013-12-15 11:46:17.000000000 -0800
193+++ binutils-2.24/ld/ld.texinfo 2013-12-15 11:46:59.813768989 -0800
194@@ -2175,6 +2175,18 @@
195
196 Passing @code{none} for @var{style} disables the setting from any
197 @code{--build-id} options earlier on the command line.
198+
199+@kindex --no-poison-system-directories
200+@item --no-poison-system-directories
201+Do not warn for @option{-L} options using system directories such as
202+@file{/usr/lib} when cross linking. This option is intended for use
203+in chroot environments when such directories contain the correct
204+libraries for the target system rather than the host.
205+
206+@kindex --error-poison-system-directories
207+@item --error-poison-system-directories
208+Give an error instead of a warning for @option{-L} options using
209+system directories when cross linking.
210 @end table
211
212 @c man end
213Index: binutils-2.24/ld/lexsup.c
214===================================================================
215--- binutils-2.24.orig/ld/lexsup.c 2013-12-15 11:46:17.000000000 -0800
216+++ binutils-2.24/ld/lexsup.c 2013-12-15 11:49:28.950434490 -0800
217@@ -507,6 +507,14 @@
218 OPTION_IGNORE_UNRESOLVED_SYMBOL},
219 '\0', N_("SYMBOL"),
220 N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES },
221+ { {"no-poison-system-directories", no_argument, NULL,
222+ OPTION_NO_POISON_SYSTEM_DIRECTORIES},
223+ '\0', NULL, N_("Do not warn for -L options using system directories"),
224+ TWO_DASHES },
225+ { {"error-poison-system-directories", no_argument, NULL,
226+ + OPTION_ERROR_POISON_SYSTEM_DIRECTORIES},
227+ '\0', NULL, N_("Give an error for -L options using system directories"),
228+ TWO_DASHES },
229 };
230
231 #define OPTION_COUNT ARRAY_SIZE (ld_options)
232@@ -1442,6 +1450,14 @@
233 einfo (_("%P%X: --hash-size needs a numeric argument\n"));
234 }
235 break;
236+
237+ case OPTION_NO_POISON_SYSTEM_DIRECTORIES:
238+ command_line.poison_system_directories = FALSE;
239+ break;
240+
241+ case OPTION_ERROR_POISON_SYSTEM_DIRECTORIES:
242+ command_line.error_poison_system_directories = TRUE;
243+ break;
244 }
245 }
246
247Index: binutils-2.24/ld/ldlex.h
248===================================================================
249--- binutils-2.24.orig/ld/ldlex.h 2013-12-15 11:46:17.000000000 -0800
250+++ binutils-2.24/ld/ldlex.h 2013-12-15 11:47:43.230435299 -0800
251@@ -138,6 +138,8 @@
252 OPTION_DEFAULT_SCRIPT,
253 OPTION_PRINT_OUTPUT_FORMAT,
254 OPTION_IGNORE_UNRESOLVED_SYMBOL,
255+ OPTION_NO_POISON_SYSTEM_DIRECTORIES,
256+ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES,
257 };
258
259 /* The initial parser states. */