How to add a writeable llvm section by IRbuilder?

I want to encrypt the special constant and store it to somewhere section writeable by IRbuilder.
The data could be very large, I wonder whether I can assign some of the global variable to an special new section( has the different name, not like bss or other section).
So that the binary could be added that writeable section which only store my target data.

Yes you can specify a section for a global in clang
Attributes in Clang — Clang 16.0.0git documentation
which means you can do it in LLVM-IR. I’d need to check if the IRBuilder exposes the
functionality but you can certainly modify the section directly with the GlobalVariable (as describe here LLVM Language Reference Manual — LLVM 16.0.0git documentation)

FWIW, there is a clang mailing list that is often the faster way to get help
and there is a generic llvm one as well
llvm-dev Info Page


Thanks a lot.
I’ve solved it using GV->setSection function