This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Segfault when reading a debug-only file.


Hi,

It seems that there is a problem with reading files that only
have debug information.  The file with debug info is split in
a file without debug info and one with only debug info.  Such
a file still contains the section headers but not the actual
data the belongs to that section.  The type has been changed
from PROGBITS to NOBITS.

Because it's set to NOBITS, nothing gets read from the file
(in __libelf_set_rawdata_wrlock()).  In relocate_section()
it seems to assume that the section was loaded in memory, but
it isn't.  tdata->d_buf is NULL.  This later results in
a segfault.

This can be reproduced with "eu-readelf -a tst.debug".

I've attached a small test case which source was:
int main(){return 0;}

I then used:
gcc tst.c -o tst -g
objcopy --only-keep-debug tst tst.debug

elflint produces a whole bunch of warnings on that file,
mostly saying "wrong type: expected PROGBITS, is NOBITS"

There is also a little more information and an other testcase
at http://bugs.debian.org/556133


Kurt

Attachment: tst.debug
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]