Author Topic: ELF .data section compression tool  (Read 709 times)

0 Members and 1 Guest are viewing this topic.

Offline abyrvalgTopic starter

  • Frequent Contributor
  • **
  • Posts: 825
  • Country: es
ELF .data section compression tool
« on: April 28, 2023, 08:03:51 pm »
I've coded a tool implementing a feature available for a long time in commercial ARM compilers (AC, IAR), but missing in GCC: build-time .data section compression and startup-time decompression.
Normally, GCC .ld script contains directives placing entire initialized data section image into flash as is (with something like .data : { *(.data*) } > ram AT > flash) and startup code contains some form of memcpy(to_ram, from_flash, size). Sometimes this results in quite significant (if you are trying to squeeze the project into a cheaper part) flash image size grows. I.e. a careless declaration like unsigned mydata[1024] = { 1 } would occupy 4K of flash to store a single 01 byte followed by 4095 zeroes to be copied to RAM. The tool attempts to compress the .data init image (trying several simple algos and selecting the most efficient one), appends a small decompression function and the compressed image. A modified startup code calls the decompressor outputting decompressed data into RAM.
Perhaps someone will find it useful: https://github.com/flowswitch/elf-data-compress
 
The following users thanked this post: peter-h, GromBeestje


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf