lundi 20 juin 2016

Code size with const objects

I have a few source files in which some const variables are required.
In the provided framework there is a .hpp header file that includes definitions (not only declarations) of those variables and this header is included in my source files mentioned before.
Then I realized, that each of my source files contains a copy of that RO data const variable, so in order to reduce memory footprint (I am working on ebdedded systems) I made one more .hpp that is included in my source files and which contains extern references to those variables (included somewhere else).
I compared build .o object information and saw that code size and RO data sizes are larger when using .hpp with extern references rather than with actual variables' definitions.
Why is that?

UPDATE: I have made the mistake. To be specific here is a fragment of linker map file: (note: RW, ZI removed)
Not using externs:
Code: 1192
(inc. data): 84
RO Data: 144

Using externs:
Code: 1392
(inc. data): 216
RO Data: 144

But my mistake has more new questions than answers:

  1. In this case, why RO (const data) size didn't change?
  2. What is inc. data in this scope?

Aucun commentaire:

Enregistrer un commentaire