mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-01 15:21:00 +00:00
[llvm-jitlink] Add support for static archives and MachO universal archives.
Archives can now be specified as input files the same way that object files are. Archives will always be linked after all objects (regardless of the relative order of the inputs) but before any dynamic libraries or process symbols. This patch also relaxes matching for slice triples in StaticLibraryDefinitionGenerator in order to support this feature: Vendors need not match if the source vendor is unknown.
This commit is contained in:
parent
4ea5511359
commit
ec5336f4a3
@ -322,7 +322,8 @@ StaticLibraryDefinitionGenerator::Load(ObjectLayer &L, const char *FileName,
|
|||||||
auto ObjTT = Obj.getTriple();
|
auto ObjTT = Obj.getTriple();
|
||||||
if (ObjTT.getArch() == TT.getArch() &&
|
if (ObjTT.getArch() == TT.getArch() &&
|
||||||
ObjTT.getSubArch() == TT.getSubArch() &&
|
ObjTT.getSubArch() == TT.getSubArch() &&
|
||||||
ObjTT.getVendor() == TT.getVendor()) {
|
(TT.getVendor() == Triple::UnknownVendor ||
|
||||||
|
ObjTT.getVendor() == TT.getVendor())) {
|
||||||
// We found a match. Create an instance from a buffer covering this
|
// We found a match. Create an instance from a buffer covering this
|
||||||
// slice.
|
// slice.
|
||||||
auto SliceBuffer = MemoryBuffer::getFileSlice(FileName, Obj.getSize(),
|
auto SliceBuffer = MemoryBuffer::getFileSlice(FileName, Obj.getSize(),
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "llvm-jitlink.h"
|
#include "llvm-jitlink.h"
|
||||||
|
|
||||||
|
#include "llvm/BinaryFormat/Magic.h"
|
||||||
#include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h"
|
#include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h"
|
||||||
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
|
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
@ -887,12 +888,19 @@ Error loadObjects(Session &S) {
|
|||||||
InputFileItr != InputFileEnd; ++InputFileItr) {
|
InputFileItr != InputFileEnd; ++InputFileItr) {
|
||||||
unsigned InputFileArgIdx =
|
unsigned InputFileArgIdx =
|
||||||
InputFiles.getPosition(InputFileItr - InputFiles.begin());
|
InputFiles.getPosition(InputFileItr - InputFiles.begin());
|
||||||
StringRef InputFile = *InputFileItr;
|
const std::string &InputFile = *InputFileItr;
|
||||||
auto &JD = *std::prev(IdxToJLD.lower_bound(InputFileArgIdx))->second;
|
auto &JD = *std::prev(IdxToJLD.lower_bound(InputFileArgIdx))->second;
|
||||||
LLVM_DEBUG(dbgs() << " " << InputFileArgIdx << ": \"" << InputFile
|
LLVM_DEBUG(dbgs() << " " << InputFileArgIdx << ": \"" << InputFile
|
||||||
<< "\" to " << JD.getName() << "\n";);
|
<< "\" to " << JD.getName() << "\n";);
|
||||||
auto ObjBuffer =
|
auto ObjBuffer =
|
||||||
ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(InputFile)));
|
ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(InputFile)));
|
||||||
|
|
||||||
|
auto Magic = identify_magic(ObjBuffer->getBuffer());
|
||||||
|
if (Magic == file_magic::archive ||
|
||||||
|
Magic == file_magic::macho_universal_binary)
|
||||||
|
JD.addGenerator(ExitOnErr(StaticLibraryDefinitionGenerator::Load(
|
||||||
|
S.ObjLayer, InputFile.c_str(), S.TT)));
|
||||||
|
else
|
||||||
ExitOnErr(S.ObjLayer.add(JD, std::move(ObjBuffer)));
|
ExitOnErr(S.ObjLayer.add(JD, std::move(ObjBuffer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1056,6 +1064,11 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
ExitOnErr(sanitizeArguments(*S));
|
ExitOnErr(sanitizeArguments(*S));
|
||||||
|
|
||||||
|
{
|
||||||
|
TimeRegion TR(Timers ? &Timers->LoadObjectsTimer : nullptr);
|
||||||
|
ExitOnErr(loadObjects(*S));
|
||||||
|
}
|
||||||
|
|
||||||
if (!NoProcessSymbols)
|
if (!NoProcessSymbols)
|
||||||
ExitOnErr(loadProcessSymbols(*S));
|
ExitOnErr(loadProcessSymbols(*S));
|
||||||
ExitOnErr(loadDylibs());
|
ExitOnErr(loadDylibs());
|
||||||
@ -1063,10 +1076,6 @@ int main(int argc, char *argv[]) {
|
|||||||
if (PhonyExternals)
|
if (PhonyExternals)
|
||||||
addPhonyExternalsGenerator(*S);
|
addPhonyExternalsGenerator(*S);
|
||||||
|
|
||||||
{
|
|
||||||
TimeRegion TR(Timers ? &Timers->LoadObjectsTimer : nullptr);
|
|
||||||
ExitOnErr(loadObjects(*S));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ShowInitialExecutionSessionState)
|
if (ShowInitialExecutionSessionState)
|
||||||
S->ES.dump(outs());
|
S->ES.dump(outs());
|
||||||
|
Loading…
Reference in New Issue
Block a user