| Summary: | union size and section sizes mismatch on aarch64 | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Michael Petlan <mpetlan> |
| Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
| Status: | CLOSED NOTABUG | QA Contact: | Michael Petlan <mpetlan> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.3 | CC: | bschmidt, jfeeney, law, mpolacek, ohudlick, yselkowi |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | aarch64 | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2017-03-08 15:18:45 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Bug Depends On: | |||
| Bug Blocks: | 1357680 | ||
|
Description
Michael Petlan
2016-09-09 17:48:28 UTC
I believe this is just insufficiently portable testcase (looking at the referenced rhbz, it seems I've suggested it, so mea culpa here).
The problem is that various targets (including x86_64) have various ABI and optimization extended alignment rules (in GCC DATA_ABI_ALIGNMENT and DATA_ALIGNMENT macros), which can enlarge the alignment of certain variables.
So, while even on aarch64 the union has size 36 and alignment 4 bytes, the aarch64 backend for performance reasons chooses to align it to 8 bytes boundary, which means the assembler then pads the user section after the struct to a multiple of 8 bytes.
Using
union B b __attribute__((aligned (__alignof__(union B)), section ("mysection"))) = { { 1, "123456789012345678901234567890" } };
instead of
union B b __attribute__((section ("mysection"))) = { { 1, "123456789012345678901234567890" } };
fixes this problem, it tells the compiler not to overalign it. Generally it is an implementation detail in which order and with what padding the toolchain emits the variables, emitting them into a user named section and expecting no padding in the entries put into that section is a common but non-portable technique (I think e.g. glibc, or Linux kernel, or prelink and various other apps use it).
Bug in the testcase, not in the compiler. |