{"id":15762087,"url":"https://github.com/harshkapadia2/parse-elf","last_synced_at":"2026-01-02T21:40:40.608Z","repository":{"id":238022362,"uuid":"795702963","full_name":"HarshKapadia2/parse-elf","owner":"HarshKapadia2","description":"A simple 64-bit ELF file parser.","archived":false,"fork":false,"pushed_at":"2024-09-15T02:42:38.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-11T11:27:04.738Z","etag":null,"topics":["c","elf","elf-parser","elf64"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HarshKapadia2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-03T21:06:57.000Z","updated_at":"2024-09-15T02:42:41.000Z","dependencies_parsed_at":"2024-09-12T07:39:05.857Z","dependency_job_id":"db313f4c-af4e-4819-9ac6-e4014ecb4940","html_url":"https://github.com/HarshKapadia2/parse-elf","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":0.12,"last_synced_commit":"4b8c1c81e5341ed7a20b16d54bb98b994956e1d5"},"previous_names":["harshkapadia2/parse-elf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshKapadia2%2Fparse-elf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshKapadia2%2Fparse-elf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshKapadia2%2Fparse-elf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshKapadia2%2Fparse-elf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HarshKapadia2","download_url":"https://codeload.github.com/HarshKapadia2/parse-elf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243478358,"owners_count":20297239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","elf","elf-parser","elf64"],"created_at":"2024-10-04T11:06:38.909Z","updated_at":"2026-01-02T21:40:40.571Z","avatar_url":"https://github.com/HarshKapadia2.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parse ELF\n\nA simple 64-bit [**E**xecutable and **L**inkable **F**ormat](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format)\nfile parser.\n\nThis utility parses and prints the ELF (File) Header, the Section Headers, the\nSegment (Program) Headers and the dynamic dependencies in the ELF file.\n\nThis utility is essentially a rudimentary clone of the `readelf` and `ldd` Linux\nutilities.\n\nThis utility is a part of [my talk on ELFs](https://talks.harshkapadia.me/elf).\n\n## Compilation and Execution Instructions\n\n-\tInstall GCC and Make\n\n\t```shell\n\t$ sudo apt-get update\n\t$ sudo apt-get install gcc make\n\t```\n\n-\tBuild the parser\n\n\t```shell\n\t$ make\n\t```\n\n-\tRun the parser\n\n\t```shell\n\t$ ./pelf \"/path/to/elf/file\"\n\t```\n\n-\tTo delete build files, run\n\n\t```shell\n\t$ make clean\n\t```\n\n-\tOptional: Formatting files\n\n\t```shell\n\t$ sudo apt-get install clang-format\n\t$ make format\n\t```\n\n## Sample Output\n\n```shell\n$ make\ngcc -Wall -pedantic -I include src/pelf.c -o pelf\nchmod +x pelf\n\n$ ./pelf \"/usr/bin/vim\"\n64-bit ELF File Parser\n\n\nELF details and value translations:\nhttps://en.wikipedia.org/wiki/Executable_and_Linkable_Format\n\nELF file path: /usr/bin/vim\n\n\nELF File 'File Header':\n\n-\u003e Magic number: 0x7f 0x45 0x4c 0x46 (0x7f E L F)\n-\u003e Class: 2\n-\u003e Data (Endianness): 1\n-\u003e Version: 1\n-\u003e OS/ABI: 00\n-\u003e ABI version: 00\n-\u003e Type: 0x03\n-\u003e Machine: 0x3e\n-\u003e Version: 1\n-\u003e Entry address: 0x4ead0\n-\u003e Program (segment) header table offset: 64 B into the file\n-\u003e Section header table offset: 3785904 B into the file\n-\u003e Flags: 0\n-\u003e This header\\'s size: 64 B\n-\u003e Program (segment) header size: 56 B\n-\u003e No. of program (segment) headers: 13\n-\u003e Section header size: 64 B\n-\u003e No. of section headers: 30\n-\u003e Index of the 'section name string table' section header in the section header\ntable: 29\n\n\nELF File Section Headers:\n\n[No.]   Name\n        Type            Address         Offset\n        Size            EntSize         Flags  Link     Info  Align\n---------------------------------------------------------------------\n[0]\n        NULL            0               0\n        0               0                    0          0     0\n---------------------------------------------------------------------\n[1]     .interp\n        PROGBITS                0x318           792\n        28              0               A     0         0     1\n---------------------------------------------------------------------\n[2]     .note.gnu.property\n        NOTE            0x338           824\n        48              0               A     0         0     8\n---------------------------------------------------------------------\n[3]     .note.gnu.build-id\n        NOTE            0x368           872\n        36              0               A     0         0     4\n---------------------------------------------------------------------\n[4]     .note.ABI-tag\n        NOTE            0x38c           908\n        32              0               A     0         0     4\n---------------------------------------------------------------------\n[5]     .gnu.hash\n        0x6ffffff6              0x3b0           944\n        240             0               A     6         0     8\n---------------------------------------------------------------------\n[6]     .dynsym\n        DYNSYM          0x4a0           1184\n        8568            24              A     7         1     8\n---------------------------------------------------------------------\n[7]     .dynstr\n        STRTAB          0x2618          9752\n        4267            0               A     0         0     1\n---------------------------------------------------------------------\n[8]     .gnu.version\n        0x6fffffff              0x36c4          14020\n        714             2               A     6         0     2\n---------------------------------------------------------------------\n[9]     .gnu.version_r\n        0x6ffffffe              0x3990          14736\n        320             0               A     7         5     8\n---------------------------------------------------------------------\n[10]    .rela.dyn\n        RELA            0x3ad0          15056\n        202464          24              A     6         0     8\n---------------------------------------------------------------------\n[11]    .rela.plt\n        RELA            0x351b0         217520\n        7704            24              IA     6        25     8\n---------------------------------------------------------------------\n[12]    .init\n        PROGBITS                0x37000         225280\n        27              0               XA     0        0     4\n---------------------------------------------------------------------\n[13]    .plt\n        PROGBITS                0x37020         225312\n        5152            16              XA     0        0     16\n---------------------------------------------------------------------\n[14]    .plt.got\n        PROGBITS                0x38440         230464\n        48              16              XA     0        0     16\n---------------------------------------------------------------------\n[15]    .plt.sec\n        PROGBITS                0x38470         230512\n        5136            16              XA     0        0     16\n---------------------------------------------------------------------\n[16]    .text\n        PROGBITS                0x39880         235648\n        2845383         0               XA     0        0     16\n---------------------------------------------------------------------\n[17]    .fini\n        PROGBITS                0x2f0348                3081032\n        13              0               XA     0        0     4\n---------------------------------------------------------------------\n[18]    .rodata\n        PROGBITS                0x2f1000                3084288\n        166822          0               A     0         0     32\n---------------------------------------------------------------------\n[19]    .eh_frame_hdr\n        PROGBITS                0x319ba8                3251112\n        37684           0               A     0         0     4\n---------------------------------------------------------------------\n[20]    .eh_frame\n        PROGBITS                0x322ee0                3288800\n        265108          0               A     0         0     8\n---------------------------------------------------------------------\n[21]    .init_array\n        INIT_ARRAY              0x365230                3555888\n        8               8               AW     0        0     8\n---------------------------------------------------------------------\n[22]    .fini_array\n        FINI_ARRAY              0x365238                3555896\n        8               8               AW     0        0     8\n---------------------------------------------------------------------\n[23]    .data.rel.ro\n        PROGBITS                0x365240                3555904\n        65792           0               AW     0        0     32\n---------------------------------------------------------------------\n[24]    .dynamic\n        DYNAMIC         0x375340                3621696\n        608             16              AW     7        0     8\n---------------------------------------------------------------------\n[25]    .got\n        PROGBITS                0x3755a0                3622304\n        2648            8               AW     0        0     8\n---------------------------------------------------------------------\n[26]    .data\n        PROGBITS                0x376000                3624960\n        160601          0               AW     0        0     32\n---------------------------------------------------------------------\n[27]    .bss\n        NOBITS          0x39d360                3785561\n        58176           0               AW     0        0     32\n---------------------------------------------------------------------\n[28]    .gnu_debuglink\n        PROGBITS                0               3785564\n        52              0                    0          0     4\n---------------------------------------------------------------------\n[29]    .shstrtab\n        STRTAB          0               3785616\n        285             0                    0          0     1\n---------------------------------------------------------------------\n\nSection Header flag legend:\nW (write), A (alloc), X (execute), M (merge), S (strings),\nI (info), L (link order), O (extra OS processing required),\nG (group), T (TLS), o (OS specific), P (processor specific),\nR (ordered), E (exclude)\n\n\nELF File Segment (Program) Headers:\n\nType            Offset          VirtAddr        PhysAddr\n                FileSiz         MemSiz          Flags  Align\n---------------------------------------------------------------------\nPHDR            0x40            0x40            0x40\n                0x2d8           0x2d8           R     0x8\n---------------------------------------------------------------------\nINTERP          0x318           0x318           0x318\n                0x1c            0x1c            R     0x1\n---------------------------------------------------------------------\nLOAD            0               0               0\n                0x36fc8         0x36fc8         R     0x1000\n---------------------------------------------------------------------\nLOAD            0x37000         0x37000         0x37000\n                0x2b9355                0x2b9355                RX     0x1000\n---------------------------------------------------------------------\nLOAD            0x2f1000                0x2f1000                0x2f1000\n                0x72a74         0x72a74         R     0x1000\n---------------------------------------------------------------------\nLOAD            0x364230                0x365230                0x365230\n                0x38129         0x46470         RW     0x1000\n---------------------------------------------------------------------\nDYNAMIC         0x374340                0x375340                0x375340\n                0x260           0x260           RW     0x8\n---------------------------------------------------------------------\nNOTE            0x338           0x338           0x338\n                0x30            0x30            R     0x8\n---------------------------------------------------------------------\nNOTE            0x368           0x368           0x368\n                0x44            0x44            R     0x4\n---------------------------------------------------------------------\n0x6474e553              0x338           0x338           0x338\n                0x30            0x30            R     0x8\n---------------------------------------------------------------------\n0x6474e550              0x319ba8                0x319ba8                0x319ba8\n                0x9334          0x9334          R     0x4\n---------------------------------------------------------------------\n0x6474e551              0               0               0\n                0               0               RW     0x10\n---------------------------------------------------------------------\n0x6474e552              0x364230                0x365230                0x365230\n                0x10dd0         0x10dd0         R     0x1\n---------------------------------------------------------------------\n\nProgram (Segment) Header flag legend:\nX (execute), W (write), R (read)\n\n\nDynamic dependencies listed in the ELF file:\n-\u003e libm.so.6\n-\u003e libtinfo.so.6\n-\u003e libselinux.so.1\n-\u003e libsodium.so.23\n-\u003e libacl.so.1\n-\u003e libgpm.so.2\n-\u003e libpython3.10.so.1.0\n-\u003e libc.so.6\n\nNOTE: Each dependency might have its own dependencies.\n\n\n```\n\n## Resources\n\n[talks.harshkapadia.me/elf](https://talks.harshkapadia.me/elf)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshkapadia2%2Fparse-elf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharshkapadia2%2Fparse-elf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshkapadia2%2Fparse-elf/lists"}