Re: [PATCH v4 0/7] Clean up arm linker scripts

2024-03-29 Thread Tom Rini
On Fri, 15 Mar 2024 08:43:44 +0200, Ilias Apalodimas wrote:

> The arm linker scripts had a mix of symbols and C defined variables in an
> effort to emit relative references instead of absolute ones e.g [0]. A
> linker bug prevented us from doing so [1] -- fixed since 2016.
> This has led to confusion over the years, ending up with mixed section
> definitions. Some sections are defined with overlays and different
> definitions between v7 and v8 architectures.
> For example __efi_runtime_rel_start/end is defined as a linker symbol for
> armv8 and a C variable in armv7.
> 
> [...]

Applied to u-boot/next, thanks!

-- 
Tom




[PATCH v4 0/7] Clean up arm linker scripts

2024-03-15 Thread Ilias Apalodimas
The arm linker scripts had a mix of symbols and C defined variables in an
effort to emit relative references instead of absolute ones e.g [0]. A
linker bug prevented us from doing so [1] -- fixed since 2016.
This has led to confusion over the years, ending up with mixed section
definitions. Some sections are defined with overlays and different
definitions between v7 and v8 architectures.
For example __efi_runtime_rel_start/end is defined as a linker symbol for
armv8 and a C variable in armv7.

Linker scripts nowadays can emit relative references, as long as the symbol
definition is contained within the section definition. So let's switch most
of the C defined variables and clean up the arm sections.c file.
There's still a few symbols remaining -- __secure_start/end,
__secure_stack_start/end and __end which can be cleaned up
in a followup series.

For both QEMU v7/v8 bloat-o-meter shows now size difference
$~ ./scripts/bloat-o-meter u-boot u-boot.new
add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
Function old new   delta
Total: Before=798861, After=798861, chg +0.00%

The symbols seem largely unchanged apart from a difference in .bss
as well as the emited sections and object types of the affected variables.

On the output below the first value is from -next and the second comes from
-next + this patchset. The .bss_start/end sections have disappeared from
the newer binaries.

# For example on QEMU v8:
efi_runtime_start
  7945: 0178 0 OBJECT  GLOBAL DEFAULT2 __efi_runtime_start
  7942: 0178 0 NOTYPE  GLOBAL DEFAULT2 __efi_runtime_start
efi_runtime_stop
  9050: 0d38 0 OBJECT  GLOBAL DEFAULT2 __efi_runtime_stop
  9047: 0d38 0 NOTYPE  GLOBAL DEFAULT2 __efi_runtime_stop
__efi_runtime_rel_start
  7172: 000dc2f0 0 OBJECT  GLOBAL DEFAULT   10 
__efi_runtime_rel_start
  7169: 000dc2f0 0 NOTYPE  GLOBAL DEFAULT   10 
__efi_runtime_rel_start
__efi_runtime_rel_stop
  7954: 000dc4a0 0 OBJECT  GLOBAL DEFAULT   10 
__efi_runtime_rel_stop
  7951: 000dc4a0 0 NOTYPE  GLOBAL DEFAULT   10 
__efi_runtime_rel_stop
__rel_dyn_start
  7030: 000dc4a0 0 OBJECT  GLOBAL DEFAULT   11 __rel_dyn_start
  7027: 000dc4a0 0 NOTYPE  GLOBAL DEFAULT   11 __rel_dyn_start
__rel_dyn_end
  8959: 00102b10 0 OBJECT  GLOBAL DEFAULT   12 __rel_dyn_end
  8956: 00102b10 0 NOTYPE  GLOBAL DEFAULT   11 __rel_dyn_end
image_copy_start
  9051:  0 OBJECT  GLOBAL DEFAULT1 __image_copy_start
  9048:  0 NOTYPE  GLOBAL DEFAULT1 __image_copy_start
image_copy_end
  7467: 000dc4a0 0 OBJECT  GLOBAL DEFAULT   11 __image_copy_end
  7464: 000dc4a0 0 NOTYPE  GLOBAL DEFAULT   11 __image_copy_end
bss_start
12: 00102b10 0 SECTION LOCAL  DEFAULT   12 .bss_start
  8087: 0018 0 NOTYPE  GLOBAL DEFAULT1 _bss_start_ofs
  8375: 00102b10 0 OBJECT  GLOBAL DEFAULT   12 __bss_start
  8084: 0018 0 NOTYPE  GLOBAL DEFAULT1 _bss_start_ofs
  8372: 00102b10 0 NOTYPE  GLOBAL DEFAULT   12 __bss_start
bss_end
14: 0010bc30 0 SECTION LOCAL  DEFAULT   14 .bss_end
  7683: 0010bc30 0 OBJECT  GLOBAL DEFAULT   14 __bss_end
  8479: 0020 0 NOTYPE  GLOBAL DEFAULT1 _bss_end_ofs
  7680: 0010bbb0 0 NOTYPE  GLOBAL DEFAULT   12 __bss_end
  8476: 0020 0 NOTYPE  GLOBAL DEFAULT1 _bss_end_ofs

# For QEMU v7:
efi_runtime_start
 10703: 03bc 0 OBJECT  GLOBAL DEFAULT2 __efi_runtime_start
 10699: 03c0 0 NOTYPE  GLOBAL DEFAULT2 __efi_runtime_start
efi_runtime_stop
 11796: 12ec 0 OBJECT  GLOBAL DEFAULT2 __efi_runtime_stop
 11792: 12ec 0 NOTYPE  GLOBAL DEFAULT2 __efi_runtime_stop
__efi_runtime_rel_start
  9937: 000c40dc 0 OBJECT  GLOBAL DEFAULT8 __efi_runtime_rel_start
  9935: 000c40dc 0 NOTYPE  GLOBAL DEFAULT9 __efi_runtime_rel_start
__efi_runtime_rel_stop
 10712: 000c41dc 0 OBJECT  GLOBAL DEFAULT   10 __efi_runtime_rel_stop
 10708: 000c41dc 0 NOTYPE  GLOBAL DEFAULT9 __efi_runtime_rel_stop
__rel_dyn_start
  9791: 000c41dc 0 OBJECT  GLOBAL DEFAULT   10 __rel_dyn_start
  9789: 000c41dc 0 NOTYPE  GLOBAL DEFAULT   10 __rel_dyn_start
__rel_dyn_end
 11708: 000da5f4 0 OBJECT  GLOBAL DEFAULT   10 __rel_dyn_end
 11704: 000da5f4 0 NOTYPE  GLOBAL DEFAULT   10 __rel_dyn_end
image_copy_start
   448: 177c 0 NOTYPE  LOCAL  DEFAULT3 _image_copy_start_ofs
 11797:  0 OBJECT  GLOBAL DEFAULT1 __image_copy_start
   445: 177c 0 NOTYPE  LOCAL  DEFAULT3 _image_copy_start_ofs
 11793:  0 NOTYPE  GLOBAL DEFAULT1 __image_copy_start
image_copy_end
   450: 1780 0 NOTYPE  LOCAL  DEFAULT3 _image_copy_end_ofs
 10225: 000c41dc 0 OBJECT  GLOBAL DEFAULT