Home > Mobile >  Shared const data segment
Shared const data segment

Time:12-06

We have to share a large chunk of compile-time known data between processes. Is it possible to put into .rodata section of a shared library? What are the practical steps to do so?

CodePudding user response:

Is it possible to put into .rodata section of a shared library?

Yes.

What are the practical steps to do so?

If you declare the data const, compiler should already do it for you.
If that isn't already happening, please ask a separate question with an MCVE.

Or do you mean: "I have a data file which I'd like to include verbatim into my foo.so, without first transforming that data into a C-style array and compiling it?"

In that case, do this:

// foo.S
    .globl foo_data
    .section .rodata
foo_data:
    .incbin "foo.data"

compile foo.S and link it into your shared library.

  • Related