summaryrefslogtreecommitdiffstats
path: root/lib/Target/AVR/AVRTargetObjectFile.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2016-01-13 19:58:01 +0000
committerdim <dim@FreeBSD.org>2016-01-13 19:58:01 +0000
commite39b9e36e5f2d2dd312004cf5f84bb382be47dcd (patch)
tree7376a0c71aad05d327e5b1dcbceb3311a10f9f29 /lib/Target/AVR/AVRTargetObjectFile.cpp
parentff2ba393a56d9d99dcb76ceada542233db28af9a (diff)
downloadFreeBSD-src-e39b9e36e5f2d2dd312004cf5f84bb382be47dcd.zip
FreeBSD-src-e39b9e36e5f2d2dd312004cf5f84bb382be47dcd.tar.gz
Vendor import of llvm trunk r257626:
https://llvm.org/svn/llvm-project/llvm/trunk@257626
Diffstat (limited to 'lib/Target/AVR/AVRTargetObjectFile.cpp')
-rw-r--r--lib/Target/AVR/AVRTargetObjectFile.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/Target/AVR/AVRTargetObjectFile.cpp b/lib/Target/AVR/AVRTargetObjectFile.cpp
new file mode 100644
index 0000000..85f03e8
--- /dev/null
+++ b/lib/Target/AVR/AVRTargetObjectFile.cpp
@@ -0,0 +1,40 @@
+//===-- AVRTargetObjectFile.cpp - AVR Object Files ------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "AVRTargetObjectFile.h"
+
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/GlobalValue.h"
+#include "llvm/IR/Mangler.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCSectionELF.h"
+#include "llvm/Support/ELF.h"
+
+#include "AVR.h"
+
+namespace llvm {
+void AVRTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM) {
+ Base::Initialize(Ctx, TM);
+ ProgmemDataSection =
+ Ctx.getELFSection(".progmem.data", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
+}
+
+MCSection *
+AVRTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
+ SectionKind Kind, Mangler &Mang,
+ const TargetMachine &TM) const {
+ // Global values in flash memory are placed in the progmem.data section
+ // unless they already have a user assigned section.
+ if (AVR::isProgramMemoryAddress(GV) && !GV->hasSection())
+ return ProgmemDataSection;
+
+ // Otherwise, we work the same way as ELF.
+ return Base::SelectSectionForGlobal(GV, Kind, Mang, TM);
+}
+} // end of namespace llvm
OpenPOWER on IntegriCloud