[tyndur-devel] [PATCH 2/2] libc: Konstruktoren
Kevin Wolf ·
+ libc: Beim Start werden Konstruktoren aufgerufen + Linkerskript fuer Userspace-Programme * Alle Programme auf das neue Linkerskript umgestellt Signed-off-by: Kevin Wolf <kevin at tyndur.org> --- buildmk.sh | 6 +++++- src/modules/c/build/Makefile.all | 2 +- src/modules/c/calc/Makefile.all | 2 +- src/modules/c/desktop/Makefile.all | 2 +- src/modules/c/fdisk/Makefile.all | 2 +- src/modules/c/ftp/Makefile.all | 2 +- src/modules/c/getterm/Makefile.all | 2 +- src/modules/c/mousetest/Makefile.all | 2 +- src/modules/c/shell/Makefile.all | 4 ++-- src/modules/c/vm86test/Makefile.all | 2 +- src/modules/cdi/ata/Makefile.all | 2 +- src/modules/cdi/e1000/Makefile.all | 2 +- src/modules/cdi/ext2/Makefile.all | 2 +- src/modules/cdi/floppy/Makefile.all | 2 +- src/modules/cdi/iso9660/Makefile.all | 2 +- src/modules/cdi/ne2k/Makefile.all | 2 +- src/modules/cdi/pcnet/Makefile.all | 2 +- src/modules/cdi/ramdisk/Makefile.all | 2 +- src/modules/cdi/rtl8139/Makefile.all | 2 +- src/modules/cdi/serial/Makefile.all | 2 +- src/modules/cdi/sis900/Makefile.all | 2 +- src/modules/cmos/Makefile.all | 2 +- src/modules/console/Makefile.all | 2 +- src/modules/dma/Makefile.all | 2 +- src/modules/fat/Makefile.all | 2 +- src/modules/file/Makefile.all | 2 +- src/modules/floppy/Makefile.all | 2 +- src/modules/gui/Makefile.all | 2 +- src/modules/init/Makefile.all | 2 +- src/modules/kbc/Makefile.all | 2 +- src/modules/lib/crt0.c | 16 ++++++++++++++++ src/modules/pas/kedit/Makefile.all | 2 +- src/modules/pas/kirc/Makefile.all | 2 +- src/modules/pas/lpt/Makefile.all | 2 +- src/modules/pas/pashello/Makefile.all | 2 +- src/modules/pas/setup/Makefile.all | 2 +- src/modules/pas/tdx/Makefile.all | 2 +- src/modules/pci/Makefile.all | 2 +- src/modules/ramoverlay/Makefile.all | 2 +- src/modules/rpcbench/Makefile.all | 2 +- src/modules/servmgr/Makefile.all | 2 +- src/modules/skeleton/Makefile.all | 2 +- src/modules/speaker/Makefile.all | 2 +- src/modules/sysinfo/Makefile.all | 2 +- src/modules/tcpip/Makefile.all | 2 +- src/modules/testlib/Makefile.all | 2 +- src/modules/tmp/Makefile.all | 2 +- src/modules/vesa/Makefile.all | 2 +- src/modules/vga/Makefile.all | 2 +- src/modules/vterm/Makefile.all | 2 +- 50 files changed, 70 insertions(+), 50 deletions(-) diff --git a/buildmk.sh b/buildmk.sh index 4e3cd85..8665913 100644 --- a/buildmk.sh +++ b/buildmk.sh @@ -72,6 +72,10 @@ if [ -d lib ]; then LIBDIRS="`pwd`/lib/library.a $LIBDIRS" fi +if [ -f "user-$LOST_ARCH.ld" ]; then + export LDSCRIPT="-T `pwd`/user-$LOST_ARCH.ld" +fi + CC_FLAGS= CC_FLAGS_APPEND= if [ -f Makefile.conf ]; then @@ -109,7 +113,7 @@ EOF fi if [ -f Makefile.all ]; then - echo -e \\tLOST_BUILDMK_ROOT="$LOST_BUILDMK_ROOT" bash Makefile.all '$(BUILD_ROOT)' \'$LIBDIRS $LIB_GCC\' \'$LOST_BUILDMK_ROOT\' >> Makefile + echo -e \\tLOST_BUILDMK_ROOT="$LOST_BUILDMK_ROOT" LDSCRIPT="'$LDSCRIPT'" bash Makefile.all '$(BUILD_ROOT)' \'$LIBDIRS $LIB_GCC\' \'$LOST_BUILDMK_ROOT\' >> Makefile fi cat <<EOF >> Makefile diff --git a/src/modules/c/build/Makefile.all b/src/modules/c/build/Makefile.all index 8c9b17a..9c2a821 100644 --- a/src/modules/c/build/Makefile.all +++ b/src/modules/c/build/Makefile.all @@ -3,5 +3,5 @@ source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/build" -$LOST_TOOLS_LD -obuild -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -obuild $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s build -o $1/apps/build diff --git a/src/modules/c/calc/Makefile.all b/src/modules/c/calc/Makefile.all index 84347dd..5c8b02b 100644 --- a/src/modules/c/calc/Makefile.all +++ b/src/modules/c/calc/Makefile.all @@ -2,6 +2,6 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/calc" -$LOST_TOOLS_LD -ocalc -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -ocalc $LDSCRIPT *.o --start-group $2 --end-group mv calc $1/apps/ diff --git a/src/modules/c/desktop/Makefile.all b/src/modules/c/desktop/Makefile.all index 510cb6e..1d4986c 100644 --- a/src/modules/c/desktop/Makefile.all +++ b/src/modules/c/desktop/Makefile.all @@ -3,7 +3,7 @@ source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/desktop" -$LOST_TOOLS_LD -odesktop -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -odesktop $LDSCRIPT *.o --start-group $2 --end-group mv desktop $1/apps/ diff --git a/src/modules/c/fdisk/Makefile.all b/src/modules/c/fdisk/Makefile.all index 8c7cbb5..652266f 100644 --- a/src/modules/c/fdisk/Makefile.all +++ b/src/modules/c/fdisk/Makefile.all @@ -3,6 +3,6 @@ source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/fdisk" -$LOST_TOOLS_LD -ofdisk -Ttext=0x40000000 --start-group *.o $2 --end-group +$LOST_TOOLS_LD -ofdisk $LDSCRIPT --start-group *.o $2 --end-group $LOST_TOOLS_STRIP -s fdisk -o $1/apps/fdisk diff --git a/src/modules/c/ftp/Makefile.all b/src/modules/c/ftp/Makefile.all index fb31509..54bf0d0 100644 --- a/src/modules/c/ftp/Makefile.all +++ b/src/modules/c/ftp/Makefile.all @@ -2,6 +2,6 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/ftp" -$LOST_TOOLS_LD -oftp -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -oftp $LDSCRIPT *.o --start-group $2 --end-group mv ftp $1/apps/ diff --git a/src/modules/c/getterm/Makefile.all b/src/modules/c/getterm/Makefile.all index 244dc29..7375874 100644 --- a/src/modules/c/getterm/Makefile.all +++ b/src/modules/c/getterm/Makefile.all @@ -3,6 +3,6 @@ source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/getterm" -$LOST_TOOLS_LD -ogetterm -Ttext=0x40000000 --start-group *.o $2 --end-group +$LOST_TOOLS_LD -ogetterm $LDSCRIPT --start-group *.o $2 --end-group $LOST_TOOLS_STRIP -s getterm -o $1/apps/getterm diff --git a/src/modules/c/mousetest/Makefile.all b/src/modules/c/mousetest/Makefile.all index 450bed8..29efae3 100644 --- a/src/modules/c/mousetest/Makefile.all +++ b/src/modules/c/mousetest/Makefile.all @@ -2,7 +2,7 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/mtest" -$LOST_TOOLS_LD -omtest -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -omtest $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s mtest -o $1/apps/mtest diff --git a/src/modules/c/shell/Makefile.all b/src/modules/c/shell/Makefile.all index 2dbbc14..dcf40c0 100644 --- a/src/modules/c/shell/Makefile.all +++ b/src/modules/c/shell/Makefile.all @@ -5,9 +5,9 @@ echo "LD $1/apps/sh" if [ -z "`grep '#define CONFIG_SHELL_BUILTIN_ONLY' ../../../include/lost/config.h`" ]; then - $LOST_TOOLS_LD -osh -Ttext=0x40000000 *.o --start-group $2 --end-group + $LOST_TOOLS_LD -osh $LDSCRIPT *.o --start-group $2 --end-group else - $LOST_TOOLS_LD -osh -Ttext=0x40000000 *.o cmds/*.o --start-group $2 --end-group + $LOST_TOOLS_LD -osh $LDSCRIPT *.o cmds/*.o --start-group $2 --end-group fi $LOST_TOOLS_STRIP -s sh -o $1/apps/sh diff --git a/src/modules/c/vm86test/Makefile.all b/src/modules/c/vm86test/Makefile.all index c128e45..c6a5c36 100644 --- a/src/modules/c/vm86test/Makefile.all +++ b/src/modules/c/vm86test/Makefile.all @@ -3,6 +3,6 @@ source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/vm86test" -$LOST_TOOLS_LD -ovm86test -Ttext=0x40000000 --start-group *.o $2 --end-group +$LOST_TOOLS_LD -ovm86test $LDSCRIPT --start-group *.o $2 --end-group $LOST_TOOLS_STRIP -s vm86test -o $1/apps/vm86test diff --git a/src/modules/cdi/ata/Makefile.all b/src/modules/cdi/ata/Makefile.all index 432c20c..a058b41 100644 --- a/src/modules/cdi/ata/Makefile.all +++ b/src/modules/cdi/ata/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/ata" -$LOST_TOOLS_LD -oata.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -oata.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s ata.mod -o $1/modules/ata diff --git a/src/modules/cdi/e1000/Makefile.all b/src/modules/cdi/e1000/Makefile.all index f0e1fc6..277e087 100644 --- a/src/modules/cdi/e1000/Makefile.all +++ b/src/modules/cdi/e1000/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/e1000" -$LOST_TOOLS_LD -oe1000.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -oe1000.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s e1000.mod -o $1/modules/e1000 diff --git a/src/modules/cdi/ext2/Makefile.all b/src/modules/cdi/ext2/Makefile.all index 3495a88..c08026b 100644 --- a/src/modules/cdi/ext2/Makefile.all +++ b/src/modules/cdi/ext2/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/ext2" -$LOST_TOOLS_LD -oext2.mod -Ttext=0x40000000 *.o */*.o --start-group $2 --end-group +$LOST_TOOLS_LD -oext2.mod $LDSCRIPT *.o */*.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s ext2.mod -o $1/modules/ext2 diff --git a/src/modules/cdi/floppy/Makefile.all b/src/modules/cdi/floppy/Makefile.all index 501db2b..487d74d 100644 --- a/src/modules/cdi/floppy/Makefile.all +++ b/src/modules/cdi/floppy/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/cdi_floppy" -$LOST_TOOLS_LD -ocdi_floppy.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -ocdi_floppy.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s cdi_floppy.mod -o $1/modules/cdi_floppy diff --git a/src/modules/cdi/iso9660/Makefile.all b/src/modules/cdi/iso9660/Makefile.all index fb14f69..7f747a1 100644 --- a/src/modules/cdi/iso9660/Makefile.all +++ b/src/modules/cdi/iso9660/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/iso9660" -$LOST_TOOLS_LD -oiso9660.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -oiso9660.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s iso9660.mod -o $1/modules/iso9660 diff --git a/src/modules/cdi/ne2k/Makefile.all b/src/modules/cdi/ne2k/Makefile.all index 250d3c3..1d51c21 100644 --- a/src/modules/cdi/ne2k/Makefile.all +++ b/src/modules/cdi/ne2k/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/ne2k" -$LOST_TOOLS_LD -Ttext=0x40000000 -one2k.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -one2k.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s ne2k.mod -o $1/modules/ne2k diff --git a/src/modules/cdi/pcnet/Makefile.all b/src/modules/cdi/pcnet/Makefile.all index 4ad6890..b8937a1 100644 --- a/src/modules/cdi/pcnet/Makefile.all +++ b/src/modules/cdi/pcnet/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/pcnet" -$LOST_TOOLS_LD -Ttext=0x40000000 -opcnet.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -opcnet.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s pcnet.mod -o $1/modules/pcnet diff --git a/src/modules/cdi/ramdisk/Makefile.all b/src/modules/cdi/ramdisk/Makefile.all index 3e03444..9c724e7 100644 --- a/src/modules/cdi/ramdisk/Makefile.all +++ b/src/modules/cdi/ramdisk/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/ramdisk" -$LOST_TOOLS_LD -oramdisk.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -oramdisk.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s ramdisk.mod -o $1/modules/ramdisk diff --git a/src/modules/cdi/rtl8139/Makefile.all b/src/modules/cdi/rtl8139/Makefile.all index c7bfe1d..d5f64ab 100644 --- a/src/modules/cdi/rtl8139/Makefile.all +++ b/src/modules/cdi/rtl8139/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/rtl8139" -$LOST_TOOLS_LD -Ttext=0x40000000 -ortl8139.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -ortl8139.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s rtl8139.mod -o $1/modules/rtl8139 diff --git a/src/modules/cdi/serial/Makefile.all b/src/modules/cdi/serial/Makefile.all index 2f03a04..7118ff0 100644 --- a/src/modules/cdi/serial/Makefile.all +++ b/src/modules/cdi/serial/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/serial" -$LOST_TOOLS_LD -oserial.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -oserial.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s serial.mod -o $1/modules/serial diff --git a/src/modules/cdi/sis900/Makefile.all b/src/modules/cdi/sis900/Makefile.all index 697149c..a76350e 100644 --- a/src/modules/cdi/sis900/Makefile.all +++ b/src/modules/cdi/sis900/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/sis900" -$LOST_TOOLS_LD -osis900.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -osis900.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s sis900.mod -o $1/modules/sis900 diff --git a/src/modules/cmos/Makefile.all b/src/modules/cmos/Makefile.all index 4678dfc..0c40b28 100755 --- a/src/modules/cmos/Makefile.all +++ b/src/modules/cmos/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/cmos" -$LOST_TOOLS_LD -ocmos.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -ocmos.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s cmos.mod -o $1/modules/cmos diff --git a/src/modules/console/Makefile.all b/src/modules/console/Makefile.all index 6d537f9..5fa0a43 100644 --- a/src/modules/console/Makefile.all +++ b/src/modules/console/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/console" -$LOST_TOOLS_LD -Ttext=0x40000000 -oconsole.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -oconsole.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s console.mod -o $1/modules/console diff --git a/src/modules/dma/Makefile.all b/src/modules/dma/Makefile.all index 2c43d17..cdf2120 100644 --- a/src/modules/dma/Makefile.all +++ b/src/modules/dma/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/dma" -$LOST_TOOLS_LD -odma.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -odma.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s dma.mod -o $1/modules/dma diff --git a/src/modules/fat/Makefile.all b/src/modules/fat/Makefile.all index 850b36d..7ceec1a 100644 --- a/src/modules/fat/Makefile.all +++ b/src/modules/fat/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/fat" -$LOST_TOOLS_LD -ofat.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -ofat.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s fat.mod -o $1/modules/fat diff --git a/src/modules/file/Makefile.all b/src/modules/file/Makefile.all index d1343c6..2e344f2 100644 --- a/src/modules/file/Makefile.all +++ b/src/modules/file/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/file" -$LOST_TOOLS_LD -ofile.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -ofile.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s file.mod -o $1/modules/file diff --git a/src/modules/floppy/Makefile.all b/src/modules/floppy/Makefile.all index 79b7e71..1c14c78 100755 --- a/src/modules/floppy/Makefile.all +++ b/src/modules/floppy/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/floppy" -$LOST_TOOLS_LD -ofloppy.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -ofloppy.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s floppy.mod -o $1/modules/floppy diff --git a/src/modules/gui/Makefile.all b/src/modules/gui/Makefile.all index 59df853..6791a3d 100644 --- a/src/modules/gui/Makefile.all +++ b/src/modules/gui/Makefile.all @@ -2,7 +2,7 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/gui" -$LOST_TOOLS_LD -Ttext=0x40000000 -ogui.mod src/*.o src/freetype/base/ftbase.o src/freetype/base/ftsystem.o src/freetype/base/ftglyph.o src/freetype/base/ftbitmap.o src/freetype/base/ftinit.o src/freetype/autofit/autofit.o src/freetype/smooth/smooth.o src/freetype/psaux/psaux.o src/freetype/psnames/psnames.o src/freetype/pshinter/pshinter.o src/freetype/truetype/truetype.o src/freetype/raster/raster.o src/freetype/gzip/ftgzip.o src/freetype/lzw/ftlzw.o src/freetype/sfnt/sfnt.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -ogui.mod src/*.o src/freetype/base/ftbase.o src/freetype/base/ftsystem.o src/freetype/base/ftglyph.o src/freetype/base/ftbitmap.o src/freetype/base/ftinit.o src/freetype/autofit/autofit.o src/freetype/smooth/smooth.o src/freetype/psaux/psaux.o src/freetype/psnames/psnames.o src/freetype/pshinter/pshinter.o src/freetype/truetype/truetype.o src/freetype/raster/raster.o src/freetype/gzip/ftgzip.o src/freetype/lzw/ftlzw.o src/freetype/sfnt/sfnt.o --start-group $2 --end-group mv gui.mod $1/modules/gui #Andere Formate (in def ftmodule.h aktivieren): #src/freetype/type42/type42.o diff --git a/src/modules/init/Makefile.all b/src/modules/init/Makefile.all index 13c03f2..3d50e8f 100644 --- a/src/modules/init/Makefile.all +++ b/src/modules/init/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/init" -$LOST_TOOLS_LD -Ttext=0x40000000 -oinit.mod *.o */*.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -oinit.mod *.o */*.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s init.mod -o $1/modules/init diff --git a/src/modules/kbc/Makefile.all b/src/modules/kbc/Makefile.all index 98dedb9..92bb1a1 100644 --- a/src/modules/kbc/Makefile.all +++ b/src/modules/kbc/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/kbc" -$LOST_TOOLS_LD -m elf_i386 -okbc.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -m elf_i386 -okbc.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s kbc.mod -o $1/modules/kbc diff --git a/src/modules/lib/crt0.c b/src/modules/lib/crt0.c index 615baf9..4c3192d 100644 --- a/src/modules/lib/crt0.c +++ b/src/modules/lib/crt0.c @@ -39,6 +39,21 @@ extern void init_envvars(void); extern void init_waitpid(void); extern void stdio_init(void); +extern void (*__ctor_start__)(void); +extern void (*__ctor_end__)(void); + +static void call_constructors(void) +{ + void (**f)(void); + + for (f = &__ctor_start__; f < &__ctor_end__; f++) { + /* Dummy-Eintrag aus crtbegin.o ueberspringen */ + if (*f && ((uintptr_t) *f != 0xffffffff)) { + (*f)(); + } + } +} + void __attribute__((weak)) _start(void) { //v(); @@ -87,6 +102,7 @@ void __attribute__((weak)) _start(void) } argv[argc] = NULL; + call_constructors(); int result = main(argc, argv); // Falls ein Buffer auf stdout eingerichtet wurde, wird der geflusht und diff --git a/src/modules/pas/kedit/Makefile.all b/src/modules/pas/kedit/Makefile.all index 7f4d2d0..03cb164 100644 --- a/src/modules/pas/kedit/Makefile.all +++ b/src/modules/pas/kedit/Makefile.all @@ -1,4 +1,4 @@ shopt -s extglob echo "LD $1/kedit" -"$COMPILER_PREFIX"ld -m elf_i386 -okedit -Ttext=0x40000000 *.o lang/*.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` +"$COMPILER_PREFIX"ld -m elf_i386 -okedit $LDSCRIPT *.o lang/*.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` strip -s kedit -o $1/apps/kedit diff --git a/src/modules/pas/kirc/Makefile.all b/src/modules/pas/kirc/Makefile.all index 2c84acc..b934084 100644 --- a/src/modules/pas/kirc/Makefile.all +++ b/src/modules/pas/kirc/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/kirc" -$LOST_TOOLS_LD -okirc -Ttext=0x40000000 *.o --start-group ../lib/units/*.a $2 --end-group +$LOST_TOOLS_LD -okirc $LDSCRIPT *.o --start-group ../lib/units/*.a $2 --end-group $LOST_TOOLS_STRIP -s kirc -o $1/apps/kirc diff --git a/src/modules/pas/lpt/Makefile.all b/src/modules/pas/lpt/Makefile.all index c4078d2..22840bc 100644 --- a/src/modules/pas/lpt/Makefile.all +++ b/src/modules/pas/lpt/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/lpt" -$LOST_TOOLS_LD -olpt.mod -Ttext=0x40000000 *.o lang/*.o --start-group ../lib/units/*.a $2 --end-group +$LOST_TOOLS_LD -olpt.mod $LDSCRIPT *.o lang/*.o --start-group ../lib/units/*.a $2 --end-group $LOST_TOOLS_STRIP -s lpt.mod -o $1/apps/lpt diff --git a/src/modules/pas/pashello/Makefile.all b/src/modules/pas/pashello/Makefile.all index 6fece97..27a3a02 100644 --- a/src/modules/pas/pashello/Makefile.all +++ b/src/modules/pas/pashello/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/apps/pashello" -$LOST_TOOLS_LD -opashello -Ttext=0x40000000 *.o --start-group ../lib/units/*.a $2 --end-group +$LOST_TOOLS_LD -opashello $LDSCRIPT *.o --start-group ../lib/units/*.a $2 --end-group $LOST_TOOLS_STRIP -s pashello -o $1/apps/pashello diff --git a/src/modules/pas/setup/Makefile.all b/src/modules/pas/setup/Makefile.all index 29fea51..1b1b1be 100644 --- a/src/modules/pas/setup/Makefile.all +++ b/src/modules/pas/setup/Makefile.all @@ -1,4 +1,4 @@ shopt -s extglob echo "LD $1/setup" -"$COMPILER_PREFIX"ld -m elf_i386 -osetup -Ttext=0x40000000 *.o lang/*.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` +"$COMPILER_PREFIX"ld -m elf_i386 -osetup $LDSCRIPT *.o lang/*.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` strip -s setup -o $1/apps/setup diff --git a/src/modules/pas/tdx/Makefile.all b/src/modules/pas/tdx/Makefile.all index 5b05399..11da9eb 100644 --- a/src/modules/pas/tdx/Makefile.all +++ b/src/modules/pas/tdx/Makefile.all @@ -1,4 +1,4 @@ shopt -s extglob echo "LD $1/tdx" -"$COMPILER_PREFIX"ld -m elf_i386 -otdx -Ttext=0x40000000 *.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` +"$COMPILER_PREFIX"ld -m elf_i386 -otdx $LDSCRIPT *.o --start-group ../lib/units/*.a $2 --end-group `gcc -print-libgcc-file-name` strip -s tdx -o $1/apps/tdx diff --git a/src/modules/pci/Makefile.all b/src/modules/pci/Makefile.all index a216d0c..a2fb264 100644 --- a/src/modules/pci/Makefile.all +++ b/src/modules/pci/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/pci" -$LOST_TOOLS_LD -opci.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -opci.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s pci.mod -o $1/modules/pci diff --git a/src/modules/ramoverlay/Makefile.all b/src/modules/ramoverlay/Makefile.all index 8eacb97..d93ef54 100644 --- a/src/modules/ramoverlay/Makefile.all +++ b/src/modules/ramoverlay/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/ramoverlay" -$LOST_TOOLS_LD -Ttext=0x40000000 -oramoverlay.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -oramoverlay.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s ramoverlay.mod -o $1/modules/ramoverlay diff --git a/src/modules/rpcbench/Makefile.all b/src/modules/rpcbench/Makefile.all index 1c47c42..6a4a465 100644 --- a/src/modules/rpcbench/Makefile.all +++ b/src/modules/rpcbench/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/rpcbench" -$LOST_TOOLS_LD -Ttext=0x40000000 -orpcbench.mod --start-group *.o $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -orpcbench.mod --start-group *.o $2 --end-group $LOST_TOOLS_STRIP -s rpcbench.mod -o $1/modules/rpcbench diff --git a/src/modules/servmgr/Makefile.all b/src/modules/servmgr/Makefile.all index 4a276b2..59b7be6 100644 --- a/src/modules/servmgr/Makefile.all +++ b/src/modules/servmgr/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/servmgr" -$LOST_TOOLS_LD -Ttext=0x40000000 -oservmgr.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -oservmgr.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s servmgr.mod -o $1/modules/servmgr diff --git a/src/modules/skeleton/Makefile.all b/src/modules/skeleton/Makefile.all index ebf4abc..ef77ae3 100644 --- a/src/modules/skeleton/Makefile.all +++ b/src/modules/skeleton/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/skeleton" -$LOST_TOOLS_LD -Ttext=0x40000000 -oskeleton.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -oskeleton.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s skeleton.mod -o $1/modules/skeleton diff --git a/src/modules/speaker/Makefile.all b/src/modules/speaker/Makefile.all index 4f8ce8e..186dcbf 100644 --- a/src/modules/speaker/Makefile.all +++ b/src/modules/speaker/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/speaker" -$LOST_TOOLS_LD -Ttext=0x40000000 -ospeaker.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -ospeaker.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s speaker.mod -o $1/modules/speaker diff --git a/src/modules/sysinfo/Makefile.all b/src/modules/sysinfo/Makefile.all index 8eda0b4..0a4aa9d 100644 --- a/src/modules/sysinfo/Makefile.all +++ b/src/modules/sysinfo/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/sysinfo" -$LOST_TOOLS_LD -Ttext=0x40000000 -osysinfo.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -osysinfo.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s sysinfo.mod -o $1/modules/sysinfo diff --git a/src/modules/tcpip/Makefile.all b/src/modules/tcpip/Makefile.all index d1e355f..ea8e4e4 100644 --- a/src/modules/tcpip/Makefile.all +++ b/src/modules/tcpip/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/tcpip" -$LOST_TOOLS_LD -Ttext=0x40000000 -otcpip.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -otcpip.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s tcpip.mod -o $1/modules/tcpip diff --git a/src/modules/testlib/Makefile.all b/src/modules/testlib/Makefile.all index 89e888d..4500c64 100644 --- a/src/modules/testlib/Makefile.all +++ b/src/modules/testlib/Makefile.all @@ -2,6 +2,6 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/tests" -$LOST_TOOLS_LD -otests.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -otests.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s tests.mod -o $1/modules/tests diff --git a/src/modules/tmp/Makefile.all b/src/modules/tmp/Makefile.all index d3aa060..81fe3eb 100755 --- a/src/modules/tmp/Makefile.all +++ b/src/modules/tmp/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/tmp" -$LOST_TOOLS_LD -otmp.mod -Ttext=0x40000000 *.o --start-group $2 --end-group +$LOST_TOOLS_LD -otmp.mod $LDSCRIPT *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s tmp.mod -o $1/modules/tmp diff --git a/src/modules/vesa/Makefile.all b/src/modules/vesa/Makefile.all index ec59a0e..2d4ace1 100644 --- a/src/modules/vesa/Makefile.all +++ b/src/modules/vesa/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/vesa" -$LOST_TOOLS_LD -Ttext=0x40000000 -ovesa.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -ovesa.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s vesa.mod -o $1/modules/vesa diff --git a/src/modules/vga/Makefile.all b/src/modules/vga/Makefile.all index 767707f..599af71 100644 --- a/src/modules/vga/Makefile.all +++ b/src/modules/vga/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/vga" -$LOST_TOOLS_LD -Ttext=0x40000000 -ovga.mod *.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -ovga.mod *.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s vga.mod -o $1/modules/vga diff --git a/src/modules/vterm/Makefile.all b/src/modules/vterm/Makefile.all index a987d5c..9bafcce 100644 --- a/src/modules/vterm/Makefile.all +++ b/src/modules/vterm/Makefile.all @@ -2,5 +2,5 @@ shopt -s extglob source $LOST_BUILDMK_ROOT/config.sh echo "LD $1/modules/vterm" -$LOST_TOOLS_LD -Ttext=0x40000000 -ovterm.mod *.o keymaps/de.o --start-group $2 --end-group +$LOST_TOOLS_LD $LDSCRIPT -ovterm.mod *.o keymaps/de.o --start-group $2 --end-group $LOST_TOOLS_STRIP -s vterm.mod -o $1/modules/vterm -- 1.6.0.2
Antworten
- [tyndur-devel] [PATCH v2 2/2] libc: Konstruktoren · Kevin Wolf