I am using Yocto to create custom linux images for an embedded project. I have discovered something strange recently and am having trouble wrapping my head around the issue. One of the applications contained in the image is custom software, let's call the application foo. After a successful build on the yocto build server, the built, cross-compiled foo executable can be found in the tmp/work/armv7at2hf-neon-fslc-linux-gnueabi/foo/1.0.0-r0/git directory. The size of the foo executable (obtained using ls -al) on the build server is 40978880 bytes.
The image can be ran on target hardware by flashing an SD card w/ the generated image tar.gz file. After flashing an SD card and booting the image on the target, I navigate to the directory in which foo was installed. On the target, I again obtain the size of the executable using ls -al and I find that the size of the foo executable has shrunk and is 38585152 bytes. Despite the executable size shrinking, the application works fine.
This change in size is unacceptable because it prevents me from being able to do a sha256 verification of the foo executable during the application launch process. The verification fails since foo on the build server is not byte for byte identical to the foo executable that is installed on the target. The size difference has left me baffled. Especially since all the other files that my layer installs on the rootfs have the same size on both the build server and the target.
What could be causing this difference regarding the size of the foo executable?