Energy Principle for 3-d Resistive Instabilities in Shaped-cross-section Tokamaks