[U-Boot] [PATCH 07/12] x86: put global data pointer into the .data section
Simon Glass
sjg at chromium.org
Fri Oct 19 03:26:27 UTC 2018
On 13 October 2018 at 09:06, Bin Meng <bmeng.cn at gmail.com> wrote:
> From: Heinrich Schuchardt <xypron.glpk at gmx.de>
>
> On x86_64 the field global_data_ptr is assigned before relocation. As
> sections for uninitialized global data (.bss) overlap with the relocation
> sections (.rela) this destroys the relocation table and leads to spurious
> errors.
>
> Initialization forces the global_data_ptr into a section for initialized
> global data (.data) which cannot overlap any .rela section.
>
> Fixes: a160092a610f ("x86: Support global_data on x86_64")
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> Tested-by: Bin Meng <bmeng.cn at gmail.com>
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
> ---
>
> arch/x86/cpu/x86_64/cpu.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
Reviewed-by: Simon Glass <sjg at chromium.org>
(see below)
> diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
> index 18b3e94..ef5e812 100644
> --- a/arch/x86/cpu/x86_64/cpu.c
> +++ b/arch/x86/cpu/x86_64/cpu.c
> @@ -7,8 +7,14 @@
> #include <common.h>
> #include <debug_uart.h>
>
> -/* Global declaration of gd */
> -struct global_data *global_data_ptr;
> +/*
> + * Global declaration of gd.
> + *
> + * As we write to it before relocation we have to make sure it is not put into
> + * a .bss section which may overlap a .rela section. Initialization forces it
> + * into a .data section which cannot overlap any .rela section.
> + */
> +struct global_data *global_data_ptr = (struct global_data *)~0;
You could use __attribute__ ((section*.data")))) perhaps as this is a
bit obscure
>
> void arch_setup_gd(gd_t *new_gd)
> {
> --
> 2.7.4
>
More information about the U-Boot
mailing list