From f14642f2f185f9af290f9fcace4851adbbe16432 Mon Sep 17 00:00:00 2001 From: Dmitry Mikulin Date: Tue, 15 Oct 2019 18:31:10 +0000 Subject: Added support for "#pragma clang section relro=" Differential Revision: https://reviews.llvm.org/D68806 llvm-svn: 374934 --- clang/lib/CodeGen/CGDecl.cpp | 2 ++ clang/lib/CodeGen/CodeGenModule.cpp | 3 +++ 2 files changed, 5 insertions(+) (limited to 'clang/lib/CodeGen') diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 46ea9c32eee..563841c068f 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -419,6 +419,8 @@ void CodeGenFunction::EmitStaticVarDecl(const VarDecl &D, var->addAttribute("data-section", SA->getName()); if (auto *SA = D.getAttr()) var->addAttribute("rodata-section", SA->getName()); + if (auto *SA = D.getAttr()) + var->addAttribute("relro-section", SA->getName()); if (const SectionAttr *SA = D.getAttr()) var->setSection(SA->getName()); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index eab48ccb9b7..c97e7b22170 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1717,6 +1717,8 @@ void CodeGenModule::setNonAliasAttributes(GlobalDecl GD, GV->addAttribute("data-section", SA->getName()); if (auto *SA = D->getAttr()) GV->addAttribute("rodata-section", SA->getName()); + if (auto *SA = D->getAttr()) + GV->addAttribute("relro-section", SA->getName()); } if (auto *F = dyn_cast(GO)) { @@ -4118,6 +4120,7 @@ static bool isVarDeclStrongDefinition(const ASTContext &Context, // If no specialized section name is applicable, it will resort to default. if (D->hasAttr() || D->hasAttr() || + D->hasAttr() || D->hasAttr()) return true; -- cgit v1.2.3