Re: gnulib's obstack_* symbols in dynamic exports on glibc. Intentional?

2022-12-30 Thread Sergei Trofimovich
On Fri, 30 Dec 2022 19:26:48 +0100
Bruno Haible  wrote:

> Sergei Trofimovich wrote:
> > to my surprise it did have one a set of dynamically exported symbols:
> > 
> > $ nm -D `which ls` | grep -v '^ '
> > 004c0d40 T _obstack_allocated_p
> > 00534808 D obstack_alloc_failed_handler
> > 004c0bd0 T _obstack_begin
> > 004c0bf0 T _obstack_begin_1
> > 004c0d80 T _obstack_free
> > 004c0e00 T _obstack_memory_used
> > 004c0c10 T _obstack_newchunk  
> 
> There's already a discussion on this topic, that started at
>   https://lists.gnu.org/archive/html/bug-gnulib/2022-12/msg7.html

Aha, thank you!

-- 

  Sergei



Re: gnulib's obstack_* symbols in dynamic exports on glibc. Intentional?

2022-12-30 Thread Bruno Haible
Sergei Trofimovich wrote:
> to my surprise it did have one a set of dynamically exported symbols:
> 
> $ nm -D `which ls` | grep -v '^ '
> 004c0d40 T _obstack_allocated_p
> 00534808 D obstack_alloc_failed_handler
> 004c0bd0 T _obstack_begin
> 004c0bf0 T _obstack_begin_1
> 004c0d80 T _obstack_free
> 004c0e00 T _obstack_memory_used
> 004c0c10 T _obstack_newchunk

There's already a discussion on this topic, that started at
  https://lists.gnu.org/archive/html/bug-gnulib/2022-12/msg7.html

Bruno






gnulib's obstack_* symbols in dynamic exports on glibc. Intentional?

2022-12-30 Thread Sergei Trofimovich
Hello bug-gnulib (and libc-alpha, CCed)!

The other day I was looking at simplest programs to make sure they don't
normally have dynamic exports. I picked coreutils-9.1 'ls'. And to my
surprise it did have one a set of dynamically exported symbols:

$ nm -D `which ls` | grep -v '^ '
004c0d40 T _obstack_allocated_p
00534808 D obstack_alloc_failed_handler
004c0bd0 T _obstack_begin
004c0bf0 T _obstack_begin_1
004c0d80 T _obstack_free
004c0e00 T _obstack_memory_used
004c0c10 T _obstack_newchunk

That was a surprise to me. I think they are exported because gnulib
defines them in obstack.c.

AFAIU gnulib assumes that local implementation is better that glibc's
as it supports 64-bit object sizes.

I think ld decides to put symbols into dynamic exports to make sure
local symbols intended to override glibc's need to propagate to glibc
and other libraries that might use it.

Questions:

1. Is it a safe override to mangle symbols ilke that?

   Or would glibc's versioned symbols be used just fine by existing
   libraries?

   $ nm -D /lib/libc.so.6 | fgrep obstack
   00201338 B _obstack@GLIBC_2.2.5
   0009aa70 T _obstack_allocated_p@@GLIBC_2.2.5
   001fb338 D obstack_alloc_failed_handler@@GLIBC_2.2.5
   0009a780 T _obstack_begin@@GLIBC_2.2.5
   0009a840 T _obstack_begin_1@@GLIBC_2.2.5
   001fa208 D obstack_exit_failure@@GLIBC_2.2.5
   0009aab0 T _obstack_free@@GLIBC_2.2.5
   0009aab0 T obstack_free@@GLIBC_2.2.5
   0009ab40 T _obstack_memory_used@@GLIBC_2.2.5
   0009a900 T _obstack_newchunk@@GLIBC_2.2.5
   0007e110 W obstack_printf@@GLIBC_2.2.5
   0011e9c0 T __obstack_printf_chk@@GLIBC_2.8
   0007e100 W obstack_vprintf@@GLIBC_2.2.5
   0011ea80 T __obstack_vprintf_chk@@GLIBC_2.8

2. Would it be feasible to avoid dynamic symbol export and maybe rename
   gnulib's symbols to avoid clash with glibc?

   I would expect loading to be a tiny bit faster for binaries without
   dynamic exports like that.

Thanks!

-- 

  Sergei