Hi all,
When I enable LTO for my program to reduce code size, msp430-gcc appears to output corrupt DWARF debug info, which prevents debug tools from working. For example, msp430-elf-addr2line outputs:
$ msp430-elf-addr2line -e a.out 00008018
msp430-elf-addr2line: DWARF error: invalid abstract instance DIE ref
??:?
I reduced the problem down to the test case below (see comment for steps). Interestingly the corruption appears to be periodic in the amount of constexpr data allocated, so I'm guessing there's an int16_t in gcc somewhere that's overflowing. To swap between working and corrupt cases, include different ranges of xN, such as x01-x03, x01-x07, etc.
Would anyone happen to know where in the msp430-gcc source I should start looking to make a patch?
Thanks,
David
// Test case:
// msp430-elf-gcc-9.3.1 -g -flto -std=c++17 test.cpp
// msp430-elf-nm a.out | grep ' main'
// msp430-elf-addr2line -e a.out <main-addr>
struct A
{
static constexpr char x01[8192] = {}; // OK
static constexpr char x02[8192] = {}; // OK
static constexpr char x03[8192] = {}; // OK
static constexpr char x04[8192] = {}; // Breaks
static constexpr char x05[8192] = {}; // Breaks
static constexpr char x06[8192] = {}; // Breaks
static constexpr char x07[8192] = {}; // Breaks
static constexpr char x08[8192] = {}; // OK
static constexpr char x09[8192] = {}; // OK
static constexpr char x10[8192] = {}; // OK
static constexpr char x11[8192] = {}; // OK
static constexpr char x12[8192] = {}; // Breaks
static constexpr char x13[8192] = {}; // Breaks
static constexpr char x14[8192] = {}; // Breaks
static constexpr char x15[8192] = {}; // Breaks
static constexpr char x16[8192] = {}; // OK
static constexpr char x17[8192] = {}; // OK
static constexpr char x18[8192] = {}; // OK
static constexpr char x19[8192] = {}; // OK
static constexpr char x20[8192] = {}; // Breaks
static constexpr char x21[8192] = {}; // Breaks
static constexpr char x22[8192] = {}; // Breaks
static constexpr char x23[8192] = {}; // Breaks
};
int main() {
for (;;);
}