[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 1/3] livepach: Add .livepatch.hooks functions and test-case
>>> On 09.08.16 at 20:01, <konrad.wilk@xxxxxxxxxx> wrote: >> >> > @@ -70,7 +71,11 @@ struct payload { >> >> > unsigned int nsyms; /* Nr of entries in .strtab >> >> > and >> >> > symbols. */ >> >> > struct livepatch_build_id id; /* >> >> > ELFNOTE_DESC(.note.gnu.build-id) of the payload. */ >> >> > struct livepatch_build_id dep; /* >> >> > ELFNOTE_DESC(.livepatch.depends). */ >> >> > - char name[XEN_LIVEPATCH_NAME_SIZE]; /* Name of it. */ >> >> > + livepatch_loadcall_t **load_funcs; /* The array of funcs to call >> >> > after */ >> >> > + livepatch_unloadcall_t **unload_funcs;/* load and unload of the >> >> > payload. */ >> >> >> >> These both seem like they want a const in the middle. >> > >> > I did that initially and found out that the calling ->load_funcs[i] >> > resulted >> > in _no_ code being called. >> > >> > I did not dig in the assembler output to figure out what happend, let me >> > do that now. >> >> Indeed - I can't see how a const modifier here could alter whether >> or not the pointed to function gets called. > > I did a diff on the pre-assemble part (-S) with and without const on the above > structs. With 'const' we get: > > call spin_debug_disable > .LVL163: > - .loc 1 1093 0 > - cmpl $0, 324(%rbx) > - je .L112 > - movl $0, %r12d > -.LVL164: > -.L113: > - .loc 1 1094 0 > - mov %r12d, %edx > - movq 312(%rbx), %rax > - call *(%rax,%rdx,8) > - .loc 1 1093 0 > - addl $1, %r12d > -.LVL165: > - cmpl %r12d, 324(%rbx) > - ja .L113 > -.LVL166: > -.L112: > > being removed. > > I thought it may have to do with the function not returning anything. But > even after making the typedef return it still omitted the call > data->load_funcs[i](); Odd. I've tried this simple example: typedef int fn_t(void); struct s { unsigned n; fn_t**fn; fn_t*const*fnc; const fn_t**cfn; }; int test1(const struct s*ps) { unsigned i; int rc = 0; for(i = 0; !rc && i < ps->n; ++i) rc = ps->fn[i](); return rc; } int test2(const struct s*ps) { unsigned i; int rc = 0; for(i = 0; !rc && i < ps->n; ++i) rc = ps->fnc[i](); return rc; } int test3(const struct s*ps) { unsigned i; int rc = 0; for(i = 0; !rc && i < ps->n; ++i) rc = ps->cfn[i](); return rc; } test1() and test2() get compiled identically. test3(), using the field with the misplaced const, oddly enough gets compiled slightly differently (and without a warning despite one would seem warranted), yet the call doesn't get omitted. If, however, I change the return type of fn_t to void, the function body of test3() ends up empty, which is a compiler bug afaict, but which also suggests that you've tried the variant with the misplaced const. Jan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |