Port-m68k archive

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

Re: Natural alignment used on NetBSD/m68k



> > Maybe we have to clarify the definition of "a natural alignment",
> > but IIRC there were incompatible alignment issue when we have
> > switched from a.out to ELF.
> 
> Yes, it was always this way since we switched to ELF.

For clarification:

---

x68030-% uname -a
NetBSD x68030 1.5.3 NetBSD 1.5.3 (GENERIC) #5: Wed Jul  3 13:29:05 JST 2002     nsmrtks%yellow.magic.or@localhost:/lhd/src-1-5-PATCH003/sys/arch/x68k/compile/GENERIC x68k
x68030-% gcc -v
Using builtin specs.
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
x68030-% cat > test.c
#include <stdio.h>
#include <stddef.h>

struct test { char x; int y; };
typedef struct test test_t;

int main(void)
{
    printf("struct test { char x; int y; };\n");
    printf("sizeof(struct test) = %d\n", sizeof(struct test));
    printf("offsetof(struct test, y) = %d\n", offsetof(struct test, y));
}
x68030-% cc test.c
x68030-% file a.out
a.out: NetBSD/m68k demand paged dynamically linked executable not stripped
x68030-% ./a.out
struct test { char x; int y; };
sizeof(struct test) = 6
offsetof(struct test, y) = 2
x68030-% 

---

milan-% uname -a
NetBSD milan 10.1 NetBSD 10.1 (MILAN-PCIIDE) #0: Mon Dec 16 13:08:11 UTC 2024  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/atari/compile/MILAN-PCIIDE atari
milan-% gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/lto-wrapper
Target: m68k--netbsdelf
Configured with: /usr/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=m68k--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/support/send-pr.html --with-pkgversion='NetBSD nb2 20230710' --with-system-zlib --without-isl --enable-__cxa_atexit --enable-libstdcxx-time=rt --enable-libstdcxx-threads --with-diagnostics-color=auto-if-env --with-default-libstdcxx-abi=new --with-mpc-lib=/var/obj/mknative/mvme68k-m68k/usr/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/mvme68k-m68k/usr/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/mvme68k-m68k/usr/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/src/external/lgpl3/gmp/lib/libgmp/arch/m68k --enable-tls --disable-multilib --disable-libstdcxx-pch --build=m68k--netbsdelf --host=m68k--netbsdelf --with-sysroot=/var/obj/mknative/mvme!
 68k-m68k/usr/src/destdir.mvme68k
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.5.0 (nb3 20231008) 
milan-% cat > test.c
#include <stdio.h>
#include <stddef.h>

struct test { char x; int y; };
typedef struct test test_t;

int main(void)
{
    printf("struct test { char x; int y; };\n");
    printf("sizeof(struct test) = %d\n", sizeof(struct test));
    printf("offsetof(struct test, y) = %d\n", offsetof(struct test, y));
}
milan-% cc test.c
milan-% file a.out
a.out: ELF 32-bit MSB executable, Motorola m68k, 68020, version 1 (SYSV), dynamically linked, interpreter /usr/libexec/ld.elf_so, for NetBSD 10.1, with debug_info, not stripped
milan-% ./a.out
struct test { char x; int y; };
sizeof(struct test) = 8
offsetof(struct test, y) = 4
milan-% 

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index