[lld] r228905 - [ELF] Add LinkingContext to the ELFReader.
Shankar Easwaran
shankare at codeaurora.org
Thu Feb 12 12:34:35 PST 2015
Yes, its needed as all the create functions have a architecture specific
LinkingContext.
On 2/12/2015 2:31 PM, Rui Ueyama wrote:
> One question is if we really had to pass <arch>ELFLinkingContext instead of
> plain ELFLinkingContext to the ELFObjectReader? You parameterized that type
> as ContextT, but seems like it doesn't have to be an architecture-specific
> subclass of ELFLinkingContext.
>
> On Thu, Feb 12, 2015 at 12:06 PM, Rui Ueyama <ruiu at google.com> wrote:
>
>> This is a large patch that possibly many places in ELF. Since many people
>> are interested in LLD ELF support and code health of LLD in general, please
>> send this kind of patch to review before submitting in the future. Thanks.
>>
>> On Wed, Feb 11, 2015 at 9:02 PM, Shankar Easwaran <shankare at codeaurora.org
>>> wrote:
>>> Author: shankare
>>> Date: Wed Feb 11 23:02:41 2015
>>> New Revision: 228905
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=228905&view=rev
>>> Log:
>>> [ELF] Add LinkingContext to the ELFReader.
>>>
>>> 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.
>>>
>>> Modified:
>>> lld/trunk/include/lld/Core/Reader.h
>>> lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
>>> lld/trunk/lib/Driver/GnuLdDriver.cpp
>>> lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFFile.h
>>> lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h
>>> lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h
>>> lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h
>>> lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFReader.h
>>> lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h
>>> lld/trunk/lib/ReaderWriter/ELF/DefaultTargetHandler.h
>>> lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h
>>> lld/trunk/lib/ReaderWriter/ELF/DynamicLibraryWriter.h
>>> lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
>>> lld/trunk/lib/ReaderWriter/ELF/ELFReader.h
>>> lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h
>>> lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h
>>> lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h
>>> lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h
>>> lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
>>> lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
>>> lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFReader.h
>>> lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
>>> lld/trunk/lib/ReaderWriter/ELF/Reader.cpp
>>> lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h
>>> lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFFile.h
>>> lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFReader.h
>>> lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h
>>> lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFFile.h
>>> lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h
>>> lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h
>>>
>>> Modified: lld/trunk/include/lld/Core/Reader.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Reader.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/include/lld/Core/Reader.h (original)
>>> +++ lld/trunk/include/lld/Core/Reader.h Wed Feb 11 23:02:41 2015
>>> @@ -122,9 +122,8 @@ public:
>>> void addSupportCOFFObjects(PECOFFLinkingContext &);
>>> void addSupportCOFFImportLibraries(PECOFFLinkingContext &);
>>> void addSupportMachOObjects(MachOLinkingContext &);
>>> - void addSupportELFObjects(bool atomizeStrings, TargetHandlerBase
>>> *handler);
>>> - void addSupportELFDynamicSharedObjects(bool useShlibUndefines,
>>> - TargetHandlerBase *handler);
>>> + void addSupportELFObjects(ELFLinkingContext &);
>>> + void addSupportELFDynamicSharedObjects(ELFLinkingContext &);
>>>
>>> /// To convert between kind values and names, the registry walks the
>>> list
>>> /// of registered kind tables. Each table is a zero terminated array of
>>>
>>> Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)
>>> +++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -38,9 +38,9 @@ public:
>>> virtual ~TargetHandlerBase() {}
>>> virtual void registerRelocationNames(Registry &) = 0;
>>>
>>> - virtual std::unique_ptr<Reader> getObjReader(bool) = 0;
>>> + virtual std::unique_ptr<Reader> getObjReader() = 0;
>>>
>>> - virtual std::unique_ptr<Reader> getDSOReader(bool) = 0;
>>> + virtual std::unique_ptr<Reader> getDSOReader() = 0;
>>>
>>> virtual std::unique_ptr<Writer> getWriter() = 0;
>>> };
>>>
>>> Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
>>> +++ lld/trunk/lib/Driver/GnuLdDriver.cpp Wed Feb 11 23:02:41 2015
>>> @@ -587,15 +587,12 @@ bool GnuLdDriver::parse(int argc, const
>>> }
>>>
>>> // Register possible input file parsers.
>>> - ctx->registry().addSupportELFObjects(
>>> - ctx->mergeCommonStrings(),
>>> - ctx->targetHandler());
>>> + ctx->registry().addSupportELFObjects(*ctx);
>>> ctx->registry().addSupportArchives(ctx->logInputFiles());
>>> ctx->registry().addSupportYamlFiles();
>>> ctx->registry().addSupportNativeObjects();
>>> if (ctx->allowLinkWithDynamicLibraries())
>>> - ctx->registry().addSupportELFDynamicSharedObjects(
>>> - ctx->useShlibUndefines(), ctx->targetHandler());
>>> + ctx->registry().addSupportELFDynamicSharedObjects(*ctx);
>>>
>>> std::stack<int> groupStack;
>>> int numfiles = 0;
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFFile.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFFile.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFFile.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFFile.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -19,13 +19,13 @@ class AArch64LinkingContext;
>>>
>>> template <class ELFT> class AArch64ELFFile : public ELFFile<ELFT> {
>>> public:
>>> - AArch64ELFFile(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings)
>>> - : ELFFile<ELFT>(std::move(mb), atomizeStrings) {}
>>> + AArch64ELFFile(std::unique_ptr<MemoryBuffer> mb, AArch64LinkingContext
>>> &ctx)
>>> + : ELFFile<ELFT>(std::move(mb), ctx) {}
>>>
>>> static ErrorOr<std::unique_ptr<AArch64ELFFile>>
>>> - create(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings) {
>>> + create(std::unique_ptr<MemoryBuffer> mb, AArch64LinkingContext &ctx) {
>>> return std::unique_ptr<AArch64ELFFile<ELFT>>(
>>> - new AArch64ELFFile<ELFT>(std::move(mb), atomizeStrings));
>>> + new AArch64ELFFile<ELFT>(std::move(mb), ctx));
>>> }
>>> };
>>>
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64ELFReader.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -23,9 +23,8 @@ struct AArch64DynamicFileCreateELFTraits
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool useUndefines) {
>>> - return lld::elf::AArch64DynamicFile<ELFT>::create(std::move(mb),
>>> - useUndefines);
>>> + AArch64LinkingContext &ctx) {
>>> + return lld::elf::AArch64DynamicFile<ELFT>::create(std::move(mb),
>>> ctx);
>>> }
>>> };
>>>
>>> @@ -34,26 +33,27 @@ struct AArch64ELFFileCreateELFTraits {
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool atomizeStrings) {
>>> - return lld::elf::AArch64ELFFile<ELFT>::create(std::move(mb),
>>> - atomizeStrings);
>>> + AArch64LinkingContext &ctx) {
>>> + return lld::elf::AArch64ELFFile<ELFT>::create(std::move(mb), ctx);
>>> }
>>> };
>>>
>>> class AArch64ELFObjectReader
>>> - : public ELFObjectReader<AArch64ELFType,
>>> AArch64ELFFileCreateELFTraits> {
>>> + : public ELFObjectReader<AArch64ELFType,
>>> AArch64ELFFileCreateELFTraits,
>>> + AArch64LinkingContext> {
>>> public:
>>> - AArch64ELFObjectReader(bool atomizeStrings)
>>> - : ELFObjectReader<AArch64ELFType, AArch64ELFFileCreateELFTraits>(
>>> - atomizeStrings, llvm::ELF::EM_AARCH64) {}
>>> + AArch64ELFObjectReader(AArch64LinkingContext &ctx)
>>> + : ELFObjectReader<AArch64ELFType, AArch64ELFFileCreateELFTraits,
>>> + AArch64LinkingContext>(ctx,
>>> llvm::ELF::EM_AARCH64) {}
>>> };
>>>
>>> class AArch64ELFDSOReader
>>> - : public ELFDSOReader<AArch64ELFType,
>>> AArch64DynamicFileCreateELFTraits> {
>>> + : public ELFDSOReader<AArch64ELFType,
>>> AArch64DynamicFileCreateELFTraits,
>>> + AArch64LinkingContext> {
>>> public:
>>> - AArch64ELFDSOReader(bool useUndefines)
>>> - : ELFDSOReader<AArch64ELFType, AArch64DynamicFileCreateELFTraits>(
>>> - useUndefines, llvm::ELF::EM_AARCH64) {}
>>> + AArch64ELFDSOReader(AArch64LinkingContext &ctx)
>>> + : ELFDSOReader<AArch64ELFType, AArch64DynamicFileCreateELFTraits,
>>> + AArch64LinkingContext>(ctx, llvm::ELF::EM_AARCH64)
>>> {}
>>> };
>>>
>>> } // namespace elf
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h
>>> (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.h Wed Feb
>>> 11 23:02:41 2015
>>> @@ -41,12 +41,12 @@ public:
>>> return *(_AArch64RelocationHandler.get());
>>> }
>>>
>>> - std::unique_ptr<Reader> getObjReader(bool atomizeStrings) override {
>>> - return std::unique_ptr<Reader>(new
>>> AArch64ELFObjectReader(atomizeStrings));
>>> + std::unique_ptr<Reader> getObjReader() override {
>>> + return std::unique_ptr<Reader>(new AArch64ELFObjectReader(_context));
>>> }
>>>
>>> - std::unique_ptr<Reader> getDSOReader(bool useShlibUndefines) override {
>>> - return std::unique_ptr<Reader>(new
>>> AArch64ELFDSOReader(useShlibUndefines));
>>> + std::unique_ptr<Reader> getDSOReader() override {
>>> + return std::unique_ptr<Reader>(new AArch64ELFDSOReader(_context));
>>> }
>>>
>>> std::unique_ptr<Writer> getWriter() override;
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFFile.h Wed Feb 11 23:02:41
>>> 2015
>>> @@ -52,13 +52,13 @@ public:
>>>
>>> template <class ELFT> class ARMELFFile : public ELFFile<ELFT> {
>>> public:
>>> - ARMELFFile(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings)
>>> - : ELFFile<ELFT>(std::move(mb), atomizeStrings) {}
>>> + ARMELFFile(std::unique_ptr<MemoryBuffer> mb, ARMLinkingContext &ctx)
>>> + : ELFFile<ELFT>(std::move(mb), ctx) {}
>>>
>>> static ErrorOr<std::unique_ptr<ARMELFFile>>
>>> - create(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings) {
>>> + create(std::unique_ptr<MemoryBuffer> mb, ARMLinkingContext &ctx) {
>>> return std::unique_ptr<ARMELFFile<ELFT>>(
>>> - new ARMELFFile<ELFT>(std::move(mb), atomizeStrings));
>>> + new ARMELFFile<ELFT>(std::move(mb), ctx));
>>> }
>>>
>>> private:
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFReader.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFReader.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFReader.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMELFReader.h Wed Feb 11 23:02:41
>>> 2015
>>> @@ -23,8 +23,8 @@ struct ARMDynamicFileCreateELFTraits {
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool useUndefines) {
>>> - return lld::elf::ARMDynamicFile<ELFT>::create(std::move(mb),
>>> useUndefines);
>>> + ARMLinkingContext &ctx) {
>>> + return lld::elf::ARMDynamicFile<ELFT>::create(std::move(mb), ctx);
>>> }
>>> };
>>>
>>> @@ -33,25 +33,27 @@ struct ARMELFFileCreateELFTraits {
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool atomizeStrings) {
>>> - return lld::elf::ARMELFFile<ELFT>::create(std::move(mb),
>>> atomizeStrings);
>>> + ARMLinkingContext &ctx) {
>>> + return lld::elf::ARMELFFile<ELFT>::create(std::move(mb), ctx);
>>> }
>>> };
>>>
>>> class ARMELFObjectReader
>>> - : public ELFObjectReader<ARMELFType, ARMELFFileCreateELFTraits> {
>>> + : public ELFObjectReader<ARMELFType, ARMELFFileCreateELFTraits,
>>> + ARMLinkingContext> {
>>> public:
>>> - ARMELFObjectReader(bool atomizeStrings)
>>> - : ELFObjectReader<ARMELFType, ARMELFFileCreateELFTraits>(
>>> - atomizeStrings, llvm::ELF::EM_ARM) {}
>>> + ARMELFObjectReader(ARMLinkingContext &ctx)
>>> + : ELFObjectReader<ARMELFType, ARMELFFileCreateELFTraits,
>>> + ARMLinkingContext>(ctx, llvm::ELF::EM_ARM) {}
>>> };
>>>
>>> class ARMELFDSOReader
>>> - : public ELFDSOReader<ARMELFType, ARMDynamicFileCreateELFTraits> {
>>> + : public ELFDSOReader<ARMELFType, ARMDynamicFileCreateELFTraits,
>>> + ARMLinkingContext> {
>>> public:
>>> - ARMELFDSOReader(bool useUndefines)
>>> - : ELFDSOReader<ARMELFType, ARMDynamicFileCreateELFTraits>(
>>> - useUndefines, llvm::ELF::EM_ARM) {}
>>> + ARMELFDSOReader(ARMLinkingContext &ctx)
>>> + : ELFDSOReader<ARMELFType, ARMDynamicFileCreateELFTraits,
>>> + ARMLinkingContext>(ctx, llvm::ELF::EM_ARM) {}
>>> };
>>>
>>> } // namespace elf
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTargetHandler.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -45,12 +45,12 @@ public:
>>> return *(_armRelocationHandler.get());
>>> }
>>>
>>> - std::unique_ptr<Reader> getObjReader(bool atomizeStrings) override {
>>> - return std::unique_ptr<Reader>(new
>>> ARMELFObjectReader(atomizeStrings));
>>> + std::unique_ptr<Reader> getObjReader() override {
>>> + return std::unique_ptr<Reader>(new ARMELFObjectReader(_context));
>>> }
>>>
>>> - std::unique_ptr<Reader> getDSOReader(bool useShlibUndefines) override {
>>> - return std::unique_ptr<Reader>(new
>>> ARMELFDSOReader(useShlibUndefines));
>>> + std::unique_ptr<Reader> getDSOReader() override {
>>> + return std::unique_ptr<Reader>(new ARMELFDSOReader(_context));
>>> }
>>>
>>> std::unique_ptr<Writer> getWriter() override;
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/DefaultTargetHandler.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultTargetHandler.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/DefaultTargetHandler.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/DefaultTargetHandler.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -26,9 +26,9 @@ class DefaultTargetHandler : public Targ
>>> public:
>>> const TargetRelocationHandler &getRelocationHandler() const = 0;
>>>
>>> - virtual std::unique_ptr<Reader> getObjReader(bool atomizeStrings) = 0;
>>> + virtual std::unique_ptr<Reader> getObjReader() = 0;
>>>
>>> - virtual std::unique_ptr<Reader> getDSOReader(bool useShlibUndefines) =
>>> 0;
>>> + virtual std::unique_ptr<Reader> getDSOReader() = 0;
>>>
>>> virtual std::unique_ptr<Writer> getWriter() = 0;
>>> };
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h Wed Feb 11 23:02:41 2015
>>> @@ -22,7 +22,7 @@ namespace elf {
>>> template <class ELFT> class DynamicFile : public SharedLibraryFile {
>>> public:
>>> static ErrorOr<std::unique_ptr<DynamicFile>>
>>> - create(std::unique_ptr<llvm::MemoryBuffer> mb, bool useShlibUndefines);
>>> + create(std::unique_ptr<llvm::MemoryBuffer> mb, ELFLinkingContext &ctx);
>>>
>>> const SharedLibraryAtom *exports(StringRef name,
>>> bool dataSymbolOnly) const override {
>>> @@ -84,9 +84,9 @@ protected:
>>> }
>>>
>>> private:
>>> - DynamicFile(std::unique_ptr<MemoryBuffer> mb, bool useShlibUndefines)
>>> - : SharedLibraryFile(mb->getBufferIdentifier()),
>>> - _mb(std::move(mb)), _useShlibUndefines(useShlibUndefines) {}
>>> + DynamicFile(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx)
>>> + : SharedLibraryFile(mb->getBufferIdentifier()), _mb(std::move(mb)),
>>> + _ctx(ctx), _useShlibUndefines(ctx.useShlibUndefines()) {}
>>>
>>> mutable llvm::BumpPtrAllocator _alloc;
>>> std::unique_ptr<llvm::object::ELFFile<ELFT>> _objFile;
>>> @@ -100,6 +100,7 @@ private:
>>> };
>>>
>>> std::unique_ptr<MemoryBuffer> _mb;
>>> + ELFLinkingContext &_ctx;
>>> bool _useShlibUndefines;
>>> mutable std::unordered_map<StringRef, SymAtomPair> _nameToSym;
>>> };
>>> @@ -107,9 +108,8 @@ private:
>>> template <class ELFT>
>>> ErrorOr<std::unique_ptr<DynamicFile<ELFT>>>
>>> DynamicFile<ELFT>::create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool useShlibUndefines) {
>>> - return std::unique_ptr<DynamicFile>(
>>> - new DynamicFile(std::move(mb), useShlibUndefines));
>>> + ELFLinkingContext &ctx) {
>>> + return std::unique_ptr<DynamicFile>(new DynamicFile(std::move(mb),
>>> ctx));
>>> }
>>>
>>> } // end namespace elf
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/DynamicLibraryWriter.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DynamicLibraryWriter.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/DynamicLibraryWriter.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/DynamicLibraryWriter.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -25,8 +25,7 @@ class DynamicLibraryWriter;
>>> template<class ELFT>
>>> class DynamicLibraryWriter : public OutputELFWriter<ELFT> {
>>> public:
>>> - DynamicLibraryWriter(const ELFLinkingContext &context,
>>> - TargetLayout<ELFT> &layout)
>>> + DynamicLibraryWriter(ELFLinkingContext &context, TargetLayout<ELFT>
>>> &layout)
>>> : OutputELFWriter<ELFT>(context, layout),
>>> _runtimeFile(new CRuntimeFile<ELFT>(context)) {}
>>>
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Wed Feb 11 23:02:41 2015
>>> @@ -115,17 +115,18 @@ template <class ELFT> class ELFFile : pu
>>> typedef typename MergedSectionMapT::iterator MergedSectionMapIterT;
>>>
>>> public:
>>> - ELFFile(StringRef name)
>>> - : File(name, kindObject), _ordinal(0), _doStringsMerge(false) {
>>> + ELFFile(StringRef name, ELFLinkingContext &ctx)
>>> + : File(name, kindObject), _ordinal(0),
>>> + _doStringsMerge(ctx.mergeCommonStrings()), _ctx(ctx) {
>>> setLastError(std::error_code());
>>> }
>>>
>>> - ELFFile(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings = false)
>>> + ELFFile(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx)
>>> : File(mb->getBufferIdentifier(), kindObject), _mb(std::move(mb)),
>>> - _ordinal(0), _doStringsMerge(atomizeStrings) {}
>>> + _ordinal(0), _doStringsMerge(ctx.mergeCommonStrings()),
>>> _ctx(ctx) {}
>>>
>>> static ErrorOr<std::unique_ptr<ELFFile>>
>>> - create(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings);
>>> + create(std::unique_ptr<MemoryBuffer> mb, ELFLinkingContext &ctx);
>>>
>>> virtual Reference::KindArch kindArch();
>>>
>>> @@ -360,6 +361,9 @@ protected:
>>>
>>> /// \brief the cached options relevant while reading the ELF File
>>> bool _doStringsMerge;
>>> +
>>> + /// \brief The LinkingContext.
>>> + ELFLinkingContext &_ctx;
>>> };
>>>
>>> /// \brief All atoms are owned by a File. To add linker specific atoms
>>> @@ -370,8 +374,8 @@ protected:
>>> template <class ELFT> class CRuntimeFile : public ELFFile<ELFT> {
>>> public:
>>> typedef llvm::object::Elf_Sym_Impl<ELFT> Elf_Sym;
>>> - CRuntimeFile(const ELFLinkingContext &context, StringRef name = "C
>>> runtime")
>>> - : ELFFile<ELFT>(name) {}
>>> + CRuntimeFile(ELFLinkingContext &context, StringRef name = "C runtime")
>>> + : ELFFile<ELFT>(name, context) {}
>>>
>>> /// \brief add a global absolute atom
>>> virtual Atom *addAbsoluteAtom(StringRef symbolName) {
>>> @@ -411,9 +415,9 @@ public:
>>>
>>> template <class ELFT>
>>> ErrorOr<std::unique_ptr<ELFFile<ELFT>>>
>>> -ELFFile<ELFT>::create(std::unique_ptr<MemoryBuffer> mb, bool
>>> atomizeStrings) {
>>> - std::unique_ptr<ELFFile<ELFT>> file(
>>> - new ELFFile<ELFT>(std::move(mb), atomizeStrings));
>>> +ELFFile<ELFT>::create(std::unique_ptr<MemoryBuffer> mb,
>>> + ELFLinkingContext &ctx) {
>>> + std::unique_ptr<ELFFile<ELFT>> file(new ELFFile<ELFT>(std::move(mb),
>>> ctx));
>>> return std::move(file);
>>> }
>>>
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/ELFReader.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFReader.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/ELFReader.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/ELFReader.h Wed Feb 11 23:02:41 2015
>>> @@ -18,13 +18,13 @@
>>> namespace lld {
>>> namespace elf {
>>>
>>> -template <typename ELFT, typename ELFTraitsT>
>>> +template <typename ELFT, typename ELFTraitsT, typename ContextT>
>>> class ELFObjectReader : public Reader {
>>> public:
>>> typedef llvm::object::Elf_Ehdr_Impl<ELFT> Elf_Ehdr;
>>>
>>> - ELFObjectReader(bool atomizeStrings, uint64_t machine)
>>> - : _atomizeStrings(atomizeStrings), _machine(machine) {}
>>> + ELFObjectReader(ContextT &ctx, uint64_t machine)
>>> + : _ctx(ctx), _machine(machine) {}
>>>
>>> bool canParse(file_magic magic, StringRef,
>>> const MemoryBuffer &buf) const override {
>>> @@ -39,7 +39,7 @@ public:
>>> 1ULL <<
>>> llvm::countTrailingZeros(uintptr_t(mb->getBufferStart()));
>>> auto f =
>>>
>>> createELF<ELFTraitsT>(llvm::object::getElfArchType(mb->getBuffer()),
>>> - maxAlignment, std::move(mb),
>>> _atomizeStrings);
>>> + maxAlignment, std::move(mb), _ctx);
>>> if (std::error_code ec = f.getError())
>>> return ec;
>>> result.push_back(std::move(*f));
>>> @@ -53,17 +53,17 @@ public:
>>> }
>>>
>>> protected:
>>> - bool _atomizeStrings;
>>> + ContextT &_ctx;
>>> uint64_t _machine;
>>> };
>>>
>>> -template <typename ELFT, typename ELFTraitsT>
>>> +template <typename ELFT, typename ELFTraitsT, typename ContextT>
>>> class ELFDSOReader : public Reader {
>>> public:
>>> typedef llvm::object::Elf_Ehdr_Impl<ELFT> Elf_Ehdr;
>>>
>>> - ELFDSOReader(bool useUndefines, uint64_t machine)
>>> - : _useUndefines(useUndefines), _machine(machine) {}
>>> + ELFDSOReader(ContextT &ctx, uint64_t machine)
>>> + : _ctx(ctx), _machine(machine) {}
>>>
>>> bool canParse(file_magic magic, StringRef,
>>> const MemoryBuffer &buf) const override {
>>> @@ -78,7 +78,7 @@ public:
>>> 1ULL <<
>>> llvm::countTrailingZeros(uintptr_t(mb->getBufferStart()));
>>> auto f =
>>>
>>> createELF<ELFTraitsT>(llvm::object::getElfArchType(mb->getBuffer()),
>>> - maxAlignment, std::move(mb),
>>> _useUndefines);
>>> + maxAlignment, std::move(mb), _ctx);
>>> if (std::error_code ec = f.getError())
>>> return ec;
>>> result.push_back(std::move(*f));
>>> @@ -92,7 +92,7 @@ public:
>>> }
>>>
>>> protected:
>>> - bool _useUndefines;
>>> + ContextT &_ctx;
>>> uint64_t _machine;
>>> };
>>>
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h Wed Feb 11 23:02:41
>>> 2015
>>> @@ -25,7 +25,7 @@ class ExecutableWriter;
>>> template<class ELFT>
>>> class ExecutableWriter : public OutputELFWriter<ELFT> {
>>> public:
>>> - ExecutableWriter(const ELFLinkingContext &context, TargetLayout<ELFT>
>>> &layout)
>>> + ExecutableWriter(ELFLinkingContext &context, TargetLayout<ELFT>
>>> &layout)
>>> : OutputELFWriter<ELFT>(context, layout),
>>> _runtimeFile(new CRuntimeFile<ELFT>(context)) {}
>>>
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -114,13 +114,13 @@ template <class ELFT> class HexagonELFFi
>>> typedef llvm::object::Elf_Shdr_Impl<ELFT> Elf_Shdr;
>>>
>>> public:
>>> - HexagonELFFile(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings)
>>> - : ELFFile<ELFT>(std::move(mb), atomizeStrings) {}
>>> + HexagonELFFile(std::unique_ptr<MemoryBuffer> mb, HexagonLinkingContext
>>> &ctx)
>>> + : ELFFile<ELFT>(std::move(mb), ctx) {}
>>>
>>> static ErrorOr<std::unique_ptr<HexagonELFFile>>
>>> - create(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings) {
>>> + create(std::unique_ptr<MemoryBuffer> mb, HexagonLinkingContext &ctx) {
>>> return std::unique_ptr<HexagonELFFile<ELFT>>(
>>> - new HexagonELFFile<ELFT>(std::move(mb), atomizeStrings));
>>> + new HexagonELFFile<ELFT>(std::move(mb), ctx));
>>> }
>>>
>>> bool isCommonSymbol(const Elf_Sym *symbol) const override {
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -23,9 +23,8 @@ struct HexagonDynamicFileCreateELFTraits
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool useUndefines) {
>>> - return lld::elf::HexagonDynamicFile<ELFT>::create(std::move(mb),
>>> - useUndefines);
>>> + HexagonLinkingContext &ctx) {
>>> + return lld::elf::HexagonDynamicFile<ELFT>::create(std::move(mb),
>>> ctx);
>>> }
>>> };
>>>
>>> @@ -34,26 +33,27 @@ struct HexagonELFFileCreateELFTraits {
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool atomizeStrings) {
>>> - return lld::elf::HexagonELFFile<ELFT>::create(std::move(mb),
>>> - atomizeStrings);
>>> + HexagonLinkingContext &ctx) {
>>> + return lld::elf::HexagonELFFile<ELFT>::create(std::move(mb), ctx);
>>> }
>>> };
>>>
>>> class HexagonELFObjectReader
>>> - : public ELFObjectReader<HexagonELFType,
>>> HexagonELFFileCreateELFTraits> {
>>> + : public ELFObjectReader<HexagonELFType,
>>> HexagonELFFileCreateELFTraits,
>>> + HexagonLinkingContext> {
>>> public:
>>> - HexagonELFObjectReader(bool atomizeStrings)
>>> - : ELFObjectReader<HexagonELFType, HexagonELFFileCreateELFTraits>(
>>> - atomizeStrings, llvm::ELF::EM_HEXAGON) {}
>>> + HexagonELFObjectReader(HexagonLinkingContext &ctx)
>>> + : ELFObjectReader<HexagonELFType, HexagonELFFileCreateELFTraits,
>>> + HexagonLinkingContext>(ctx,
>>> llvm::ELF::EM_HEXAGON) {}
>>> };
>>>
>>> class HexagonELFDSOReader
>>> - : public ELFDSOReader<HexagonELFType,
>>> HexagonDynamicFileCreateELFTraits> {
>>> + : public ELFDSOReader<HexagonELFType,
>>> HexagonDynamicFileCreateELFTraits,
>>> + HexagonLinkingContext> {
>>> public:
>>> - HexagonELFDSOReader(bool useUndefines)
>>> - : ELFDSOReader<HexagonELFType, HexagonDynamicFileCreateELFTraits>(
>>> - useUndefines, llvm::ELF::EM_HEXAGON) {}
>>> + HexagonELFDSOReader(HexagonLinkingContext &ctx)
>>> + : ELFDSOReader<HexagonELFType, HexagonDynamicFileCreateELFTraits,
>>> + HexagonLinkingContext>(ctx, llvm::ELF::EM_HEXAGON)
>>> {}
>>> };
>>>
>>> } // namespace elf
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h
>>> (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonExecutableAtoms.h Wed
>>> Feb 11 23:02:41 2015
>>> @@ -20,7 +20,7 @@ class HexagonLinkingContext;
>>> template <class HexagonELFType> class HexagonRuntimeFile
>>> : public CRuntimeFile<HexagonELFType> {
>>> public:
>>> - HexagonRuntimeFile(const HexagonLinkingContext &context)
>>> + HexagonRuntimeFile(HexagonLinkingContext &context)
>>> : CRuntimeFile<HexagonELFType>(context, "Hexagon runtime file") {}
>>> };
>>> } // elf
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
>>> (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h Wed Feb
>>> 11 23:02:41 2015
>>> @@ -117,12 +117,14 @@ public:
>>> return *(_hexagonTargetLayout.get());
>>> }
>>>
>>> - std::unique_ptr<Reader> getObjReader(bool atomizeStrings) override {
>>> - return std::unique_ptr<Reader>(new
>>> HexagonELFObjectReader(atomizeStrings));
>>> + std::unique_ptr<Reader> getObjReader() override {
>>> + return std::unique_ptr<Reader>(
>>> + new HexagonELFObjectReader(_hexagonLinkingContext));
>>> }
>>>
>>> - std::unique_ptr<Reader> getDSOReader(bool useShlibUndefines) override {
>>> - return std::unique_ptr<Reader>(new
>>> HexagonELFDSOReader(useShlibUndefines));
>>> + std::unique_ptr<Reader> getDSOReader() override {
>>> + return std::unique_ptr<Reader>(
>>> + new HexagonELFDSOReader(_hexagonLinkingContext));
>>> }
>>>
>>> std::unique_ptr<Writer> getWriter() override;
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h Wed Feb 11 23:02:41
>>> 2015
>>> @@ -80,13 +80,13 @@ public:
>>>
>>> template <class ELFT> class MipsELFFile : public ELFFile<ELFT> {
>>> public:
>>> - MipsELFFile(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings)
>>> - : ELFFile<ELFT>(std::move(mb), atomizeStrings) {}
>>> + MipsELFFile(std::unique_ptr<MemoryBuffer> mb, MipsLinkingContext &ctx)
>>> + : ELFFile<ELFT>(std::move(mb), ctx) {}
>>>
>>> static ErrorOr<std::unique_ptr<MipsELFFile>>
>>> - create(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings) {
>>> + create(std::unique_ptr<MemoryBuffer> mb, MipsLinkingContext &ctx) {
>>> return std::unique_ptr<MipsELFFile<ELFT>>(
>>> - new MipsELFFile<ELFT>(std::move(mb), atomizeStrings));
>>> + new MipsELFFile<ELFT>(std::move(mb), ctx));
>>> }
>>>
>>> bool isPIC() const {
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFReader.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFReader.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFReader.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFReader.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -22,8 +22,8 @@ struct MipsELFFileCreateTraits {
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool atomizeStrings) {
>>> - return lld::elf::MipsELFFile<ELFT>::create(std::move(mb),
>>> atomizeStrings);
>>> + MipsLinkingContext &ctx) {
>>> + return lld::elf::MipsELFFile<ELFT>::create(std::move(mb), ctx);
>>> }
>>> };
>>>
>>> @@ -32,19 +32,21 @@ struct MipsDynamicFileCreateELFTraits {
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool useUndefines) {
>>> - return lld::elf::MipsDynamicFile<ELFT>::create(std::move(mb),
>>> useUndefines);
>>> + MipsLinkingContext &ctx) {
>>> + return lld::elf::MipsDynamicFile<ELFT>::create(std::move(mb), ctx);
>>> }
>>> };
>>>
>>> template <class ELFT>
>>> class MipsELFObjectReader
>>> - : public ELFObjectReader<ELFT, MipsELFFileCreateTraits> {
>>> - typedef ELFObjectReader<ELFT, MipsELFFileCreateTraits> BaseReaderType;
>>> + : public ELFObjectReader<ELFT, MipsELFFileCreateTraits,
>>> + MipsLinkingContext> {
>>> + typedef ELFObjectReader<ELFT, MipsELFFileCreateTraits,
>>> MipsLinkingContext>
>>> + BaseReaderType;
>>>
>>> public:
>>> - MipsELFObjectReader(MipsLinkingContext &ctx, bool atomizeStrings)
>>> - : BaseReaderType(atomizeStrings, llvm::ELF::EM_MIPS),
>>> + MipsELFObjectReader(MipsLinkingContext &ctx)
>>> + : BaseReaderType(ctx, llvm::ELF::EM_MIPS),
>>> _flagMerger(ctx.getELFFlagsMerger()) {}
>>>
>>> std::error_code
>>> @@ -62,12 +64,14 @@ private:
>>>
>>> template <class ELFT>
>>> class MipsELFDSOReader
>>> - : public ELFDSOReader<ELFT, MipsDynamicFileCreateELFTraits> {
>>> - typedef ELFDSOReader<ELFT, MipsDynamicFileCreateELFTraits>
>>> BaseReaderType;
>>> + : public ELFDSOReader<ELFT, MipsDynamicFileCreateELFTraits,
>>> + MipsLinkingContext> {
>>> + typedef ELFDSOReader<ELFT, MipsDynamicFileCreateELFTraits,
>>> MipsLinkingContext>
>>> + BaseReaderType;
>>>
>>> public:
>>> - MipsELFDSOReader(MipsLinkingContext &ctx, bool useUndefines)
>>> - : BaseReaderType(useUndefines, llvm::ELF::EM_MIPS),
>>> + MipsELFDSOReader(MipsLinkingContext &ctx)
>>> + : BaseReaderType(ctx, llvm::ELF::EM_MIPS),
>>> _flagMerger(ctx.getELFFlagsMerger()) {}
>>>
>>> std::error_code
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -79,7 +79,7 @@ private:
>>> template <class ELFType>
>>> class MipsRuntimeFile final : public CRuntimeFile<ELFType> {
>>> public:
>>> - MipsRuntimeFile(const MipsLinkingContext &ctx)
>>> + MipsRuntimeFile(MipsLinkingContext &ctx)
>>> : CRuntimeFile<ELFType>(ctx, "Mips runtime file") {}
>>> };
>>>
>>> @@ -102,14 +102,12 @@ public:
>>>
>>> MipsTargetLayout<ELFT> &getTargetLayout() override { return
>>> *_targetLayout; }
>>>
>>> - std::unique_ptr<Reader> getObjReader(bool atomizeStrings) override {
>>> - return std::unique_ptr<Reader>(
>>> - new MipsELFObjectReader<ELFT>(_ctx, atomizeStrings));
>>> + std::unique_ptr<Reader> getObjReader() override {
>>> + return std::unique_ptr<Reader>(new MipsELFObjectReader<ELFT>(_ctx));
>>> }
>>>
>>> - std::unique_ptr<Reader> getDSOReader(bool useShlibUndefines) override {
>>> - return std::unique_ptr<Reader>(
>>> - new MipsELFDSOReader<ELFT>(_ctx, useShlibUndefines));
>>> + std::unique_ptr<Reader> getDSOReader() override {
>>> + return std::unique_ptr<Reader>(new MipsELFDSOReader<ELFT>(_ctx));
>>> }
>>>
>>> const TargetRelocationHandler &getRelocationHandler() const override {
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/Reader.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Reader.cpp?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/Reader.cpp (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/Reader.cpp Wed Feb 11 23:02:41 2015
>>> @@ -26,20 +26,18 @@ namespace lld {
>>> // 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(bool atomizeStrings,
>>> - TargetHandlerBase *handler) {
>>> +void Registry::addSupportELFObjects(ELFLinkingContext &ctx) {
>>>
>>> // Tell registry about the ELF object file parser.
>>> - add(std::move(handler->getObjReader(atomizeStrings)));
>>> + add(std::move(ctx.targetHandler()->getObjReader()));
>>>
>>> // Tell registry about the relocation name to number mapping for this
>>> arch.
>>> - handler->registerRelocationNames(*this);
>>> + ctx.targetHandler()->registerRelocationNames(*this);
>>> }
>>>
>>> -void Registry::addSupportELFDynamicSharedObjects(bool useShlibUndefines,
>>> - TargetHandlerBase
>>> *handler) {
>>> +void Registry::addSupportELFDynamicSharedObjects(ELFLinkingContext &ctx)
>>> {
>>> // Tell registry about the ELF dynamic shared library file parser.
>>> - add(handler->getDSOReader(useShlibUndefines));
>>> + add(ctx.targetHandler()->getDSOReader());
>>> }
>>>
>>> } // end namespace lld
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/TargetHandler.h Wed Feb 11 23:02:41
>>> 2015
>>> @@ -63,10 +63,10 @@ public:
>>> virtual const TargetRelocationHandler &getRelocationHandler() const =
>>> 0;
>>>
>>> /// How does the target deal with reading input files.
>>> - virtual std::unique_ptr<Reader> getObjReader(bool) = 0;
>>> + virtual std::unique_ptr<Reader> getObjReader() = 0;
>>>
>>> /// How does the target deal with reading dynamic libraries.
>>> - virtual std::unique_ptr<Reader> getDSOReader(bool) = 0;
>>> + virtual std::unique_ptr<Reader> getDSOReader() = 0;
>>>
>>> /// How does the target deal with writing ELF output.
>>> virtual std::unique_ptr<Writer> getWriter() = 0;
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFFile.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFFile.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFFile.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFFile.h Wed Feb 11 23:02:41
>>> 2015
>>> @@ -19,13 +19,13 @@ class X86LinkingContext;
>>>
>>> template <class ELFT> class X86ELFFile : public ELFFile<ELFT> {
>>> public:
>>> - X86ELFFile(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings)
>>> - : ELFFile<ELFT>(std::move(mb), atomizeStrings) {}
>>> + X86ELFFile(std::unique_ptr<MemoryBuffer> mb, X86LinkingContext &ctx)
>>> + : ELFFile<ELFT>(std::move(mb), ctx) {}
>>>
>>> static ErrorOr<std::unique_ptr<X86ELFFile>>
>>> - create(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings) {
>>> + create(std::unique_ptr<MemoryBuffer> mb, X86LinkingContext &ctx) {
>>> return std::unique_ptr<X86ELFFile<ELFT>>(
>>> - new X86ELFFile<ELFT>(std::move(mb), atomizeStrings));
>>> + new X86ELFFile<ELFT>(std::move(mb), ctx));
>>> }
>>> };
>>>
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFReader.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFReader.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFReader.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/X86/X86ELFReader.h Wed Feb 11 23:02:41
>>> 2015
>>> @@ -23,8 +23,8 @@ struct X86DynamicFileCreateELFTraits {
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool useUndefines) {
>>> - return lld::elf::X86DynamicFile<ELFT>::create(std::move(mb),
>>> useUndefines);
>>> + X86LinkingContext &ctx) {
>>> + return lld::elf::X86DynamicFile<ELFT>::create(std::move(mb), ctx);
>>> }
>>> };
>>>
>>> @@ -33,25 +33,27 @@ struct X86ELFFileCreateELFTraits {
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool atomizeStrings) {
>>> - return lld::elf::X86ELFFile<ELFT>::create(std::move(mb),
>>> atomizeStrings);
>>> + X86LinkingContext &ctx) {
>>> + return lld::elf::X86ELFFile<ELFT>::create(std::move(mb), ctx);
>>> }
>>> };
>>>
>>> class X86ELFObjectReader
>>> - : public ELFObjectReader<X86ELFType, X86ELFFileCreateELFTraits> {
>>> + : public ELFObjectReader<X86ELFType, X86ELFFileCreateELFTraits,
>>> + X86LinkingContext> {
>>> public:
>>> - X86ELFObjectReader(bool atomizeStrings)
>>> - : ELFObjectReader<X86ELFType, X86ELFFileCreateELFTraits>(
>>> - atomizeStrings, llvm::ELF::EM_386) {}
>>> + X86ELFObjectReader(X86LinkingContext &ctx)
>>> + : ELFObjectReader<X86ELFType, X86ELFFileCreateELFTraits,
>>> + X86LinkingContext>(ctx, llvm::ELF::EM_386) {}
>>> };
>>>
>>> class X86ELFDSOReader
>>> - : public ELFDSOReader<X86ELFType, X86DynamicFileCreateELFTraits> {
>>> + : public ELFDSOReader<X86ELFType, X86DynamicFileCreateELFTraits,
>>> + X86LinkingContext> {
>>> public:
>>> - X86ELFDSOReader(bool useUndefines)
>>> - : ELFDSOReader<X86ELFType, X86DynamicFileCreateELFTraits>(
>>> - useUndefines, llvm::ELF::EM_386) {}
>>> + X86ELFDSOReader(X86LinkingContext &ctx)
>>> + : ELFDSOReader<X86ELFType, X86DynamicFileCreateELFTraits,
>>> + X86LinkingContext>(ctx, llvm::ELF::EM_386) {}
>>> };
>>>
>>> } // namespace elf
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/X86/X86TargetHandler.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -41,12 +41,12 @@ public:
>>> return *(_x86RelocationHandler.get());
>>> }
>>>
>>> - std::unique_ptr<Reader> getObjReader(bool atomizeStrings) override {
>>> - return std::unique_ptr<Reader>(new
>>> X86ELFObjectReader(atomizeStrings));
>>> + std::unique_ptr<Reader> getObjReader() override {
>>> + return std::unique_ptr<Reader>(new
>>> X86ELFObjectReader(_x86LinkingContext));
>>> }
>>>
>>> - std::unique_ptr<Reader> getDSOReader(bool useShlibUndefines) override {
>>> - return std::unique_ptr<Reader>(new
>>> X86ELFDSOReader(useShlibUndefines));
>>> + std::unique_ptr<Reader> getDSOReader() override {
>>> + return std::unique_ptr<Reader>(new
>>> X86ELFDSOReader(_x86LinkingContext));
>>> }
>>>
>>> std::unique_ptr<Writer> getWriter() override;
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFFile.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFFile.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFFile.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFFile.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -19,13 +19,13 @@ class X86_64LinkingContext;
>>>
>>> template <class ELFT> class X86_64ELFFile : public ELFFile<ELFT> {
>>> public:
>>> - X86_64ELFFile(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings)
>>> - : ELFFile<ELFT>(std::move(mb), atomizeStrings) {}
>>> + X86_64ELFFile(std::unique_ptr<MemoryBuffer> mb, X86_64LinkingContext
>>> &ctx)
>>> + : ELFFile<ELFT>(std::move(mb), ctx) {}
>>>
>>> static ErrorOr<std::unique_ptr<X86_64ELFFile>>
>>> - create(std::unique_ptr<MemoryBuffer> mb, bool atomizeStrings) {
>>> + create(std::unique_ptr<MemoryBuffer> mb, X86_64LinkingContext &ctx) {
>>> return std::unique_ptr<X86_64ELFFile<ELFT>>(
>>> - new X86_64ELFFile<ELFT>(std::move(mb), atomizeStrings));
>>> + new X86_64ELFFile<ELFT>(std::move(mb), ctx));
>>> }
>>> };
>>>
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64ELFReader.h Wed Feb 11
>>> 23:02:41 2015
>>> @@ -23,9 +23,8 @@ struct X86_64DynamicFileCreateELFTraits
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool useUndefines) {
>>> - return lld::elf::X86_64DynamicFile<ELFT>::create(std::move(mb),
>>> - useUndefines);
>>> + X86_64LinkingContext &ctx) {
>>> + return lld::elf::X86_64DynamicFile<ELFT>::create(std::move(mb), ctx);
>>> }
>>> };
>>>
>>> @@ -34,25 +33,27 @@ struct X86_64ELFFileCreateELFTraits {
>>>
>>> template <class ELFT>
>>> static result_type create(std::unique_ptr<llvm::MemoryBuffer> mb,
>>> - bool atomizeStrings) {
>>> - return lld::elf::X86_64ELFFile<ELFT>::create(std::move(mb),
>>> atomizeStrings);
>>> + X86_64LinkingContext &ctx) {
>>> + return lld::elf::X86_64ELFFile<ELFT>::create(std::move(mb), ctx);
>>> }
>>> };
>>>
>>> class X86_64ELFObjectReader
>>> - : public ELFObjectReader<X86_64ELFType,
>>> X86_64ELFFileCreateELFTraits> {
>>> + : public ELFObjectReader<X86_64ELFType, X86_64ELFFileCreateELFTraits,
>>> + X86_64LinkingContext> {
>>> public:
>>> - X86_64ELFObjectReader(bool atomizeStrings)
>>> - : ELFObjectReader<X86_64ELFType, X86_64ELFFileCreateELFTraits>(
>>> - atomizeStrings, llvm::ELF::EM_X86_64) {}
>>> + X86_64ELFObjectReader(X86_64LinkingContext &ctx)
>>> + : ELFObjectReader<X86_64ELFType, X86_64ELFFileCreateELFTraits,
>>> + X86_64LinkingContext>(ctx, llvm::ELF::EM_X86_64)
>>> {}
>>> };
>>>
>>> class X86_64ELFDSOReader
>>> - : public ELFDSOReader<X86_64ELFType,
>>> X86_64DynamicFileCreateELFTraits> {
>>> + : public ELFDSOReader<X86_64ELFType,
>>> X86_64DynamicFileCreateELFTraits,
>>> + X86_64LinkingContext> {
>>> public:
>>> - X86_64ELFDSOReader(bool useUndefines)
>>> - : ELFDSOReader<X86_64ELFType, X86_64DynamicFileCreateELFTraits>(
>>> - useUndefines, llvm::ELF::EM_X86_64) {}
>>> + X86_64ELFDSOReader(X86_64LinkingContext &ctx)
>>> + : ELFDSOReader<X86_64ELFType, X86_64DynamicFileCreateELFTraits,
>>> + X86_64LinkingContext>(ctx, llvm::ELF::EM_X86_64) {}
>>> };
>>>
>>> } // namespace elf
>>>
>>> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h?rev=228905&r1=228904&r2=228905&view=diff
>>>
>>> ==============================================================================
>>> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h (original)
>>> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.h Wed Feb
>>> 11 23:02:41 2015
>>> @@ -42,12 +42,12 @@ public:
>>> return *(_x86_64RelocationHandler.get());
>>> }
>>>
>>> - std::unique_ptr<Reader> getObjReader(bool atomizeStrings) override {
>>> - return std::unique_ptr<Reader>(new
>>> X86_64ELFObjectReader(atomizeStrings));
>>> + std::unique_ptr<Reader> getObjReader() override {
>>> + return std::unique_ptr<Reader>(new X86_64ELFObjectReader(_context));
>>> }
>>>
>>> - std::unique_ptr<Reader> getDSOReader(bool useShlibUndefines) override {
>>> - return std::unique_ptr<Reader>(new
>>> X86_64ELFDSOReader(useShlibUndefines));
>>> + std::unique_ptr<Reader> getDSOReader() override {
>>> + return std::unique_ptr<Reader>(new X86_64ELFDSOReader(_context));
>>> }
>>>
>>> std::unique_ptr<Writer> getWriter() override;
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
More information about the llvm-commits
mailing list