tkchia / newlib-ia16

Fork of IA-16 port of Newlib -- added small and medium model support
GNU General Public License v2.0
13 stars 4 forks source link

Putenv doesn't seem to be in libc #19

Closed andrewbird closed 2 years ago

andrewbird commented 2 years ago

Hello @tkchia, I'm trying to compile / link kitten's test program with gcc-ia16. I'm sure it must have worked in the past, but for some reason I don't seem to be able to link in putenv now.

https://github.com/FDOS/kitten

ajb@polly:/clients/common/fdos/kitten.git$ make -C test clean ; env COMPILER=gcc ./build.sh 
make: Entering directory '/clients/common/fdos/kitten.git/test'
rm -f test.exe
rm -f *.obj
rm -f *.o
make: Leaving directory '/clients/common/fdos/kitten.git/test'
make: Entering directory '/clients/common/fdos/kitten.git/test'
ia16-elf-gcc -Wall -mcmodel=small -otest.exe test.c ../kitten.c
/usr/lib/x86_64-linux-gnu/gcc/ia16-elf/6.3.0/../../../../../ia16-elf/bin/ld: /tmp/cc4zOWYO.o: in function `main':
(.text+0xd): undefined reference to `putenv'
/usr/lib/x86_64-linux-gnu/gcc/ia16-elf/6.3.0/../../../../../ia16-elf/bin/ld: (.text+0x19): undefined reference to `putenv'
collect2: error: ld returned 1 exit status
make: *** [Makefile:2: test.exe] Error 1
make: Leaving directory '/clients/common/fdos/kitten.git/test'
ajb@polly:/clients/common/fdos/kitten.git$ readelf -a /usr/ia16-elf/lib/rtd/libc.a | grep putenv
ajb@polly:/clients/common/fdos/kitten.git$ readelf -a /usr/ia16-elf/lib/rtd/libc.a | grep getenv
File: /usr/ia16-elf/lib/rtd/libc.a(lib_a-getenv.o)
     8: 00000016    24 FUNC    GLOBAL DEFAULT    1 getenv
File: /usr/ia16-elf/lib/rtd/libc.a(lib_a-getenv_r.o)
    10: 00000083    23 FUNC    GLOBAL DEFAULT    1 _getenv_r
000001b9  00001115 R_386_PC16        00000000   getenv
    17: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND getenv
00000076  00000e15 R_386_PC16        00000000   _getenv_r
    14: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _getenv_r
0000000d  00001315 R_386_PC16        00000000   _getenv_r
00000025  00001315 R_386_PC16        00000000   _getenv_r
00000031  00001315 R_386_PC16        00000000   _getenv_r
    19: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _getenv_r
000000c0  00000e15 R_386_PC16        00000000   getenv
    14: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND getenv
000000e0  00001015 R_386_PC16        00000000   _getenv_r
    16: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _getenv_r

Thank you!

tkchia commented 2 years ago

Hello @andrewbird,

It looks like putenv got left out of the Newlib compilation after I changed the build process to only build EL/IX level 2 routines.

I guess I will need to see how to either re-enable putenv (and setenv) to Newlib, or somehow add them into libi86.

Thank you!

andrewbird commented 2 years ago

Hello @tkchia,

That's good to know. There's no hurry for this on my part, so fit it in when you can.

Thanks you!

andrewbird commented 2 years ago

Thanks, it works fine again now!