Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jan 2007 14:41:12 -0800
From:      Marcel Moolenaar <xcllnt@mac.com>
To:        Ruslan Ermilov <ru@freebsd.org>
Cc:        FreeBSD Current <freebsd-current@freebsd.org>, LI Xin <delphij@delphij.net>
Subject:   Re: PowerPC port broken?
Message-ID:  <5DC1BBA2-94E6-4A32-B000-498244D7BB30@mac.com>
In-Reply-To: <20070130132839.GA1052@rambler-co.ru>
References:  <45B97535.5070900@delphij.net> <A003FD22-616E-440E-881D-4CCEE2D90F7D@mac.com> <45B997ED.7000605@delphij.net> <45B99C6E.2030803@delphij.net> <1C63ACE4-DD1E-4FDB-A36B-F3D9650773EF@mac.com> <45B9AA00.3030906@delphij.net> <20070130132839.GA1052@rambler-co.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 30, 2007, at 5:28 AM, Ruslan Ermilov wrote:

>>>> Latest build shows this:
>>>>
>>>> (What does Assembler messages:
>>>> FATAL: can't create crtbegin.o: Invalid bfd target
>>>> mean for me, by the way?)
>>>
>>
> We've a fix for this problem since last summer.
> See PR amd64/102996 for details and the patch.
>
> Please don't ask me about committing it into
> our Binutils.  :-)

The fix is actually wrong but happen to do the right thing.
BFD_DEFAULT_TARGET_SIZE is used outside of the libbfd directory.
It is references by gas/config/tc-ppc.c and opcodes/ppc-dis.c.
Within BFD it is also referenced only for PowerPC, which is
why this problem only exists for PowerPC. The fixes in the PR
only define TARGET_64BIT in the libbfd Makefile, which means
that BFD_DEFAULT_TARGET_SIZE may not get the right definitions
when used by sources outside the libbfd directory.

A good fix in our context is to define it BFD_DEFAULT_TARGET_SIZE
as 32 unconditionally in bfd.h. Since the define is only referenced
for PowerPC targets and our PowerPC target is 32-bit only, e.g:

Index: libbfd/bfd.h
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/binutils/libbfd/bfd.h,v
retrieving revision 1.3
diff -u -r1.3 bfd.h
--- libbfd/bfd.h        8 Jul 2004 17:05:32 -0000       1.3
+++ libbfd/bfd.h        31 Jan 2007 22:30:30 -0000
@@ -56,16 +56,14 @@
     been selected with --enable-targets, or if --enable-64-bit-bfd.  */
  #define BFD_ARCH_SIZE 64

+/* The word size of the default PowerPC bfd target.  */
+#define BFD_DEFAULT_TARGET_SIZE 32

  #if defined(__i386__) || defined(__powerpc__) || defined(__arm__)
-/* The word size of the default bfd target.  */
-#define BFD_DEFAULT_TARGET_SIZE 32
  #define BFD_HOST_64BIT_LONG 0
  #define BFD_HOST_64_BIT long long
  #define BFD_HOST_U_64_BIT unsigned long long
  #elif defined(__alpha__) || defined(__sparc64__) || defined 
(__amd64__) || defined(__ia64__)
-/* The word size of the default bfd target.  */
-#define BFD_DEFAULT_TARGET_SIZE 64
  #define BFD_HOST_64BIT_LONG 1
  #define BFD_HOST_64_BIT long
  #define BFD_HOST_U_64_BIT unsigned long



A better fix would be to define BFD_DEFAULT_TARGET_SIZE in the top-
level Makefile so that the definition can be used everywhere within
the binutils sources. It's setting can be made dependent upon
TARGET_ARCH. This makes sure that future imports of binutils where
BFD_DEFAULT_TARGET_SIZE may be referenced for more targets will
work in this respect, e.g:

Index: Makefile.inc0
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/binutils/Makefile.inc0,v
retrieving revision 1.37
diff -u -r1.37 Makefile.inc0
--- Makefile.inc0       8 Jul 2004 17:05:30 -0000       1.37
+++ Makefile.inc0       31 Jan 2007 22:39:14 -0000
@@ -22,6 +22,12 @@
  RELSRC=        ${RELTOP}/../../../contrib/binutils
  SRCDIR=        ${.CURDIR}/${RELSRC}

+.if ${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "i386" || $ 
{TARGET_ARCH} == "powerpc"
+CFLAGS+= -DBFD_DEFAULT_TARGET_SIZE=32
+.else
+CFLAGS+= -DBFD_DEFAULT_TARGET_SIZE=64
+.endif
+
  CFLAGS+= -I.
  .if exists(${.CURDIR}/${TARGET_ARCH})
  CFLAGS+= -I${.CURDIR}/${TARGET_ARCH}
Index: libbfd/bfd.h
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/binutils/libbfd/bfd.h,v
retrieving revision 1.3
diff -u -r1.3 bfd.h
--- libbfd/bfd.h        8 Jul 2004 17:05:32 -0000       1.3
+++ libbfd/bfd.h        31 Jan 2007 22:38:32 -0000
@@ -58,14 +58,10 @@
  #if defined(__i386__) || defined(__powerpc__) || defined(__arm__)
-/* The word size of the default bfd target.  */
-#define BFD_DEFAULT_TARGET_SIZE 32
  #define BFD_HOST_64BIT_LONG 0
  #define BFD_HOST_64_BIT long long
  #define BFD_HOST_U_64_BIT unsigned long long
  #elif defined(__alpha__) || defined(__sparc64__) || defined 
(__amd64__) || defined(__ia64__)
-/* The word size of the default bfd target.  */
-#define BFD_DEFAULT_TARGET_SIZE 64
  #define BFD_HOST_64BIT_LONG 1
  #define BFD_HOST_64_BIT long
  #define BFD_HOST_U_64_BIT unsigned long


-- 
Marcel Moolenaar
xcllnt@mac.com





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5DC1BBA2-94E6-4A32-B000-498244D7BB30>