public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: Ian Lance Taylor <iant@google.com>
Cc: binutils@sourceware.org
Subject: Re: version scripts and default/C language mangling
Date: Mon, 19 Jul 2010 23:34:00 -0000	[thread overview]
Message-ID: <201007191931.02766.vapier@gentoo.org> (raw)
In-Reply-To: <mcrvd8lt9ap.fsf@google.com>

[-- Attachment #1: Type: Text/Plain, Size: 3740 bytes --]

On Monday, July 12, 2010 04:05:02 Ian Lance Taylor wrote:
> Mike Frysinger writes:
> > first, i'm asking what the default language is for the version script. 
> > i'd expect the answer to be "no language" which means the symbols would
> > be matched against any random leading char a target introduces.  i'm
> > also OK with the answer "C language", although it does prevent working
> > with symbols that lack the prefix char because they were created via
> > assembly code.
> 
> The default language is "C".  I think the right thing to do in that case
> is strip the leading character if present, and otherwise do nothing.
> That is what bfd_demangle does.

works for me

> > yes, but presumably changing ldlang.c to consider that value is
> > unacceptable. the current parsing code is also not given the current
> > bfd, only bfd_elf_version_expr structures, and those dont contain links
> > back to a bfd that i can see.  unless there is a way to get the current
> > "active" bfd ?  then it should be easy to drop in support in
> > lang_vers_match() with the function bfd_get_symbol_leading_char() you
> > pointed out.
> 
> I think it would be entirely reasonable to change lang_vers_match to
> take a BFD parameter, and change the corresponding calling code in
> bfd/elflink.c.  Or, the output BFD is always available in
> link_info.output_bfd.

since the existing bfd_demangle user in this file is using
link_info.output_bfd, i'm going to roll with that.

how does the attached patch look ?  seems to fix things with Blackfin targets,
and no regressions are seen with x86_64-linux-gnu and bfin-linux-uclibc.

i'll do some more system wide testing in the mean time ...
-mike

diff --git a/ld/ldlang.c b/ld/ldlang.c
index 9c4e17b..5875ef6 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7179,19 +7179,28 @@ lang_vers_match (struct bfd_elf_version_expr_head *head,
 		 struct bfd_elf_version_expr *prev,
 		 const char *sym)
 {
+  const char *c_sym;
   const char *cxx_sym = sym;
   const char *java_sym = sym;
   struct bfd_elf_version_expr *expr = NULL;
+  enum demangling_styles curr_style;
+
+  curr_style = CURRENT_DEMANGLING_STYLE;
+  c_sym = bfd_demangle (link_info.output_bfd, sym, DMGL_NO_OPTS);
+  if (!c_sym)
+    c_sym = sym;
+  cplus_demangle_set_style (curr_style);
 
   if (head->mask & BFD_ELF_VERSION_CXX_TYPE)
     {
-      cxx_sym = cplus_demangle (sym, DMGL_PARAMS | DMGL_ANSI);
+      cxx_sym = bfd_demangle (link_info.output_bfd, sym,
+			      DMGL_PARAMS | DMGL_ANSI);
       if (!cxx_sym)
 	cxx_sym = sym;
     }
   if (head->mask & BFD_ELF_VERSION_JAVA_TYPE)
     {
-      java_sym = cplus_demangle (sym, DMGL_JAVA);
+      java_sym = bfd_demangle (link_info.output_bfd, sym, DMGL_JAVA);
       if (!java_sym)
 	java_sym = sym;
     }
@@ -7205,10 +7214,10 @@ lang_vers_match (struct bfd_elf_version_expr_head *head,
 	case 0:
 	  if (head->mask & BFD_ELF_VERSION_C_TYPE)
 	    {
-	      e.pattern = sym;
+	      e.pattern = c_sym;
 	      expr = (struct bfd_elf_version_expr *)
                   htab_find ((htab_t) head->htab, &e);
-	      while (expr && strcmp (expr->pattern, sym) == 0)
+	      while (expr && strcmp (expr->pattern, c_sym) == 0)
 		if (expr->mask == BFD_ELF_VERSION_C_TYPE)
 		  goto out_ret;
 		else
@@ -7266,12 +7275,14 @@ lang_vers_match (struct bfd_elf_version_expr_head *head,
       else if (expr->mask == BFD_ELF_VERSION_CXX_TYPE)
 	s = cxx_sym;
       else
-	s = sym;
+	s = c_sym;
       if (fnmatch (expr->pattern, s, 0) == 0)
 	break;
     }
 
  out_ret:
+  if (c_sym != sym)
+    free ((char *) c_sym);
   if (cxx_sym != sym)
     free ((char *) cxx_sym);
   if (java_sym != sym)

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2010-07-19 23:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-06 20:03 Mike Frysinger
2010-07-11 11:57 ` Ian Lance Taylor
2010-07-11 22:07   ` Mike Frysinger
2010-07-12  8:05     ` Ian Lance Taylor
2010-07-19 23:34       ` Mike Frysinger [this message]
2010-07-22  2:26         ` Alan Modra
2010-08-17 11:11         ` Will Newton
2010-08-17 12:42           ` Mike Frysinger
2010-12-09 20:56 ` [PATCH] bfd/ld: handle ABI prefixes in version scripts Mike Frysinger
2010-12-09 21:43   ` Joseph S. Myers
2010-12-10  3:52     ` Mike Frysinger
2010-12-10 10:45       ` Joseph S. Myers
2010-12-10 22:04         ` Mike Frysinger
2010-12-13 19:40           ` Mike Frysinger
2010-12-13 23:15             ` Joseph S. Myers
2010-12-14  0:44               ` Mike Frysinger
2011-01-14  0:33   ` Mike Frysinger
2011-02-14  5:19     ` Mike Frysinger
2011-02-14  6:07   ` Alan Modra
2011-02-14 17:11     ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201007191931.02766.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=binutils@sourceware.org \
    --cc=iant@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).