This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld input file and INPUT command - file location problem
- From: Nick Clifton <nickc at redhat dot com>
- To: "Galit Heller" <Galit dot Heller at nsc dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 30 Oct 2003 13:33:14 +0000
- Subject: Re: ld input file and INPUT command - file location problem
- References: <3F9BA45B.4AC81F2C@nsc.com>
Hi Galit,
> When a library file is the argument to INPUT command, the archive
> library search path is searched, and the archive is found. However,
> for object files the search path isn't searched. E.g. if file.o
> resides in .., and -L.. is used in the command line, and the linker
> script has the line:
>
> INPUT(file.o)
>
> then ld returns the following error:
> "cannot open file.o": No such file or directory".
Which version of the sources are you using ? I tried the current
sources in the CVS repository and could not reproduce this failure.
> When library or object file which resides in the archive library
> search path appears in the input file specification, e.g.
>
> SECTIONS {
>
> .text : { library.a(.text) }
> }
>
> then ld returns
> "cannot open library.a": No such file or directory".
I could reproduce this failure.
Please could you try out the patch below and let me know if it solves
the problem for you ?
Cheers
Nick
2003-10-30 Nick Clifton <nickc@redhat.com>
* ldlang.c (lookup_name): When looking for a previously loaded
file compare the local_sym_name not the filename, as the
filename might have been transformed via the search directory
path lookup.
If the sought-for file has not been found in the input file
chain then create a new node with the search_dirs_flag set so
that the entire set of directory paths will be scanned for it.
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.126
diff -c -3 -p -r1.126 ldlang.c
*** ld/ldlang.c 25 Oct 2003 16:26:30 -0000 1.126
--- ld/ldlang.c 30 Oct 2003 13:36:16 -0000
*************** lookup_name (const char *name)
*** 1320,1335 ****
search != NULL;
search = (lang_input_statement_type *) search->next_real_file)
{
! if (search->filename == NULL && name == NULL)
return search;
! if (search->filename != NULL
&& name != NULL
! && strcmp (search->filename, name) == 0)
break;
}
if (search == NULL)
! search = new_afile (name, lang_input_file_is_file_enum, default_target,
FALSE);
/* If we have already added this file, or this file is not real
--- 1320,1340 ----
search != NULL;
search = (lang_input_statement_type *) search->next_real_file)
{
! /* Use the local_sym_name as the name of the file that has
! already been loaded as filename might have been transformed
! via the search directory lookup mechanism. */
! const char * filename = search->local_sym_name;
!
! if (filename == NULL && name == NULL)
return search;
! if (filename != NULL
&& name != NULL
! && strcmp (filename, name) == 0)
break;
}
if (search == NULL)
! search = new_afile (name, lang_input_file_is_search_file_enum, default_target,
FALSE);
/* If we have already added this file, or this file is not real