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