We add DWARF support in https://reviews.llvm.org/D97184. For DWARF sections, because there are many of them especially for DWARF 5, 20 DWARF sections without split-dwarf feature and 30 sections with split-dwarf support, it is not good to predefine them as we do for csect sections(text, data, bss). We should dynamically allocate section entries for DWARF sections.
This patch refactors the generation for csect sections to be dynamically allocated, so csect sections can be handled the same way as DWARF sections.
This patch also refactors the groups to be dynamically allocated in one csect section.
Because of dynamically allocating, the order of the sections/groups is determined by the object writer's caller. As shown in the test, the order of BSSCsects and FuncDSCsects is changed after this patch.
If we are doing dynamic allocation for CsectGroup, why do we need to store pointers?