Search code examples
cembeddedmicrochipxc16

Memory map shows space allocated to mystery variables _powers_ and _npowers_


I've been looking at the memory map for my code (written in c and compiled by the XC16 compiler), and see significant space allocated to powers, npowers, and dpowers in the .data segment.

Does anyone know what this allocation is used for?

My code uses the floating point library, as well as printf/scanf - could this be working space for these functions?

Here are two snippets from the map file:

section                    address      alignment gaps    total length  (dec)
-------                    -------      --------------    -------------------
...
.data._powers_              0x20b2                   0            0xb0  (176)
.data._npowers_             0x2162                   0            0xb0  (176)
.data.dpowers               0x2212                   0           0x140  (320)

...and...

.data._powers_      0x20b2         0xb0
.data._powers_
                    0x20b2         0xb0 c:/program files (x86)/microchip/xc16/v1.24/bin/bin/../../lib\libc-coff.a(powers.epo)
                    0x20b2                  _powers_

.data._npowers_
                    0x2162         0xb0
.data._npowers_
                    0x2162         0xb0 c:/program files (x86)/microchip/xc16/v1.24/bin/bin/../../lib\libc-coff.a(powers.epo)
                    0x2162                  _npowers_

.data.dpowers       0x2212        0x140
.data.dpowers      0x2212         0xa0 c:/program files (x86)/microchip/xc16/v1.24/bin/bin/../../lib\libc-coff.a(doprnt_cdfFnopsuxX.EPo)
.data.dpowers      0x22b2         0xa0 c:/program files (x86)/microchip/xc16/v1.24/bin/bin/../../lib\libc-coff.a(doprnt.epo)

Solution

  • You would have to look at the source for the version of libc to get a categorical answer. I did look at the source for one and found that, in that implementation, dpowers was a table of constants (powers of 10) used for output (doprnt). I suspect the others are similar.

    Note - while constants, these are not in a read-only section due to language limitations.