bug-binutils
[Top][All Lists]
Advanced

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

[Bug gold/14608] --detect-odr-violations doesn't work with GCC 4.7


From: hjl.tools at gmail dot com
Subject: [Bug gold/14608] --detect-odr-violations doesn't work with GCC 4.7
Date: Sat, 20 Dec 2014 15:50:05 +0000

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |2.26

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
resolve.cc has

  // A new weak undefined reference, merging with an old weak
  // reference, could be a One Definition Rule (ODR) violation --
  // especially if the types or sizes of the references differ.  We'll
  // store such pairs and look them up later to make sure they
  // actually refer to the same lines of code.  We also check
  // combinations of weak and strong, which might occur if one case is
  // inline and the other is not.  (Note: not all ODR violations can
  // be found this way, and not everything this finds is an ODR
  // violation.  But it's helpful to warn about.)
  if (parameters->options().detect_odr_violations()
      && (sym.get_st_bind() == elfcpp::STB_WEAK
          || to->binding() == elfcpp::STB_WEAK)
      && orig_st_shndx != elfcpp::SHN_UNDEF
      && to->shndx(&to_is_ordinary) != elfcpp::SHN_UNDEF
      && to_is_ordinary
      && sym.get_st_size() != 0    // Ignore weird 0-sized symbols.
      && to->symsize() != 0 
      && (sym.get_st_type() != to->type()
          || sym.get_st_size() != to->symsize())
      // C does not have a concept of ODR, so we only need to do this
      // on C++ symbols.  These have (mangled) names starting with _Z.
      && to->name()[0] == '_' && to->name()[1] == 'Z') 
    {

On Linux/ia32, the newer GCC generates:

odr_violation2.o:

00000150 <_Z23SometimesInlineFunctioni>:
 150:   8b 44 24 04             mov    0x4(%esp),%eax
 154:   0f af c0                imul   %eax,%eax
 157:   c3                      ret    
 158:   90                      nop
 159:   8d b4 26 00 00 00 00    lea    0x0(%esi,%eiz,1),%esi

debug_msg.o:

00000000 <_Z23SometimesInlineFunctioni>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   8b 45 08                mov    0x8(%ebp),%eax
   6:   5d                      pop    %ebp
   7:   c3                      ret    

They happen to have the same size and One Definition Rule (ODR) violation
fails to trigger.

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]