[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v1 1/3] libelf: Preserve log callback after elf_init



The elf_init function uses the log callback to report
errors. But it also memsets the whole structure so the
log callback (if set) is wiped out!

This preserves the log callback function along with its
states.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
 xen/common/libelf/libelf-loader.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/xen/common/libelf/libelf-loader.c 
b/xen/common/libelf/libelf-loader.c
index 6f42bea..32a9724 100644
--- a/xen/common/libelf/libelf-loader.c
+++ b/xen/common/libelf/libelf-loader.c
@@ -27,14 +27,28 @@ elf_errorstatus elf_init(struct elf_binary *elf, const char 
*image_input, size_t
 {
     ELF_HANDLE_DECL(elf_shdr) shdr;
     uint64_t i, count, section, offset;
+#ifndef __XEN__
+    elf_log_callback *callback;
+    void *log_callback_data;
+#endif
+    int verbose;
 
     if ( !elf_is_elfbinary(image_input, size) )
     {
         elf_err(elf, "%s: not an ELF binary\n", __FUNCTION__);
         return -1;
     }
-
+#ifndef __XEN__
+    callback = elf->log_callback;
+    log_callback_data = elf->log_caller_data;
+#endif
+    verbose = elf->verbose;
     elf_memset_unchecked(elf, 0, sizeof(*elf));
+#ifndef __XEN__
+    elf->log_callback = callback;
+    elf->log_caller_data = log_callback_data;
+#endif
+    elf->verbose = verbose;
     elf->image_base = image_input;
     elf->size = size;
     elf->ehdr = ELF_MAKE_HANDLE(elf_ehdr, (elf_ptrval)image_input);
-- 
2.4.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.