I am using TMS320C6x C/C++ Compiler v7.4.4.
I have the following program (test.c), the minimal example I can make to demonstrate the fault:
--------------------
asm(" .sect MODULE");
asm("id: .word 0");
asm(" .sect OVERLAY");
asm(" .word id");
asm(" .text");
extern far void Fn1(void *, unsigned int, unsigned int);
extern far int V;
extern far void *Fn0(void *x);
#pragma CODE_SECTION(A, "OVERLAY");
far void A(void *p) {
void *P = Fn0(&V);
if (!P) Fn1(&V, 0,0);
}
#pragma CODE_SECTION(B, "OVERLAY");
far int B(void *p) {return 0;}
--------------------
I run the following makefile to build and display test.obj:
--------------------
default: test.obj
ofd6x --obj_display=rawdata test.obj > z.lis
test.obj: test.c
cl6x -O3 -c -mv=6600 test.c
--------------------
In the resulting output file, z.lis, I see the following:
Raw Data for Section "OVERLAY"
00000000: 00 00 00 00 62 83 8c 00 58 a3 00 02 2b 00 00 02 ....b...X...+...
00000010: 01 00 00 00 01 00 00 00 00 00 00 00 6a 00 00 02 ............j...
00000020: 62 03 10 00 f4 54 bc 05 f4 22 3c 05 28 00 00 05 b....T..."<.(...
00000030: 68 00 00 05 d9 0f 28 02 a1 16 8c 05 62 01 88 01 h.....(.....b...
00000040: d9 0f 10 00 2b 00 80 02 a1 06 28 02 5b a3 00 02 ....+.....(.[...
00000050: 40 00 00 03 91 08 00 c0 6b 00 80 02 db 1f ac c1 @.......k.......
00000060: e4 22 3c c5 63 03 14 d0 e4 52 bc c5 62 63 8c c0 ."<.c....R..bc..
00000070: 62 01 85 01 db 1f ac 01 e4 22 3c 05 63 63 8c 00 b........"<.cc..
00000080: e4 52 bc 05 00 20 00 00 00 00 00 00 00 00 00 00 .R... ..........
00000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
and in the symbol table:
25 B 0x00000004 defined OVERLAY global function
26 A 0x0000000c defined OVERLAY global function
While B seems correct, the code for C is utter junk, with the first words being:
0200002b
00000001
00000001
00000000
0200006a
00100362
05bc54f4
The output from the assembler for the actual start of function C is:
165 0000000c A:
169 0000000c 0200002A! MVKL .S2 Fn0,B4
170 0000001c 0200006A! MVKH .S2 Fn0,B4
175 00000020 00100362 CALL .S2 B4 ; |13|
176 00000024 05BC54F4 STW .D2T1 A11,*SP--(8) ; |12|
177 00000028 053C22F4 STW .D2T1 A10,*+SP(4) ; |12|
178 0000002c 05000028! MVKL .S1 V,A10
179 00000030 05000068! MVKH .S1 V,A10
This has brought my project to a crashing halt.
Is it a known fault?
How can I make sure this problems is not going to affect a vast amount of similar code?