{"id":29014319,"url":"https://github.com/armmbed/mbed-os-linker-report","last_synced_at":"2025-06-25T20:13:11.358Z","repository":{"id":55131245,"uuid":"68648668","full_name":"ARMmbed/mbed-os-linker-report","owner":"ARMmbed","description":"Post-processing of linker output to calculate and visualize memory usage for elf-sections","archived":false,"fork":false,"pushed_at":"2021-01-07T23:25:20.000Z","size":654,"stargazers_count":45,"open_issues_count":3,"forks_count":14,"subscribers_count":9,"default_branch":"master","last_synced_at":"2023-08-03T07:54:22.488Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/ARMmbed.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}},"created_at":"2016-09-19T21:34:16.000Z","updated_at":"2023-06-07T21:02:22.000Z","dependencies_parsed_at":"2022-08-14T13:00:14.024Z","dependency_job_id":null,"html_url":"https://github.com/ARMmbed/mbed-os-linker-report","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"purl":"pkg:github/ARMmbed/mbed-os-linker-report","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fmbed-os-linker-report","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fmbed-os-linker-report/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fmbed-os-linker-report/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fmbed-os-linker-report/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ARMmbed","download_url":"https://codeload.github.com/ARMmbed/mbed-os-linker-report/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ARMmbed%2Fmbed-os-linker-report/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261945406,"owners_count":23234245,"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":"2025-06-25T20:13:09.966Z","updated_at":"2025-06-25T20:13:11.338Z","avatar_url":"https://github.com/ARMmbed.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binary Size Analysis\nThis repository is used to generate interactive linker statistics. Please have a look at our [interactive example](https://armmbed.github.io/mbed-os-linker-report/).\n\n## Installation\nInstall `arm-none-eabi-gcc` and add to your path. This will install `arm-none-eabi-nm`. The analysis tool require the executable `arm-none-eabi-nm` to be present in your environemntal PATH.\n\nThen clone the tool to a local directory\n```bash\ngit clone https://github.com/ARMmbed/mbed-os-linker-report\n```\n\n## Running the Analysis\n\n### File level analysis - any compiler, any compiler profile\n\nIf you want to know how much each file contributes to the final size of the binary mbed-cli provides these statistics at compile time:\n```\n\u003e mbed compile -m K64F -t GCC_ARM --stats-depth=100\nBuilding project mbed-os-example-blinky (K64F, GCC_ARM)\nScan: .\nScan: mbed\nScan: env\nScan: FEATURE_LWIP\nScan: FEATURE_STORAGE\n...\n+--------------------------------------------------------------------------------------------------------------------+-------+-------+------+\n| Module                                                                                                             | .text | .data | .bss |\n+--------------------------------------------------------------------------------------------------------------------+-------+-------+------+\n| [fill]                                                                                                             |    86 |     4 | 2369 |\n| [lib]/libc.a/lib_a-abort.o                                                                                         |    16 |     0 |    0 |\n| [lib]/libc.a/lib_a-closer.o                                                                                        |    36 |     0 |    0 |\n| [lib]/libc.a/lib_a-ctype_.o                                                                                        |   257 |     0 |    0 |\n| [lib]/libc.a/lib_a-fputwc.o                                                                                        |   264 |     0 |    0 |\n...\n...\n...\n| mbed-os/rtos/rtx5/mbed_rtx_handlers.o                                                                              |   649 |     0 |    0 |\n| mbed-os/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralPins.o               |   288 |     0 |    0 |\n| mbed-os/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/fsl_clock_config.o             |   120 |     0 |    0 |\n| mbed-os/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/sleep.o                                                |    16 |     0 |    0 |\n| Subtotals                                                                                                          | 44769 |  2680 | 9080 |\n+--------------------------------------------------------------------------------------------------------------------+-------+-------+------+\nTotal Static RAM memory (data + bss): 11760 bytes\nTotal Flash memory (text + data): 47449 bytes\n\nImage: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin\n```\n\nTo turn this data into the example visualisation:\n```\n\u003e mbed compile --stats-depth=100 | ../mbed-os-linker-report/binsize.py -b\n```\n\n### Symbol level analysis - arm gcc compiler, modified compiler profile\n\nFor performing the analysis, you need to recompile your program. You need to enable debugging info in your elf file by passing the `-g` option to `gcc`. The default mbed-os compile profile does not do this, hence you need to use the modified profile inside the `compiler_profiles` folder.\n```bash\n# For develop profile\n\u003e mbed compile -m K64F -t GCC_ARM -c --profile=../mbed-os-linker-report/compiler_profiles/develop.json\n# For release profile\n\u003e mbed compile -m K64F -t GCC_ARM -c --profile=../mbed-os-linker-report/compiler_profiles/release.json\n# For debug profile\n\u003e mbed compile -m K64F -t GCC_ARM -c --profile=debug\n```\n\nNote: if you have a custom compiler profile, you will need to add the `\"-g\"` flag in the `\"common\"` section.\n\nNow run the ELF linker statistics tool:\n```bash\n# Process Data: provide one or more elf files for analysis\n\u003e python ../mbed-os-linker-report/elfsize.py -i BUILD/K64F/GCC_ARM/mbed-os-example-blinky.elf -b\n```\nThis will open up a browser page automatically with the visualisation.\n\n## Advanced usage\n### More Options\n```\n\u003e python binsize.py -h\nusage: binsize.py [-h] [-o OUTPUT] [-b]\n\nAnalyse mbed compile output from stdin and generate a json data file for\nvisualisation\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -o OUTPUT, --output OUTPUT\n                        path of output json, defaults to\n                        /Users/leozhou/projects/mbed-os-linker-report/html\n                        /data-flare.js, default filename to data-flare.js if a\n                        folder is specified\n  -b, --browser         launch the pie chart visualisation in a browser\n\n\u003e python elfsize.py -h\nusage: elfsize.py [-h] -i [BINARY [BINARY ...]] [-o OUTPUT] [-b]\n\nAnalyse binary built by gcc and generate json containing binary size\ninformation\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -i [BINARY [BINARY ...]], --binary [BINARY [BINARY ...]]\n                        path to the binary. You can also specify multiple\n                        binaries: -i \u003cpath1\u003e \u003cpath2\u003e\n  -o OUTPUT, --output OUTPUT\n                        path of output json, defaults to\n                        /Users/leozhou/projects/mbed-os-linker-report/html\n                        /data-flare.js, default filename to data-flare.js if a\n                        folder is specified\n  -b, --browser         launch the pie chart visualisation in a browser\n```\n\n### Example for uVisor statistics\nFor uVisor the statistics of two ELF files need to be combined into a single JSON file. This is how it works:\n```bash\n# Download latest version of a uVisor enabled app\n\u003e mbed import mbed-os-example-uvisor\n# Change into that directory\n\u003e cd mbed-os-example-uvisor\n# Recompile uVisor - the command below needs to run twice due to a Makefile bug\n\u003e make -C mbed-os/features/FEATURE_UVISOR/importer\n# Recompile mbed-os app\n# For develop profile\n\u003e mbed compile -m K64F -t GCC_ARM -c --profile=../mbed-os-linker-report/compiler_profiles/develop.json\n# Combine both elf outputs into a singe JSON file\n\u003e python ../mbed-os-linker-report/elfsize.py -i mbed-os/features/FEATURE_UVISOR/importer/TARGET_IGNORE/uvisor/platform/kinetis/release/configuration_kinetis_cortex_m4_0x1fff0000.elf BUILD/K64F/GCC_ARM/mbed-os-example-uvisor.elf -b\n```\n\n## Example Output\nBelow you can find an example screenshot of our tool. Please have a look at our [interactive example](https://armmbed.github.io/mbed-os-linker-report/), too.\n![d3.js based ELF Linker Statistics](docs/example.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmmbed%2Fmbed-os-linker-report","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farmmbed%2Fmbed-os-linker-report","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmmbed%2Fmbed-os-linker-report/lists"}