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'
On Thu, Jul 12, 2001 at 12:15:39PM -0700, H . J . Lu wrote:
> On Thu, Jul 12, 2001 at 11:59:27AM -0700, David O'Brien wrote:
> > On Thu, Jul 12, 2001 at 11:57:53AM -0700, David O'Brien wrote:
> > > would still be needed. My read and test cases showed the patch was fine
> > > (with no test regression for i386-known-freebsd4.3. Since all the other
>
> It doesn't mean much.
>
> > > basename() calls needed to be wrapped with xstrdup it appeared to me this
> > > basename() call was wrapped in xstrdup for the same reason.
> >
>
> I don't like such kind of change. Unless it is broken, don't fix
> it :-).
The current code is broken (ie, has bugs that are biting FreeBSD users).
Since the existing xstrdup(basename(...)) call isn't one of the problems,
and I changed it just for consistancy; I've taken it out. Here is the
patch I would now like to commit.
--
-- David (obrien@FreeBSD.org)
Index: elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.51
diff -u -r1.51 elf32.em
--- elf32.em 2001/07/13 07:25:18 1.51
+++ elf32.em 2001/07/14 16:33:04
@@ -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. */