Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22040

How to add a section with variables using the linker, and modifying afterwards using objcopy --update-section

$
0
0

I have declared this section in my linker, the memory definition is this:

POSTBUILD (rx) : ORIGIN = 0x08003E00, LENGTH = 512

and the section is this:

  .Postbuild :  {    . = ALIGN(4);    KEEP(*(.PN))   /* Product Number */    . = ALIGN(4);    KEEP(*(.SN))   /* Serial Number */    . = ALIGN(4);    KEEP(*(.FW))   /* Firmware ID */    . = ALIGN(4);    KEEP(*(.HW))   /* Hardware ID */    . = ALIGN(4);  } >POSTBUILD

In my code I added this:

__attribute__ ((section(".PN"))) const uint8_t HW_PN[16] = {"41324E4F47505301"}; ///< Hardware part number__attribute__ ((section(".SN"))) const uint8_t HW_SN[16] = {"SERIAL_NUMBER___"}; ///< Hardware serial number__attribute__ ((section(".HW"))) const uint8_t HW_HW[16] = {"HARDWARE_VERSION"}; ///< Hardware version/revision__attribute__ ((section(".FW"))) const uint8_t HW_FW[16] = {"FIRMWARE_VERSION"}; ///< Firmware version

My intention is to run a postbuild script to update those fields using, for .FW example, arm-none-eabi-objcopy --update-section .FW=$FW_VERSION" "$ELF_FILE" where the $FW_VERSION is the version and the $ELF_FILE is my .elf file. But when I run it I get this message:

arm-none-eabi-objcopy: error: .FW not found, can't be updated

When I run readelf I don't see any section called .FW, just .Postbuild, and I was expecting to see all those sections just after .Postbuild. What am I doing wrong?


Viewing all articles
Browse latest Browse all 22040

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>