[Top][All Lists]

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

[Bug ld/24267] New: ld discard a symbol with -flto and -static

From: marxin.liska at gmail dot com
Subject: [Bug ld/24267] New: ld discard a symbol with -flto and -static
Date: Mon, 25 Feb 2019 13:19:57 +0000


            Bug ID: 24267
           Summary: ld discard a symbol with -flto and -static
           Product: binutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: marxin.liska at gmail dot com
  Target Milestone: ---

This is follow up of:

$ cat simpler.ii
namespace std {
template <class> struct char_traits;
template <typename a, typename = char_traits<a>> class basic_ostream;
typedef basic_ostream<char> b;
class ios_base {
  class Init {
template <typename> class ctype {
  virtual char do_widen(char c) const { return c; }
class d {
  ctype<char> e;
template <typename, typename> class basic_ostream : d {};
template <class f>
basic_ostream<char, f> &operator<<(basic_ostream<char, f> &, const char *);
b cout;
ios_base::Init g;
} // namespace std
int main() { std::cout << "ok"; }

When compiler with:

$ x86_64-w64-mingw32-g++ -v
Using built-in specs.
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/usr --bindir=/usr/bin
--includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/lib64
--mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share
--build=x86_64-suse-linux-gnu --host=x86_64-suse-linux-gnu
--target=x86_64-w64-mingw32 --with-gnu-as --with-gnu-ld --verbose
--without-newlib --disable-multilib --enable-shared --disable-plugin
--with-system-zlib --disable-nls --without-included-gettext
--disable-win32-registry --enable-threads=posix
--enable-languages=c,c++,fortran,objc,obj-c++ --without-x
--enable-hash-synchronization --enable-fully-dynamic-string --enable-libgomp
--enable-linker-build-id --disable-vtable-verify --with-pkgversion='SUSE Linux'
Thread model: posix
gcc version 8.2.0 (SUSE Linux) 

$ x86_64-w64-mingw32-g++ simpler.ii -flto -O2 -static --save-temps --verbose

$ cat simpler.res
simpler.o 10
257 4b7905b9947ad39f PREEMPTED_REG _ZNKSt5ctypeIcE8do_widenEc
260 4b7905b9947ad39f PREVAILING_DEF main
279 4b7905b9947ad39f PREEMPTED_REG _ZSt4cout
282 4b7905b9947ad39f PREVAILING_DEF_IRONLY _ZSt1g
291 4b7905b9947ad39f PREEMPTED_REG _ZTSSt5ctypeIcE
305 4b7905b9947ad39f PREEMPTED_REG _ZTISt5ctypeIcE
207 4b7905b9947ad39f PREEMPTED_REG _ZTVSt5ctypeIcE
316 4b7905b9947ad39f RESOLVED_EXEC _ZTVN10__cxxabiv117__class_type_infoE
271 4b7905b9947ad39f RESOLVED_EXEC
276 4b7905b9947ad39f RESOLVED_EXEC _ZNSt8ios_base4InitC1Ev

as seen _ZNKSt5ctypeIcE8do_widenEc is both defined in the static libstdc++ and
simpler.ii. Linker tells to not to emit assembly for the symbol. However we
then end up with a binary where the symbol is missing:

$ x86_64-w64-mingw32-nm a.exe | grep _ZNKSt5ctypeIcE8do_widenEc
0000000000acda70 N .debug_frame$_ZNKSt5ctypeIcE8do_widenEc
00000000004b9150 p .pdata$_ZNKSt5ctypeIcE8do_widenEc
00000000004c51b4 r .xdata$_ZNKSt5ctypeIcE8do_widenEc
                 U _ZNKSt5ctypeIcE8do_widenEc
                 U _ZNKSt5ctypeIcE8do_widenEc
                 U _ZNKSt5ctypeIcE8do_widenEc
                 U _ZNKSt5ctypeIcE8do_widenEc
                 U _ZNKSt5ctypeIcE8do_widenEc
                 U _ZNKSt5ctypeIcE8do_widenEc
                 U _ZNKSt5ctypeIcE8do_widenEc

Which is causing wine crash:

 wine a.exe
wine: Unhandled page fault on read access to 0x00000000 at address 0x4a3a2e
(thread 002b), starting debugger...

So I suspect ld.bfd for not copying the _ZNKSt5ctypeIcE8do_widenEc from static

$ x86_64-w64-mingw32-nm /usr/lib64/gcc/x86_64-w64-mingw32/8.2.0/libstdc++.dll.a
| grep _ZNKSt5ctypeIcE8do_widenEc
0000000000000000 I __imp__ZNKSt5ctypeIcE8do_widenEc
0000000000000000 T _ZNKSt5ctypeIcE8do_widenEc

If needed I can upload somewhere libstdc++.dll.a file.

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]