{"id":17250686,"url":"https://github.com/statusfailed/elf-from-scratch","last_synced_at":"2025-09-09T00:44:28.138Z","repository":{"id":145119667,"uuid":"144769790","full_name":"statusfailed/elf-from-scratch","owner":"statusfailed","description":"generate an ELF64 binary from scratch","archived":false,"fork":false,"pushed_at":"2019-01-18T13:03:15.000Z","size":8,"stargazers_count":17,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T05:17:29.297Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/statusfailed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2018-08-14T20:38:17.000Z","updated_at":"2025-03-10T13:39:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"9e3d883e-e0df-4636-b87c-fb18f058a30f","html_url":"https://github.com/statusfailed/elf-from-scratch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/statusfailed/elf-from-scratch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Felf-from-scratch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Felf-from-scratch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Felf-from-scratch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Felf-from-scratch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/statusfailed","download_url":"https://codeload.github.com/statusfailed/elf-from-scratch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Felf-from-scratch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274231033,"owners_count":25245687,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-15T06:49:20.008Z","updated_at":"2025-09-09T00:44:28.120Z","avatar_url":"https://github.com/statusfailed.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# elf-from-scratch\n\nThis was a challenge to myself: build an ELF64 file from scratch without using\na toolchain (other than an assembler to get raw `x86_64` instructions)\n\n[main.py](main.py) will write to stdout an executable ELF64 file with a single program header\ntable entry, and no sections.\n\n[main.py](main.py) currently hardcodes the program to write- it's \"hello world\".\nSee [asm/hello.asm](asm/hello.asm) for a program listing.\n\n[go.sh](go.sh) will run the main script, call `readelf -a` on the output, and run the\nELF64 file.\n\nHere's what `readelf` has to say about the produced ELF:\n\n\t\tELF Header:\n\t\t\tMagic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00\n\t\t\tClass:                             ELF64\n\t\t\tData:                              2's complement, little endian\n\t\t\tVersion:                           1 (current)\n\t\t\tOS/ABI:                            UNIX - System V\n\t\t\tABI Version:                       0\n\t\t\tType:                              EXEC (Executable file)\n\t\t\tMachine:                           Advanced Micro Devices X86-64\n\t\t\tVersion:                           0x1\n\t\t\tEntry point address:               0x400078\n\t\t\tStart of program headers:          64 (bytes into file)\n\t\t\tStart of section headers:          0 (bytes into file)\n\t\t\tFlags:                             0x0\n\t\t\tSize of this header:               64 (bytes)\n\t\t\tSize of program headers:           56 (bytes)\n\t\t\tNumber of program headers:         1\n\t\t\tSize of section headers:           0 (bytes)\n\t\t\tNumber of section headers:         0\n\t\t\tSection header string table index: 0\n\n\t\tThere are no sections in this file.\n\n\t\tThere are no sections to group in this file.\n\n\t\tProgram Headers:\n\t\t\tType           Offset             VirtAddr           PhysAddr\n\t\t\t\t\t\t\t\t\t\t FileSiz            MemSiz              Flags  Align\n\t\t\tLOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000\n\t\t\t\t\t\t\t\t\t\t 0x000000000000002f 0x000000000000002f  RWE    0x4\n\n\t\tThere is no dynamic section in this file.\n\n\t\tThere are no relocations in this file.\n\n\t\tThe decoding of unwind sections for machine type Advanced Micro Devices X86-64 is not currently supported.\n\n\t\tDynamic symbol information is not available for displaying symbols.\n\n\t\tNo version information found in this file.\n\n# TODO\n\n* Why does my program header table entry have to have an offset of 0? I get segfaults otherwise :(\n  - Might be due to [this][1] - seems like `p_offset` must be page aligned?\n\n[1]: https://stackoverflow.com/questions/5104060/elf-program-header-offset\n\n# references\n\nLinks I found useful while making this:\n\n- [ELF-64 Object File Format](https://www.uclibc.org/docs/elf-64-gen.pdf)\n- [Linux X86_64 syscalls table](http://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/)\n\n# useful commands\n\nsee [util/](util/) folder for handy scripts using the below commands.\n\nnasm assembler\n\n    # compile only x86_64 instructions\n    nasm -f bin -o out.bin in.asm\n\n    # compile to linkable elf\n    nasm -f elf64 -o out.o in.asm\n\nlink `out.o` file without stdlib and gcc cruft:\n\n    gcc out.o -o out.elf -nostartfiles -nostdinc -nostdlib\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatusfailed%2Felf-from-scratch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstatusfailed%2Felf-from-scratch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatusfailed%2Felf-from-scratch/lists"}