mklibs: fix crashes on nonexistant sections in readelf (thx, justus)
[openwrt-10.03/.git] / tools / mklibs / patches / 005-readelf_fixes.patch
diff --git a/tools/mklibs/patches/005-readelf_fixes.patch b/tools/mklibs/patches/005-readelf_fixes.patch
new file mode 100644 (file)
index 0000000..f755942
--- /dev/null
@@ -0,0 +1,33 @@
+--- a/src/mklibs-readelf/main.cpp
++++ b/src/mklibs-readelf/main.cpp
+@@ -57,6 +57,10 @@ static void process_elf_header (Elf::fil
+ static void process_dynamics (Elf::file *file, int64_t tag)
+ {
+   const Elf::section_type<Elf::section_type_DYNAMIC> *section = file->get_section_DYNAMIC ();
++
++  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;
+@@ -67,6 +71,9 @@ static void process_dynamics (Elf::file 
+ static void process_symbols_provided (const Elf::section_type<Elf::section_type_DYNSYM> *section)
+ {
++  if (!section)
++    return;
++
+   for (std::vector<Elf::symbol *>::const_iterator it = section->get_symbols ().begin (); it != section->get_symbols ().end (); ++it)
+   {
+     const Elf::symbol *symbol = *it;
+@@ -95,6 +102,9 @@ static void process_symbols_provided (co
+ static void process_symbols_undefined (const Elf::section_type<Elf::section_type_DYNSYM> *section)
+ {
++  if (!section)
++    return;
++
+   for (std::vector<Elf::symbol *>::const_iterator it = section->get_symbols ().begin (); it != section->get_symbols ().end (); ++it)
+   {
+     const Elf::symbol *symbol = *it;