[lld] r193476 - [Darwin] Fix Reference to nullptr.
Shankar Easwaran
shankare at codeaurora.org
Sat Oct 26 12:38:27 PDT 2013
Author: shankare
Date: Sat Oct 26 14:38:26 2013
New Revision: 193476
URL: http://llvm.org/viewvc/llvm-project?rev=193476&view=rev
Log:
[Darwin] Fix Reference to nullptr.
On discussing this with Nick, it looks like the StubAtoms
that contain a lazyImmediate reference kind should be null
and the location needs to be fixed up later with some value
that is an offset into the __LINKEDIT segment.
The drawback is that it allows yaml files with references
that expect a target to be considered without one.
This results in bad yaml files that would need to be handled
in the YAML Reader.
Inorder to fix this, the Stub Atoms use a dummy target such
as itself.
Modified:
lld/trunk/lib/ReaderWriter/MachO/StubAtoms_x86.hpp
lld/trunk/lib/ReaderWriter/MachO/StubAtoms_x86_64.hpp
Modified: lld/trunk/lib/ReaderWriter/MachO/StubAtoms_x86.hpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/StubAtoms_x86.hpp?rev=193476&r1=193475&r2=193476&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/StubAtoms_x86.hpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/StubAtoms_x86.hpp Sat Oct 26 14:38:26 2013
@@ -28,7 +28,7 @@ namespace mach_o {
//
class X86StubAtom : public SimpleDefinedAtom {
public:
- X86StubAtom(const File &file, const Atom &lazyPointer)
+ X86StubAtom(const File &file, const Atom &lazyPointer)
: SimpleDefinedAtom(file) {
this->addReference(KindHandler_x86::abs32, 2, &lazyPointer, 0);
}
@@ -44,14 +44,14 @@ public:
virtual ContentPermissions permissions() const {
return DefinedAtom::permR_X;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
- static const uint8_t instructions[] =
+ static const uint8_t instructions[] =
{ 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00 }; // jmp *lazyPointer
assert(sizeof(instructions) == this->size());
return ArrayRef<uint8_t>(instructions, sizeof(instructions));
}
-
+
};
@@ -66,65 +66,65 @@ public:
this->addReference(KindHandler_x86::abs32, 1, &cache, 0);
this->addReference(KindHandler_x86::abs32, 7, &binder, 0);
}
-
+
virtual ContentType contentType() const {
return DefinedAtom::typeStubHelper;
}
-
+
virtual uint64_t size() const {
return 12;
}
-
+
virtual ContentPermissions permissions() const {
return DefinedAtom::permR_X;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
- static const uint8_t instructions[] =
+ static const uint8_t instructions[] =
{ 0x68, 0x00, 0x00, 0x00, 0x00, // pushl $dyld_ImageLoaderCache
0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, // jmp *_fast_lazy_bind
0x90 }; // nop
assert(sizeof(instructions) == this->size());
return ArrayRef<uint8_t>(instructions, sizeof(instructions));
}
-
+
};
-
-
+
+
//
// X86 Stub Helper Atom created by the stubs pass.
//
class X86StubHelperAtom : public SimpleDefinedAtom {
public:
- X86StubHelperAtom(const File &file, const Atom &helperCommon)
+ X86StubHelperAtom(const File &file, const Atom &helperCommon)
: SimpleDefinedAtom(file) {
- this->addReference(KindHandler_x86::lazyImmediate, 1, nullptr, 0);
+ this->addReference(KindHandler_x86::lazyImmediate, 1, this, 0);
this->addReference(KindHandler_x86::branch32, 6, &helperCommon, 0);
}
-
+
virtual ContentType contentType() const {
return DefinedAtom::typeStubHelper;
}
-
+
virtual uint64_t size() const {
return 10;
}
-
+
virtual ContentPermissions permissions() const {
return DefinedAtom::permR_X;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
- static const uint8_t instructions[] =
+ static const uint8_t instructions[] =
{ 0x68, 0x00, 0x00, 0x00, 0x00, // pushq $lazy-info-offset
0xE9, 0x00, 0x00, 0x00, 0x00 }; // jmp helperhelper
assert(sizeof(instructions) == this->size());
return ArrayRef<uint8_t>(instructions, sizeof(instructions));
}
-
+
};
-
+
//
// X86 Lazy Pointer Atom created by the stubs pass.
@@ -149,12 +149,12 @@ public:
virtual ContentPermissions permissions() const {
return DefinedAtom::permRW_;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
static const uint8_t bytes[] = { 0x00, 0x00, 0x00, 0x00 };
return ArrayRef<uint8_t>(bytes, 4);
}
-
+
};
@@ -166,35 +166,35 @@ public:
X86NonLazyPointerAtom(const File &file)
: SimpleDefinedAtom(file) {
}
-
+
X86NonLazyPointerAtom(const File &file, const Atom &shlib)
: SimpleDefinedAtom(file) {
this->addReference(KindHandler_x86::pointer32, 0, &shlib, 0);
}
-
+
virtual ContentType contentType() const {
return DefinedAtom::typeGOT;
}
-
+
virtual uint64_t size() const {
return 4;
}
-
+
virtual ContentPermissions permissions() const {
return DefinedAtom::permRW_;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
static const uint8_t bytes[] = { 0x00, 0x00, 0x00, 0x0 };
return ArrayRef<uint8_t>(bytes, 4);
}
-
+
};
-} // namespace mach_o
-} // namespace lld
+} // namespace mach_o
+} // namespace lld
#endif // LLD_READER_WRITER_MACHO_STUB_ATOM_X86_H_
Modified: lld/trunk/lib/ReaderWriter/MachO/StubAtoms_x86_64.hpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/StubAtoms_x86_64.hpp?rev=193476&r1=193475&r2=193476&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/StubAtoms_x86_64.hpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/StubAtoms_x86_64.hpp Sat Oct 26 14:38:26 2013
@@ -28,7 +28,7 @@ namespace mach_o {
//
class X86_64StubAtom : public SimpleDefinedAtom {
public:
- X86_64StubAtom(const File &file, const Atom &lazyPointer)
+ X86_64StubAtom(const File &file, const Atom &lazyPointer)
: SimpleDefinedAtom(file) {
this->addReference(KindHandler_x86_64::ripRel32, 2, &lazyPointer, 0);
}
@@ -44,14 +44,14 @@ public:
virtual ContentPermissions permissions() const {
return DefinedAtom::permR_X;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
- static const uint8_t instructions[] =
+ static const uint8_t instructions[] =
{ 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00 }; // jmp *lazyPointer
assert(sizeof(instructions) == this->size());
return ArrayRef<uint8_t>(instructions, sizeof(instructions));
}
-
+
};
@@ -66,21 +66,21 @@ public:
this->addReference(KindHandler_x86_64::ripRel32, 3, &cache, 0);
this->addReference(KindHandler_x86_64::ripRel32, 11, &binder, 0);
}
-
+
virtual ContentType contentType() const {
return DefinedAtom::typeStubHelper;
}
-
+
virtual uint64_t size() const {
return 16;
}
-
+
virtual ContentPermissions permissions() const {
return DefinedAtom::permR_X;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
- static const uint8_t instructions[] =
+ static const uint8_t instructions[] =
{ 0x4C, 0x8D, 0x1D, 0x00, 0x00, 0x00, 0x00, // leaq cache(%rip),%r11
0x41, 0x53, // push %r11
0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, // jmp *binder(%rip)
@@ -88,44 +88,44 @@ public:
assert(sizeof(instructions) == this->size());
return ArrayRef<uint8_t>(instructions, sizeof(instructions));
}
-
+
};
-
-
+
+
//
// X86_64 Stub Helper Atom created by the stubs pass.
//
class X86_64StubHelperAtom : public SimpleDefinedAtom {
public:
- X86_64StubHelperAtom(const File &file, const Atom &helperCommon)
+ X86_64StubHelperAtom(const File &file, const Atom &helperCommon)
: SimpleDefinedAtom(file) {
- this->addReference(KindHandler_x86_64::lazyImmediate, 1, nullptr, 0);
+ this->addReference(KindHandler_x86_64::lazyImmediate, 1, this, 0);
this->addReference(KindHandler_x86_64::ripRel32, 6, &helperCommon, 0);
}
-
+
virtual ContentType contentType() const {
return DefinedAtom::typeStubHelper;
}
-
+
virtual uint64_t size() const {
return 10;
}
-
+
virtual ContentPermissions permissions() const {
return DefinedAtom::permR_X;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
- static const uint8_t instructions[] =
+ static const uint8_t instructions[] =
{ 0x68, 0x00, 0x00, 0x00, 0x00, // pushq $lazy-info-offset
0xE9, 0x00, 0x00, 0x00, 0x00 }; // jmp helperhelper
assert(sizeof(instructions) == this->size());
return ArrayRef<uint8_t>(instructions, sizeof(instructions));
}
-
+
};
-
+
//
// X86_64 Lazy Pointer Atom created by the stubs pass.
@@ -150,13 +150,13 @@ public:
virtual ContentPermissions permissions() const {
return DefinedAtom::permRW_;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
- static const uint8_t bytes[] =
+ static const uint8_t bytes[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
return ArrayRef<uint8_t>(bytes, 8);
}
-
+
};
@@ -168,36 +168,36 @@ public:
X86_64NonLazyPointerAtom(const File &file)
: SimpleDefinedAtom(file) {
}
-
+
X86_64NonLazyPointerAtom(const File &file, const Atom &shlib)
: SimpleDefinedAtom(file) {
this->addReference(KindHandler_x86_64::pointer64, 0, &shlib, 0);
}
-
+
virtual ContentType contentType() const {
return DefinedAtom::typeGOT;
}
-
+
virtual uint64_t size() const {
return 8;
}
-
+
virtual ContentPermissions permissions() const {
return DefinedAtom::permRW_;
}
-
+
virtual ArrayRef<uint8_t> rawContent() const {
- static const uint8_t bytes[] =
+ static const uint8_t bytes[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
return ArrayRef<uint8_t>(bytes, 8);
}
-
+
};
-} // namespace mach_o
-} // namespace lld
+} // namespace mach_o
+} // namespace lld
#endif // LLD_READER_WRITER_MACHO_STUB_ATOM_X86_64_H_
More information about the llvm-commits
mailing list