public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
* PATCH: fix up fake BFD functions in cgen-cpu/tracedis.cxx
@ 2004-03-23 23:13 Jim Blandy
  2004-03-26 20:24 ` Jim Blandy
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Blandy @ 2004-03-23 23:13 UTC (permalink / raw)
  To: sid


In trying to build SID with --disable-shared, I found that linking
'sid' died because the references to these functions in libopcodes
weren't being satisfied.  As it turns out:

$ nm tracedis.o | grep bfd_get_bits
000024de T _Z12bfd_get_bitsPhii
$

But when I added the 'extern "C"' thingies, the compiler was suddenly
able to check the definitions against the declarations in bfd/bfd.h
again.  Those changed recently; see Alan Modra's 2004-03-15 change in
bfd/ChangeLog.

2004-03-23  Jim Blandy  <jimb@redhat.com>

	* tracedis.cxx (bfd_get_arch, bfd_getb16, bfd_getl16, bfd_getb32)
	(bfd_getl32, bfd_put_bits, bfd_get_bits, bfd_lookup_arch): These
	definitions are meant to satisfy references in libopcodes, which
	is C code, so declare these with 'extern "C"'.  Adjust types to
	match those declared in the BFD header file.

Index: sid/component/cgen-cpu/tracedis.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/tracedis.cxx,v
retrieving revision 1.2
diff -c -r1.2 tracedis.cxx
*** sid/component/cgen-cpu/tracedis.cxx	9 Jan 2003 18:14:56 -0000	1.2
--- sid/component/cgen-cpu/tracedis.cxx	23 Mar 2004 22:57:56 -0000
***************
*** 74,80 ****
  //
  // so that only really leaves bfd_lookup_arch() as an issue...we can hack it.
  
! enum bfd_architecture
  bfd_get_arch(bfd *abfd)
  { 
    return static_cast<enum bfd_architecture> (0);
--- 74,80 ----
  //
  // so that only really leaves bfd_lookup_arch() as an issue...we can hack it.
  
! extern "C" enum bfd_architecture
  bfd_get_arch(bfd *abfd)
  { 
    return static_cast<enum bfd_architecture> (0);
***************
*** 82,126 ****
  
  /* Stolen from libbfd.  */
  
! bfd_vma
! bfd_getb16 (register const bfd_byte *addr)
  {
!   return (addr[0] << 8) | addr[1];
  }
  
! bfd_vma
! bfd_getl16 (register const bfd_byte *addr)
  {
!   return (addr[1] << 8) | addr[0];
  }
  
! bfd_vma
! bfd_getb32 (register const bfd_byte *addr)
  {
    unsigned long v;
  
!   v = (unsigned long) addr[0] << 24;
!   v |= (unsigned long) addr[1] << 16;
!   v |= (unsigned long) addr[2] << 8;
!   v |= (unsigned long) addr[3];
    return (bfd_vma) v;
  }
  
! bfd_vma
! bfd_getl32 (register const bfd_byte *addr)
  {
    unsigned long v;
  
!   v = (unsigned long) addr[0];
!   v |= (unsigned long) addr[1] << 8;
!   v |= (unsigned long) addr[2] << 16;
!   v |= (unsigned long) addr[3] << 24;
    return (bfd_vma) v;
  }
  
! void
! bfd_put_bits (bfd_vma data, bfd_byte* addr, int bits, int big_p)
  {
    int i;
    int bytes;
  
--- 82,131 ----
  
  /* Stolen from libbfd.  */
  
! extern "C" bfd_vma
! bfd_getb16 (register const void *addr)
  {
!   const bfd_byte *byteaddr = static_cast <const bfd_byte *> (addr);
!   return (byteaddr[0] << 8) | byteaddr[1];
  }
  
! extern "C" bfd_vma
! bfd_getl16 (register const void *addr)
  {
!   const bfd_byte *byteaddr = static_cast <const bfd_byte *> (addr);
!   return (byteaddr[1] << 8) | byteaddr[0];
  }
  
! extern "C" bfd_vma
! bfd_getb32 (register const void *addr)
  {
+   const bfd_byte *byteaddr = static_cast <const bfd_byte *> (addr);
    unsigned long v;
  
!   v = (unsigned long) byteaddr[0] << 24;
!   v |= (unsigned long) byteaddr[1] << 16;
!   v |= (unsigned long) byteaddr[2] << 8;
!   v |= (unsigned long) byteaddr[3];
    return (bfd_vma) v;
  }
  
! extern "C" bfd_vma
! bfd_getl32 (register const void *addr)
  {
+   const bfd_byte *byteaddr = static_cast <const bfd_byte *> (addr);
    unsigned long v;
  
!   v = (unsigned long) byteaddr[0];
!   v |= (unsigned long) byteaddr[1] << 8;
!   v |= (unsigned long) byteaddr[2] << 16;
!   v |= (unsigned long) byteaddr[3] << 24;
    return (bfd_vma) v;
  }
  
! extern "C" void
! bfd_put_bits (bfd_uint64_t data, void* addr, int bits, bfd_boolean big_p)
  {
+   bfd_byte *byteaddr = static_cast <bfd_byte *> (addr);
    int i;
    int bytes;
  
***************
*** 132,147 ****
      {
        int index = big_p ? bytes - i - 1 : i;
  
!       addr[index] = (bfd_byte) data;
        data >>= 8;
      }
  }
  
  /* Stolen from libbfd.  */
! bfd_vma
! bfd_get_bits (bfd_byte* addr, int bits, int big_p)
  {
!   bfd_vma data;
    int i;
    int bytes;
  
--- 137,153 ----
      {
        int index = big_p ? bytes - i - 1 : i;
  
!       byteaddr[index] = (bfd_byte) data;
        data >>= 8;
      }
  }
  
  /* Stolen from libbfd.  */
! extern "C" bfd_uint64_t
! bfd_get_bits (const void* addr, int bits, int big_p)
  {
!   const bfd_byte *byteaddr = static_cast <const bfd_byte *> (addr);
!   bfd_uint64_t data;
    int i;
    int bytes;
  
***************
*** 154,160 ****
      {
        int index = big_p ? i : bytes - i - 1;
  
!       data = (data << 8) | addr[index];
      }
  
    return data;
--- 160,166 ----
      {
        int index = big_p ? i : bytes - i - 1;
  
!       data = (data << 8) | byteaddr[index];
      }
  
    return data;
***************
*** 199,205 ****
    p->name = name;
  }
  
! const bfd_arch_info_type *
  bfd_lookup_arch (enum bfd_architecture arch, unsigned long machine)
  { 
    static bfd_arch_info_type info;
--- 205,211 ----
    p->name = name;
  }
  
! extern "C" const bfd_arch_info_type *
  bfd_lookup_arch (enum bfd_architecture arch, unsigned long machine)
  { 
    static bfd_arch_info_type info;

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

* Re: PATCH: fix up fake BFD functions in cgen-cpu/tracedis.cxx
  2004-03-23 23:13 PATCH: fix up fake BFD functions in cgen-cpu/tracedis.cxx Jim Blandy
@ 2004-03-26 20:24 ` Jim Blandy
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Blandy @ 2004-03-26 20:24 UTC (permalink / raw)
  To: sid


I've committed this.

Jim Blandy <jimb@redhat.com> writes:

> In trying to build SID with --disable-shared, I found that linking
> 'sid' died because the references to these functions in libopcodes
> weren't being satisfied.  As it turns out:
> 
> $ nm tracedis.o | grep bfd_get_bits
> 000024de T _Z12bfd_get_bitsPhii
> $
> 
> But when I added the 'extern "C"' thingies, the compiler was suddenly
> able to check the definitions against the declarations in bfd/bfd.h
> again.  Those changed recently; see Alan Modra's 2004-03-15 change in
> bfd/ChangeLog.
> 
> 2004-03-23  Jim Blandy  <jimb@redhat.com>
> 
> 	* tracedis.cxx (bfd_get_arch, bfd_getb16, bfd_getl16, bfd_getb32)
> 	(bfd_getl32, bfd_put_bits, bfd_get_bits, bfd_lookup_arch): These
> 	definitions are meant to satisfy references in libopcodes, which
> 	is C code, so declare these with 'extern "C"'.  Adjust types to
> 	match those declared in the BFD header file.

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

end of thread, other threads:[~2004-03-26 20:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-23 23:13 PATCH: fix up fake BFD functions in cgen-cpu/tracedis.cxx Jim Blandy
2004-03-26 20:24 ` Jim Blandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).