17 HMR is a great survival cartridge (rifle or handgun)
It is better to compare it to the 22LR than the 22 Magnum. The 20 grain 17 HMR loading would be great for piercing deer sculls or even taking shots through the ribs (more risky but still doable).
Body shots on rabbits and squirrels with the 20 grain load just make a pencil size hole through the animal; the 17 grain ballistic tip destroys too much meat on small game body shots.
It easily is twice as accurate as the 22 LR thus making it easier to hit your target.
In short, in every way but cost it is a much more updated rimefire cartridge than the 22LR and would be nice in an over-under 17HMR/410 (for example the Savage Model 42).
The 22 Magnum would have the advantage over the 17 HRM because of the heavier and faster 40 grain bullet will give you more penetration.
If I was going to be in a survival situation for less than two months I would go with the 17 HMR. For more than two months I would choose the 22LR because of the lower cost of ammunition.