Treat a prefix of "$SYSROOT" in the same way as "=" when parsing linker search paths.

PR ld/21251
	* ldfile.c (ldfile_add_library_path): If the path starts with
	$SYSROOT then use the sysroot as the real prefix.
	* ldlang.c (lang_add_input_file): Treat $SYSROOT in the same
	way as =.
	* ldlex.l: Add $SYSROOT as allow prefix for a filename.
	* ld.texinfo (-L): Document that $SYSROOT acts like = when
	prefixing a library search path.
	(INPUT): Likewise.
	* testsuite/ld-scripts/sysroot-prefix.exp: Add $SYSROOT prefix
	tests.
This commit is contained in:
Nick Clifton
2017-05-18 15:07:59 +01:00
parent 59cc050d89
commit 3aa2d05a72
6 changed files with 40 additions and 8 deletions

View File

@ -1138,11 +1138,14 @@ lang_add_input_file (const char *name,
lang_input_file_enum_type file_type,
const char *target)
{
if (name != NULL && *name == '=')
if (name != NULL
&& (*name == '=' || CONST_STRNEQ (name, "$SYSROOT")))
{
lang_input_statement_type *ret;
char *sysrooted_name
= concat (ld_sysroot, name + 1, (const char *) NULL);
= concat (ld_sysroot,
name + (*name == '=' ? 1 : strlen ("$SYSROOT")),
(const char *) NULL);
/* We've now forcibly prepended the sysroot, making the input
file independent of the context. Therefore, temporarily