0

I guess, though I'm not quite sure, that,like the text segment of an ELF file in tmpfs, where the instructions can be executed in place, the data segment in the file doesn't need to be copied until the program is trying to modify the value of a global variable (or a static local variable). That is called COPY ON WRITE.

To my project, however, it doesn't matter that the ELF files in tmpfs are modified. So I wonder if it would possible to write directly to the data segment of an ELF file while writing a global variable in it. I think this would save a lot of RAM space.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
xiaokaoy
  • 1,608
  • 3
  • 15
  • 27
  • How big is the variable that you're thinking of writing? Unless you do a lot of work, you won't save any RAM anyway because the system will allocate the space for the variable as usual. You'd have to finagle the system into not allocating that space but writing to the tmpfs locations instead. It doesn't sound practical or sensible to me. – Jonathan Leffler Aug 23 '16 at 05:35
  • Are you talking about the `.data` section or do you mean data section to include both `.bss` and `.data` (uninitialized and initialized respectively). – dave Aug 23 '16 at 05:40
  • We have nearly 60 ELF files on each board running embedded Linux. Some of them have over 50MB of global variables. I mean the .data section, not including the .bss section, which needs additional pages in RAM to be allocated when either reading or writing an uninitialized variable. – xiaokaoy Aug 23 '16 at 06:24
  • The problem is, no sufficient memory is available to start some services now. – xiaokaoy Aug 23 '16 at 06:35

0 Answers0