diff options
| author | Dmitry Mikulin <dmitry.mikulin@sony.com> | 2019-10-15 18:31:10 +0000 |
|---|---|---|
| committer | Dmitry Mikulin <dmitry.mikulin@sony.com> | 2019-10-15 18:31:10 +0000 |
| commit | f14642f2f185f9af290f9fcace4851adbbe16432 (patch) | |
| tree | 023054e847f2845c009d66e9e3e88ad11872fe41 /clang/lib/CodeGen | |
| parent | 2cb27072cefb11d5018735a3b70a903dc1d319ac (diff) | |
| download | bcm5719-llvm-f14642f2f185f9af290f9fcace4851adbbe16432.tar.gz bcm5719-llvm-f14642f2f185f9af290f9fcace4851adbbe16432.zip | |
Added support for "#pragma clang section relro=<name>"
Differential Revision: https://reviews.llvm.org/D68806
llvm-svn: 374934
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 3 |
2 files changed, 5 insertions, 0 deletions
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<PragmaClangRodataSectionAttr>()) var->addAttribute("rodata-section", SA->getName()); + if (auto *SA = D.getAttr<PragmaClangRelroSectionAttr>()) + var->addAttribute("relro-section", SA->getName()); if (const SectionAttr *SA = D.getAttr<SectionAttr>()) 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<PragmaClangRodataSectionAttr>()) GV->addAttribute("rodata-section", SA->getName()); + if (auto *SA = D->getAttr<PragmaClangRelroSectionAttr>()) + GV->addAttribute("relro-section", SA->getName()); } if (auto *F = dyn_cast<llvm::Function>(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<PragmaClangBSSSectionAttr>() || D->hasAttr<PragmaClangDataSectionAttr>() || + D->hasAttr<PragmaClangRelroSectionAttr>() || D->hasAttr<PragmaClangRodataSectionAttr>()) return true; |

