ToTamire
ToTamire

Reputation: 1693

Different memory for one variable from .bss section

I have a huge DDR memory (2GB) with huge access time and tiny internal RAM (1MB) with tiny access time. At this moment I have whole .bss section in DDR. The .bss section contains one often used variable from external library. How can I move it from slow DDR to fast RAM? There is no way to fit whole .bss in RAM and also I can't modify external library.

Disassembly of section .bss:
8000008c <some_variable>
.bss (NOLOAD) : {
   . = ALIGN(4);
   __bss_start = .;
   *(.bss)
   *(.bss.*)
   *(.gnu.linkonce.b.*)
   *(COMMON)
   . = ALIGN(4);
   __bss_end = .;
} > DDR

I tried someting like that, but its not work.

.bssFAST (NOLOAD) : {
   . = ALIGN(4);
   file.o:some_variable(.bss)
   . = ALIGN(4);
} > RAM

Upvotes: 0

Views: 165

Answers (1)

Employed Russian
Employed Russian

Reputation: 213375

I tried someting like that, but its not work.

That couldn't work: the linker doesn't work at the variable level, it works on sections.

If foo.os .bss section is not too large, you may be able to move that entire section into .bssFAST.

If you can't do that, your only other choice is to binary-patch foo.o such that:

  1. It has a new .bssFAST section (objcopy --add-section should work) and
  2. Change some_variable so it's in that new section (this should be relatively easy -- updating .st_shndx should do it).

Upvotes: 1

Related Questions