Menu

#217 TDM-GCC always adding debug information sections

None
open
John E.
None
1
2015-01-10
2014-03-14
Anonymous
No

Description
Linking an executable with this version of TDM gcc always add the debug information sections to the executable. Even if '-g' is not specified.

Test Program (test.c)

int main() {
    return 0;
}

Procedure
compile and link:

    g++ test.c -o test

list the sections:

dumpin /SUMMARY test.exe

Microsoft (R) COFF/PE Dumper Version 11.00.50727.1
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file test.exe

File Type: EXECUTABLE IMAGE

  Summary

        1000 .CRT
        1000 .bss
        1000 .data
        2000 .debug_abbrev
        1000 .debug_aranges
        1000 .debug_frame
        C000 .debug_info
        2000 .debug_line
        3000 .debug_loc
        1000 .debug_ranges
        1000 .debug_str
        1000 .idata
        1000 .pdata
        1000 .rdata
        2000 .text
        1000 .tls
        1000 .xdata

Expected Output
None of the sections that begin with .debug should be present unless the '-g' option is given.

Workaround
There are two options to work around this.
1) Run GNU strip on executable to remove debug information
2) Use the '-Wl,-S' to tell the linker to strip debug information

    g++ -Wl,-S test.c -o test

NOTE
This only occurs when linking. When compiling to object files, the debug information is only included when '-g' is specified. So,

g++ -c test.c -o test.o

Running dumpbin on test.o shows no .debug sections.

GCC Version: TDM 4.8.1-3
Using built-in specs.
COLLECT_GCC=C:\TDM-GCC-64\bin\g++.exe
COLLECT_LTO_WRAPPER=c:/tdm-gcc-64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.1/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.8.1/configure --build=x86_64-w64-mingw32 --enable-targets=all --enable-languages=ada,c,c++,fortran,lto,o bjc,obj-c++ --enable-libgomp --enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC --enable-libstdcxx-debug --enable-threads =posix --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-ld --disable-werror --disable-nls --disable-win32-registry --prefix=/mingw64tdm --with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-2 --wi th-bugurl=http://tdm-gcc.tdragon.net/bugs
Thread model: posix
gcc version 4.8.1 (tdm64-2)

LD Version
GNU ld (GNU Binutils) 2.23.2

Discussion

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB