Forcing function section alignment at the compiler level ensures that enough
space is present in the text section so that at least a jump can be encoded in
the old function body to switch to the newly loaded code payload.
Modify create-diff-object to account for any section alignment when calculating
the size of the old function.
When used with a suitable -falign-function compiler parameter on the Xen
hypervisor build this ensures that all functions have enough space to
accommodate for any control flow instructions plus a jump.
Note that while the rounding could be applied to all (text) symbols, it's not
required, as the size is only relevant for functions that are live patched, and
hence only do the rounding when calculating the old (previous) function size.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
list_add_tail(&(_new)->list, (_list)); \
}
+#define ROUNDUP(x, a) (((x) + (a) - 1) & ~((a) - 1))
+
enum loglevel {
DEBUG,
NORMAL
ERROR("lookup_global_symbol %s",
sym->name);
}
+
+ /* Take into account section alignment for padding. */
+ result.size = ROUNDUP(result.size,
+ sym->sec->sh.sh_addralign);
+
log_debug("lookup for %s @ 0x%016lx len %lu\n",
sym->name, result.value, result.size);