Linker script not working as expected when trying to compile elf file - cpp, exceptions

Hello all,

I am currently working on adding cpp exception support to loadable elf binaries in my project. The current issue is that, even though I have mentioned the sections for exidx and extab in the linker script, the actual elf file generated does not follow the linker script.

SECTIONS
{
.text 0x00000000 :
{
_stext_flash = . ;
*(.text)
*(.text.*)
*(.gnu.warning)
*(.stub)
*(.glue_7)
*(.glue_7t)
*(.jcr)

*(.gnu.linkonce.t.*)
*(.init) /* Old ABI */
*(.fini) /* Old ABI */
_etext_flash = . ;
}

.rodata :
{
_srodata = . ;
*(.rodata)
*(.rodata1)
*(.rodata.*)
*(.gnu.linkonce.r*)
_erodata = . ;
_eronly = .;
}

.data 0x00000000 :
{
_sdata = . ;
*(.data)
*(.data1)
*(.data.*)
*(.gnu.linkonce.d*)
_edata = . ;
}

.ctors :
{
_sctors = . ;
*(.ctors) /* Old ABI: Unallocated */
*(.init_array) /* New ABI: Allocated */
_ectors = . ;
}

.dtors :
{
_sdtors = . ;
*(.dtors) /* Old ABI: Unallocated */
*(.fini_array) /* New ABI: Allocated */
_edtors = . ;
}

.ARM.extab :
{
*(.ARM.extab*)
}

.ARM.exidx :
{
__exidx_start = . ;
*(.ARM.exidx*)
__exidx_end = . ;
}

.bss :
{
_sbss = . ;
*(.bss)
*(.bss.*)
*(.sbss)
*(.sbss.*)
*(.gnu.linkonce.b*)
*(COMMON)
_ebss = . ;
}

/* Stabs debugging sections. */
.
.
.
}

But, when I checked the sections created using readelf -S, it has multiple section of text, extab, exidx even though I have grouped them together in the linker script.

[135] .group GROUP 00000000 000474 000008 04 392 10201 4
[136] .group GROUP 00000000 00047c 000008 04 392 10549 4
[137] .group GROUP 00000000 000484 000008 04 392 10317 4
[138] .group GROUP 00000000 00048c 000008 04 392 11364 4
[139] .group GROUP 00000000 000494 000008 04 392 10312 4
[140] .group GROUP 00000000 00049c 000008 04 392 11481 4
[141] .group GROUP 00000000 0004a4 000010 04 392 11541 4
[142] .text PROGBITS 00000000 0004b8 06349c 00 AX 0 0 8
[143] .rel.text REL 00000000 44c514 034088 08 I 392 142 4
[144] .text._ZN11C[...] PROGBITS 00000000 063954 000002 00 AXG 0 0 2
[145] .text._ZN11C[...] PROGBITS 00000000 063958 000024 00 AXG 0 0 4
[146] .rel.text._Z[...] REL 00000000 48059c 000020 08 I 392 145 4
[147] .text._ZNK10[...] PROGBITS 00000000 06397c 000014 00 AXG 0 0 4
[148] .rodata PROGBITS 00000018 063990 0241e3 00 A 0 0 8
[149] .rel.rodata REL 00000000 4805bc 001c30 08 I 392 148 4
[150] .ARM.extab.t[...] PROGBITS 00000000 087b73 000000 00 AG 0 0 1
[151] .ARM.exidx.t[...] ARM_EXIDX 00000000 087b74 000008 00 ALG 144 0 4
[152] .rel.ARM.exi[...] REL 00000000 4821ec 000008 08 I 392 151 4
[153] .ARM.extab.t[...] PROGBITS 00000000 087b7c 00000c 00 AG 0 0 4
[154] .ARM.exidx.t[...] ARM_EXIDX 00000000 087b88 000008 00 ALG 145 0 4
[155] .rel.ARM.exi[...] REL 00000000 4821f4 000018 08 I 392 154 4
[156] .rodata._ZTSv PROGBITS 00000000 087b90 000002 00 AG 0 0 4
[157] .rodata._ZTSPv PROGBITS 00000000 087b94 000003 00 AG 0 0 4
[158] .rodata._ZTSPKv PROGBITS 00000000 087b98 000004 00 AG 0 0 4
[159] .rodata._ZTSb PROGBITS 00000000 087b9c 000002 00 AG 0 0 4
[160] .rodata._ZTSPb PROGBITS 00000000 087ba0 000003 00 AG 0 0 4
[161] .rodata._ZTSPKb PROGBITS 00000000 087ba4 000004 00 AG 0 0 4
[162] .rodata._ZTSw PROGBITS 00000000 087ba8 000002 00 AG 0 0 4

Is there something wrong with my linker script? Any guidance would you very helpful.

Incase I dont add any cpp code, the sections are fine,

Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 000038 001f68 00 AX 0 0 8
[ 2] .rel.text REL 00000000 032c4c 000598 08 I 27 1 4
[ 3] .rodata PROGBITS 00001f68 001fa0 000355 00 A 0 0 8
[ 4] .data PROGBITS 00000000 0022f5 000005 00 WA 0 0 1
[ 5] .ctors PROGBITS 00000005 0022fa 000000 00 W 0 0 1
[ 6] .dtors PROGBITS 00000005 0022fa 000000 00 W 0 0 1
[ 7] .ARM.extab PROGBITS 00000005 0022fa 000000 00 A 0 0 1
[ 8] .ARM.exidx ARM_EXIDX 00000008 0022fc 000008 00 AL 1 0 4
[ 9] .rel.ARM.exidx REL 00000000 0331e4 000008 08 I 27 8 4
[10] .bss NOBITS 00000010 002304 000000 00 WA 0 0 1
[11] .comment PROGBITS 00000000 002304 001780 01 MS 0 0 1
[12] .ARM.attributes ARM_ATTRIBUTES 00000000 003a84 000038 00 0 0 1
[13] .debug_abbrev PROGBITS 00000000 003abc 0040ba 00 0 0 1
[14] .debug_info PROGBITS 00000000 007b76 013253 00 0 0 1
[15] .rel.debug_info REL 00000000 0331ec 00a1f0 08 I 27 14 4
[16] .debug_line PROGBITS 00000000 01adc9 004118 00 0 0 1
[17] .rel.debug_line REL 00000000 03d3dc 0001c0 08 I 27 16 4
[18] .debug_aranges PROGBITS 00000000 01eee8 000640 00 0 0 8
[19] .rel.debug_a[...] REL 00000000 03d59c 000340 08 I 27 18 4
[20] .debug_loc PROGBITS 00000000 01f528 00281e 00 0 0 1
[21] .rel.debug_loc REL 00000000 03d8dc 002d98 08 I 27 20 4
[22] .debug_ranges PROGBITS 00000000 021d46 000480 00 0 0 1
[23] .rel.debug_ranges REL 00000000 040674 000560 08 I 27 22 4
[24] .debug_str PROGBITS 00000000 0221c6 00df42 01 MS 0 0 1
[25] .debug_frame PROGBITS 00000000 030108 000af4 00 0 0 4
[26] .rel.debug_frame REL 00000000 040bd4 000490 08 I 27 25 4
[27] .symtab SYMTAB 00000000 030bfc 0016d0 10 28 252 4
[28] .strtab STRTAB 00000000 0322cc 000980 00 0 0 1
[29] .shstrtab STRTAB 00000000 041064 0000f7 00 0 0 1
Parents Reply Children
No data