Bug 65997 - Bad DWARF debug info
Summary: Bad DWARF debug info
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 5.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-03 23:05 UTC by H.J. Lu
Modified: 2015-05-04 00:17 UTC (History)
0 users

See Also:
Host:
Target: x86
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-05-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2015-05-03 23:05:54 UTC
On Linux/x86, I got

[hjl@gnu-6 gcc]$ cat /tmp/x.c
typedef unsigned int size_t;
void
bzero(void *b , size_t length)
{
  char *ptr = (char *)b;
  while (length--)
    *ptr++ = 0;
}
[hjl@gnu-6 gcc]$ /usr/gcc-5.1.1/bin/gcc  -m32  -O2 -g /tmp/x.i -c -o /tmp/x.o  -mregparm=3  
[hjl@gnu-6 gcc]$ readelf -w /tmp/x.o >! /dev/null
readelf: Warning: There are 44 unused bytes at the end of section .zdebug_loc
readelf: Error: '/dev/null' is not an ordinary file
[hjl@gnu-6 gcc]$ /usr/gcc-5.1.1/bin/gcc  -m32  -O2 -g /tmp/x.i -c -o /tmp/x.o 
[hjl@gnu-6 gcc]$ readelf -w /tmp/x.o >! /dev/null
readelf: Error: '/dev/null' is not an ordinary file
[hjl@gnu-6 gcc]$
Comment 1 H.J. Lu 2015-05-04 00:05:54 UTC
Also happen on x86-64:

[hjl@gnu-6 gcc]$ cat /tmp/x.c
void
foo (void *b , unsigned int length)
{
  char *ptr = (char *)b;
  while (length--)
    *ptr++ = 0;
}
[hjl@gnu-6 gcc]$ /usr/gcc-5.1.1/bin/gcc   -O2 -g /tmp/x.c -c 
[hjl@gnu-6 gcc]$  readelf --debug-dump=loc x.o 
Contents of the .zdebug_loc section:

    Offset   Begin    End      Expression
    00000000 0000000000000000 000000000000000c (DW_OP_reg5 (rdi))
    00000013 000000000000000c 000000000000001f (DW_OP_GNU_entry_value: (DW_OP_reg5 (rdi)); DW_OP_stack_value)
    00000029 <End of list>
    00000039 <End of list>
readelf: Warning: There are 40 unused bytes at the end of section .zdebug_loc

[hjl@gnu-6 gcc]$
Comment 2 H.J. Lu 2015-05-04 00:10:31 UTC
This could be a readelf bug.
Comment 3 H.J. Lu 2015-05-04 00:17:51 UTC
It is a readelf bug.  I opened:

https://sourceware.org/bugzilla/show_bug.cgi?id=18374