• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "bcc/Config/Config.h"
18 #include "bcc/Support/TargetLinkerConfigs.h"
19 
20 using namespace bcc;
21 
22 #ifdef TARGET_BUILD
23 static const char* gDefaultDyld = "/system/bin/linker";
24 static const char* gDefaultSysroot = "/system";
25 #else
26 static const char* gDefaultDyld = "/usr/lib/ld.so.1";
27 static const char* gDefaultSysroot = "/";
28 #endif
29 
30 //===----------------------------------------------------------------------===//
31 // ARM
32 //===----------------------------------------------------------------------===//
33 #if defined(PROVIDE_ARM_CODEGEN)
ARMLinkerConfig()34 ARMLinkerConfig::ARMLinkerConfig() : LinkerConfig(DEFAULT_ARM_TRIPLE_STRING) {
35 
36   // set up target-dependent constraints of attributes
37   getLDInfo()->attrFactory().constraint().enableWholeArchive();
38   getLDInfo()->attrFactory().constraint().disableAsNeeded();
39   getLDInfo()->attrFactory().constraint().setSharedSystem();
40 
41   // set up the predefined attributes
42   getLDInfo()->attrFactory().predefined().setWholeArchive();
43   getLDInfo()->attrFactory().predefined().setDynamic();
44 
45   // set up target dependent options
46   if (getLDInfo()->options().sysroot().empty()) {
47     getLDInfo()->options().setSysroot(gDefaultSysroot);
48   }
49 
50   if (!getLDInfo()->options().hasDyld()) {
51     getLDInfo()->options().setDyld(gDefaultDyld);
52   }
53 }
54 #endif // defined(PROVIDE_ARM_CODEGEN)
55 
56 //===----------------------------------------------------------------------===//
57 // Mips
58 //===----------------------------------------------------------------------===//
59 #if defined(PROVIDE_MIPS_CODEGEN)
MipsLinkerConfig()60 MipsLinkerConfig::MipsLinkerConfig()
61   : LinkerConfig(DEFAULT_MIPS_TRIPLE_STRING) {
62 
63   // set up target-dependent constraints of attibutes
64   getLDInfo()->attrFactory().constraint().enableWholeArchive();
65   getLDInfo()->attrFactory().constraint().disableAsNeeded();
66   getLDInfo()->attrFactory().constraint().setSharedSystem();
67 
68   // set up the predefined attributes
69   getLDInfo()->attrFactory().predefined().setWholeArchive();
70   getLDInfo()->attrFactory().predefined().setDynamic();
71 
72   // set up target dependent options
73   if (getLDInfo()->options().sysroot().empty()) {
74     getLDInfo()->options().setSysroot(gDefaultSysroot);
75   }
76 
77   if (!getLDInfo()->options().hasDyld()) {
78     getLDInfo()->options().setDyld(gDefaultDyld);
79   }
80 }
81 #endif // defined(PROVIDE_MIPS_CODEGEN)
82 
83 //===----------------------------------------------------------------------===//
84 // X86 and X86_64
85 //===----------------------------------------------------------------------===//
86 #if defined(PROVIDE_X86_CODEGEN)
X86FamilyLinkerConfigBase(const std::string & pTriple)87 X86FamilyLinkerConfigBase::X86FamilyLinkerConfigBase(const std::string& pTriple)
88   : LinkerConfig(pTriple) {
89   // set up target-dependent constraints of attibutes
90   getLDInfo()->attrFactory().constraint().enableWholeArchive();
91   getLDInfo()->attrFactory().constraint().disableAsNeeded();
92   getLDInfo()->attrFactory().constraint().setSharedSystem();
93 
94   // set up the predefined attributes
95   getLDInfo()->attrFactory().predefined().setWholeArchive();
96   getLDInfo()->attrFactory().predefined().setDynamic();
97 
98   // set up target dependent options
99   if (getLDInfo()->options().sysroot().empty()) {
100     getLDInfo()->options().setSysroot(gDefaultSysroot);
101   }
102 
103   if (!getLDInfo()->options().hasDyld()) {
104     getLDInfo()->options().setDyld(gDefaultDyld);
105   }
106 }
107 
X86_32LinkerConfig()108 X86_32LinkerConfig::X86_32LinkerConfig()
109   : X86FamilyLinkerConfigBase(DEFAULT_X86_TRIPLE_STRING) {
110 }
111 
X86_64LinkerConfig()112 X86_64LinkerConfig::X86_64LinkerConfig()
113   : X86FamilyLinkerConfigBase(DEFAULT_X86_64_TRIPLE_STRING) {
114 }
115 #endif // defined(PROVIDE_X86_CODEGEN)
116