This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH [Re: unexpected behaviour of ld with --start-group]
- To: bryan dot white at rsctech dot com, gaya dot rime at rsctech dot com,binutils at sourceware dot cygnus dot com
- Subject: Re: PATCH [Re: unexpected behaviour of ld with --start-group]
- From: "H . J . Lu" <hjl at valinux dot com>
- Date: Tue, 20 Feb 2001 11:52:06 -0800
- References: <PNELICDMEDCHEEIEBCGOAEODCAAA.bryan.white@rsctech.com> <20010220110502.A8219@valinux.com> <sielwtno5t.fsf@daffy.airs.com>
On Tue, Feb 20, 2001 at 11:35:10AM -0800, Ian Lance Taylor wrote:
> "H . J . Lu" <hjl@valinux.com> writes:
>
> > We have to scan a linker script twice to get the correct behavior.
> > "--start-group -lc --end-group" means we have a linker script inside
> > another linker script. We didn't handle this case well. With my
> > patch, I got
> >
> > ...
> >
> > Ian, do you have any comments?
>
> Looks reasonable. I might clear the search_dirs_flag in
> ldfile_open_file or ldfile_open_file_search in ldfile.c, to catch all
> cases rather than fixing all the emulation files separately. Also,
> probably the same bug can occur with careful use of an INPUT
> statement, and clearing the flag in ldfile.c would avoid that.
>
How about this one? I chose ldfile_open_file since it also calls
ldemul_find_potential_libraries.
Thanks.
--
H.J. Lu (hjl@valinux.com)
---
2001-02-20 H.J. Lu <hjl@gnu.org>
* ldfile.c (ldfile_open_file): Set entry->search_dirs_flag to
false if we found the file.
Index: ldfile.c
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/ldfile.c,v
retrieving revision 1.8
diff -u -p -r1.8 ldfile.c
--- ldfile.c 2000/10/10 19:47:38 1.8
+++ ldfile.c 2001/02/20 19:48:32
@@ -242,23 +242,32 @@ ldfile_open_file (entry)
else
{
search_arch_type *arch;
+ boolean found = false;
/* Try to open <filename><suffix> or lib<filename><suffix>.a */
for (arch = search_arch_head;
arch != (search_arch_type *) NULL;
arch = arch->next)
{
- if (ldfile_open_file_search (arch->name, entry, "lib", ".a"))
- return;
+ found = ldfile_open_file_search (arch->name, entry, "lib", ".a");
+ if (found)
+ break;
#ifdef VMS
- if (ldfile_open_file_search (arch->name, entry, ":lib", ".a"))
- return;
+ found = ldfile_open_file_search (arch->name, entry, ":lib", ".a");
+ if (found)
+ break;
#endif
- if (ldemul_find_potential_libraries (arch->name, entry))
- return;
+ found = ldemul_find_potential_libraries (arch->name, entry);
+ if (found)
+ break;
}
- einfo (_("%F%P: cannot find %s\n"), entry->local_sym_name);
+ /* If we have found the file, we don't need to search directories
+ again. */
+ if (found)
+ entry->search_dirs_flag = false;
+ else
+ einfo (_("%F%P: cannot find %s\n"), entry->local_sym_name);
}
}