All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash
@ 2020-02-27  4:59 Michael Ellerman
  2020-02-27  4:59 ` [PATCH 2/2] powerpc/vmlinux.lds: Discard .interp section Michael Ellerman
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michael Ellerman @ 2020-02-27  4:59 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: joel, amodra

Relocatable kernel builds produce a warning about .gnu.hash being an
orphan section:

  ld: warning: orphan section `.gnu.hash' from `linker stubs' being placed in section `.gnu.hash'

If we try to discard it the build fails:

  ld -EL -m elf64lppc -pie --orphan-handling=warn --build-id -o
    .tmp_vmlinux1 -T ./arch/powerpc/kernel/vmlinux.lds --whole-archive
    arch/powerpc/kernel/head_64.o arch/powerpc/kernel/entry_64.o
    ...
    sound/built-in.a net/built-in.a virt/built-in.a --no-whole-archive
    --start-group lib/lib.a --end-group
  ld: could not find section .gnu.hash

So add an entry to explicitly retain it, as we do for .hash.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/vmlinux.lds.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index b4c89a1acebb..31a0f201fb6f 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -256,6 +256,7 @@ SECTIONS
 		*(.dynamic)
 	}
 	.hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
+	.gnu.hash : AT(ADDR(.gnu.hash) - LOAD_OFFSET) { *(.gnu.hash) }
 	.interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
 	.rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
 	{
-- 
2.21.1


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

* [PATCH 2/2] powerpc/vmlinux.lds: Discard .interp section
  2020-02-27  4:59 [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash Michael Ellerman
@ 2020-02-27  4:59 ` Michael Ellerman
  2020-02-27  6:27   ` Alan Modra
  2020-02-27  6:21 ` [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash Alan Modra
  2020-04-01 12:53 ` Michael Ellerman
  2 siblings, 1 reply; 7+ messages in thread
From: Michael Ellerman @ 2020-02-27  4:59 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: joel, amodra

The .interp section specifies which "interpreter", ie. dynamic loader,
the kernel requests. But that doesn't make any sense, the kernel is
not a regular binary that is run with an interpreter.

The content seems to be some default value, this file doesn't even
exist on my system:
  00000000  2f 75 73 72 2f 6c 69 62  2f 6c 64 2e 73 6f 2e 31  |/usr/lib/ld.so.1|

So the section serves no useful purpose and consumes a small amount of
space.

Also Alan Modra says we "likely could discard" it, so do so.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/vmlinux.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 31a0f201fb6f..619ffbaf72ad 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -257,7 +257,6 @@ SECTIONS
 	}
 	.hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
 	.gnu.hash : AT(ADDR(.gnu.hash) - LOAD_OFFSET) { *(.gnu.hash) }
-	.interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
 	.rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
 	{
 		__rela_dyn_start = .;
@@ -370,5 +369,6 @@ SECTIONS
 		*(.gnu.version*)
 		*(.gnu.attributes)
 		*(.eh_frame)
+		*(.interp)
 	}
 }
-- 
2.21.1


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

* Re: [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash
  2020-02-27  4:59 [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash Michael Ellerman
  2020-02-27  4:59 ` [PATCH 2/2] powerpc/vmlinux.lds: Discard .interp section Michael Ellerman
@ 2020-02-27  6:21 ` Alan Modra
  2020-03-27  9:29   ` Michael Ellerman
  2020-04-01 12:53 ` Michael Ellerman
  2 siblings, 1 reply; 7+ messages in thread
From: Alan Modra @ 2020-02-27  6:21 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, joel

On Thu, Feb 27, 2020 at 03:59:32PM +1100, Michael Ellerman wrote:
> Relocatable kernel builds produce a warning about .gnu.hash being an
> orphan section:
> 
>   ld: warning: orphan section `.gnu.hash' from `linker stubs' being placed in section `.gnu.hash'
> 
> If we try to discard it the build fails:
> 
>   ld -EL -m elf64lppc -pie --orphan-handling=warn --build-id -o
>     .tmp_vmlinux1 -T ./arch/powerpc/kernel/vmlinux.lds --whole-archive
>     arch/powerpc/kernel/head_64.o arch/powerpc/kernel/entry_64.o
>     ...
>     sound/built-in.a net/built-in.a virt/built-in.a --no-whole-archive
>     --start-group lib/lib.a --end-group
>   ld: could not find section .gnu.hash
> 
> So add an entry to explicitly retain it, as we do for .hash.

Looks fine to me.  You can also pass --hash-style=sysv to ld (since
binutils-2.18) to disable generation of .gnu.hash.

> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/kernel/vmlinux.lds.S | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index b4c89a1acebb..31a0f201fb6f 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -256,6 +256,7 @@ SECTIONS
>  		*(.dynamic)
>  	}
>  	.hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
> +	.gnu.hash : AT(ADDR(.gnu.hash) - LOAD_OFFSET) { *(.gnu.hash) }
>  	.interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
>  	.rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
>  	{
> -- 
> 2.21.1

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [PATCH 2/2] powerpc/vmlinux.lds: Discard .interp section
  2020-02-27  4:59 ` [PATCH 2/2] powerpc/vmlinux.lds: Discard .interp section Michael Ellerman
@ 2020-02-27  6:27   ` Alan Modra
  2020-03-27  9:27     ` Michael Ellerman
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Modra @ 2020-02-27  6:27 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, joel

On Thu, Feb 27, 2020 at 03:59:33PM +1100, Michael Ellerman wrote:
> The .interp section specifies which "interpreter", ie. dynamic loader,
> the kernel requests. But that doesn't make any sense, the kernel is
> not a regular binary that is run with an interpreter.
> 
> The content seems to be some default value, this file doesn't even
> exist on my system:
>   00000000  2f 75 73 72 2f 6c 69 62  2f 6c 64 2e 73 6f 2e 31  |/usr/lib/ld.so.1|
> 
> So the section serves no useful purpose and consumes a small amount of
> space.
> 
> Also Alan Modra says we "likely could discard" it, so do so.

Yes, but you ought to check with the mimimum required binutils.  It is
quite possible that an older linker will blow up.

If the minimum required binutils is at least binutils-2.26 then
passing --no-dynamic-linker to ld is a more elegant solution.

> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/kernel/vmlinux.lds.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index 31a0f201fb6f..619ffbaf72ad 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -257,7 +257,6 @@ SECTIONS
>  	}
>  	.hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
>  	.gnu.hash : AT(ADDR(.gnu.hash) - LOAD_OFFSET) { *(.gnu.hash) }
> -	.interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
>  	.rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
>  	{
>  		__rela_dyn_start = .;
> @@ -370,5 +369,6 @@ SECTIONS
>  		*(.gnu.version*)
>  		*(.gnu.attributes)
>  		*(.eh_frame)
> +		*(.interp)
>  	}
>  }
> -- 
> 2.21.1

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [PATCH 2/2] powerpc/vmlinux.lds: Discard .interp section
  2020-02-27  6:27   ` Alan Modra
@ 2020-03-27  9:27     ` Michael Ellerman
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2020-03-27  9:27 UTC (permalink / raw)
  To: Alan Modra; +Cc: linuxppc-dev, joel

Alan Modra <amodra@gmail.com> writes:
> On Thu, Feb 27, 2020 at 03:59:33PM +1100, Michael Ellerman wrote:
>> The .interp section specifies which "interpreter", ie. dynamic loader,
>> the kernel requests. But that doesn't make any sense, the kernel is
>> not a regular binary that is run with an interpreter.
>> 
>> The content seems to be some default value, this file doesn't even
>> exist on my system:
>>   00000000  2f 75 73 72 2f 6c 69 62  2f 6c 64 2e 73 6f 2e 31  |/usr/lib/ld.so.1|
>> 
>> So the section serves no useful purpose and consumes a small amount of
>> space.
>> 
>> Also Alan Modra says we "likely could discard" it, so do so.
>
> Yes, but you ought to check with the mimimum required binutils.  It is
> quite possible that an older linker will blow up.

OK, I guess I'll have to test.

> If the minimum required binutils is at least binutils-2.26 then
> passing --no-dynamic-linker to ld is a more elegant solution.

The current minimum is 2.21, though there's talk of increasing it to
2.23.

cheers

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

* Re: [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash
  2020-02-27  6:21 ` [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash Alan Modra
@ 2020-03-27  9:29   ` Michael Ellerman
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2020-03-27  9:29 UTC (permalink / raw)
  To: Alan Modra; +Cc: linuxppc-dev, joel

Alan Modra <amodra@gmail.com> writes:
> On Thu, Feb 27, 2020 at 03:59:32PM +1100, Michael Ellerman wrote:
>> Relocatable kernel builds produce a warning about .gnu.hash being an
>> orphan section:
>> 
>>   ld: warning: orphan section `.gnu.hash' from `linker stubs' being placed in section `.gnu.hash'
>> 
>> If we try to discard it the build fails:
>> 
>>   ld -EL -m elf64lppc -pie --orphan-handling=warn --build-id -o
>>     .tmp_vmlinux1 -T ./arch/powerpc/kernel/vmlinux.lds --whole-archive
>>     arch/powerpc/kernel/head_64.o arch/powerpc/kernel/entry_64.o
>>     ...
>>     sound/built-in.a net/built-in.a virt/built-in.a --no-whole-archive
>>     --start-group lib/lib.a --end-group
>>   ld: could not find section .gnu.hash
>> 
>> So add an entry to explicitly retain it, as we do for .hash.
>
> Looks fine to me.  You can also pass --hash-style=sysv to ld (since
> binutils-2.18) to disable generation of .gnu.hash.

Our current minimum is 2.21, so that's probably 5-10 years away :)

cheers

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

* Re: [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash
  2020-02-27  4:59 [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash Michael Ellerman
  2020-02-27  4:59 ` [PATCH 2/2] powerpc/vmlinux.lds: Discard .interp section Michael Ellerman
  2020-02-27  6:21 ` [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash Alan Modra
@ 2020-04-01 12:53 ` Michael Ellerman
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2020-04-01 12:53 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: joel, amodra

On Thu, 2020-02-27 at 04:59:32 UTC, Michael Ellerman wrote:
> Relocatable kernel builds produce a warning about .gnu.hash being an
> orphan section:
> 
>   ld: warning: orphan section `.gnu.hash' from `linker stubs' being placed in section `.gnu.hash'
> 
> If we try to discard it the build fails:
> 
>   ld -EL -m elf64lppc -pie --orphan-handling=warn --build-id -o
>     .tmp_vmlinux1 -T ./arch/powerpc/kernel/vmlinux.lds --whole-archive
>     arch/powerpc/kernel/head_64.o arch/powerpc/kernel/entry_64.o
>     ...
>     sound/built-in.a net/built-in.a virt/built-in.a --no-whole-archive
>     --start-group lib/lib.a --end-group
>   ld: could not find section .gnu.hash
> 
> So add an entry to explicitly retain it, as we do for .hash.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Applied to powerpc next.

https://git.kernel.org/powerpc/c/ead983604c5a390f1e3ce085945b60e82f08dbbe

cheers

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

end of thread, other threads:[~2020-04-01 13:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-27  4:59 [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash Michael Ellerman
2020-02-27  4:59 ` [PATCH 2/2] powerpc/vmlinux.lds: Discard .interp section Michael Ellerman
2020-02-27  6:27   ` Alan Modra
2020-03-27  9:27     ` Michael Ellerman
2020-02-27  6:21 ` [PATCH 1/2] powerpc/vmlinux.lds: Explicitly retain .gnu.hash Alan Modra
2020-03-27  9:29   ` Michael Ellerman
2020-04-01 12:53 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.