[PATCH] D120645: [Object] Skip section offset checking for /<XFGHASHMAP>/
Pavel Samolysov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 1 04:02:30 PST 2022
psamolysov-intel updated this revision to Diff 412043.
psamolysov-intel added a comment.
@jhenderson thank you for the review. I'm not an English native speaker, so some grammar may be bad, sorry. I've put the python script into the test itself as you suggested and added a few comments why this script is used at all.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120645/new/
https://reviews.llvm.org/D120645
Files:
llvm/lib/Object/Archive.cpp
llvm/test/tools/llvm-lib/xfghashmap-list.test
Index: llvm/test/tools/llvm-lib/xfghashmap-list.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-lib/xfghashmap-list.test
@@ -0,0 +1,33 @@
+# RUN: rm -rf %t && mkdir -p %t && cd %t
+# RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o a.obj %S/Inputs/a.s
+# RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o b.obj %S/Inputs/b.s
+# RUN: llvm-lib /out:xfghashmap.lib a.obj b.obj
+
+## Replace a section in the library file with /<XFGHASHMAP>/ emulating
+## a library from the Windows SDK for Windows 11.
+# RUN: %python %s xfghashmap.lib b.obj/
+
+## This should print the /<XFGHASHMAP>/ section as well as an .obj one.
+# RUN: llvm-lib /list %t/xfghashmap.lib | FileCheck %s
+
+# CHECK: a.obj
+# CHECK: /<XFGHASHMAP>/
+# CHECK-NOT: b.obj
+
+import sys
+
+if len(sys.argv) < 3:
+ print("Use: python3 xfghashmap-list.test <LIBRARY_FILE> <TEMPLATE>")
+ exit(1)
+
+template = bytes(sys.argv[2], 'utf-8')
+xfghashmap = bytes("/<XFGHASHMAP>/", 'utf-8')
+
+data = None
+with open(sys.argv[1], "rb") as inp:
+ data = inp.read()
+with open(sys.argv[1], "wb") as outp:
+ pos = data.find(template)
+ outp.write(data[:pos])
+ outp.write(xfghashmap)
+ outp.write(data[pos + len(xfghashmap):])
Index: llvm/lib/Object/Archive.cpp
===================================================================
--- llvm/lib/Object/Archive.cpp
+++ llvm/lib/Object/Archive.cpp
@@ -256,6 +256,10 @@
return Name;
if (Name.size() == 2 && Name[1] == '/') // String table.
return Name;
+ // System libraries from the Windows SDK for Window 11 contain this symbol.
+ // It looks like a CFG guard, we just skip it for now.
+ if (Name.equals("/<XFGHASHMAP>/"))
+ 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.412043.patch
Type: text/x-patch
Size: 1855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220301/bec4ab4a/attachment.bin>
More information about the llvm-commits
mailing list