xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, ian.campbell@citrix.com,
	ian.jackson@eu.citrix.com, jbeulich@suse.com, tim@xen.org,
	keir@xen.org
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH v1 1/3] libelf: Preserve log callback after elf_init
Date: Sat,  3 Oct 2015 14:39:48 -0400	[thread overview]
Message-ID: <1443897590-5663-2-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1443897590-5663-1-git-send-email-konrad.wilk@oracle.com>

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@oracle.com>
---
 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

  reply	other threads:[~2015-10-03 18:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-03 18:39 [PATCH] Various fixes - libelf, paging, blktap Konrad Rzeszutek Wilk
2015-10-03 18:39 ` Konrad Rzeszutek Wilk [this message]
2015-10-05 10:36   ` [PATCH v1 1/3] libelf: Preserve log callback after elf_init Jan Beulich
2015-10-05 14:23     ` Konrad Rzeszutek Wilk
2015-10-05 14:39       ` Jan Beulich
2015-10-05 14:48         ` Konrad Rzeszutek Wilk
2015-10-03 18:39 ` [PATCH v1 2/3] paging: Fix compile error when DEBUG_TRACE_DUMP is enabled Konrad Rzeszutek Wilk
2015-10-05  8:46   ` Andrew Cooper
2015-10-03 18:39 ` [PATCH v1 3/3] blktap2: Silence warnings under GCC 5.1.1 Konrad Rzeszutek Wilk
2015-10-05  8:49   ` Andrew Cooper
2015-10-05 10:46     ` Jan Beulich
2015-10-05 14:26       ` Konrad Rzeszutek Wilk
2015-10-05 14:46         ` Jan Beulich
2015-10-05 14:57           ` Konrad Rzeszutek Wilk
2015-10-05 15:02             ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443897590-5663-2-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).