Mercurial > hg > CbC > CbC_llvm
comparison lib/Object/ObjectFile.cpp @ 147:c2174574ed3a
LLVM 10
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 16:55:33 +0900 |
parents | 803732b1fca8 |
children |
comparison
equal
deleted
inserted
replaced
134:3a76565eade5 | 147:c2174574ed3a |
---|---|
1 //===- ObjectFile.cpp - File format independent object file ---------------===// | 1 //===- ObjectFile.cpp - File format independent object file ---------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 // | 4 // See https://llvm.org/LICENSE.txt for license information. |
5 // This file is distributed under the University of Illinois Open Source | 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 // License. See LICENSE.TXT for details. | |
7 // | 6 // |
8 //===----------------------------------------------------------------------===// | 7 //===----------------------------------------------------------------------===// |
9 // | 8 // |
10 // This file defines a file format independent ObjectFile class. | 9 // This file defines a file format independent ObjectFile class. |
11 // | 10 // |
55 if (Flags & SymbolRef::SF_Common) | 54 if (Flags & SymbolRef::SF_Common) |
56 return getCommonSymbolSize(Ref); | 55 return getCommonSymbolSize(Ref); |
57 return getSymbolValueImpl(Ref); | 56 return getSymbolValueImpl(Ref); |
58 } | 57 } |
59 | 58 |
60 std::error_code ObjectFile::printSymbolName(raw_ostream &OS, | 59 Error ObjectFile::printSymbolName(raw_ostream &OS, DataRefImpl Symb) const { |
61 DataRefImpl Symb) const { | |
62 Expected<StringRef> Name = getSymbolName(Symb); | 60 Expected<StringRef> Name = getSymbolName(Symb); |
63 if (!Name) | 61 if (!Name) |
64 return errorToErrorCode(Name.takeError()); | 62 return Name.takeError(); |
65 OS << *Name; | 63 OS << *Name; |
66 return std::error_code(); | 64 return Error::success(); |
67 } | 65 } |
68 | 66 |
69 uint32_t ObjectFile::getSymbolAlignment(DataRefImpl DRI) const { return 0; } | 67 uint32_t ObjectFile::getSymbolAlignment(DataRefImpl DRI) const { return 0; } |
70 | 68 |
71 bool ObjectFile::isSectionBitcode(DataRefImpl Sec) const { | 69 bool ObjectFile::isSectionBitcode(DataRefImpl Sec) const { |
72 StringRef SectName; | 70 if (Expected<StringRef> NameOrErr = getSectionName(Sec)) |
73 if (!getSectionName(Sec, SectName)) | 71 return *NameOrErr == ".llvmbc"; |
74 return SectName == ".llvmbc"; | |
75 return false; | 72 return false; |
76 } | 73 } |
77 | 74 |
78 bool ObjectFile::isSectionStripped(DataRefImpl Sec) const { return false; } | 75 bool ObjectFile::isSectionStripped(DataRefImpl Sec) const { return false; } |
76 | |
77 bool ObjectFile::isBerkeleyText(DataRefImpl Sec) const { | |
78 return isSectionText(Sec); | |
79 } | |
80 | |
81 bool ObjectFile::isBerkeleyData(DataRefImpl Sec) const { | |
82 return isSectionData(Sec); | |
83 } | |
79 | 84 |
80 section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const { | 85 section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const { |
81 return section_iterator(SectionRef(Sec, this)); | 86 return section_iterator(SectionRef(Sec, this)); |
82 } | 87 } |
83 | 88 |
117 case file_magic::bitcode: | 122 case file_magic::bitcode: |
118 case file_magic::coff_cl_gl_object: | 123 case file_magic::coff_cl_gl_object: |
119 case file_magic::archive: | 124 case file_magic::archive: |
120 case file_magic::macho_universal_binary: | 125 case file_magic::macho_universal_binary: |
121 case file_magic::windows_resource: | 126 case file_magic::windows_resource: |
127 case file_magic::pdb: | |
128 case file_magic::minidump: | |
122 return errorCodeToError(object_error::invalid_file_type); | 129 return errorCodeToError(object_error::invalid_file_type); |
123 case file_magic::elf: | 130 case file_magic::elf: |
124 case file_magic::elf_relocatable: | 131 case file_magic::elf_relocatable: |
125 case file_magic::elf_executable: | 132 case file_magic::elf_executable: |
126 case file_magic::elf_shared_object: | 133 case file_magic::elf_shared_object: |
140 return createMachOObjectFile(Object); | 147 return createMachOObjectFile(Object); |
141 case file_magic::coff_object: | 148 case file_magic::coff_object: |
142 case file_magic::coff_import_library: | 149 case file_magic::coff_import_library: |
143 case file_magic::pecoff_executable: | 150 case file_magic::pecoff_executable: |
144 return createCOFFObjectFile(Object); | 151 return createCOFFObjectFile(Object); |
152 case file_magic::xcoff_object_32: | |
153 return createXCOFFObjectFile(Object, Binary::ID_XCOFF32); | |
154 case file_magic::xcoff_object_64: | |
155 return createXCOFFObjectFile(Object, Binary::ID_XCOFF64); | |
145 case file_magic::wasm_object: | 156 case file_magic::wasm_object: |
146 return createWasmObjectFile(Object); | 157 return createWasmObjectFile(Object); |
147 } | 158 } |
148 llvm_unreachable("Unexpected Object File Type"); | 159 llvm_unreachable("Unexpected Object File Type"); |
149 } | 160 } |