Version script help needed
H. J. Lu
hjl@lucon.org
Mon Aug 5 10:23:00 GMT 2002
On Mon, Aug 05, 2002 at 10:18:28AM -0700, H. J. Lu wrote:
> >
> > And I wanted to accomplish that without having an explicit .symver for the
> > VERNEW symbol version.
> >
> > I think I just don't understand how the symbol matching in a version script
> > works. With this script:
> >
> > VEROLD {
> > global:
> > divdi3;
> > };
> >
> > VERNEW {
> > global:
> > divdi3;
> > local:
> > *;
> > } VEROLD;
> >
>
> Here is a patch to do that. However, I am sure if it is %100 correct.
> Any comments with testcases?
>
>
Ooops. I forgot to free the memory. Here is the new one. I will add
a new ld testcase if it is the right thing to do.
H.J.
-------------- next part --------------
bfd/
2002-08-05 H.J. Lu <hjl@gnu.org>
* elflink.h (elf_link_assign_sym_version): Don't match a
default version if there is a hidden versioned definition.
--- bfd/elflink.h.defver Fri Jul 26 23:41:26 2002
+++ bfd/elflink.h Mon Aug 5 10:21:03 2002
@@ -4274,6 +4274,10 @@ elf_link_assign_sym_version (h, data)
struct bfd_elf_version_tree *t;
struct bfd_elf_version_tree *local_ver;
struct bfd_elf_version_expr *d;
+ const char *verstr, *name;
+ size_t namelen, verlen, newlen;
+ char *newname;
+ struct elf_link_hash_entry *newh;
/* See if can find what version this symbol is in. If the
symbol is supposed to be local, then don't actually register
@@ -4287,9 +4291,39 @@ elf_link_assign_sym_version (h, data)
{
if ((*d->match) (d, h->root.root.string))
{
- h->verinfo.vertree = t;
- local_ver = NULL;
- break;
+ name = h->root.root.string;
+ namelen = strlen (name);
+ verstr = t->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);
+ free (newname);
+
+ if (!newh
+ || ((newh->root.type
+ != bfd_link_hash_defined)
+ && (newh->root.type
+ != bfd_link_hash_defweak)))
+ {
+ /* We didn't find the hidden versioned
+ definition. Use it. */
+ h->verinfo.vertree = t;
+ local_ver = NULL;
+ break;
+ }
}
}
@@ -4332,11 +4366,6 @@ elf_link_assign_sym_version (h, data)
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;
More information about the Binutils
mailing list