In D49685 sysroot behaviour was partially fixed. But files from local filesystem with same path still has priority over files from sysroot.
This patch fixes it by removing fallback to local filesystem from RemoteAwarePlatform::GetModuleSpec(). It is not actually required because higher level code do such fallback itself. See, for example, resolver in Platform::GetSharedModule().
Would it be possible to make this test not depend on the existence of /bin/sh? Maybe if you place the "wrong" file in $BUILD/a.out, and the "right" file at $BUILD/sysroot/$BUILD/a.out and then check that the "right" file was selected?
I guess that will require creating a new core file with a sufficiently long path so that it can be replaced by the right runtime value.