[EXT_EP-10948] assembler/linker incorrectly handles REL relocations if user specifies a CODE_SECTION that starts with 'a' Created: 07/Dec/22  Updated: 02/Apr/24  Resolved: 18/Sep/23

Status: Fixed
Project: Embedded Software & Tools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Medium
Reporter: TI User Assignee: TI User
Resolution: Fixed Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Product: Code Generation Tools
Internal ID: CODEGEN-10691
Forum URL: https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/171/t/1167764
Found In Release: ARMCLANG_2.1.0.LTS
C2000_22.6.0.LTS
C6000_8.3.0
MSP430_20.2.0.LTS
C7000_2.1.0.LTS
MSP430_21.6.0.LTS
ARMCLANG_1.3.0.LTS
C2000_21.6.0.LTS
PRU_2.3.0
C7000_3.1.0.LTS
ARM_20.2.0.LTS
Fix In Release: MSP430_20.2.8.LTS*
C7000_2.1.3.LTS*
MSP430_21.6.2.LTS*
ARMCLANG_1.3.2.LTS*
ARMCLANG_2.1.4.LTS*
C7000_3.1.1.LTS
C2000_22.6.1.LTS
C6000_8.3.13
ARM_20.2.8.LTS*
PRU_2.3.4*
C2000_21.6.2.LTS*
Affected Platform/Device: default
Workaround: Change the section name used in pragma CODE_SECTION, pragma SET_CODE_SECTION or section attribute from a name starting with "a" to instead start with any other letter or . or :

 Description   

Using CODE_SECTION pragma, SET_CODE_SECTION pragma, or section attribute with a section name that begins with the letter 'a' will cause the linker to generate an incorrect address for accessing variables in that code section.

The linker incorrectly assumes the relocation type is RELA instead of REL.

More details:
----------------
The attached C file has this line ...

#pragma CODE_SECTION(GetA2DAnalogMux, "a2d_funcs")
void GetA2DAnalogMux(void)
{
    ...
    gpioDataReg = (volatile Uint32 *)&GpioDataRegs + (104/32)*(0x8/2); 

Build it.

% cl2000 -@options.txt file.c -z -o file.out link2000.cmd

Inspect the generated assembly file.asm to see ...

        MOVL      XAR4,#||GpioDataRegs||+24 ; [CPU_ARAU] |22245| 

The symbol GpioDataRegs resolves to the address 0x7f00. So, the final encoding of this address, in hex, is 0x7f18. Disassemble ...

% dis2000 file.out > disassembly.txt

Inspect the disassembly to see ...

00000003   8f00   MOVL         XAR4, #0x007f00
00000004   7f00

0x7f00 is encoded where 0x7f18 is expected.


Generated at Sun Apr 13 23:22:09 CDT 2025 using Jira 9.12.17#9120017-sha1:aba4002bcd633f188b6a4bb5dd8a0e1f20b79ee4.