serge1 / ELFIO

ELFIO - ELF (Executable and Linkable Format) reader and producer implemented as a header only C++ library
http://serge1.github.io/ELFIO
MIT License
706 stars 152 forks source link

elfio doesn't seem to be able to read notes from coredump #93

Closed isage closed 2 years ago

isage commented 2 years ago

While readelf -n and objdump -h works, elfio doesn't seem to be able to auto-parse (or, rather, auto-create) note sections from note segments.

Right now i'm using this workaround:

ELFIO::Elf_Half n = reader.segments.size();

        for ( ELFIO::Elf_Half i = 0; i < n; ++i )
        {
            ELFIO::segment* seg = reader.segments[i];
            if (seg->get_type() == PT_NOTE)
            {
                std::ostringstream name;
                name << "note" << (int)i;
                ELFIO::section* note_sec = reader.sections.add(name.str());
                note_sec->set_type( SHT_NOTE );
                note_sec->set_data( seg->get_data(), seg->get_file_size() );
            }
        }
serge1 commented 2 years ago

Hi, Sorry, I cannot confirm the report. Note section of a coredump is processed correctly in my environment:

Note section (note0)
    No Name         Data size  Description
  [ 0] CORE         0x00000088 0x00000003
         00740000ff7f00000000004000000000

Would it be possible for you to provide an example file that demonstrates the problem?

serge1 commented 2 years ago

In addition, I am not sure I understand your example. It looks like you are looking PT_NOTE segment. Is it the intention to read a segment instead of a Note section (SHT_NOTE)?

isage commented 2 years ago

Here's sample: https://transfer.sh/8Axwv9/psp2core-1255533211-0x0000072aa7-eboot.bin.psp2dmp

my example is a workaround, because elfio fails to see sections in that file, only segments.

serge1 commented 2 years ago

Here's sample: https://transfer.sh/8Axwv9/psp2core-1255533211-0x0000072aa7-eboot.bin.psp2dmp

For some reason, access to this file is not available: "This site can’t be reached"

isage commented 2 years ago

https://drive.google.com/file/d/101RicL-nzIsaloaD4fxBWjoOrRUwjD2A/view?usp=sharing how about this?

serge1 commented 2 years ago

Thank you for the example. I see what you mean now. I am trying to extend note section accessor to be able to work with segments as well.

serge1 commented 2 years ago

Hi, Note segment accessor is available in commit feee9d4. In addition, elfdump prints out this data too.

isage commented 2 years ago

Awesome, thank you!