diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2003-03-03 20:00:35 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@redhat.com> | 2003-03-03 20:00:35 +0000 |
commit | e3f2db7fa69d2c1f4c7dbee442da6b262c706700 (patch) | |
tree | c1c9691a2ba1728c3b9dcaac761845c83524bd57 /ld | |
parent | 832a94844fffdf222dd6726c26d2678daf440202 (diff) | |
download | gdb-e3f2db7fa69d2c1f4c7dbee442da6b262c706700.zip gdb-e3f2db7fa69d2c1f4c7dbee442da6b262c706700.tar.gz gdb-e3f2db7fa69d2c1f4c7dbee442da6b262c706700.tar.bz2 |
* 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.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 17 | ||||
-rw-r--r-- | ld/ld.texinfo | 11 | ||||
-rw-r--r-- | ld/ldfile.c | 31 | ||||
-rw-r--r-- | ld/ldfile.h | 6 | ||||
-rw-r--r-- | ld/ldlang.c | 7 | ||||
-rw-r--r-- | ld/ldlang.h | 6 |
6 files changed, 68 insertions, 10 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 7db7e0a..fbb39f1 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,20 @@ +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, diff --git a/ld/ld.texinfo b/ld/ld.texinfo index d49c4f1..a23deef 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -2305,10 +2305,13 @@ then you can put @samp{INPUT (subr.o)} in your linker script. 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 diff --git a/ld/ldfile.c b/ld/ldfile.c index bc1fd87..84795e1 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -92,7 +92,12 @@ ldfile_add_library_path (name, cmdline) /* 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. */ @@ -265,8 +270,22 @@ ldfile_open_file_search (arch, entry, lib, suffix) 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; @@ -278,7 +297,10 @@ ldfile_open_file_search (arch, entry, lib, suffix) 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) @@ -306,6 +328,7 @@ ldfile_open_file_search (arch, entry, lib, suffix) if (ldfile_try_open_bfd (string, entry)) { entry->filename = string; + entry->sysrooted = search->sysrooted; return TRUE; } diff --git a/ld/ldfile.h b/ld/ldfile.h index 050a989..0bfea7c 100644 --- a/ld/ldfile.h +++ b/ld/ldfile.h @@ -1,12 +1,12 @@ /* 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, @@ -37,6 +37,8 @@ typedef struct search_dirs { 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; diff --git a/ld/ldlang.c b/ld/ldlang.c index 283b970..703779f 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -240,6 +240,7 @@ bfd_boolean lang_float_flag = FALSE; 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 */ @@ -547,6 +548,7 @@ new_afile (name, file_type, target, add_to_list) lang_has_input_file = TRUE; p->target = target; + p->sysrooted = FALSE; switch (file_type) { case lang_input_file_is_symbols_only_enum: @@ -582,6 +584,7 @@ new_afile (name, file_type, target, add_to_list) 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; @@ -1539,6 +1542,7 @@ load_symbols (entry, place) bfd_error_type err; lang_statement_list_type *hold; bfd_boolean bad_load = TRUE; + bfd_boolean save_ldlang_sysrooted_script; err = bfd_get_error (); @@ -1570,12 +1574,15 @@ load_symbols (entry, place) 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; diff --git a/ld/ldlang.h b/ld/ldlang.h index 7dd4efd..3c4936b 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -230,6 +230,12 @@ typedef struct lang_input_statement_struct { /* 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. */ |