This adds the LinkingContext parameter to the ELFReader. Previously the flags in that were needed in the Context was passed to the ELFReader, this made it very hard to access data structures in the LinkingContext when reading an ELF file. This change makes the ELFReader more flexible so that required parameters can be grabbed directly from the LinkingContext. Future patches make use of the changes. There is no change in functionality though. llvm-svn: 228905
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
//===- lib/ReaderWriter/ELF/Reader.cpp ------------------------------------===//
|
|
//
|
|
// The LLVM Linker
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// \file
|
|
/// \brief Defines the ELF Reader and all helper sub classes to consume an ELF
|
|
/// file and produces atoms out of it.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "ELFReader.h"
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
using llvm::support::endianness;
|
|
using namespace llvm::object;
|
|
|
|
namespace lld {
|
|
|
|
// This dynamic registration of a handler causes support for all ELF
|
|
// architectures to be pulled into the linker. If we want to support making a
|
|
// linker that only supports one ELF architecture, we'd need to change this
|
|
// to have a different registration method for each architecture.
|
|
void Registry::addSupportELFObjects(ELFLinkingContext &ctx) {
|
|
|
|
// Tell registry about the ELF object file parser.
|
|
add(std::move(ctx.targetHandler()->getObjReader()));
|
|
|
|
// Tell registry about the relocation name to number mapping for this arch.
|
|
ctx.targetHandler()->registerRelocationNames(*this);
|
|
}
|
|
|
|
void Registry::addSupportELFDynamicSharedObjects(ELFLinkingContext &ctx) {
|
|
// Tell registry about the ELF dynamic shared library file parser.
|
|
add(ctx.targetHandler()->getDSOReader());
|
|
}
|
|
|
|
} // end namespace lld
|