[PATCH 14/42] initcall: Correct use of relocation offset

Caleb Connolly caleb.connolly at linaro.org
Wed Jun 12 11:04:52 CEST 2024


Hi Simon,

On 11/06/2024 22:01, Simon Glass wrote:
> The relocation offset can change in some initcall sequences. Handle
> this and make sure it is used for all debugging statements in
> init_run_list()
> 
> Update the trace test to match.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
>   lib/initcall.c              | 6 ++++--
>   test/py/tests/test_trace.py | 4 ++--
>   2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/initcall.c b/lib/initcall.c
> index c8e2b0f6a38..2686b9aed5c 100644
> --- a/lib/initcall.c
> +++ b/lib/initcall.c
> @@ -49,13 +49,14 @@ static int initcall_is_event(init_fnc_t func)
>    */
>   int initcall_run_list(const init_fnc_t init_sequence[])
>   {
> -	ulong reloc_ofs = calc_reloc_ofs();
> +	ulong reloc_ofs;
>   	const init_fnc_t *ptr;
>   	enum event_t type;
>   	init_fnc_t func;
>   	int ret = 0;
>   
>   	for (ptr = init_sequence; func = *ptr, func; ptr++) {
> +		reloc_ofs = calc_reloc_ofs();
>   		type = initcall_is_event(func);
>   
>   		if (type) {
> @@ -84,7 +85,8 @@ int initcall_run_list(const init_fnc_t init_sequence[])
>   				sprintf(buf, "event %d/%s", type,
>   					event_type_name(type));
>   			} else {
> -				sprintf(buf, "call %p", func);
> +				sprintf(buf, "call %p",
> +					(char *)func - reloc_ofs);
>   			}
>   
>   			printf("initcall failed at %s (err=%dE)\n", buf, ret);
> diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py
> index f41d4cf71f0..ec1e624722c 100644
> --- a/test/py/tests/test_trace.py
> +++ b/test/py/tests/test_trace.py
> @@ -175,7 +175,7 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat):
>       # Then look for this:
>       #  u-boot-1     0.....   282.101375: funcgraph_exit:         0.006 us   |      }
>       # Then check for this:
> -    #  u-boot-1     0.....   282.101375: funcgraph_entry:        0.000 us   |    initcall_is_event();
> +    #  u-boot-1     0.....   282.101375: funcgraph_entry:        0.000 us   |    calc_reloc_ofs();
>   
>       expected_indent = None
>       found_start = False
> @@ -199,7 +199,7 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat):
>   
>       # The next function after initf_bootstage() exits should be
>       # initcall_is_event()

This comment needs updating.
> -    assert upto == 'initcall_is_event()'
> +    assert upto == 'calc_reloc_ofs()'
>   
>       # Now look for initf_dm() and dm_timer_init() so we can check the bootstage
>       # time

Otherwise, this looks sensible to me.

Reviewed-by: Caleb Connolly <caleb.connolly at linaro.org>

-- 
// Caleb (they/them)


More information about the U-Boot mailing list