aboutsummaryrefslogtreecommitdiff
path: root/llvm/include/llvm/Object/ELFObjectFile.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
commit344a3780b2e33f6ca763666c380202b18aab72a3 (patch)
treef0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/include/llvm/Object/ELFObjectFile.h
parentb60736ec1405bb0a8dd40989f67ef4c93da068ab (diff)
downloadsrc-344a3780b2e33f6ca763666c380202b18aab72a3.tar.gz
src-344a3780b2e33f6ca763666c380202b18aab72a3.zip
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.h40
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;