diff mbox series

[v2,6/7] powerpc/64/build: merge .got and .toc input sections

Message ID 20220916040755.2398112-7-npiggin@gmail.com (mailing list archive)
State Accepted
Headers show
Series powerpc: build / linker improvements | expand

Commit Message

Nicholas Piggin Sept. 16, 2022, 4:07 a.m. UTC
Follow the binutils ld internal linker script and merge .got and .toc
input sections in the .got output section.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/vmlinux.lds.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Christophe Leroy Sept. 16, 2022, 6:45 p.m. UTC | #1
Le 16/09/2022 à 06:07, Nicholas Piggin a écrit :
> Follow the binutils ld internal linker script and merge .got and .toc
> input sections in the .got output section.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>   arch/powerpc/kernel/vmlinux.lds.S | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index 737825ae2ae0..3d96d51c8a5f 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -169,13 +169,12 @@ SECTIONS
>   	}
>   
>   	.got : AT(ADDR(.got) - LOAD_OFFSET) ALIGN(256) {
> -		*(.got)
> +		*(.got .toc)

At the begining I was thinking that this change would jeopardise the 
below, but in fact the #ifdef below is pointless, because prom_init.o is 
built only when CONFIG_PPC_OF_BOOT_TRAMPOLINE is selected but 
CONFIG_PPC_OF_BOOT_TRAMPOLINE selects CONFIG_RELOCATABLE

So all __prom_init_toc_ stuff can go away :

arch/powerpc/include/asm/sections.h:extern char __prom_init_toc_start[];
arch/powerpc/include/asm/sections.h:extern char __prom_init_toc_end[];
arch/powerpc/kernel/prom_init_check.sh:__prom_init_toc_start 
__prom_init_toc_end btext_setup_display TOC.
arch/powerpc/kernel/vmlinux.lds.S:              __prom_init_toc_start = .;
arch/powerpc/kernel/vmlinux.lds.S:              __prom_init_toc_end = .;


>   #ifndef CONFIG_RELOCATABLE
>   		__prom_init_toc_start = .;
>   		arch/powerpc/kernel/prom_init.o*(.toc)
>   		__prom_init_toc_end = .;
>   #endif
> -		*(.toc)
>   	}
>   
>   	SOFT_MASK_TABLE(8)
Michael Ellerman Sept. 17, 2022, 6:36 a.m. UTC | #2
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 16/09/2022 à 06:07, Nicholas Piggin a écrit :
>> Follow the binutils ld internal linker script and merge .got and .toc
>> input sections in the .got output section.
>> 
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>>   arch/powerpc/kernel/vmlinux.lds.S | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
>> index 737825ae2ae0..3d96d51c8a5f 100644
>> --- a/arch/powerpc/kernel/vmlinux.lds.S
>> +++ b/arch/powerpc/kernel/vmlinux.lds.S
>> @@ -169,13 +169,12 @@ SECTIONS
>>   	}
>>   
>>   	.got : AT(ADDR(.got) - LOAD_OFFSET) ALIGN(256) {
>> -		*(.got)
>> +		*(.got .toc)
>
> At the begining I was thinking that this change would jeopardise the 
> below, but in fact the #ifdef below is pointless, because prom_init.o is 
> built only when CONFIG_PPC_OF_BOOT_TRAMPOLINE is selected but 
> CONFIG_PPC_OF_BOOT_TRAMPOLINE selects CONFIG_RELOCATABLE
>
> So all __prom_init_toc_ stuff can go away :
>
> arch/powerpc/include/asm/sections.h:extern char __prom_init_toc_start[];
> arch/powerpc/include/asm/sections.h:extern char __prom_init_toc_end[];
> arch/powerpc/kernel/prom_init_check.sh:__prom_init_toc_start 
> __prom_init_toc_end btext_setup_display TOC.
> arch/powerpc/kernel/vmlinux.lds.S:              __prom_init_toc_start = .;
> arch/powerpc/kernel/vmlinux.lds.S:              __prom_init_toc_end = .;

Yes you're right.

Missed cleanup by me in 24d33ac5b8ff ("powerpc/64s: Make prom_init require RELOCATABLE").

I'll send a patch tomorrow.

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 737825ae2ae0..3d96d51c8a5f 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -169,13 +169,12 @@  SECTIONS
 	}
 
 	.got : AT(ADDR(.got) - LOAD_OFFSET) ALIGN(256) {
-		*(.got)
+		*(.got .toc)
 #ifndef CONFIG_RELOCATABLE
 		__prom_init_toc_start = .;
 		arch/powerpc/kernel/prom_init.o*(.toc)
 		__prom_init_toc_end = .;
 #endif
-		*(.toc)
 	}
 
 	SOFT_MASK_TABLE(8)