FIX: calculate size for .dynamic before layout ELF

1. FIX: calculate size for section .dynamic before layout ELF.
2. FEAT: code refactoring.