Framed M-branes, corners, and topological invariants