Mercurial > hg > CbC > CbC_llvm
comparison lld/ELF/InputFiles.h @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 0572611fdcc8 |
children | 5f17cb93ff66 |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
90 assert(fileKind == BinaryKind || fileKind == ObjKind || | 90 assert(fileKind == BinaryKind || fileKind == ObjKind || |
91 fileKind == BitcodeKind); | 91 fileKind == BitcodeKind); |
92 return symbols; | 92 return symbols; |
93 } | 93 } |
94 | 94 |
95 // Filename of .a which contained this file. If this file was | 95 // Get filename to use for linker script processing. |
96 // not in an archive file, it is the empty string. We use this | 96 StringRef getNameForScript() const; |
97 // string for creating error messages. | 97 |
98 // If not empty, this stores the name of the archive containing this file. | |
99 // We use this string for creating error messages. | |
98 std::string archiveName; | 100 std::string archiveName; |
99 | 101 |
100 // If this is an architecture-specific file, the following members | 102 // If this is an architecture-specific file, the following members |
101 // have ELF type (i.e. ELF{32,64}{LE,BE}) and target machine type. | 103 // have ELF type (i.e. ELF{32,64}{LE,BE}) and target machine type. |
102 ELFKind ekind = ELFNoneKind; | 104 ELFKind ekind = ELFNoneKind; |
126 // code model relocations support immediates in the range [-0x8000, 0x7FFC], | 128 // code model relocations support immediates in the range [-0x8000, 0x7FFC], |
127 // making the addressable range relative to the toc pointer | 129 // making the addressable range relative to the toc pointer |
128 // [.got, .got + 0xFFFC]. | 130 // [.got, .got + 0xFFFC]. |
129 bool ppc64SmallCodeModelTocRelocs = false; | 131 bool ppc64SmallCodeModelTocRelocs = false; |
130 | 132 |
133 // True if the file has TLSGD/TLSLD GOT relocations without R_PPC64_TLSGD or | |
134 // R_PPC64_TLSLD. Disable TLS relaxation to avoid bad code generation. | |
135 bool ppc64DisableTLSRelax = false; | |
136 | |
131 // groupId is used for --warn-backrefs which is an optional error | 137 // groupId is used for --warn-backrefs which is an optional error |
132 // checking feature. All files within the same --{start,end}-group or | 138 // checking feature. All files within the same --{start,end}-group or |
133 // --{start,end}-lib get the same group ID. Otherwise, each file gets a new | 139 // --{start,end}-lib get the same group ID. Otherwise, each file gets a new |
134 // group ID. For more info, see checkDependency() in SymbolTable.cpp. | 140 // group ID. For more info, see checkDependency() in SymbolTable.cpp. |
135 uint32_t groupId; | 141 uint32_t groupId; |
145 InputFile(Kind k, MemoryBufferRef m); | 151 InputFile(Kind k, MemoryBufferRef m); |
146 std::vector<InputSectionBase *> sections; | 152 std::vector<InputSectionBase *> sections; |
147 | 153 |
148 private: | 154 private: |
149 const Kind fileKind; | 155 const Kind fileKind; |
156 | |
157 // Cache for getNameForScript(). | |
158 mutable std::string nameForScriptCache; | |
150 }; | 159 }; |
151 | 160 |
152 class ELFFileBase : public InputFile { | 161 class ELFFileBase : public InputFile { |
153 public: | 162 public: |
154 ELFFileBase(Kind k, MemoryBufferRef m); | 163 ELFFileBase(Kind k, MemoryBufferRef m); |
178 StringRef stringTable; | 187 StringRef stringTable; |
179 }; | 188 }; |
180 | 189 |
181 // .o file. | 190 // .o file. |
182 template <class ELFT> class ObjFile : public ELFFileBase { | 191 template <class ELFT> class ObjFile : public ELFFileBase { |
183 using Elf_Rel = typename ELFT::Rel; | 192 LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) |
184 using Elf_Rela = typename ELFT::Rela; | |
185 using Elf_Sym = typename ELFT::Sym; | |
186 using Elf_Shdr = typename ELFT::Shdr; | |
187 using Elf_Word = typename ELFT::Word; | |
188 using Elf_CGProfile = typename ELFT::CGProfile; | |
189 | 193 |
190 public: | 194 public: |
191 static bool classof(const InputFile *f) { return f->kind() == ObjKind; } | 195 static bool classof(const InputFile *f) { return f->kind() == ObjKind; } |
192 | 196 |
193 llvm::object::ELFFile<ELFT> getObj() const { | 197 llvm::object::ELFFile<ELFT> getObj() const { |
305 static bool classof(const InputFile *f) { return f->kind() == LazyObjKind; } | 309 static bool classof(const InputFile *f) { return f->kind() == LazyObjKind; } |
306 | 310 |
307 template <class ELFT> void parse(); | 311 template <class ELFT> void parse(); |
308 void fetch(); | 312 void fetch(); |
309 | 313 |
314 // Check if a non-common symbol should be fetched to override a common | |
315 // definition. | |
316 bool shouldFetchForCommon(const StringRef &name); | |
317 | |
318 bool fetched = false; | |
319 | |
310 private: | 320 private: |
311 uint64_t offsetInArchive; | 321 uint64_t offsetInArchive; |
312 }; | 322 }; |
313 | 323 |
314 // An ArchiveFile object represents a .a file. | 324 // An ArchiveFile object represents a .a file. |
322 // returns it. If the same file was instantiated before, this | 332 // returns it. If the same file was instantiated before, this |
323 // function does nothing (so we don't instantiate the same file | 333 // function does nothing (so we don't instantiate the same file |
324 // more than once.) | 334 // more than once.) |
325 void fetch(const Archive::Symbol &sym); | 335 void fetch(const Archive::Symbol &sym); |
326 | 336 |
337 // Check if a non-common symbol should be fetched to override a common | |
338 // definition. | |
339 bool shouldFetchForCommon(const Archive::Symbol &sym); | |
340 | |
327 size_t getMemberCount() const; | 341 size_t getMemberCount() const; |
328 size_t getFetchedMemberCount() const { return seen.size(); } | 342 size_t getFetchedMemberCount() const { return seen.size(); } |
343 | |
344 bool parsed = false; | |
329 | 345 |
330 private: | 346 private: |
331 std::unique_ptr<Archive> file; | 347 std::unique_ptr<Archive> file; |
332 llvm::DenseSet<uint64_t> seen; | 348 llvm::DenseSet<uint64_t> seen; |
333 }; | 349 }; |
363 | 379 |
364 static bool classof(const InputFile *f) { return f->kind() == SharedKind; } | 380 static bool classof(const InputFile *f) { return f->kind() == SharedKind; } |
365 | 381 |
366 template <typename ELFT> void parse(); | 382 template <typename ELFT> void parse(); |
367 | 383 |
368 // Used for --no-allow-shlib-undefined. | |
369 bool allNeededIsKnown; | |
370 | |
371 // Used for --as-needed | 384 // Used for --as-needed |
372 bool isNeeded; | 385 bool isNeeded; |
386 | |
387 // Non-weak undefined symbols which are not yet resolved when the SO is | |
388 // parsed. Only filled for `--no-allow-shlib-undefined`. | |
389 std::vector<Symbol *> requiredSymbols; | |
373 | 390 |
374 private: | 391 private: |
375 template <typename ELFT> | 392 template <typename ELFT> |
376 std::vector<uint32_t> parseVerneed(const llvm::object::ELFFile<ELFT> &obj, | 393 std::vector<uint32_t> parseVerneed(const llvm::object::ELFFile<ELFT> &obj, |
377 const typename ELFT::Shdr *sec); | 394 const typename ELFT::Shdr *sec); |