public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Indu Bhagat <indu.bhagat@oracle.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: binutils@sourceware.org
Subject: Re: Missing alignment in SFrame spec
Date: Mon, 1 May 2023 17:24:49 -0700	[thread overview]
Message-ID: <2485551a-9608-e4ff-8d4c-bd7974c6c695@oracle.com> (raw)
In-Reply-To: <87ildgbf9g.fsf@oldenburg.str.redhat.com>

On 4/28/23 01:08, Florian Weimer wrote:
> The SFrame specification does not say anything explict about alignment.
> It uses ATTRIBUTE_PACKED, which strongly suggests alignment 1, but
> looking at the structures themselves, I think what you actually want is
> 4-byte alignment.
> 
> Thanks,
> Florian
> 

Hi Florian,

SFrame stack trace format is an unaligned on-disk format. IIUC, you 
suggest 4 byte alignment for all structs in SFrame format?

Yes, current SFrame FDE and SFrame FRE are 1-byte aligned.

I had reasoned about unaligned accesses previously when a bug showed up.

Memory READ side:
------------------
So far, we ran into some unaligned memory access issues earlier 
https://sourceware.org/bugzilla/show_bug.cgi?id=29856, but were fixable 
in libsframe, because the latter provides SFrame FREs via an in-memory 
abstraction sframe_frame_row_entry defined in include/sframe-api.h. The 
members of sframe_frame_row_entry are naturally aligned.

PR 29856 was about issues on the the memory READ side of SFrame FREs 
(Frame Row Entry). Now, I had also expected to see unaligned access when 
READ access to SFrame FDEs 
(sframe_func_desc_entry.sfde_func_start_address) was done by GNU 
ld/objdump. But when fixing the above bug, I did not see them. But I 
have it noted down to get to this sometime soon.

Memory WRITE side:
------------------
As for the accesses to SFrame header and its members, these should all 
be aligned memory accesses - both READ and WRITE. This is because SFrame 
header is the first entity in the section.  Its members have natural 
alignment.

On the WRITE side, GAS does a byte by byte write IIRC (GAS does not use 
libsframe APIs to write SFrame section). And as for GNU ld WRITE side, I 
checked (mentally) that unaligned accesses are either taken care of in 
libsframe or not present due to usage of memcpy.

So bottomline: I _think_ we are okay on the GNU as/ld READ and WRITE 
side as far as unaligned memory accesses are concerned. *EXCEPT*, SFrame 
Function Descriptor Entries (FDEs): there is an open item around access 
to sframe_func_desc_entry.sfde_func_start_address (and following members 
should exhibit the same problem), which I will check soon. I will double 
check for both READ and WRITE access to all SFrame FDE members when I do 
get to this.

Thank you for bringing it up. Does the above make sense ?

Indu

  reply	other threads:[~2023-05-02  0:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28  8:08 Florian Weimer
2023-05-02  0:24 ` Indu Bhagat [this message]
2023-05-02  6:03   ` Florian Weimer
2023-05-03 17:37     ` Indu Bhagat

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=2485551a-9608-e4ff-8d4c-bd7974c6c695@oracle.com \
    --to=indu.bhagat@oracle.com \
    --cc=binutils@sourceware.org \
    --cc=fweimer@redhat.com \
    /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).