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]$
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]$
This could be a readelf bug.
It is a readelf bug. I opened: https://sourceware.org/bugzilla/show_bug.cgi?id=18374