LinuxPPC-Dev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] powerpc/boot: move the .got section to after the .dynamic section
@ 2020-10-17  0:01 Bill Wendling
  2020-10-19 23:56 ` Fāng-ruì Sòng
  0 siblings, 1 reply; 2+ messages in thread
From: Bill Wendling @ 2020-10-17  0:01 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Fangrui Song, Alan Modra, Paul Mackerras, Bill Wendling

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
-
   . = ALIGN(4096);
   .bss       :
   {
-- 
2.29.0.rc1.297.gfa9743e501-goog


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] powerpc/boot: move the .got section to after the .dynamic section
  2020-10-17  0:01 [PATCH] powerpc/boot: move the .got section to after the .dynamic section Bill Wendling
@ 2020-10-19 23:56 ` Fāng-ruì Sòng
  0 siblings, 0 replies; 2+ messages in thread
From: Fāng-ruì Sòng @ 2020-10-19 23:56 UTC (permalink / raw)
  To: Bill Wendling; +Cc: Alan Modra, linuxppc-dev, Paul Mackerras

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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-17  0:01 [PATCH] powerpc/boot: move the .got section to after the .dynamic section Bill Wendling
2020-10-19 23:56 ` Fāng-ruì Sòng

LinuxPPC-Dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linuxppc-dev/0 linuxppc-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linuxppc-dev linuxppc-dev/ https://lore.kernel.org/linuxppc-dev \
		linuxppc-dev@lists.ozlabs.org linuxppc-dev@ozlabs.org
	public-inbox-index linuxppc-dev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linuxppc-dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git