mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] lds: Fix alignment of initcall table
@ 2020-01-17  9:50 Christian Eggers
  2020-01-17 10:26 ` Sam Ravnborg
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Eggers @ 2020-01-17  9:50 UTC (permalink / raw)
  To: barebox; +Cc: Christian Eggers, ceggers

[-- Attachment #1: Type: text/plain, Size: 5880 bytes --]

Depending on the preceding *(.rodata*) sections, the contents of the
RO_DATA_SECTION macro may be unaligned.

In my case, the initcall table was unaligned, because the preceding
.rodata ended with the defaultenv when CONFIG_KALLSYMS was set to N.

                0x00000000000b0a00      0x1c2 arch/arm/lib32/built-in.o
 .rodata.unwind_get_byte.str1.1
                0x00000000000b0bc2       0x1e arch/arm/lib32/built-in.o
 .rodata.default_environment
                0x00000000000b0be0       0x1d defaultenv/built-in.o
 .rodata.defaultenv_add_base.part.0.str1.1
                0x00000000000b0bfd       0x35 defaultenv/built-in.o
 .rodata.defaultenv_load.str1.1
                0x00000000000b0c32       0x2b defaultenv/built-in.o
                                         0x36 (size before relaxing)
                0x00000000000b0c5d       <--- oops
                 __barebox_initcalls_start = .
 *(.initcall.0)

Tested on i.MX6 (ARM v7).

Fixes: c5d38e9201 ("lds: Add and use RO_DATA_SECTION macro")
Signed-off-by: Christian Eggers <ceggers@arri.de>
---
 arch/arm/lib32/barebox.lds.S           | 1 +
 arch/arm/lib64/barebox.lds.S           | 1 +
 arch/mips/lib/barebox.lds.S            | 1 +
 arch/nios2/cpu/barebox.lds.S           | 1 +
 arch/openrisc/cpu/barebox.lds.S        | 1 +
 arch/ppc/boards/pcm030/barebox.lds.S   | 1 +
 arch/riscv/lib/barebox.lds.S           | 1 +
 arch/x86/mach-efi/elf_ia32_efi.lds.S   | 1 +
 arch/x86/mach-efi/elf_x86_64_efi.lds.S | 1 +
 9 files changed, 9 insertions(+)

diff --git a/arch/arm/lib32/barebox.lds.S b/arch/arm/lib32/barebox.lds.S
index c479e02e9..e08833d22 100644
--- a/arch/arm/lib32/barebox.lds.S
+++ b/arch/arm/lib32/barebox.lds.S
@@ -57,6 +57,7 @@ SECTIONS
        . = ALIGN(4);
        .rodata : {
                *(.rodata*)
+               . = ALIGN(4);
                RO_DATA_SECTION
        }

diff --git a/arch/arm/lib64/barebox.lds.S b/arch/arm/lib64/barebox.lds.S
index cf6ef1889..f361c7c55 100644
--- a/arch/arm/lib64/barebox.lds.S
+++ b/arch/arm/lib64/barebox.lds.S
@@ -55,6 +55,7 @@ SECTIONS
        . = ALIGN(4);
        .rodata : {
                *(.rodata*)
+               . = ALIGN(4);
                RO_DATA_SECTION
        }

diff --git a/arch/mips/lib/barebox.lds.S b/arch/mips/lib/barebox.lds.S
index e96c3bf6e..331fb0e83 100644
--- a/arch/mips/lib/barebox.lds.S
+++ b/arch/mips/lib/barebox.lds.S
@@ -32,6 +32,7 @@ SECTIONS
        . = ALIGN(4);
        .rodata : {
                *(.rodata*)
+               . = ALIGN(4);
                RO_DATA_SECTION
        }

diff --git a/arch/nios2/cpu/barebox.lds.S b/arch/nios2/cpu/barebox.lds.S
index 8d82aa59e..c7a6626d2 100644
--- a/arch/nios2/cpu/barebox.lds.S
+++ b/arch/nios2/cpu/barebox.lds.S
@@ -51,6 +51,7 @@ SECTIONS

        .rodata : {
                *(.rodata*)
+               . = ALIGN(4);
                RO_DATA_SECTION
        }

diff --git a/arch/openrisc/cpu/barebox.lds.S b/arch/openrisc/cpu/barebox.lds.S
index adb0c22f8..da48c35e5 100644
--- a/arch/openrisc/cpu/barebox.lds.S
+++ b/arch/openrisc/cpu/barebox.lds.S
@@ -49,6 +49,7 @@ SECTIONS
                *(.rodata);
                *(.rodata.*)
                *(.bbenv.rodata.*)
+               . = ALIGN(4);
                RO_DATA_SECTION
        } > ram

diff --git a/arch/ppc/boards/pcm030/barebox.lds.S b/arch/ppc/boards/pcm030/barebox.lds.S
index 6c91ed625..051a94058 100644
--- a/arch/ppc/boards/pcm030/barebox.lds.S
+++ b/arch/ppc/boards/pcm030/barebox.lds.S
@@ -38,6 +38,7 @@ SECTIONS
     *(.rodata*)
     *(.rodata1*)
     *(.rodata.str1.4)
+    . = ALIGN(16);
     RO_DATA_SECTION
   }

diff --git a/arch/riscv/lib/barebox.lds.S b/arch/riscv/lib/barebox.lds.S
index 5149f8ce2..6e6641043 100644
--- a/arch/riscv/lib/barebox.lds.S
+++ b/arch/riscv/lib/barebox.lds.S
@@ -32,6 +32,7 @@ SECTIONS
        . = ALIGN(8);
        .rodata : {
                *(.rodata*)
+               . = ALIGN(8);
                RO_DATA_SECTION
        }

diff --git a/arch/x86/mach-efi/elf_ia32_efi.lds.S b/arch/x86/mach-efi/elf_ia32_efi.lds.S
index 18ddf1780..2232b8d86 100644
--- a/arch/x86/mach-efi/elf_ia32_efi.lds.S
+++ b/arch/x86/mach-efi/elf_ia32_efi.lds.S
@@ -35,6 +35,7 @@ SECTIONS

        .data : {
                *(.rodata*)
+               . = ALIGN(4096);
                RO_DATA_SECTION
                *(.data)
                *(.data1)
diff --git a/arch/x86/mach-efi/elf_x86_64_efi.lds.S b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
index 40a942503..0d42e6ddd 100644
--- a/arch/x86/mach-efi/elf_x86_64_efi.lds.S
+++ b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
@@ -38,6 +38,7 @@ SECTIONS

        .data : {
                *(.rodata*)
+               . = ALIGN(4096);
                RO_DATA_SECTION
                *(.got.plt)
                *(.got)
--
2.16.4

________________________________
 [http://assets.arri.com/media/sign/2019-12-13a-ARRI-E-mail-Signatur-Parkstadt.jpg] <https://www.google.com/maps/place/Herbert-Bayer-Stra%C3%9Fe+10,+80807+M%C3%BCnchen/data=!4m2!3m1!1s0x479e74379489f045:0x4bbf0c7a9e893d66?sa=X&ved=2ahUKEwjjvdSlh8TmAhWIp4sKHe3vDlQQ8gEwAHoECAsQAQ>

Get all the latest information from www.arri.com<https://www.arri.com/>, Facebook<https://www.facebook.com/TeamARRI>, Twitter<https://twitter.com/ARRIChannel>, Instagram<https://instagram.com/arri> and YouTube<https://www.youtube.com/user/ARRIChannel>.

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRA 57918
Persönlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRB 54477
Geschäftsführer: Dr. Michael Neuhäuser; Stephan Schenk; Walter Trauninger; Markus Zeiler


[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] lds: Fix alignment of initcall table
  2020-01-17  9:50 [PATCH] lds: Fix alignment of initcall table Christian Eggers
@ 2020-01-17 10:26 ` Sam Ravnborg
  2020-01-17 11:12   ` Christian Eggers
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2020-01-17 10:26 UTC (permalink / raw)
  To: Christian Eggers; +Cc: barebox, ceggers

Hi Christian.

Thanks for the patch.

On Fri, Jan 17, 2020 at 10:50:13AM +0100, Christian Eggers wrote:
> Depending on the preceding *(.rodata*) sections, the contents of the
> RO_DATA_SECTION macro may be unaligned.
> 
> In my case, the initcall table was unaligned, because the preceding
> .rodata ended with the defaultenv when CONFIG_KALLSYMS was set to N.
> 
>                 0x00000000000b0a00      0x1c2 arch/arm/lib32/built-in.o
>  .rodata.unwind_get_byte.str1.1
>                 0x00000000000b0bc2       0x1e arch/arm/lib32/built-in.o
>  .rodata.default_environment
>                 0x00000000000b0be0       0x1d defaultenv/built-in.o
>  .rodata.defaultenv_add_base.part.0.str1.1
>                 0x00000000000b0bfd       0x35 defaultenv/built-in.o
>  .rodata.defaultenv_load.str1.1
>                 0x00000000000b0c32       0x2b defaultenv/built-in.o
>                                          0x36 (size before relaxing)
>                 0x00000000000b0c5d       <--- oops
>                  __barebox_initcalls_start = .
>  *(.initcall.0)
> 
> Tested on i.MX6 (ARM v7).
> 
> Fixes: c5d38e9201 ("lds: Add and use RO_DATA_SECTION macro")
> Signed-off-by: Christian Eggers <ceggers@arri.de>

Have you seen:
d5f8bd9c503e0a17ef071eec50c537cc82a7956c ("lds: align RO_DATA_SECTION members")
which was recently committed to master?

It looks like the two patches fixes the same.
Expect that you have much higher alignment demands in a few cases (ia32, x86).

Could you verify if things works on latest master or you still need
additional alignment?

Thanks,
	Sam

> +++ b/arch/x86/mach-efi/elf_ia32_efi.lds.S
> @@ -35,6 +35,7 @@ SECTIONS
> 
>         .data : {
>                 *(.rodata*)
> +               . = ALIGN(4096);
>                 RO_DATA_SECTION
>                 *(.data)
>                 *(.data1)
> diff --git a/arch/x86/mach-efi/elf_x86_64_efi.lds.S b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
> index 40a942503..0d42e6ddd 100644
> --- a/arch/x86/mach-efi/elf_x86_64_efi.lds.S
> +++ b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
> @@ -38,6 +38,7 @@ SECTIONS
> 
>         .data : {
>                 *(.rodata*)
> +               . = ALIGN(4096);
>                 RO_DATA_SECTION
>                 *(.got.plt)
>                 *(.got)


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] lds: Fix alignment of initcall table
  2020-01-17 10:26 ` Sam Ravnborg
@ 2020-01-17 11:12   ` Christian Eggers
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Eggers @ 2020-01-17 11:12 UTC (permalink / raw)
  To: ceggers; +Cc: barebox

Hi Sam,

Am Freitag, 17. Januar 2020, 11:26:37 CET schrieben Sie:
> Hi Christian.
>
> Thanks for the patch.
>
> [...]
> Have you seen:
> d5f8bd9c503e0a17ef071eec50c537cc82a7956c ("lds: align RO_DATA_SECTION
> members") which was recently committed to master?
unfortunately I haven't. I started development 2 days before 2020.01 has
been released...

> It looks like the two patches fixes the same.
> Expect that you have much higher alignment demands in a few cases (ia32,
> x86).
I have no demands for other architectures than ARMv7, I only took
the alignment values from the other .align() statements in the platform
linker scripts.

> Could you verify if things works on latest master or you still need
> additional alignment?
Barebox 2020.01 works find without my patch. So you can drop it.

regards
Christian



________________________________
 [http://assets.arri.com/media/sign/2019-12-13a-ARRI-E-mail-Signatur-Parkstadt.jpg] <https://www.google.com/maps/place/Herbert-Bayer-Stra%C3%9Fe+10,+80807+M%C3%BCnchen/data=!4m2!3m1!1s0x479e74379489f045:0x4bbf0c7a9e893d66?sa=X&ved=2ahUKEwjjvdSlh8TmAhWIp4sKHe3vDlQQ8gEwAHoECAsQAQ>

Get all the latest information from www.arri.com<https://www.arri.com/>, Facebook<https://www.facebook.com/TeamARRI>, Twitter<https://twitter.com/ARRIChannel>, Instagram<https://instagram.com/arri> and YouTube<https://www.youtube.com/user/ARRIChannel>.

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRA 57918
Persönlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRB 54477
Geschäftsführer: Dr. Michael Neuhäuser; Stephan Schenk; Walter Trauninger; Markus Zeiler

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2020-01-17 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17  9:50 [PATCH] lds: Fix alignment of initcall table Christian Eggers
2020-01-17 10:26 ` Sam Ravnborg
2020-01-17 11:12   ` Christian Eggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox