[quote user="stomp"]Is it possible to achieve single byte alignment in constant data?[/quote]Using the TI v15.12.3.LTS compiler with your example code found that the compiler was placing the g_pDescriptor and g_pInterface variables in a section which had two byte alignment, which was why the compiler reported an alignment warning and then forced the g_pInterface to be two byte aligned (and also ignored the requested location). Initially tried to use the DATA_ALIGN pragma but the variables were still placed in a section with two byte alignment. Found that could use the aligned attribute to set one byte alignment for the g_pDescriptor and g_pInterface variables: typedef unsigned char Luint8; #pragma location = 0x4800 const Luint8 g_pDescriptor[9] __attribute__ ((aligned (1))) = {1,2,3,4,5,6,7,8,9}; #pragma location = 0x4809 const Luint8 g_pInterface[] __attribute__ ((aligned (1))) = {10,11,12}; With this change there are no alignment warnings from the compiler or linker, and the linker map file reports that the requested locations have been used: .TI.bound:g_pDescriptor * 0 00004800 00000009 00004800 00000009 main.obj (.TI.bound:g_pDescriptor) .TI.bound:g_pInterface * 0 00004809 00000003 00004809 00000003 main.obj (.TI.bound:g_pInterface) The ofd430 program in the TI compiler can report the alignment for the sections created by the compiler. With the above code this reports that the compiler has told the linker that the sections which contain the g_pDescriptor and g_pInterface variables only require one byte alignment: C:\Users\Mr_Halfword\workspace_v6_2\MSP430F5529_alignment\Debug>c:\ti_ccs6_2_0\ccsv6\tools\compiler\msp430_15.12.3.LTS\bin\ofd430.exe main.obj OBJECT FILE: main.obj Object File Information File Name: main.obj Format: ELF Version 1 File Type: relocatable file Machine: MSP430 Machine Endian: little endian Entry Point: 0x00000000 Vendor: Texas Instruments, Inc. Producer: Assembler Assembler Version: 15.12.3 Number of Sections: 63 File Length: 8380 ELF Class: 32-bit objects ELF e_flags: 0x00000000 Section Information id name load addr run addr size align alloc -- ---- --------- -------- ---- ----- ----- 0 (no name) 0x00000000 0x00000000 0x0 0 N 1 __TI_DW.debug_info.$ba... 0x00000000 0x00000000 0x18 0 N 2 __TI_DW.debug_info.msp... 0x00000000 0x00000000 0x18 0 N 3 __TI_DW.debug_info.mai... 0x00000000 0x00000000 0x18 0 N 4 .text 0x00000000 0x00000000 0x0 1 Y 5 .TI.bound:g_pDescriptor 0x00004800 0x00004800 0x9 1 Y 6 .TI.bound:g_pInterface 0x00004809 0x00004809 0x3 1 Y 7 .text:main 0x00000000 0x00000000 0x16 2 Y
↧