This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

msp430-elf-gcc: far data without using '-mlarge', 'medium' memory model missing

Other Parts Discussed in Thread: MSP430FR5969

Hi Nick et al.!

As far as I know, without using '-mlarge' I can not address far data.

E.g. the following code, with data placed into section ".upper.bss", which is per default located in HIFRAM on an MSP430FR5969:

volatile uint16_t  __attribute__ ((section (".upper.bss"))) y[1];

int main(void)
{
	y[0]++;
...

The linker generates the following warning: "relocation truncated to fit: R_MSP430X_ABS16 against symbol `y' defined in .upper.bss" when I don't add the option '-mlarge'.

The large data model does increase the code quite a bit (approx 25% in one of my projects). For example I could only place data objects into memory beyond 64k (far memory) and code would reside below 64k (near memory).

What I'm missing is a 'medium' memory model very much like the medium memory model of the Intel cpu's, where I'd use the 'far' qualifier on data which resided in far memory.

Is there anything like a 'medium' memory model planned? If not, could you possibly add support for it?

  • I have started an internal conversation between people from TI and Redhat concerning your feature request for a medium memory model.  At this point, it is too soon to say what could happen.

    Thanks and regards,

    -George

  • The problem with a "medium" model, or any model where size_t and sizeof(void *) are not the same, is that they technically violate the ISO C standard. GCC has minimal support for such models, and having done some in the past, I recommend against it. (for example, something as simple as foo[-1] doesn't work in a mixed model, because of pointer math rules).

    In addition, gcc has no way of having function and data pointers be different sizes, which is the key to the Intel-style "medium" model.