Index: boot/arch/arm32/loader/Makefile
===================================================================
--- boot/arch/arm32/loader/Makefile	(revision e19d6679169d90e6f4384eed72d6cd3992334f1d)
+++ boot/arch/arm32/loader/Makefile	(revision 136edca07dac4855f2401e71778a4078795a3216)
@@ -28,13 +28,16 @@
 
 include ../../../../version
-include ../../../../Makefile.config
+include ../../../Makefile.config
 
 ## Toolchain configuration
 #
 
+BFD = elf32-littlearm
+BFD_NAME = elf32-littlearm
+BFD_ARCH = arm
 TARGET = arm-linux-gnu
 TOOLCHAIN_DIR = /usr/local/arm/bin
 
-ifeq ($(COMPILER),native)
+ifeq ($(COMPILER),gcc_native)
 	CC = gcc
 	AS = as
@@ -42,5 +45,7 @@
 	OBJCOPY = objcopy
 	OBJDUMP = objdump
-else
+endif
+
+ifeq ($(COMPILER),gcc_cross)
 	CC = $(TOOLCHAIN_DIR)/$(TARGET)-gcc
 	AS = $(TOOLCHAIN_DIR)/$(TARGET)-as
@@ -69,18 +74,15 @@
 	asm.S \
 	mm.c \
+	print/gxemul.c \
+	_components.c \
 	../../../generic/printf.c \
 	../../../genarch/division.c
-
-ifeq ($(MACHINE), gxemul_testarm)
-	SOURCES += print/gxemul.c
-endif
-
 
 COMPONENTS = \
 	$(KERNELDIR)/kernel.bin \
 	$(USPACEDIR)/srv/ns/ns \
+	$(USPACEDIR)/srv/fb/fb \
 	$(USPACEDIR)/srv/kbd/kbd \
 	$(USPACEDIR)/srv/console/console \
-	$(USPACEDIR)/srv/fb/fb \
 	$(USPACEDIR)/srv/vfs/vfs \
 	$(USPACEDIR)/srv/fs/tmpfs/tmpfs \
@@ -88,7 +90,7 @@
 	$(USPACEDIR)/srv/devmap/devmap \
 	$(USPACEDIR)/app/init/init \
+	$(USPACEDIR)/app/tetris/tetris \
 	$(USPACEDIR)/app/tester/tester \
-	$(USPACEDIR)/app/klog/klog \
-	$(USPACEDIR)/app/tetris/tetris
+	$(USPACEDIR)/app/klog/klog
 
 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
@@ -101,6 +103,6 @@
 -include Makefile.depend
 
-image.boot: depend _components.h _link.ld $(OBJECTS) $(COMPONENT_OBJECTS)
-	$(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@ 
+image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS)
+	$(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@
 
 depend:
@@ -108,8 +110,8 @@
 
 clean:
-	-rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend 
+	-rm -f _components.h _components.c _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
 
-_components.h _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
-	./pack $(IMAGE) $(OBJCOPY) $(COMPONENTS)
+_components.h _components.c _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
+	../../../tools/pack.py $(OBJCOPY) $(BFD_NAME) $(BFD) $(BFD_ARCH) 4096 $(COMPONENTS)
 
 %.o: %.S
Index: boot/arch/arm32/loader/_link.ld.in
===================================================================
--- boot/arch/arm32/loader/_link.ld.in	(revision 136edca07dac4855f2401e71778a4078795a3216)
+++ boot/arch/arm32/loader/_link.ld.in	(revision 136edca07dac4855f2401e71778a4078795a3216)
@@ -0,0 +1,17 @@
+	.boot 0x0: AT (0) {
+		*(BOOTSTRAP);
+		*(.text);
+		
+		*(.rodata);
+		*(.rodata.*);
+		*(.data);		/* initialized data */
+		*(.sdata);
+		*(.sdata2);
+		*(.sbss);
+		*(.scommon);
+		*(.bss);		/* uninitialized static variables */	
+		*(COMMON); 		/* global variables */
+		*(.reginfo);
+
+		. = 0x4000;
+		*(PT);			/* page table placed at 0x4000 */
Index: boot/arch/arm32/loader/main.c
===================================================================
--- boot/arch/arm32/loader/main.c	(revision e19d6679169d90e6f4384eed72d6cd3992334f1d)
+++ boot/arch/arm32/loader/main.c	(revision 136edca07dac4855f2401e71778a4078795a3216)
@@ -77,6 +77,7 @@
 
 	component_t components[COMPONENTS];
+	init_components(components);
+	
 	bootinfo_t bootinfo;
-	init_components(components);
 	
 	printf("\nMemory statistics\n");
Index: ot/arch/arm32/loader/pack
===================================================================
--- boot/arch/arm32/loader/pack	(revision e19d6679169d90e6f4384eed72d6cd3992334f1d)
+++ 	(revision )
@@ -1,139 +1,0 @@
-#! /bin/sh
-
-#
-# Copyright (C) 2007 Michal Kebrt
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-
-OBJCOPY="$1"
-LINK="_link.ld"
-HEADER="_components.h"
-
-shift 1
-
-echo "OUTPUT_FORMAT(\"elf32-littlearm\")
-
-ENTRY(start)
-
-SECTIONS {
-	.boot 0x0: AT (0) {
-		*(BOOTSTRAP);
-		*(.text);
-		
-		*(.rodata);
-		*(.rodata.*);
-		*(.data);		/* initialized data */
-		*(.sdata);
-		*(.sdata2);
-		*(.sbss);
-		*(.scommon);
-		*(.bss);		/* uninitialized static variables */	
-		*(COMMON); 		/* global variables */
-		*(.reginfo);
-
-		. = 0x4000;
-		*(PT);			/* page table placed at 0x4000 */" > "$LINK"
-
-echo '
-/** @addtogroup arm32boot
- * @{
- */
-/** @file
- *  @brief Components (kernel + tasks) related declarations.
- *
- *  Generated by the <code>pack</code> script. This script packs all the
- *  components (kernel + tasks) into one image (image.boot) and generates
- *  a code that initializes an array of #component_t structs.
- */
-
-#ifndef ___COMPONENTS_H__
-#define ___COMPONENTS_H__
-
-/** Holds information about components packed to one image (kernel + tasks). */
-typedef struct {
-	/** Name. */
-	char *name;
-	/** Start address. */
-	void *start;
-	/** End address. */
-	void *end;
-	/** Size (in bytes). */
-	unsigned int size;
-} component_t;
-
-/** @}
-*/
-
-' > "$HEADER"
-
-COUNT="0"
-DATA=""
-
-for TASK in "$@" ; do
-	BASENAME="`basename "$TASK" | sed 's/^\(.*\)\.[^.]*$/\1/'`"
-	OBJECT="${BASENAME}.o"
-	SYMBOL="`echo "_binary_$TASK" | tr "./" "__"`"
-	MACRO="`echo "$BASENAME" | tr [:lower:] [:upper:]`"
-	echo "$TASK -> $OBJECT"
-	
-	echo "
-		. = ALIGN(4096);
-		*(.${BASENAME}_image);" >> "$LINK"
-	
-	echo "
-extern int ${SYMBOL}_start;
-extern int ${SYMBOL}_end;
-
-#define ${MACRO}_START ((void *) &${SYMBOL}_start)
-#define ${MACRO}_END ((void *) &${SYMBOL}_end)
-#define ${MACRO}_SIZE ((unsigned int) ${MACRO}_END - (unsigned int) ${MACRO}_START)" >> "$HEADER"
-	
-	"$OBJCOPY" -I binary -O elf32-littlearm -B arm --rename-section ".data=.${BASENAME}_image" "$TASK" "$OBJECT"
-		
-	DATA="${DATA}
-	components[$COUNT].name = \"${BASENAME}\";
-	components[$COUNT].start = ${MACRO}_START;
-	components[$COUNT].end = ${MACRO}_END;
-	components[$COUNT].size = ${MACRO}_SIZE;";
-	COUNT="`expr "$COUNT" + 1`"
-done
-
-echo '	}
-}' >> "$LINK"
-
-echo "
-#define COMPONENTS $COUNT
-
-/** Initializes array of components. */
-static void init_components(component_t components[])
-{
-$DATA
-}
-
-#endif
-
-" >> "$HEADER"
Index: boot/arch/mips32/loader/Makefile
===================================================================
--- boot/arch/mips32/loader/Makefile	(revision e19d6679169d90e6f4384eed72d6cd3992334f1d)
+++ boot/arch/mips32/loader/Makefile	(revision 136edca07dac4855f2401e71778a4078795a3216)
@@ -46,12 +46,4 @@
 ifeq ($(COMPILER),gcc_native)
 	CC = gcc
-	AS = as
-	LD = ld
-	OBJCOPY = objcopy
-	OBJDUMP = objdump
-endif
-
-ifeq ($(COMPILER),icc_native)
-	CC = icc
 	AS = as
 	LD = ld
Index: boot/arch/ppc32/loader/Makefile
===================================================================
--- boot/arch/ppc32/loader/Makefile	(revision e19d6679169d90e6f4384eed72d6cd3992334f1d)
+++ boot/arch/ppc32/loader/Makefile	(revision 136edca07dac4855f2401e71778a4078795a3216)
@@ -41,12 +41,4 @@
 ifeq ($(COMPILER),gcc_native)
 	CC = gcc
-	AS = as
-	LD = ld
-	OBJCOPY = objcopy
-	OBJDUMP = objdump
-endif
-
-ifeq ($(COMPILER),icc_native)
-	CC = icc
 	AS = as
 	LD = ld
Index: boot/arch/ppc64/loader/Makefile
===================================================================
--- boot/arch/ppc64/loader/Makefile	(revision e19d6679169d90e6f4384eed72d6cd3992334f1d)
+++ boot/arch/ppc64/loader/Makefile	(revision 136edca07dac4855f2401e71778a4078795a3216)
@@ -41,12 +41,4 @@
 ifeq ($(COMPILER),gcc_native)
 	CC = gcc
-	AS = as
-	LD = ld
-	OBJCOPY = objcopy
-	OBJDUMP = objdump
-endif
-
-ifeq ($(COMPILER),icc_native)
-	CC = icc
 	AS = as
 	LD = ld
Index: boot/arch/sparc64/loader/Makefile
===================================================================
--- boot/arch/sparc64/loader/Makefile	(revision e19d6679169d90e6f4384eed72d6cd3992334f1d)
+++ boot/arch/sparc64/loader/Makefile	(revision 136edca07dac4855f2401e71778a4078795a3216)
@@ -38,12 +38,4 @@
 ifeq ($(COMPILER),gcc_native)
 	CC = gcc
-	AS = as
-	LD = ld
-	OBJCOPY = objcopy
-	OBJDUMP = objdump
-endif
-
-ifeq ($(COMPILER),icc_native)
-	CC = icc
 	AS = as
 	LD = ld
