This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] basename buffer gets spammed in `ld'
I would like to check this patch into head and the 2.11 branch.
It is a better patch than my last one (which still had a "whole" in it).
--
-- David (obrien@FreeBSD.org)
2001-07-11 David O'Brien <obrien@FreeBSD.org>
* emultempl/elf32.em: Make all basename calls safe by using
lbasename() with non-changing buffers.
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.50
diff -u -r1.50 elf32.em
--- elf32.em 2001/07/10 00:38:16 1.50
+++ elf32.em 2001/07/12 18:35:01
@@ -155,7 +155,7 @@
soname = bfd_elf_get_dt_soname (s->the_bfd);
if (soname == NULL)
- soname = basename (bfd_get_filename (s->the_bfd));
+ soname = lbasename (bfd_get_filename (s->the_bfd));
for (l = global_vercheck_needed; l != NULL; l = l->next)
{
@@ -237,7 +237,7 @@
soname = bfd_elf_get_dt_soname (s->the_bfd);
if (soname == NULL)
- soname = basename (s->filename);
+ soname = lbasename (s->filename);
if (strncmp (soname, global_needed->name,
suffix - global_needed->name) == 0)
@@ -342,7 +342,7 @@
einfo ("%F%P:%B: bfd_stat failed: %E\n", abfd);
/* First strip off everything before the last '/'. */
- soname = basename (abfd->filename);
+ soname = lbasename (abfd->filename);
if (trace_file_tries)
info_msg (_("found %s at %s\n"), soname, name);
@@ -360,9 +360,6 @@
DT_NEEDED entry for this file. */
bfd_elf_set_dt_needed_name (abfd, "");
- /* Previos basename call was clobbered in lang_for_each_input_file. */
- soname = basename (abfd->filename);
-
/* Tell the ELF backend that the output file needs a DT_NEEDED
entry for this file if it is used to resolve the reference in
a regular object. */
@@ -967,7 +964,7 @@
/* Rather than duplicating the logic above. Just use the
filename we recorded earlier. */
- filename = xstrdup (basename (entry->filename));
+ filename = lbasename (entry->filename);
bfd_elf_set_dt_needed_name (entry->the_bfd, filename);
}