Cross-Layer Design for Secure and Resilient Cyber-Physical Systems