Bug#606621: Acknowledgement (mklibs-readelf: segfaults on static objects)
Hello,
This is the patch I used for hurd-i386. I can't remember why it never
got commited into mklibs.
Samuel
diff -ur mklibs-0.1.29.backup/src/mklibs-readelf/main.cpp mklibs-0.1.29/src/mklibs-readelf/main.cpp
--- mklibs-0.1.29.backup/src/mklibs-readelf/main.cpp 2009-07-24 10:16:15.000000000 +0000
+++ mklibs-0.1.29/src/mklibs-readelf/main.cpp 2009-12-29 09:51:52.000000000 +0000
@@ -56,7 +56,9 @@
static void process_dynamics (Elf::file *file, int64_t tag)
{
const Elf::section_type<Elf::section_type_DYNAMIC> *section = file->get_section_DYNAMIC ();
- for (std::vector<Elf::dynamic *>::const_iterator it = section->get_dynamics ().begin (); it != section->get_dynamics ().end (); ++it)
+ if (!section)
+ return;
+ for (std::vector<Elf::dynamic *>::const_iterator it = section->get_dynamics ().begin ();it != section->get_dynamics ().end (); ++it)
{
Elf::dynamic *dynamic = *it;
if (dynamic->get_tag () == tag)
@@ -123,6 +125,7 @@
static void process (command cmd, const char *filename)
{
Elf::file *file = Elf::file::open (filename);
+ const Elf::section_type<Elf::section_type_DYNSYM> *section;
switch (cmd)
{
@@ -143,10 +146,14 @@
process_dynamics (file, DT_SONAME);
break;
case COMMAND_PRINT_SYMBOLS_PROVIDED:
- process_symbols_provided (file->get_section_DYNSYM ());
+ section = file->get_section_DYNSYM ();
+ if (section)
+ process_symbols_provided (section);
break;
case COMMAND_PRINT_SYMBOLS_UNDEFINED:
- process_symbols_undefined (file->get_section_DYNSYM ());
+ section = file->get_section_DYNSYM ();
+ if (section)
+ process_symbols_undefined (section);
break;
}
}
Reply to: