* ldlang.h (struct lang_input_statement_struct): Likewise.
* ldfile.c (ldfile_add_library_path): Mark sysrooted paths.
(ldfile_open_file_search): Look for sysrooted filename starting
with / in ld_sysroot instead of in the current directory. Clear
sysrooted flag if it's found in the current directory. Set it
from the search directory's sysrooted flag where it is found
otherwise.
* ldlang.c (ldlang_sysrooted_script): New static variable.
(new_afile): Mark search_file_enums as sysrooted if
ldlang_sysrooted_script.
(load_symbols): Set ldlang_sysrooted_script according to the
script's sysrooted field while processing it.
* ld.texinfo: Document INPUT behavior in sysroot.
+2003-03-03 Alexandre Oliva <aoliva@redhat.com>
+
+ * ldfile.h (struct search_dirs): Added sysrooted field.
+ * ldlang.h (struct lang_input_statement_struct): Likewise.
+ * ldfile.c (ldfile_add_library_path): Mark sysrooted paths.
+ (ldfile_open_file_search): Look for sysrooted filename starting
+ with / in ld_sysroot instead of in the current directory. Clear
+ sysrooted flag if it's found in the current directory. Set it
+ from the search directory's sysrooted flag where it is found
+ otherwise.
+ * ldlang.c (ldlang_sysrooted_script): New static variable.
+ (new_afile): Mark search_file_enums as sysrooted if
+ ldlang_sysrooted_script.
+ (load_symbols): Set ldlang_sysrooted_script according to the
+ script's sysrooted field while processing it.
+ * ld.texinfo: Document INPUT behavior in sysroot.
+
2003-03-02 Danny Smith <dannysmith@users.sourceforge.net>
* scripttempl/pe.sc: Use PROVIDE with etext, end, _end,
In fact, if you like, you can list all of your input files in the linker
script, and then invoke the linker with nothing but a @samp{-T} option.
-The linker will first try to open the file in the current directory. If
-it is not found, the linker will search through the archive library
-search path. See the description of @samp{-L} in @ref{Options,,Command
-Line Options}.
+In case a @dfn{sysroot prefix} is configured, and the filename starts
+with the @samp{/} character, and the script being processed was
+located inside the @dfn{sysroot prefix}, the filename will be looked
+for in the @dfn{sysroot prefix}. Otherwise, the linker will try to
+open the file in the current directory. If it is not found, the
+linker will search through the archive library search path. See the
+description of @samp{-L} in @ref{Options,,Command Line Options}.
If you use @samp{INPUT (-l@var{file})}, @command{ld} will transform the
name to @code{lib@var{file}.a}, as with the command line argument
/* If a directory is marked as honoring sysroot, prepend the sysroot path
now. */
if (new->name[0] == '=')
- new->name = concat (ld_sysroot, &new->name[1], NULL);
+ {
+ new->name = concat (ld_sysroot, &new->name[1], NULL);
+ new->sysrooted = TRUE;
+ }
+ else
+ new->sysrooted = FALSE;
}
/* Try to open a BFD for a lang_input_statement. */
directory first. */
if (! entry->is_archive)
{
- if (ldfile_try_open_bfd (entry->filename, entry))
- return TRUE;
+ if (entry->sysrooted && entry->filename[0] == '/')
+ {
+ char *name = concat (ld_sysroot, entry->filename,
+ (const char *) NULL);
+ if (ldfile_try_open_bfd (name, entry))
+ {
+ entry->filename = name;
+ return TRUE;
+ }
+ free (name);
+ }
+ else if (ldfile_try_open_bfd (entry->filename, entry))
+ {
+ entry->sysrooted = FALSE;
+ return TRUE;
+ }
}
for (search = search_head;
if (entry->dynamic && ! link_info.relocateable)
{
if (ldemul_open_dynamic_archive (arch, search, entry))
- return TRUE;
+ {
+ entry->sysrooted = search->sysrooted;
+ return TRUE;
+ }
}
string = (char *) xmalloc (strlen (search->name)
if (ldfile_try_open_bfd (string, entry))
{
entry->filename = string;
+ entry->sysrooted = search->sysrooted;
return TRUE;
}
/* ldfile.h -
- Copyright 1991, 1992, 1993, 1994, 1995, 2000, 2002
+ Copyright 1991, 1992, 1993, 1994, 1995, 2000, 2002, 2003
Free Software Foundation, Inc.
This file is part of GLD, the Gnu Linker.
GLD is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
GLD is distributed in the hope that it will be useful,
const char *name;
/* TRUE if this is from the command line. */
bfd_boolean cmdline;
+ /* true if this is from within the sys-root. */
+ bfd_boolean sysrooted;
} search_dirs_type;
extern search_dirs_type *search_head;
bfd_boolean delete_output_file_on_failure = FALSE;
struct lang_nocrossrefs *nocrossref_list;
struct unique_sections *unique_section_list;
+static bfd_boolean ldlang_sysrooted_script = FALSE;
etree_type *base; /* Relocation base - or null */
lang_has_input_file = TRUE;
p->target = target;
+ p->sysrooted = FALSE;
switch (file_type)
{
case lang_input_file_is_symbols_only_enum:
p->search_dirs_flag = TRUE;
break;
case lang_input_file_is_search_file_enum:
+ p->sysrooted = ldlang_sysrooted_script;
p->filename = name;
p->is_archive = FALSE;
p->real = TRUE;
bfd_error_type err;
lang_statement_list_type *hold;
bfd_boolean bad_load = TRUE;
+ bfd_boolean save_ldlang_sysrooted_script;
err = bfd_get_error ();
hold = stat_ptr;
stat_ptr = place;
+ save_ldlang_sysrooted_script = ldlang_sysrooted_script;
+ ldlang_sysrooted_script = entry->sysrooted;
ldfile_assumed_script = TRUE;
parser_input = input_script;
yyparse ();
ldfile_assumed_script = FALSE;
+ ldlang_sysrooted_script = save_ldlang_sysrooted_script;
stat_ptr = hold;
return ! bad_load;
/* 1 means search a set of directories for this file. */
bfd_boolean search_dirs_flag;
+ /* 1 means this was found in a search directory marked as sysrooted,
+ if search_dirs_flag is false, otherwise, that it should be
+ searched in ld_sysroot before any other location, as long as it
+ starts with a slash. */
+ bfd_boolean sysrooted;
+
/* 1 means this is base file of incremental load.
Do not load this file's text or data.
Also default text_start to after this file's bss. */