aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/Target/TargetLoweringObjectFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/Target/TargetLoweringObjectFile.cpp')
-rw-r--r--contrib/llvm/lib/Target/TargetLoweringObjectFile.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/contrib/llvm/lib/Target/TargetLoweringObjectFile.cpp b/contrib/llvm/lib/Target/TargetLoweringObjectFile.cpp
index 91cc97e38b3d..f941891f3183 100644
--- a/contrib/llvm/lib/Target/TargetLoweringObjectFile.cpp
+++ b/contrib/llvm/lib/Target/TargetLoweringObjectFile.cpp
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Target/TargetLoweringObjectFile.h"
+#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
@@ -24,7 +25,6 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
-#include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetLowering.h"
@@ -240,6 +240,20 @@ MCSection *TargetLoweringObjectFile::SectionForGlobal(
if (GO->hasSection())
return getExplicitSectionGlobal(GO, Kind, TM);
+ if (auto *GVar = dyn_cast<GlobalVariable>(GO)) {
+ auto Attrs = GVar->getAttributes();
+ if ((Attrs.hasAttribute("bss-section") && Kind.isBSS()) ||
+ (Attrs.hasAttribute("data-section") && Kind.isData()) ||
+ (Attrs.hasAttribute("rodata-section") && Kind.isReadOnly())) {
+ return getExplicitSectionGlobal(GO, Kind, TM);
+ }
+ }
+
+ if (auto *F = dyn_cast<Function>(GO)) {
+ if (F->hasFnAttribute("implicit-section-name"))
+ return getExplicitSectionGlobal(GO, Kind, TM);
+ }
+
// Use default section depending on the 'type' of global
return SelectSectionForGlobal(GO, Kind, TM);
}