1.1 --- a/lib/payload.c Sat Oct 27 17:16:55 2018 +0200
1.2 +++ b/lib/payload.c Sat Oct 27 21:51:40 2018 +0200
1.3 @@ -19,12 +19,14 @@
1.4
1.5 #include <stdint.h>
1.6
1.7 -extern uint8_t _data_original, _data;
1.8 +
1.9 +
1.10 +extern uint8_t _data_original, _data, _bss;
1.11
1.12 -/* This is defined using SIZEOF and its table entry contains the actual value.
1.13 - Its "address" provided by the table is therefore the value! */
1.14 +/* These are defined using SIZEOF and their table entries contain actual values.
1.15 + The "address" provided by each entry is therefore the value! */
1.16
1.17 -extern uint32_t _data_size;
1.18 +extern uint32_t _data_size, _bss_size;
1.19
1.20 /* Relocate the .data section's contents to initialise mutable structures. */
1.21
1.22 @@ -38,3 +40,13 @@
1.23 while (original < limit)
1.24 *current++ = *original++;
1.25 }
1.26 +
1.27 +/* Clear the .bss section. */
1.28 +
1.29 +void init_bss(void)
1.30 +{
1.31 + uint8_t *current = &_bss, *limit = current + (uint32_t) &_bss_size;
1.32 +
1.33 + while (current < limit)
1.34 + *current++ = 0;
1.35 +}