mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-09-22 13:42:55 +08:00
* ld.texinfo (-L): Mention that -L options do not affect how ld
searches for a linker script unless -T option is specified. * ldfile.c (ldfile_find_command_file): Append the path obtained from the program name to the search path instead of prepending. Add a new parameter "default_only". Restrict the search to the default script location if the new parameter is true. (ldfile_open_command_file_1): New. (ldfile_open_command_file): Call ldfile_open_command_file_1. (ldfile_open_default_command_file): New.
This commit is contained in:
13
ld/ChangeLog
13
ld/ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
2009-04-06 Kazu Hirata <kazu@codesourcery.com>
|
||||||
|
|
||||||
|
* ld.texinfo (-L): Mention that -L options do not affect how ld
|
||||||
|
searches for a linker script unless -T option is specified.
|
||||||
|
* ldfile.c (ldfile_find_command_file): Append the path obtained
|
||||||
|
from the program name to the search path instead of
|
||||||
|
prepending. Add a new parameter "default_only". Restrict the
|
||||||
|
search to the default script location if the new parameter is
|
||||||
|
true.
|
||||||
|
(ldfile_open_command_file_1): New.
|
||||||
|
(ldfile_open_command_file): Call ldfile_open_command_file_1.
|
||||||
|
(ldfile_open_default_command_file): New.
|
||||||
|
|
||||||
2009-04-03 Nathan Sidwell <nathan@codesourcery.com>
|
2009-04-03 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
* ldlang.c (lang_leave_output_section_statement): Set lma_region
|
* ldlang.c (lang_leave_output_section_statement): Set lma_region
|
||||||
|
@ -673,7 +673,9 @@ option any number of times. The directories are searched in the order
|
|||||||
in which they are specified on the command line. Directories specified
|
in which they are specified on the command line. Directories specified
|
||||||
on the command line are searched before the default directories. All
|
on the command line are searched before the default directories. All
|
||||||
@option{-L} options apply to all @option{-l} options, regardless of the
|
@option{-L} options apply to all @option{-l} options, regardless of the
|
||||||
order in which the options appear.
|
order in which the options appear. @option{-L} options do not affect
|
||||||
|
how @command{ld} searches for a linker script unless @option{-T}
|
||||||
|
option is specified.
|
||||||
|
|
||||||
If @var{searchdir} begins with @code{=}, then the @code{=} will be replaced
|
If @var{searchdir} begins with @code{=}, then the @code{=} will be replaced
|
||||||
by the @dfn{sysroot prefix}, a path specified when the linker is configured.
|
by the @dfn{sysroot prefix}, a path specified when the linker is configured.
|
||||||
|
64
ld/ldfile.c
64
ld/ldfile.c
@ -542,22 +542,27 @@ find_scripts_dir (void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to open NAME; if that fails, look for it in the default script
|
/* If DEFAULT_ONLY is false, try to open NAME; if that fails, look for
|
||||||
directory, then in any directories specified with -L, without and
|
it in directories specified with -L, then in the default script
|
||||||
with EXTEND appended. */
|
directory, without and with EXTEND appended. If DEFAULT_ONLY is
|
||||||
|
true, the search is restricted to the default script location. */
|
||||||
|
|
||||||
static FILE *
|
static FILE *
|
||||||
ldfile_find_command_file (const char *name, const char *extend)
|
ldfile_find_command_file (const char *name, const char *extend,
|
||||||
|
bfd_boolean default_only)
|
||||||
{
|
{
|
||||||
search_dirs_type *search;
|
search_dirs_type *search;
|
||||||
FILE *result;
|
FILE *result;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
static search_dirs_type *script_search;
|
static search_dirs_type *script_search;
|
||||||
|
|
||||||
/* First try raw name. */
|
if (!default_only)
|
||||||
result = try_open (name, "");
|
{
|
||||||
if (result != NULL)
|
/* First try raw name. */
|
||||||
return result;
|
result = try_open (name, "");
|
||||||
|
if (result != NULL)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (!script_search)
|
if (!script_search)
|
||||||
{
|
{
|
||||||
@ -569,16 +574,17 @@ ldfile_find_command_file (const char *name, const char *extend)
|
|||||||
ldfile_add_library_path (script_dir, TRUE);
|
ldfile_add_library_path (script_dir, TRUE);
|
||||||
search_tail_ptr = save_tail_ptr;
|
search_tail_ptr = save_tail_ptr;
|
||||||
}
|
}
|
||||||
if (!script_search)
|
|
||||||
script_search = search_head;
|
|
||||||
else
|
|
||||||
script_search->next = search_head;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try now prefixes. */
|
/* Temporarily append script_search to the path list so that the
|
||||||
for (search = script_search; search != NULL; search = search->next)
|
paths specified with -L will be searched first. */
|
||||||
{
|
*search_tail_ptr = script_search;
|
||||||
|
|
||||||
|
/* Try now prefixes. */
|
||||||
|
for (search = default_only ? script_search : search_head;
|
||||||
|
search != NULL;
|
||||||
|
search = search->next)
|
||||||
|
{
|
||||||
buffer = concat (search->name, slash, name, (const char *) NULL);
|
buffer = concat (search->name, slash, name, (const char *) NULL);
|
||||||
result = try_open (buffer, extend);
|
result = try_open (buffer, extend);
|
||||||
free (buffer);
|
free (buffer);
|
||||||
@ -586,14 +592,19 @@ ldfile_find_command_file (const char *name, const char *extend)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Restore the original path list. */
|
||||||
|
*search_tail_ptr = NULL;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* Open command file NAME. */
|
||||||
ldfile_open_command_file (const char *name)
|
|
||||||
|
static void
|
||||||
|
ldfile_open_command_file_1 (const char *name, bfd_boolean default_only)
|
||||||
{
|
{
|
||||||
FILE *ldlex_input_stack;
|
FILE *ldlex_input_stack;
|
||||||
ldlex_input_stack = ldfile_find_command_file (name, "");
|
ldlex_input_stack = ldfile_find_command_file (name, "", default_only);
|
||||||
|
|
||||||
if (ldlex_input_stack == NULL)
|
if (ldlex_input_stack == NULL)
|
||||||
{
|
{
|
||||||
@ -609,6 +620,23 @@ ldfile_open_command_file (const char *name)
|
|||||||
saved_script_handle = ldlex_input_stack;
|
saved_script_handle = ldlex_input_stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Open command file NAME in the current directory, -L directories,
|
||||||
|
the default script location, in that order. */
|
||||||
|
|
||||||
|
void
|
||||||
|
ldfile_open_command_file (const char *name)
|
||||||
|
{
|
||||||
|
ldfile_open_command_file_1 (name, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open command file NAME at the default script location. */
|
||||||
|
|
||||||
|
void
|
||||||
|
ldfile_open_default_command_file (const char *name)
|
||||||
|
{
|
||||||
|
ldfile_open_command_file_1 (name, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ldfile_add_arch (const char *in_name)
|
ldfile_add_arch (const char *in_name)
|
||||||
{
|
{
|
||||||
|
@ -50,6 +50,8 @@ extern void ldfile_add_library_path
|
|||||||
(const char *, bfd_boolean cmdline);
|
(const char *, bfd_boolean cmdline);
|
||||||
extern void ldfile_open_command_file
|
extern void ldfile_open_command_file
|
||||||
(const char *name);
|
(const char *name);
|
||||||
|
extern void ldfile_open_default_command_file
|
||||||
|
(const char *name);
|
||||||
extern void ldfile_open_file
|
extern void ldfile_open_file
|
||||||
(struct lang_input_statement_struct *);
|
(struct lang_input_statement_struct *);
|
||||||
extern bfd_boolean ldfile_try_open_bfd
|
extern bfd_boolean ldfile_try_open_bfd
|
||||||
|
@ -376,7 +376,7 @@ main (int argc, char **argv)
|
|||||||
char *s = ldemul_get_script (&isfile);
|
char *s = ldemul_get_script (&isfile);
|
||||||
|
|
||||||
if (isfile)
|
if (isfile)
|
||||||
ldfile_open_command_file (s);
|
ldfile_open_default_command_file (s);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lex_string = s;
|
lex_string = s;
|
||||||
|
Reference in New Issue
Block a user