diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-07-29 20:15:26 +0000 |
commit | 344a3780b2e33f6ca763666c380202b18aab72a3 (patch) | |
tree | f0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/include/llvm/Object/ELFObjectFile.h | |
parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
download | src-344a3780b2e33f6ca763666c380202b18aab72a3.tar.gz src-344a3780b2e33f6ca763666c380202b18aab72a3.zip |
Vendor import of llvm-project main 88e66fa60ae5, the last commit beforevendor/llvm-project/llvmorg-13-init-16847-g88e66fa60ae5vendor/llvm-project/llvmorg-12.0.1-rc2-0-ge7dac564cd0evendor/llvm-project/llvmorg-12.0.1-0-gfed41342a82f
the upstream release/13.x branch was created.
Diffstat (limited to 'llvm/include/llvm/Object/ELFObjectFile.h')
-rw-r--r-- | llvm/include/llvm/Object/ELFObjectFile.h | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h index fed53eef68c3..c87a09f86fae 100644 --- a/llvm/include/llvm/Object/ELFObjectFile.h +++ b/llvm/include/llvm/Object/ELFObjectFile.h @@ -289,7 +289,7 @@ protected: bool isSectionVirtual(DataRefImpl Sec) const override; bool isBerkeleyText(DataRefImpl Sec) const override; bool isBerkeleyData(DataRefImpl Sec) const override; - bool isDebugSection(StringRef SectionName) const override; + bool isDebugSection(DataRefImpl Sec) const override; relocation_iterator section_rel_begin(DataRefImpl Sec) const override; relocation_iterator section_rel_end(DataRefImpl Sec) const override; std::vector<SectionRef> dynamic_relocation_sections() const override; @@ -670,8 +670,8 @@ ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const { return SymbolRef::ST_Function; case ELF::STT_OBJECT: case ELF::STT_COMMON: - case ELF::STT_TLS: return SymbolRef::ST_Data; + case ELF::STT_TLS: default: return SymbolRef::ST_Other; } @@ -716,7 +716,16 @@ Expected<uint32_t> ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const { // TODO: Test this error. return SymbolsOrErr.takeError(); - if (EF.getHeader().e_machine == ELF::EM_ARM) { + if (EF.getHeader().e_machine == ELF::EM_AARCH64) { + if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) { + StringRef Name = *NameOrErr; + if (Name.startswith("$d") || Name.startswith("$x")) + Result |= SymbolRef::SF_FormatSpecific; + } else { + // TODO: Actually report errors helpfully. + consumeError(NameOrErr.takeError()); + } + } else if (EF.getHeader().e_machine == ELF::EM_ARM) { if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) { StringRef Name = *NameOrErr; if (Name.startswith("$d") || Name.startswith("$t") || @@ -728,6 +737,15 @@ Expected<uint32_t> ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Sym) const { } if (ESym->getType() == ELF::STT_FUNC && (ESym->st_value & 1) == 1) Result |= SymbolRef::SF_Thumb; + } else if (EF.getHeader().e_machine == ELF::EM_RISCV) { + if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) { + // Mark empty name symbols used for label differences. + if (NameOrErr->empty()) + Result |= SymbolRef::SF_FormatSpecific; + } else { + // TODO: Actually report errors helpfully. + consumeError(NameOrErr.takeError()); + } } if (ESym->st_shndx == ELF::SHN_UNDEF) @@ -910,7 +928,14 @@ bool ELFObjectFile<ELFT>::isBerkeleyData(DataRefImpl Sec) const { } template <class ELFT> -bool ELFObjectFile<ELFT>::isDebugSection(StringRef SectionName) const { +bool ELFObjectFile<ELFT>::isDebugSection(DataRefImpl Sec) const { + Expected<StringRef> SectionNameOrErr = getSectionName(Sec); + if (!SectionNameOrErr) { + // TODO: Report the error message properly. + consumeError(SectionNameOrErr.takeError()); + return false; + } + StringRef SectionName = SectionNameOrErr.get(); return SectionName.startswith(".debug") || SectionName.startswith(".zdebug") || SectionName == ".gdb_index"; } @@ -950,9 +975,6 @@ ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const { template <class ELFT> Expected<section_iterator> ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const { - if (EF.getHeader().e_type != ELF::ET_REL) - return section_end(); - const Elf_Shdr *EShdr = getSection(Sec); uintX_t Type = EShdr->sh_type; if (Type != ELF::SHT_REL && Type != ELF::SHT_RELA) @@ -1141,6 +1163,8 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const { switch (EF.getHeader().e_ident[ELF::EI_CLASS]) { case ELF::ELFCLASS32: switch (EF.getHeader().e_machine) { + case ELF::EM_68K: + return "elf32-m68k"; case ELF::EM_386: return "elf32-i386"; case ELF::EM_IAMCU: @@ -1209,6 +1233,8 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const { template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const { bool IsLittleEndian = ELFT::TargetEndianness == support::little; switch (EF.getHeader().e_machine) { + case ELF::EM_68K: + return Triple::m68k; case ELF::EM_386: case ELF::EM_IAMCU: return Triple::x86; |