MPC574xB/C/G Device Header Files - structure packing

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MPC574xB/C/G Device Header Files - structure packing

750 次查看
heathsmith
Contributor I

Can anyone tell me if structure packing should be used with these file? My target is an MPC5748G and I am using the GreenHills compiler/linker v7.1.4.

I thought that packing with a 1 byte alignment would be the safest option (GHS - #pragma pack(1)) but doing so there were problems detected at run-time. I then tried a 4-byte alignment (#pragma pack(4)) and this worked Ok.

Can anyone tell if there is an assumption about the structure packing?

See:

https://www.nxp.com/downloads/en/libraries/MPC574xB_C_G.zip

Thanks in advance.

0 项奖励
回复
2 回复数

683 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

Screenshot from Power-Arch-32-bit-ABI-supp-1.0-Embedded.pdf:

pastedImage_2.png

0 项奖励
回复

683 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi, I know it only from CodeWarrior but never mind, it is the same situation as other compilers are based on same EABI standard. The global setting has an option “Struct Alignment” its description says following:

The Struct Alignment drop-down list has the default selection PowerPC. To conform with the PowerPC EABI and interoperate with third-party object code, this setting should remain PowerPC. Other settings may lead to reduced performance or alignment violation exceptions. If you choose another setting for Struct Alignment, your code may not work correctly. The options available are as follows:

- PowerPC

- 68K

- 68K 4-byte

 

If PowerPC alignment is chosen, struct content is aligned to content size and may contain padding bytes. Thus, access to such content should not lead in misaligned access.

pastedImage_2.png

0 项奖励
回复