[PATCH] D120645: [Object] Skip section offset checking for /<XFGHASHMAP>/

Pavel Samolysov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 28 00:07:52 PST 2022


psamolysov-intel created this revision.
psamolysov-intel added reviewers: jhenderson, kazu.
psamolysov-intel created this object with edit policy "Administrators".
psamolysov-intel added a project: LLVM.
Herald added a subscriber: hiraditya.
psamolysov-intel requested review of this revision.
Herald added a subscriber: llvm-commits.

Starting from Windows SDK for Windows 11 (10.0.22000.x), all the system
libraries (.lib files) contain a section with the '/<XFGHASHMAP>/' name.
This looks like the libraries are built with control flow guard enabled:
https://docs.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard?view=msvc-170

      

To let the LLVM tools (llvm-ar, llvm-lib) work with these libraries,
this patch just skips the section offset check for sections with the
'/<XFGHASHMAP>/' name.

      

Closes: llvm/llvm-project#53814

      

Signed-off-by: Pavel Samolysov <pavel.samolysov at intel.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120645

Files:
  llvm/lib/Object/Archive.cpp


Index: llvm/lib/Object/Archive.cpp
===================================================================
--- llvm/lib/Object/Archive.cpp
+++ llvm/lib/Object/Archive.cpp
@@ -157,13 +157,13 @@
     EndCond = ' ';
   else
     EndCond = '/';
-  StringRef::size_type end =
+  StringRef::size_type End =
       StringRef(ArMemHdr->Name, sizeof(ArMemHdr->Name)).find(EndCond);
-  if (end == StringRef::npos)
-    end = sizeof(ArMemHdr->Name);
-  assert(end <= sizeof(ArMemHdr->Name) && end > 0);
+  if (End == StringRef::npos)
+    End = sizeof(ArMemHdr->Name);
+  assert(End <= sizeof(ArMemHdr->Name) && End > 0);
   // Don't include the EndCond if there is one.
-  return StringRef(ArMemHdr->Name, end);
+  return StringRef(ArMemHdr->Name, End);
 }
 
 Expected<uint64_t>
@@ -256,6 +256,8 @@
       return Name;
     if (Name.size() == 2 && Name[1] == '/') // String table.
       return Name;
+    if (Name.equals("/<XFGHASHMAP>/")) // names in Windows SDK for Windows 11
+      return Name;
     // It's a long name.
     // Get the string table offset.
     std::size_t StringOffset;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120645.411742.patch
Type: text/x-patch
Size: 1080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220228/6732568c/attachment.bin>


More information about the llvm-commits mailing list