Dylan McKay | 5c96de3 | 2016-01-07 10:53:15 +0000 | [diff] [blame] | 1 | //===-- AVRTargetObjectFile.cpp - AVR Object Files ------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "AVRTargetObjectFile.h" |
| 11 | |
| 12 | #include "llvm/IR/DerivedTypes.h" |
| 13 | #include "llvm/IR/GlobalValue.h" |
| 14 | #include "llvm/IR/Mangler.h" |
| 15 | #include "llvm/MC/MCContext.h" |
| 16 | #include "llvm/MC/MCSectionELF.h" |
| 17 | #include "llvm/Support/ELF.h" |
| 18 | |
| 19 | #include "AVR.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | void AVRTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM) { |
| 23 | Base::Initialize(Ctx, TM); |
| 24 | ProgmemDataSection = |
| 25 | Ctx.getELFSection(".progmem.data", ELF::SHT_PROGBITS, ELF::SHF_ALLOC); |
| 26 | } |
| 27 | |
| 28 | MCSection * |
Peter Collingbourne | 6733564 | 2016-10-24 19:23:39 +0000 | [diff] [blame] | 29 | AVRTargetObjectFile::SelectSectionForGlobal(const GlobalObject *GO, |
Dylan McKay | 907cde3 | 2016-09-24 11:38:08 +0000 | [diff] [blame] | 30 | SectionKind Kind, |
Dylan McKay | 5c96de3 | 2016-01-07 10:53:15 +0000 | [diff] [blame] | 31 | const TargetMachine &TM) const { |
| 32 | // Global values in flash memory are placed in the progmem.data section |
| 33 | // unless they already have a user assigned section. |
Peter Collingbourne | 6733564 | 2016-10-24 19:23:39 +0000 | [diff] [blame] | 34 | if (AVR::isProgramMemoryAddress(GO) && !GO->hasSection()) |
Dylan McKay | 5c96de3 | 2016-01-07 10:53:15 +0000 | [diff] [blame] | 35 | return ProgmemDataSection; |
| 36 | |
| 37 | // Otherwise, we work the same way as ELF. |
Peter Collingbourne | 6733564 | 2016-10-24 19:23:39 +0000 | [diff] [blame] | 38 | return Base::SelectSectionForGlobal(GO, Kind, TM); |
Dylan McKay | 5c96de3 | 2016-01-07 10:53:15 +0000 | [diff] [blame] | 39 | } |
| 40 | } // end of namespace llvm |
Dylan McKay | 907cde3 | 2016-09-24 11:38:08 +0000 | [diff] [blame] | 41 | |