* A symbol version bug? @ 2002-07-12 21:35 H. J. Lu 2002-07-12 22:43 ` H. J. Lu 0 siblings, 1 reply; 11+ messages in thread From: H. J. Lu @ 2002-07-12 21:35 UTC (permalink / raw) To: binutils; +Cc: howarth [-- Attachment #1: Type: text/plain, Size: 394 bytes --] I got # make cc -fPIC -c c1.c cc -fPIC -c c2.c ld --version-script=c.map -shared -o lib-c1.so c1.o c2.o objdump --dynamic-sym lib-c1.so| grep bar 00000264 g DF .text 0000000a VERS.0 bar 00000258 g DF .text 0000000a (VERS.0) bar I am expecting ... objdump --dynamic-sym lib-c1.so| grep bar xxxxxxxx g DF .text 0000000a (VERS.0) bar I will see what I can do. H.J. [-- Attachment #2: bug.tar.gz --] [-- Type: application/x-gzip, Size: 480 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: A symbol version bug? 2002-07-12 21:35 A symbol version bug? H. J. Lu @ 2002-07-12 22:43 ` H. J. Lu 2002-07-14 0:32 ` PACTH: Fix duplicated version (Re: A symbol version bug?) H. J. Lu 0 siblings, 1 reply; 11+ messages in thread From: H. J. Lu @ 2002-07-12 22:43 UTC (permalink / raw) To: binutils; +Cc: howarth On Fri, Jul 12, 2002 at 08:51:03PM -0700, H. J. Lu wrote: > I got > > # make > cc -fPIC -c c1.c > cc -fPIC -c c2.c > ld --version-script=c.map -shared -o lib-c1.so c1.o c2.o > objdump --dynamic-sym lib-c1.so| grep bar > 00000264 g DF .text 0000000a VERS.0 bar > 00000258 g DF .text 0000000a (VERS.0) bar > > I am expecting > Corretion. I am expecting a fatal error. H.J. ^ permalink raw reply [flat|nested] 11+ messages in thread
* PACTH: Fix duplicated version (Re: A symbol version bug?) 2002-07-12 22:43 ` H. J. Lu @ 2002-07-14 0:32 ` H. J. Lu 2002-07-14 7:09 ` H. J. Lu 0 siblings, 1 reply; 11+ messages in thread From: H. J. Lu @ 2002-07-14 0:32 UTC (permalink / raw) To: binutils; +Cc: howarth [-- Attachment #1: Type: text/plain, Size: 891 bytes --] On Fri, Jul 12, 2002 at 10:43:33PM -0700, H. J. Lu wrote: > On Fri, Jul 12, 2002 at 08:51:03PM -0700, H. J. Lu wrote: > > I got > > > > # make > > cc -fPIC -c c1.c > > cc -fPIC -c c2.c > > ld --version-script=c.map -shared -o lib-c1.so c1.o c2.o > > objdump --dynamic-sym lib-c1.so| grep bar > > 00000264 g DF .text 0000000a VERS.0 bar > > 00000258 g DF .text 0000000a (VERS.0) bar > > > > I am expecting > > > > Corretion. I am expecting a fatal error. > Here is the patch. Now I got /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new -soname lib-c.so --version-script=c.map -shared -o lib-c1.so c1.o c2.o /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new: foo (c2.o): duplicated versioned symbol: foo@VERS.0 (c1.o) /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new: failed to set dynamic section sizes: Bad value H.J. [-- Attachment #2: bfd-version-dup.patch --] [-- Type: text/plain, Size: 2016 bytes --] 2002-07-13 H.J. Lu <hjl@gnu.org> * elflink.h (elf_link_assign_sym_version): Bail out if a symbol with a default version conflicts with a hidden symbol with the same version. --- bfd/elflink.h.dup Mon Jul 8 08:58:42 2002 +++ bfd/elflink.h Sat Jul 13 19:48:37 2002 @@ -4345,6 +4345,7 @@ elf_link_assign_sym_version (h, data) (_("%s: undefined versioned symbol name %s"), bfd_get_filename (sinfo->output_bfd), h->root.root.string); bfd_set_error (bfd_error_bad_value); +error_return: sinfo->failed = true; return false; } @@ -4416,6 +4417,52 @@ elf_link_assign_sym_version (h, data) (*bed->elf_backend_hide_symbol) (info, h, true); } } + + /* We need to check if there is a conflict. */ + if (h->dynindx != -1) + { + const char *verstr, *name; + size_t namelen, verlen, newlen; + char *newname, *p; + struct elf_link_hash_entry *newh; + + name = h->root.root.string; + namelen = strlen (name); + verstr = h->verinfo.vertree->name; + verlen = strlen (verstr); + newlen = namelen + verlen + 2; + + newname = (char *) bfd_malloc ((bfd_size_type) newlen); + if (newname == NULL) + { + bfd_set_error (bfd_error_no_memory); + goto error_return; + } + memcpy (newname, name, namelen); + + /* Check the hidden symbol. */ + p = newname + namelen; + *p++ = ELF_VER_CHR; + memcpy (p, verstr, verlen + 1); + newh = elf_link_hash_lookup (elf_hash_table (info), newname, + false, false, false); + + if (newh && newh->root.type == bfd_link_hash_defined) + { + /* We find a versioned definition. Bail out. */ + (*_bfd_error_handler) + (_("%s (%s): duplicated versioned symbol: %s (%s)"), + h->root.root.string, + bfd_get_filename (h->root.u.def.section->owner), + newname, + bfd_get_filename (newh->root.u.def.section->owner)); + free (newname); + bfd_set_error (bfd_error_bad_value); + goto error_return; + } + + free (newname); + } } return true; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PACTH: Fix duplicated version (Re: A symbol version bug?) 2002-07-14 0:32 ` PACTH: Fix duplicated version (Re: A symbol version bug?) H. J. Lu @ 2002-07-14 7:09 ` H. J. Lu 2002-07-14 7:12 ` H. J. Lu 2002-07-14 8:43 ` Alan Modra 0 siblings, 2 replies; 11+ messages in thread From: H. J. Lu @ 2002-07-14 7:09 UTC (permalink / raw) To: binutils; +Cc: howarth [-- Attachment #1: Type: text/plain, Size: 2114 bytes --] On Sat, Jul 13, 2002 at 07:56:44PM -0700, H. J. Lu wrote: > On Fri, Jul 12, 2002 at 10:43:33PM -0700, H. J. Lu wrote: > > On Fri, Jul 12, 2002 at 08:51:03PM -0700, H. J. Lu wrote: > > > I got > > > > > > # make > > > cc -fPIC -c c1.c > > > cc -fPIC -c c2.c > > > ld --version-script=c.map -shared -o lib-c1.so c1.o c2.o > > > objdump --dynamic-sym lib-c1.so| grep bar > > > 00000264 g DF .text 0000000a VERS.0 bar > > > 00000258 g DF .text 0000000a (VERS.0) bar > > > > > > I am expecting > > > > > > > Corretion. I am expecting a fatal error. > > > > Here is the patch. Now I got > > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new -soname > lib-c.so --version-script=c.map -shared -o lib-c1.so c1.o c2.o > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new: foo (c2.o): > duplicated versioned symbol: foo@VERS.0 (c1.o) > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new: failed to set > dynamic section sizes: Bad value > Second thought. I think it should work. Here is the new patch and a testcase. Now I got: # make cc -c -o foo.o foo.c cc -c -o c0.o c0.c cc -Wl,-soname,lib-c.so -shared -o lib-c.so c0.o cc -o foo -Wl,-rpath,. foo.o lib-c.so cc -fPIC -c c1.c cc -fPIC -c c2.c /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new -soname lib-c.so --version-script=c.map -shared -o lib-c1.so c1.o c2.o /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new -soname lib-c.so --version-script=c.map -shared -o lib-c2.so c2.o c1.o objdump --dynamic-sym lib-c1.so | grep VER 00000280 g DF .text 00000021 (VERS.0) foo 00000000 g DO *ABS* 00000000 VERS.0 VERS.0 0000025c g DF .text 00000021 (VERS.0) bar objdump --dynamic-sym lib-c2.so | grep VER 0000028c g DF .text 00000021 (VERS.0) foo 00000000 g DO *ABS* 00000000 VERS.0 VERS.0 00000268 g DF .text 00000021 (VERS.0) bar ./foo bar: 0 foo: 0 cp lib-c1.so lib-c.so ./foo bar: 1 foo: 2 cp lib-c2.so lib-c.so ./foo bar: 1 foo: 2 Jack, please try this to see if gcc 2.95.4 works without any glibc changes. H.J. [-- Attachment #2: bug.tar.gz --] [-- Type: application/x-gzip, Size: 798 bytes --] [-- Attachment #3: bfd-version-dup.patch --] [-- Type: text/plain, Size: 1770 bytes --] 2002-07-14 H.J. Lu <hjl@gnu.org> * elflink.h (elf_link_assign_sym_version): Hide the default definition if there is a hidden versioned definition. --- bfd/elflink.h.dup Mon Jul 8 08:58:42 2002 +++ bfd/elflink.h Sun Jul 14 06:49:57 2002 @@ -4345,6 +4345,7 @@ elf_link_assign_sym_version (h, data) (_("%s: undefined versioned symbol name %s"), bfd_get_filename (sinfo->output_bfd), h->root.root.string); bfd_set_error (bfd_error_bad_value); +error_return: sinfo->failed = true; return false; } @@ -4416,6 +4417,44 @@ elf_link_assign_sym_version (h, data) (*bed->elf_backend_hide_symbol) (info, h, true); } } + + /* We need to check if a hidden versioned definition should + override the default one. */ + if (h->dynindx != -1) + { + const char *verstr, *name; + size_t namelen, verlen, newlen; + char *newname; + struct elf_link_hash_entry *newh; + + name = h->root.root.string; + namelen = strlen (name); + verstr = h->verinfo.vertree->name; + verlen = strlen (verstr); + newlen = namelen + verlen + 2; + + newname = (char *) bfd_malloc ((bfd_size_type) newlen); + if (newname == NULL) + { + bfd_set_error (bfd_error_no_memory); + goto error_return; + } + memcpy (newname, name, namelen); + + /* Check the hidden versioned definition. */ + p = newname + namelen; + *p++ = ELF_VER_CHR; + memcpy (p, verstr, verlen + 1); + newh = elf_link_hash_lookup (elf_hash_table (info), newname, + false, false, false); + + if (newh && newh->root.type == bfd_link_hash_defined) + /* We find a versioned definition. Hide the default + one. */ + (*bed->elf_backend_hide_symbol) (info, h, true); + + free (newname); + } } return true; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PACTH: Fix duplicated version (Re: A symbol version bug?) 2002-07-14 7:09 ` H. J. Lu @ 2002-07-14 7:12 ` H. J. Lu 2002-07-14 7:46 ` H. J. Lu 2002-07-14 8:43 ` Alan Modra 1 sibling, 1 reply; 11+ messages in thread From: H. J. Lu @ 2002-07-14 7:12 UTC (permalink / raw) To: binutils; +Cc: howarth [-- Attachment #1: Type: text/plain, Size: 2343 bytes --] On Sun, Jul 14, 2002 at 06:56:20AM -0700, H. J. Lu wrote: > On Sat, Jul 13, 2002 at 07:56:44PM -0700, H. J. Lu wrote: > > On Fri, Jul 12, 2002 at 10:43:33PM -0700, H. J. Lu wrote: > > > On Fri, Jul 12, 2002 at 08:51:03PM -0700, H. J. Lu wrote: > > > > I got > > > > > > > > # make > > > > cc -fPIC -c c1.c > > > > cc -fPIC -c c2.c > > > > ld --version-script=c.map -shared -o lib-c1.so c1.o c2.o > > > > objdump --dynamic-sym lib-c1.so| grep bar > > > > 00000264 g DF .text 0000000a VERS.0 bar > > > > 00000258 g DF .text 0000000a (VERS.0) bar > > > > > > > > I am expecting > > > > > > > > > > Corretion. I am expecting a fatal error. > > > > > > > Here is the patch. Now I got > > > > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new -soname > > lib-c.so --version-script=c.map -shared -o lib-c1.so c1.o c2.o > > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new: foo (c2.o): > > duplicated versioned symbol: foo@VERS.0 (c1.o) > > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new: failed to set > > dynamic section sizes: Bad value > > > > Second thought. I think it should work. Here is the new patch and a > testcase. Now I got: > > # make > cc -c -o foo.o foo.c > cc -c -o c0.o c0.c > cc -Wl,-soname,lib-c.so -shared -o lib-c.so c0.o > cc -o foo -Wl,-rpath,. foo.o lib-c.so > cc -fPIC -c c1.c > cc -fPIC -c c2.c > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new -soname > lib-c.so --version-script=c.map -shared -o lib-c1.so c1.o c2.o > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new -soname lib-c.so --version-script=c.map -shared -o lib-c2.so c2.o c1.o > objdump --dynamic-sym lib-c1.so | grep VER > 00000280 g DF .text 00000021 (VERS.0) foo > 00000000 g DO *ABS* 00000000 VERS.0 VERS.0 > 0000025c g DF .text 00000021 (VERS.0) bar > objdump --dynamic-sym lib-c2.so | grep VER > 0000028c g DF .text 00000021 (VERS.0) foo > 00000000 g DO *ABS* 00000000 VERS.0 VERS.0 > 00000268 g DF .text 00000021 (VERS.0) bar > ./foo > bar: 0 > foo: 0 > cp lib-c1.so lib-c.so > ./foo > bar: 1 > foo: 2 > cp lib-c2.so lib-c.so > ./foo > bar: 1 > foo: 2 > > Jack, please try this to see if gcc 2.95.4 works without any glibc > changes. > Ooops. Wrong one. Please use this one. H.J. [-- Attachment #2: bfd-version-dup.patch --] [-- Type: text/plain, Size: 1800 bytes --] 2002-07-14 H.J. Lu <hjl@gnu.org> * elflink.h (elf_link_assign_sym_version): Hide the default definition if there is a hidden versioned definition. --- bfd/elflink.h.dup Mon Jul 8 08:58:42 2002 +++ bfd/elflink.h Sun Jul 14 07:06:31 2002 @@ -4345,6 +4345,7 @@ elf_link_assign_sym_version (h, data) (_("%s: undefined versioned symbol name %s"), bfd_get_filename (sinfo->output_bfd), h->root.root.string); bfd_set_error (bfd_error_bad_value); +error_return: sinfo->failed = true; return false; } @@ -4416,6 +4417,44 @@ elf_link_assign_sym_version (h, data) (*bed->elf_backend_hide_symbol) (info, h, true); } } + + /* We need to check if a hidden versioned definition should + override the default one. */ + if (h->dynindx != -1 && h->verinfo.vertree != NULL) + { + const char *verstr, *name; + size_t namelen, verlen, newlen; + char *newname; + struct elf_link_hash_entry *newh; + + name = h->root.root.string; + namelen = strlen (name); + verstr = h->verinfo.vertree->name; + verlen = strlen (verstr); + newlen = namelen + verlen + 2; + + newname = (char *) bfd_malloc ((bfd_size_type) newlen); + if (newname == NULL) + { + bfd_set_error (bfd_error_no_memory); + goto error_return; + } + memcpy (newname, name, namelen); + + /* Check the hidden versioned definition. */ + p = newname + namelen; + *p++ = ELF_VER_CHR; + memcpy (p, verstr, verlen + 1); + newh = elf_link_hash_lookup (elf_hash_table (info), newname, + false, false, false); + + if (newh && newh->root.type == bfd_link_hash_defined) + /* We find a versioned definition. Hide the default + one. */ + (*bed->elf_backend_hide_symbol) (info, h, true); + + free (newname); + } } return true; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PACTH: Fix duplicated version (Re: A symbol version bug?) 2002-07-14 7:12 ` H. J. Lu @ 2002-07-14 7:46 ` H. J. Lu 2002-07-14 16:33 ` Jack Howarth 0 siblings, 1 reply; 11+ messages in thread From: H. J. Lu @ 2002-07-14 7:46 UTC (permalink / raw) To: binutils; +Cc: howarth [-- Attachment #1: Type: text/plain, Size: 2604 bytes --] On Sun, Jul 14, 2002 at 07:09:53AM -0700, H. J. Lu wrote: > On Sun, Jul 14, 2002 at 06:56:20AM -0700, H. J. Lu wrote: > > On Sat, Jul 13, 2002 at 07:56:44PM -0700, H. J. Lu wrote: > > > On Fri, Jul 12, 2002 at 10:43:33PM -0700, H. J. Lu wrote: > > > > On Fri, Jul 12, 2002 at 08:51:03PM -0700, H. J. Lu wrote: > > > > > I got > > > > > > > > > > # make > > > > > cc -fPIC -c c1.c > > > > > cc -fPIC -c c2.c > > > > > ld --version-script=c.map -shared -o lib-c1.so c1.o c2.o > > > > > objdump --dynamic-sym lib-c1.so| grep bar > > > > > 00000264 g DF .text 0000000a VERS.0 bar > > > > > 00000258 g DF .text 0000000a (VERS.0) bar > > > > > > > > > > I am expecting > > > > > > > > > > > > > Corretion. I am expecting a fatal error. > > > > > > > > > > Here is the patch. Now I got > > > > > > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new -soname > > > lib-c.so --version-script=c.map -shared -o lib-c1.so c1.o c2.o > > > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new: foo (c2.o): > > > duplicated versioned symbol: foo@VERS.0 (c1.o) > > > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new: failed to set > > > dynamic section sizes: Bad value > > > > > > > Second thought. I think it should work. Here is the new patch and a > > testcase. Now I got: > > > > # make > > cc -c -o foo.o foo.c > > cc -c -o c0.o c0.c > > cc -Wl,-soname,lib-c.so -shared -o lib-c.so c0.o > > cc -o foo -Wl,-rpath,. foo.o lib-c.so > > cc -fPIC -c c1.c > > cc -fPIC -c c2.c > > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new -soname > > lib-c.so --version-script=c.map -shared -o lib-c1.so c1.o c2.o > > /export/build/gnu/binutils-debug/build-full-i686-linux/ld/ld-new -soname lib-c.so --version-script=c.map -shared -o lib-c2.so c2.o c1.o > > objdump --dynamic-sym lib-c1.so | grep VER > > 00000280 g DF .text 00000021 (VERS.0) foo > > 00000000 g DO *ABS* 00000000 VERS.0 VERS.0 > > 0000025c g DF .text 00000021 (VERS.0) bar > > objdump --dynamic-sym lib-c2.so | grep VER > > 0000028c g DF .text 00000021 (VERS.0) foo > > 00000000 g DO *ABS* 00000000 VERS.0 VERS.0 > > 00000268 g DF .text 00000021 (VERS.0) bar > > ./foo > > bar: 0 > > foo: 0 > > cp lib-c1.so lib-c.so > > ./foo > > bar: 1 > > foo: 2 > > cp lib-c2.so lib-c.so > > ./foo > > bar: 1 > > foo: 2 > > > > Jack, please try this to see if gcc 2.95.4 works without any glibc > > changes. > > > > Ooops. Wrong one. Please use this one. > > Ooops. I missed the weak definition. Here is the new patch. H.J. [-- Attachment #2: bfd-version-dup.patch --] [-- Type: text/plain, Size: 1862 bytes --] 2002-07-14 H.J. Lu <hjl@gnu.org> * elflink.h (elf_link_assign_sym_version): Hide the default definition if there is a hidden versioned definition. --- bfd/elflink.h.dup Mon Jul 8 08:58:42 2002 +++ bfd/elflink.h Sun Jul 14 07:41:59 2002 @@ -4345,6 +4345,7 @@ elf_link_assign_sym_version (h, data) (_("%s: undefined versioned symbol name %s"), bfd_get_filename (sinfo->output_bfd), h->root.root.string); bfd_set_error (bfd_error_bad_value); +error_return: sinfo->failed = true; return false; } @@ -4416,6 +4417,46 @@ elf_link_assign_sym_version (h, data) (*bed->elf_backend_hide_symbol) (info, h, true); } } + + /* We need to check if a hidden versioned definition should + hide the default one. */ + if (h->dynindx != -1 && h->verinfo.vertree != NULL) + { + const char *verstr, *name; + size_t namelen, verlen, newlen; + char *newname; + struct elf_link_hash_entry *newh; + + name = h->root.root.string; + namelen = strlen (name); + verstr = h->verinfo.vertree->name; + verlen = strlen (verstr); + newlen = namelen + verlen + 2; + + newname = (char *) bfd_malloc ((bfd_size_type) newlen); + if (newname == NULL) + { + bfd_set_error (bfd_error_no_memory); + goto error_return; + } + memcpy (newname, name, namelen); + + /* Check the hidden versioned definition. */ + p = newname + namelen; + *p++ = ELF_VER_CHR; + memcpy (p, verstr, verlen + 1); + newh = elf_link_hash_lookup (elf_hash_table (info), newname, + false, false, false); + + if (newh + && (newh->root.type == bfd_link_hash_defined + || newh->root.type == bfd_link_hash_defweak)) + /* We find a hidden versioned definition. Hide the default + one. */ + (*bed->elf_backend_hide_symbol) (info, h, true); + + free (newname); + } } return true; ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PACTH: Fix duplicated version (Re: A symbol version bug?) 2002-07-14 7:46 ` H. J. Lu @ 2002-07-14 16:33 ` Jack Howarth 0 siblings, 0 replies; 11+ messages in thread From: Jack Howarth @ 2002-07-14 16:33 UTC (permalink / raw) To: H. J. Lu; +Cc: binutils HJ, Using this last version of the patch, applied to binutils 2.12.90.0.14, I was able to build a binutils which passed all of make check. Using this new binutils, I was able to build debian's current glibc 2.2.5-9 package with the libgcc-compat patch added in. There were no link problems with libc6.so this time with the patched binutils and the resulting glibc passes all of make check. Looks like this might be the fix we need. Jack ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PACTH: Fix duplicated version (Re: A symbol version bug?) 2002-07-14 7:09 ` H. J. Lu 2002-07-14 7:12 ` H. J. Lu @ 2002-07-14 8:43 ` Alan Modra 2002-07-14 16:38 ` H. J. Lu 1 sibling, 1 reply; 11+ messages in thread From: Alan Modra @ 2002-07-14 8:43 UTC (permalink / raw) To: H. J. Lu; +Cc: binutils, howarth On Sun, Jul 14, 2002 at 06:56:20AM -0700, H. J. Lu wrote: > On Sat, Jul 13, 2002 at 07:56:44PM -0700, H. J. Lu wrote: > > On Fri, Jul 12, 2002 at 10:43:33PM -0700, H. J. Lu wrote: > > > On Fri, Jul 12, 2002 at 08:51:03PM -0700, H. J. Lu wrote: > > > > I am expecting > > > Corretion. I am expecting a fatal error. > Second thought. I think it should work. That's quite a few changes of mind. :) Can you tell us why you "think it should work"? Why doesn't bar defined by __asm__(".symver _old_bar,bar@VERS.0"); not conflict with another bar, set to VERS.0 by a version script? -- Alan Modra IBM OzLabs - Linux Technology Centre ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PACTH: Fix duplicated version (Re: A symbol version bug?) 2002-07-14 8:43 ` Alan Modra @ 2002-07-14 16:38 ` H. J. Lu 2002-07-14 18:37 ` Alan Modra 0 siblings, 1 reply; 11+ messages in thread From: H. J. Lu @ 2002-07-14 16:38 UTC (permalink / raw) To: binutils, howarth On Mon, Jul 15, 2002 at 01:08:09AM +0930, Alan Modra wrote: > On Sun, Jul 14, 2002 at 06:56:20AM -0700, H. J. Lu wrote: > > On Sat, Jul 13, 2002 at 07:56:44PM -0700, H. J. Lu wrote: > > > On Fri, Jul 12, 2002 at 10:43:33PM -0700, H. J. Lu wrote: > > > > On Fri, Jul 12, 2002 at 08:51:03PM -0700, H. J. Lu wrote: > > > > > I am expecting > > > > Corretion. I am expecting a fatal error. > > Second thought. I think it should work. > > That's quite a few changes of mind. :) Can you tell us why you "think > it should work"? Why doesn't bar defined by > __asm__(".symver _old_bar,bar@VERS.0"); > not conflict with another bar, set to VERS.0 by a version script? That is because by using __asm__(".symver _old_bar,bar@VERS.0"); the intention is the definition of bar with version VERS.0 is _old_bar, The version script only specifies there is a bar with version VERS.0, nothing more. As my testcase show, it has its use. H.J. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PACTH: Fix duplicated version (Re: A symbol version bug?) 2002-07-14 16:38 ` H. J. Lu @ 2002-07-14 18:37 ` Alan Modra 2002-07-14 19:11 ` H. J. Lu 0 siblings, 1 reply; 11+ messages in thread From: Alan Modra @ 2002-07-14 18:37 UTC (permalink / raw) To: H. J. Lu; +Cc: binutils, howarth On Sun, Jul 14, 2002 at 04:32:52PM -0700, H. J. Lu wrote: > On Mon, Jul 15, 2002 at 01:08:09AM +0930, Alan Modra wrote: > > That's quite a few changes of mind. :) Can you tell us why you "think > > it should work"? Why doesn't bar defined by > > __asm__(".symver _old_bar,bar@VERS.0"); > > not conflict with another bar, set to VERS.0 by a version script? > > That is because by using > > __asm__(".symver _old_bar,bar@VERS.0"); > > the intention is the definition of bar with version VERS.0 is _old_bar, > The version script only specifies there is a bar with version VERS.0, > nothing more. As my testcase show, it has its use. I suppose it's fair enough to say that a .symver takes precedence over a version script. Would you please make a note of this in ld.texinfo? Your patch is OK, but remove the unnecessary bfd_set_error on malloc failure. bfd_malloc will do this for you. -- Alan Modra IBM OzLabs - Linux Technology Centre ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: PACTH: Fix duplicated version (Re: A symbol version bug?) 2002-07-14 18:37 ` Alan Modra @ 2002-07-14 19:11 ` H. J. Lu 0 siblings, 0 replies; 11+ messages in thread From: H. J. Lu @ 2002-07-14 19:11 UTC (permalink / raw) To: binutils, howarth [-- Attachment #1: Type: text/plain, Size: 1062 bytes --] On Mon, Jul 15, 2002 at 10:17:44AM +0930, Alan Modra wrote: > On Sun, Jul 14, 2002 at 04:32:52PM -0700, H. J. Lu wrote: > > On Mon, Jul 15, 2002 at 01:08:09AM +0930, Alan Modra wrote: > > > That's quite a few changes of mind. :) Can you tell us why you "think > > > it should work"? Why doesn't bar defined by > > > __asm__(".symver _old_bar,bar@VERS.0"); > > > not conflict with another bar, set to VERS.0 by a version script? > > > > That is because by using > > > > __asm__(".symver _old_bar,bar@VERS.0"); > > > > the intention is the definition of bar with version VERS.0 is _old_bar, > > The version script only specifies there is a bar with version VERS.0, > > nothing more. As my testcase show, it has its use. > > I suppose it's fair enough to say that a .symver takes precedence over > a version script. Would you please make a note of this in ld.texinfo? > Your patch is OK, but remove the unnecessary bfd_set_error on malloc > failure. bfd_malloc will do this for you. Ok. Here is the updated one. I will check it in shortly. Thanks. H.J. [-- Attachment #2: bfd-version-dup.patch --] [-- Type: text/plain, Size: 2610 bytes --] bfd/ 2002-07-14 H.J. Lu <hjl@gnu.org> * elflink.h (elf_link_assign_sym_version): Hide the default definition if there is a hidden versioned definition. ld/ 2002-07-14 H.J. Lu <hjl@gnu.org> * ld.texinfo: Document a .symver takes precedence over a version script. --- binutils/bfd/elflink.h.dup Mon Jul 8 08:58:42 2002 +++ binutils/bfd/elflink.h Sun Jul 14 18:25:09 2002 @@ -4345,6 +4345,7 @@ elf_link_assign_sym_version (h, data) (_("%s: undefined versioned symbol name %s"), bfd_get_filename (sinfo->output_bfd), h->root.root.string); bfd_set_error (bfd_error_bad_value); +error_return: sinfo->failed = true; return false; } @@ -4416,6 +4417,43 @@ elf_link_assign_sym_version (h, data) (*bed->elf_backend_hide_symbol) (info, h, true); } } + + /* We need to check if a hidden versioned definition should + hide the default one. */ + if (h->dynindx != -1 && h->verinfo.vertree != NULL) + { + const char *verstr, *name; + size_t namelen, verlen, newlen; + char *newname; + struct elf_link_hash_entry *newh; + + name = h->root.root.string; + namelen = strlen (name); + verstr = h->verinfo.vertree->name; + verlen = strlen (verstr); + newlen = namelen + verlen + 2; + + newname = (char *) bfd_malloc ((bfd_size_type) newlen); + if (newname == NULL) + goto error_return; + memcpy (newname, name, namelen); + + /* Check the hidden versioned definition. */ + p = newname + namelen; + *p++ = ELF_VER_CHR; + memcpy (p, verstr, verlen + 1); + newh = elf_link_hash_lookup (elf_hash_table (info), newname, + false, false, false); + + if (newh + && (newh->root.type == bfd_link_hash_defined + || newh->root.type == bfd_link_hash_defweak)) + /* We find a hidden versioned definition. Hide the default + one. */ + (*bed->elf_backend_hide_symbol) (info, h, true); + + free (newname); + } } return true; --- binutils/ld/ld.texinfo.dup Sat Jun 22 21:49:03 2002 +++ binutils/ld/ld.texinfo Sun Jul 14 18:36:02 2002 @@ -3762,7 +3762,8 @@ __asm__(".symver original_foo,foo@@VERS_ in the C source file. This renames the function @samp{original_foo} to be an alias for @samp{foo} bound to the version node @samp{VERS_1.1}. The @samp{local:} directive can be used to prevent the symbol -@samp{original_foo} from being exported. +@samp{original_foo} from being exported. A @samp{.symver} directive +takes precedence over a version script. The second GNU extension is to allow multiple versions of the same function to appear in a given shared library. In this way you can make ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2002-07-15 1:37 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-07-12 21:35 A symbol version bug? H. J. Lu 2002-07-12 22:43 ` H. J. Lu 2002-07-14 0:32 ` PACTH: Fix duplicated version (Re: A symbol version bug?) H. J. Lu 2002-07-14 7:09 ` H. J. Lu 2002-07-14 7:12 ` H. J. Lu 2002-07-14 7:46 ` H. J. Lu 2002-07-14 16:33 ` Jack Howarth 2002-07-14 8:43 ` Alan Modra 2002-07-14 16:38 ` H. J. Lu 2002-07-14 18:37 ` Alan Modra 2002-07-14 19:11 ` 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).