34 lines · plain
1# RUN: rm -rf %t && mkdir -p %t && cd %t2# RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o a.obj %S/Inputs/a.s3# RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o b.obj %S/Inputs/b.s4# RUN: llvm-lib /out:xfghashmap.lib b.obj a.obj5 6## Replace a section in the library file with /<XFGHASHMAP>/ emulating7## 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 %s12 13# CHECK: /<XFGHASHMAP>/14# CHECK-NOT: b.obj15# CHECK: a.obj16 17import sys18 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 = None27with 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