public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Earnshaw <Richard.Earnshaw@foss.arm.com>
To: "Фёдар Стрыжнёў (Fiodar Stryzhniou)" <fedor_qd@mail.ru>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Symbian: unalighned relocations for pointers-to-members
Date: Fri, 21 Jan 2022 15:08:27 +0000	[thread overview]
Message-ID: <995c213b-400a-7056-e06a-fcc55ac4a48b@foss.arm.com> (raw)
In-Reply-To: <20220121171701.7f1d9228113d2b9b0b4aee19@mail.ru>

The assembly output?  Just compile with -S rather than -c and the 
compiler will output the assembler file rather than an object file.

R.


On 21/01/2022 14:17, Фёдар Стрыжнёў (Fiodar Stryzhniou) wrote:
> How create such output? It's good to know such thing.
> -----
> Фёдар Стрыжнёў(Fiodar Stryzhniou)
> 
> On Tue, 18 Jan 2022 10:14:17 +0000
> Richard Earnshaw <Richard.Earnshaw@foss.arm.com> wrote:
> 
>> [Sending a copy to the list as this was accidentally moved to private mail]
>>
>> On 16/01/2022 11:52, Фёдар Стрыжнёў (Fiodar Stryzhniou) wrote:
>>> On Tue, 4 Jan 2022 13:01:14 +0000
>>> Richard Earnshaw <Richard.Earnshaw@foss.arm.com> wrote:
>>>
>>>> I've had a very quick look at this (I can only look at the compiler
>>>> output as I do not have any of the other symbian-related tools).  The
>>>> only thing I can think of is that the problem is coming from the dwarf
>>>> debug information.  Can you check whether the problem still occurs if
>>>> you add -g0 to the end of the list of compilation options (or remove all
>>>> the -g... options from the compilation command).
>>>>
>>>> R.
>>>
>>> Sorry for long response. You mail was moved to spam by mail provider.
>>>
>>> Error remains.
>>>
>>> I made this file OS-independent. It can be linked and compiled by GCC.
>>> I compile and use object dump. Found unaligned entry. Is it error?
>>>
>>
>>> No, I think that's an exact consequence of having a packed data type.
>> This is the relevant part of the assembly file (after passing through
>> the demangler):
>>>
>>>           .section        .rodata
>>>           .align  2
>>> .LC0:
>>>           .ascii  "the rune of Spirituality\000"
>>>           .align  2
>>> .LC1:
>>>           .ascii  "spiritualityrune\000"
>>>           .align  2
>>> .LC2:
>>>           .ascii  "the rune of Humility\000"
>>>           .align  2
>>> .LC3:
>>>           .ascii  "humilityrune\000"
>>>           .align  2
>>>           .type   Items::ITEMS, %object
>>>           .size   Items::ITEMS, 1394
>>> Items::ITEMS:
>>>                   // RE: ITEMS[0]
>>>           .word   .LC0
>>>           .word   0
>>>           .word   .LC1
>>>           .word   Items::isRuneInInventory(int)
>>>           .word   0
>>>           .word   Items::putRuneInInventory(int)
>>>           .word   0
>>>           .word   0
>>>           .word   0
>>>           .word   64
>>>           .byte   0
>>>                   // RE: ITEMS[1]
>>>           .4byte  .LC2
>>>           .4byte  0
>>>           .4byte  .LC3
>>>           .4byte  Items::isRuneInInventory(int)
>>>           .4byte  0
>>>           .4byte  Items::putRuneInInventory(int)
>>>           .4byte  0
>>>           .4byte  0
>>>           .4byte  0
>>>           .4byte  128
>>>           .byte   0
>>>                   // RE: And some empty space.
>>>           .space  1312
>>>
>>> Note that each entry in the ITEMS list is 41 bytes, so the second
>>> element (and third and fourth, if initialized) has to be placed in an
>>> unaligned location (because the structure has been packed).  Note that
>>> the .4byte directive is used by the compiler when it knows that the
>>> element can be misaligned.
>>
>> Sorry, I meant to also say that your source code is using two ways of
>> forcing packing: pragma pack and __attribute((packed)).  If I remove
>> both of those, then the output becomes
>>
>> Items::ITEMS:
>>          .word   .LC0
>>          .word   0
>>          .word   .LC1
>>          .word   Items::isRuneInInventory(int)
>>          .word   0
>>          .word   Items::putRuneInInventory(int)
>>          .word   0
>>          .word   0
>>          .word   0
>>          .word   64
>>          .byte   0
>>          .space  3
>>          .word   .LC2
>>          .word   0
>>          .word   .LC3
>>          .word   Items::isRuneInInventory(int)
>>          .word   0
>>          .word   Items::putRuneInInventory(int)
>>          .word   0
>>          .word   0
>>          .word   0
>>          .word   128
>>          .byte   0
>>          .space  3
>>          .space  1408
>>
>> and we can see that the data is all now fully aligned.  Leaving either
>> one of the packed directives in place obviously leads to the object
>> containing unaligned pointers, which leads to the unaligned relocations.
>>
>> AAELF (the ELF specification binding for Arm) states:
>>
>>    Except as indicated in Table 4-10, Static Data relocations with
>>    non-standard size or processing all static data relocations have
>>    size 4, alignment 1 and [...].
>>
>> R_ARM_ABS32 is not listed in Table 4-10, so can have any alignment.
>>
>>
>> R.
>>

      reply	other threads:[~2022-01-21 15:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16  0:39 Фёдар Стрыжнёў
2021-12-19  9:35 ` Фёдар Стрыжнёў
2021-12-20 15:37 ` Richard Earnshaw
2021-12-20 19:30   ` Фёдар Стрыжнёў
2021-12-21  0:00     ` Segher Boessenkool
2021-12-21 14:01       ` Фёдар Стрыжнёў
2021-12-21 14:13         ` Jonathan Wakely
2021-12-21 15:17           ` Фёдар Стрыжнёў
2021-12-21 17:05             ` Jonathan Wakely
2021-12-29 11:04   ` Фёдар Стрыжнёў
2022-01-04 13:01     ` Richard Earnshaw
2022-01-16 11:52       ` Фёдар Стрыжнёў
2022-01-18 10:14         ` Richard Earnshaw
2022-01-21 14:17           ` Фёдар Стрыжнёў
2022-01-21 15:08             ` Richard Earnshaw [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=995c213b-400a-7056-e06a-fcc55ac4a48b@foss.arm.com \
    --to=richard.earnshaw@foss.arm.com \
    --cc=fedor_qd@mail.ru \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).