aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-05-28 09:27:40 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-05-28 09:27:40 +0100
commit36cfb6aa84c1b5a5b5ac15883e34b10f32ab0ab8 (patch)
treef6eb1345d9d81843e0213b31d30f672895d8fdac /tools
parent96830282274a9f6a7aafd506976a3639b6f80836 (diff)
downloadxen-36cfb6aa84c1b5a5b5ac15883e34b10f32ab0ab8.tar.gz
xen-36cfb6aa84c1b5a5b5ac15883e34b10f32ab0ab8.tar.bz2
xen-36cfb6aa84c1b5a5b5ac15883e34b10f32ab0ab8.zip
libelf: Tidy up logging and remove dependency on stdio.
libelf now permits callers to specify logging callback functions, rather than a FILE*. libelf's non-Xen callers are all libxc users, so the stdio dependency and the default logging callback function (which calls vfprintf) is now in libxc. Xen's use of libxc is unaffected in this patch. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/libxc/xc_dom_elfloader.c17
-rw-r--r--tools/libxc/xenctrl.h5
-rw-r--r--tools/xcutils/readnotes.c2
3 files changed, 21 insertions, 3 deletions
diff --git a/tools/libxc/xc_dom_elfloader.c b/tools/libxc/xc_dom_elfloader.c
index f9bbd85ba3..280f722d30 100644
--- a/tools/libxc/xc_dom_elfloader.c
+++ b/tools/libxc/xc_dom_elfloader.c
@@ -9,6 +9,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <inttypes.h>
#include "xg_private.h"
@@ -18,6 +19,17 @@
/* ------------------------------------------------------------------------ */
+static void log_callback(struct elf_binary *elf, void *caller_data,
+ int iserr, const char *fmt, va_list al) {
+ vfprintf(caller_data,fmt,al);
+}
+
+void xc_elf_set_logfile(struct elf_binary *elf, FILE *f, int verbose) {
+ elf_set_log(elf, log_callback, f, verbose);
+}
+
+/* ------------------------------------------------------------------------ */
+
static char *xc_dom_guest_type(struct xc_dom_image *dom,
struct elf_binary *elf)
{
@@ -137,8 +149,9 @@ static int xc_dom_load_elf_symtab(struct xc_dom_image *dom,
}
if ( elf_init(&syms, hdr + sizeof(int), size - sizeof(int)) )
return -1;
+
if ( xc_dom_logfile )
- elf_set_logfile(&syms, xc_dom_logfile, 1);
+ xc_elf_set_logfile(&syms, xc_dom_logfile, 1);
symtab = dom->bsd_symtab_start + sizeof(int);
maxaddr = elf_round_up(&syms, symtab + elf_size(&syms, syms.ehdr) +
@@ -231,7 +244,7 @@ static int xc_dom_parse_elf_kernel(struct xc_dom_image *dom)
dom->private_loader = elf;
rc = elf_init(elf, dom->kernel_blob, dom->kernel_size);
if ( xc_dom_logfile )
- elf_set_logfile(elf, xc_dom_logfile, 1);
+ xc_elf_set_logfile(elf, xc_dom_logfile, 1);
if ( rc != 0 )
{
xc_dom_panic(XC_INVALID_KERNEL, "%s: corrupted ELF image\n",
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index 2d01467d82..f63f96deb7 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -19,6 +19,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <stdio.h>
#include <xen/xen.h>
#include <xen/domctl.h>
#include <xen/physdev.h>
@@ -1474,4 +1475,8 @@ int xc_memshr_debug_gref(int xc_handle,
uint32_t domid,
grant_ref_t gref);
+struct elf_binary;
+void xc_elf_set_logfile(struct elf_binary *elf, FILE *f, int verbose);
+/* Useful for callers who also use libelf. */
+
#endif /* XENCTRL_H */
diff --git a/tools/xcutils/readnotes.c b/tools/xcutils/readnotes.c
index b770f56fe9..270c48b017 100644
--- a/tools/xcutils/readnotes.c
+++ b/tools/xcutils/readnotes.c
@@ -170,7 +170,7 @@ int main(int argc, char **argv)
fprintf(stderr, "File %s is not an ELF image\n", f);
return 1;
}
- elf_set_logfile(&elf, stderr, 0);
+ xc_elf_set_logfile(&elf, stderr, 0);
count = elf_phdr_count(&elf);
for ( h=0; h < count; h++)