summaryrefslogtreecommitdiffstats
path: root/recipes-devtools/binutils/binutils-linaro-2.25/binutils-poison.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-devtools/binutils/binutils-linaro-2.25/binutils-poison.patch')
-rw-r--r--recipes-devtools/binutils/binutils-linaro-2.25/binutils-poison.patch279
1 files changed, 279 insertions, 0 deletions
diff --git a/recipes-devtools/binutils/binutils-linaro-2.25/binutils-poison.patch b/recipes-devtools/binutils/binutils-linaro-2.25/binutils-poison.patch
new file mode 100644
index 0000000..814a4a3
--- /dev/null
+++ b/recipes-devtools/binutils/binutils-linaro-2.25/binutils-poison.patch
@@ -0,0 +1,279 @@
1From d5b58a44afcafd3c6ec1c9c69facbb2c17bc2b69 Mon Sep 17 00:00:00 2001
2From: Koen Kooi <koen.kooi@linaro.org>
3Date: Wed, 7 Jan 2015 09:46:35 +0100
4Subject: [PATCH] Warn for uses of system directories when cross linking
5
6Upstream-Status: Inappropriate [distribution: codesourcery]
7
8Patch originally created by Mark Hatle, forward-ported to
9binutils 2.21 by Scott Garman and forward ported to binutils 2.25 by Koen Kooi.
10
11purpose: warn for uses of system directories when cross linking
12
13Code Merged from Sourcery G++ binutils 2.19 - 4.4-277
14
152008-07-02 Joseph Myers <joseph@codesourcery.com>
16
17 ld/
18 * ld.h (args_type): Add error_poison_system_directories.
19 * ld.texinfo (--error-poison-system-directories): Document.
20 * ldfile.c (ldfile_add_library_path): Check
21 command_line.error_poison_system_directories.
22 * ldmain.c (main): Initialize
23 command_line.error_poison_system_directories.
24 * lexsup.c (enum option_values): Add
25 OPTION_ERROR_POISON_SYSTEM_DIRECTORIES.
26 (ld_options): Add --error-poison-system-directories.
27 (parse_args): Handle new option.
28
292007-06-13 Joseph Myers <joseph@codesourcery.com>
30
31 ld/
32 * config.in: Regenerate.
33 * ld.h (args_type): Add poison_system_directories.
34 * ld.texinfo (--no-poison-system-directories): Document.
35 * ldfile.c (ldfile_add_library_path): Check
36 command_line.poison_system_directories.
37 * ldmain.c (main): Initialize
38 command_line.poison_system_directories.
39 * lexsup.c (enum option_values): Add
40 OPTION_NO_POISON_SYSTEM_DIRECTORIES.
41 (ld_options): Add --no-poison-system-directories.
42 (parse_args): Handle new option.
43
442007-04-20 Joseph Myers <joseph@codesourcery.com>
45
46 Merge from Sourcery G++ binutils 2.17:
47
48 2007-03-20 Joseph Myers <joseph@codesourcery.com>
49 Based on patch by Mark Hatle <mark.hatle@windriver.com>.
50 ld/
51 * configure.in (--enable-poison-system-directories): New option.
52 * configure, config.in: Regenerate.
53 * ldfile.c (ldfile_add_library_path): If
54 ENABLE_POISON_SYSTEM_DIRECTORIES defined, warn for use of /lib,
55 /usr/lib, /usr/local/lib or /usr/X11R6/lib.
56
57Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
58Signed-off-by: Scott Garman <scott.a.garman@intel.com>
59Signed-off-by: Koen Kooi <koen.kooi@linaro.org>
60---
61 ld/config.in | 3 +++
62 ld/configure | 14 ++++++++++++++
63 ld/configure.ac | 10 ++++++++++
64 ld/ld.h | 8 ++++++++
65 ld/ld.texinfo | 12 ++++++++++++
66 ld/ldfile.c | 17 +++++++++++++++++
67 ld/ldlex.h | 2 ++
68 ld/ldmain.c | 2 ++
69 ld/lexsup.c | 16 ++++++++++++++++
70 9 files changed, 84 insertions(+)
71
72diff --git a/ld/config.in b/ld/config.in
73index 2ab4844..766d23c 100644
74--- a/ld/config.in
75+++ b/ld/config.in
76@@ -11,6 +11,9 @@
77 language is requested. */
78 #undef ENABLE_NLS
79
80+/* Define to warn for use of native system library directories */
81+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
82+
83 /* Additional extension a shared object might have. */
84 #undef EXTRA_SHLIB_EXTENSION
85
86diff --git a/ld/configure b/ld/configure
87index 4408b0d..c0dfa53 100755
88--- a/ld/configure
89+++ b/ld/configure
90@@ -783,6 +783,7 @@ with_lib_path
91 enable_targets
92 enable_64_bit_bfd
93 with_sysroot
94+enable_poison_system_directories
95 enable_gold
96 enable_got
97 enable_werror
98@@ -1439,6 +1440,8 @@ Optional Features:
99 --disable-largefile omit support for large files
100 --enable-targets alternative target configurations
101 --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)
102+ --enable-poison-system-directories
103+ warn for use of native system library directories
104 --enable-gold[=ARG] build gold [ARG={default,yes,no}]
105 --enable-got=<type> GOT handling scheme (target, single, negative,
106 multigot)
107@@ -15487,7 +15490,18 @@ else
108 fi
109
110
111+# Check whether --enable-poison-system-directories was given.
112+if test "${enable_poison_system_directories+set}" = set; then :
113+ enableval=$enable_poison_system_directories;
114+else
115+ enable_poison_system_directories=no
116+fi
117+
118+if test "x${enable_poison_system_directories}" = "xyes"; then
119
120+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
121+
122+fi
123
124 # Check whether --enable-got was given.
125 if test "${enable_got+set}" = set; then :
126diff --git a/ld/configure.ac b/ld/configure.ac
127index 1bddfc9..e9edb7f 100644
128--- a/ld/configure.ac
129+++ b/ld/configure.ac
130@@ -94,6 +94,16 @@ AC_SUBST(use_sysroot)
131 AC_SUBST(TARGET_SYSTEM_ROOT)
132 AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
133
134+AC_ARG_ENABLE([poison-system-directories],
135+ AS_HELP_STRING([--enable-poison-system-directories],
136+ [warn for use of native system library directories]),,
137+ [enable_poison_system_directories=no])
138+if test "x${enable_poison_system_directories}" = "xyes"; then
139+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
140+ [1],
141+ [Define to warn for use of native system library directories])
142+fi
143+
144 dnl Use --enable-gold to decide if this linker should be the default.
145 dnl "install_as_default" is set to false if gold is the default linker.
146 dnl "installed_linker" is the installed BFD linker name.
147diff --git a/ld/ld.h b/ld/ld.h
148index f773ce7..adba0f6 100644
149--- a/ld/ld.h
150+++ b/ld/ld.h
151@@ -161,6 +161,14 @@ typedef struct {
152 /* If TRUE we'll just print the default output on stdout. */
153 bfd_boolean print_output_format;
154
155+ /* If TRUE (the default) warn for uses of system directories when
156+ cross linking. */
157+ bfd_boolean poison_system_directories;
158+
159+ /* If TRUE (default FALSE) give an error for uses of system
160+ directories when cross linking instead of a warning. */
161+ bfd_boolean error_poison_system_directories;
162+
163 /* Big or little endian as set on command line. */
164 enum endian_enum endian;
165
166diff --git a/ld/ld.texinfo b/ld/ld.texinfo
167index 502582c..dae168a 100644
168--- a/ld/ld.texinfo
169+++ b/ld/ld.texinfo
170@@ -2212,6 +2212,18 @@ string identifying the original linked file does not change.
171
172 Passing @code{none} for @var{style} disables the setting from any
173 @code{--build-id} options earlier on the command line.
174+
175+@kindex --no-poison-system-directories
176+@item --no-poison-system-directories
177+Do not warn for @option{-L} options using system directories such as
178+@file{/usr/lib} when cross linking. This option is intended for use
179+in chroot environments when such directories contain the correct
180+libraries for the target system rather than the host.
181+
182+@kindex --error-poison-system-directories
183+@item --error-poison-system-directories
184+Give an error instead of a warning for @option{-L} options using
185+system directories when cross linking.
186 @end table
187
188 @c man end
189diff --git a/ld/ldfile.c b/ld/ldfile.c
190index 782ed7f..19a9ab4 100644
191--- a/ld/ldfile.c
192+++ b/ld/ldfile.c
193@@ -114,6 +114,23 @@ ldfile_add_library_path (const char *name, bfd_boolean cmdline)
194 new_dirs->name = concat (ld_sysroot, name + 1, (const char *) NULL);
195 else
196 new_dirs->name = xstrdup (name);
197+
198+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
199+ if (command_line.poison_system_directories
200+ && ((!strncmp (name, "/lib", 4))
201+ || (!strncmp (name, "/usr/lib", 8))
202+ || (!strncmp (name, "/usr/local/lib", 14))
203+ || (!strncmp (name, "/usr/X11R6/lib", 14))))
204+ {
205+ if (command_line.error_poison_system_directories)
206+ einfo (_("%X%P: error: library search path \"%s\" is unsafe for "
207+ "cross-compilation\n"), name);
208+ else
209+ einfo (_("%P: warning: library search path \"%s\" is unsafe for "
210+ "cross-compilation\n"), name);
211+ }
212+#endif
213+
214 }
215
216 /* Try to open a BFD for a lang_input_statement. */
217diff --git a/ld/ldlex.h b/ld/ldlex.h
218index e3e9b24..29487a3 100644
219--- a/ld/ldlex.h
220+++ b/ld/ldlex.h
221@@ -140,6 +140,8 @@ enum option_values
222 OPTION_IGNORE_UNRESOLVED_SYMBOL,
223 OPTION_PUSH_STATE,
224 OPTION_POP_STATE,
225+ OPTION_NO_POISON_SYSTEM_DIRECTORIES,
226+ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES,
227 };
228
229 /* The initial parser states. */
230diff --git a/ld/ldmain.c b/ld/ldmain.c
231index bc24957..396c4a0 100644
232--- a/ld/ldmain.c
233+++ b/ld/ldmain.c
234@@ -266,6 +266,8 @@ main (int argc, char **argv)
235 command_line.warn_mismatch = TRUE;
236 command_line.warn_search_mismatch = TRUE;
237 command_line.check_section_addresses = -1;
238+ command_line.poison_system_directories = TRUE;
239+ command_line.error_poison_system_directories = FALSE;
240
241 /* We initialize DEMANGLING based on the environment variable
242 COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
243diff --git a/ld/lexsup.c b/ld/lexsup.c
244index 4812c97..21b49df 100644
245--- a/ld/lexsup.c
246+++ b/ld/lexsup.c
247@@ -513,6 +513,14 @@ static const struct ld_option ld_options[] =
248 { {"pop-state", no_argument, NULL, OPTION_POP_STATE},
249 '\0', NULL, N_("Pop state of flags governing input file handling"),
250 TWO_DASHES },
251+ { {"no-poison-system-directories", no_argument, NULL,
252+ OPTION_NO_POISON_SYSTEM_DIRECTORIES},
253+ '\0', NULL, N_("Do not warn for -L options using system directories"),
254+ TWO_DASHES },
255+ { {"error-poison-system-directories", no_argument, NULL,
256+ + OPTION_ERROR_POISON_SYSTEM_DIRECTORIES},
257+ '\0', NULL, N_("Give an error for -L options using system directories"),
258+ TWO_DASHES },
259 };
260
261 #define OPTION_COUNT ARRAY_SIZE (ld_options)
262@@ -1474,6 +1482,14 @@ parse_args (unsigned argc, char **argv)
263 free (oldp);
264 }
265 break;
266+
267+ case OPTION_NO_POISON_SYSTEM_DIRECTORIES:
268+ command_line.poison_system_directories = FALSE;
269+ break;
270+
271+ case OPTION_ERROR_POISON_SYSTEM_DIRECTORIES:
272+ command_line.error_poison_system_directories = TRUE;
273+ break;
274 }
275 }
276
277--
2781.9.3
279