public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: "dodji at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: libabigail@sourceware.org
Subject: [Bug default/19638] Different output for abidiff a.xml b.xml and abidiff a.xml b.so
Date: Fri, 01 Jan 2016 00:00:00 -0000	[thread overview]
Message-ID: <bug-19638-9487-mrsRVO2rVb@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-19638-9487@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=19638

--- Comment #4 from dodji at redhat dot com ---
OK, I think I understand what is happening with respect to the "added
functions" discrepancy.  I think it's Libabigail that "forgets" how some
function representation (provided by DWARF) relate to the address of some
symbols (provided by the ELF symbol table).  This loss of information happens
at type canonicalization time.  I think I probably have a fix for this.

Now I am looking at the discrepancy with respected to the "changed functions"
section.

So, in the .so file that was build with -O2 -g (the one you provided the base
abi dump for), a compiler optimization resulted in these two functions to have
their function symbols be aliases:

unity::scopes::ConfigException::ConfigException(const std::string&)

and 

unity::scopes::ConfigException::ConfigException(const
unity::scopes::ConfigException&)


Their respective symbols are
_ZN5unity6scopes15ConfigExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

and 

_ZN5unity6scopes15ConfigExceptionC2ERKS1_.

The fact that these symbols are aliases is represented in the abi dump by the
following xml element:

    <elf-symbol
name='_ZN5unity6scopes15ConfigExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
type='func-type' binding='global-binding'
alias='_ZN5unity6scopes15ConfigExceptionC2ERKS1_' is-defined='yes'/>

I believe Libabigail is thus being tricked by how DWARF represents the copy
constructor ConfigException(const ConfigException&), in light of this
optimization:

Here is what libabigail sees from DWARF (and ELF):


<function-decl name='ConfigException'
mangled-name='_ZN5unity6scopes15ConfigExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
filepath='/build/unity-scopes-api-CnWggJ/unity-scopes-api-1.0.3+16.04.20160210.5/include/unity/scopes/ScopeExceptions.h'
line='140' column='1' visibility='default' binding='global' size-in-bits='64'
elf-symbol-id='_ZN5unity6scopes15ConfigExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'>
[...]

See how the mangled name of the copy constructor is said to be
_ZN5unity6scopes15ConfigExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.
 It should be 
_ZN5unity6scopes15ConfigExceptionC2ERKS1_, but then, as these two symbols are
the same, well, the compiler is right to emit debug info that says this!

But then, as a result, libabigail is comparing the function
ConfigException(const ConfigException&) from the old library, with the function
ConfigException(const string&) from the new library.  And it's (rightfully)
saying that parameter 'const ConfigException&' was changed to parameter 'const
string&' !

Why?

Because, the symbol of ConfigException(const ConfigException&) in the old
library is
_ZN5unity6scopes15ConfigExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
(an alias of _ZN5unity6scopes15ConfigExceptionC2ERKS1_) and the symbol of
ConfigException(const string&) in the new library has the same symbol!

So, libabigail does its job of also comparing the *types* of these symbols. 
And indeed, the ABI of the first build is different from the ABI of the second
build, though, not in an incompatible way.

Now to understand the reason why comparing the two ABI dumps is different from
comparing one ABI dump against the later DSO, I think I would need to get my
hand on the .so file compiled with -g -O2.  It doesn't have to be exactly the
same as the one you provided here, though.  It "just" have to contain the code
of the ConfigException constructors which exhibits the compiler optimization I
talked about.

Thanks.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2016-02-16 10:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-01  0:00 [Bug default/19638] New: " michi.henning at canonical dot com
2016-01-01  0:00 ` [Bug default/19638] " dodji at redhat dot com
2016-01-01  0:00 ` michi.henning at canonical dot com
2016-01-01  0:00 ` michi.henning at canonical dot com
2016-01-01  0:00 ` [Bug default/19638] DWARF reader fails to link clone function to its root declaration dodji at seketeli dot org
2016-01-01  0:00 ` dodji at redhat dot com [this message]
2016-01-01  0:00 ` dodji at redhat dot com
2016-01-01  0:00 ` [Bug default/19638] Different output for abidiff a.xml b.xml and abidiff a.xml b.so michi.henning at canonical dot com
2016-01-01  0:00 ` [Bug default/19638] DWARF reader fails to link cloned function to its root declaration dodji at seketeli dot org
2016-01-01  0:00 ` [Bug default/19638] Different output for abidiff a.xml b.xml and abidiff a.xml b.so michi.henning at canonical dot com

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=bug-19638-9487-mrsRVO2rVb@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=libabigail@sourceware.org \
    /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).