| Bug Number | DPPBLM-127 |
|---|---|
| Title | Wrong code generated for jump table |
| Publish Date | 20.02.2026 |
| Severity | Minor |
| Affected Version |
v4.6.x |
| Fixed Version |
- |
| Affected Architecture |
Tricore/AURIX |
| Environment Conditions |
- |
| Description |
The compiler might generate jump tables for switch statements, where the destination code is missing. This cause that the jumps target will be undefined symbols causing linker error at link time. Compiled with optimizations (e.g. with -O2) then linking the object will abort. The error messages is:
|
| ISO 26262 Error Detection Measures |
Not needed. As the linker process is interrupted, the output file is not written. |
| Steps to reproduce |
Write the following C-program extern int gvar_a;
extern int gvar_b;
void foo(void)
{
int loc_var_a;
int loc_var_b;
if (gvar_b)
{
loc_var_a = 2;
switch (gvar_a)
{
case 3:
switch (gvar_b)
{
case 0:
if (gvar_b == 0)
{
loc_var_a = 0;
}
break;
case 1:
loc_var_a = 7;
break;
default:
loc_var_a = 6;
break;
}
break;
}
switch (loc_var_a)
{
case 2:
loc_var_b = 3;
break;
case 3:
loc_var_b = 4;
break;
case 4:
loc_var_b = 5;
break;
case 6:
loc_var_b = 6;
break;
default:
loc_var_b = 7;
break;
}
}
gvar_a = loc_var_a;
gvar_b = loc_var_b;
}
Compile it then create the dump with the following commands tricore-gcc -O2 -c test.c -o test.o tricore-objdump -d -t -r -w test.o Objdump output: SYMBOL TABLE: 00000000 l df *ABS* 00000000 reproducer.c 00000000 l d .text 00000000 .text 00000000 l d .data 00000000 .data 00000000 l d .bss 00000000 .bss 00000000 l d .comment 00000000 .comment 00000000 g F .text 0000003e foo 00000000 O *UND* 00000004 gvar_b 00000000 O *UND* 00000004 gvar_a 00000000 *UND* 00000000 .L14 00000000 *UND* 00000000 .L6 00000000 *UND* 00000000 .L7 00000000 *UND* 00000000 .L5 00000000 *UND* 00000000 .L8 Disassembly of section .text: 00000000 : foo(): 0: 91 00 00 20 movh.a %a2,0 0: R_TRICORE_HIADJ gvar_b 4: 19 2f 00 00 ld.w %d15,[%a2]0 <0 > 4: R_TRICORE_LO2 gvar_b 8: 91 00 00 f0 movh.a %a15,0 8: R_TRICORE_HIADJ gvar_a c: 6e 14 jz %d15,34 e: 19 f2 00 00 ld.w %d2,[%a15]0 <0 > e: R_TRICORE_LO2 gvar_a 12: df 32 0d 00 jeq %d2,3,2c 16: 3c 01 j 18 18: 1d 00 00 00 j 18 18: R_TRICORE_24REL .L14 1c: 1d 00 00 00 j 1c 1c: R_TRICORE_24REL .L6 20: 1d 00 00 00 j 20 20: R_TRICORE_24REL .L7 24: 1d 00 00 00 j 24 24: R_TRICORE_24REL .L5 28: 1d 00 00 00 j 28 28: R_TRICORE_24REL .L8 2c: ba 1f eq %d15,%d15,1 2e: 82 72 mov %d2,7 30: ea 62 cmovn %d2,%d15,6 32: 02 23 mov %d3,%d2 34: 59 f3 00 00 st.w [%a15]0 <0 >,%d3 34: R_TRICORE_LO2 gvar_a 38: 59 22 00 00 st.w [%a2]0 <0 >,%d2 38: R_TRICORE_LO2 gvar_b 3c: 00 90 ret ... The jumps (j) leading to nowhere, therefore the target labels are undefined symbols. |
| Workaround |
|
| Resolution |
Confirmed |