tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] alinged/unaligned on OpenBSD


From: Herman ten Brugge
Subject: Re: [Tinycc-devel] alinged/unaligned on OpenBSD
Date: Wed, 27 Jan 2021 10:02:31 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 1/25/21 7:34 PM, Herman ten Brugge wrote:
On 1/25/21 6:55 PM, grischka wrote:
Herman ten Brugge via Tinycc-devel wrote:
The problem is that packed structeres should probably always use
single_byte code.
For example:
-----
struct __attribute__((packed)) {
  char a;
  int b;
} s;

int
main(void)
{
  s.b = 3;
}
-----
Also fails to run on arm32 (openbsd).
I do not have a solution. But maybe Grischka can solve this?

Don't know, maybe look what gcc does?
gcc uses load/store bytes for packed structs. A packed struct can
also start at any address (see below) so this is the only thing that works.

However, with your example, for example, one could take the address
    int *p = &s.b;
and pass that to other functions, as well.  There is not much
that the compiler could do.
yes this would not work. But this also does not work with all other compilers.

For the 96_nodata_wanted test using 'packed' or not probably would
not make much difference, at least on ARM.  Maybe it was supposed
to test single-byte access under code suppression.  But why shouldn't
it work anyway.
The stack is adjusted with 7 bytes (size of the struct =7 and align=1). The code in struct_layout expects the struct is aligned but this is not the case for packed structs.

I implemented load/store bytes for packed structs in tcc (see attachment).
Can I push it to mob?

    Herman

Attachment: patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]