Update linker_interceptor.py
This commit is contained in:
parent
fa42ed1dd2
commit
26c850174f
1
linker_interceptor++.py
Symbolic link
1
linker_interceptor++.py
Symbolic link
@ -0,0 +1 @@
|
||||
linker_interceptor.py
|
@ -4,17 +4,24 @@ import subprocess, shutil, json, sys, os
|
||||
|
||||
FILTER = ['-shared']
|
||||
|
||||
CC = os.getenv('__LIBAFL_QEMU_BUILD_CC') or 'cc'
|
||||
CXX = os.getenv('__LIBAFL_QEMU_BUILD_CXX') or 'c++'
|
||||
OUT = os.getenv('__LIBAFL_QEMU_BUILD_OUT') or 'linkinfo.json'
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
if '++' in sys.argv[0]:
|
||||
cc = CXX
|
||||
else:
|
||||
cc = CC
|
||||
|
||||
out_args = []
|
||||
shareds = []
|
||||
search = []
|
||||
islinking = False
|
||||
|
||||
def process_args(args):
|
||||
global out_args, shareds, search
|
||||
global out_args, shareds, search, islinking
|
||||
prev_o = False
|
||||
|
||||
for i in range(len(args)):
|
||||
@ -22,6 +29,7 @@ def process_args(args):
|
||||
prev_o = False
|
||||
continue
|
||||
elif args[i] in FILTER:
|
||||
islinking = True
|
||||
continue
|
||||
elif args[i].endswith('.so') and not args[i].startswith('-'):
|
||||
name = os.path.basename(args[i])[3:-3] # remove prefix and suffix
|
||||
@ -45,11 +53,12 @@ def process_args(args):
|
||||
|
||||
process_args(args)
|
||||
|
||||
with open(OUT, 'w') as f:
|
||||
json.dump({
|
||||
'cmd': out_args,
|
||||
'libs': shareds,
|
||||
'search': search,
|
||||
}, f, indent=2)
|
||||
if islinking:
|
||||
with open(OUT, 'w') as f:
|
||||
json.dump({
|
||||
'cmd': out_args,
|
||||
'libs': shareds,
|
||||
'search': search,
|
||||
}, f, indent=2)
|
||||
|
||||
subprocess.run([CXX] + args)
|
||||
subprocess.run([cc] + args)
|
||||
|
Loading…
x
Reference in New Issue
Block a user