1 //===- AArch64ELFDynamic.cpp ----------------------------------------------===//
2 //
3 //                     The MCLinker Project
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #include "AArch64ELFDynamic.h"
10 
11 #include <mcld/LD/ELFFileFormat.h>
12 #include <mcld/LinkerConfig.h>
13 
14 using namespace mcld;
15 
AArch64ELFDynamic(const GNULDBackend & pParent,const LinkerConfig & pConfig)16 AArch64ELFDynamic::AArch64ELFDynamic(const GNULDBackend& pParent,
17                                      const LinkerConfig& pConfig)
18   : ELFDynamic(pParent, pConfig)
19 {
20 }
21 
~AArch64ELFDynamic()22 AArch64ELFDynamic::~AArch64ELFDynamic()
23 {
24 }
25 
reserveTargetEntries(const ELFFileFormat & pFormat)26 void AArch64ELFDynamic::reserveTargetEntries(const ELFFileFormat& pFormat)
27 {
28   // reservePLTGOT
29   if (config().options().hasNow()) {
30     if (pFormat.hasGOT())
31       reserveOne(llvm::ELF::DT_PLTGOT);
32   }
33   else {
34     if (pFormat.hasGOTPLT())
35       reserveOne(llvm::ELF::DT_PLTGOT);
36   }
37 }
38 
applyTargetEntries(const ELFFileFormat & pFormat)39 void AArch64ELFDynamic::applyTargetEntries(const ELFFileFormat& pFormat)
40 {
41   // applyPLTGOT
42   if (config().options().hasNow()) {
43     if (pFormat.hasGOT())
44       applyOne(llvm::ELF::DT_PLTGOT, pFormat.getGOT().addr());
45   }
46   else {
47     if (pFormat.hasGOTPLT())
48       applyOne(llvm::ELF::DT_PLTGOT, pFormat.getGOTPLT().addr());
49   }
50 }
51 
52