Message ID | 20201017000151.150788-1-morbo@google.com (mailing list archive) |
---|---|
State | Accepted |
Commit | a538d184e3f0e3b5f800c5ab148e83bb5cdd0133 |
Headers | show |
Series | powerpc/boot: move the .got section to after the .dynamic section | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | Successfully applied on branch powerpc/merge (4fa6f5d55f64e974784cfc8f38312d48479a4323) |
snowpatch_ozlabs/build-ppc64le | warning | Upstream build failed, couldn't test patch |
snowpatch_ozlabs/build-ppc64be | warning | Upstream build failed, couldn't test patch |
snowpatch_ozlabs/build-ppc64e | warning | Upstream build failed, couldn't test patch |
snowpatch_ozlabs/build-pmac32 | warning | Upstream build failed, couldn't test patch |
snowpatch_ozlabs/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 33 lines checked |
snowpatch_ozlabs/needsstable | success | Patch has no Fixes tags |
On Fri, Oct 16, 2020 at 5:01 PM Bill Wendling <morbo@google.com> wrote: > > Both .dynamic and .got are RELRO sections and should be placed together, > and LLD emits an error: > > ld.lld: error: section: .got is not contiguous with other relro sections > > Place them together to avoid this. > > Cc: Fangrui Song <maskray@google.com> > Cc: Alan Modra <amodra@gmail.com> > Signed-off-by: Bill Wendling <morbo@google.com> > --- > arch/powerpc/boot/zImage.lds.S | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > > diff --git a/arch/powerpc/boot/zImage.lds.S b/arch/powerpc/boot/zImage.lds.S > index a21f3a76e06f..d6f072865627 100644 > --- a/arch/powerpc/boot/zImage.lds.S > +++ b/arch/powerpc/boot/zImage.lds.S > @@ -34,6 +34,17 @@ SECTIONS > __dynamic_start = .; > *(.dynamic) > } > + > +#ifdef CONFIG_PPC64_BOOT_WRAPPER > + . = ALIGN(256); > + .got : > + { > + __toc_start = .; > + *(.got) > + *(.toc) > + } > +#endif > + > .hash : { *(.hash) } > .interp : { *(.interp) } > .rela.dyn : > @@ -76,16 +87,6 @@ SECTIONS > _esm_blob_end = .; > } > > -#ifdef CONFIG_PPC64_BOOT_WRAPPER > - . = ALIGN(256); > - .got : > - { > - __toc_start = .; > - *(.got) > - *(.toc) > - } > -#endif The kernel does not require this but normally all read-only sections precede SHF_WRITE sections. .dynamic and .got have the SHF_WRITE flag and should be placed here. Ideally, the order is: R RX RW(RELRO) RW(non-RELRO) (LLD order) For comparison: GNU ld -z separate-code order: R RX R RW(RELRO) RW(non-RELRO) (GNU ld>=2.31 enables -z separate-code by default for Linux x86) GNU ld -z noseparate-code order: RX RW(RELRO) RW(non-RELRO) (AFAIK The only reason .dynamic is writable is due to DT_DEBUG (whose purpose is questionable nowadays). mips .dynamic is read-only. LLD has an option -z rodynamic to make .dynamic readonly) > . = ALIGN(4096); > .bss : > { > -- > 2.29.0.rc1.297.gfa9743e501-goog >
On Fri, 16 Oct 2020 17:01:51 -0700, Bill Wendling wrote: > Both .dynamic and .got are RELRO sections and should be placed together, > and LLD emits an error: > > ld.lld: error: section: .got is not contiguous with other relro sections > > Place them together to avoid this. Applied to powerpc/next. [1/1] powerpc/boot: Move the .got section to after the .dynamic section https://git.kernel.org/powerpc/c/a538d184e3f0e3b5f800c5ab148e83bb5cdd0133 cheers
diff --git a/arch/powerpc/boot/zImage.lds.S b/arch/powerpc/boot/zImage.lds.S index a21f3a76e06f..d6f072865627 100644 --- a/arch/powerpc/boot/zImage.lds.S +++ b/arch/powerpc/boot/zImage.lds.S @@ -34,6 +34,17 @@ SECTIONS __dynamic_start = .; *(.dynamic) } + +#ifdef CONFIG_PPC64_BOOT_WRAPPER + . = ALIGN(256); + .got : + { + __toc_start = .; + *(.got) + *(.toc) + } +#endif + .hash : { *(.hash) } .interp : { *(.interp) } .rela.dyn : @@ -76,16 +87,6 @@ SECTIONS _esm_blob_end = .; } -#ifdef CONFIG_PPC64_BOOT_WRAPPER - . = ALIGN(256); - .got : - { - __toc_start = .; - *(.got) - *(.toc) - } -#endif - . = ALIGN(4096); .bss : {
Both .dynamic and .got are RELRO sections and should be placed together, and LLD emits an error: ld.lld: error: section: .got is not contiguous with other relro sections Place them together to avoid this. Cc: Fangrui Song <maskray@google.com> Cc: Alan Modra <amodra@gmail.com> Signed-off-by: Bill Wendling <morbo@google.com> --- arch/powerpc/boot/zImage.lds.S | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)