Skip to content

This is a modified version of Mini-CRT++ in the book <程序员的自我修养>, it supports 32-bit and 64-bit system.

Notifications You must be signed in to change notification settings

liupengs/Mini-CRT

Repository files navigation

#Mini-Crt Introduction:

This Mini-CRT (C runtime library) is a modified version of the code in the book <程序员的自我修养>.

当前支持64位的系统,在linux和windows下测试通过。

Environment:

Linux or Windows

In Linux x86:

gcc -c -fno-builtin -nostdlib -fno-stack-protector entry.c malloc.c stdio.c string.c atexit.c

g++ -c -nostdinc++ -fno-rtti -fno-exceptions -fno-builtin -nostdlib -fno-stack-protector crtbegin.cpp crtend.cpp ctors.cpp new_delete.cpp sysdep.cpp iostream.cpp sysdep.cpp

ar -rs minicrt.a malloc.o stdio.o string.o ctors.o atexit.o iostream.o new_delete.o sysdep.o

g++ -c -nostdinc++ -fno-rtti -fno-exceptions -fno-builtin -nostdlib -fno-stack-protector test.cpp

ld -static -e mini_crt_entry entry.o crtbegin.o test.o minicrt.a crtend.o -o test

In Linux x64:

gcc -c -fno-builtin -nostdlib -fno-stack-protector entry.c malloc.c stdio.c string.c atexit.c -DX64

g++ -c -nostdinc++ -fno-rtti -fno-exceptions -fno-builtin -nostdlib -fno-stack-protector crtbegin.cpp crtend.cpp ctors.cpp new_delete.cpp sysdep.cpp iostream.cpp sysdep.cpp -DX64

ar -rs minicrt.a malloc.o stdio.o string.o ctors.o atexit.o iostream.o new_delete.o sysdep.o

g++ -c -nostdinc++ -fno-rtti -fno-exceptions -fno-builtin -nostdlib -fno-stack-protector test.cpp

ld -static -e mini_crt_entry entry.o crtbegin.o test.o minicrt.a crtend.o -o test

In Windows:

cl /c /DWIN32 /GS- entry.c malloc.c stdio.c string.c atexit.c

cl /c /DWIN32 /GS- /GR- crtbegin.cpp crtend.cpp ctors.cpp new_delete.cpp iostream.cpp

lib entry.obj malloc.obj stdio.obj string.obj ctors.obj new_delete.obj atexit.obj iostream.obj /OUT:minicrt.lib

cl /c /DWIN32 /GR- test.cpp

link test.obj minicrt.lib kernel32.lib /NODEFAULTLIB /entry:mini_crt_entry

About

This is a modified version of Mini-CRT++ in the book <程序员的自我修养>, it supports 32-bit and 64-bit system.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published