Skip to content

How to get unused global variables into the IMEM as ROM #993

Answered by stnolting
Sam-Vervaeck asked this question in Q&A
Discussion options

You must be logged in to vote

I have a header file with test values that I would like to include in my IMEM as ROM. Currently, not all of them are used yet, so the compiler/linker optimizes them away. This is a slight problem because I do want to know how much the ROM image would increase in size if I would include the whole header file.

What do your test values look like? Just simple constants?

const test_a uint32_t = 123;

Therefore, i added my own section to the linker script and set it to be kept: [...]

Good idea! But I think the linker is smart enough to trim all non-referenced symbols (and sections). Therefore, I also think that it would be pointless to use attributes here (e.g. __attribute__((unused))).

Howe…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@Sam-Vervaeck
Comment options

@stnolting
Comment options

@Sam-Vervaeck
Comment options

Answer selected by Sam-Vervaeck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants