[llvm] 88d8f12 - [Orc] Filter sections for debug load-address patching upfront

Stefan Gränitz via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 31 01:35:05 PDT 2023


Author: Stefan Gränitz
Date: 2023-03-31T10:34:05+02:00
New Revision: 88d8f127ce4bc532df91532bded1505ff274ce9d

URL: https://github.com/llvm/llvm-project/commit/88d8f127ce4bc532df91532bded1505ff274ce9d
DIFF: https://github.com/llvm/llvm-project/commit/88d8f127ce4bc532df91532bded1505ff274ce9d.diff

LOG: [Orc] Filter sections for debug load-address patching upfront

Originally, the DebugObjectManagerPlugin recorded all sections and filtered some of them for load-address patching.
Then we spotted problems with duplicate section names and started additional filtering upfront (see b26f45e5a49ae363164e7dbbf57eadd9e78d612c).
This seems the better approach. Let's go for it and stop filtering in two locations.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp
index 922c60bb5a8c..b2c4c27ce2aa 100644
--- a/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp
@@ -66,20 +66,9 @@ class ELFDebugObjectSection : public DebugObjectSection {
 
 template <typename ELFT>
 void ELFDebugObjectSection<ELFT>::setTargetMemoryRange(SectionRange Range) {
-  // Only patch load-addresses for executable and data sections.
-  if (isTextOrDataSection())
-    Header->sh_addr =
-        static_cast<typename ELFT::uint>(Range.getStart().getValue());
-}
-
-template <typename ELFT>
-bool ELFDebugObjectSection<ELFT>::isTextOrDataSection() const {
-  switch (Header->sh_type) {
-  case ELF::SHT_PROGBITS:
-  case ELF::SHT_X86_64_UNWIND:
-    return Header->sh_flags & (ELF::SHF_EXECINSTR | ELF::SHF_ALLOC);
-  }
-  return false;
+  // All recorded sections are candidates for load-address patching.
+  Header->sh_addr =
+      static_cast<typename ELFT::uint>(Range.getStart().getValue());
 }
 
 template <typename ELFT>
@@ -289,6 +278,10 @@ ELFDebugObject::CreateArchType(MemoryBufferRef Buffer,
       continue;
     HasDwarfSection |= isDwarfSection(*Name);
 
+    // Only record text and data sections (i.e. no bss, comments, rel, etc.)
+    if (Header.sh_type != ELF::SHT_PROGBITS &&
+        Header.sh_type != ELF::SHT_X86_64_UNWIND)
+      continue;
     if (!(Header.sh_flags & ELF::SHF_ALLOC))
       continue;
 


        


More information about the llvm-commits mailing list