xref: /llvm-project/llvm/test/tools/llvm-lib/xfghashmap-list.test (revision 350c89fa75a089060baea83a7ed88ed360f6e918)
1# RUN: rm -rf %t && mkdir -p %t && cd %t
2# RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o a.obj %S/Inputs/a.s
3# RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o b.obj %S/Inputs/b.s
4# RUN: llvm-lib /out:xfghashmap.lib b.obj a.obj
5
6## Replace a section in the library file with /<XFGHASHMAP>/ emulating
7## a library from the Windows SDK for Windows 11.
8# RUN: %python %s xfghashmap.lib b.obj/
9
10## This should print the /<XFGHASHMAP>/ section as well as an .obj one.
11# RUN: llvm-lib /list %t/xfghashmap.lib | FileCheck %s
12
13# CHECK: /<XFGHASHMAP>/
14# CHECK-NOT: b.obj
15# CHECK: a.obj
16
17import sys
18
19if len(sys.argv) < 3:
20  print("Use: python3 xfghashmap-list.test <LIBRARY_FILE> <TEMPLATE>")
21  exit(1)
22
23template = bytes(sys.argv[2], 'utf-8')
24xfghashmap = b'/<XFGHASHMAP>/'
25
26data = None
27with open(sys.argv[1], "rb") as inp:
28  data = inp.read()
29with open(sys.argv[1], "wb") as outp:
30  pos = data.find(template)
31  outp.write(data[:pos])
32  outp.write(xfghashmap)
33  outp.write(data[pos + len(xfghashmap):])
34