diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2018-12-03 20:58:05 +0100 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2020-01-02 13:27:18 +0900 |
commit | acec9a12b2f44a535911b6ac79e3752d7790fe79 (patch) | |
tree | 1b048b97f1285220a1e25ca8c2148663cfa5663c | |
parent | 1ef0132a611b2b66bae620bd738352380339ded4 (diff) | |
download | linux-artik7-acec9a12b2f44a535911b6ac79e3752d7790fe79.tar.gz linux-artik7-acec9a12b2f44a535911b6ac79e3752d7790fe79.tar.bz2 linux-artik7-acec9a12b2f44a535911b6ac79e3752d7790fe79.zip |
arm64: relocatable: fix inconsistencies in linker script and optionssubmit/tizen/20200102.014302accepted/tizen/unified/20200102.220841
commit 3bbd3db86470c701091fb1d67f1fab6621debf50 upstream.
readelf complains about the section layout of vmlinux when building
with CONFIG_RELOCATABLE=y (for KASLR):
readelf: Warning: [21]: Link field (0) should index a symtab section.
readelf: Warning: [21]: Info field (0) should index a relocatable section.
Also, it seems that our use of '-pie -shared' is contradictory, and
thus ambiguous. In general, the way KASLR is wired up at the moment
is highly tailored to how ld.bfd happens to implement (and conflate)
PIE executables and shared libraries, so given the current effort to
support other toolchains, let's fix some of these issues as well.
- Drop the -pie linker argument and just leave -shared. In ld.bfd,
the differences between them are unclear (except for the ELF type
of the produced image [0]) but lld chokes on seeing both at the
same time.
- Rename the .rela output section to .rela.dyn, as is customary for
shared libraries and PIE executables, so that it is not misidentified
by readelf as a static relocation section (producing the warnings
above).
- Pass the -z notext and -z norelro options to explicitly instruct the
linker to permit text relocations, and to omit the RELRO program
header (which requires a certain section layout that we don't adhere
to in the kernel). These are the defaults for current versions of
ld.bfd.
- Discard .eh_frame and .gnu.hash sections to avoid them from being
emitted between .head.text and .text, screwing up the section layout.
These changes only affect the ELF image, and produce the same binary
image.
[0] b9dce7f1ba01 ("arm64: kernel: force ET_DYN ELF type for ...")
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Smith <peter.smith@linaro.org>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Found solution for Tizen 6.0 toolchain by Mikhail Kashkarov <m.kashkarov@partner.samsung.com> ]
[sw0312.kim: backport stable linux-4.14.y commit f21ce3cdff2f for gcc 9 built image
- only apply only section discarding part]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I0ddfedad20188dcd9d7b416370e95d175b595db0
-rw-r--r-- | arch/arm64/kernel/vmlinux.lds.S | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 71426a78db12..d240acfb7e5a 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -87,6 +87,7 @@ SECTIONS EXIT_CALL *(.discard) *(.discard.*) + *(.eh_frame) } . = PAGE_OFFSET + TEXT_OFFSET; |