pyelftools | Parsing ELF and DWARF in Python

 by   eliben Python Version: 0.31 License: Non-SPDX

kandi X-RAY | pyelftools Summary

kandi X-RAY | pyelftools Summary

pyelftools is a Python library. pyelftools has no bugs, it has no vulnerabilities, it has build file available and it has high support. However pyelftools has a Non-SPDX License. You can install using 'pip install pyelftools' or download it from GitHub, PyPI.

Parsing ELF and DWARF in Python
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pyelftools has a highly active ecosystem.
              It has 1674 star(s) with 479 fork(s). There are 71 watchers for this library.
              There were 1 major release(s) in the last 6 months.
              There are 66 open issues and 148 have been closed. On average issues are closed in 207 days. There are no pull requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of pyelftools is 0.31

            kandi-Quality Quality

              pyelftools has 0 bugs and 0 code smells.

            kandi-Security Security

              pyelftools has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pyelftools code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              pyelftools has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              pyelftools releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              pyelftools saves you 5814 person hours of effort in developing the same functionality from scratch.
              It has 12660 lines of code, 973 functions and 110 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pyelftools and discovered the below as its top functions. This is intended to give you an instant insight into pyelftools implemented functionality, and help decide if they suit your requirements.
            • Display the version information
            • Iterate over all sections
            • Describe the version flags
            • Return the section at the given index n
            • Yield Location - like objects
            • Get the DIE from the attribute name
            • Iterate over the children of a die
            • Return an iterator over the DIE tree
            • Return a list of all entries in the binary
            • Display the contents of a section specification
            • Display a string representation of a section
            • Display dynamic tags
            • Display the file header
            • Display section headers
            • Parse a DIE
            • Greedy range
            • Describe locations
            • Dump all range lists
            • Dump the debug info
            • Display unwind section
            • Return the data of this section
            • Creates a PascalCase field
            • Process an ELF file
            • Display the available symbols
            • Display the relocations section
            • Display the program headers
            Get all kandi verified functions for this library.

            pyelftools Key Features

            No Key Features are available at this moment for pyelftools.

            pyelftools Examples and Code Snippets

            default
            Pythondot img1Lines of Code : 33dot img1no licencesLicense : No License
            copy iconCopy
            apt-get install python-pyelftools python-jinja2
            git clone https://github.com/kroemeke/bcc_dwarf_poc.git /tmp/minimal
            cd /tmp/minimal
            gcc -g3 -o minimal minimal.c
            
            marek@node:/tmp/minimal$ ./minimal
            0
            1
            2
            3
            4
            5
            6
            
            marek@node:/tmp/minimal$ sudo python   
            QEMU Development Toolkit,Getting started,Environment preparation
            Pythondot img2Lines of Code : 19dot img2License : Non-SPDX (NOASSERTION)
            copy iconCopy
            sudo apt install python-tk python3-tk
            
            sudo apt install idle-python2.7 idle-python3.4
            
            sudo apt install python-pip python3-pip
            
            sudo python -m pip install --upgrade gitpython six graphviz \
              path.py construct serial psutil
            
            sudo pip install --upgrad  
            PULP-SDK,Getting started
            Cdot img3Lines of Code : 6dot img3License : Permissive (Apache-2.0)
            copy iconCopy
            sudo apt-get install -y build-essential git libftdi-dev libftdi1 doxygen python3-pip libsdl2-dev curl cmake libusb-1.0-0-dev scons gtkwave libsndfile1-dev rsync autoconf automake texinfo libtool pkg-config libsdl2-ttf-dev
            
            pip install --user argcompl  

            Community Discussions

            QUESTION

            Fail to build Yocto extensible SDK
            Asked 2022-Jan-02 at 13:11

            I'm new to Yocto and I've been trying to setup for developing with devtool.

            I've followed the instructions from from the Yocto Linux Kernel Development Manual, but I've made a change to Step #2, setting MACHINE = stm32mp1 since I'm targeting the STM32MP157D-DK1. However, Step #5 fails, where it asks you to build the SDK using the command bitbake core-image-minimal -c populate_sdk_ext with the following error:

            ...

            ANSWER

            Answered 2022-Jan-02 at 13:11

            I've fixed the build issue. It required adding meta-python2 as I did; but instead of IMAGE_INSTALL_append = " python-dev", TOOLCHAIN_HOST_TASK_append = " nativesdk-python-core" is needed instead in local.conf.

            Source https://stackoverflow.com/questions/70554998

            QUESTION

            Change DWARF elf format in IAR ARM V8 compiler
            Asked 2021-Mar-01 at 10:32

            In our development, we switched from IAR ARM V7.40 to IAR ARM V8.40

            We are using the python package pyelftools for postprocessing of the debug information. Unfortunately, this seems to be broken now, as the V8-compiler seems to use DWARF4 syntax, which is not fully covered by pyelftools. The V7-compiler used DWARF3 which was fine.

            Is there any compiler option for IAR V8 to change DWARF format? In the IAR C/C++ Development Guide, I only find the --debug, -r option to enable debug information, but no further fine tunings (e.g. like -gdwarf-3 option for the arm-clang compiler).

            ...

            ANSWER

            Answered 2021-Mar-01 at 10:32

            There is a hidden compiler option --no_dwarf4 which disables DWARF4. This works fine for our problem.

            Unfortunately, this compiler option is neither documented in the IAR C/C++ Development Guide nor listed in the command line help ($ iccarm --help) for the compiler.

            Source https://stackoverflow.com/questions/66419060

            QUESTION

            How do I dump the contents of an ELF file at a specific address?
            Asked 2020-Nov-10 at 20:49

            Using GDB, if I load an ELF image and give it an address, I can get GDB to dump the contents of the ELF file at that address. For example:

            ...

            ANSWER

            Answered 2020-Nov-10 at 20:49

            I just want a dump of 20 bytes at location 0x06f8f5b0.

            Your question only makes sense in the context of position-dependent (i.e. ET_EXEC) binary (any other binary can be loaded at arbitrary address).

            For a position-dependent binary, the answer is pretty easy:

            • iterate over program headers until you find one which "covers" desired address,
            • from .p_vaddr and .p_offset compute the offset in the file
            • use lseek and read to read the bytes of interest.

            To make this more concrete, here is an example:

            Source https://stackoverflow.com/questions/64760653

            QUESTION

            Efficient way to parse DWARF
            Asked 2020-Oct-08 at 05:52

            I try to build a debugger which allows me to set breakpoints at functions or codelines. The needed debug information should be extracted from the DWARF section from an elf file. I am able to extract these data. The project I want to debug has 50-100 files, so I need about 10 min to parse the elf with readelf or pyelftools for all the dwarf infos I need. To increase speed, my next approach was to only parse for the debug infos of the currently opend source file. But it also takes a few minutes using pyelftools.

            How do debuggers get the informations so fast? I use an iSystem debugger with winIDEA and it takes about 20sec. to flash the elf and afterwards I am instantly able to set breakpoints in any source file.

            I am new to the topic so any help is appreciated.

            EDIT: This is how I use pyelftools to get function addresses from one file

            ...

            ANSWER

            Answered 2020-Oct-08 at 02:25

            How do debuggers get the informations so fast?

            By reading only the info they need (DWARF format is structured such that you can efficiently skip over translation units and functions you are not interested in), and by doing it in C.

            I need about 10 min to parse the elf with readelf or pyelftools

            That is likely significant part of your problem: parsing readelf output is probably 100 to 1000 times less efficient than reading the info directly.

            pyelftools does appear to provide an API to iterate over compilation units, and in theory should be able to provide efficient access.

            You didn't show how you are using it, you may not be doing that efficiently.

            Even then, pyelftools is implemented in pure Python, so likely is at least 10 times slower than something like libdwarf.

            Source https://stackoverflow.com/questions/64238017

            QUESTION

            Grabbing program header information with pyelftools
            Asked 2020-Aug-16 at 15:27

            I am simply trying to grab the program header information with pyelftools (the offset, virtual address, and physical address).

            This can be done from the terminal by running:

            readelf -l

            But I am having trouble getting the same information from pyelftools. From the examples, I have pieced together this:

            ...

            ANSWER

            Answered 2020-Aug-16 at 15:27

            Some strange things in your post happen.

            You say:

            I am simply trying to grab the program header information with pyelftools (the offset, virtual address, and physical address).

            Note: Elf_Shdr is the program header file.

            But Elf_Shdr is not Program header, it is Section header. Look at elftools/elf/structs.py

            Source https://stackoverflow.com/questions/63417042

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pyelftools

            You can install using 'pip install pyelftools' or download it from GitHub, PyPI.
            You can use pyelftools like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install pyelftools

          • CLONE
          • HTTPS

            https://github.com/eliben/pyelftools.git

          • CLI

            gh repo clone eliben/pyelftools

          • sshUrl

            git@github.com:eliben/pyelftools.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link