Bug 20993 - GCC/GCJ not creating proper symbols for inline native CNI code
: GCC/GCJ not creating proper symbols for inline native CNI code
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: libgcj
: 4.0.0
: P2 normal
: 4.0.3
Assigned To: Not yet assigned to anyone
:
:
:
:
  Show dependency treegraph
 
Reported: 2005-04-13 15:20 UTC by steve
Modified: 2005-11-08 16:27 UTC (History)
2 users (show)

See Also:
Host: i386-mingw32msvc
Target: i386-mingw32msvc
Build: i386-mingw32msvc
Known to work:
Known to fail:
Last reconfirmed: 2005-11-08 16:26:06


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description steve 2005-04-13 15:20:42 UTC
The following code will not link because j.getName has multiple definitions. 
Both j.o and natj.o contain a T definition when natj.o should contain a W def.

Ultimatly this causes the mingw 4.0.0 cross compiler to not build a functioning
 native compiler becuase libgcj.a contains multiple defintion.

[steve@pascal steve]$ cat j.java
class j
{
        String _name;
        j() {
                _name="BOB";
        }
        String getName() {
                return _name;
        };
}

#pragma implementation "j.h"
#include "j.h"
#include <java/lang/Object.h>
#include <gcj/cni.h>

int main(int argc,char** argv)
{
        j *bob=new j();
        bob->getName();
        return 0;
}

gcjh j creates j.h
$ cat j.h
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-

#ifndef __j__
#define __j__

#pragma interface

#include <java/lang/Object.h>

extern "Java"
{
  class j;
}

class j : public ::java::lang::Object
{
public: // actually package-private
  j ();
  virtual ::java::lang::String *getName () { return _name; }
  ::java::lang::String * __attribute__((aligned(__alignof__(
::java::lang::Object )))) _name;
public:

  static ::java::lang::Class class$;
};

#endif /* __j__ */

$ nm j.o
00000000 b .bss
00000000 d .ctors
00000000 d .data
00000000 r .rdata
00000000 N .stab
00000000 N .stabstr
00000000 t .text
00000094 d __catch_classes_j
00000088 d __CD_j
00000090 d __CT_j
00000000 d __FL_j
00000030 t __GLOBAL__I_0__ZN1jC1Ev
         U __Jv_RegisterClass
00000020 d __MT_j
00000000 r __Utf1
0000000a r __Utf2
00000016 r __Utf3
0000001e r __Utf4
0000002a r __Utf5
00000044 r __Utf6
0000004c r __Utf7
000000c0 D __ZN1j6class$E
00000024 T __ZN1j7getNameEv
00000000 T __ZN1jC1Ev
         U __ZN4java4lang6Object5cloneEv
         U __ZN4java4lang6Object6class$E
         U __ZN4java4lang6Object6equalsEPS1_
         U __ZN4java4lang6Object8finalizeEv
         U __ZN4java4lang6Object8hashCodeEv
         U __ZN4java4lang6Object8toStringEv
         U __ZN4java4lang6ObjectC1Ev
         U __ZN4java4lang6String6class$E
00000060 D __ZTVN1jE
         U __ZTVN4java4lang5ClassE

$ nm natj.o
00000000 b .bss
00000000 d .data
00000000 r .rdata$_ZTI15_JvObjectPrefix
00000000 r .rdata$_ZTI1j
00000000 r .rdata$_ZTIN4java4lang6ObjectE
00000000 r .rdata$_ZTS15_JvObjectPrefix
00000000 r .rdata$_ZTS1j
00000000 r .rdata$_ZTSN4java4lang6ObjectE
00000000 t .text
00000000 t .text$_ZN1j7getNameEv
         U ___main
         U __alloca
         U __Jv_AllocObject
         U __ZN1j6class$E
00000000 T __ZN1j7getNameEv
         U __ZN1jC1Ev
00000000 R __ZTI15_JvObjectPrefix
00000000 R __ZTI1j
00000000 R __ZTIN4java4lang6ObjectE
00000000 R __ZTS15_JvObjectPrefix
00000000 R __ZTS1j
00000000 R __ZTSN4java4lang6ObjectE
         U __ZTVN10__cxxabiv117__class_type_infoE
         U __ZTVN10__cxxabiv120__si_class_type_infoE
00000000 T _main
Comment 1 steve 2005-04-13 19:03:13 UTC
This as also been duplicated using the mingw binary release of
gcc-3.4.2-20040916-1.
Comment 2 Andrew Pinski 2005-11-08 16:25:38 UTC
*** Bug 24736 has been marked as a duplicate of this bug. ***
Comment 3 Andrew Pinski 2005-11-08 16:26:06 UTC
Confirmed.
Comment 4 Andrew Pinski 2005-11-08 16:27:59 UTC
Fixed by:
+2005-11-08  Terry Laurenzo  <tlaurenzo@gmail.com>
+
+       PR java/24736
+       * gjavah.c (HANDLE_CODE_ATTRIBUTE): Only define for ELF Object
+       formats.
+       * gjavah.c (decompile_method): Add ATTRIBUTE_UNUSED
+