Commit 2c78a79ec7fc0b3729e9f16214cf8e08e4664a0b

Authored by Heinrich Schuchardt
Committed by Bin Meng
1 parent 80df194f01

x86: put global data pointer into the .data section

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@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

Showing 1 changed file with 8 additions and 2 deletions Side-by-side Diff

arch/x86/cpu/x86_64/cpu.c
... ... @@ -7,8 +7,14 @@
7 7 #include <common.h>
8 8 #include <debug_uart.h>
9 9  
10   -/* Global declaration of gd */
11   -struct global_data *global_data_ptr;
  10 +/*
  11 + * Global declaration of gd.
  12 + *
  13 + * As we write to it before relocation we have to make sure it is not put into
  14 + * a .bss section which may overlap a .rela section. Initialization forces it
  15 + * into a .data section which cannot overlap any .rela section.
  16 + */
  17 +struct global_data *global_data_ptr = (struct global_data *)~0;
12 18  
13 19 void arch_setup_gd(gd_t *new_gd)
14 20 {