libelf: Rearrange size test to prevent integer overflow

Sponsored by:	The FreeBSD Foundation