Skip to content
Snippets Groups Projects
  1. Mar 30, 2024
  2. Mar 29, 2024
    • Tom Rini's avatar
      Merge patch series "Clean up arm linker scripts" · 6e2228fb
      Tom Rini authored
      Ilias Apalodimas <ilias.apalodimas@linaro.org> says:
      
      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: 0000000000000178     0 OBJECT  GLOBAL DEFAULT    2 __efi_runtime_start
        7942: 0000000000000178     0 NOTYPE  GLOBAL DEFAULT    2 __efi_runtime_start
      efi_runtime_stop
        9050: 0000000000000d38     0 OBJECT  GLOBAL DEFAULT    2 __efi_runtime_stop
        9047: 0000000000000d38     0 NOTYPE  GLOBAL DEFAULT    2 __efi_runtime_stop
      __efi_runtime_rel_start
        7172: 00000000000dc2f0     0 OBJECT  GLOBAL DEFAULT   10 __efi_runtime_rel_start
        7169: 00000000000dc2f0     0 NOTYPE  GLOBAL DEFAULT   10 __efi_runtime_rel_start
      __efi_runtime_rel_stop
        7954: 00000000000dc4a0     0 OBJECT  GLOBAL DEFAULT   10 __efi_runtime_rel_stop
        7951: 00000000000dc4a0     0 NOTYPE  GLOBAL DEFAULT   10 __efi_runtime_rel_stop
      __rel_dyn_start
        7030: 00000000000dc4a0     0 OBJECT  GLOBAL DEFAULT   11 __rel_dyn_start
        7027: 00000000000dc4a0     0 NOTYPE  GLOBAL DEFAULT   11 __rel_dyn_start
      __rel_dyn_end
        8959: 0000000000102b10     0 OBJECT  GLOBAL DEFAULT   12 __rel_dyn_end
        8956: 0000000000102b10     0 NOTYPE  GLOBAL DEFAULT   11 __rel_dyn_end
      image_copy_start
        9051: 0000000000000000     0 OBJECT  GLOBAL DEFAULT    1 __image_copy_start
        9048: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    1 __image_copy_start
      image_copy_end
        7467: 00000000000dc4a0     0 OBJECT  GLOBAL DEFAULT   11 __image_copy_end
        7464: 00000000000dc4a0     0 NOTYPE  GLOBAL DEFAULT   11 __image_copy_end
      bss_start
          12: 0000000000102b10     0 SECTION LOCAL  DEFAULT   12 .bss_start
        8087: 0000000000000018     0 NOTYPE  GLOBAL DEFAULT    1 _bss_start_ofs
        8375: 0000000000102b10     0 OBJECT  GLOBAL DEFAULT   12 __bss_start
        8084: 0000000000000018     0 NOTYPE  GLOBAL DEFAULT    1 _bss_start_ofs
        8372: 0000000000102b10     0 NOTYPE  GLOBAL DEFAULT   12 __bss_start
      bss_end
          14: 000000000010bc30     0 SECTION LOCAL  DEFAULT   14 .bss_end
        7683: 000000000010bc30     0 OBJECT  GLOBAL DEFAULT   14 __bss_end
        8479: 0000000000000020     0 NOTYPE  GLOBAL DEFAULT    1 _bss_end_ofs
        7680: 000000000010bbb0     0 NOTYPE  GLOBAL DEFAULT   12 __bss_end
        8476: 0000000000000020     0 NOTYPE  GLOBAL DEFAULT    1 _bss_end_ofs
      
      # For QEMU v7:
      efi_runtime_start
       10703: 000003bc     0 OBJECT  GLOBAL DEFAULT    2 __efi_runtime_start
       10699: 000003c0     0 NOTYPE  GLOBAL DEFAULT    2 __efi_runtime_start
      efi_runtime_stop
       11796: 000012ec     0 OBJECT  GLOBAL DEFAULT    2 __efi_runtime_stop
       11792: 000012ec     0 NOTYPE  GLOBAL DEFAULT    2 __efi_runtime_stop
      __efi_runtime_rel_start
        9937: 000c40dc     0 OBJECT  GLOBAL DEFAULT    8 __efi_runtime_rel_start
        9935: 000c40dc     0 NOTYPE  GLOBAL DEFAULT    9 __efi_runtime_rel_start
      __efi_runtime_rel_stop
       10712: 000c41dc     0 OBJECT  GLOBAL DEFAULT   10 __efi_runtime_rel_stop
       10708: 000c41dc     0 NOTYPE  GLOBAL DEFAULT    9 __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: 0000177c     0 NOTYPE  LOCAL  DEFAULT    3 _image_copy_start_ofs
       11797: 00000000     0 OBJECT  GLOBAL DEFAULT    1 __image_copy_start
         445: 0000177c     0 NOTYPE  LOCAL  DEFAULT    3 _image_copy_start_ofs
       11793: 00000000     0 NOTYPE  GLOBAL DEFAULT    1 __image_copy_start
      image_copy_end
         450: 00001780     0 NOTYPE  LOCAL  DEFAULT    3 _image_copy_end_ofs
       10225: 000c41dc     0 OBJECT  GLOBAL DEFAULT   10 __image_copy_end
         447: 00001780     0 NOTYPE  LOCAL  DEFAULT    3 _image_copy_end_ofs
       10222: 000c41dc     0 NOTYPE  GLOBAL DEFAULT   10 __image_copy_end
      bss_start
          11: 000c41dc     0 SECTION LOCAL  DEFAULT   11 .bss_start
       11124: 000c41dc     0 OBJECT  GLOBAL DEFAULT   11 __bss_start
       11120: 000c41dc     0 NOTYPE  GLOBAL DEFAULT   11 __bss_start
      bss_end
          13: 000cbbf8     0 SECTION LOCAL  DEFAULT   13 .bss_end
       10442: 000cbbf8     0 OBJECT  GLOBAL DEFAULT   13 __bss_end
       10439: 000cbbf8     0 NOTYPE  GLOBAL DEFAULT   11 __bss_end
      
      It's worth noting that since the efi regions are affected by the change, booting
      with EFI is preferable while testing. Booting the kernel only should be enough
      since the efi stub and the kernel proper do request boottime and runtime
      services respectively.
      Something along the lines of
      > virtio scan && load virtio 0 $kernel_addr_r Image && bootefi $kernel_addr_r
      will work for QEMU aarch64.
      
      Tested platforms:
      - QEMU aarch64
      - Xilinx kv260 kria starter kit & zynq
      - QEMU armv7
      - STM32MP157C-DK2
      
      [0] commit 3ebd1cbc ("arm: make __bss_start and __bss_end__ compiler-generated")
      [1] binutils commit 6b3b0ab89663 ("Make linker assigned symbol dynamic only for shared object")
      6e2228fb
    • Ilias Apalodimas's avatar
      arm: remove redundant section alignments · 7828a1ee
      Ilias Apalodimas authored and Tom Rini's avatar Tom Rini committed
      
      Previous patches cleaning up linker symbols, also merged any explicit
      . = ALIGN(x); into section definitions -- e.g
      .bss ALIGN(x) : instead of
      
      . = ALIGN(x);
      . bss : {...}
      
      However, if the output address is not specified then one will be chosen
      for the section. This address will be adjusted to fit the alignment
      requirement of the output section following the strictest alignment of
      any input section contained within the output section. So let's get rid
      of the redundant ALIGN directives when they are not needed.
      
      While at add comments for the alignment of __bss_start/end since our
      C runtime setup assembly assumes that __bss_start - __bss_end will be
      a multiple of 4/8 for armv7 and armv8 respectively.
      
      It's worth noting that the alignment is preserved on .rel.dyn for
      mach-zynq which was explicitly aligning that section on an 8b
      boundary instead of 4b one.
      
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Signed-off-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
      7828a1ee
    • Ilias Apalodimas's avatar
      arm: move image_copy_start/end to linker symbols · 4ee32ea0
      Ilias Apalodimas authored and Tom Rini's avatar Tom Rini committed
      
      image_copy_start/end are defined as c variables in order to force the compiler
      emit relative references. However, defining those within a section definition
      will do the same thing since [0].
      
      So let's remove the special sections from the linker scripts, the
      variable definitions from sections.c and define them as a symbols within
      a section.
      
      [0] binutils commit 6b3b0ab89663 ("Make linker assigned symbol dynamic only for shared object")
      
      Suggested-by: default avatarSam Edwards <CFSworks@gmail.com>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Tested-by: Sam Edwards <CFSworks@gmail.com> # Binary output identical
      Signed-off-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
      4ee32ea0
    • Ilias Apalodimas's avatar
      arm: fix __efi_runtime_start/end definitions · c0802104
      Ilias Apalodimas authored and Tom Rini's avatar Tom Rini committed
      
      __efi_runtime_start/end are defined as c variables for arm7 only in
      order to force the compiler emit relative references. However, defining
      those within a section definition will do the same thing since [0].
      On top of that the v8 linker scripts define it as a symbol.
      
      So let's remove the special sections from the linker scripts, the
      variable definitions from sections.c and define them as a symbols within
      the correct section.
      
      [0] binutils commit 6b3b0ab89663 ("Make linker assigned symbol dynamic only for shared object")
      
      Suggested-by: default avatarSam Edwards <CFSworks@gmail.com>
      Reviewed-by: default avatarSam Edwards <CFSworks@gmail.com>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Tested-by: Sam Edwards <CFSworks@gmail.com> # Binary output identical
      Signed-off-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
      c0802104
    • Ilias Apalodimas's avatar
      arm: clean up v7 and v8 linker scripts for __rel_dyn_start/end · 742752af
      Ilias Apalodimas authored and Tom Rini's avatar Tom Rini committed
      commit 47bd65ef ("arm: make __rel_dyn_{start, end} compiler-generated")
      were moving the __rel_dyn_start/end on c generated variables that were
      injected in their own sections. The reason was that we needed relative
      relocations for position independent code and linker bugs back then
      prevented us from doing so [0].
      
      However, the linker documentation pages states that symbols that are
      defined within a section definition will create a relocatable
      type with the value being a fixed offset from the base of a section [1].
      
      [0] binutils commit 6b3b0ab89663 ("Make linker assigned symbol dynamic only for shared object")
      [1] https://sourceware.org/binutils/docs/ld/Expression-Section.html
      
      
      
      Suggested-by: default avatarSam Edwards <CFSworks@gmail.com>
      Reviewed-by: default avatarSam Edwards <CFSworks@gmail.com>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Tested-by: Sam Edwards <CFSworks@gmail.com> # Binary output identical
      Signed-off-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
      742752af
    • Ilias Apalodimas's avatar
      arm: fix __efi_runtime_rel_start/end definitions · 6b7f91cd
      Ilias Apalodimas authored and Tom Rini's avatar Tom Rini committed
      
      __efi_runtime_rel_start/end are defined as c variables for arm7 only in
      order to force the compiler emit relative references. However, defining
      those within a section definition will do the same thing since [0].
      On top of that the v8 linker scripts define it as a symbol.
      
      So let's remove the special sections from the linker scripts, the
      variable definitions from sections.c and define them as a symbols within
      the correct section.
      
      [0] binutils commit 6b3b0ab89663 ("Make linker assigned symbol dynamic only for shared object")
      
      Suggested-by: default avatarSam Edwards <CFSworks@gmail.com>
      Reviewed-by: default avatarSam Edwards <CFSworks@gmail.com>
      Tested-by: Sam Edwards <CFSworks@gmail.com> # Binary output identical
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Signed-off-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
      6b7f91cd
    • Ilias Apalodimas's avatar
      arm: clean up v7 and v8 linker scripts for bss_start/end · faf396aa
      Ilias Apalodimas authored and Tom Rini's avatar Tom Rini committed
      commit 3ebd1cbc ("arm: make __bss_start and __bss_end__ compiler-generated")
      and
      commit f84a7b8f ("ARM: Fix __bss_start and __bss_end in linker scripts")
      were moving the bss_start/end on c generated variables that were
      injected in their own sections. The reason was that we needed relative
      relocations for position independent code and linker bugs back then
      prevented us from doing so [0].
      
      However, the linker documentation pages states that symbols that are
      defined within a section definition will create a relocatable type with
      the value being a fixed offset from the base of a section [1].
      So let's start cleaning this up starting with the bss_start and bss_end
      variables. Convert them into symbols within the .bss section definition.
      
      [0] binutils commit 6b3b0ab89663 ("Make linker assigned symbol dynamic only for shared object")
      [1] https://sourceware.org/binutils/docs/ld/Expression-Section.html
      
      
      
      Tested-by: Caleb Connolly <caleb.connolly@linaro.org> # Qualcomm sdm845
      Tested-by: Sam Edwards <CFSworks@gmail.com> # Binary output identical
      Signed-off-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      faf396aa
    • Ilias Apalodimas's avatar
      arm: baltos: remove custom linker script · fb570674
      Ilias Apalodimas authored and Tom Rini's avatar Tom Rini committed
      
      commit 3d74a097 ("ti: am335x: Remove unused linker script") removed
      the linker script for the TI variant. This linker script doesn't seem to
      do anything special and on top of that, has no definitions for the EFI
      runtime sections.
      
      So let's get rid of it and use the generic linker script which defines
      those correctly
      
      Signed-off-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
      Reviewed-by: default avatarTom Rini <trini@konsulko.com>
      fb570674
  3. Mar 28, 2024
  4. Mar 27, 2024
  5. Mar 26, 2024
  6. Mar 25, 2024
Loading