[PECOFF] Explicitly pass machine type

x86 and x64 are created equal -- taking x86 as the default argument
made it hard to find bugs.

llvm-svn: 216295
This commit is contained in:
Rui Ueyama 2014-08-22 22:03:16 +00:00
parent 2d9bb65b3d
commit 4c6847aab9
5 changed files with 13 additions and 15 deletions

View File

@ -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));
}

View File

@ -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);

View File

@ -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));
}

View File

@ -794,8 +794,7 @@ std::error_code FileCOFF::addRelocationReference(
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::maybeCreateSXDataAtoms() {
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);

View File

@ -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));