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
|
||||
)
|
||||
|
||||
#### --- 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
|
||||
cross="config-meson.cross.new"
|
||||
meson_quote() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess, shutil, json, sys, os
|
||||
import subprocess, shutil, json, sys, os, re
|
||||
|
||||
FILTER = ['-shared']
|
||||
|
||||
@ -18,8 +18,14 @@ else:
|
||||
out_args = []
|
||||
shareds = []
|
||||
search = []
|
||||
rpath = []
|
||||
|
||||
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):
|
||||
global out_args, shareds, search, is_linking_qemu
|
||||
prev_o = False
|
||||
@ -32,10 +38,18 @@ def process_args(args):
|
||||
continue
|
||||
elif args[i] in FILTER:
|
||||
continue
|
||||
elif args[i].endswith('.so') and not args[i].startswith('-'):
|
||||
name = os.path.basename(args[i])[3:-3] # remove prefix and suffix
|
||||
elif (res := re.match(shared_library_pattern, args[i])) is not None:
|
||||
name = res.group(1)
|
||||
shareds.append(name)
|
||||
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':
|
||||
prev_o = True
|
||||
continue
|
||||
@ -60,6 +74,7 @@ if is_linking_qemu:
|
||||
'cmd': out_args,
|
||||
'libs': shareds,
|
||||
'search': search,
|
||||
'rpath': rpath,
|
||||
}, f, indent=2)
|
||||
|
||||
r = subprocess.run([cc] + args)
|
||||
|
Loading…
x
Reference in New Issue
Block a user