[PATCH] D51343: Fix RuntimeDyldCOFFX86_64 handling of image-relative relocations when there are not loaded sections

Andrew Scheidecker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 28 04:26:03 PDT 2018


AndrewScheidecker created this revision.
AndrewScheidecker added reviewers: marsupial, lhames, martell, compnerd.

I'm not sure if this is the correct fix, but it does make it work for my use.

Without this change, I get some message in stderr about "IMAGE_REL_AMD64_ADDR32NB relocation requires anordered section layout", and I have to rely on my old workaround for IMAGE_REL_AMD64_ADDR32NB.

With this change, the IMAGE_REL_AMD64_ADDR32NB relocations seem to work correctly.

If I print the sections that have a load address of 0, sometimes it's a zero-sized .data or .bss, but usually it's debug sections that aren't loaded with ProcessAllSections=false.


Repository:
  rL LLVM

https://reviews.llvm.org/D51343

Files:
  lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h


Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
===================================================================
--- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
+++ lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
@@ -37,7 +37,8 @@
     if (!ImageBase) {
       ImageBase = std::numeric_limits<uint64_t>::max();
       for (const SectionEntry &Section : Sections)
-        ImageBase = std::min(ImageBase, Section.getLoadAddress());
+        if (Section.getLoadAddress() != 0)
+          ImageBase = std::min(ImageBase, Section.getLoadAddress());
     }
     return ImageBase;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51343.162825.patch
Type: text/x-patch
Size: 642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180828/ecaf984b/attachment.bin>


More information about the llvm-commits mailing list