[lld] r216295 - [PECOFF] Explicitly pass machine type
Rui Ueyama
ruiu at google.com
Fri Aug 22 15:03:16 PDT 2014
Author: ruiu
Date: Fri Aug 22 17:03:16 2014
New Revision: 216295
URL: http://llvm.org/viewvc/llvm-project?rev=216295&view=rev
Log:
[PECOFF] Explicitly pass machine type
x86 and x64 are created equal -- taking x86 as the default argument
made it hard to find bugs.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h
lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
lld/trunk/lib/ReaderWriter/PECOFF/Pass.cpp
lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp
Modified: lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h?rev=216295&r1=216294&r2=216295&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/Atoms.h Fri Aug 22 17:03:16 2014
@@ -28,8 +28,8 @@ class COFFDefinedAtom;
class COFFReference final : public Reference {
public:
COFFReference(const Atom *target, uint32_t offsetInAtom, uint16_t relocType,
- Reference::KindNamespace ns = Reference::KindNamespace::COFF,
- Reference::KindArch arch = Reference::KindArch::x86)
+ Reference::KindArch arch,
+ Reference::KindNamespace ns = Reference::KindNamespace::COFF)
: Reference(ns, arch, relocType), _target(target),
_offsetInAtom(offsetInAtom) {}
@@ -168,8 +168,8 @@ public:
void addAssociate(const DefinedAtom *other) {
auto *ref = new COFFReference(other, 0, lld::Reference::kindAssociate,
- Reference::KindNamespace::all,
- Reference::KindArch::all);
+ Reference::KindArch::all,
+ Reference::KindNamespace::all);
addReference(std::unique_ptr<COFFReference>(ref));
}
@@ -347,8 +347,8 @@ private:
template <typename T, typename U>
void addLayoutEdge(T *a, U *b, uint32_t which) {
- auto ref = new COFFReference(nullptr, 0, which, Reference::KindNamespace::all,
- Reference::KindArch::all);
+ auto ref = new COFFReference(nullptr, 0, which, Reference::KindArch::all,
+ Reference::KindNamespace::all);
ref->setTarget(b);
a->addReference(std::unique_ptr<COFFReference>(ref));
}
Modified: lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h?rev=216295&r1=216294&r2=216295&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h Fri Aug 22 17:03:16 2014
@@ -48,9 +48,11 @@ public:
: SimpleFile(defsym), _undefined(*this, undefsym),
_defined(*this, defsym, ordinal) {
auto *ref = is64 ? new COFFReference(&_undefined, 0,
- llvm::COFF::IMAGE_REL_AMD64_ADDR32)
+ llvm::COFF::IMAGE_REL_AMD64_ADDR32,
+ Reference::KindArch::x86_64)
: new COFFReference(&_undefined, 0,
- llvm::COFF::IMAGE_REL_I386_DIR32);
+ llvm::COFF::IMAGE_REL_I386_DIR32,
+ Reference::KindArch::x86);
_defined.addReference(std::unique_ptr<COFFReference>(ref));
addAtom(_defined);
addAtom(_undefined);
Modified: lld/trunk/lib/ReaderWriter/PECOFF/Pass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/Pass.cpp?rev=216295&r1=216294&r2=216295&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/Pass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/Pass.cpp Fri Aug 22 17:03:16 2014
@@ -19,8 +19,7 @@ namespace pecoff {
static void addReloc(COFFBaseDefinedAtom *atom, const Atom *target,
size_t offsetInAtom, Reference::KindArch arch,
Reference::KindValue relType) {
- auto *ref = new COFFReference(target, offsetInAtom, relType,
- Reference::KindNamespace::COFF, arch);
+ auto *ref = new COFFReference(target, offsetInAtom, relType, arch);
atom->addReference(std::unique_ptr<COFFReference>(ref));
}
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=216295&r1=216294&r2=216295&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Fri Aug 22 17:03:16 2014
@@ -794,8 +794,7 @@ std::error_code FileCOFF::addRelocationR
if (std::error_code ec = findAtomAt(section, itemAddress, atom, offsetInAtom))
return ec;
atom->addReference(std::unique_ptr<COFFReference>(
- new COFFReference(targetAtom, offsetInAtom, rel->Type,
- Reference::KindNamespace::COFF, _referenceArch)));
+ new COFFReference(targetAtom, offsetInAtom, rel->Type, _referenceArch)));
return std::error_code();
}
@@ -901,7 +900,7 @@ std::error_code FileCOFF::maybeCreateSXD
atom->addReference(std::unique_ptr<COFFReference>(new COFFReference(
handlerFunc, offsetInAtom, _is64 ? llvm::COFF::IMAGE_REL_AMD64_ADDR32
: llvm::COFF::IMAGE_REL_I386_DIR32,
- Reference::KindNamespace::COFF, _referenceArch)));
+ _referenceArch)));
}
_definedAtoms._atoms.push_back(atom);
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp?rev=216295&r1=216294&r2=216295&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderImportHeader.cpp Fri Aug 22 17:03:16 2014
@@ -245,11 +245,9 @@ private:
COFFReference *ref;
if (_is64) {
ref = new COFFReference(dataAtom, 2, llvm::COFF::IMAGE_REL_AMD64_REL32,
- Reference::KindNamespace::COFF,
Reference::KindArch::x86_64);
} else {
ref = new COFFReference(dataAtom, 2, llvm::COFF::IMAGE_REL_I386_DIR32,
- Reference::KindNamespace::COFF,
Reference::KindArch::x86);
}
atom->addReference(std::unique_ptr<COFFReference>(ref));
More information about the llvm-commits
mailing list