From d85efe0b10f1f8ed4b854717f994062a4bbffe26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20=C3=98ye=20Amundsen?= Date: Thu, 29 Nov 2018 12:12:19 +0000 Subject: [PATCH] arch: arm: Add symbol for flash used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add symbol which contains the number of bytes contained in the image. Using '_image_rom_end' will not work, as there are symbols loaded after its value. Signed-off-by: Håkon Øye Amundsen --- include/arch/arm/cortex_m/scripts/linker.ld | 9 +++++++++ include/linker/linker-defs.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/include/arch/arm/cortex_m/scripts/linker.ld b/include/arch/arm/cortex_m/scripts/linker.ld index 6c3d23717c9..1f8b1cc5a59 100644 --- a/include/arch/arm/cortex_m/scripts/linker.ld +++ b/include/arch/arm/cortex_m/scripts/linker.ld @@ -518,4 +518,13 @@ SECTIONS KEEP(*(.gnu.attributes)) } +/* Must be last in romable region */ +SECTION_PROLOGUE(.last_section,(NOLOAD),) +{ +} GROUP_LINK_IN(ROMABLE_REGION) + +/* To provide the image size as a const expression, + * calculate this value here. */ +_flash_used = LOADADDR(.last_section) - _image_rom_start; + } diff --git a/include/linker/linker-defs.h b/include/linker/linker-defs.h index f7a96898bdf..bb95f421235 100644 --- a/include/linker/linker-defs.h +++ b/include/linker/linker-defs.h @@ -233,6 +233,9 @@ extern char _image_rom_start[]; extern char _image_rom_end[]; extern char _image_rom_size[]; +/* Includes all ROMable data, i.e. the size of the output image file. */ +extern char _flash_used[]; + /* datas, bss, noinit */ extern char _image_ram_start[]; extern char _image_ram_end[];