将section属性添加到llvm中的全局变量
Add section attribute to global variable in llvm
int x `__attribute__ ((section("some_name")))`;
我有一个全局变量 x
并想向其添加 __attribute__ ((section("custom_name")))
。我将如何在 LLVM 中做到这一点?
我创建了全局变量 x
,如下所示。
GlobalVariable *x =
new GlobalVariable(M, Type::getInt32Ty(C), false, GlobalValue::ExternalLinkage, 0,
"x");
您可以使用
void GlobalObject::setSection(StringRef S)
来自父 class GlobalObject 的方法。
GlobalVariable *x = new GlobalVariable(...);
x->setSection(".lrodata") // >2GB rodata on Linux x86_64
x->setAlignment(llvm::Align(N));
int x `__attribute__ ((section("some_name")))`;
我有一个全局变量 x
并想向其添加 __attribute__ ((section("custom_name")))
。我将如何在 LLVM 中做到这一点?
我创建了全局变量 x
,如下所示。
GlobalVariable *x =
new GlobalVariable(M, Type::getInt32Ty(C), false, GlobalValue::ExternalLinkage, 0,
"x");
您可以使用
void GlobalObject::setSection(StringRef S)
来自父 class GlobalObject 的方法。
GlobalVariable *x = new GlobalVariable(...);
x->setSection(".lrodata") // >2GB rodata on Linux x86_64
x->setAlignment(llvm::Align(N));