Skip to content

Commit 248db71

Browse files
committed
[XCOFF][NFC] Add extern template declarations needed by llvm-objdump
These symbols are implicitly imported from the LLVM shared library by llvm-objdump, but for windows they need to be explicitly exported when LLVM is built as shared library. Also add manual visibility macros for XCOFFObjectFile::getExceptionEntries that can't automatically be added by clang tooling since it doesn't store the source locations for explicit function template instantiations.
1 parent 46a76c3 commit 248db71

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

llvm/include/llvm/Object/XCOFFObjectFile.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/ADT/iterator_range.h"
1919
#include "llvm/BinaryFormat/XCOFF.h"
2020
#include "llvm/Object/ObjectFile.h"
21+
#include "llvm/Support/Compiler.h"
2122
#include "llvm/Support/Endian.h"
2223
#include <limits>
2324

@@ -775,6 +776,13 @@ struct XCOFFSymbolEntry64 {
775776
uint8_t NumberOfAuxEntries;
776777
};
777778

779+
extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<XCOFFRelocation32>>
780+
XCOFFObjectFile::relocations<XCOFFSectionHeader32, XCOFFRelocation32>(
781+
const XCOFFSectionHeader32 &Sec) const;
782+
extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<XCOFFRelocation64>>
783+
XCOFFObjectFile::relocations<XCOFFSectionHeader64, XCOFFRelocation64>(
784+
const XCOFFSectionHeader64 &Sec) const;
785+
778786
class XCOFFSymbolRef : public SymbolRef {
779787
public:
780788
enum { NAME_IN_STR_TBL_MAGIC = 0x0 };

llvm/lib/Object/XCOFFObjectFile.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "llvm/Object/XCOFFObjectFile.h"
1414
#include "llvm/ADT/StringSwitch.h"
15+
#include "llvm/Support/Compiler.h"
1516
#include "llvm/Support/DataExtractor.h"
1617
#include "llvm/TargetParser/SubtargetFeature.h"
1718
#include <cstddef>
@@ -1060,9 +1061,9 @@ Expected<ArrayRef<ExceptEnt>> XCOFFObjectFile::getExceptionEntries() const {
10601061
ExceptEntStart, ExceptEntStart + getSectionSize(DRI) / sizeof(ExceptEnt));
10611062
}
10621063

1063-
template Expected<ArrayRef<ExceptionSectionEntry32>>
1064+
template LLVM_EXPORT_TEMPLATE Expected<ArrayRef<ExceptionSectionEntry32>>
10641065
XCOFFObjectFile::getExceptionEntries() const;
1065-
template Expected<ArrayRef<ExceptionSectionEntry64>>
1066+
template LLVM_EXPORT_TEMPLATE Expected<ArrayRef<ExceptionSectionEntry64>>
10661067
XCOFFObjectFile::getExceptionEntries() const;
10671068

10681069
Expected<XCOFFStringTable>
@@ -1376,14 +1377,16 @@ template struct XCOFFSectionHeader<XCOFFSectionHeader64>;
13761377
template struct XCOFFRelocation<llvm::support::ubig32_t>;
13771378
template struct XCOFFRelocation<llvm::support::ubig64_t>;
13781379

1379-
template llvm::Expected<llvm::ArrayRef<llvm::object::XCOFFRelocation64>>
1380-
llvm::object::XCOFFObjectFile::relocations<llvm::object::XCOFFSectionHeader64,
1381-
llvm::object::XCOFFRelocation64>(
1382-
llvm::object::XCOFFSectionHeader64 const &) const;
1383-
template llvm::Expected<llvm::ArrayRef<llvm::object::XCOFFRelocation32>>
1384-
llvm::object::XCOFFObjectFile::relocations<llvm::object::XCOFFSectionHeader32,
1385-
llvm::object::XCOFFRelocation32>(
1386-
llvm::object::XCOFFSectionHeader32 const &) const;
1380+
template LLVM_EXPORT_TEMPLATE
1381+
llvm::Expected<llvm::ArrayRef<llvm::object::XCOFFRelocation64>>
1382+
llvm::object::XCOFFObjectFile::relocations<
1383+
llvm::object::XCOFFSectionHeader64, llvm::object::XCOFFRelocation64>(
1384+
llvm::object::XCOFFSectionHeader64 const &) const;
1385+
template LLVM_EXPORT_TEMPLATE
1386+
llvm::Expected<llvm::ArrayRef<llvm::object::XCOFFRelocation32>>
1387+
llvm::object::XCOFFObjectFile::relocations<
1388+
llvm::object::XCOFFSectionHeader32, llvm::object::XCOFFRelocation32>(
1389+
llvm::object::XCOFFSectionHeader32 const &) const;
13871390

13881391
bool doesXCOFFTracebackTableBegin(ArrayRef<uint8_t> Bytes) {
13891392
if (Bytes.size() < 4)

0 commit comments

Comments
 (0)