X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=ld%2Fldfile.c;h=53112c86947fdf222e9517f5b3db4a36a56ff5ad;hb=02eba61aa6cad683e96cf13f483adc04982c0c2b;hp=411f7ddf971a28676564b50f6083c35798dc6436;hpb=b3adc24a0713411ab38a21dc894dd40dbc5c8f4f;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/ldfile.c b/ld/ldfile.c index 411f7ddf97..53112c8694 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -302,7 +302,7 @@ ldfile_try_open_bfd (const char *attempt, } } } -success: + success: #ifdef ENABLE_PLUGINS /* If plugins are active, they get first chance to claim any successfully-opened input file. We skip archives @@ -416,7 +416,24 @@ ldfile_open_file (lang_input_statement_type *entry) search_arch_type *arch; bfd_boolean found = FALSE; - /* Try to open or lib.a */ + /* If extra_search_path is set, entry->filename is a relative path. + Search the directory of the current linker script before searching + other paths. */ + if (entry->extra_search_path) + { + char *path = concat (entry->extra_search_path, slash, entry->filename, + (const char *)0); + if (ldfile_try_open_bfd (path, entry)) + { + entry->filename = path; + entry->flags.search_dirs = FALSE; + return; + } + + free (path); + } + + /* Try to open or lib.a. */ for (arch = search_arch_head; arch != NULL; arch = arch->next) { found = ldfile_open_file_search (arch->name, entry, "lib", ".a"); @@ -445,6 +462,22 @@ ldfile_open_file (lang_input_statement_type *entry) entry->local_sym_name, ld_sysroot); else einfo (_("%P: cannot find %s\n"), entry->local_sym_name); + + /* PR 25747: Be kind to users who forgot to add the + "lib" prefix to their library when it was created. */ + for (arch = search_arch_head; arch != NULL; arch = arch->next) + { + if (ldfile_open_file_search (arch->name, entry, "", ".a")) + { + const char * base = lbasename (entry->filename); + + einfo (_("%P: note to link with %s use -l:%s or rename it to lib%s\n"), + entry->filename, base, base); + bfd_close (entry->the_bfd); + entry->the_bfd = NULL; + break; + } + } entry->flags.missing_file = TRUE; input_flags.missing_file = TRUE; }