From d68304eeee368582a84bec790b7dccb3d8b71091 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 12 Dec 2013 10:01:14 +0000 Subject: [PATCH] [PECOFF] Move a utility function used in a pass to Pass.cpp. The file currently has only one function. Function that is useful both for IdataPass and EdataPass will be added to that file. llvm-svn: 197140 --- lld/lib/ReaderWriter/PECOFF/CMakeLists.txt | 1 + lld/lib/ReaderWriter/PECOFF/IdataPass.cpp | 8 +------ lld/lib/ReaderWriter/PECOFF/Pass.cpp | 28 ++++++++++++++++++++++ lld/lib/ReaderWriter/PECOFF/Pass.h | 24 +++++++++++++++++++ 4 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 lld/lib/ReaderWriter/PECOFF/Pass.cpp create mode 100644 lld/lib/ReaderWriter/PECOFF/Pass.h diff --git a/lld/lib/ReaderWriter/PECOFF/CMakeLists.txt b/lld/lib/ReaderWriter/PECOFF/CMakeLists.txt index 556e49b7412f..6cb4d1af058f 100644 --- a/lld/lib/ReaderWriter/PECOFF/CMakeLists.txt +++ b/lld/lib/ReaderWriter/PECOFF/CMakeLists.txt @@ -1,6 +1,7 @@ add_lld_library(lldPECOFF IdataPass.cpp PECOFFLinkingContext.cpp + Pass.cpp ReaderCOFF.cpp ReaderImportHeader.cpp WriterPECOFF.cpp diff --git a/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp b/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp index 9bbdce0e040c..c5d5490348b2 100644 --- a/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp +++ b/lld/lib/ReaderWriter/PECOFF/IdataPass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "IdataPass.h" +#include "Pass.h" #include "lld/Core/File.h" #include "lld/Core/Pass.h" @@ -23,13 +24,6 @@ namespace lld { namespace pecoff { - -static void addDir32NBReloc(COFFBaseDefinedAtom *atom, const Atom *target, - size_t offsetInAtom = 0) { - atom->addReference(std::unique_ptr(new COFFReference( - target, offsetInAtom, llvm::COFF::IMAGE_REL_I386_DIR32NB))); -} - namespace idata { IdataAtom::IdataAtom(Context &context, std::vector data) diff --git a/lld/lib/ReaderWriter/PECOFF/Pass.cpp b/lld/lib/ReaderWriter/PECOFF/Pass.cpp new file mode 100644 index 000000000000..88d4e5f020c0 --- /dev/null +++ b/lld/lib/ReaderWriter/PECOFF/Pass.cpp @@ -0,0 +1,28 @@ +//===- lib/ReaderWriter/PECOFF/Pass.cpp -----------------------------------===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "Atoms.h" +#include "Pass.h" + +#include "lld/Core/File.h" +#include "llvm/Support/COFF.h" + +namespace lld { +namespace pecoff { + +void addDir32NBReloc(coff::COFFBaseDefinedAtom *atom, const Atom *target, + size_t offsetInAtom) { + std::unique_ptr ref(new coff::COFFReference( + target, offsetInAtom, llvm::COFF::IMAGE_REL_I386_DIR32NB)); + atom->addReference(std::move(ref)); +} + +} // end namespace pecoff +} // end namespace lld + diff --git a/lld/lib/ReaderWriter/PECOFF/Pass.h b/lld/lib/ReaderWriter/PECOFF/Pass.h new file mode 100644 index 000000000000..a396b6525fa1 --- /dev/null +++ b/lld/lib/ReaderWriter/PECOFF/Pass.h @@ -0,0 +1,24 @@ +//===- lib/ReaderWriter/PECOFF/Pass.h -------------------------------------===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLD_READER_WRITER_PE_COFF_PASS_H +#define LLD_READER_WRITER_PE_COFF_PASS_H + +#include "Atoms.h" + +namespace lld { +namespace pecoff { + +void addDir32NBReloc(coff::COFFBaseDefinedAtom *atom, const Atom *target, + size_t offsetInAtom = 0); + +} // namespace pecoff +} // namespace lld + +#endif