{"id":48483841,"url":"https://github.com/fzakaria/uld","last_synced_at":"2026-04-07T09:03:36.980Z","repository":{"id":331269666,"uuid":"1125588877","full_name":"fzakaria/uld","owner":"fzakaria","description":"A minimal Rust linker","archived":false,"fork":false,"pushed_at":"2026-01-01T03:23:00.000Z","size":106,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-05T07:16:08.970Z","etag":null,"topics":["compilers","educational","linker","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/fzakaria.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-31T02:07:37.000Z","updated_at":"2026-01-05T00:48:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/fzakaria/uld","commit_stats":null,"previous_names":["fzakaria/uld"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/fzakaria/uld","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzakaria%2Fuld","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzakaria%2Fuld/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzakaria%2Fuld/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzakaria%2Fuld/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fzakaria","download_url":"https://codeload.github.com/fzakaria/uld/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzakaria%2Fuld/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31506593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["compilers","educational","linker","rust"],"created_at":"2026-04-07T09:03:32.653Z","updated_at":"2026-04-07T09:03:36.974Z","avatar_url":"https://github.com/fzakaria.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# µld - A Minimal Rust Static Linker\n\n`uld` is a minimal static linker written in Rust for educational purposes. It targets **x86_64 Linux ELF** binaries.\n\n## Features\n\n- **Static linking** of object files (`.o`) and archives (`.a`)\n- **musl libc** support for fully static executables\n- **Works as a clang backend** via `-fuse-ld=/path/to/uld`\n- **Symbol resolution**: global, weak, and local symbols\n- **Relocations**: `R_X86_64_64`, `R_X86_64_PC32`, `R_X86_64_PLT32`, `R_X86_64_GOT*`\n- **GOT (Global Offset Table)** generation\n- **Selective archive linking**: only pulls in needed members\n\n## Design Philosophy\n\n- **Minimalism**: Core linking logic without legacy cruft\n- **Educational**: Code is structured to be readable\n- **Static-only**: No dynamic linking, no PLT trampolines\n- **Safe Rust**: Uses `object` crate for parsing, safe code throughout\n\n## Building\n\n```bash\ncargo build\n```\n\n## Usage\n\n### Direct invocation\n```bash\n./target/debug/uld -o output crt1.o crti.o main.o -L/path -lc crtn.o\n```\n\n### Via gcc driver (recommended)\n```bash\n# Compile and link a static binary using musl-gcc\nmusl-gcc -fuse-ld=/path/to/uld -static -o hello hello.c\n```\n\n## Project Structure\n\n```\nsrc/\n├── main.rs      # Entry point\n├── config.rs    # CLI argument handling\n├── linker.rs    # Core linking: load → layout → relocate\n├── symbol.rs    # Symbol table management\n├── layout.rs    # Section/Segment structures\n├── arch/        # Architecture-specific relocation handling\n│   └── x86_64.rs\n├── writer.rs    # ELF output generation\n└── utils.rs     # Utilities (alignment)\n```\n\n### Linking Phases\n\n1. **Load**: Parse object files and archives, build symbol table\n2. **Layout**: Map sections into segments, assign virtual addresses\n3. **Resolve**: Compute final address for each symbol\n4. **Relocate**: Patch code/data with resolved addresses\n5. **Write**: Generate ELF executable\n\n## Testing\n\nUses [LLVM lit](https://llvm.org/docs/CommandGuide/lit.html) for integration tests:\n\n```bash\n# Run all tests\nlit tests/\n\n# Run with verbose output\nlit tests/ -v\n```\n\n### Test Categories\n\n| Test | Description |\n|------|-------------|\n| `exit_42.s` | Minimal assembly, syscall exit |\n| `function_call.s` | Assembly function calls |\n| `c_return_42.c` | Basic C with custom start.s |\n| `libc_printf.c` | C with musl libc (manual CRT) |\n| `libc_printf_clang_driver.c` | C via clang driver |\n| `recursive_fib.c` | Recursive functions |\n| `large_bss_array.c` | Large BSS arrays |\n| `string_ops.c` | String operations |\n| `argc_argv.c` | Command-line arguments |\n\n## Requirements\n\n- Rust (stable)\n- musl-gcc (for libc tests)\n- LLVM lit and FileCheck (for running tests)\n\n## Limitations\n\n- x86_64 Linux only\n- No dynamic linking\n- No debug info (DWARF)\n- No linker scripts\n- No LTO\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffzakaria%2Fuld","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffzakaria%2Fuld","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffzakaria%2Fuld/lists"}