[haiku-commits] haiku: hrev46255 - src/kits/debug

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 19 Oct 2013 01:07:35 +0200 (CEST)

hrev46255 adds 1 changeset to branch 'master'
old head: e9487c70c5764317d45aef2e903c4ef683b5c18d
new head: 1bcd34c4da5e08d339dd1c59a6d4806919fd6727
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=1bcd34c+%5Ee9487c7

----------------------------------------------------------------------------

1bcd34c: libdebug: Improve handling of stripped binaries.
  
  - When searching for the symbol table, first see if the normal SHT_SYMTAB
    section is present. If not, fall back to trying to use SHT_DYNSYM if
    present. This allows us to resolve non-static functions/symbols
    in stripped binaries for the purposes of crash reports/disassembly.

                                         [ Rene Gollent <rene@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46255
Commit:      1bcd34c4da5e08d339dd1c59a6d4806919fd6727
URL:         http://cgit.haiku-os.org/haiku/commit/?id=1bcd34c
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Fri Oct 18 23:03:30 2013 UTC

----------------------------------------------------------------------------

2 files changed, 18 insertions(+), 4 deletions(-)
src/kits/debug/Image.cpp | 19 +++++++++++++++----
src/kits/debug/Image.h   |  3 +++

----------------------------------------------------------------------------

diff --git a/src/kits/debug/Image.cpp b/src/kits/debug/Image.cpp
index b2f23d3..239820f 100644
--- a/src/kits/debug/Image.cpp
+++ b/src/kits/debug/Image.cpp
@@ -305,9 +305,6 @@ ImageFile::_LoadFile(const char* path, addr_t* 
_textAddress, size_t* _textSize,
                return B_NOT_AN_EXECUTABLE;
        }
 
-       elf_shdr* sectionHeaders
-               = (elf_shdr*)(fMappedFile + elfHeader->e_shoff);
-
        // find the text and data segment -- we need load address and size
        *_textAddress = 0;
        *_textSize = 0;
@@ -328,12 +325,26 @@ ImageFile::_LoadFile(const char* path, addr_t* 
_textAddress, size_t* _textSize,
                }
        }
 
+       status_t error = _FindTableInSection(elfHeader, SHT_SYMTAB);
+       if (error != B_OK)
+               error = _FindTableInSection(elfHeader, SHT_DYNSYM);
+
+       return error;
+}
+
+
+status_t
+ImageFile::_FindTableInSection(elf_ehdr* elfHeader, uint16 sectionType)
+{
+       elf_shdr* sectionHeaders
+               = (elf_shdr*)(fMappedFile + elfHeader->e_shoff);
+
        // find the symbol table
        for (int32 i = 0; i < elfHeader->e_shnum; i++) {
                elf_shdr* sectionHeader = (elf_shdr*)
                        ((uint8*)sectionHeaders + i * elfHeader->e_shentsize);
 
-               if (sectionHeader->sh_type == SHT_SYMTAB) {
+               if (sectionHeader->sh_type == sectionType) {
                        elf_shdr& stringHeader = *(elf_shdr*)
                                ((uint8*)sectionHeaders
                                        + sectionHeader->sh_link * 
elfHeader->e_shentsize);
diff --git a/src/kits/debug/Image.h b/src/kits/debug/Image.h
index 4d4be64..2d5cbbe 100644
--- a/src/kits/debug/Image.h
+++ b/src/kits/debug/Image.h
@@ -96,6 +96,9 @@ private:
                                                                        addr_t* 
_textAddress, size_t* _textSize,
                                                                        addr_t* 
_dataAddress, size_t* _dataSize);
 
+                       status_t                        
_FindTableInSection(elf_ehdr* elfHeader,
+                                                                       uint16 
sectionType);
+
 private:
                        int                                     fFD;
                        off_t                           fFileSize;


Other related posts:

  • » [haiku-commits] haiku: hrev46255 - src/kits/debug - anevilyak