public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] basename buffer gets spammed in `ld'
@ 2001-07-09 16:37 David O'Brien
  2001-07-09 16:48 ` DJ Delorie
  2001-07-09 16:49 ` H . J . Lu
  0 siblings, 2 replies; 28+ messages in thread
From: David O'Brien @ 2001-07-09 16:37 UTC (permalink / raw)
  To: GNU Binutils mailing list

There is a bug in `ld' that causes it to record crtn.o as a shared
library dependency in some cases on FreeBSD.

Permission to apply to head and 2.11 branch?

-- 
-- David  (obrien@FreeBSD.org)


Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/ld/ChangeLog,v
retrieving revision 1.423
diff -u -r1.423 ChangeLog
--- ChangeLog	2001/07/03 23:22:19	1.423
+++ ChangeLog	2001/07/09 23:31:29
@@ -1,3 +1,8 @@
+2001-07-09  David O'Brien  <obrien@FreeBSD.org>
+
+	* emultempl/elf32.em: Do not assuming that contents of the buffer returned
+	from basename function will remain unchanged accross other function calls.
+
 2001-07-03  H.J. Lu  <hjl@gnu.org>
 
 	* scripttempl/elf.sc (DYNAMIC_PAD): Revert the change made on
Index: emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.49
diff -u -r1.49 elf32.em
--- elf32.em	2001/06/18 22:20:57	1.49
+++ elf32.em	2001/07/09 23:31:30
@@ -360,6 +360,9 @@
      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.  */

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 16:37 [PATCH] basename buffer gets spammed in `ld' David O'Brien
@ 2001-07-09 16:48 ` DJ Delorie
  2001-07-09 17:09   ` David O'Brien
  2001-07-09 21:17   ` David O'Brien
  2001-07-09 16:49 ` H . J . Lu
  1 sibling, 2 replies; 28+ messages in thread
From: DJ Delorie @ 2001-07-09 16:48 UTC (permalink / raw)
  To: obrien; +Cc: binutils

Have you tried replacing basename() with libiberty's new lbasename()?
lbasename() always returns a pointer to the string you give it, which
shouldn't be clobbered unless someone renames a bfd.

If that works, it would be a preferrable solution.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 16:37 [PATCH] basename buffer gets spammed in `ld' David O'Brien
  2001-07-09 16:48 ` DJ Delorie
@ 2001-07-09 16:49 ` H . J . Lu
  2001-07-09 17:19   ` DJ Delorie
  1 sibling, 1 reply; 28+ messages in thread
From: H . J . Lu @ 2001-07-09 16:49 UTC (permalink / raw)
  To: David O'Brien; +Cc: GNU Binutils mailing list

On Mon, Jul 09, 2001 at 04:36:42PM -0700, David O'Brien wrote:
> There is a bug in `ld' that causes it to record crtn.o as a shared
> library dependency in some cases on FreeBSD.
> 
> Permission to apply to head and 2.11 branch?
> 

I am not against this patch. But there may be other places in the
soourceware tree where it assumes basename doesn't use a buffer.
I think libibery should check if the system's basename behaves
the same as the one in libibery before using the system one. I
can try to write a test for it.


H.J.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 16:48 ` DJ Delorie
@ 2001-07-09 17:09   ` David O'Brien
  2001-07-09 17:30     ` DJ Delorie
  2001-07-10 22:55     ` Andrew Cagney
  2001-07-09 21:17   ` David O'Brien
  1 sibling, 2 replies; 28+ messages in thread
From: David O'Brien @ 2001-07-09 17:09 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils

On Mon, Jul 09, 2001 at 07:48:03PM -0400, DJ Delorie wrote:
> 
> Have you tried replacing basename() with libiberty's new lbasename()?

Nope.  I stayed consistent with the existing style of using basename().
(especially since I'd like to also commit this to the 2.11 branch)

I'd rather commit my patch and leave trying lbasename() to a
basename->lbasename sweep.

-- 
-- David  (obrien@FreeBSD.org)

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 16:49 ` H . J . Lu
@ 2001-07-09 17:19   ` DJ Delorie
  2001-07-09 17:24     ` H . J . Lu
  0 siblings, 1 reply; 28+ messages in thread
From: DJ Delorie @ 2001-07-09 17:19 UTC (permalink / raw)
  To: hjl; +Cc: binutils

> I think libibery should check if the system's basename behaves
> the same as the one in libibery before using the system one. I
> can try to write a test for it.

Libiberty provides lbasename() for when you know you want a fixed set
of semantics.  You can't test for functionality in libiberty, only for
the presence or absense of a function (think "cross compiler").

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 17:19   ` DJ Delorie
@ 2001-07-09 17:24     ` H . J . Lu
  2001-07-09 17:34       ` DJ Delorie
  0 siblings, 1 reply; 28+ messages in thread
From: H . J . Lu @ 2001-07-09 17:24 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils

On Mon, Jul 09, 2001 at 08:19:20PM -0400, DJ Delorie wrote:
> 
> > I think libibery should check if the system's basename behaves
> > the same as the one in libibery before using the system one. I
> > can try to write a test for it.
> 
> Libiberty provides lbasename() for when you know you want a fixed set
> of semantics.  You can't test for functionality in libiberty, only for
> the presence or absense of a function (think "cross compiler").

It has been done all the time. For cross compile, just make a safer
choice. See

dnl AC_TRY_RUN(PROGRAM, [ACTION-IF-TRUE [, ACTION-IF-FALSE
dnl            [, ACTION-IF-CROSS-COMPILING]]])

I have been adding the missing ACTION-IF-CROSS-COMPILING to many
packacages.


H.J.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 17:09   ` David O'Brien
@ 2001-07-09 17:30     ` DJ Delorie
  2001-07-10  0:33       ` Philip Blundell
  2001-07-10  3:41       ` Nick Clifton
  2001-07-10 22:55     ` Andrew Cagney
  1 sibling, 2 replies; 28+ messages in thread
From: DJ Delorie @ 2001-07-09 17:30 UTC (permalink / raw)
  To: obrien; +Cc: binutils

Ok, then.  Approved for head.  I don't recall the branch checkin
rules, but if I'm allowed to approve it, it's approved for that also.
Nick - can we add a "current branches and checkin rules" section on
the binutils web page?

> Nope.  I stayed consistent with the existing style of using basename().
> (especially since I'd like to also commit this to the 2.11 branch)
> 
> I'd rather commit my patch and leave trying lbasename() to a
> basename->lbasename sweep.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 17:24     ` H . J . Lu
@ 2001-07-09 17:34       ` DJ Delorie
  2001-07-09 17:39         ` H . J . Lu
  0 siblings, 1 reply; 28+ messages in thread
From: DJ Delorie @ 2001-07-09 17:34 UTC (permalink / raw)
  To: hjl; +Cc: binutils

> It has been done all the time. For cross compile, just make a safer
> choice.

I suppose.  In this case, though, we'd just use lbasename().

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 17:34       ` DJ Delorie
@ 2001-07-09 17:39         ` H . J . Lu
  0 siblings, 0 replies; 28+ messages in thread
From: H . J . Lu @ 2001-07-09 17:39 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils

On Mon, Jul 09, 2001 at 08:34:35PM -0400, DJ Delorie wrote:
> 
> > It has been done all the time. For cross compile, just make a safer
> > choice.
> 
> I suppose.  In this case, though, we'd just use lbasename().

Ok with me.


H.J.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 16:48 ` DJ Delorie
  2001-07-09 17:09   ` David O'Brien
@ 2001-07-09 21:17   ` David O'Brien
  2001-07-09 21:34     ` DJ Delorie
  2001-07-10  0:34     ` Philip Blundell
  1 sibling, 2 replies; 28+ messages in thread
From: David O'Brien @ 2001-07-09 21:17 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils

On Mon, Jul 09, 2001 at 07:48:03PM -0400, DJ Delorie wrote:
> Have you tried replacing basename() with libiberty's new lbasename()?
> lbasename() always returns a pointer to the string you give it, which
> shouldn't be clobbered unless someone renames a bfd.

I'd like to update libiberty in the 2.11 branch based on top of tree (to
bring in lbasename).  Is that something you could do?  (IIRC you usually
handle the updates of libiberty w/in Binutils)
 
-- 
-- David  (obrien@FreeBSD.org)

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 21:17   ` David O'Brien
@ 2001-07-09 21:34     ` DJ Delorie
  2001-07-10  0:34     ` Philip Blundell
  1 sibling, 0 replies; 28+ messages in thread
From: DJ Delorie @ 2001-07-09 21:34 UTC (permalink / raw)
  To: obrien; +Cc: binutils

> I'd like to update libiberty in the 2.11 branch based on top of tree (to
> bring in lbasename).  Is that something you could do?  (IIRC you usually
> handle the updates of libiberty w/in Binutils)

I don't normally keep head in sync with branches.  Usually, branches
are changed for specific reasons, not "just because".  The head sync
with gcc is done by a script, and I wouldn't unleash that on a branch.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 17:30     ` DJ Delorie
@ 2001-07-10  0:33       ` Philip Blundell
  2001-07-12 11:43         ` David O'Brien
  2001-07-10  3:41       ` Nick Clifton
  1 sibling, 1 reply; 28+ messages in thread
From: Philip Blundell @ 2001-07-10  0:33 UTC (permalink / raw)
  To: DJ Delorie; +Cc: obrien, binutils

>Ok, then.  Approved for head.  I don't recall the branch checkin
>rules, but if I'm allowed to approve it, it's approved for that also.
>Nick - can we add a "current branches and checkin rules" section on
>the binutils web page?

Yes, it's okay for the branch.

p.


-- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (GNU/Linux)
Comment: Exmh version 2.1.1 10/15/1999 (debian)

iD8DBQE7Sq+mVTLPJe9CT30RAjY6AJ95f4Q9RULF8EvbhvidoM+lVqF8wwCbB6Ie
VtPyaV93w55RFmFtu6U8kWU=
=9q5n
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 21:17   ` David O'Brien
  2001-07-09 21:34     ` DJ Delorie
@ 2001-07-10  0:34     ` Philip Blundell
  2001-07-10  9:10       ` David O'Brien
  1 sibling, 1 reply; 28+ messages in thread
From: Philip Blundell @ 2001-07-10  0:34 UTC (permalink / raw)
  To: obrien; +Cc: DJ Delorie, binutils

>I'd like to update libiberty in the 2.11 branch based on top of tree (to
>bring in lbasename).  Is that something you could do?  (IIRC you usually
>handle the updates of libiberty w/in Binutils)

That would make me a bit nervous.  Is there any particular issue you want to 
address?  If it's just adding lbasename, I'd have thought there would be a 
less intrusive way to achieve that without updating the whole of libiberty.

p.


-- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (GNU/Linux)
Comment: Exmh version 2.1.1 10/15/1999 (debian)

iD8DBQE7Sq/hVTLPJe9CT30RAtM4AJ4hdW0fKJUN8Enf/m5g2+0DIBCTFQCfZSY7
2DvEqDQOuu8K7XFRKwOI/CM=
=TYV0
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 17:30     ` DJ Delorie
  2001-07-10  0:33       ` Philip Blundell
@ 2001-07-10  3:41       ` Nick Clifton
  2001-07-10  6:06         ` Philip Blundell
  1 sibling, 1 reply; 28+ messages in thread
From: Nick Clifton @ 2001-07-10  3:41 UTC (permalink / raw)
  To: DJ Delorie, philb; +Cc: binutils

Hi DJ,

> Nick - can we add a "current branches and checkin rules" section on
> the binutils web page?

A good idea.  How about something like this:

	       --------- Branch Checkins ---------

    If a patch is approved for check in to the mainline sources,
    it can also be checked into the current release branch.
    Normally however only bug fixes should be applied to the branch.
    New features, new ports, etc, should be restricted to the
    mainline.  (Otherwise the burden of maintaing the branch in
    sync with the mainline becomes too great).  If you are
    uncertain as to whether a patch is appropriate for the branch,
    ask the branch maintainer.  This is:

        Philip Blundell  <philb@gnu.org>

Phil, do you agree ?  Would you prefer to have patches always
submiited for your approval before they are applied to the branch ?


Cheers
        Nick

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-10  3:41       ` Nick Clifton
@ 2001-07-10  6:06         ` Philip Blundell
  0 siblings, 0 replies; 28+ messages in thread
From: Philip Blundell @ 2001-07-10  6:06 UTC (permalink / raw)
  To: Nick Clifton; +Cc: DJ Delorie, binutils

>A good idea.  How about something like this:

This seems fine.  No, there is no need for maintainers to ask me before 
checking patches in, if they're confident that the change is appropriate.

p.

-- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (GNU/Linux)
Comment: Exmh version 2.1.1 10/15/1999 (debian)

iD8DBQE7Sv3MVTLPJe9CT30RAgAiAJ97FeATORTlQ/8AV+HDrxZJj0GYrwCgwmM1
KuScNO1BQty+2qyWavfDoy4=
=dD/+
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-10  0:34     ` Philip Blundell
@ 2001-07-10  9:10       ` David O'Brien
  2001-07-10 10:43         ` Philip Blundell
  0 siblings, 1 reply; 28+ messages in thread
From: David O'Brien @ 2001-07-10  9:10 UTC (permalink / raw)
  To: Philip Blundell; +Cc: DJ Delorie, binutils

On Tue, Jul 10, 2001 at 08:33:54AM +0100, Philip Blundell wrote:
> >I'd like to update libiberty in the 2.11 branch based on top of tree (to
> >bring in lbasename).  Is that something you could do?  (IIRC you usually
> >handle the updates of libiberty w/in Binutils)
> 
> That would make me a bit nervous.  Is there any particular issue you want to 
> address?  If it's just adding lbasename, I'd have thought there would be a 
> less intrusive way to achieve that without updating the whole of libiberty.

I didn't realize syncing libiberty from top of tree would be considered
risky.

Would you be open to me adding lbasename.c to the 2.11 branch + adding
the prototype to libiberty.h and libiberty/Makefile* ?
 
I have a better patch for the problem that uses lbasename() as DJ
recommended.

-- 
-- David  (obrien@FreeBSD.org)

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-10  9:10       ` David O'Brien
@ 2001-07-10 10:43         ` Philip Blundell
  0 siblings, 0 replies; 28+ messages in thread
From: Philip Blundell @ 2001-07-10 10:43 UTC (permalink / raw)
  To: obrien; +Cc: DJ Delorie, binutils

>I didn't realize syncing libiberty from top of tree would be considered
>risky.

It's not, particularly.  But it's bound to introduce changes that haven't been 
thoroughly tested, so it does carry some risk.  I'd rather not do that unless 
it brings a clear and compelling benefit.

>Would you be open to me adding lbasename.c to the 2.11 branch + adding
>the prototype to libiberty.h and libiberty/Makefile* ?

Yes.

p.


-- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (GNU/Linux)
Comment: Exmh version 2.1.1 10/15/1999 (debian)

iD8DBQE7Sz7DVTLPJe9CT30RAkwEAJwIRApAnddM4WmESDbaV5fiHHJQ1ACguSBa
WafmJ05Mz/3E65av9HMdrA4=
=3One
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-09 17:09   ` David O'Brien
  2001-07-09 17:30     ` DJ Delorie
@ 2001-07-10 22:55     ` Andrew Cagney
  2001-07-10 23:04       ` David O'Brien
  1 sibling, 1 reply; 28+ messages in thread
From: Andrew Cagney @ 2001-07-10 22:55 UTC (permalink / raw)
  To: obrien; +Cc: DJ Delorie, binutils

> On Mon, Jul 09, 2001 at 07:48:03PM -0400, DJ Delorie wrote:
> 
>> 
>> Have you tried replacing basename() with libiberty's new lbasename()?
> 
> 
> Nope.  I stayed consistent with the existing style of using basename().
> (especially since I'd like to also commit this to the 2.11 branch)
> 
> I'd rather commit my patch and leave trying lbasename() to a
> basename->lbasename sweep.


Just a heads up.  I've approval in principal to change the lbasename() 
signature to:

	const char *lbasename (const char *);

If you're doing a s/basename/lbasename/ sweep please keep this in mind.

	Andrew

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-10 22:55     ` Andrew Cagney
@ 2001-07-10 23:04       ` David O'Brien
  0 siblings, 0 replies; 28+ messages in thread
From: David O'Brien @ 2001-07-10 23:04 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: DJ Delorie, binutils

On Wed, Jul 11, 2001 at 01:55:57AM -0400, Andrew Cagney wrote:
> Just a heads up.  I've approval in principal to change the lbasename() 
> signature to:
> 
> 	const char *lbasename (const char *);
> 
> If you're doing a s/basename/lbasename/ sweep please keep this in mind.

I am (testing patch now).  When do you plan on changing the signature?
 
-- 
-- David  (obrien@FreeBSD.org)

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-10  0:33       ` Philip Blundell
@ 2001-07-12 11:43         ` David O'Brien
  2001-07-12 11:49           ` H . J . Lu
  2001-07-12 11:49           ` DJ Delorie
  0 siblings, 2 replies; 28+ messages in thread
From: David O'Brien @ 2001-07-12 11:43 UTC (permalink / raw)
  To: DJ Delorie, binutils

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);
     }
 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-12 11:43         ` David O'Brien
@ 2001-07-12 11:49           ` H . J . Lu
  2001-07-12 11:49           ` DJ Delorie
  1 sibling, 0 replies; 28+ messages in thread
From: H . J . Lu @ 2001-07-12 11:49 UTC (permalink / raw)
  To: David O'Brien; +Cc: DJ Delorie, binutils

On Thu, Jul 12, 2001 at 11:43:19AM -0700, David O'Brien wrote:
> @@ -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);
>      }
>  

Are you sure it is 100% safe to remove xstrdup?


H.J.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-12 11:43         ` David O'Brien
  2001-07-12 11:49           ` H . J . Lu
@ 2001-07-12 11:49           ` DJ Delorie
  2001-07-12 11:57             ` David O'Brien
  1 sibling, 1 reply; 28+ messages in thread
From: DJ Delorie @ 2001-07-12 11:49 UTC (permalink / raw)
  To: obrien; +Cc: binutils

> 2001-07-11  David O'Brien  <obrien@FreeBSD.org>
> 
> 	* emultempl/elf32.em: Make all basename calls safe by using
> 	lbasename() with non-changing buffers.

Make sure the branch has lbasename in libiberty, else OK (unless Phil
B disagrees, of course ;).

> -      filename = xstrdup (basename (entry->filename));
> +      filename = lbasename (entry->filename);

Are you sure the xstrdup is no longer needed with lbasename?

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-12 11:49           ` DJ Delorie
@ 2001-07-12 11:57             ` David O'Brien
  2001-07-12 11:59               ` David O'Brien
  0 siblings, 1 reply; 28+ messages in thread
From: David O'Brien @ 2001-07-12 11:57 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils

On Thu, Jul 12, 2001 at 02:49:13PM -0400, DJ Delorie wrote:
> 
> > 2001-07-11  David O'Brien  <obrien@FreeBSD.org>
> > 
> > 	* emultempl/elf32.em: Make all basename calls safe by using
> > 	lbasename() with non-changing buffers.
> 
> Make sure the branch has lbasename in libiberty, else OK (unless Phil
> B disagrees, of course ;).
> 
> > -      filename = xstrdup (basename (entry->filename));
> > +      filename = lbasename (entry->filename);
> 
> Are you sure the xstrdup is no longer needed with lbasename?

Depends on why the xstrdup was there.  If it was there because of
basename()'s internal non-reentrant buff, then it is not needed.  As you
know that is how lbasename() differs from basename().

If entry->filename's contents are not static across the run, then it
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
basename() calls needed to be wrapped with xstrdup it appeared to me this
basename() call was wrapped in xstrdup for the same reason.

HOWEVER, I would not mind at all a second set of eyes looking into it.

-- 
-- David  (obrien@FreeBSD.org)

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-12 11:57             ` David O'Brien
@ 2001-07-12 11:59               ` David O'Brien
  2001-07-12 12:15                 ` H . J . Lu
  0 siblings, 1 reply; 28+ messages in thread
From: David O'Brien @ 2001-07-12 11:59 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils

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
> basename() calls needed to be wrapped with xstrdup it appeared to me this
> basename() call was wrapped in xstrdup for the same reason.

That said, if it is more expedient (or will put minds at rest), I'll
leave this line as-is and commit the other changes [with permission].

-- 
-- David  (obrien@FreeBSD.org)

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-12 11:59               ` David O'Brien
@ 2001-07-12 12:15                 ` H . J . Lu
  2001-07-14  9:39                   ` David O'Brien
  0 siblings, 1 reply; 28+ messages in thread
From: H . J . Lu @ 2001-07-12 12:15 UTC (permalink / raw)
  To: David O'Brien; +Cc: DJ Delorie, binutils

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 :-).


H.J.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-12 12:15                 ` H . J . Lu
@ 2001-07-14  9:39                   ` David O'Brien
  2001-07-14  9:47                     ` H . J . Lu
  0 siblings, 1 reply; 28+ messages in thread
From: David O'Brien @ 2001-07-14  9:39 UTC (permalink / raw)
  To: H . J . Lu; +Cc: DJ Delorie, binutils

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.  */

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-14  9:39                   ` David O'Brien
@ 2001-07-14  9:47                     ` H . J . Lu
  2001-07-14 11:03                       ` David O'Brien
  0 siblings, 1 reply; 28+ messages in thread
From: H . J . Lu @ 2001-07-14  9:47 UTC (permalink / raw)
  To: David O'Brien; +Cc: DJ Delorie, binutils

On Sat, Jul 14, 2001 at 09:39:34AM -0700, David O'Brien wrote:
> > 
> > > > 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).

My comment was for the xstrdup change, which is not broken. If you go
back, you can see it is the part of your patch we are discussing. 


H.J.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH] basename buffer gets spammed in `ld'
  2001-07-14  9:47                     ` H . J . Lu
@ 2001-07-14 11:03                       ` David O'Brien
  0 siblings, 0 replies; 28+ messages in thread
From: David O'Brien @ 2001-07-14 11:03 UTC (permalink / raw)
  To: H . J . Lu; +Cc: DJ Delorie, binutils

On Sat, Jul 14, 2001 at 09:47:50AM -0700, H . J . Lu wrote:
> On Sat, Jul 14, 2001 at 09:39:34AM -0700, David O'Brien wrote:
> > > 
> > > > > 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).
> 
> My comment was for the xstrdup change, which is not broken. If you go
> back, you can see it is the part of your patch we are discussing. 

Why are you still discussing the older patch vs. the one that was at the
bottom of the email you replied to?
 
-- 
-- David  (obrien@FreeBSD.org)

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2001-07-14 11:03 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-09 16:37 [PATCH] basename buffer gets spammed in `ld' David O'Brien
2001-07-09 16:48 ` DJ Delorie
2001-07-09 17:09   ` David O'Brien
2001-07-09 17:30     ` DJ Delorie
2001-07-10  0:33       ` Philip Blundell
2001-07-12 11:43         ` David O'Brien
2001-07-12 11:49           ` H . J . Lu
2001-07-12 11:49           ` DJ Delorie
2001-07-12 11:57             ` David O'Brien
2001-07-12 11:59               ` David O'Brien
2001-07-12 12:15                 ` H . J . Lu
2001-07-14  9:39                   ` David O'Brien
2001-07-14  9:47                     ` H . J . Lu
2001-07-14 11:03                       ` David O'Brien
2001-07-10  3:41       ` Nick Clifton
2001-07-10  6:06         ` Philip Blundell
2001-07-10 22:55     ` Andrew Cagney
2001-07-10 23:04       ` David O'Brien
2001-07-09 21:17   ` David O'Brien
2001-07-09 21:34     ` DJ Delorie
2001-07-10  0:34     ` Philip Blundell
2001-07-10  9:10       ` David O'Brien
2001-07-10 10:43         ` Philip Blundell
2001-07-09 16:49 ` H . J . Lu
2001-07-09 17:19   ` DJ Delorie
2001-07-09 17:24     ` H . J . Lu
2001-07-09 17:34       ` DJ Delorie
2001-07-09 17:39         ` H . J . Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).