3 ms·
> I mostly allocate static areas in the BSS segment. How is this done from C code? Any code examples someone can point me to?
by ctrlmeta 4y ago
> I mostly allocate static areas in the BSS segment.
How is this done from C code? Any code examples someone can point me to?
- larve 4y agoHonestly just a global char foobar[256] = {0};
- deleted 4y ago[deleted]
- flyingfences 4y agoIt's not done in the code itself, it's done in the compiler configuration. We specify a mapping of memory ranges (based on the hardware and how we want to use it) and the compiler assigns addresses to variables within those ranges as appropriate. gcc calls these files "linker scripts", armcc "scatter files" -- those are the keywords to look up for examples and documentation.
- zen_1 4y agoBSS is the section of your program's address space where all the un/zero-initialized memory lives, so just a global std::array<u64, 1024> foo{}; would be placed in BSS by the compiler. BSS is also usually not included in the actual executable size (as it's marked as NOLOAD in the linkerscript), and needs to be zero-initialized by the C runtime if you want to guarantee that . https://en.wikipedia.org/wiki/.bss https://en.wikipedia.org/wiki/.bss