Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Object][NFC] Add extern template declarations needed by llvm-objdump #109156

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions llvm/include/llvm/Object/ELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Object/ELFTypes.h"
#include "llvm/Object/Error.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Error.h"
#include <cassert>
Expand Down Expand Up @@ -1367,6 +1368,11 @@ inline uint32_t hashGnu(StringRef Name) {
return H;
}

extern template class LLVM_TEMPLATE_ABI llvm::object::ELFFile<ELF32LE>;
extern template class LLVM_TEMPLATE_ABI llvm::object::ELFFile<ELF32BE>;
extern template class LLVM_TEMPLATE_ABI llvm::object::ELFFile<ELF64LE>;
extern template class LLVM_TEMPLATE_ABI llvm::object::ELFFile<ELF64BE>;

} // end namespace object
} // end namespace llvm

Expand Down
8 changes: 8 additions & 0 deletions llvm/include/llvm/Object/XCOFFObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/ADT/iterator_range.h"
#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Endian.h"
#include <limits>

Expand Down Expand Up @@ -775,6 +776,13 @@ struct XCOFFSymbolEntry64 {
uint8_t NumberOfAuxEntries;
};

extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<XCOFFRelocation32>>
XCOFFObjectFile::relocations<XCOFFSectionHeader32, XCOFFRelocation32>(
const XCOFFSectionHeader32 &Sec) const;
extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<XCOFFRelocation64>>
XCOFFObjectFile::relocations<XCOFFSectionHeader64, XCOFFRelocation64>(
const XCOFFSectionHeader64 &Sec) const;

class XCOFFSymbolRef : public SymbolRef {
public:
enum { NAME_IN_STR_TBL_MAGIC = 0x0 };
Expand Down
9 changes: 5 additions & 4 deletions llvm/lib/Object/ELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "llvm/Object/ELF.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataExtractor.h"

using namespace llvm;
Expand Down Expand Up @@ -980,7 +981,7 @@ ELFFile<ELFT>::getSectionAndRelocations(
return SecToRelocMap;
}

template class llvm::object::ELFFile<ELF32LE>;
template class llvm::object::ELFFile<ELF32BE>;
template class llvm::object::ELFFile<ELF64LE>;
template class llvm::object::ELFFile<ELF64BE>;
template class LLVM_EXPORT_TEMPLATE llvm::object::ELFFile<ELF32LE>;
template class LLVM_EXPORT_TEMPLATE llvm::object::ELFFile<ELF32BE>;
template class LLVM_EXPORT_TEMPLATE llvm::object::ELFFile<ELF64LE>;
template class LLVM_EXPORT_TEMPLATE llvm::object::ELFFile<ELF64BE>;
23 changes: 13 additions & 10 deletions llvm/lib/Object/XCOFFObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "llvm/Object/XCOFFObjectFile.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/TargetParser/SubtargetFeature.h"
#include <cstddef>
Expand Down Expand Up @@ -1060,9 +1061,9 @@ Expected<ArrayRef<ExceptEnt>> XCOFFObjectFile::getExceptionEntries() const {
ExceptEntStart, ExceptEntStart + getSectionSize(DRI) / sizeof(ExceptEnt));
}

template Expected<ArrayRef<ExceptionSectionEntry32>>
template LLVM_EXPORT_TEMPLATE Expected<ArrayRef<ExceptionSectionEntry32>>
XCOFFObjectFile::getExceptionEntries() const;
template Expected<ArrayRef<ExceptionSectionEntry64>>
template LLVM_EXPORT_TEMPLATE Expected<ArrayRef<ExceptionSectionEntry64>>
XCOFFObjectFile::getExceptionEntries() const;

Expected<XCOFFStringTable>
Expand Down Expand Up @@ -1376,14 +1377,16 @@ template struct XCOFFSectionHeader<XCOFFSectionHeader64>;
template struct XCOFFRelocation<llvm::support::ubig32_t>;
template struct XCOFFRelocation<llvm::support::ubig64_t>;

template llvm::Expected<llvm::ArrayRef<llvm::object::XCOFFRelocation64>>
llvm::object::XCOFFObjectFile::relocations<llvm::object::XCOFFSectionHeader64,
llvm::object::XCOFFRelocation64>(
llvm::object::XCOFFSectionHeader64 const &) const;
template llvm::Expected<llvm::ArrayRef<llvm::object::XCOFFRelocation32>>
llvm::object::XCOFFObjectFile::relocations<llvm::object::XCOFFSectionHeader32,
llvm::object::XCOFFRelocation32>(
llvm::object::XCOFFSectionHeader32 const &) const;
template LLVM_EXPORT_TEMPLATE
llvm::Expected<llvm::ArrayRef<llvm::object::XCOFFRelocation64>>
llvm::object::XCOFFObjectFile::relocations<
llvm::object::XCOFFSectionHeader64, llvm::object::XCOFFRelocation64>(
llvm::object::XCOFFSectionHeader64 const &) const;
template LLVM_EXPORT_TEMPLATE
llvm::Expected<llvm::ArrayRef<llvm::object::XCOFFRelocation32>>
llvm::object::XCOFFObjectFile::relocations<
llvm::object::XCOFFSectionHeader32, llvm::object::XCOFFRelocation32>(
llvm::object::XCOFFSectionHeader32 const &) const;

bool doesXCOFFTracebackTableBegin(ArrayRef<uint8_t> Bytes) {
if (Bytes.size() < 4)
Expand Down
Loading