Add RPATH to linker_interceptor.py (#61)
* Add check for __LIBAFL_QEMU_CONFIGURE in configure script. * Use regex in linker_interceptor.py to detect shared libraries * Add a rpath section to linkinfo.json * Update configure
This commit is contained in:
parent
50b0c90e0a
commit
c9519ee8b6
9
configure
vendored
9
configure
vendored
@ -1742,6 +1742,15 @@ if test "$tcg" = "enabled"; then
|
|||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#### --- Begin LibAFL code ---
|
||||||
|
|
||||||
|
# Remove LibAFL config signature if building manually
|
||||||
|
if [ -z ${__LIBAFL_QEMU_CONFIGURE+x} ]; then
|
||||||
|
rm -f libafl_config
|
||||||
|
fi
|
||||||
|
|
||||||
|
#### --- End LibAFL code ---
|
||||||
|
|
||||||
if test "$skip_meson" = no; then
|
if test "$skip_meson" = no; then
|
||||||
cross="config-meson.cross.new"
|
cross="config-meson.cross.new"
|
||||||
meson_quote() {
|
meson_quote() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import subprocess, shutil, json, sys, os
|
import subprocess, shutil, json, sys, os, re
|
||||||
|
|
||||||
FILTER = ['-shared']
|
FILTER = ['-shared']
|
||||||
|
|
||||||
@ -18,8 +18,14 @@ else:
|
|||||||
out_args = []
|
out_args = []
|
||||||
shareds = []
|
shareds = []
|
||||||
search = []
|
search = []
|
||||||
|
rpath = []
|
||||||
|
|
||||||
is_linking_qemu = False
|
is_linking_qemu = False
|
||||||
|
|
||||||
|
shared_library_pattern = r"^[^-].*/lib(.*)\.so(\.[0-9].*)?(?!rsp)$"
|
||||||
|
rpath_pattern = r"^'.*,-rpath,(.*)'$"
|
||||||
|
rpath_link_pattern = r"^.*,-rpath-link,(.*)$"
|
||||||
|
|
||||||
def process_args(args):
|
def process_args(args):
|
||||||
global out_args, shareds, search, is_linking_qemu
|
global out_args, shareds, search, is_linking_qemu
|
||||||
prev_o = False
|
prev_o = False
|
||||||
@ -32,10 +38,18 @@ def process_args(args):
|
|||||||
continue
|
continue
|
||||||
elif args[i] in FILTER:
|
elif args[i] in FILTER:
|
||||||
continue
|
continue
|
||||||
elif args[i].endswith('.so') and not args[i].startswith('-'):
|
elif (res := re.match(shared_library_pattern, args[i])) is not None:
|
||||||
name = os.path.basename(args[i])[3:-3] # remove prefix and suffix
|
name = res.group(1)
|
||||||
shareds.append(name)
|
shareds.append(name)
|
||||||
continue
|
continue
|
||||||
|
elif (res := re.match(rpath_link_pattern, args[i])) is not None:
|
||||||
|
rpath_link_path = res.group(1)
|
||||||
|
search.append(rpath_link_path)
|
||||||
|
continue
|
||||||
|
elif (res := re.match(rpath_pattern, args[i])) is not None:
|
||||||
|
rpath_path = res.group(1)
|
||||||
|
rpath.append(rpath_path)
|
||||||
|
continue
|
||||||
elif args[i] == '-o':
|
elif args[i] == '-o':
|
||||||
prev_o = True
|
prev_o = True
|
||||||
continue
|
continue
|
||||||
@ -57,9 +71,10 @@ process_args(args)
|
|||||||
if is_linking_qemu:
|
if is_linking_qemu:
|
||||||
with open(OUT, 'w') as f:
|
with open(OUT, 'w') as f:
|
||||||
json.dump({
|
json.dump({
|
||||||
'cmd': out_args,
|
'cmd': out_args,
|
||||||
'libs': shareds,
|
'libs': shareds,
|
||||||
'search': search,
|
'search': search,
|
||||||
|
'rpath': rpath,
|
||||||
}, f, indent=2)
|
}, f, indent=2)
|
||||||
|
|
||||||
r = subprocess.run([cc] + args)
|
r = subprocess.run([cc] + args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user