[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#606621: Acknowledgement (mklibs-readelf: segfaults on static objects)



Followup email:

It appears that the same segfault appeared with two other command line 
options, --print-symbols-provided and --print-symbols-undefined (on the
same file, /sbin/ldconfig.real. I attach
the complete patch (tested to work properly throughout the whole d-i image
build process).

Konstantinos
diff -ruN mklibs-0.1.30/src/mklibs-readelf/main.cpp mklibs-0.1.30.fixed//src/mklibs-readelf/main.cpp
--- mklibs-0.1.30/src/mklibs-readelf/main.cpp	2010-06-02 17:47:32.000000000 +0000
+++ mklibs-0.1.30.fixed//src/mklibs-readelf/main.cpp	2010-12-10 14:06:16.159766238 +0000
@@ -56,67 +56,75 @@
 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)
-  {
-    Elf::dynamic *dynamic = *it;
-    if (dynamic->get_tag () == tag)
-      std::cout << dynamic->get_val_string () << '\n';
+  if (section != NULL) {
+    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)
+        std::cout << dynamic->get_val_string () << '\n';
+    }
   }
 }
 
 static void process_symbols_provided (const Elf::section_type<Elf::section_type_DYNSYM> *section)
 {
-  for (std::vector<Elf::symbol *>::const_iterator it = section->get_symbols ().begin (); it != section->get_symbols ().end (); ++it)
+  if (section != NULL)
   {
-    const Elf::symbol *symbol = *it;
-    uint8_t bind = symbol->get_bind ();
-    uint16_t shndx = symbol->get_shndx ();
-    uint8_t type = symbol->get_type ();
-    const std::string &name = symbol->get_name_string ();
-
-    if (bind != STB_GLOBAL && bind != STB_WEAK)
-      continue;
-    if (shndx == SHN_UNDEF || shndx == SHN_ABS)
-      continue;
-    if (type != STT_NOTYPE && type != STT_OBJECT && type != STT_FUNC && type != STT_GNU_IFUNC && type != STT_COMMON && type != STT_TLS)
-      continue;
-    if (!name.size())
-      continue;
-
-    std::cout <<
-      name <<
-      ' ' << (bind == STB_WEAK ? "True" : "False") <<
-      ' ' << symbol->get_version() <<
-      ' ' << (symbol->get_version_data() & 0x8000 ? "False" : "True") <<
-      '\n';
+    for (std::vector<Elf::symbol *>::const_iterator it = section->get_symbols ().begin (); it != section->get_symbols ().end (); ++it)
+    {
+      const Elf::symbol *symbol = *it;
+      uint8_t bind = symbol->get_bind ();
+      uint16_t shndx = symbol->get_shndx ();
+      uint8_t type = symbol->get_type ();
+      const std::string &name = symbol->get_name_string ();
+
+      if (bind != STB_GLOBAL && bind != STB_WEAK)
+        continue;
+      if (shndx == SHN_UNDEF || shndx == SHN_ABS)
+        continue;
+      if (type != STT_NOTYPE && type != STT_OBJECT && type != STT_FUNC && type != STT_GNU_IFUNC && type != STT_COMMON && type != STT_TLS)
+        continue;
+      if (!name.size())
+        continue;
+
+      std::cout <<
+        name <<
+        ' ' << (bind == STB_WEAK ? "True" : "False") <<
+        ' ' << symbol->get_version() <<
+        ' ' << (symbol->get_version_data() & 0x8000 ? "False" : "True") <<
+        '\n';
+    }
   }
 }
 
 static void process_symbols_undefined (const Elf::section_type<Elf::section_type_DYNSYM> *section)
 {
-  for (std::vector<Elf::symbol *>::const_iterator it = section->get_symbols ().begin (); it != section->get_symbols ().end (); ++it)
+  if (section != NULL)
   {
-    const Elf::symbol *symbol = *it;
-    uint8_t bind = symbol->get_bind ();
-    uint16_t shndx = symbol->get_shndx ();
-    uint8_t type = symbol->get_type ();
-    const std::string &name = symbol->get_name_string ();
-
-    if (bind != STB_GLOBAL && bind != STB_WEAK)
-      continue;
-    if (shndx != SHN_UNDEF)
-      continue;
-    if (type != STT_NOTYPE && type != STT_OBJECT && type != STT_FUNC && type != STT_GNU_IFUNC && type != STT_COMMON && type != STT_TLS)
-      continue;
-    if (!name.size())
-      continue;
-
-    std::cout <<
-      name << 
-      ' ' << (bind == STB_WEAK ? "True" : "False") <<
-      ' ' << symbol->get_version() <<
-      ' ' << symbol->get_version_file() <<
-      '\n';
+    for (std::vector<Elf::symbol *>::const_iterator it = section->get_symbols ().begin (); it != section->get_symbols ().end (); ++it)
+    {
+      const Elf::symbol *symbol = *it;
+      uint8_t bind = symbol->get_bind ();
+      uint16_t shndx = symbol->get_shndx ();
+      uint8_t type = symbol->get_type ();
+      const std::string &name = symbol->get_name_string ();
+
+      if (bind != STB_GLOBAL && bind != STB_WEAK)
+        continue;
+      if (shndx != SHN_UNDEF)
+        continue;
+      if (type != STT_NOTYPE && type != STT_OBJECT && type != STT_FUNC && type != STT_GNU_IFUNC && type != STT_COMMON && type != STT_TLS)
+        continue;
+      if (!name.size())
+        continue;
+
+      std::cout <<
+        name << 
+        ' ' << (bind == STB_WEAK ? "True" : "False") <<
+        ' ' << symbol->get_version() <<
+        ' ' << symbol->get_version_file() <<
+        '\n';
+    }
   }
 }
 

Reply to: