Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support parsing of dynamic ELFs w/out section headers #3

Closed
eliben opened this issue Jun 9, 2013 · 4 comments
Closed

support parsing of dynamic ELFs w/out section headers #3

eliben opened this issue Jun 9, 2013 · 4 comments

Comments

@eliben
Copy link
Owner

eliben commented Jun 9, 2013

Moving from bitbucket pull request #11 by Mike Frysinger:

support parsing of dynamic ELFs w/out section headers

At runtime, ELFs do not use the section headers at all. Instead, only
the program segments and dynamic tags get used. This means you can
strip the section table completely from an ELF and have it still work.

In practice, people rarely do this, but it's not unheard of. Make the
Dynamic tags work even in these cases by loading the strings table the
same way the runtime loader does:

  • parse the symtab address from DT_STRTAB
  • locate the file offset via the program segments

In order to avoid circular deps (parsing a dyntag requires walking parsed
dyntags), add a set of internal funcs for returning the raw values.
ave it still work.

@eliben
Copy link
Owner Author

eliben commented Jun 9, 2013

Raw patch from the pull request is here: https://dl.dropboxusercontent.com/u/15602400/pyelftools-issue3-patch.patch

@eliben
Copy link
Owner Author

eliben commented Jun 9, 2013

Additional information from OP:

$ eu-strip -g --strip-sections a.out
$ readelf -S a.out
<nothing>
$ lddtree.py ./a.out
a.out (interpreter => /lib64/ld-linux-x86-64.so.2)
    libïäöëß.so => None
    libc.so.6 => /lib64/libc.so.6

vadmium pushed a commit to vadmium/pyelftools that referenced this issue Feb 12, 2014
Various APIs are modified, but in a backwards compatible manner. Should close
eliben#3.

Original explanation from Mike Frysinger:

    At runtime, ELFs do not use the section headers at all.  Instead, only
    the program segments and dynamic tags get used.  This means you can strip
    the section table completely from an ELF and have it still work.
    
    In practice, people rarely do this, but it's not unheard of.  Make the
    Dynamic tags work even in these cases by loading the strings table the
    same way the runtime loader does:
     - parse the symtab address from DT_STRTAB
     - locate the file offset via the program segments
@vadmium
Copy link

vadmium commented Feb 12, 2014

I have restored this patch for reference: https://github.com/vadmium/pyelftools/compare/vapier

vadmium pushed a commit to vadmium/pyelftools that referenced this issue Feb 17, 2014
Signature of the Dynamic class constructor is modified, but it should be
compatible with before.

Should close eliben#3. Original explanation from Mike Frysinger:

    At runtime, ELFs do not use the section headers at all.  Instead, only
    the program segments and dynamic tags get used.  This means you can strip
    the section table completely from an ELF and have it still work.

    In practice, people rarely do this, but it's not unheard of.  Make the
    Dynamic tags work even in these cases by loading the strings table the
    same way the runtime loader does:
     - parse the symtab address from DT_STRTAB
     - locate the file offset via the program segments
@vapier
Copy link
Contributor

vapier commented Jun 17, 2014

we should be able to close this now that my updated change has been merged

@eliben eliben closed this as completed Jun 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants