Patchwork [v3,1/7] arch: toolchain: Introduce binary formats BINFMT_*.

login
register
mail settings
Submitter Sonic Zhang
Date April 9, 2013, 6:29 a.m.
Message ID <1365488988-21604-1-git-send-email-sonic.adi@gmail.com>
Download mbox | patch
Permalink /patch/234965/
State Changes Requested
Headers show

Comments

Sonic Zhang - April 9, 2013, 6:29 a.m.
From: Sonic Zhang <sonic.zhang@analog.com>

v3-changes:
- Rename the BINFMT dependency names in external toolchain config file.
- Add some help text to BINFMT macros.

v2-changes:
none

v1-changes:
- Just introduce the symbol and options in arch generic Config.in.
Append FLAT format link flags to external toolchain wrapper.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 arch/Config.in                                     |   29 ++++++++++++++++++++
 toolchain/toolchain-external/Config.in             |   12 ++++----
 toolchain/toolchain-external/ext-tool.mk           |    4 +++
 .../toolchain-external/ext-toolchain-wrapper.c     |    3 ++
 4 files changed, 42 insertions(+), 6 deletions(-)
Arnout Vandecappelle - April 10, 2013, 6:11 a.m.
Hi Sonic,

On 09/04/13 08:29, Sonic Zhang wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> v3-changes:

  Please put your changelog below the Signed-off-by line, separated by ---
This way, the changelog doesn't appear in the final git commit log (it's 
anyway not relevant anymore).

> - Rename the BINFMT dependency names in external toolchain config file.
> - Add some help text to BINFMT macros.
>
> v2-changes:
> none
>
> v1-changes:
> - Just introduce the symbol and options in arch generic Config.in.
> Append FLAT format link flags to external toolchain wrapper.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
>   arch/Config.in                                     |   29 ++++++++++++++++++++
>   toolchain/toolchain-external/Config.in             |   12 ++++----
>   toolchain/toolchain-external/ext-tool.mk           |    4 +++
>   .../toolchain-external/ext-toolchain-wrapper.c     |    3 ++
>   4 files changed, 42 insertions(+), 6 deletions(-)
>
> diff --git a/arch/Config.in b/arch/Config.in
> index 472b10c..5dd6467 100644
> --- a/arch/Config.in
> +++ b/arch/Config.in
> @@ -174,6 +174,35 @@ config BR2_GCC_TARGET_ABI
>   config BR2_GCC_TARGET_CPU
>   	string
>
> +# Set up target binary format
> +choice
> +	prompt "Target Binary Format"

  I don't really like to have this choice-which-isn't-really-a-choice for 
all platforms. I think the following should work:

	prompt "Target Binary Format" if BR2_bfin

> +	default BR2_BINFMT_ELF

  There should be a default for blackfin as well. So either put

	default BR2_BINFMT_FDPIC if BR2_bfin
	default BR2_BINFMT_ELF

  or alternatively you can put a 'default y' at the appropriate places below.


> +config BR2_BINFMT_ELF

  This symbol isn't used anywhere. Does it make sense to have it? We only 
need a binfmt choice on platforms that offer the choice, right?

> +	bool "ELF"
> +	depends on !BR2_bfin
> +	help
> +	  ELF (Executable and Linkable Format) is a format for libraries and
> +	  executables used across different architectures and operating
> +	  systems.

  An empty line between the config options would be nice.

> +config BR2_BINFMT_FDPIC
> +	bool "FDPIC"
> +	depends on BR2_bfin
> +	help
> +	  ELF FDPIC binaries are based on ELF, but allow the individual load
> +	  segments of a binary to be located in memory independently of each
> +	  other. This makes this format ideal for use in environments where no
> +	  MMU is available.

  I like this help text! It's very clear.

  Regards,
  Arnout

> +config BR2_BINFMT_FLAT
> +	bool "FLAT"
> +	depends on BR2_bfin
> +	select BR2_PREFER_STATIC_LIB
> +	help
> +	  FLAT binary is a relatively simple and lightweight executable format
> +	  based on the original a.out format. It is widely used in environment
> +	  where no MMU is available.
> +endchoice
> +
>   if BR2_arm || BR2_armeb
>   source "arch/Config.in.arm"
>   endif
[snip]
Sonic Zhang - April 10, 2013, 7:10 a.m.
Hi Arnout,

On Wed, Apr 10, 2013 at 2:11 PM, Arnout Vandecappelle <arnout@mind.be> wrote:
>  Hi Sonic,
>
>
> On 09/04/13 08:29, Sonic Zhang wrote:
>>
>> From: Sonic Zhang <sonic.zhang@analog.com>
>>
>> v3-changes:
>
>
>  Please put your changelog below the Signed-off-by line, separated by ---
> This way, the changelog doesn't appear in the final git commit log (it's
> anyway not relevant anymore).
>

OK.

>
>> - Rename the BINFMT dependency names in external toolchain config file.
>> - Add some help text to BINFMT macros.
>>
>> v2-changes:
>> none
>>
>> v1-changes:
>> - Just introduce the symbol and options in arch generic Config.in.
>> Append FLAT format link flags to external toolchain wrapper.
>>
>> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
>> ---
>>   arch/Config.in                                     |   29
>> ++++++++++++++++++++
>>   toolchain/toolchain-external/Config.in             |   12 ++++----
>>   toolchain/toolchain-external/ext-tool.mk           |    4 +++
>>   .../toolchain-external/ext-toolchain-wrapper.c     |    3 ++
>>   4 files changed, 42 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/Config.in b/arch/Config.in
>> index 472b10c..5dd6467 100644
>> --- a/arch/Config.in
>> +++ b/arch/Config.in
>> @@ -174,6 +174,35 @@ config BR2_GCC_TARGET_ABI
>>   config BR2_GCC_TARGET_CPU
>>         string
>>
>> +# Set up target binary format
>> +choice
>> +       prompt "Target Binary Format"
>
>
>  I don't really like to have this choice-which-isn't-really-a-choice for all
> platforms. I think the following should work:
>
>         prompt "Target Binary Format" if BR2_bfin
>

Thomas suggests to have this BINFMT macro for all architectures. If
you disagree, could you and Thomas make an agreement?


>> +       default BR2_BINFMT_ELF
>
>
>  There should be a default for blackfin as well. So either put
>
>         default BR2_BINFMT_FDPIC if BR2_bfin
>         default BR2_BINFMT_ELF
>
>  or alternatively you can put a 'default y' at the appropriate places below.
>
>
>> +config BR2_BINFMT_ELF
>

OK

>
>  This symbol isn't used anywhere. Does it make sense to have it? We only
> need a binfmt choice on platforms that offer the choice, right?
>

Symbol "ELF" is also suggested by Thomas. I am fine to both ways.

>
>> +       bool "ELF"
>> +       depends on !BR2_bfin
>> +       help
>> +         ELF (Executable and Linkable Format) is a format for libraries
>> and
>> +         executables used across different architectures and operating
>> +         systems.
>
>
>  An empty line between the config options would be nice.
>

OK.

>
>> +config BR2_BINFMT_FDPIC
>> +       bool "FDPIC"
>> +       depends on BR2_bfin
>> +       help
>> +         ELF FDPIC binaries are based on ELF, but allow the individual
>> load
>> +         segments of a binary to be located in memory independently of
>> each
>> +         other. This makes this format ideal for use in environments
>> where no
>> +         MMU is available.
>
>
>  I like this help text! It's very clear.
>
>  Regards,
>  Arnout
>
>
>> +config BR2_BINFMT_FLAT
>> +       bool "FLAT"
>> +       depends on BR2_bfin
>> +       select BR2_PREFER_STATIC_LIB
>> +       help
>> +         FLAT binary is a relatively simple and lightweight executable
>> format
>> +         based on the original a.out format. It is widely used in
>> environment
>> +         where no MMU is available.
>> +endchoice
>> +
>>   if BR2_arm || BR2_armeb
>>   source "arch/Config.in.arm"
>>   endif
>
> [snip]
>
>
> --
> Arnout Vandecappelle                          arnout at mind be
> Senior Embedded Software Architect            +32-16-286500
> Essensium/Mind                                http://www.mind.be
> G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
> LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
> GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
Sonic Zhang - April 12, 2013, 5:01 a.m.
Hi Arnout and Thomas,


Could you give me a conclusion on which way do you prefer to define
the macro BINFMT_XXX? Generic for all architectures or depend on
BR2_bfin and BR2_m68k only?


Thanks

Sonic

Patch

diff --git a/arch/Config.in b/arch/Config.in
index 472b10c..5dd6467 100644
--- a/arch/Config.in
+++ b/arch/Config.in
@@ -174,6 +174,35 @@  config BR2_GCC_TARGET_ABI
 config BR2_GCC_TARGET_CPU
 	string
 
+# Set up target binary format
+choice
+	prompt "Target Binary Format"
+	default BR2_BINFMT_ELF
+config BR2_BINFMT_ELF
+	bool "ELF"
+	depends on !BR2_bfin
+	help
+	  ELF (Executable and Linkable Format) is a format for libraries and
+	  executables used across different architectures and operating
+	  systems.
+config BR2_BINFMT_FDPIC
+	bool "FDPIC"
+	depends on BR2_bfin
+	help
+	  ELF FDPIC binaries are based on ELF, but allow the individual load
+	  segments of a binary to be located in memory independently of each
+	  other. This makes this format ideal for use in environments where no
+	  MMU is available.
+config BR2_BINFMT_FLAT
+	bool "FLAT"
+	depends on BR2_bfin
+	select BR2_PREFER_STATIC_LIB
+	help
+	  FLAT binary is a relatively simple and lightweight executable format
+	  based on the original a.out format. It is widely used in environment
+	  where no MMU is available.
+endchoice
+
 if BR2_arm || BR2_armeb
 source "arch/Config.in.arm"
 endif
diff --git a/toolchain/toolchain-external/Config.in b/toolchain/toolchain-external/Config.in
index 5b26aa9..6cf29aa 100644
--- a/toolchain/toolchain-external/Config.in
+++ b/toolchain/toolchain-external/Config.in
@@ -758,12 +758,12 @@  config BR2_TOOLCHAIN_EXTERNAL_PREFIX
 	default "i686-pc-linux-gnu"	 if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201109
 	default "i686-pc-linux-gnu"	 if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201203
 	default "i686-pc-linux-gnu"	 if BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_X86_201209
-	default "bfin-uclinux"		 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2011R1 && !BR2_BFIN_FDPIC
-	default "bfin-linux-uclibc"	 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2011R1 && BR2_BFIN_FDPIC
-	default "bfin-uclinux"		 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R1 && !BR2_BFIN_FDPIC
-	default "bfin-linux-uclibc"	 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R1 && BR2_BFIN_FDPIC
-	default "bfin-uclinux"		 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R2 && !BR2_BFIN_FDPIC
-	default "bfin-linux-uclibc"	 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R2 && BR2_BFIN_FDPIC
+	default "bfin-uclinux"		 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2011R1 && BR2_BINFMT_FLAT
+	default "bfin-linux-uclibc"	 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2011R1 && BR2_BINFMT_FDPIC
+	default "bfin-uclinux"		 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R1 && BR2_BINFMT_FLAT
+	default "bfin-linux-uclibc"	 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R1 && BR2_BINFMT_FDPIC
+	default "bfin-uclinux"		 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R2 && BR2_BINFMT_FLAT
+	default "bfin-linux-uclibc"	 if BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R2 && BR2_BINFMT_FDPIC
 	default $(BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX) \
 					 if BR2_TOOLCHAIN_EXTERNAL_CUSTOM
 
diff --git a/toolchain/toolchain-external/ext-tool.mk b/toolchain/toolchain-external/ext-tool.mk
index b477bc0..92183a4 100644
--- a/toolchain/toolchain-external/ext-tool.mk
+++ b/toolchain/toolchain-external/ext-tool.mk
@@ -160,6 +160,10 @@  ifneq ($(CC_TARGET_ABI_),)
 TOOLCHAIN_EXTERNAL_CFLAGS += -mabi=$(CC_TARGET_ABI_)
 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ABI='"$(CC_TARGET_ABI_)"'
 endif
+ifeq ($(BR2_BINFMT_FLAT),y)
+TOOLCHAIN_EXTERNAL_CFLAGS += -Wl,-elf2flt
+TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_BINFMT_FLAT
+endif
 
 ifneq ($(BR2_TARGET_OPTIMIZATION),)
 TOOLCHAIN_EXTERNAL_CFLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
diff --git a/toolchain/toolchain-external/ext-toolchain-wrapper.c b/toolchain/toolchain-external/ext-toolchain-wrapper.c
index a92bada..9a2fc70 100644
--- a/toolchain/toolchain-external/ext-toolchain-wrapper.c
+++ b/toolchain/toolchain-external/ext-toolchain-wrapper.c
@@ -47,6 +47,9 @@  static char *predef_args[] = {
 #ifdef BR_64
 	"-m64",
 #endif
+#ifdef BR_BINFMT_FLAT
+	"-Wl,-elf2flt",
+#endif
 #ifdef BR_ADDITIONAL_CFLAGS
 	BR_ADDITIONAL_CFLAGS
 #endif