Turn ___brk_addr into a compat symbol

Message ID mvmpn42anev.fsf@suse.de
State Superseded
Headers
Series Turn ___brk_addr into a compat symbol |

Commit Message

Andreas Schwab Nov. 24, 2020, 1:34 p.m. UTC
  At least since GCC 2.95 the ___brk_addr symbol has only been needed on
i386-linux.  The architectures added later do not need to define it any
more.  This includes all current users of .../generic/brk.c, plus ia64 and
microblaze.  GCC 3.1 finally removed that reference even for i386-linux.
---
 sysdeps/unix/sysv/linux/generic/brk.c    | 5 ++++-
 sysdeps/unix/sysv/linux/ia64/brk.S       | 5 ++++-
 sysdeps/unix/sysv/linux/microblaze/brk.c | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)
  

Comments

H.J. Lu Nov. 24, 2020, 1:41 p.m. UTC | #1
On Tue, Nov 24, 2020 at 5:35 AM Andreas Schwab <schwab@suse.de> wrote:
>
> At least since GCC 2.95 the ___brk_addr symbol has only been needed on
> i386-linux.  The architectures added later do not need to define it any
> more.  This includes all current users of .../generic/brk.c, plus ia64 and
> microblaze.  GCC 3.1 finally removed that reference even for i386-linux.

Do any targets, except for i386-linux, ever reference this symbol?
  
Andreas Schwab Nov. 24, 2020, 2:46 p.m. UTC | #2
On Nov 24 2020, H.J. Lu wrote:

> Do any targets, except for i386-linux, ever reference this symbol?

See gcc commit bced43dd6ca.

Andreas.
  
H.J. Lu Nov. 24, 2020, 3:33 p.m. UTC | #3
On Tue, Nov 24, 2020 at 6:46 AM Andreas Schwab <schwab@suse.de> wrote:
>
> On Nov 24 2020, H.J. Lu wrote:
>
> > Do any targets, except for i386-linux, ever reference this symbol?
>
> See gcc commit bced43dd6ca.
>
> Andreas.
>

I don't see references to ___brk_addr for ia64 nor microblaze since they were
added after

commit d0f8fcea2689a8c9c32648370c14e0ce40288bfa
Author: Richard Kenner <kenner@gcc.gnu.org>
Date:   Fri Jun 28 14:08:53 1996 -0400

    (init_dummy): Only i386-linux (at most) needs ___brk_addr hack.

I think ___brk_addr should be removed for ia64 and microblaze.
  
Andreas Schwab Nov. 24, 2020, 3:43 p.m. UTC | #4
On Nov 24 2020, H.J. Lu via Libc-alpha wrote:

> I think ___brk_addr should be removed for ia64 and microblaze.

That's exactly what I do.

Andreas.
  
H.J. Lu Nov. 24, 2020, 3:56 p.m. UTC | #5
On Tue, Nov 24, 2020 at 7:43 AM Andreas Schwab <schwab@suse.de> wrote:
>
> On Nov 24 2020, H.J. Lu via Libc-alpha wrote:
>
> > I think ___brk_addr should be removed for ia64 and microblaze.
>
> That's exactly what I do.
>

You added

#include <shlib-compat.h>
...
compat_symbol (libc, __curbrk, ___brk_addr, GLIBC_2_0);

to ia64 and microblaze.
  
Andreas Schwab Nov. 24, 2020, 4:13 p.m. UTC | #6
On Nov 24 2020, H.J. Lu via Libc-alpha wrote:

> On Tue, Nov 24, 2020 at 7:43 AM Andreas Schwab <schwab@suse.de> wrote:
>>
>> On Nov 24 2020, H.J. Lu via Libc-alpha wrote:
>>
>> > I think ___brk_addr should be removed for ia64 and microblaze.
>>
>> That's exactly what I do.
>>
>
> You added
>
> #include <shlib-compat.h>
> ...
> compat_symbol (libc, __curbrk, ___brk_addr, GLIBC_2_0);
>
> to ia64 and microblaze.

Yes, and?

Andreas.
  
H.J. Lu Nov. 24, 2020, 5:16 p.m. UTC | #7
On Tue, Nov 24, 2020 at 8:13 AM Andreas Schwab <schwab@suse.de> wrote:
>
> On Nov 24 2020, H.J. Lu via Libc-alpha wrote:
>
> > On Tue, Nov 24, 2020 at 7:43 AM Andreas Schwab <schwab@suse.de> wrote:
> >>
> >> On Nov 24 2020, H.J. Lu via Libc-alpha wrote:
> >>
> >> > I think ___brk_addr should be removed for ia64 and microblaze.
> >>
> >> That's exactly what I do.
> >>
> >
> > You added
> >
> > #include <shlib-compat.h>
> > ...
> > compat_symbol (libc, __curbrk, ___brk_addr, GLIBC_2_0);
> >
> > to ia64 and microblaze.
>
> Yes, and?
>

There is no need for that.  ___brk_addr should be simply removed from ia64
and microblaze.
  
Andreas Schwab Nov. 25, 2020, 11:15 a.m. UTC | #8
On Nov 24 2020, H.J. Lu wrote:

> There is no need for that.  ___brk_addr should be simply removed from ia64
> and microblaze.

It is part of the ABI.

Andreas.
  
Florian Weimer Dec. 2, 2020, 11:21 a.m. UTC | #9
* Andreas Schwab:

> At least since GCC 2.95 the ___brk_addr symbol has only been needed on
> i386-linux.  The architectures added later do not need to define it any
> more.  This includes all current users of .../generic/brk.c, plus ia64 and
> microblaze.  GCC 3.1 finally removed that reference even for i386-linux.

Is the intent of this patch that __brk_addr should turn into a compat
symbol on i386, too?

Thanks,
Florian
  
Andreas Schwab Dec. 8, 2020, 11:43 a.m. UTC | #10
On Dez 02 2020, Florian Weimer wrote:

> Is the intent of this patch that __brk_addr should turn into a compat
> symbol on i386, too?

You objected.

Andreas.
  

Patch

diff --git a/sysdeps/unix/sysv/linux/generic/brk.c b/sysdeps/unix/sysv/linux/generic/brk.c
index 40a80ab970..0c12b3a487 100644
--- a/sysdeps/unix/sysv/linux/generic/brk.c
+++ b/sysdeps/unix/sysv/linux/generic/brk.c
@@ -19,14 +19,17 @@ 
 #include <errno.h>
 #include <unistd.h>
 #include <sysdep.h>
+#include <shlib-compat.h>
 
 /* This must be initialized data because commons can't have aliases.  */
 void *__curbrk = 0;
 
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_33)
 /* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt
    to work around different old braindamage in the old Linux ELF dynamic
    linker.  */
-weak_alias (__curbrk, ___brk_addr)
+compat_symbol (libc, __curbrk, ___brk_addr, GLIBC_2_0);
+#endif
 
 int
 __brk (void *addr)
diff --git a/sysdeps/unix/sysv/linux/ia64/brk.S b/sysdeps/unix/sysv/linux/ia64/brk.S
index 734d3467a7..3e643fa745 100644
--- a/sysdeps/unix/sysv/linux/ia64/brk.S
+++ b/sysdeps/unix/sysv/linux/ia64/brk.S
@@ -19,6 +19,7 @@ 
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
+#include <shlib-compat.h>
 
 #include <asm/errno.h>
 
@@ -30,7 +31,9 @@ 
 __curbrk:
 	data8	0
 
-weak_alias (__curbrk, ___brk_addr)
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_33)
+compat_symbol (libc, __curbrk, ___brk_addr, GLIBC_2_0)
+#endif
 
 LEAF(__brk)
 	.regstk 1, 0, 0, 0
diff --git a/sysdeps/unix/sysv/linux/microblaze/brk.c b/sysdeps/unix/sysv/linux/microblaze/brk.c
index 20c3e625e4..c41fbbf03a 100644
--- a/sysdeps/unix/sysv/linux/microblaze/brk.c
+++ b/sysdeps/unix/sysv/linux/microblaze/brk.c
@@ -18,14 +18,17 @@ 
 #include <errno.h>
 #include <unistd.h>
 #include <sysdep.h>
+#include <shlib-compat.h>
 
 /* This must be initialized data because commons can't have aliases.  */
 void *__curbrk = 0;
 
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_33)
 /* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt
    to work around different old braindamage in the old Linux ELF dynamic
    linker.  */
-weak_alias (__curbrk, ___brk_addr)
+compat_symbol (libc, __curbrk, ___brk_addr, GLIBC_2_0);
+#endif
 
 int
 __brk (void *addr)