From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6049 invoked by alias); 23 Mar 2004 23:13:11 -0000 Mailing-List: contact sid-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sid-owner@sources.redhat.com Received: (qmail 6007 invoked from network); 23 Mar 2004 23:13:04 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 23 Mar 2004 23:13:04 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i2NND3WA023103 for ; Tue, 23 Mar 2004 18:13:03 -0500 Received: from zenia.home.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i2NND2j21878; Tue, 23 Mar 2004 18:13:02 -0500 To: sid@sources.redhat.com Subject: PATCH: fix up fake BFD functions in cgen-cpu/tracedis.cxx From: Jim Blandy Date: Tue, 23 Mar 2004 23:13:00 -0000 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-q1/txt/msg00050.txt.bz2 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 * 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 (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 (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 (addr); ! return (byteaddr[0] << 8) | byteaddr[1]; } ! extern "C" bfd_vma ! bfd_getl16 (register const void *addr) { ! const bfd_byte *byteaddr = static_cast (addr); ! return (byteaddr[1] << 8) | byteaddr[0]; } ! extern "C" bfd_vma ! bfd_getb32 (register const void *addr) { + const bfd_byte *byteaddr = static_cast (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 (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 (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 (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;