Le 28/07/2016 à 13:57, Peter Maydell a écrit :
> For i386, the ABI specifies that 'long long' (8 byte values)
> need only be 4 aligned, but we were requiring them to be
> 8-aligned. This meant we were laying out the target_epoll_event
> structure wrongly. Add a suitable ifdef to abitypes.h to
> specify the i386-specific alignment requirement.
> 
> Reported-by: Icenowy Zheng <icen...@aosc.xyz>
> Signed-off-by: Peter Maydell <peter.mayd...@linaro.org>
> ---
>  include/exec/user/abitypes.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h
> index a09d6c6..ba18860 100644
> --- a/include/exec/user/abitypes.h
> +++ b/include/exec/user/abitypes.h
> @@ -15,6 +15,10 @@
>  #define ABI_LLONG_ALIGNMENT 2
>  #endif
>  
> +#if defined(TARGET_I386) && !defined(TARGET_X86_64)
> +#define ABI_LLONG_ALIGNMENT 4
> +#endif
> +
>  #ifndef ABI_SHORT_ALIGNMENT
>  #define ABI_SHORT_ALIGNMENT 2
>  #endif
> 

Why the following program from commit

    c2e3dee linux-user: Define target alignment size

int main(void)
{
    printf("alignof(short) %ld\n", __alignof__(short));
    printf("alignof(int) %ld\n", __alignof__(int));
    printf("alignof(long) %ld\n", __alignof__(long));
    printf("alignof(long long) %ld\n", __alignof__(long long));
}


gives me:

alignof(short) 2
alignof(int) 4
alignof(long) 4
alignof(long long) 8

?

I compile it on x86_64 in 32bit mode:

cc -m32 -o align align.c
file align
align: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux
2.6.32, BuildID[sha1]=f5312f2334462b48fd9764e78a845879ff317b94, not stripped

Thanks,
Laurent

Reply via email to