# Binsize tool
Tool for analyzing the sizes of symbols in binaries.
It can be used to find out which symbols are taking up the most space in a binary.
It requires `bloaty` and `nm` tools to be installed.
It analyzes the `.elf` file and optionally also the `.map` file from the binary creation process.
## Tool basic usage
Installable by `pip install binsize` - see [PyPI](https://pypi.org/project/binsize/).
Installing this package creates `binsize` command, which has a lot of subcommands seeable by `binsize --help`. For example
```bash
$ binsize get firmware.elf -d
$ binsize compare firmware.elf other_firmware.elf
$ binsize tree firmware.elf
```
`--help` can be used even on the subcommands, for example `binsize get --help` - to see all available options.
Result will be usually printed into terminal, unless specifying `--output` option which some commands support.
## Setting root directory
To resolve all the files properly, the project's root directory needs to be set correctly.
There are couple of possibilities how to do it.
In the end, all of them are changing the `root` value in `settings.json`, from where everything else gets the value. It needs to be an absolute path.
`settings.json` will be created in a user's home directory, based on `platformdirs` library (`~/.config/binsize/settings.json` on `linux`).
### Manually
Just modifying the `root` in the `settings.json` file.
### Via environmental variable
`BINSIZE_ROOT_DIR` env variable is checked and when not empty, it will set the root directory.
e.g. `BINSIZE_ROOT_DIR=/home/user/project binsize tree /path/to/file.elf`
### Via CLI argument
`binsize` accepts `-r / --root-dir` argument, which can be used to set the root directory.
It has lower priority than the environmental variable.
e.g. `binsize -r /home/user/project tree /path/to/file.elf`
### Via exposed function
`binsize` exposes `set_root_dir` function, which can be called from any `python` script.
e.g. `binsize.set_root_dir("/home/user/project")`
---
TODO: document all the CLI commands, exportable symbols, basic functioning, ways to extend it, etc.
Raw data
{
"_id": null,
"home_page": "https://github.com/grdddj/binsize",
"name": "binsize",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "binary size,code size,.elf file",
"author": "SatoshiLabs",
"author_email": "info@satoshilabs.com",
"download_url": "https://files.pythonhosted.org/packages/37/3f/268cb0091c7230811bb54e46ef7235d86bd987003f550017ca50c3a1e8f8/binsize-0.1.3.tar.gz",
"platform": null,
"description": "# Binsize tool\n\nTool for analyzing the sizes of symbols in binaries.\n\nIt can be used to find out which symbols are taking up the most space in a binary.\n\nIt requires `bloaty` and `nm` tools to be installed.\n\nIt analyzes the `.elf` file and optionally also the `.map` file from the binary creation process.\n\n## Tool basic usage\n\nInstallable by `pip install binsize` - see [PyPI](https://pypi.org/project/binsize/).\n\nInstalling this package creates `binsize` command, which has a lot of subcommands seeable by `binsize --help`. For example\n\n```bash\n$ binsize get firmware.elf -d\n$ binsize compare firmware.elf other_firmware.elf\n$ binsize tree firmware.elf\n```\n\n`--help` can be used even on the subcommands, for example `binsize get --help` - to see all available options.\n\nResult will be usually printed into terminal, unless specifying `--output` option which some commands support.\n\n## Setting root directory\nTo resolve all the files properly, the project's root directory needs to be set correctly.\n\nThere are couple of possibilities how to do it.\n\nIn the end, all of them are changing the `root` value in `settings.json`, from where everything else gets the value. It needs to be an absolute path.\n\n`settings.json` will be created in a user's home directory, based on `platformdirs` library (`~/.config/binsize/settings.json` on `linux`).\n\n### Manually\nJust modifying the `root` in the `settings.json` file.\n\n### Via environmental variable\n`BINSIZE_ROOT_DIR` env variable is checked and when not empty, it will set the root directory.\n\ne.g. `BINSIZE_ROOT_DIR=/home/user/project binsize tree /path/to/file.elf`\n\n### Via CLI argument\n`binsize` accepts `-r / --root-dir` argument, which can be used to set the root directory.\n\nIt has lower priority than the environmental variable.\n\ne.g. `binsize -r /home/user/project tree /path/to/file.elf`\n\n### Via exposed function\n`binsize` exposes `set_root_dir` function, which can be called from any `python` script.\n\ne.g. `binsize.set_root_dir(\"/home/user/project\")`\n\n---\n\nTODO: document all the CLI commands, exportable symbols, basic functioning, ways to extend it, etc.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Tool to analyze the size of a binary from .elf file",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/grdddj/binsize",
"Repository": "https://github.com/grdddj/binsize"
},
"split_keywords": [
"binary size",
"code size",
".elf file"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8a6c0ddb5bc8fe5f513a74709cdf8dd6da7894d0a9cb05420e759e6d35ac1cc6",
"md5": "8186078c9c59df8827767c221c0342b2",
"sha256": "af041e449aab8b7166ae404ddb1d8d7815add3196f079f5da48eb4d9e5981205"
},
"downloads": -1,
"filename": "binsize-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8186078c9c59df8827767c221c0342b2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 39982,
"upload_time": "2023-07-27T08:35:57",
"upload_time_iso_8601": "2023-07-27T08:35:57.183678Z",
"url": "https://files.pythonhosted.org/packages/8a/6c/0ddb5bc8fe5f513a74709cdf8dd6da7894d0a9cb05420e759e6d35ac1cc6/binsize-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "373f268cb0091c7230811bb54e46ef7235d86bd987003f550017ca50c3a1e8f8",
"md5": "b92b05aa8b6a600682d5b2fd0796824b",
"sha256": "d3a92381eefe61ab4cd29f5d71d8d59de6b9622452e4cbc8422cdf926cf61dd1"
},
"downloads": -1,
"filename": "binsize-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "b92b05aa8b6a600682d5b2fd0796824b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 29362,
"upload_time": "2023-07-27T08:35:58",
"upload_time_iso_8601": "2023-07-27T08:35:58.955133Z",
"url": "https://files.pythonhosted.org/packages/37/3f/268cb0091c7230811bb54e46ef7235d86bd987003f550017ca50c3a1e8f8/binsize-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-27 08:35:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "grdddj",
"github_project": "binsize",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "binsize"
}