cancel
Showing results for 
Search instead for 
Did you mean: 

const array is overflowing .text segment when there is plenty of room

mchahn
Senior

I am using a stm8s103f which has 8K flash. My project compiles fine using the cosmic compiler. I get a map that looks like this .

start 00008080 end 00008080 length     0 segment .const
start 000080a1 end 00008924 length  2179 segment .text
start 00004000 end 00004000 length     0 segment .eeprom
start 00000000 end 00000019 length    25 segment .bsct, initialized
start 00008088 end 000080a1 length    25 segment .bsct, from
start 00000019 end 000000b9 length   160 segment .ubsct
start 000000b9 end 000000b9 length     0 segment .bit
start 000000b9 end 000000b9 length     0 segment .share
start 00000100 end 00000100 length     0 segment .data
start 00000100 end 00000100 length     0 segment .bss
start 00000000 end 0000074e length  1870 segment .info.
start 00000000 end 00001a11 length  6673 segment .debug
start 00008000 end 00008080 length   128 segment .const
start 00008080 end 00008088 length     8 segment .init

When I try to add a large constant array with

const u16 tempTable[867] = {
<snip>
}

I get the build error "segment .text size overflow (14)".

What am I doing wrong? 2179 plus 2*867 is less than 8K.

4 REPLIES 4
S.Ma
Principal

check the map file when linker fail, reduce the table by binary search to find out the limit, check the linker parameter file in case the memory range is wrong. also check thatthere is no float ansi lib plugged in and bloating the flash for example.

MM..1
Chief II

const isnt definition for placement of data, but protected against write. Some compilers place it to data area.

static const

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mchahn
Senior

> check the linker parameter file 

Thks. Which file/location is that? I'll look for it.

> Some compilers place it to data area

The error specifically says it is .text that is overflowing. That is the 8K code segment, right?

> static const

I just tried that and it didn't help.