aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/elf32.em
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-03-14 11:25:59 +1030
committerAlan Modra <amodra@gmail.com>2014-03-14 12:54:24 +1030
commitd4ae5fb0b5d1ae4270b3343509e8bd2d529aa291 (patch)
treec9c91d0fd583689b7f204415b871632089d7ba1a /ld/emultempl/elf32.em
parentd6b6434614d9752d705d4f3199c3d59330938c66 (diff)
downloadgdb-d4ae5fb0b5d1ae4270b3343509e8bd2d529aa291.zip
gdb-d4ae5fb0b5d1ae4270b3343509e8bd2d529aa291.tar.gz
gdb-d4ae5fb0b5d1ae4270b3343509e8bd2d529aa291.tar.bz2
Remove search path from -l:namespec DT_NEEDED
For libraries without a soname, -l:libfoo.so set DT_NEEDED to the search dir plus filename, while gold and -lfoo just use the filename. This patch fixes the inconsistency. * ldlang.h (full_name_provided): New input flag. * ldlang.c (new_afile): Don't use lang_input_file_is_search_file_enum for -l:namespec. Instead use lang_input_file_is_l_enum with full_name_provided flag. * ldlfile.c (ldfile_open_file_search): Don't complete lib name if full_name_provided flag is set. * emultempl/elf32.em (gld${EMULATION_NAME}_open_dynamic_archive): Handle full_name_provided libraries. Tidy EXTRA_SHLIB_EXTENSION support. Set DT_NEEDED for -l:namespec as namespec. * emultempl/aix.em (ppc_after_open_output): Handle full_name_provided. * emultempl/linux.em (gld${EMULATION_NAME}_open_dynamic_archive): Don't handle full_name_provided libraries. * emultempl/pe.em (gld${EMULATION_NAME}_open_dynamic_archive): Ditto. * emultempl/pep.em (gld${EMULATION_NAME}_open_dynamic_archive): Ditto. * emultempl/vms.em (gld${EMULATION_NAME}_open_dynamic_archive): Ditto.
Diffstat (limited to 'ld/emultempl/elf32.em')
-rw-r--r--ld/emultempl/elf32.em49
1 files changed, 27 insertions, 22 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 789e12c..7ea5adc 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1656,42 +1656,46 @@ gld${EMULATION_NAME}_open_dynamic_archive
{
const char *filename;
char *string;
+ size_t len;
+ bfd_boolean opened = FALSE;
if (! entry->flags.maybe_archive)
return FALSE;
filename = entry->filename;
+ len = strlen (search->name) + strlen (filename);
+ if (entry->flags.full_name_provided)
+ {
+ len += sizeof "/";
+ string = (char *) xmalloc (len);
+ sprintf (string, "%s/%s", search->name, filename);
+ }
+ else
+ {
+ size_t xlen = 0;
- /* This allocates a few bytes too many when EXTRA_SHLIB_EXTENSION
- is defined, but it does not seem worth the headache to optimize
- away those two bytes of space. */
- string = (char *) xmalloc (strlen (search->name)
- + strlen (filename)
- + strlen (arch)
+ len += strlen (arch) + sizeof "/lib.so";
#ifdef EXTRA_SHLIB_EXTENSION
- + strlen (EXTRA_SHLIB_EXTENSION)
+ xlen = (strlen (EXTRA_SHLIB_EXTENSION) > 3
+ ? strlen (EXTRA_SHLIB_EXTENSION) - 3
+ : 0);
#endif
- + sizeof "/lib.so");
-
- sprintf (string, "%s/lib%s%s.so", search->name, filename, arch);
-
+ string = (char *) xmalloc (len + xlen);
+ sprintf (string, "%s/lib%s%s.so", search->name, filename, arch);
#ifdef EXTRA_SHLIB_EXTENSION
- /* Try the .so extension first. If that fails build a new filename
- using EXTRA_SHLIB_EXTENSION. */
- if (! ldfile_try_open_bfd (string, entry))
- {
- sprintf (string, "%s/lib%s%s%s", search->name,
- filename, arch, EXTRA_SHLIB_EXTENSION);
+ /* Try the .so extension first. If that fails build a new filename
+ using EXTRA_SHLIB_EXTENSION. */
+ opened = ldfile_try_open_bfd (string, entry);
+ if (!opened)
+ strcpy (string + len - 4, EXTRA_SHLIB_EXTENSION);
#endif
+ }
- if (! ldfile_try_open_bfd (string, entry))
+ if (!opened && !ldfile_try_open_bfd (string, entry))
{
free (string);
return FALSE;
}
-#ifdef EXTRA_SHLIB_EXTENSION
- }
-#endif
entry->filename = string;
@@ -1716,7 +1720,8 @@ gld${EMULATION_NAME}_open_dynamic_archive
/* Rather than duplicating the logic above. Just use the
filename we recorded earlier. */
- filename = lbasename (entry->filename);
+ if (!entry->flags.full_name_provided)
+ filename = lbasename (entry->filename);
bfd_elf_set_dt_needed_name (entry->the_bfd, filename);
}