[v3,2/8] riscv: Enable function sections

Message ID 20180423055950.78818-3-agraf@suse.de
State New
Headers show
Series
  • riscv: Enable efi_loader support
Related show

Commit Message

Alexander Graf April 23, 2018, 5:59 a.m.
The linker can remove sections that are never addressed, so it makes a lot
of sense to declare every function as an individual section.

This reduces the output U-Boot code size by ~30kb for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/riscv/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Heinrich Schuchardt April 23, 2018, 7:35 a.m. | #1
On 04/23/2018 07:59 AM, Alexander Graf wrote:
> The linker can remove sections that are never addressed, so it makes a lot
> of sense to declare every function as an individual section.
> 
> This reduces the output U-Boot code size by ~30kb for me.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>   arch/riscv/config.mk | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
> index 6b681c4286..69f4cf6ce8 100644
> --- a/arch/riscv/config.mk
> +++ b/arch/riscv/config.mk
> @@ -29,5 +29,5 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
>   			      -T $(srctree)/examples/standalone/riscv.lds
>   
>   PLATFORM_CPPFLAGS	+= -ffixed-gp -fpic
> -PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
> +PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2 -ffunction-sections

Other architectures also use -fdata-sections.
Why wouldn't we set it for RISC-V?

Cf. 
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/Optimize-Options.html#index-fdata-sections

Regards

Heinrich

>   LDFLAGS_u-boot += --gc-sections -static -pie
>
Alexander Graf April 23, 2018, 5:21 p.m. | #2
On 23.04.18 09:35, Heinrich Schuchardt wrote:
> 
> 
> On 04/23/2018 07:59 AM, Alexander Graf wrote:
>> The linker can remove sections that are never addressed, so it makes a
>> lot
>> of sense to declare every function as an individual section.
>>
>> This reduces the output U-Boot code size by ~30kb for me.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>>   arch/riscv/config.mk | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
>> index 6b681c4286..69f4cf6ce8 100644
>> --- a/arch/riscv/config.mk
>> +++ b/arch/riscv/config.mk
>> @@ -29,5 +29,5 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
>>                     -T $(srctree)/examples/standalone/riscv.lds
>>     PLATFORM_CPPFLAGS    += -ffixed-gp -fpic
>> -PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
>> +PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
>> -ffunction-sections
> 
> Other architectures also use -fdata-sections.
> Why wouldn't we set it for RISC-V?

I think we could. That definitely makes sense as a follow-up patch -
ideally slightly more cross-architecture :).


Alex
rick@andestech.com May 7, 2018, 2:24 a.m. | #3
> -----Original Message-----

> From: Alexander Graf [mailto:agraf@suse.de]

> Sent: Monday, April 23, 2018 2:00 PM

> To: u-boot@lists.denx.de

> Cc: Rick Jian-Zhi Chen(陳建志); Greentime Hu; Philipp Tomsich; Heinrich

> Schuchardt; schwab@suse.de

> Subject: [PATCH v3 2/8] riscv: Enable function sections

>

> The linker can remove sections that are never addressed, so it makes a lot of

> sense to declare every function as an individual section.

>

> This reduces the output U-Boot code size by ~30kb for me.

>

> Signed-off-by: Alexander Graf <agraf@suse.de>

> ---

>  arch/riscv/config.mk | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk index

> 6b681c4286..69f4cf6ce8 100644

> --- a/arch/riscv/config.mk

> +++ b/arch/riscv/config.mk

> @@ -29,5 +29,5 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \

>                             -T $(srctree)/examples/standalone/riscv.lds

>

>  PLATFORM_CPPFLAGS    += -ffixed-gp -fpic

> -PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2

> +PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2

> +-ffunction-sections


Reviewed-by: Rick Chen <rick@andestech.com>


>  LDFLAGS_u-boot += --gc-sections -static -pie

> --

> 2.12.3


CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.

Patch

diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
index 6b681c4286..69f4cf6ce8 100644
--- a/arch/riscv/config.mk
+++ b/arch/riscv/config.mk
@@ -29,5 +29,5 @@  CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
 			      -T $(srctree)/examples/standalone/riscv.lds
 
 PLATFORM_CPPFLAGS	+= -ffixed-gp -fpic
-PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
+PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2 -ffunction-sections
 LDFLAGS_u-boot += --gc-sections -static -pie