Re: PowerPC port broken?

From: Marcel Moolenaar <xcllnt_at_mac.com>
Date: Wed, 31 Jan 2007 14:41:12 -0800
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
_at__at_ -56,16 +56,14 _at__at_
     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
_at__at_ -22,6 +22,12 _at__at_
  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
_at__at_ -58,14 +58,10 _at__at_
  #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_at_mac.com
Received on Wed Jan 31 2007 - 21:42:56 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:05 UTC