kexec-tools: Make xc_dlhandle static
Subsystems (2)
PATCH v3 1/1 kexec-tools: Make xc_dlhandle static
This patch is a follow-on to commit 894bea93 "kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.
This patch implements Daniel's suggestion to make the xc_dlhandle variable static.
---
v1: 23jan2018
- Implemented feedback from Daniel Kiper
v2: 23jan2018
- Implemented feedback from Daniel Kiper
- Broke patch into two
v3: 24jan2018
- Implemented feedback from Daniel Kiper
- Added 'extern' to the new declarations in kexec-xen.h
--- kexec/kexec-xen.c | 9 ++++++++- kexec/kexec-xen.h | 13 ++++++------- 2 files changed, 14 insertions(+), 8 deletions(-)
kexec/kexec-xen.c +8 -1
@@ -15,8 +15,15 @@#include "crashdump.h" #ifdef CONFIG_LIBXENCTRL_DL -void *xc_dlhandle; +/* The handle from dlopen(), needed by dlsym(), dlclose() */ +static void *xc_dlhandle;xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME (HYPERCALL_BUFFER_NULL ); + +void *__xc_dlsym (const char *symbol) +{ +return dlsym (xc_dlhandle, symbol); +} +xc_interface *__xc_interface_open (xentoollog_logger *logger,xentoollog_logger *dombuild_logger,unsigned open_flags)
kexec/kexec-xen.h +6 -7
@@ -6,28 +6,27 @@#ifdef CONFIG_LIBXENCTRL_DL #include <dlfcn.h> - -/* The handle from dlopen(), needed by dlsym(), dlclose() */ -extern void *xc_dlhandle; +/* Lookup symbols in libxenctrl.so */ +extern void *__xc_dlsym (const char *symbol);/* Wrappers around xc_interface_open/close() to insert dlopen/dlclose() */ -xc_interface *__xc_interface_open (xentoollog_logger *logger, +extern xc_interface *__xc_interface_open (xentoollog_logger *logger,xentoollog_logger *dombuild_logger,unsigned open_flags); -int __xc_interface_close (xc_interface *xch); +extern int __xc_interface_close (xc_interface *xch);/* GCC expression statements for evaluating dlsym() */ #define __xc_call(dtype, name, args...) \ ( \ { dtype value; \ typedef dtype (*func_t)(xc_interface *, ...); \ - func_t func = dlsym(xc_dlhandle, #name); \ + func_t func = __xc_dlsym(#name); \ value = func(args); \ value; } \ )#define __xc_data (dtype, name) \ ( \ - { dtype *value = (dtype *)dlsym(xc_dlhandle, #name); value; } \ + { dtype *value = (dtype *)__xc_dlsym(#name); value; } \ )/* The wrappers around utilized xenctrl.h functions */
Signature · 7 lines
2.7.4 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 6 lines · Eric DeVolder
This patch is a follow-on to commit
894bea93"kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.This patch implements Daniel's suggestion to make the
xc_dlhandlevariable static.
You should also mention that by the way you are adding missing extern in this patch. Or do it in separate patch with relevant comment.
Quoted 44 lines
Signed-off-by Eric DeVolder <[email protected]>Reviewed-by Daniel Kiper <[email protected]>---
v1: 23jan2018
- Implemented feedback from Daniel Kiperv2: 23jan2018
- Implemented feedback from Daniel Kiper
- Broke patch into twov3: 24jan2018
- Implemented feedback from Daniel Kiper
- Added 'extern' to the new declarations inkexec-xen.h--- kexec/kexec-xen.c | 9 ++++++++- kexec/kexec-xen.h | 13 ++++++------- 2 files changed, 14 insertions(+), 8 deletions(-)kexec/kexec-xen.c +8
-1@@ -15,8 +15,15 @@#include "crashdump.h" #ifdef CONFIG_LIBXENCTRL_DL -void *xc_dlhandle; +/* The handle from dlopen(), needed by dlsym(), dlclose() */ +static void *xc_dlhandle;xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME (HYPERCALL_BUFFER_NULL ); + +void *__xc_dlsym (const char *symbol) +{ +return dlsym (xc_dlhandle, symbol); +} +xc_interface *__xc_interface_open (xentoollog_logger *logger,xentoollog_logger *dombuild_logger,unsigned open_flags)kexec/kexec-xen.h +0
-0
kexec/kexec-xen.h line 8
Quoted 3 lines
kexec/kexec-xen.h +0
-0@@ -6,28 +6,27 @@#ifdef CONFIG_LIBXENCTRL_DL #include <dlfcn.h>
I understand that you need this header but I think that it is really needed in kexec/kexec-xen.c only. Is not it? If yes please drop it from here and add to kexec/kexec-xen.c. Just after "#include <elf.h>".
kexec/kexec-xen.h line 15
Quoted 10 lines
kexec/kexec-xen.h +3
-3-/* The handle from dlopen(), needed by dlsym(), dlclose() */ -extern void *xc_dlhandle; +/* Lookup symbols in libxenctrl.so */ +extern void *__xc_dlsym (const char *symbol);/* Wrappers around xc_interface_open/close() to insert dlopen/dlclose() */ -xc_interface *__xc_interface_open (xentoollog_logger *logger, +extern xc_interface *__xc_interface_open (xentoollog_logger *logger,xentoollog_logger *dombuild_logger,unsigned open_flags);
Broken variable alignment after extern addition. Please fix this too.
Thanks,
Daniel
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Inline responses below. v4 forthcoming.
eric
Quoted 10 lines · Daniel Kiper
Quoted 6 lines · Eric DeVolder
This patch is a follow-on to commit
894bea93"kexec-tools: Perform run-time linking of libxenctrl.so". This patch addresses feedback from Daniel Kiper.This patch implements Daniel's suggestion to make the
xc_dlhandlevariable static.You should also mention that by the way you are adding missing extern in this patch. Or do it in separate patch with relevant comment.
I've included this in the v4 message. I've removed your RB too.
Quoted 46 lines
Quoted 46 lines
Signed-off-by Eric DeVolder <[email protected]>Reviewed-by Daniel Kiper <[email protected]>---
v1: 23jan2018
- Implemented feedback from Daniel Kiperv2: 23jan2018
- Implemented feedback from Daniel Kiper
- Broke patch into twov3: 24jan2018
- Implemented feedback from Daniel Kiper
- Added 'extern' to the new declarations inkexec-xen.h--- kexec/kexec-xen.c | 9 ++++++++- kexec/kexec-xen.h | 13 ++++++------- 2 files changed, 14 insertions(+), 8 deletions(-)kexec/kexec-xen.c +8
-1@@ -15,8 +15,15 @@#include "crashdump.h" #ifdef CONFIG_LIBXENCTRL_DL -void *xc_dlhandle; +/* The handle from dlopen(), needed by dlsym(), dlclose() */ +static void *xc_dlhandle;xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME (HYPERCALL_BUFFER_NULL ); + +void *__xc_dlsym (const char *symbol) +{ +return dlsym (xc_dlhandle, symbol); +} +xc_interface *__xc_interface_open (xentoollog_logger *logger,xentoollog_logger *dombuild_logger,unsigned open_flags)kexec/kexec-xen.h +0
-0@@ -6,28 +6,27 @@
Quoted 6 lines
kexec/kexec-xen.h line 8
Quoted 2 lines
kexec/kexec-xen.h +0
-0#ifdef CONFIG_LIBXENCTRL_DL #include <dlfcn.h> I understand that you need this header but I think that it is really needed in
kexec/kexec-xen.conly. Is not it? If yes please drop it from here and add tokexec/kexec-xen.c. Just after "#include <elf.h>".
Ah yes, you are correct. Now that dlopen/close/sym() are all wrapped in functions in kexec-xen.c, this header can be included just in that file.
done
Quoted 6 lines
Quoted 6 lines
kexec/kexec-xen.h +2
-2-/* The handle from dlopen(), needed by dlsym(), dlclose() */ -extern void *xc_dlhandle; +/* Lookup symbols in libxenctrl.so */ +extern void *__xc_dlsym (const char *symbol);
Quoted 7 lines
kexec/kexec-xen.h line 15
Quoted 5 lines
kexec/kexec-xen.h +1
-1/* Wrappers around xc_interface_open/close() to insert dlopen/dlclose() */ -xc_interface *__xc_interface_open (xentoollog_logger *logger, +extern xc_interface *__xc_interface_open (xentoollog_logger *logger,xentoollog_logger *dombuild_logger,unsigned open_flags);Broken variable alignment after extern addition. Please fix this too.
done.
Quoted 5 lines
Thanks,
Daniel
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec