Missing AlignedAllocate/AlignedDeallocate iOS/ARM64 (was: Crypto++ on iOS)

149 views
Skip to first unread message

Jeffrey Walton

unread,
Dec 12, 2016, 2:36:50 PM12/12/16
to pdoh...@cipherloc.net, Crypto++ Users
On Mon, Dec 12, 2016 at 11:49 AM, <pdoh...@cipherloc.net> wrote:
> So just as a sanity check, I decided to pull the cryptopp lib out by itself
> and see if I could use that by itself to make sure that the changes I had
> made before didn't mess with that library. It does not work however and I
> get completely different errors. When trying to use cryptopp on its own, I
> get missing symbols for CryptoPP::AlignedAllocate(unsgined long) and
> CryptoPP::AlignedDeallocate(void*). AlignedAllocate is referenced from
> AllocatorwithCleanup<unsigned char, true>::allocate(unsigned long, void
> const*) and AlignedDeallocate is referenced from
> AllocatorWithCleanup<unsigned char, true>::deallocate(void*, unsigned long).
> The library is built for the right architecture I am testing on, I checked
> this with lipo -info. I am also using objective C as the language for this
> test if that makes a difference, although I do not think it does. Any ideas
> on that one?

This happens when the library is built with non-SSE and non-NEON
support. AlignedAllocate are AlignedDeallocate are used for 16-byte
aligned allocations. The aligned data buffers are eventually sent to
the SIMD (SSE) or ASIMD (ARM) coprocessors. Use of SSE and NEON can be
disabled with -DCRYPTOPP_DISABLE_ASM, which means AlignedAllocate are
AlignedDeallocate are not needed.

I usually see it surface under MinGW32 because they {are|were}
building Crypto++ with -DCRYPTOPP_DISABLE_ASM. Later, a user would
come along and not include -DCRYPTOPP_DISABLE_ASM in their CXXFLAGS.
So users wanted AlignedAllocate are AlignedDeallocate, but the library
was shipped without them.

When I use setenv-ios.sh to build the library from the latest sources,
I get the symbol. The 'T' section is the text section, which means the
symbols are present in the library.

cryptopp-arm64$ xcrun -sdk iphoneos lipo -info libcryptopp.a
input file libcryptopp.a is not a fat file
Non-fat file: libcryptopp.a is architecture: arm64

cryptopp-arm64$ nm libcryptopp.a | c++filt | egrep
'(AlignedAllocate|AlignedDeallocate)' | grep ' T '
0000000000000400 T CryptoPP::AlignedAllocate(unsigned long)
0000000000000430 T CryptoPP::AlignedDeallocate(void*)

I also performed the exercise for Crypto++ 5.6.4 and 5.6.5, and the
symbols are present too. So its not like there are strings attached to
get the symbols.

It may be worth noting.... Crypto++ 5.6.3 and earlier used
-DCRYPTOPP_DISABLE_ASM for Clang. It took Uri and I several months to
get the compiler and integrated assembler issues worked out. We could
not remove -DCRYPTOPP_DISABLE_ASM until 5.6.4.

It sounds like (to me) the Xcode project is not quite right.

Jeff

Jeffrey Walton

unread,
Dec 12, 2016, 3:25:31 PM12/12/16
to Crypto++ Users, pdoh...@cipherloc.net, nolo...@gmail.com

I updated the wiki page at https://www.cryptopp.com/wiki/IOS_(Command_Line). It had some stale information.

I'm not sure the changes are going to help with your issue, though. Your issue seems to be related to Xcode CXXFLAGS and LDFLAGS settings.

Jeff

Sree

unread,
May 10, 2018, 12:56:27 PM5/10/18
to Crypto++ Users
Hi Jeff,
I have to use CBC with CST for AES algorithm. as I did not find any library to support it even like Cryptoswift I have to look for crypto++. I generated the libcryptopp.a file, I am getting no such file error for the last step. is there something wrong with it.


clang++ -o cryptest.exe -DNDEBUG -g2 -Os -fPIC -pipe -Wall -miphoneos-version-min=7 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk -stdlib=libc++ -ffunction-sections -fdata-sections adhoc.o test.o bench1.o bench2.o validat0.o validat1.o validat2.o validat3.o datatest.o regtest.o fip salgt.o dlltest.o ./libcryptopp.a -Wl,-dead_strip

clang: error: no such file or directory: 'regtest.o'

clang: error: no such file or directory: 'fip'

clang: error: no such file or directory: 'salgt.o'

Jeffrey Walton

unread,
May 10, 2018, 2:09:25 PM5/10/18
to Crypto++ Users


On Thursday, May 10, 2018 at 12:56:27 PM UTC-4, Sree wrote:
Hi Jeff,
I have to use CBC with CST for AES algorithm. as I did not find any library to support it even like Cryptoswift I have to look for crypto++. I generated the libcryptopp.a file, I am getting no such file error for the last step. is there something wrong with it.


clang++ -o cryptest.exe -DNDEBUG -g2 -Os -fPIC -pipe -Wall -miphoneos-version-min=7 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk -stdlib=libc++ -ffunction-sections -fdata-sections adhoc.o test.o bench1.o bench2.o validat0.o validat1.o validat2.o validat3.o datatest.o regtest.o fip salgt.o dlltest.o ./libcryptopp.a -Wl,-dead_strip

clang: error: no such file or directory: 'regtest.o'

clang: error: no such file or directory: 'fip'

clang: error: no such file or directory: 'salgt.o'


regtest.o is old Crypto++ from the Crypto++ 5.6.2 days. I'm guessing its coming from GNUmakefile-cross when it was a separate download. Update to the latest version of the library. All the files are now part of the library. You may need to fetch them from GitHub if they are missing from the ZIP file. 

fips and salgt.o sounds like something from your project.

Jeff 

Sree

unread,
May 10, 2018, 4:28:58 PM5/10/18
to Crypto++ Users
Thanks Jeff,

Do u know which steps(any link) we need to use to build this library to use it on latest xcode9.2 ? Do we have to use command line to generate .a file?

 

Jeffrey Walton

unread,
May 13, 2018, 11:08:39 PM5/13/18
to Crypto++ Users


On Thursday, May 10, 2018 at 4:28:58 PM UTC-4, Sree wrote:
On Thursday, 10 May 2018 11:09:25 UTC-7, Jeffrey Walton wrote:

On Thursday, May 10, 2018 at 12:56:27 PM UTC-4, Sree wrote:
Hi Jeff,
I have to use CBC with CST for AES algorithm. as I did not find any library to support it even like Cryptoswift I have to look for crypto++. I generated the libcryptopp.a file, I am getting no such file error for the last step. is there something wrong with it.


clang++ -o cryptest.exe -DNDEBUG -g2 -Os -fPIC -pipe -Wall -miphoneos-version-min=7 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk -stdlib=libc++ -ffunction-sections -fdata-sections adhoc.o test.o bench1.o bench2.o validat0.o validat1.o validat2.o validat3.o datatest.o regtest.o fip salgt.o dlltest.o ./libcryptopp.a -Wl,-dead_strip

clang: error: no such file or directory: 'regtest.o'

clang: error: no such file or directory: 'fip'

clang: error: no such file or directory: 'salgt.o'


regtest.o is old Crypto++ from the Crypto++ 5.6.2 days. I'm guessing its coming from GNUmakefile-cross when it was a separate download. Update to the latest version of the library. All the files are now part of the library. You may need to fetch them from GitHub if they are missing from the ZIP file. 

fips and salgt.o sounds like something from your project.


Thanks Jeff,

Do u know which steps(any link) we need to use to build this library to use it on latest xcode9.2 ? Do we have to use command line to generate .a file?

Well, as far as I know you still use https://www.cryptopp.com/wiki/IOS_(Command_Line) .

We actively test the following architectures (https://github.com/weidai11/cryptopp/blob/master/TestScripts/cryptest-ios.sh): iPhoneOS iPhoneSimulator WatchOS WatchSimulator AppleTVOS AppleTVSimulator . The test results are available at https://travis-ci.org/noloader/cryptopp/builds/378299084 .

The Travis testing uses Xcode 9.1, however (https://github.com/weidai11/cryptopp/blob/master/.travis.yml). Maybe something changed with Xcode 9.2?

Jeff
Reply all
Reply to author
Forward
0 new messages