Makers Blog Archive

x86 or ARM? Check your cross compilation with “readelf”

fwalde@phoenixcontact.com 22 September 2017 min. read
491 views 0 comments
Using your own or other cross compiled executables is sometimes not clear documented for which target it was originally compiled. Compiling a Library for the AXC F 2152 means you have to compile it for an ARM architecture.
In such situation the tool “readelf” is very helpful and this manual demonstrates the usage with an example
(a more detailed description is available here).
 
Download
article

Usage of readelf and grep

Calling readelf gives a lot of output, it’s better to pipe the output to grep to filter and view only what you need.

readelf -h libcpp_redis.a
grep 'Class\|File\|Machine'

Use the “|” pipe operator to send the output of readelf to grep as follows:

 readelf -h libcpp_redis.a | grep 'Class\|File\|Machine' 

This leads to the output
 File: libcpp_redis.a(future_client.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(logger.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(redis_client.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(redis_subscriber.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(reply.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(redis_connection.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(array_builder.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(builders_factory.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(bulk_string_builder.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(error_builder.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(integer_builder.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(reply_builder.cpp.o)
Class: ELF32
Machine: ARM
File: libcpp_redis.a(simple_string_builder.cpp.o)
Class: ELF32
Machine: ARM

Yes it is compiled to be used on a ARM processor and you can use the binary on an AXC F 2152!

Note:

The Makers Blog shows applications and user stories of community members that are not tested or reviewed by Phoenix Contact. Use them at your own risk.

Discussion

Please login/register to comment

Login/Register

Leave a Reply

Newsletter
Never miss a new article
Sign up for the newsletter
Never miss news about PLCnext Technology
Get interesting content via newsletter four times a year
Receive exclusive information before all other users