diff mbox

[PATCH/TopLevel] Fix compiling libgo with a combined sources

Message ID CA+=Sn1nMV44+3jMMZ0WJQbX=KTaETk7ZC5ZzOv3K-wYdQiCPkw@mail.gmail.com
State New
Headers show

Commit Message

Andrew Pinski Nov. 23, 2014, 4:20 a.m. UTC
Hi,
  The problem here is here is that OBJCOPY is not being set to the
newly built objcopy when compiling libgo.  This patch adds
OBJCOPY_FOR_TARGET to the toplevel configure/Makefile so that when
libgo is compiled OBJCOPY is set to OBJCOPY_FOR_TARGET.

I noticed this issue when building an aarch64 cross compile on an
older system where objcopy did not understand aarch64.

OK?  Bootstrapped and tested on x86_64 with no regressions.  Also
tested with a combined build for a cross compiler to
aarch64-linux-gnu.

Thanks,
Andrew Pinski


        * Makefile.def (flags_to_pass): Pass OBJCOPY_FOR_TARGET also.
        * Makefile.tpl (HOST_EXPORTS): Add OBJCOPY_FOR_TARGET.
        (BASE_TARGET_EXPORTS): Add OBJCOPY.
        (OBJCOPY_FOR_TARGET): New variable.
        (EXTRA_TARGET_FLAGS): Add OBJCOPY.
        * Makefile.in: Regenerate.
        * configure.ac: Check for already installed target objcopy.
        Also GCC_TARGET_TOOL on objcopy.
        * configure: Regenerate.
From 09f04f392049c0c3777f74f5e1cab29ca7357810 Mon Sep 17 00:00:00 2001
From: Andrew Pinski <apinski@cavium.com>
Date: Tue, 14 Oct 2014 23:14:58 -0700
Subject: [PATCH] 2014-10-14  Andrew Pinski  <apinski@cavium.com>

        * Makefile.def (flags_to_pass): Pass OBJCOPY_FOR_TARGET also.
        * Makefile.tpl (HOST_EXPORTS): Add OBJCOPY_FOR_TARGET.
        (BASE_TARGET_EXPORTS): Add OBJCOPY.
        (OBJCOPY_FOR_TARGET): New variable.
        (EXTRA_TARGET_FLAGS): Add OBJCOPY.
        * Makefile.in: Regenerate.
        * configure.ac: Check for already installed target objcopy.
        Also GCC_TARGET_TOOL on objcopy.
        * configure: Regenerate.
---
 Makefile.def     |    1 +
 Makefile.in      |    5 +
 Makefile.tpl     |    4 +
 configure        |  276 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac     |    2 +

Comments

Richard Biener Nov. 24, 2014, 11:56 a.m. UTC | #1
On Sun, Nov 23, 2014 at 5:20 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> Hi,
>   The problem here is here is that OBJCOPY is not being set to the
> newly built objcopy when compiling libgo.  This patch adds
> OBJCOPY_FOR_TARGET to the toplevel configure/Makefile so that when
> libgo is compiled OBJCOPY is set to OBJCOPY_FOR_TARGET.
>
> I noticed this issue when building an aarch64 cross compile on an
> older system where objcopy did not understand aarch64.
>
> OK?  Bootstrapped and tested on x86_64 with no regressions.  Also
> tested with a combined build for a cross compiler to
> aarch64-linux-gnu.

Ok.

Thanks,
Richard.

> Thanks,
> Andrew Pinski
>
>
>         * Makefile.def (flags_to_pass): Pass OBJCOPY_FOR_TARGET also.
>         * Makefile.tpl (HOST_EXPORTS): Add OBJCOPY_FOR_TARGET.
>         (BASE_TARGET_EXPORTS): Add OBJCOPY.
>         (OBJCOPY_FOR_TARGET): New variable.
>         (EXTRA_TARGET_FLAGS): Add OBJCOPY.
>         * Makefile.in: Regenerate.
>         * configure.ac: Check for already installed target objcopy.
>         Also GCC_TARGET_TOOL on objcopy.
>         * configure: Regenerate.
Jan-Benedict Glaw Nov. 24, 2014, 1:15 p.m. UTC | #2
Hi Andrew,

On Sat, 2014-11-22 20:20:08 -0800, Andrew Pinski <pinskia@gmail.com> wrote:
> Hi,
>   The problem here is here is that OBJCOPY is not being set to the
> newly built objcopy when compiling libgo.  This patch adds
> OBJCOPY_FOR_TARGET to the toplevel configure/Makefile so that when
> libgo is compiled OBJCOPY is set to OBJCOPY_FOR_TARGET.
> 
> I noticed this issue when building an aarch64 cross compile on an
> older system where objcopy did not understand aarch64.
> 
> OK?  Bootstrapped and tested on x86_64 with no regressions.  Also
> tested with a combined build for a cross compiler to
> aarch64-linux-gnu.

I just sent a patch set these days, bringing the configury of Binutils
and GCC in sync again.

  Quite a number of changes accumulated in both trees that weren't
merged. I'm quite willing to keep those in sync, but let's have a
dicision whether or not we see those as common files---or not.

  That is, I would be grateful if you'd commit that patch after mine
is accepted (or right away, if my patch set is rejected.) Would save
me from some rebase hell. ;-)

MfG, JBG
Jeff Law Nov. 24, 2014, 9:32 p.m. UTC | #3
On 11/22/14 21:20, Andrew Pinski wrote:
> Hi,
>    The problem here is here is that OBJCOPY is not being set to the
> newly built objcopy when compiling libgo.  This patch adds
> OBJCOPY_FOR_TARGET to the toplevel configure/Makefile so that when
> libgo is compiled OBJCOPY is set to OBJCOPY_FOR_TARGET.
>
> I noticed this issue when building an aarch64 cross compile on an
> older system where objcopy did not understand aarch64.
>
> OK?  Bootstrapped and tested on x86_64 with no regressions.  Also
> tested with a combined build for a cross compiler to
> aarch64-linux-gnu.
>
> Thanks,
> Andrew Pinski
>
>
>          * Makefile.def (flags_to_pass): Pass OBJCOPY_FOR_TARGET also.
>          * Makefile.tpl (HOST_EXPORTS): Add OBJCOPY_FOR_TARGET.
>          (BASE_TARGET_EXPORTS): Add OBJCOPY.
>          (OBJCOPY_FOR_TARGET): New variable.
>          (EXTRA_TARGET_FLAGS): Add OBJCOPY.
>          * Makefile.in: Regenerate.
>          * configure.ac: Check for already installed target objcopy.
>          Also GCC_TARGET_TOOL on objcopy.
>          * configure: Regenerate.
OK
Jeff
Andrew Pinski Jan. 3, 2015, 10:55 p.m. UTC | #4
On Mon, Nov 24, 2014 at 1:32 PM, Jeff Law <law@redhat.com> wrote:
> On 11/22/14 21:20, Andrew Pinski wrote:
>>
>> Hi,
>>    The problem here is here is that OBJCOPY is not being set to the
>> newly built objcopy when compiling libgo.  This patch adds
>> OBJCOPY_FOR_TARGET to the toplevel configure/Makefile so that when
>> libgo is compiled OBJCOPY is set to OBJCOPY_FOR_TARGET.
>>
>> I noticed this issue when building an aarch64 cross compile on an
>> older system where objcopy did not understand aarch64.
>>
>> OK?  Bootstrapped and tested on x86_64 with no regressions.  Also
>> tested with a combined build for a cross compiler to
>> aarch64-linux-gnu.
>>
>> Thanks,
>> Andrew Pinski
>>
>>
>>          * Makefile.def (flags_to_pass): Pass OBJCOPY_FOR_TARGET also.
>>          * Makefile.tpl (HOST_EXPORTS): Add OBJCOPY_FOR_TARGET.
>>          (BASE_TARGET_EXPORTS): Add OBJCOPY.
>>          (OBJCOPY_FOR_TARGET): New variable.
>>          (EXTRA_TARGET_FLAGS): Add OBJCOPY.
>>          * Makefile.in: Regenerate.
>>          * configure.ac: Check for already installed target objcopy.
>>          Also GCC_TARGET_TOOL on objcopy.
>>          * configure: Regenerate.
>
> OK


Committed to GCC and gdb/binutils repos now.

Thanks,
Andrew

> Jeff
>
>
Bin.Cheng Jan. 4, 2015, 9:35 a.m. UTC | #5
On Sun, Jan 4, 2015 at 6:55 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> On Mon, Nov 24, 2014 at 1:32 PM, Jeff Law <law@redhat.com> wrote:
>> On 11/22/14 21:20, Andrew Pinski wrote:
>>>
>>> Hi,
>>>    The problem here is here is that OBJCOPY is not being set to the
>>> newly built objcopy when compiling libgo.  This patch adds
>>> OBJCOPY_FOR_TARGET to the toplevel configure/Makefile so that when
>>> libgo is compiled OBJCOPY is set to OBJCOPY_FOR_TARGET.
>>>
>>> I noticed this issue when building an aarch64 cross compile on an
>>> older system where objcopy did not understand aarch64.
>>>
>>> OK?  Bootstrapped and tested on x86_64 with no regressions.  Also
>>> tested with a combined build for a cross compiler to
>>> aarch64-linux-gnu.
>>>
>>> Thanks,
>>> Andrew Pinski
>>>
>>>
>>>          * Makefile.def (flags_to_pass): Pass OBJCOPY_FOR_TARGET also.
>>>          * Makefile.tpl (HOST_EXPORTS): Add OBJCOPY_FOR_TARGET.
>>>          (BASE_TARGET_EXPORTS): Add OBJCOPY.
>>>          (OBJCOPY_FOR_TARGET): New variable.
>>>          (EXTRA_TARGET_FLAGS): Add OBJCOPY.
>>>          * Makefile.in: Regenerate.
>>>          * configure.ac: Check for already installed target objcopy.
>>>          Also GCC_TARGET_TOOL on objcopy.
>>>          * configure: Regenerate.
>>
>> OK
>
>
> Committed to GCC and gdb/binutils repos now.
>
> Thanks,
> Andrew

Hi Andrew,

> +  elif test "x$target" = "x$host"; then
> +    # We can use an host tool
> +    OBJCOPY_FOR_TARGET='$(OBJDUMP)'
Is it a typo for '$(OBJCOPY)' ?

Thanks,
bin
Andrew Pinski Jan. 4, 2015, 10:30 a.m. UTC | #6
> On Jan 4, 2015, at 1:35 AM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> 
>> On Sun, Jan 4, 2015 at 6:55 AM, Andrew Pinski <pinskia@gmail.com> wrote:
>>> On Mon, Nov 24, 2014 at 1:32 PM, Jeff Law <law@redhat.com> wrote:
>>>> On 11/22/14 21:20, Andrew Pinski wrote:
>>>> 
>>>> Hi,
>>>>   The problem here is here is that OBJCOPY is not being set to the
>>>> newly built objcopy when compiling libgo.  This patch adds
>>>> OBJCOPY_FOR_TARGET to the toplevel configure/Makefile so that when
>>>> libgo is compiled OBJCOPY is set to OBJCOPY_FOR_TARGET.
>>>> 
>>>> I noticed this issue when building an aarch64 cross compile on an
>>>> older system where objcopy did not understand aarch64.
>>>> 
>>>> OK?  Bootstrapped and tested on x86_64 with no regressions.  Also
>>>> tested with a combined build for a cross compiler to
>>>> aarch64-linux-gnu.
>>>> 
>>>> Thanks,
>>>> Andrew Pinski
>>>> 
>>>> 
>>>>         * Makefile.def (flags_to_pass): Pass OBJCOPY_FOR_TARGET also.
>>>>         * Makefile.tpl (HOST_EXPORTS): Add OBJCOPY_FOR_TARGET.
>>>>         (BASE_TARGET_EXPORTS): Add OBJCOPY.
>>>>         (OBJCOPY_FOR_TARGET): New variable.
>>>>         (EXTRA_TARGET_FLAGS): Add OBJCOPY.
>>>>         * Makefile.in: Regenerate.
>>>>         * configure.ac: Check for already installed target objcopy.
>>>>         Also GCC_TARGET_TOOL on objcopy.
>>>>         * configure: Regenerate.
>>> 
>>> OK
>> 
>> 
>> Committed to GCC and gdb/binutils repos now.
>> 
>> Thanks,
>> Andrew
> 
> Hi Andrew,
> 
>> +  elif test "x$target" = "x$host"; then
>> +    # We can use an host tool
>> +    OBJCOPY_FOR_TARGET='$(OBJDUMP)'
> Is it a typo for '$(OBJCOPY)' ?

Yes it is a pasto. I think the fix for this would be obvious. 

Thanks,
Andrew

> 
> Thanks,
> bin
diff mbox

Patch

diff --git a/Makefile.def b/Makefile.def
index 239ad36..a8ebe1a 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -280,6 +280,7 @@  flags_to_pass = { flag= LIBCFLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= LIBCXXFLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= NM_FOR_TARGET ; };
 flags_to_pass = { flag= OBJDUMP_FOR_TARGET ; };
+flags_to_pass = { flag= OBJCOPY_FOR_TARGET ; };
 flags_to_pass = { flag= RANLIB_FOR_TARGET ; };
 flags_to_pass = { flag= READELF_FOR_TARGET ; };
 flags_to_pass = { flag= STRIP_FOR_TARGET ; };
diff --git a/Makefile.in b/Makefile.in
index d6105b3..d34796d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -213,6 +213,7 @@  HOST_EXPORTS = \
 	LD_FOR_TARGET="$(LD_FOR_TARGET)"; export LD_FOR_TARGET; \
 	NM_FOR_TARGET="$(NM_FOR_TARGET)"; export NM_FOR_TARGET; \
 	OBJDUMP_FOR_TARGET="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP_FOR_TARGET; \
+	OBJCOPY_FOR_TARGET="$(OBJCOPY_FOR_TARGET)"; export OBJCOPY_FOR_TARGET; \
 	RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \
 	READELF_FOR_TARGET="$(READELF_FOR_TARGET)"; export READELF_FOR_TARGET; \
 	TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
@@ -287,6 +288,7 @@  BASE_TARGET_EXPORTS = \
 	LIPO="$(LIPO_FOR_TARGET)"; export LIPO; \
 	NM="$(COMPILER_NM_FOR_TARGET)"; export NM; \
 	OBJDUMP="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP; \
+	OBJCOPY="$(OBJCOPY_FOR_TARGET)"; export OBJCOPY; \
 	RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
 	READELF="$(READELF_FOR_TARGET)"; export READELF; \
 	STRIP="$(STRIP_FOR_TARGET)"; export STRIP; \
@@ -539,6 +541,7 @@  LD_FOR_TARGET=@LD_FOR_TARGET@
 LIPO_FOR_TARGET=@LIPO_FOR_TARGET@
 NM_FOR_TARGET=@NM_FOR_TARGET@
 OBJDUMP_FOR_TARGET=@OBJDUMP_FOR_TARGET@
+OBJCOPY_FOR_TARGET=@OBJCOPY_FOR_TARGET@
 RANLIB_FOR_TARGET=@RANLIB_FOR_TARGET@
 READELF_FOR_TARGET=@READELF_FOR_TARGET@
 STRIP_FOR_TARGET=@STRIP_FOR_TARGET@
@@ -758,6 +761,7 @@  BASE_FLAGS_TO_PASS = \
 	"LIBCXXFLAGS_FOR_TARGET=$(LIBCXXFLAGS_FOR_TARGET)" \
 	"NM_FOR_TARGET=$(NM_FOR_TARGET)" \
 	"OBJDUMP_FOR_TARGET=$(OBJDUMP_FOR_TARGET)" \
+	"OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET)" \
 	"RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \
 	"READELF_FOR_TARGET=$(READELF_FOR_TARGET)" \
 	"STRIP_FOR_TARGET=$(STRIP_FOR_TARGET)" \
@@ -855,6 +859,7 @@  EXTRA_TARGET_FLAGS = \
 	'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET)' \
 	'NM=$(COMPILER_NM_FOR_TARGET)' \
 	'OBJDUMP=$$(OBJDUMP_FOR_TARGET)' \
+	'OBJCOPY=$$(OBJCOPY_FOR_TARGET)' \
 	'RANLIB=$$(RANLIB_FOR_TARGET)' \
 	'READELF=$$(READELF_FOR_TARGET)' \
 	'WINDRES=$$(WINDRES_FOR_TARGET)' \
diff --git a/Makefile.tpl b/Makefile.tpl
index f7c7e38..959dcb9 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -216,6 +216,7 @@  HOST_EXPORTS = \
 	LD_FOR_TARGET="$(LD_FOR_TARGET)"; export LD_FOR_TARGET; \
 	NM_FOR_TARGET="$(NM_FOR_TARGET)"; export NM_FOR_TARGET; \
 	OBJDUMP_FOR_TARGET="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP_FOR_TARGET; \
+	OBJCOPY_FOR_TARGET="$(OBJCOPY_FOR_TARGET)"; export OBJCOPY_FOR_TARGET; \
 	RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \
 	READELF_FOR_TARGET="$(READELF_FOR_TARGET)"; export READELF_FOR_TARGET; \
 	TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
@@ -290,6 +291,7 @@  BASE_TARGET_EXPORTS = \
 	LIPO="$(LIPO_FOR_TARGET)"; export LIPO; \
 	NM="$(COMPILER_NM_FOR_TARGET)"; export NM; \
 	OBJDUMP="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP; \
+	OBJCOPY="$(OBJCOPY_FOR_TARGET)"; export OBJCOPY; \
 	RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
 	READELF="$(READELF_FOR_TARGET)"; export READELF; \
 	STRIP="$(STRIP_FOR_TARGET)"; export STRIP; \
@@ -492,6 +494,7 @@  LD_FOR_TARGET=@LD_FOR_TARGET@
 LIPO_FOR_TARGET=@LIPO_FOR_TARGET@
 NM_FOR_TARGET=@NM_FOR_TARGET@
 OBJDUMP_FOR_TARGET=@OBJDUMP_FOR_TARGET@
+OBJCOPY_FOR_TARGET=@OBJCOPY_FOR_TARGET@
 RANLIB_FOR_TARGET=@RANLIB_FOR_TARGET@
 READELF_FOR_TARGET=@READELF_FOR_TARGET@
 STRIP_FOR_TARGET=@STRIP_FOR_TARGET@
@@ -660,6 +663,7 @@  EXTRA_TARGET_FLAGS = \
 	'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET)' \
 	'NM=$(COMPILER_NM_FOR_TARGET)' \
 	'OBJDUMP=$$(OBJDUMP_FOR_TARGET)' \
+	'OBJCOPY=$$(OBJCOPY_FOR_TARGET)' \
 	'RANLIB=$$(RANLIB_FOR_TARGET)' \
 	'READELF=$$(READELF_FOR_TARGET)' \
 	'WINDRES=$$(WINDRES_FOR_TARGET)' \
diff --git a/configure b/configure
index 591fcfb..e0ec13e 100755
--- a/configure
+++ b/configure
@@ -574,6 +574,7 @@  STRIP_FOR_TARGET
 READELF_FOR_TARGET
 RANLIB_FOR_TARGET
 OBJDUMP_FOR_TARGET
+OBJCOPY_FOR_TARGET
 NM_FOR_TARGET
 LIPO_FOR_TARGET
 LD_FOR_TARGET
@@ -835,6 +836,7 @@  DLLTOOL_FOR_TARGET
 LD_FOR_TARGET
 LIPO_FOR_TARGET
 NM_FOR_TARGET
+OBJCOPY_FOR_TARGET
 OBJDUMP_FOR_TARGET
 RANLIB_FOR_TARGET
 READELF_FOR_TARGET
@@ -1614,6 +1616,8 @@  Some influential environment variables:
               LIPO for the target
   NM_FOR_TARGET
               NM for the target
+  OBJCOPY_FOR_TARGET
+              OBJCOPY for the target
   OBJDUMP_FOR_TARGET
               OBJDUMP for the target
   RANLIB_FOR_TARGET
@@ -12223,6 +12227,236 @@  fi
 
 
 
+if test -z "$ac_cv_path_OBJCOPY_FOR_TARGET" ; then
+  if test -n "$with_build_time_tools"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objcopy in $with_build_time_tools" >&5
+$as_echo_n "checking for objcopy in $with_build_time_tools... " >&6; }
+    if test -x $with_build_time_tools/objcopy; then
+      OBJCOPY_FOR_TARGET=`cd $with_build_time_tools && pwd`/objcopy
+      ac_cv_path_OBJCOPY_FOR_TARGET=$OBJCOPY_FOR_TARGET
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_OBJCOPY_FOR_TARGET" >&5
+$as_echo "$ac_cv_path_OBJCOPY_FOR_TARGET" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    fi
+  elif test $build != $host && test $have_gcc_for_target = yes; then
+    OBJCOPY_FOR_TARGET=`$GCC_FOR_TARGET --print-prog-name=objcopy`
+    test $OBJCOPY_FOR_TARGET = objcopy && OBJCOPY_FOR_TARGET=
+    test -n "$OBJCOPY_FOR_TARGET" && ac_cv_path_OBJCOPY_FOR_TARGET=$OBJCOPY_FOR_TARGET
+  fi
+fi
+if test -z "$ac_cv_path_OBJCOPY_FOR_TARGET" && test -n "$gcc_cv_tool_dirs"; then
+  # Extract the first word of "objcopy", so it can be a program name with args.
+set dummy objcopy; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_OBJCOPY_FOR_TARGET+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $OBJCOPY_FOR_TARGET in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_OBJCOPY_FOR_TARGET="$OBJCOPY_FOR_TARGET" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $gcc_cv_tool_dirs
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_OBJCOPY_FOR_TARGET="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+OBJCOPY_FOR_TARGET=$ac_cv_path_OBJCOPY_FOR_TARGET
+if test -n "$OBJCOPY_FOR_TARGET"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJCOPY_FOR_TARGET" >&5
+$as_echo "$OBJCOPY_FOR_TARGET" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_OBJCOPY_FOR_TARGET" ; then
+
+
+if test -n "$OBJCOPY_FOR_TARGET"; then
+  ac_cv_prog_OBJCOPY_FOR_TARGET=$OBJCOPY_FOR_TARGET
+elif test -n "$ac_cv_prog_OBJCOPY_FOR_TARGET"; then
+  OBJCOPY_FOR_TARGET=$ac_cv_prog_OBJCOPY_FOR_TARGET
+fi
+
+if test -n "$ac_cv_prog_OBJCOPY_FOR_TARGET"; then
+  for ncn_progname in objcopy; do
+    # Extract the first word of "${ncn_progname}", so it can be a program name with args.
+set dummy ${ncn_progname}; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_OBJCOPY_FOR_TARGET+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OBJCOPY_FOR_TARGET"; then
+  ac_cv_prog_OBJCOPY_FOR_TARGET="$OBJCOPY_FOR_TARGET" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OBJCOPY_FOR_TARGET="${ncn_progname}"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJCOPY_FOR_TARGET=$ac_cv_prog_OBJCOPY_FOR_TARGET
+if test -n "$OBJCOPY_FOR_TARGET"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJCOPY_FOR_TARGET" >&5
+$as_echo "$OBJCOPY_FOR_TARGET" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  done
+fi
+
+if test -z "$ac_cv_prog_OBJCOPY_FOR_TARGET" && test -n "$with_build_time_tools"; then
+  for ncn_progname in objcopy; do
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ncn_progname} in $with_build_time_tools" >&5
+$as_echo_n "checking for ${ncn_progname} in $with_build_time_tools... " >&6; }
+    if test -x $with_build_time_tools/${ncn_progname}; then
+      ac_cv_prog_OBJCOPY_FOR_TARGET=$with_build_time_tools/${ncn_progname}
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+      break
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    fi
+  done
+fi
+
+if test -z "$ac_cv_prog_OBJCOPY_FOR_TARGET"; then
+  for ncn_progname in objcopy; do
+    if test -n "$ncn_target_tool_prefix"; then
+      # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args.
+set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_OBJCOPY_FOR_TARGET+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OBJCOPY_FOR_TARGET"; then
+  ac_cv_prog_OBJCOPY_FOR_TARGET="$OBJCOPY_FOR_TARGET" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OBJCOPY_FOR_TARGET="${ncn_target_tool_prefix}${ncn_progname}"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJCOPY_FOR_TARGET=$ac_cv_prog_OBJCOPY_FOR_TARGET
+if test -n "$OBJCOPY_FOR_TARGET"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJCOPY_FOR_TARGET" >&5
+$as_echo "$OBJCOPY_FOR_TARGET" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    fi
+    if test -z "$ac_cv_prog_OBJCOPY_FOR_TARGET" && test $build = $target ; then
+      # Extract the first word of "${ncn_progname}", so it can be a program name with args.
+set dummy ${ncn_progname}; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_OBJCOPY_FOR_TARGET+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OBJCOPY_FOR_TARGET"; then
+  ac_cv_prog_OBJCOPY_FOR_TARGET="$OBJCOPY_FOR_TARGET" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OBJCOPY_FOR_TARGET="${ncn_progname}"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJCOPY_FOR_TARGET=$ac_cv_prog_OBJCOPY_FOR_TARGET
+if test -n "$OBJCOPY_FOR_TARGET"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJCOPY_FOR_TARGET" >&5
+$as_echo "$OBJCOPY_FOR_TARGET" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    fi
+    test -n "$ac_cv_prog_OBJCOPY_FOR_TARGET" && break
+  done
+fi
+
+if test -z "$ac_cv_prog_OBJCOPY_FOR_TARGET" ; then
+  set dummy objcopy
+  if test $build = $target ; then
+    OBJCOPY_FOR_TARGET="$2"
+  else
+    OBJCOPY_FOR_TARGET="${ncn_target_tool_prefix}$2"
+  fi
+else
+  OBJCOPY_FOR_TARGET="$ac_cv_prog_OBJCOPY_FOR_TARGET"
+fi
+
+else
+  OBJCOPY_FOR_TARGET=$ac_cv_path_OBJCOPY_FOR_TARGET
+fi
+
+
+
+
 if test -z "$ac_cv_path_OBJDUMP_FOR_TARGET" ; then
   if test -n "$with_build_time_tools"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdump in $with_build_time_tools" >&5
@@ -14153,6 +14387,48 @@  $as_echo "pre-installed" >&6; }
   fi
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target objcopy" >&5
+$as_echo_n "checking where to find the target objcopy... " >&6; }
+if test "x${build}" != "x${host}" ; then
+  if expr "x$OBJCOPY_FOR_TARGET" : "x/" > /dev/null; then
+    # We already found the complete path
+    ac_dir=`dirname $OBJCOPY_FOR_TARGET`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed in $ac_dir" >&5
+$as_echo "pre-installed in $ac_dir" >&6; }
+  else
+    # Canadian cross, just use what we found
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed" >&5
+$as_echo "pre-installed" >&6; }
+  fi
+else
+  ok=yes
+  case " ${configdirs} " in
+    *" binutils "*) ;;
+    *) ok=no ;;
+  esac
+
+  if test $ok = yes; then
+    # An in-tree tool is available and we can use it
+    OBJCOPY_FOR_TARGET='$$r/$(HOST_SUBDIR)/binutils/objcopy'
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: just compiled" >&5
+$as_echo "just compiled" >&6; }
+  elif expr "x$OBJCOPY_FOR_TARGET" : "x/" > /dev/null; then
+    # We already found the complete path
+    ac_dir=`dirname $OBJCOPY_FOR_TARGET`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed in $ac_dir" >&5
+$as_echo "pre-installed in $ac_dir" >&6; }
+  elif test "x$target" = "x$host"; then
+    # We can use an host tool
+    OBJCOPY_FOR_TARGET='$(OBJDUMP)'
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: host tool" >&5
+$as_echo "host tool" >&6; }
+  else
+    # We need a cross tool
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed" >&5
+$as_echo "pre-installed" >&6; }
+  fi
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target objdump" >&5
 $as_echo_n "checking where to find the target objdump... " >&6; }
 if test "x${build}" != "x${host}" ; then
diff --git a/configure.ac b/configure.ac
index e4566a1..5ba852b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3258,6 +3258,7 @@  ACX_CHECK_INSTALLED_TARGET_TOOL(DLLTOOL_FOR_TARGET, dlltool)
 ACX_CHECK_INSTALLED_TARGET_TOOL(LD_FOR_TARGET, ld)
 ACX_CHECK_INSTALLED_TARGET_TOOL(LIPO_FOR_TARGET, lipo)
 ACX_CHECK_INSTALLED_TARGET_TOOL(NM_FOR_TARGET, nm)
+ACX_CHECK_INSTALLED_TARGET_TOOL(OBJCOPY_FOR_TARGET, objcopy)
 ACX_CHECK_INSTALLED_TARGET_TOOL(OBJDUMP_FOR_TARGET, objdump)
 ACX_CHECK_INSTALLED_TARGET_TOOL(RANLIB_FOR_TARGET, ranlib)
 ACX_CHECK_INSTALLED_TARGET_TOOL(READELF_FOR_TARGET, readelf)
@@ -3288,6 +3289,7 @@  GCC_TARGET_TOOL(gccgo, GOC_FOR_TARGET, GOC,
 GCC_TARGET_TOOL(ld, LD_FOR_TARGET, LD, [ld/ld-new])
 GCC_TARGET_TOOL(lipo, LIPO_FOR_TARGET, LIPO)
 GCC_TARGET_TOOL(nm, NM_FOR_TARGET, NM, [binutils/nm-new])
+GCC_TARGET_TOOL(objcopy, OBJCOPY_FOR_TARGET, OBJDUMP, [binutils/objcopy])
 GCC_TARGET_TOOL(objdump, OBJDUMP_FOR_TARGET, OBJDUMP, [binutils/objdump])
 GCC_TARGET_TOOL(ranlib, RANLIB_FOR_TARGET, RANLIB, [binutils/ranlib])
 GCC_TARGET_TOOL(readelf, READELF_FOR_TARGET, READELF, [binutils/readelf])