taviso / 123elf

A native port of Lotus 1-2-3 to Linux.
1.16k stars 59 forks source link

NetBSD port #77

Open vrza opened 2 years ago

vrza commented 2 years ago

Ports to BSD variants should not be much more difficult than Linux.

Currently build fails on NetBSD:

cc -m32 -ggdb3 -O0 -fno-stack-protector  -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -D_GNU_SOURCE -I ttydraw -c wrappers.c
wrappers.c: In function ‘__unix_ioctl’:
wrappers.c:62:14: error: ‘TCSETSW’ undeclared (first use in this function); did you mean ‘TC_TSS’?
         case TCSETSW:
              ^~~~~~~
              TC_TSS
wrappers.c:62:14: note: each undeclared identifier is reported only once for each function it appears in
wrappers.c:67:14: error: ‘TCSETS’ undeclared (first use in this function); did you mean ‘TCSETSW’?
         case TCSETS:
              ^~~~~~
              TCSETSW
wrappers.c:83:14: error: ‘TCGETS’ undeclared (first use in this function); did you mean ‘TCSETS’?
         case TCGETS:
              ^~~~~~
              TCSETS
wrappers.c: In function ‘__unix_readdir’:
wrappers.c:407:26: error: ‘struct dirent’ has no member named ‘d_off’
         uent.d_off = lent->d_off;
                          ^~
wrappers.c: At top level:
wrappers.c:419:1: error: unknown type name ‘sighandler_t’; did you mean ‘sa_handler’?
 sighandler_t __unix_signal(int signum, sighandler_t handler)
 ^~~~~~~~~~~~
 sa_handler
wrappers.c:419:40: error: unknown type name ‘sighandler_t’; did you mean ‘sa_handler’?
 sighandler_t __unix_signal(int signum, sighandler_t handler)
                                        ^~~~~~~~~~~~
                                        sa_handler
taviso commented 2 years ago

This seems solvable, but it's been a while since I've used NetBSD, I'll setup a VM and take a look.

Unless someone else volunteers to take a look!

vrza commented 2 years ago

I started working towards making it build on BSDs: https://github.com/vrza/123elf/tree/openbsd-1

vrza commented 2 years ago

I got it to compile, currently looking into how to make it link. ld is complaining about symbols that were undefined, and about multiple definitions:

cc forceplt.o -m32 -ggdb3 -O0 -fno-stack-protector -m32 -ggdb3 -O0 -fno-stack-protector -lc -B. -Wl,-b,coff-i386 -no-pie 123.o dl_init.o main.o wrappers.o patch.o filemap.o graphics.o draw.o ttydraw/ttydraw.a atfuncs/atfuncs.a forceplt.o -Wl,--whole-archive,ttydraw/ttydraw.a,atfuncs/atfuncs.a,--no-whole-archive -o bin/123 -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -Wl,-zrelro -Wl,-R/usr/pkg/lib -lncurses -lm
ld: forceplt.o: in function `__require_ref':
(.text+0x45c): warning: warning: reference to compatibility shmctl(); include <sys/shm.h> for correct reference
ld: (.text+0x452): warning: warning: reference to compatibility msgctl(); include <sys/msg.h> for correct reference
ld: (.text+0x3df): warning: warning: reference to compatibility tzset(); include <time.h> for correct reference
ld: (.text+0x1ff): warning: warning: reference to compatibility mknod(); include <sys/stat.h> to generate correct reference
ld: (.text+0x20e): warning: warning: reference to compatibility mount(); include <sys/mount.h> to generate correct reference
ld: (.text+0x25e): warning: warning: reference to compatibility putenv(); include <stdlib.h> for correct reference
ld: (.text+0x155): warning: warning: reference to compatibility getutent(); include <utmp.h> for correct reference
ld: (.text+0x150): warning: warning: reference to compatibility getpwuid(); include <pwd.h> to generate correct reference
ld: (.text+0x14b): warning: warning: reference to compatibility getpwnam(); include <pwd.h> to generate correct reference
ld: (.text+0x146): warning: warning: reference to compatibility getpwent(); include <pwd.h> to generate correct reference
ld: (.text+0x402): warning: warning: reference to compatibility utime(); include <utime.h> to generate correct reference
ld: (.text+0x3ad): warning: warning: reference to compatibility time(); include <time.h> for correct reference
ld: (.text+0x3b7): warning: warning: reference to compatibility timezone; include <time.h> to generate correct reference
ld: (.text+0x3b2): warning: warning: reference to compatibility times(); include <sys/times.h> for correct reference
ld: (.text+0x330): warning: warning: reference to obsolete statfs(); use statvfs()
ld: (.text+0xdd): warning: warning: reference to obsolete fstatfs(); use fstatvfs()
ld: (.text+0x335): warning: warning: reference to compatibility stat(); include <sys/stat.h> to generate correct reference
ld: (.text+0xe2): warning: warning: reference to compatibility fstat(); include <sys/stat.h> to generate correct reference
ld: (.text+0x281): warning: warning: reference to compatibility readdir(); include <dirent.h> for correct reference
ld: (.text+0x231): warning: warning: reference to compatibility opendir(); include <dirent.h> for correct reference
ld: 123.o:lic_hooks.c:(.text+0x9eff8): multiple definition of `__udivsi3'; /usr/lib/libc.so:(.text+0x578d0): first defined here
ld: 123.o:lic_hooks.c:(.text+0x9f008): multiple definition of `__divsi3'; /usr/lib/libc.so:(.text+0x578e0): first defined here
ld: 123.o:lic_hooks.c:(.text+0x9f02c): multiple definition of `__fixdfsi'; /usr/lib/libc.so:(.text+0x26c90): first defined here
ld: 123.o:lic_hooks.c:(.text+0x9f05c): multiple definition of `__negdf2'; /usr/lib/libc.so:(.text+0x34af4): first defined here
ld: 123.o:fseek.c:(.text+0xd9d8c): multiple definition of `ftell'; /usr/lib/libc.so:(.text+0x55fac): first defined here
ld: 123.o:getopt.c:(.text+0xda394): multiple definition of `fputs'; /usr/lib/libc.so:(.text+0xfc3d0): first defined here
ld: 123.o:getpwent.c:(.text+0xda94c): multiple definition of `gets'; /usr/lib/libc.so:(.text+0x4eb64): first defined here
ld: 123.o:mon.c:(.text+0xdb81c): multiple definition of `nlist'; /usr/lib/libc.so:(.text+0x2b6b4): first defined here
ld: 123.o: warning: warning: tempnam() possibly used unsafely, use mkstemp() or mkdtemp()
ld: 123.o:time_comm.c:(.text+0xdf104): warning: warning: tmpnam() possibly used unsafely, use mkstemp() or mkdtemp()
ld: 123.o:fopen.c:(.text+0xdf354): multiple definition of `mktemp'; /usr/lib/libc.so:(.text+0x4ea7b): first defined here
ld: 123.o:dtop.c:(.text+0xe183c): multiple definition of `fwrite'; /usr/lib/libc.so:(.text+0x1372b4): first defined here
ld: 123.o:fwrite.c:(.text+0xe19e0): multiple definition of `_cleanup'; /usr/lib/libc.so:(.text+0xdccb7): first defined here
ld: 123.o:drand48.c:(.text+0xd8e44): multiple definition of `exect'; /usr/lib/libc.so:(.text+0x30fbb): first defined here
ld: 123.o:qsort.c:(.text+0xdc710): multiple definition of `getdents'; /usr/lib/libc.so:(.text+0x3e3dc): first defined here
ld: forceplt.o: in function `__require_ref':
(.text+0x6f): undefined reference to `cuserid'
ld: (.text+0x88): undefined reference to `eaccess'
ld: (.text+0x8d): undefined reference to `ecvt'
ld: (.text+0xce): undefined reference to `fcvt'
ld: (.text+0xf1): undefined reference to `gcvt'
ld: (.text+0x15a): undefined reference to `getutid'
ld: (.text+0x15f): undefined reference to `getutline'
ld: (.text+0x16e): undefined reference to `gsignal'
ld: (.text+0x1c8): undefined reference to `mallinfo'
ld: (.text+0x1d2): undefined reference to `mallopt'
ld: (.text+0x1d7): undefined reference to `_mcount'
ld: (.text+0x263): undefined reference to `putpwent'
ld: (.text+0x26d): undefined reference to `pututline'
ld: (.text+0x32b): undefined reference to `ssignal'
ld: (.text+0x3ee): undefined reference to `umount'
ld: (.text+0x461): undefined reference to `fstat64'
ld: (.text+0x466): undefined reference to `stat64'
ld: 123.o:lefwin.c:(.text+0x9ea88): undefined reference to `cuserid'
ld: 123.o:baseten.c:(.text+0xc7438): undefined reference to `ecvt'
ld: 123.o:ftw.c:(.text+0xd95ba): undefined reference to `ecvt'
ld: 123.o:doprnt.c:(.text+0xe01d3): undefined reference to `ecvt'
ld: 123.o:doprnt.c:(.text+0xe03d7): undefined reference to `fcvt'
ld: 123.o:doprnt.c:(.text+0xe06bf): undefined reference to `ecvt'
ld: forceplt.o: in function `__require_ref':
(.text+0x6f): undefined reference to `cuserid'
ld: (.text+0x88): undefined reference to `eaccess'
ld: (.text+0x8d): undefined reference to `ecvt'
ld: (.text+0xce): undefined reference to `fcvt'
ld: (.text+0xf1): undefined reference to `gcvt'
ld: (.text+0x15a): undefined reference to `getutid'
ld: (.text+0x15f): undefined reference to `getutline'
ld: (.text+0x16e): undefined reference to `gsignal'
ld: (.text+0x1c8): undefined reference to `mallinfo'
ld: (.text+0x1d2): undefined reference to `mallopt'
ld: (.text+0x1d7): undefined reference to `_mcount'
ld: (.text+0x263): undefined reference to `putpwent'
ld: (.text+0x26d): undefined reference to `pututline'
ld: (.text+0x32b): undefined reference to `ssignal'
ld: (.text+0x3ee): undefined reference to `umount'
ld: (.text+0x461): undefined reference to `fstat64'
ld: (.text+0x466): undefined reference to `stat64'
*** Error code 1
vrza commented 2 years ago

Build is now working using the feature branch from https://github.com/taviso/123elf/pull/86

When invoked through gdb or dtruss, program runs fine!

However, when starting it from the shell it fails:

$ bin/123 
Abort trap