Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package/Makefile.in: append endianness argument to TARGET_LD for MIPS
@ 2016-02-17 17:07 Vicente Olivert Riera
  2016-02-17 17:07 ` [Buildroot] [PATCH 2/2] linux/linux.mk: add LD="$(TARGET_LD)" to LINUX_MAKE_FLAGS Vicente Olivert Riera
  2016-02-17 21:13 ` [Buildroot] [PATCH 1/2] package/Makefile.in: append endianness argument to TARGET_LD for MIPS Thomas Petazzoni
  0 siblings, 2 replies; 9+ messages in thread
From: Vicente Olivert Riera @ 2016-02-17 17:07 UTC (permalink / raw)
  To: buildroot

We don't use a wrapper for ld in Buildroot like we do for gcc, so when
using ld for linking (instead of gcc) the process can fail if the
appropriate arguments are not passed to it. For instance, this happens
when building perf (Linux -> Linux Kernel Tools -> perf) for MIPS little
endian, and this is how the error message looks like:

 LD    /br/output/build/perf-custom/fd/libapi-in.o
/br/output/host/usr/bin/mips-linux-gnu-ld:
/br/output/build/perf-custom/fd/array.o: compiled for a little endian
system and target is big endian

In this case the linker is called without passing any argument to
indicate the endianness, so the default one is used, which is big endian
and therefore the process fails because the object files were built for
little endian instead.

This patch doesn't fix the problem in perf. It just appends the right
endianness argument (-EL or -EB) to the TARGET_LD variable when building
for MIPS architecture.

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
---
 package/Makefile.in | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/package/Makefile.in b/package/Makefile.in
index dd595e2..8422b96 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -190,6 +190,19 @@ TARGET_READELF  = $(TARGET_CROSS)readelf
 TARGET_OBJCOPY  = $(TARGET_CROSS)objcopy
 TARGET_OBJDUMP  = $(TARGET_CROSS)objdump
 
+# Append the endianness argument to ld for MIPS architecture in order to
+# avoid problems like this one when using ld instead of gcc for linking:
+# mips-linux-gnu-ld: failed to merge target specific data of file foo.o
+# mips-linux-gnu-ld: foo.o: compiled for a little endian system and
+# target is big endian
+ifeq ($(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el),y)
+ifeq ($(BR2_ENDIAN),"BIG")
+TARGET_LD += -EB
+else
+TARGET_LD += -EL
+endif
+endif
+
 ifeq ($(BR2_STRIP_strip),y)
 STRIP_STRIP_DEBUG := --strip-debug
 STRIP_STRIP_UNNEEDED := --strip-unneeded
-- 
2.4.10

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-02-20  9:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-17 17:07 [Buildroot] [PATCH 1/2] package/Makefile.in: append endianness argument to TARGET_LD for MIPS Vicente Olivert Riera
2016-02-17 17:07 ` [Buildroot] [PATCH 2/2] linux/linux.mk: add LD="$(TARGET_LD)" to LINUX_MAKE_FLAGS Vicente Olivert Riera
2016-02-17 21:13 ` [Buildroot] [PATCH 1/2] package/Makefile.in: append endianness argument to TARGET_LD for MIPS Thomas Petazzoni
2016-02-17 22:41   ` Arnout Vandecappelle
2016-02-18  8:07     ` Thomas Petazzoni
2016-02-18  9:25       ` Peter Korsgaard
2016-02-18 14:20         ` Vicente Olivert Riera
2016-02-18 14:44           ` Peter Korsgaard
2016-02-20  9:34     ` Jan Heylen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox