[PATCH 0/4] s390: compile relocatable kernel with/without fPIE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

This is a rebased version of Josh's patch series with a few fixups.
https://git.kernel.org/pub/scm/linux/kernel/git/jpoimboe/linux.git/log/?h=s390

This introduces the capability to compile the s390 relocatable kernel
with and without the -fPIE option.

When utilizing the kpatch functionality, it is advisable to compile the
kernel without the -fPIE option. This is particularly important if the
kernel is built with the -ffunction-sections and -fdata-sections flags.
The linker imposes a restriction on the number of sections (limited to
64k), necessitating the omission of -fPIE.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2023-June/622872.html
[2] https://gcc.gnu.org/pipermail/gcc-patches/2023-August/625986.html

Gcc recently implemented an optimization [1] for loading symbols without
explicit alignment, aligning with the IBM Z ELF ABI. This ABI mandates
symbols to reside on a 2-byte boundary, enabling the use of the larl
instruction. However, kernel linker scripts may still generate unaligned
symbols. To address this, a new -munaligned-symbols option has been
introduced [2] in recent gcc versions. This option has to be used with
future gcc versions.

Older Clang lacks support for handling unaligned symbols generated
by kernel linker scripts when the kernel is built without -fPIE. However,
future versions of Clang will include support for the -munaligned-symbols
option. When the support is unavailable, compile the kernel with -fPIE
to maintain the existing behavior.

Patch 1 filters out -munaligned-symbol flag for vdso code. This is beneficial
when compiling kernel with -fno-PIE and -munaligned-symbols combination.

Patch 2 introduces the 'relocs' tool, which reads the vmlinux file and
generates a vmlinux.relocs_64 section, containing offsets for all
R_390_64 relocations.

Patch 3 enables the compilation of a relocatable kernel with or without
the -fPIE option. It  allows for building the relocatable kernel without
-fPIE.  However, if compiler cannot handle unaligned symbols, the kernel
is built with -fPIE.

Patch 4 handles orphan .rela sections when kernel is built with
-fno-PIE.

kpatch tools changes:
* -mno-pic-data-is-text-relative prevents relative addressing between
  code and data. This is needed to avoid relocation error when klp text
  and data are too far apart. kpatch already includes this flag.
  However, with these changes, ARCH_KFLAGS+="-fPIC" should be added to
  s390 kpatch tools, As -mno-pic-data-is-text-relative can be used only
  with -fPIC. The corresponding pull request will be sent to kpatch
  tools.

Thank you,
Sumanth

Josh Poimboeuf (2):
  s390: Add relocs tool
  s390: Compile relocatable kernel without -fPIE

Sumanth Korikkar (2):
  s390/vdso64: filter out munaligned-symbols flag for vdso
  s390/kernel: vmlinux.lds.S: handle orphan .rela sections

 arch/s390/Kconfig                    |  15 +-
 arch/s390/Makefile                   |   8 +-
 arch/s390/boot/.gitignore            |   1 +
 arch/s390/boot/Makefile              |  14 +-
 arch/s390/boot/boot.h                |   6 +
 arch/s390/boot/startup.c             |  80 +++++-
 arch/s390/boot/vmlinux.lds.S         |  18 ++
 arch/s390/include/asm/physmem_info.h |   1 +
 arch/s390/kernel/vdso64/Makefile     |   1 +
 arch/s390/kernel/vmlinux.lds.S       |  15 ++
 arch/s390/tools/.gitignore           |   1 +
 arch/s390/tools/Makefile             |   5 +
 arch/s390/tools/relocs.c             | 390 +++++++++++++++++++++++++++
 13 files changed, 542 insertions(+), 13 deletions(-)
 create mode 100644 arch/s390/tools/relocs.c

-- 
2.40.1





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux