# Re: \[RFC PATCH v2 5/6\] samples: livepatch: init reloc section array and mark as klp module

- From: Josh Poimboeuf \<hidden\>
- Date: 2015-12-08 18:41:08 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2015/12/4637838
- Thread: https://ratatoskr.run/linux-api/2015/12/4631621/t.md

```text
On Mon, Nov 30, 2015 at 11:21:18PM -0500, Jessica Yu wrote:
> Create the array of klp relocation sections in the sample
> klp_object (even if the array is empty in this case).
> 
> In addition, mark the module as a livepatch module so that
> the module loader can appropriately identify and initialize it.
> 
> Signed-off-by: Jessica Yu <redacted>
> ---
>  samples/livepatch/livepatch-sample.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/samples/livepatch/livepatch-sample.c b/samples/livepatch/livepatch-sample.c
> index fb8c861..298dc21 100644
> --- a/samples/livepatch/livepatch-sample.c
> +++ b/samples/livepatch/livepatch-sample.c
> @@ -53,10 +53,15 @@ static struct klp_func funcs[] = {
>  	}, { }
>  };
>  
> +static struct klp_reloc_sec reloc_secs[] = {
> +	{ }
> +};
> +

I think it's not possible to specify the relocations when building the
patch module in this way, right?  If so, I think this is confusing, and
it would be better to just leave out any mention of reloc_secs in the
sample module.

>  static struct klp_object objs[] = {
>  	{
>  		/* name being NULL means vmlinux */
>  		.funcs = funcs,
> +		.reloc_secs = reloc_secs,
>  	}, { }
>  };
>  
> @@ -89,3 +94,4 @@ static void livepatch_exit(void)
>  module_init(livepatch_init);
>  module_exit(livepatch_exit);
>  MODULE_LICENSE("GPL");
> +MODULE_INFO(livepatch, "Y");
> -- 
> 2.4.3
> 

-- 
Josh
```
