https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92664
Bug ID: 92664
Summary: Wrong .debug_line section information when compiling
stdin input with -g3
Product: gcc
Version: 7.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: robert.dumitru at cyberthorstudios dot com
Target Milestone: ---
Hello,
When compiling simple test programs with -g3 and input from the console (-
(stdin)), the .debug_line section is wrong.
Steps to reproduce this issue:
1. In your console type:
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16
-O0 -g3 -c -o test.o -x c -
2. Copy and paste:
#include <stdio.h>
int main(void)
{
printf("Hello World\n");
return 0;
}
3. Ctrl+Z and Return
4. If you type: arm-none-eabi-readelf --debug-dump=decodedline test.o
You get the following:
Contents of the .debug_line section:
CU: ./<stdin>:
File name Line number Starting address View
readelf: Warning: Badly formed extended line op encountered!
readelf: Warning: Badly formed extended line op encountered!
UNKNOWN (116): length 115
<stdin> 0 0xc
<stdin> -1 0x1a
<stdin> -1 0x1e
<stdin> 1 0x2a
UNKNOWN (0): length 4
<stdin> -1 0x36
<stdin> -6 0x42
<stdin> -8 0x50
<stdin> -7 0x5c
<stdin> -7 0x60
<stdin> -5 0x6c
UNKNOWN (0): length 2
<stdin> 2 0x76
<stdin> 2 0x84
<stdin> 7 0x92
<stdin> 3 0xa0
<stdin> 2 0xac
<stdin> 1 0xba
<stdin> 1 0xbe
<stdin> 3 0xca
UNKNOWN (0): length 4
<stdin> -1 0xd8
<stdin> -2 0xe4
<stdin> -3 0xf2
<stdin> -3 0xf6
<stdin> -1 0x102
UNKNOWN (0): length 1
UNKNOWN (115): length 95
<stdin> -2 0x110
<stdin> -6 0x11e
<stdin> -7 0x12a
<stdin> -10 0x136
<stdin> -10 0x13a
<stdin> -8 0x146
UNKNOWN (0): length 1
UNKNOWN (112): length 95
5. Repeating the steps with -g instead of -g3 we get the right .debug_line
section:
Contents of the .debug_line section:
CU: ./<stdin>:
File name Line number Starting address View
<stdin> 3 0
<stdin> 4 0x4
<stdin> 5 0xa
<stdin> 6 0xc
<stdin> 6 0x14
