Bill Wendling | bdc38e5 | 2010-03-09 18:31:07 +0000 | [diff] [blame] | 1 | //===-- llvm/Target/ARMTargetObjectFile.cpp - ARM Object Info Impl --------===// |
| 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 "ARMTargetObjectFile.h" |
| 11 | #include "ARMSubtarget.h" |
Chris Lattner | 287df1b | 2010-04-08 21:34:17 +0000 | [diff] [blame] | 12 | #include "llvm/MC/MCContext.h" |
Bill Wendling | bdc38e5 | 2010-03-09 18:31:07 +0000 | [diff] [blame] | 13 | #include "llvm/MC/MCSectionELF.h" |
Bill Wendling | bdc38e5 | 2010-03-09 18:31:07 +0000 | [diff] [blame] | 14 | #include "llvm/Support/Dwarf.h" |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 15 | #include "llvm/Support/ELF.h" |
Bill Wendling | bdc38e5 | 2010-03-09 18:31:07 +0000 | [diff] [blame] | 16 | #include "llvm/Target/TargetMachine.h" |
Anton Korobeynikov | 4a99f59 | 2012-01-25 22:24:19 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/StringExtras.h" |
Bill Wendling | bdc38e5 | 2010-03-09 18:31:07 +0000 | [diff] [blame] | 18 | using namespace llvm; |
| 19 | using namespace dwarf; |
| 20 | |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | // ELF Target |
| 23 | //===----------------------------------------------------------------------===// |
| 24 | |
| 25 | void ARMElfTargetObjectFile::Initialize(MCContext &Ctx, |
| 26 | const TargetMachine &TM) { |
| 27 | TargetLoweringObjectFileELF::Initialize(Ctx, TM); |
Anton Korobeynikov | 4a99f59 | 2012-01-25 22:24:19 +0000 | [diff] [blame] | 28 | isAAPCS_ABI = TM.getSubtarget<ARMSubtarget>().isAAPCS_ABI(); |
Bill Wendling | bdc38e5 | 2010-03-09 18:31:07 +0000 | [diff] [blame] | 29 | |
Anton Korobeynikov | 4a99f59 | 2012-01-25 22:24:19 +0000 | [diff] [blame] | 30 | if (isAAPCS_ABI) { |
Bill Wendling | bdc38e5 | 2010-03-09 18:31:07 +0000 | [diff] [blame] | 31 | StaticCtorSection = |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 32 | getContext().getELFSection(".init_array", ELF::SHT_INIT_ARRAY, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 33 | ELF::SHF_WRITE | |
| 34 | ELF::SHF_ALLOC, |
Chris Lattner | 287df1b | 2010-04-08 21:34:17 +0000 | [diff] [blame] | 35 | SectionKind::getDataRel()); |
Bill Wendling | bdc38e5 | 2010-03-09 18:31:07 +0000 | [diff] [blame] | 36 | StaticDtorSection = |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 37 | getContext().getELFSection(".fini_array", ELF::SHT_FINI_ARRAY, |
Rafael Espindola | 1c13026 | 2011-01-23 04:43:11 +0000 | [diff] [blame] | 38 | ELF::SHF_WRITE | |
| 39 | ELF::SHF_ALLOC, |
Chris Lattner | 287df1b | 2010-04-08 21:34:17 +0000 | [diff] [blame] | 40 | SectionKind::getDataRel()); |
Anton Korobeynikov | b5e16af | 2011-03-05 18:43:15 +0000 | [diff] [blame] | 41 | LSDASection = NULL; |
Bill Wendling | bdc38e5 | 2010-03-09 18:31:07 +0000 | [diff] [blame] | 42 | } |
Anton Korobeynikov | b5e16af | 2011-03-05 18:43:15 +0000 | [diff] [blame] | 43 | |
Jason W Kim | 17b443d | 2010-10-11 23:01:44 +0000 | [diff] [blame] | 44 | AttributesSection = |
| 45 | getContext().getELFSection(".ARM.attributes", |
Rafael Espindola | c85dca6 | 2011-01-23 04:28:49 +0000 | [diff] [blame] | 46 | ELF::SHT_ARM_ATTRIBUTES, |
Jason W Kim | 17b443d | 2010-10-11 23:01:44 +0000 | [diff] [blame] | 47 | 0, |
| 48 | SectionKind::getMetadata()); |
Bill Wendling | bdc38e5 | 2010-03-09 18:31:07 +0000 | [diff] [blame] | 49 | } |
Anton Korobeynikov | 4a99f59 | 2012-01-25 22:24:19 +0000 | [diff] [blame] | 50 | |
| 51 | const MCSection * |
| 52 | ARMElfTargetObjectFile::getStaticCtorSection(unsigned Priority) const { |
| 53 | if (!isAAPCS_ABI) |
| 54 | return TargetLoweringObjectFileELF::getStaticCtorSection(Priority); |
| 55 | |
| 56 | if (Priority == 65535) |
| 57 | return StaticCtorSection; |
| 58 | |
| 59 | // Emit ctors in priority order. |
| 60 | std::string Name = std::string(".init_array.") + utostr(Priority); |
| 61 | return getContext().getELFSection(Name, ELF::SHT_INIT_ARRAY, |
| 62 | ELF::SHF_ALLOC | ELF::SHF_WRITE, |
| 63 | SectionKind::getDataRel()); |
| 64 | } |
| 65 | |
| 66 | const MCSection * |
| 67 | ARMElfTargetObjectFile::getStaticDtorSection(unsigned Priority) const { |
| 68 | if (!isAAPCS_ABI) |
| 69 | return TargetLoweringObjectFileELF::getStaticDtorSection(Priority); |
| 70 | |
| 71 | if (Priority == 65535) |
| 72 | return StaticDtorSection; |
| 73 | |
| 74 | // Emit dtors in priority order. |
| 75 | std::string Name = std::string(".fini_array.") + utostr(Priority); |
| 76 | return getContext().getELFSection(Name, ELF::SHT_FINI_ARRAY, |
| 77 | ELF::SHF_ALLOC | ELF::SHF_WRITE, |
| 78 | SectionKind::getDataRel()); |
| 79 | } |