#25 compilation of Crypto/MyAes.cpp fails with invalid operands

Unstable (example)


I cannot run the prebuilt binary for AIX 5.1 as it will not load, I guess because my aix 5.1 is an older maintenance level than the binary was built on.
So I'm trying to compile p7zip_9.20.1 using gcc 2.9-aix51-020209 (very old I know) and it is failing with:


-DBREAK_HANDLER -DUNICODE -D_UNICODE -c -I. -I../../../myWindows -I../../../ -

I../../../include_windows ../../Crypto/MyAes.cpp
../../Crypto/MyAes.cpp: In method NCrypto::CAesCbcCoder::CAesCbcCoder ()': ../../Crypto/MyAes.cpp:13: invalid operandsunsigned int ()[71]' and int' to binaryoperator&'
** [MyAes.o] Error 1

The code that is failing is:

_offset = ((0 - (unsigned)(ptrdiff_t)_aes) & 0xF) / sizeof(UInt32);

Can some-one please tell me how to change this line so it is acceptable to gcc?
I'm not any sort of c++ programmer...
Any help would be much appreciated thanks.


  • Igor Pavlov

    Igor Pavlov - 2014-07-02

    Actually we need pointer to integer conversion.
    Does gcc 2.9 support pointer to unsigned conversion?
    _offset = ((0 - (ptrdiff_t)_aes) & 0xF) / sizeof(UInt32);
    _offset = ((0 - (unsigned)(size_t)(ptrdiff_t)_aes) & 0xF) / sizeof(UInt32);

    This code sets _offset in _aes array to make it (_aes + _offset) aligned for 16 bytes. It's required for Intel AES instructions.
    if your binary doesn't support Intel AES instructions, you can try to write:
    _offset = 0;

    Last edit: Igor Pavlov 2014-07-02
  • Goodvibes2

    Goodvibes2 - 2014-07-03

    Hi Igor,

    Thanks very much for your suggestions.
    I tried the first 2 suggestions but the compiler gave the same error.
    As I'm using a powerpc, I assume it has no Intel AES instructions, so I was able to compile using your 3rd suggestion of _offset = 0;
    I also had to make a similar change to CAesCtr2::CAesCtr2() in Crypto/WzAes.cpp.

    The 'make all_test' has problems with the creation of the 7za.exe.x archive :
    7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
    p7zip Version 9.20 (locale=en_US,Utf16=on,HugeFiles=on,1 CPU)

    Creating archive 7za.exe.xz

    Compressing 7za.exe 0%

    ERROR: Can't allocate required memory!
    ERROR during : /usr/local/src/packages/SOURCES/p7zip_9.20.1/check/../bin/7za -txz a 7za.exe.xz

    make: *** [test] Error 1

    The same problem occurs when testing 7zr.

    I've done some manual tests using .zip and .7z archives and they all seem to be working fine, so I'm happy.
    You're probably not interested in the .xz problem on this old platform, but if you are, just let me know if you'd like me to do anything to help.

    By the way, Does the .7z format with password always use AES256 encryption?
    There doesn't seem to be any options for specifying the encryption method for .7z.
    Is AES:19 the same as AES256?

    Thanks again for your help.

  • Igor Pavlov

    Igor Pavlov - 2014-07-03

    7zAES:19 means AES-256 + (2^19) SHA-256 iterations in password to key function.

    About xz problem. I want to fix it. If you can debug it, try to use smaller test file (some small txt file). Maybe you can try to reduce dictionary size.

    does "7z b" command work?

    Last edit: Igor Pavlov 2014-07-03
  • Igor Pavlov

    Igor Pavlov - 2014-07-03

    And do you know any way for your compiler to convert from (char *) variable to unsigned or size_t?

  • Goodvibes2

    Goodvibes2 - 2014-11-24

    Hi Igor,

    Sorry about the long pause - I should have more time now.
    I was able to fix :
    ERROR: Can't allocate required memory!
    by reducing dictionary size to 8 mb (7z b -md23)
    Error occurs using dictionary size 16 mb or greater.
    The size of the test file makes no difference.
    My AIX 5.1 is using 64 bit kernel BTW.

    I've got no idea if there is any way for g++ 2.9-aix51-020209 to convert from (char *) variable to unsigned or size_t.
    I'll try asking for help on stackexchange.

  • my p7zip

    my p7zip - 2014-12-30

    Perharps, your account cannot have unlimited memory.
    try this command : ulimit -a

    p7zip is also tested with g++ 2.9.2 but not g++ 2.9.0 ...

    I don't have acces to a AIX machine.
    p7zip 9.37 will soon be available.
    Would you try this new version on your AIX machine ?

  • Goodvibes2

    Goodvibes2 - 2015-01-05

    Hi Igor,

    Here is the ulimit info (I was compiling + testing as root) :

    # ulimit -a
    time(seconds) unlimited
    file(blocks) unlimited
    data(kbytes) 131072
    stack(kbytes) 32768
    memory(kbytes) 32768
    coredump(blocks) 2097151
    nofiles(descriptors) 2000

    AIX server has 1gb ram + 1088MB swap.

    I'm happy to try the new version. I cannot find 9.37 source yet. I can see a 9.38 source but that seems to be beta?


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks