Article View: gnu.gcc.help
Article #50525Padding Structures on 16 Bit Boundary?
From: Pat Baumann
Date: Mon, 20 Sep 1993 21:29
Date: Mon, 20 Sep 1993 21:29
34 lines
2534 bytes
2534 bytes
BACKGROUND: Two compiler ISSUEs relating to structure padding and alignment have been found recently. The first ISSUE is related to the way that the SUN-target compilers pad a structure within a structure with respect to the way it pads a union within a structure. A structure within a structure is padded as if the structure does not exist; the alignment rules are followed on a field by field basis. A union within a structure is handled differently: either the union is always started on a 32 bit boundary or the largest field is used in the alignment rules. This difference was brought to light by the fact that one task uses a structure within a structure to send messages, while another task uses a union within a structure to receive them. Please note that a problem only occurs for SUN-target compilers and does not occurs when the Microtek cross-compiler is used with the <-Z2> option (to our knowledge); this is only a problem when a Sparc task tries to communicate with another Sparc task. The problem was solved by explicitly padding the header to a 32 bit boundary for Sparc testing. The other ISSUE is really the same problem, except that it impacts a Sparc simulation that drives the target software. Because headers are padded to 16 bit rather than 32 bit boundaries for the target, the actual data portion of the message can be offset by a word due to the reasons that have already been mentioned and due to the difference in alignment rules. QUESTION: Is there an option that pads structures on 16 bit boundaries for the Sparc resident GCC compiler? Such an option would help greatly for simulations that run from the Sparc. If you have any ideas, reply through this venue or send me mail at baumann@comm.mot.com.
Technical Details
Message-ID:
<1993Sep20.212953.12832@lmpsbbs.comm.mot.com>Path:
arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!ftpbox!mothost!lmpsbbs!baumannShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,153a6a6cf324a394,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1993-09-20 18:20:41 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!ftpbox!mothost!lmpsbbs!baumann From: baumann@ssd.comm.mot.com (Pat Baumann) Subject: Padding Structures on 16 Bit Boundary? Organization: Motorola Land Mobile Products Sector Date: Mon, 20 Sep 1993 21:29:53 GMT Message-ID: <1993Sep20.212953.12832@lmpsbbs.comm.mot.com> X-Newsreader: TIN [version 1.2 PL1] Keywords: Padding Structure Boundary Sender: news@lmpsbbs.comm.mot.com (Net News) Nntp-Posting-Host: 145.1.185.17 Lines: 39