Closed onoraba closed 2 years ago
Building binutils
with --enable-tui
didn't help
Hmm -- I think it wants the static version, maybe it's lib32ncurses-dev
?
I'll try to get better build instructions for Ubuntu this weekend, I was mostly using Fedora while hacking on this!
maybe it's
lib32ncurses-dev
thanks, after installing I get new error
$ make
cc -m32 -ggdb3 -O0 -Wno-multichar -m32 -ggdb3 -O0 -Wno-multichar -B. -Wl,-b,coff-i386 coffsyrup.c -lncurses -o coffsyrup
./ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib32/Scrt1.o: in function `_start':
(.text+0x1c): undefined reference to `__libc_csu_fini'
./ld: (.text+0x23): undefined reference to `__libc_csu_init'
./ld: /tmp/cckQdK5o.o: in function `main':
/home/user/123/123elf/coffsyrup.c:382: undefined reference to `__stack_chk_fail_local'
./ld: coffsyrup: hidden symbol `__stack_chk_fail_local' isn't defined
./ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [<builtin>: coffsyrup] Error 1
I had to # apt install libncurses5-dev:i386
on Ubuntu 20.04.
I've not yet built the binary due to linking errors, but I got further with adding -fno-stack-protector /lib32/libc_nonshared.a
to CFLAGS. The latter fixed undefined reference to __libc_csu_fini
(not sure if it's the correct way of doing this) and the former undefined reference to `__stack_chk_fail_local'
I'm now stuck on
cc -m32 -ggdb3 -O0 -Wno-multichar -fno-stack-protector /lib32/libc_nonshared.a -B. -Wl,-b,coff-i386 123.o dl_init.o main.o forceplt.o wrappers.o patch.o -lncurses -o 123
./ld: 123.o:nrcreate.c:(.text+0xb60b4): undefined reference to `close_range'
./ld: 123.o:nrcreate.c:(.text+0xb61ce): undefined reference to `close_range'
./ld: 123.o:nrfixup.c:(.text+0xb6ca5): undefined reference to `close_range'
./ld: 123.o:nrfixup.c:(.text+0xb6e52): undefined reference to `close_range'
./ld: forceplt.o: in function `__require_ref':
(.text+0x5b): undefined reference to `close_range'
./ld: (.text+0xec): undefined reference to `fstat'
./ld: (.text+0x209): undefined reference to `mknod'
./ld: (.text+0x358): undefined reference to `stat'
./ld: wrappers.o: in function `__unix_stat':
/home/steve/sandbox/123elf/wrappers.c:134: undefined reference to `stat'
./ld: wrappers.o: in function `__unix_fstat':
/home/steve/sandbox/123elf/wrappers.c:148: undefined reference to `fstat'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: 123] Error 1
yep, added -fno-stack-protector /lib32/libc_nonshared.a
to CFLAGS
and stuck on
$ make
cc -m32 -ggdb3 -O0 -Wno-multichar -fno-stack-protector /lib32/libc_nonshared.a -B. -Wl,-b,coff-i386 123.o dl_init.o main.o forceplt.o wrappers.o patch.o -lpanel -lncurses -dynamic-linker /usr/lib32/ld-linux.so.2 -o 123
./ld: 123.o:nrcreate.c:(.text+0xb60b4): undefined reference to `close_range'
./ld: 123.o:nrcreate.c:(.text+0xb61ce): undefined reference to `close_range'
./ld: 123.o:nrfixup.c:(.text+0xb6ca5): undefined reference to `close_range'
./ld: 123.o:nrfixup.c:(.text+0xb6e52): undefined reference to `close_range'
./ld: forceplt.o: in function `__require_ref':
(.text+0x5b): undefined reference to `close_range'
./ld: (.text+0xec): undefined reference to `fstat'
./ld: (.text+0x209): undefined reference to `mknod'
./ld: (.text+0x358): undefined reference to `stat'
./ld: wrappers.o: in function `__unix_stat':
/home/user/123/123elf/wrappers.c:134: undefined reference to `stat'
./ld: wrappers.o: in function `__unix_fstat':
/home/user/123/123elf/wrappers.c:148: undefined reference to `fstat'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: 123] Error 1
Oops - that looks like a bug, close_range
should be a localized. Let me quickly push that change and see if that fixes it.
That fixes close_range
Hmm, I think I just need to add stat
, mknod
and fstat
to forceplt.s
-- can you see if that does anything? (Note: you might need to make clean after changing it)
Nevermind, they're already in there - very confusing! It might take me a few hours before I can get to my Ubuntu machine and repro, sorry!
Okay, I think I've found the problem -- give me five minutes to commit something.
It might work now -- although I'm still confused about how a few things work, can you see if it makes any progress?
Not quite yet...
cc -lc -m32 -ggdb3 -O0 -Wno-multichar -fno-stack-protector -B. -Wl,-b,coff-i386 -no-pie 123.o dl_init.o main.o forceplt.o wrappers.o patch.o -lncurses -o 123
./ld: 123.o: warning: the use of `tempnam' is dangerous, better use `mkstemp'
./ld: 123.o:time_comm.c:(.text+0xdf104): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
./ld: 123.o: warning: gtty is not implemented and will always fail
./ld: 123.o: warning: stty is not implemented and will always fail
./ld: 123.o:crt1.s:(.data+0x1f684): multiple definition of `sys_errlist'
./ld: 123.o:crt1.s:(.data+0x1f8c0): multiple definition of `sys_nerr'
./ld: forceplt.o: in function `__require_ref':
(.text+0xe7): undefined reference to `fstat'
./ld: (.text+0x204): undefined reference to `mknod'
./ld: (.text+0x353): undefined reference to `stat'
./ld: wrappers.o: in function `__unix_stat':
/home/steve/sandbox/123elf/wrappers.c:126: undefined reference to `stat'
./ld: wrappers.o: in function `__unix_fstat':
/home/steve/sandbox/123elf/wrappers.c:138: undefined reference to `fstat'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: 123] Error 1
same here
cc -lc -m32 -ggdb3 -O0 -Wno-multichar -fno-stack-protector -B. -Wl,-b,coff-i386 -no-pie 123.o dl_init.o main.o forceplt.o wrappers.o patch.o -lncurses -o 123
./ld: 123.o: warning: the use of `tempnam' is dangerous, better use `mkstemp'
./ld: 123.o:time_comm.c:(.text+0xdf104): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
./ld: 123.o: warning: gtty is not implemented and will always fail
./ld: 123.o: warning: stty is not implemented and will always fail
./ld: 123.o:crt1.s:(.data+0x1f684): multiple definition of `sys_errlist'
./ld: 123.o:crt1.s:(.data+0x1f8c0): multiple definition of `sys_nerr'
./ld: forceplt.o: in function `__require_ref':
(.text+0xe7): undefined reference to `fstat'
./ld: (.text+0x204): undefined reference to `mknod'
./ld: (.text+0x353): undefined reference to `stat'
./ld: wrappers.o: in function `__unix_stat':
/home/user/123/123elf/wrappers.c:126: undefined reference to `stat'
./ld: wrappers.o: in function `__unix_fstat':
/home/user/123/123elf/wrappers.c:138: undefined reference to `fstat'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: 123] Error 1
Hmm, okay - can you try running this manually to see if it works:
cc forceplt.o -lc -m32 -ggdb3 -O0 -Wno-multichar -fno-stack-protector -B. -Wl,-b,coff-i386 -no-pie 123.o dl_init.o main.o wrappers.o patch.o -lncurses -o 123
It must be a link order issue!
I think I've finally got it - I installed focal in a VM, and it seems to work now!
I can confirm that works for me. It's nice seeing 123 greater than 80x25!
Hi
I've tried to build on
First build binutils with --prefix=/home/user/opt --enable-targets=all And then
Installing every ncurses* pkg with 32-bit versions didn't help
Changing Makefile also didn't help
LDLIBS = -lncurses -L/usr/lib/x86_64-linux-gnu
Even with
LDLIBS = -lncurses -L/usr/lib32