Patchwork [v2,3/7] arch: toolchain: Introduce binary formats BINFMT_*.

login
register
mail settings
Submitter Sonic Zhang
Date March 29, 2013, 9:50 a.m.
Message ID <1364550643-11793-3-git-send-email-sonic.adi@gmail.com>
Download mbox | patch
Permalink /patch/232346/
State Changes Requested
Headers show

Comments

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

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                                     |   13 +++++++++++++
 toolchain/toolchain-external/ext-tool.mk           |    4 ++++
 .../toolchain-external/ext-toolchain-wrapper.c     |    3 +++
 3 files changed, 20 insertions(+), 0 deletions(-)
Thomas Petazzoni - April 7, 2013, 8:45 p.m.
Dear Sonic Zhang,

On Fri, 29 Mar 2013 17:50:39 +0800, Sonic Zhang wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
> 
> 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>

As detailed in my comments to PATCH 1/7, this patch needs to be
refactored with BR2_BFIN_FDPIC/BR2_BFIN_FLAT to avoid breaking existing
code.

Also, I believe we want to add some architecture dependencies here. For
the beginning, we at least want something like:

+# Set up target binary format
+choice
+	prompt "Target Binary Format"
+	default BR2_BINFMT_ELF
+config BR2_BINFMT_ELF
+	bool "ELF"
+	depends on !BR2_bfin
+config BR2_BINFMT_FDPIC
+	bool "FDPIC"
+	depends on BR2_bfin
+config BR2_BINFMT_FLAT
+	bool "FLAT"
+	select BR2_PREFER_STATIC_LIB
+	depends on BR2_bfin
+endchoice

Of course, this might be extended later on if we enable FLAT support on
other architectures. But for now, it ensures that users can't make an
invalid choice (like chose FDPIC on ARM).

Thanks!

Thomas
Thomas Petazzoni - April 7, 2013, 8:47 p.m.
Dear Sonic Zhang,

On Fri, 29 Mar 2013 17:50:39 +0800, Sonic Zhang wrote:

> +choice
> +	prompt "Target Binary Format"
> +	default BR2_BINFMT_ELF
> +config BR2_BINFMT_ELF
> +	bool "ELF"
> +config BR2_BINFMT_FDPIC
> +	bool "FDPIC"
> +config BR2_BINFMT_FLAT
> +	bool "FLAT"
> +	select BR2_PREFER_STATIC_LIB
> +endchoice

Maybe some help text would also be nice for each choice.

Thanks,

Thomas
Sonic Zhang - April 8, 2013, 6:03 a.m.
Hi Thomas,

On Mon, Apr 8, 2013 at 4:45 AM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Sonic Zhang,
>
> On Fri, 29 Mar 2013 17:50:39 +0800, Sonic Zhang wrote:
>> From: Sonic Zhang <sonic.zhang@analog.com>
>>
>> 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>
>
> As detailed in my comments to PATCH 1/7, this patch needs to be
> refactored with BR2_BFIN_FDPIC/BR2_BFIN_FLAT to avoid breaking existing
> code.

OK.

>
> Also, I believe we want to add some architecture dependencies here. For
> the beginning, we at least want something like:
>
> +# Set up target binary format
> +choice
> +       prompt "Target Binary Format"
> +       default BR2_BINFMT_ELF
> +config BR2_BINFMT_ELF
> +       bool "ELF"
> +       depends on !BR2_bfin
> +config BR2_BINFMT_FDPIC
> +       bool "FDPIC"
> +       depends on BR2_bfin
> +config BR2_BINFMT_FLAT
> +       bool "FLAT"
> +       select BR2_PREFER_STATIC_LIB
> +       depends on BR2_bfin
> +endchoice
>

No problem.

Regards,

Sonic
Sonic Zhang - April 8, 2013, 6:04 a.m.
Hi Thomas,

On Mon, Apr 8, 2013 at 4:47 AM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Sonic Zhang,
>
> On Fri, 29 Mar 2013 17:50:39 +0800, Sonic Zhang wrote:
>
>> +choice
>> +     prompt "Target Binary Format"
>> +     default BR2_BINFMT_ELF
>> +config BR2_BINFMT_ELF
>> +     bool "ELF"
>> +config BR2_BINFMT_FDPIC
>> +     bool "FDPIC"
>> +config BR2_BINFMT_FLAT
>> +     bool "FLAT"
>> +     select BR2_PREFER_STATIC_LIB
>> +endchoice
>
> Maybe some help text would also be nice for each choice.
>
OK

Regards,

Sonic

Patch

diff --git a/arch/Config.in b/arch/Config.in
index c341848..be475c0 100644
--- a/arch/Config.in
+++ b/arch/Config.in
@@ -177,6 +177,19 @@  config BR2_GCC_TARGET_CPU
 config BR2_GCC_TARGET_CPU_REVISION
 	string
 
+# Set up target binary format
+choice
+	prompt "Target Binary Format"
+	default BR2_BINFMT_ELF
+config BR2_BINFMT_ELF
+	bool "ELF"
+config BR2_BINFMT_FDPIC
+	bool "FDPIC"
+config BR2_BINFMT_FLAT
+	bool "FLAT"
+	select BR2_PREFER_STATIC_LIB
+endchoice
+
 if BR2_arm || BR2_armeb
 source "arch/Config.in.arm"
 endif
diff --git a/toolchain/toolchain-external/ext-tool.mk b/toolchain/toolchain-external/ext-tool.mk
index 407e1ad..27fd296 100644
--- a/toolchain/toolchain-external/ext-tool.mk
+++ b/toolchain/toolchain-external/ext-tool.mk
@@ -164,6 +164,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