[llvm-commits] [PATCH] [lld][ELF] Add very basic support for IFUNC.

Michael Spencer bigcheesegs at gmail.com
Thu Jan 24 03:10:30 PST 2013


  I can actually make this generic now that we have TargetHandler.


================
Comment at: lib/ReaderWriter/ELF/ELFTargetInfo.cpp:65-66
@@ -58,1 +64,4 @@
 
+class GOTAtom : public SimpleDefinedAtom {
+  static const uint8_t _defaultContent[8];
+
----------------
Shankar Kalpathi Easwaran wrote:
> shouldnt this be a ELFDefinedAtom ?
Why? The Writer is only going to see it as a DefinedAtom.

================
Comment at: lib/ReaderWriter/ELF/ELFTargetInfo.cpp:70-71
@@ +69,4 @@
+  GOTAtom(const File &f, const DefinedAtom *target) : SimpleDefinedAtom(f) {
+    if (target->contentType() == DefinedAtom::typeResolver)
+      addReference(llvm::ELF::R_X86_64_IRELATIVE, 0, target, 0);
+  }
----------------
Shankar Kalpathi Easwaran wrote:
> These references are tied to X86_64 and they shouldnt be in generic GOTAtom
> 
This isn't generic yet.

================
Comment at: lib/ReaderWriter/ELF/ELFTargetInfo.cpp:74-83
@@ +73,12 @@
+
+  virtual ContentType contentType() const {
+    return DefinedAtom::typeGOT;
+  }
+
+  virtual uint64_t size() const {
+    return rawContent().size();
+  }
+
+  virtual ContentPermissions permissions() const {
+    return DefinedAtom::permRW_;
+  }
----------------
Shankar Kalpathi Easwaran wrote:
> you need to have a sectionName too
It already has typeGOT, the writer should assign a section name.

================
Comment at: lib/ReaderWriter/ELF/ELFTargetInfo.cpp:94
@@ +93,3 @@
+class PLTAtom : public SimpleDefinedAtom {
+  static const uint8_t _defaultContent[16];
+
----------------
Shankar Kalpathi Easwaran wrote:
> why static, cant it be part of a instance variable ?
It doesn't need to be yet, I'd like to keep memory usage down.

================
Comment at: lib/ReaderWriter/ELF/ELFTargetInfo.cpp:118-122
@@ +117,7 @@
+
+const uint8_t PLTAtom::_defaultContent[16] = {
+    0xff, 0x25, 0x00, 0x00, 0x00, 0x00, // jmpq *gotatom(%rip)
+    0x68, 0x00, 0x00, 0x00, 0x00,       // pushq pltentry
+    0xe9, 0x00, 0x00, 0x00, 0x00        // jmpq plt[-1]
+  };
+
----------------
Shankar Kalpathi Easwaran wrote:
> again, platform specific.
This isn't generic yet.

================
Comment at: lib/ReaderWriter/ELF/ELFTargetInfo.cpp:138-139
@@ +137,4 @@
+      for (const auto &ref : *atom) {
+        if (ref->kind() != llvm::ELF::R_X86_64_PC32)
+          continue;
+        if (const DefinedAtom *da = dyn_cast<const DefinedAtom>(ref->target())){
----------------
Shankar Kalpathi Easwaran wrote:
> specific to X86_64.
This isn't generic yet.


http://llvm-reviews.chandlerc.com/D324



More information about the llvm-commits mailing list