{"id":13472782,"url":"https://github.com/rust-embedded/cargo-binutils","last_synced_at":"2025-05-14T05:08:26.404Z","repository":{"id":31632631,"uuid":"128481245","full_name":"rust-embedded/cargo-binutils","owner":"rust-embedded","description":"Cargo subcommands to invoke the LLVM tools shipped with the Rust toolchain","archived":false,"fork":false,"pushed_at":"2025-04-20T15:57:19.000Z","size":230,"stargazers_count":534,"open_issues_count":16,"forks_count":48,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-20T16:37:40.678Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-embedded.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-04-06T23:53:00.000Z","updated_at":"2025-04-20T15:57:21.000Z","dependencies_parsed_at":"2024-11-19T02:15:33.739Z","dependency_job_id":"d97b7f2b-b3bd-4b18-92de-b0ac4e6fdc59","html_url":"https://github.com/rust-embedded/cargo-binutils","commit_stats":{"total_commits":131,"total_committers":24,"mean_commits":5.458333333333333,"dds":0.6183206106870229,"last_synced_commit":"7abd59489ce1ff1ce724cb640f4b91b031a904d8"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Fcargo-binutils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Fcargo-binutils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Fcargo-binutils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-embedded%2Fcargo-binutils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-embedded","download_url":"https://codeload.github.com/rust-embedded/cargo-binutils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076776,"owners_count":22010611,"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":[],"created_at":"2024-07-31T16:00:57.960Z","updated_at":"2025-05-14T05:08:26.338Z","avatar_url":"https://github.com/rust-embedded.png","language":"Rust","readme":"# `cargo-binutils`\n\n\u003e Cargo subcommands to invoke the LLVM tools shipped with the Rust toolchain\n\n**NOTE** This is **not** an official Rust project.\n\nThis project is developed and maintained by the [Embedded WG Tools team][team].\n\n## Features\n\n- All Rust symbols in the output of the LLVM tools are automatically demangled.\n- No need to pass the path to the artifact as an argument if using the tool in\n  \"build and inspect\" mode.\n\n## Installation\n\n``` console\n$ cargo install cargo-binutils\n\n$ rustup component add llvm-tools\n```\n\n## Usage\n\nThis:\n\n``` console\n$ rust-$tool ${args[@]}\n```\n\nis basically sugar for:\n\n``` console\n$ $(find $(rustc --print sysroot) -name llvm-$tool) ${args[@]}\n```\n\nApart from these `rust-*` tools, which are direct proxies for the llvm tools in\nthe `llvm-tools` component, the crate also provides some Cargo\nsubcommands that will first build the project and then run the llvm tool on the\noutput artifact. This:\n\n``` console\n$ cargo size --example foo\n```\n\nis sugar for:\n\n``` console\n$ cargo build --example foo\n$ rust-size target/examples/foo\n```\n\nThese commands take similar options to `cargo build` and you can specify\na specific binary with `--bin NAME`, an example with `--example NAME`\nor the default binary by not passing `--bin` or `--example`.\n\nIn the case of `cargo-objdump` the architecture of the compilation target is\npassed as `-arch-name=$target` to `llvm-objdump`. `-arch-name` specifies to\nwhich architecture disassemble the object file to.\n\nYou can get more information about the CLI of each tool by running `rust-$tool\n -help`.\n\nAll the Cargo subcommands accept a `--verbose` / `-v` flag. In verbose mode the\n`rust-$tool` invocation will be printed to stderr.\n\nBuild and inspect mode: Some subcommands accept the flags: `--bin`, `--example`,\n`--lib`, `--target` and `--release`. These can be used to make the subcommand\nfirst build the respective binary, example or library and have the path to the\nartifact be automatically passed to the LLVM tool. This mode only works when the\nsubcommand is used from within a Cargo project.\n\n*Disclaimer* Note that `cargo-binutils` simply proxies the LLVM tools in the\n`llvm-tools` component and the Rust project makes no guarantee about the\navailability and the CLI of these tools -- i.e. the availability and CLI of\nthese tools may change as new Rust releases are made.\n\n## Examples\n\n### `nm`\n\nList all symbols in an executable\n\n``` console\n$ cargo nm --release\n0800040a T BusFault\n0800040a T DebugMonitor\n0800040a T DefaultHandler\n0800065e T HardFault\n0800040a T MemoryManagement\n0800040a T NonMaskableInt\n0800040a T PendSV\n0800040c T Reset\n0800040a T SVCall\n0800040a T SysTick\n0800040a T UsageFault\n08000408 T UserHardFault\n08000008 R __EXCEPTIONS\n08000040 R __INTERRUPTS\n08000004 R __RESET_VECTOR\n08000000 R __STACK_START\n```\n\nList all symbols in an executable sorted by size (smallest first).\n\n``` console\n$ cargo nm --release -- --print-size --size-sort\n0800040a 00000002 T DefaultHandler\n08000408 00000002 T UserHardFault\n08000004 00000004 R __RESET_VECTOR\n08000400 00000008 T main\n08000008 00000038 R __EXCEPTIONS\n0800040c 00000252 T Reset\n08000040 000003c0 R __INTERRUPTS\n```\n\n### `objcopy`\n\nTransform the output of Cargo (ELF) into binary format.\n\n``` console\n$ cargo objcopy --release -- -O binary app.bin\n\n$ stat --printf=\"%s\\n\" app.bin\n1642\n```\n\n### `objdump`\n\nDisassemble a binary.\n\n``` console\n$ cargo objdump --release -- --disassemble --no-show-raw-insn\ntarget/thumbv7m-none-eabi/debug/app:    file format ELF32-arm-little\n\nDisassembly of section .text:\nmain:\n 8000400:       push    {r7, lr}\n 8000402:       bl      #608\n 8000406:       b       #-8 \u003cmain+0x2\u003e\n\nUserHardFault:\n 8000408:       trap\n\nUsageFault:\n 800040a:       trap\n\nReset:\n 800040c:       push.w  {r4, r5, r6, r7, r8, lr}\n 8000410:       movw    r0, #0\n 8000414:       movw    r2, #0\n 8000418:       movt    r0, #8192\n 800041c:       movt    r2, #8192\n(..)\n```\n\n### `size`\n\nPrint binary size in System V format\n\n``` console\n$ cargo size --release -- -A -x\ntarget/thumbv7m-none-eabi/release/app  :\nsection               size         addr\n.vector_table        0x400    0x8000000\n.text                0x26a    0x8000400\n.rodata                0x2    0x800066a\n.data                    0   0x20000000\n.bss                     0   0x20000000\n.debug_str          0x107e            0\n.debug_loc           0x3e2            0\n.debug_abbrev        0x31b            0\n.debug_info         0x19f9            0\n.debug_ranges         0xe8            0\n.debug_macinfo         0x1            0\n.debug_pubnames      0x9ff            0\n.debug_pubtypes      0x8dd            0\n.ARM.attributes       0x2e            0\n.debug_frame          0x6c            0\n.debug_line          0x69b            0\n.debug_aranges        0x40            0\nTotal               0x531a\n```\n\n### `strip`\n\nStrip all symbols from the build artifact\n\n``` console\n$ stat --printf=\"%s\\n\" target/release/hello\n4094240\n\n$ cargo-strip --release -- --strip-all -o smaller-hello\n\n$ stat --printf=\"%s\\n\" smaller-hello\n424432\n```\n\n### `rust-lld`\n\nProvides a link to `lld`.\nUsed to change the linker or providing a workaround if `-C linker-flavor` is not doing the job.\n\n`.cargo/config`\n```toml\n[target.wasm32-unknown-unknown]\nlinker = \"rust-lld\"\n```\n\n## Minimum Supported Rust Version (MSRV)\n\nThis crate is guaranteed to compile on stable Rust 1.70.0 and up.\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\n## Code of Conduct\n\nContribution to this crate is organized under the terms of the [Rust Code of\nConduct][CoC], the maintainer of this crate, the [Embedded WG Tools team][team], promises\nto intervene to uphold that code of conduct.\n\n[CoC]: CODE_OF_CONDUCT.md\n[team]: https://github.com/rust-embedded/wg#the-tools-team\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-embedded%2Fcargo-binutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-embedded%2Fcargo-binutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-embedded%2Fcargo-binutils/lists"}