From: Jim Blandy <jimb@redhat.com>
To: sid@sources.redhat.com
Subject: PATCH: fix up fake BFD functions in cgen-cpu/tracedis.cxx
Date: Tue, 23 Mar 2004 23:13:00 -0000 [thread overview]
Message-ID: <vt21xnjyx94.fsf@zenia.home> (raw)
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;
next reply other threads:[~2004-03-23 23:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-23 23:13 Jim Blandy [this message]
2004-03-26 20:24 ` Jim Blandy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vt21xnjyx94.fsf@zenia.home \
--to=jimb@redhat.com \
--cc=sid@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).