-m32 on freeBSD 8.2r amd64

Kostik Belousov kostikbel at gmail.com
Wed Aug 24 13:01:50 UTC 2011


On Wed, Aug 24, 2011 at 01:57:02PM +0100, Tom Evans wrote:
> On Wed, Aug 24, 2011 at 12:11 PM, Michael Hoffmann <benzene at arcor.de> wrote:
> > Maybe off topic?
> >
> > 1: echo "int main(void) { return 0; }" > t.c
> >
> > 2: setenv LDEMULATION elf_i386_fbsd
> >
> > 3: gcc -c -m32 -o t.o t.c
> >
> > 4: gcc -nostartfiles -o a.out
> > t.o -L/usr/lib32 /usr/lib32/crt1.o /usr/lib32/crti.o
> >
> > 5: file a.out
> > a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD),
> > dynamically linked (uses shared libs), for FreeBSD 8.2, not stripped
> >
> > 6: uname -m
> > amd64
> >
> > 2: q.v. info binutils -> Selecting The Target System
> >
> > Maybe there is a more comfortable way.
> > Michael
> >
> 
> You don't need to go to all that effort:
> 
> $ uname -m
> amd64
> $ echo "int main(void) { return 0; }" > t.c
> $ gcc -c -m32 -o t.o t.c
> $ gcc -m32 -o t t.o -B/usr/lib32
> $ file t
> t: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD),
> dynamically linked (uses shared libs), for FreeBSD 8.2 (802510), not
> stripped

Well-known problem is that /usr/include/machine/*.h still contains
amd64 arch definitions. The resulting binary is broken in the quite
subtle ways.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20110824/0db5f8cd/attachment.pgp


More information about the freebsd-stable mailing list