[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fixing multiple aliasing of a symbol



Thank you so much for feedback. I have made changes according to instruction 
mentioned in the email and attached updated patch.

On Wednesday 18 Jun 2014 6:03:47 PM you wrote:
> Hello Sinny,
> 
> Thank you very much for the patch, which looks good to me, overall.
> 
> I just have a few nits to point you to, if you don't mind.
> 
> First, you need to really locally commit the thing and sign your work,
> and then use 'git format-patch' to get the patch.  This is explained in
> the CONTRIBUTING file in the source tree.  Also, please read the
> COMMIT-LOG-GUIDELINES file of the source tree to know how to format the
> commit log.
> 
> You can look at existing commits in the history to see how they are
> formatted, for instancve.
> 
> Now the nits of the patch itself.
> 
> diff --git a/src/abg-reader.cc b/src/abg-reader.cc
> [...]
> 
> @@ -1650,13 +1651,26 @@ build_elf_symbol_db(read_context& ctxt,
> [...]
> 
>      {
>        if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(x->first, "alias"))
>  	{
> -	  string alias_id = CHAR_STR(s);
> -	  string_elf_symbol_sptr_map_type::const_iterator i =
> -	    id_sym_map.find(alias_id);
> -	  assert(i != id_sym_map.end());
> -	  assert(i->second->is_main_symbol());
> +      string alias_id = CHAR_STR(s);
> 
> -	  x->second->get_main_symbol()->add_alias(i->second.get());
> +      // Symbol aliases can be multiple separtaed by comma(,), split them
> 
> In the comment, I guess you meant 'separated'.
> 
> +      std::vector<std::string> elems;
> +      std::stringstream aliases(alias_id);
> +      std::string item;
> +      while (std::getline(aliases, item, ','))
> +      {
> +        elems.push_back(item);
> +      }
> 
> I think we need a test case for this, similar to what is found in the
> tests/data/test-read-dwarf/ directory.  Basically, there would be a short
> program compiled in a *.so file, and that contains a symbol with several
> aliases.  The tests/test-read-dwarf.cc harness would then read the .so
> file, emit an XML for that and compare it to a reference XML.  If you
> can send me the source code for the program that is to be compiled into
> the *.so, I can add it to the test suite, or we can discuss how to do
> that if you want.  I think I need to add documentation for all this ;-)
> 

I will work on writing test case for same.


Thanks
SInny Kumari
>From 4aeb9d7fa4bebb3852047eac45a7d6b018ce71fe Mon Sep 17 00:00:00 2001
From: Sinny Kumari <skumari@redhat.com>
Date: Thu, 19 Jun 2014 12:13:54 +0530
Subject: [PATCH 1/1] Keep symbol's multiple aliases within single attribute
 separated by comma(,)

    * src/abg-writer.cc (write_elf_symbol_aliases): Changing function
    to keep multiple symbol aliases within one alias attribute
    * src/abg-reader.cc (build_elf_symbol_db): Changing function to read
    symbol's alias attribute and split if multiple alias exist with comma(,)
    as a delimiter and add all aliases to main symbol

Signed-off-by: Sinny Kumari <skumari@redhat.com>
---
 src/abg-reader.cc | 26 ++++++++++++++++++++------
 src/abg-writer.cc |  7 ++++++-
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/abg-reader.cc b/src/abg-reader.cc
index 21ec927..140d5c5 100644
--- a/src/abg-reader.cc
+++ b/src/abg-reader.cc
@@ -29,6 +29,7 @@
 #include <tr1/unordered_map>
 #include <deque>
 #include <assert.h>
+#include <sstream>
 #include <libxml/xmlstring.h>
 #include <libxml/xmlreader.h>
 #include "abg-libxml-utils.h"
@@ -1650,13 +1651,26 @@ build_elf_symbol_db(read_context& ctxt,
     {
       if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(x->first, "alias"))
 	{
-	  string alias_id = CHAR_STR(s);
-	  string_elf_symbol_sptr_map_type::const_iterator i =
-	    id_sym_map.find(alias_id);
-	  assert(i != id_sym_map.end());
-	  assert(i->second->is_main_symbol());
+      string alias_id = CHAR_STR(s);
 
-	  x->second->get_main_symbol()->add_alias(i->second.get());
+      // Symbol aliases can be multiple separated by comma(,), split them
+      std::vector<std::string> elems;
+      std::stringstream aliases(alias_id);
+      std::string item;
+      while (std::getline(aliases, item, ','))
+      {
+        elems.push_back(item);
+      }
+      for (std::vector<string>::iterator alias = elems.begin();
+           alias != elems.end(); alias++)
+        {
+          string_elf_symbol_sptr_map_type::const_iterator i =
+          id_sym_map.find(*alias);
+          assert(i != id_sym_map.end());
+          assert(i->second->is_main_symbol());
+
+          x->second->get_main_symbol()->add_alias(i->second.get());
+        }
 	}
     }
 
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 07bb3a2..84b8e48 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -652,11 +652,16 @@ write_elf_symbol_aliases(const elf_symbol& sym, ostream& o)
     return false;
 
   bool emitted = false;
+  o << " alias='";
   for (elf_symbol* s = sym.get_next_alias();
        !s->is_main_symbol();
        s = s->get_next_alias())
     {
-      o << " alias='" << s->get_id_string() << "'";
+      if (s->get_next_alias() == s->get_main_symbol())
+          o << s->get_id_string() << "'";
+      else
+          o << s->get_id_string() << ",";
+
       emitted = true;
     }
 
-- 
1.8.3.1