This patch prepares for ELFv2, where sizes of these areas change. It also makes some minor changes to improve code efficiency.