https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90441

            Bug ID: 90441
           Summary: [9 regression] corrupt debug info with LTO
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: needs-bisection
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hoganmeier at gmail dot com
  Target Milestone: ---

Originally occurred with arm-gcc 9.1
Reproduced it with Ubuntu 19.04 gcc 9.0, works with gcc 8.3.
Couldn't reduce it further.

mk20dx128.c:
__attribute__ ((section(".vectors"), used))
_VectorsFlash[100]=
{
};

main.cpp:
void yield();
int main()
{
        yield();
}

yield.cpp:
int serial3_available() {}

struct HardwareSerial3 {
        int available()     { serial3_available(); }
};
HardwareSerial3 Serial3;

void yield()
{
  serial3_available();
}

script.ld:
MEMORY
{
        FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 4K
}

SECTIONS
{
        .text : {
                . = 0;
                KEEP(*(.vectors))
                *(.text*)
        } > FLASH = 0xFF
}

gcc-9 -o mk20dx128.c.o -c -flto -g -ffunction-sections -fdata-sections
-nostdlib -O2 teensy3/mk20dx128.c
g++-9 -o main.cpp.o -c -fno-exceptions -fno-rtti -flto -g -ffunction-sections
-fdata-sections -nostdlib -O2 teensy3/main.cpp
g++-9 -o yield.cpp.o -c -fno-exceptions -fno-rtti -flto -g -ffunction-sections
-fdata-sections -nostdlib -O2 yield.cpp
g++-9 -o firmware.elf -g -T script.ld -Wl,--gc-sections,--relax -O2 main.cpp.o
mk20dx128.c.o yield.cpp.o
nm -ClS --radix=d --size-sort firmware.elf

0000000000000224 0000000000000400 T _VectorsFlashnm: DWARF error: could not
find abbrev number 8

If you remove the 'HardwareSerial3 Serial3;' line the error becomes
DWARF error: info pointer extends beyond end of attributes

Reply via email to