c - Can I map global variables to a section other than the .data or .bss sections? -


what happen if not map global variables in .data or .bss section. when try map in different section other .bss , .data, takes garbage value.

can define other section global variables other .bss or .data?

before execution of main(), memory setup takes place.

in case of embedded environments, built tools (compiler, linker etc.) bring code files named "crte" (c runtime environment) have code that. maybe if have special (expensive) contract compiler manufacturer, otherwise might not allow insight.
code fill "bss" section 0 , "data" section defined values. defined values found in non-volatile memory in section called "data.rom", gets copied "data" section.

if create section, not automatically convenient service. not without special precautions. result values happen in memory after power-on. not random number generator, pretty unpredictable. match description "garbage value".

either find out how crte that, or yourself.
way crte linker directive file. should allow configurations user defined sections. maybe "init0", or "init .rom". manual should of course define environment.

for doing (probably commercially less optimal method, i.e. risky, time consuming), "just" make sure code executed writes values section - before accessing variables first time. linker publishes symbols compiler-visible list of identifiers, "__linker_section__begin" , "__linker_section__end". use memory addresses right.


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -