Posts

Showing posts from February, 2023

Towards GNU/MINIX - libstdc++

Image
Cross-compiled C++ program running on Minix   To compile a C++ program, we need C++ standard library. While Clang libc++.so comes with Minix distribution, GCC version of libstdc++.so has to be cross-compiled . Interestingly, while GNU C library Glibc is a separate project, libstdc++ is part of the GCC project. In other words, you can use a different C library (like musl or ulibc) with GCC if you want. Lessons Learnt Clang uses inline namespaces by default whereas GCC does not. anand@PureBook:~/work/minix/usr/lib$ nm -s libstdc++.so | c++filt | grep cout 00328a20 b __gnu_internal::buf_cout_sync 00329080 b __gnu_internal::buf_wcout_sync 00328ae0 b __gnu_internal::buf_cout 00329140 b __gnu_internal::buf_wcout 003285c0 B std::cout 00328840 B std::wcout anand@PureBook:~/work/minix/usr/lib$ nm -s libc++.so | c++filt | grep cout 000c2b00 B std::__1::cout 000c2c54 B std::__1::wcout   You can use objcopy to alter symbol name in an object file or library. mthread.h has provisions for supporti

Micro Emacs on GNU/Minix

Image
Following the filesystem creation on GNU/Minix, the next step is to port an application. Here's a basic port of Micro Emacs (v3.5) running on GNU/Minix (v3.3.0). ./configure --without-curses     Since configure doesn't support Minix, we need to manually edit the CC and LIBOBJS (for reallocarray() function) variable in generated Makefile. LIBOBJS =  ${LIBOBJDIR}fparseln$U.o ${LIBOBJDIR}strlcpy$U.o ${LIBOBJDIR}strlcat$U.o ${LIBOBJDIR}strtonum$U.o ${LIBOBJDIR}reallocarray$U.o   Also we need following patches. modified   src/def.h @@ -12,7 +12,8 @@    #include    "config.h"   -#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) \ +  || defined(__minix)  # include    <sys/queue.h>  # include    <sys/tree.h>  # ifdef __FreeBSD__ @@ -23,15 +24,14 @@  #else /* __NotBSD__, DragonFly BSD, or macOS */  # include    "queue.h"  # include    "tree.h" +#ifd

Towards GNU/MINIX - Filesystem

Image
In this post, we will look at populating Minix filesystem with some files of our own (specifically the welcome message) using GNU tools. Extract files from distribution CD into three folders - isodir, root.dir and usr.dir. Create a text file grub-hd.cfg . p0 denotes first partition. insmod part_msdos menuentry "GNU MINIX 3" {     multiboot /kernel rootdevname= c0d0p0 verbose=1          module /mod01_ds     module /mod02_rs     module /mod03_pm     module /mod04_sched     module /mod05_vfs     module /mod06_memory     module /mod07_tty     module /mod08_mfs     module /mod09_vm     module /mod10_pfs     module /mod11_init }   Create a text file partition.txt for your partition definition . label: dos label-id: 0x40fbf996 device: minix.img unit: sectors sector-size: 512 minix.img1 : start=        2048, size=         +64M, type=81, bootable     The script below will create a disk image. Then create a Minix partition (code 81). For creating the filesystem (MinixFS v3), you'