bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/26198] New: Failure to merge read only data of machine code obje


From: markus.boeck02 at gmail dot com
Subject: [Bug ld/26198] New: Failure to merge read only data of machine code object file and LTO object file on MinGW
Date: Thu, 02 Jul 2020 20:25:47 +0000

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

            Bug ID: 26198
           Summary: Failure to merge read only data of machine code object
                    file and LTO object file on MinGW
           Product: binutils
           Version: 2.35 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: markus.boeck02 at gmail dot com
  Target Milestone: ---

Given following C++ source code:
test.cpp:

#include <typeinfo> 
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                      class A                  
                                                                               
                                                                               
                                                   {                           
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                             };
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                       int     
                                                                               
                                                                               
                                                                    #ifndef LTO
                                                                               
                                                                               
                                                                 foo()         
                                                                               
                                                                               
                                                              #else            
                                                                               
                                                                               
                                                           bar()               
                                                                               
                                                                               
                                                        #endif                 
                                                                               
                                                                               
                                                     {                          
    return typeid(A).hash_code();                                              
                                                                               
                                                                 }

If compiled twice using following commands with g++ with the x86_64-w64-mingw32
target:

g++ -c test.cpp -o test1.o
g++ -c test.cpp -DLTO -flto -fno-fat-lto-objects -o test2.o

And then attempted to be linked together using:

g++ -shared test1.o test2.o

yields following linker errors:

c:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld.exe:
test2.o (symbol from plugin):(.gnu.linkonce.t._ZNKSt9type_info4nameEv+0x0):
multiple definition of `std::type_info::name() const';
test1.o:test.cpp:(.text$_ZNKSt9type_info4nameEv[_ZNKSt9type_info4nameEv]+0x0):
first defined here                                            
c:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld.exe:
test2.o (symbol from
plugin):(.gnu.linkonce.t._ZNKSt9type_info9hash_codeEv+0x0): multiple definition
of `std::type_info::hash_code() const';
test1.o:test.cpp:(.text$_ZNKSt9type_info9hash_codeEv[_ZNKSt9type_info9hash_codeEv]+0x0):
first defined here                        
c:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld.exe:
test2.o (symbol from plugin):(.gnu.linkonce.t._ZTI1A+0x0): multiple definition
of `typeinfo for A'; test1.o:test.cpp:(.rdata$_ZTI1A[_ZTI1A]+0x0): first
defined here                                                                   
                                        
c:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld.exe:
test2.o (symbol from plugin):(.gnu.linkonce.t._ZTS1A+0x0): multiple definition
of `typeinfo name for A'; test1.o:test.cpp:(.rdata$_ZTS1A[_ZTS1A]+0x0): first
defined here                                                                   
                                    collect2.exe: error: ld returned 1 exit
status

Failed to reproduce this issue with a linux target

GCC version used was from the GCC 10 Branch at revision
d73846862b5e4cd381bb43024efdcbf6bd61e888
and binutils trunk at revision 33d1369f183f1c276e3f0f52b5573fb2f5843b1c

nm output of test1.o:
0000000000000000 b .bss                                                        
                                        0000000000000000 d .data               
                                                                               
0000000000000000 p .pdata                                                      
                                        0000000000000000 p
.pdata$_ZNKSt9type_info4nameEv                                                 
                     0000000000000000 p .pdata$_ZNKSt9type_info9hash_codeEv    
                                                             0000000000000000 r
.rdata$_ZTI1A                                                                  
                     0000000000000000 r .rdata$_ZTS1A                          
                                                             0000000000000000 r
.rdata$zzz                                                                     
                     0000000000000000 t .text                                  
                                                             0000000000000000 t
.text$_ZNKSt9type_info4nameEv                                                  
                     0000000000000000 t .text$_ZNKSt9type_info9hash_codeEv     
                                                             0000000000000000 r
.xdata                                                                         
                     0000000000000000 r .xdata$_ZNKSt9type_info4nameEv         
                                                             0000000000000000 r
.xdata$_ZNKSt9type_info9hash_codeEv                                             
                 U __gxx_personality_seh0                                      
                                        0000000000000000 T _Z3foov             
                                                                               
0000000000000000 T _ZNKSt9type_info4nameEv                                     
                                        0000000000000000 T
_ZNKSt9type_info9hash_codeEv                                                    
                 U _ZSt11_Hash_bytesPKvyy                                      
                                        0000000000000000 R _ZTI1A              
                                                                               
0000000000000000 R _ZTS1A                                                       
                 U _ZTVN10__cxxabiv117__class_type_infoE                        
                 U strlen

gcc-nm output of test2.o:
         U __gxx_personality_seh0                                              
                                        00000000 T _Z3barv                     
                                                                               
00000000 T _ZNKSt9type_info4nameEv                                             
                                        00000000 T _ZNKSt9type_info9hash_codeEv 
         U _ZSt11_Hash_bytesPKvyy                                              
                                        00000000 D _ZTI1A                      
                                                                               
00000000 D _ZTS1A                                                               
         U _ZTVN10__cxxabiv117__class_type_infoE

-- 
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]