Introduce target-specific LDFLAGS, the same way we have CFLAGS for the target.
It seems to be helping gcc somewhat into telling the correct endianness to ld that sticks with little endian even when the target is big (eg armeb-unknown-linux-uclibcgnueabi).
There's still work to do, especially finish the gcc part that is not in this commit.
/trunk/scripts/functions | 9 7 2 0 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
1 --- gcc-4.1.2.orig/gcc/config/arm/linux-elf.h 2007-03-04 23:25:37.000000000 +0100
2 +++ gcc-4.1.2/gcc/config/arm/linux-elf.h 2007-03-04 23:35:09.000000000 +0100
5 #define TARGET_VERSION fputs (" (ARM GNU/Linux with ELF)", stderr);
8 + * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
9 + * (big endian) configurations.
11 +#if TARGET_BIG_ENDIAN_DEFAULT
12 +#define TARGET_ENDIAN_DEFAULT MASK_BIG_END
13 +#define TARGET_ENDIAN_OPTION "mbig-endian"
14 +#define TARGET_LINKER_EMULATION "armelfb_linux"
16 +#define TARGET_ENDIAN_DEFAULT 0
17 +#define TARGET_ENDIAN_OPTION "mlittle-endian"
18 +#define TARGET_LINKER_EMULATION "armelf_linux"
21 #undef TARGET_DEFAULT_FLOAT_ABI
22 #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
25 -#define TARGET_DEFAULT (0)
26 +#define TARGET_DEFAULT (TARGET_ENDIAN_DEFAULT)
28 #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
30 -#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
31 +#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
33 #undef MULTILIB_DEFAULTS
34 #define MULTILIB_DEFAULTS \
35 - { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
36 + { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }
38 /* Now we define the strings used to build the spec file. */
41 %{rdynamic:-export-dynamic} \
42 %{!dynamic-linker:-dynamic-linker " LINUX_TARGET_INTERPRETER "} \
44 - %{mbig-endian:-EB}" \
45 + %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
46 SUBTARGET_EXTRA_LINK_SPEC
49 --- gcc-4.1.2.orig/gcc/config.gcc 2007-03-04 23:31:48.000000000 +0100
50 +++ gcc-4.1.2/gcc/config.gcc 2007-03-04 23:35:09.000000000 +0100
53 arm*-*-linux*) # ARM GNU/Linux with ELF
54 tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
57 + tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
60 tmake_file="${tmake_file} t-linux arm/t-arm"
62 arm*-*-linux-gnueabi | arm*-*-linux-uclibcgnueabi)
63 --- gcc-4.1.2.orig/gcc/config/arm/linux-eabi.h 2007-03-04 23:31:48.000000000 +0100
64 +++ gcc-4.1.2/gcc/config/arm/linux-eabi.h 2007-03-04 23:35:09.000000000 +0100
66 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
67 Boston, MA 02110-1301, USA. */
70 + * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
71 + * (big endian) configurations.
73 +#undef TARGET_LINKER_EMULATION
74 +#if TARGET_BIG_ENDIAN_DEFAULT
75 +#define TARGET_LINKER_EMULATION "armelfb_linux_eabi"
77 +#define TARGET_LINKER_EMULATION "armelf_linux_eabi"
80 /* On EABI GNU/Linux, we want both the BPABI builtins and the
81 GNU/Linux builtins. */
82 #undef TARGET_OS_CPP_BUILTINS
84 #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi
86 #undef SUBTARGET_EXTRA_LINK_SPEC
87 -#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux_eabi"
88 +#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION
90 /* Use ld-linux.so.3 so that it will be possible to run "classic"
91 GNU/Linux binaries on an EABI system. */
92 --- gcc-4.1.2.orig/gcc/config/arm/bpabi.h 2005-12-13 02:35:37.000000000 +0100
93 +++ gcc-4.1.2/gcc/config/arm/bpabi.h 2007-03-04 23:35:09.000000000 +0100
95 #undef FPUTYPE_DEFAULT
96 #define FPUTYPE_DEFAULT FPUTYPE_VFP
99 + * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
100 + * (big endian) configurations.
102 +#if TARGET_BIG_ENDIAN_DEFAULT
103 +#define TARGET_ENDIAN_DEFAULT MASK_BIG_END
105 +#define TARGET_ENDIAN_DEFAULT 0
108 /* EABI targets should enable interworking by default. */
109 #undef TARGET_DEFAULT
110 -#define TARGET_DEFAULT MASK_INTERWORK
111 +#define TARGET_DEFAULT (MASK_INTERWORK | TARGET_ENDIAN_DEFAULT)
113 /* The ARM BPABI functions return a boolean; they use no special
114 calling convention. */