static void xsplice_create_patches_sections(struct xsplice_elf *kelf,
struct lookup_table *table,
- char *hint)
+ char *hint, int resolve)
{
int nr, index;
struct section *sec, *relasec;
ERROR("%s too small to patch", sym->name);
/* add entry in text section */
- funcs[index].old_addr = result.value;
+ if (resolve)
+ funcs[index].old_addr = result.value;
+ else
+ /* This will be filled in at module load time */
+ funcs[index].old_addr = 0;
funcs[index].old_size = result.size;
funcs[index].new_addr = 0;
funcs[index].new_size = sym->sym.st_size;
struct arguments {
char *args[4];
int debug;
+ int resolve;
};
static char args_doc[] = "original.o patched.o kernel-object output.o";
static struct argp_option options[] = {
{"debug", 'd', 0, 0, "Show debug output" },
+ {"resolve", 'r', 0, 0, "Resolve to-be-patched function addresses" },
{ 0 }
};
case 'd':
arguments->debug = 1;
break;
+ case 'r':
+ arguments->resolve = 1;
+ break;
case ARGP_KEY_ARG:
if (state->arg_num >= 4)
/* Too many arguments. */
char *hint = NULL;
arguments.debug = 0;
+ arguments.resolve = 0;
argp_parse (&argp, argc, argv, 0, 0, &arguments);
if (arguments.debug)
loglevel = DEBUG;
log_debug("Create strings elements\n");
xsplice_create_strings_elements(kelf_out);
log_debug("Create patches sections\n");
- xsplice_create_patches_sections(kelf_out, lookup, hint);
+ xsplice_create_patches_sections(kelf_out, lookup, hint,
+ arguments.resolve);
xsplice_build_strings_section_data(kelf_out);
/*
XEN_DEBUG=n
SKIP=
DEPENDS=
+PRELINK=
XENSYMS=xen-syms
warn() {
mkdir -p "output/$(dirname $i)" || die
echo "Processing ${i}"
echo "Run create-diff-object on $i" >> "${OUTPUT}/create-diff-object.log"
- "${SCRIPTDIR}"/create-diff-object $debugopt "original/$i" "patched/$i" "$XENSYMS" "output/$i" &>> "${OUTPUT}/create-diff-object.log"
+ "${SCRIPTDIR}"/create-diff-object $debugopt $PRELINK "original/$i" "patched/$i" "$XENSYMS" "output/$i" &>> "${OUTPUT}/create-diff-object.log"
rc="${PIPESTATUS[0]}"
if [[ $rc = 139 ]]; then
warn "create-diff-object SIGSEGV"
fi
echo "Creating patch module..."
- ld -r -o output.o --build-id=sha1 $(find output -type f -name "*.o") || die
- "${SCRIPTDIR}"/prelink $debugopt output.o "${PATCHNAME}.xsplice" "$XENSYMS" &>> "${OUTPUT}/prelink.log" || die
+ if [ -z "$PRELINK" ]; then
+ ld -r -o "${PATCHNAME}.xsplice" --build-id=sha1 $(find output -type f -name "*.o") || die
+ chmod +x "${PATCHNAME}.xsplice"
+ else
+ ld -r -o output.o --build-id=sha1 $(find output -type f -name "*.o") || die
+ "${SCRIPTDIR}"/prelink $debugopt output.o "${PATCHNAME}.xsplice" "$XENSYMS" &>> "${OUTPUT}/prelink.log" || die
+ fi
objcopy --add-section .xsplice.depends=depends.bin "${PATCHNAME}.xsplice"
objcopy --set-section-flags .xsplice.depends=alloc,readonly "${PATCHNAME}.xsplice"
echo " --xen-debug Build debug Xen" >&2
echo " --xen-syms Build against a xen-syms" >&2
echo " --depends Required build-id" >&2
+ echo " --prelink Prelink" >&2
}
-options=$(getopt -o hs:p:o:j:k:d -l "help,srcdir:patch:output:cpus:,skip:,debug,xen-debug,xen-syms:,depends:" -- "$@") || die "getopt failed"
+options=$(getopt -o hs:p:o:j:k:d -l "help,srcdir:patch:output:cpus:,skip:,debug,xen-debug,xen-syms:,depends:,prelink" -- "$@") || die "getopt failed"
eval set -- "$options"
DEPENDS="$1"
shift
;;
+ --prelink)
+ PRELINK=--resolve
+ shift
+ ;;
--)
shift
break