Add linker interceptor script
This commit is contained in:
parent
7dd994beba
commit
2d5fcb7b66
34
linker_interceptor.py
Executable file
34
linker_interceptor.py
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import subprocess, json, sys, os
|
||||||
|
|
||||||
|
FILTER = ['-shared']
|
||||||
|
|
||||||
|
CXX = os.getenv('__LIBAFL_QEMU_BUILD_CXX') or 'c++'
|
||||||
|
OUT = os.getenv('__LIBAFL_QEMU_BUILD_OUT') or 'linkinfo.json'
|
||||||
|
|
||||||
|
args = sys.argv[1:]
|
||||||
|
|
||||||
|
out_args = []
|
||||||
|
shareds = []
|
||||||
|
prev_o = False
|
||||||
|
for i in range(len(args)):
|
||||||
|
if prev_o:
|
||||||
|
prev_o = False
|
||||||
|
continue
|
||||||
|
elif args[i] in FILTER:
|
||||||
|
continue
|
||||||
|
elif args[i].endswith('.so') and not args[i].startswith('-'):
|
||||||
|
shareds.append(args[i])
|
||||||
|
continue
|
||||||
|
elif args[i] == '-o':
|
||||||
|
prev_o = True
|
||||||
|
continue
|
||||||
|
elif args[i].startswith('-L') or args[i].startswith('-l'):
|
||||||
|
shareds.append(args[i])
|
||||||
|
out_args.append(args[i])
|
||||||
|
|
||||||
|
with open(OUT, 'w') as f:
|
||||||
|
json.dump({'cmd': out_args, 'so': shareds}, f, indent=2)
|
||||||
|
|
||||||
|
subprocess.run([CXX] + args)
|
Loading…
x
Reference in New Issue
Block a user