CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Warning on AIX

  1. #1
    Join Date
    Jun 2008
    Posts
    10

    Warning on AIX

    Hi

    My dev environment is -

    AIX mars 1 5 005A28AD4C00
    Thread model: aix
    gcc version 3.3.2

    I am trying to build a popular open source cryptography library (crypto++ http://www.cryptopp.com/#download v5.5.2).
    However, I get a warning message while compiling a CPP file (dll.cpp)

    misc.h: In member function `const T& CryptoPP::Singleton<T, F, instance>::Ref()
    const [with T = CryptoPP::DL_KeyAgreementAlgorithm_DH<CryptoPP::Integer,
    CryptoPP::NoCofactorMultiplication>, F =
    CryptoPP::NewObject<CryptoPP::DL_KeyAgreementAlgorithm_DH<CryptoPP::Integer,
    CryptoPP::NoCofactorMultiplication> >, int instance = 0]':
    dh.h:85: instantiated from `const CryptoPP::DL_KeyAgreementAlgorithm<typename GROUP_PARAMETERS::Element>& CryptoPP::DH_Domain<GROUP_PARAMETERS, COFACTOR_OPTION>::GetKeyAgreementAlgorithm() const [with GROUP_PARAMETERS = CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime, COFACTOR_OPTION = CryptoPP::NoCofactorMultiplication]'
    dh.h:92: instantiated from here
    misc.h:121: warning: sorry: semantics of inline function static data `char
    s_objectState' are wrong (you'll wind up with multiple copies)

    The reference to misc.h (line 121) is in several places and I get many warning messages like that. I am going bonkers trying to figure out what this means and how to get rid of this.

    Line 120/121 looks like this -

    120: static simple_ptr<T> s_pObject;
    121: static char s_objectState = 0;

    I have attached the files in question and will be glad if someone can help me with this.

    Thanks

    Cheers!

    sid
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2008
    Posts
    10

    Re: Warning on AIX

    I tried removing the static part from the variable initialization on line 121 and tried compiling the file using g++ -DNDEBUG -g -O2 -pipe -c dll.cpp
    Now I dont get any warnings but the compiler is stuck there, it wont give any result now

  3. #3
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,019

    Re: Warning on AIX

    Change
    Code:
    120: static simple_ptr<T> s_pObject;
    121: static char s_objectState = 0;
    to
    Code:
    120: extern simple_ptr<T> s_pObject;
    121: extern char s_objectState;
    Then look for misc.cpp and add
    Code:
    char s_objectState = 0;
    Succinct is verbose for terse

  4. #4
    Join Date
    Jun 2008
    Posts
    10

    Re: Warning on AIX

    Hi, this issue was solved after I removed static however, I have a new issue that seems to be AIX specific :

    Just to summarize - I am using a cryptographic library called libcryptopp.a and building a wrapper around that library to access specific functions I need to use. The wrapper is in the form of a Shared Object so that I can call it from my legacy application.

    I have libcryptopp.a and the functions in my wrapper (C++ program - aeswrap.cpp) are defined in the ".a" library. I am using the attached make file to build the Shared Object (libaes.so). However, when I try to call the function in my wrapper, I get a segmentation violation. It is worthwhile to mention that when I create an exe out of the same wrapper by statically linking it with libcryptopp.a it works fine.

    I did a Truss on the file and these are the last few lines I got -

    0509-151 The program does not have an entry point or
    the o_snentry field in the auxiliary header is invalid.
    kwrite(2, "\t 0 5 0 9 - 1 5 1 T h".., 115) = 115
    _getpid() = 467000
    lseek(3, 0, 1) = 4096
    lseek(3, 4551, 0) = 4551
    kread(3, "\t 0 5 0 9 - 1 9 4 E x".., 4096) = 454
    0509-194 Examine file headers with the 'dump -ohv' command.
    kwrite(2, "\t 0 5 0 9 - 1 9 4 E x".., 61) = 61
    kfcntl(1, F_GETFL, 0x00000000) = 2
    kfcntl(2, F_GETFL, 0x00000000) = 2
    _exit(255)

    ldd libaes.so gives -

    /usr/lib/libcrypt.a(shr.o)
    /usr/lib/libc.a(shr.o)
    ./libaes.so

    and a dump gives -

    libaes.so:

    ***Object Module Header***

    1. Sections Symbol Ptr # Symbols Opt Hdr Len Flags

    5 0x00080544 11231 72 0x3002
    Flags=( EXEC DYNLOAD SHROBJ )
    Timestamp = "25 Jun 18:23:48 2008"
    Magic = 0x1df (32-bit XCOFF)

    ***Optional Header***
    Tsize Dsize Bsize Tstart Dstart
    0x0000c1c6 0x00001560 0x00000001 0x00000000 0x00000000

    SNloader SNentry SNtext SNtoc SNdata
    0x0004 0x0000 0x0001 0x0002 0x0002

    TXTalign DATAalign TOC vstamp entry
    0x0005 0x0003 0x00001308 0x0001 0xffffffff

    maxSTACK maxDATA SNbss magic modtype
    0x00000000 0x00000000 0x0003 0x010b RE

    ***Section Header Information***
    Section Header for .text
    PHYaddr VTRaddr SCTsiz RAWptr RELptr
    0x00000000 0x00000000 0x0000c1c6 0x00000160 0x00077f5c

    LN#ptr #RELent #LINent Flags
    0x0007d20e 0x03d0 0x0889 0x00000020

    Section Header for .data
    PHYaddr VTRaddr SCTsiz RAWptr RELptr
    0x00000000 0x00000000 0x00001560 0x0000c328 0x0007a57c

    LN#ptr #RELent #LINent Flags
    0x00000000 0x0475 0x0000 0x00000040

    Section Header for .bss
    PHYaddr VTRaddr SCTsiz RAWptr RELptr
    0x00001560 0x00001560 0x00000001 0x00000000 0x00000000

    LN#ptr #RELent #LINent Flags
    0x00000000 0x0000 0x0000 0x00000080

    Section Header for .loader
    PHYaddr VTRaddr SCTsiz RAWptr RELptr
    0x00000000 0x00000000 0x00005902 0x0000d888 0x00000000

    LN#ptr #RELent #LINent Flags
    0x00000000 0x0000 0x0000 0x00001000

    Section Header for .debug
    PHYaddr VTRaddr SCTsiz RAWptr RELptr
    0x00000000 0x00000000 0x00064dd1 0x0001318a 0x00000000

    LN#ptr #RELent #LINent Flags
    0x00000000 0x0000 0x0000 0x00002000

    I am stuck here and I dont know what I am doing wrong. Is the SO not being built correctly? I haave no clue what is to be done next. Just to debug I opened a file (FILE *fp) and noticed that the program exits after it encounters a particular function in the cpp program -

    StringSource( PlainText.c_str() , true,
    new StreamTransformationFilter( Encryptor,
    new StringSink( CipherText )
    ) // StreamTransformationFilter
    ); // StringSource

    This function is defined in the archive ".a" file.

    I am just confused because it goes through when I make it into an exe? obviously there seems to be something wrong with the SO. Any help will be greatly appreciated.

    AIX Release 1 Version 5
    g++ version 3.3.2
    Attached Files Attached Files

  5. #5
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,019

    Re: Warning on AIX

    Just a long shot. Compile as position independent code and use gcc or g++ to do the linking

    Changes

    CFLAGS=-g -Wall $(INCLUDE) -fPIC
    LDFLAGS=-shared
    LD=gcc

    It is something I've noticed about C++ progs - we can never get all the libraries whenever there is something STL related. If you use g++ or gcc or linking, the executable always works correctly. If you use ld, it sometimes works, but most of the time it comes up with a segv. If you run ldd on the exe, you'll find a whole load of stuff missing even though it links ok.

    Be careful of -b in ld. Sun, AIX and gcc all have a -b parameter but the meaning and how it operates is different on all three.
    Succinct is verbose for terse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured