Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/Makefile	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -240,4 +240,5 @@
 	generic/src/lib/func.c \
 	generic/src/lib/memstr.c \
+	generic/src/lib/memfnc.c \
 	generic/src/lib/sort.c \
 	generic/src/lib/str.c \
Index: rnel/arch/abs32le/include/memstr.h
===================================================================
--- kernel/arch/abs32le/include/memstr.h	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2010 Martin Decky
- * 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.
- */
-
-/** @addtogroup abs32le
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_abs32le_MEMSTR_H_
-#define KERN_abs32le_MEMSTR_H_
-
-#define memcpy(dst, src, cnt)   _memcpy((dst), (src), (cnt))
-#define memsetb(dst, cnt, val)  _memsetb((dst), (cnt), (val))
-#define memsetw(dst, cnt, val)  _memsetw((dst), (cnt), (val))
-
-#endif
-
-/** @}
- */
Index: kernel/arch/amd64/Makefile.inc
===================================================================
--- kernel/arch/amd64/Makefile.inc	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/amd64/Makefile.inc	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -33,5 +33,22 @@
 
 FPU_NO_CFLAGS = -mno-sse -mno-sse2
-CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
+
+#
+# FIXME:
+#
+# The -fno-optimize-sibling-calls should be removed as soon as a bug
+# in GCC concerning the "large" memory model and tail call optimization
+# is fixed.
+#
+# If GCC generates a code for tail call, instead of generating ..
+#
+#   jmp *fnc
+#
+# it generates an assembly code with an illegal immediate prefix:
+#
+#   jmp *$fnc
+#
+
+CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer -fno-optimize-sibling-calls
 GCC_CFLAGS += $(CMN1)
 ICC_CFLAGS += $(CMN1)
Index: kernel/arch/amd64/_link.ld.in
===================================================================
--- kernel/arch/amd64/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/amd64/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -26,10 +26,10 @@
 	.mapped (PA2KA(BOOT_OFFSET)+SIZEOF(.unmapped)) : AT (SIZEOF(.unmapped)) {
 		ktext_start = .;
-		*(.text);
+		*(.text .text.*);
 		ktext_end = .;
 		
 		kdata_start = .;
-		*(.data);       /* initialized data */
-		*(.rodata*);    /* string literals */
+		*(.data);              /* initialized data */
+		*(.rodata .rodata.*);  /* string literals */
 		hardcoded_load_address = .;
 		QUAD(PA2KA(BOOT_OFFSET));
Index: rnel/arch/amd64/include/memstr.h
===================================================================
--- kernel/arch/amd64/include/memstr.h	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2005 Sergey Bondari
- * 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.
- */
-
-/** @addtogroup amd64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_amd64_MEMSTR_H_
-#define KERN_amd64_MEMSTR_H_
-
-#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
-
-extern void memsetw(void *, size_t, uint16_t);
-extern void memsetb(void *, size_t, uint8_t);
-
-#endif
-
-/** @}
- */
Index: kernel/arch/amd64/src/asm.S
===================================================================
--- kernel/arch/amd64/src/asm.S	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/amd64/src/asm.S	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -37,7 +37,4 @@
 .global read_efer_flag
 .global set_efer_flag
-.global memsetb
-.global memsetw
-.global memcpy
 .global memcpy_from_uspace
 .global memcpy_to_uspace
@@ -46,12 +43,4 @@
 .global early_putchar
 
-/* Wrapper for generic memsetb */
-memsetb:
-	jmp _memsetb
-
-/* Wrapper for generic memsetw */
-memsetw:
-	jmp _memsetw
-
 #define MEMCPY_DST   %rdi
 #define MEMCPY_SRC   %rsi
@@ -74,5 +63,4 @@
  *
  */
-memcpy:
 memcpy_from_uspace:
 memcpy_to_uspace:
Index: rnel/arch/arm32/include/memstr.h
===================================================================
--- kernel/arch/arm32/include/memstr.h	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2005 Sergey Bondari
- * 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.
- */
-
-/** @addtogroup arm32
- * @{
- */
-/** @file
- *  @brief Memory manipulating functions declarations.
- */
-
-#ifndef KERN_arm32_MEMSTR_H_
-#define KERN_arm32_MEMSTR_H_
-
-#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
-
-extern void memsetw(void *, size_t, uint16_t);
-extern void memsetb(void *, size_t, uint8_t);
-
-#endif
-
-/** @}
- */
Index: kernel/arch/arm32/src/asm.S
===================================================================
--- kernel/arch/arm32/src/asm.S	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/arm32/src/asm.S	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -29,7 +29,4 @@
 .text
 
-.global memsetb
-.global memsetw
-.global memcpy
 .global memcpy_from_uspace
 .global memcpy_to_uspace
@@ -38,11 +35,4 @@
 .global early_putchar
 
-memsetb:
-	b _memsetb
-
-memsetw:
-	b _memsetw
-
-memcpy:
 memcpy_from_uspace:
 memcpy_to_uspace:
Index: kernel/arch/arm32/src/exception.c
===================================================================
--- kernel/arch/arm32/src/exception.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/arm32/src/exception.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -35,5 +35,4 @@
 
 #include <arch/exception.h>
-#include <arch/memstr.h>
 #include <arch/regutils.h>
 #include <arch/machine_func.h>
Index: kernel/arch/ia32/_link.ld.in
===================================================================
--- kernel/arch/ia32/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/ia32/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -25,10 +25,10 @@
 	.mapped (PA2KA(BOOT_OFFSET)+SIZEOF(.unmapped)): AT (SIZEOF(.unmapped)) { 
 		ktext_start = .;
-		*(.text);
+		*(.text .text.*);
 		ktext_end = .;
 		
 		kdata_start = .;
 		*(.data);               /* initialized data */
-		*(.rodata*);            /* string literals */
+		*(.rodata .rodata.*);   /* string literals */
 		*(COMMON);              /* global variables */
 		hardcoded_load_address = .;
Index: rnel/arch/ia32/include/memstr.h
===================================================================
--- kernel/arch/ia32/include/memstr.h	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2005 Sergey Bondari
- * 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.
- */
-
-/** @addtogroup ia32
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_ia32_MEMSTR_H_
-#define KERN_ia32_MEMSTR_H_
-
-#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
-
-extern void memsetw(void *, size_t, uint16_t);
-extern void memsetb(void *, size_t, uint8_t);
-
-#endif
-
-/** @}
- */
Index: kernel/arch/ia32/src/asm.S
===================================================================
--- kernel/arch/ia32/src/asm.S	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/ia32/src/asm.S	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -38,7 +38,4 @@
 .global paging_on
 .global enable_l_apic_in_msr
-.global memsetb
-.global memsetw
-.global memcpy
 .global memcpy_from_uspace
 .global memcpy_from_uspace_failover_address
@@ -47,12 +44,4 @@
 .global early_putchar
 
-/* Wrapper for generic memsetb */
-memsetb:
-	jmp _memsetb
-
-/* Wrapper for generic memsetw */
-memsetw:
-	jmp _memsetw
-
 #define MEMCPY_DST   4
 #define MEMCPY_SRC   8
@@ -74,5 +63,4 @@
  *
  */
-memcpy:
 memcpy_from_uspace:
 memcpy_to_uspace:
Index: kernel/arch/ia32/src/cpu/cpu.c
===================================================================
--- kernel/arch/ia32/src/cpu/cpu.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/ia32/src/cpu/cpu.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -92,5 +92,4 @@
 void cpu_arch_init(void)
 {
-	cpuid_extended_feature_info efi;
 	cpu_info_t info;
 	uint32_t help = 0;
@@ -104,5 +103,4 @@
 	
 	CPU->arch.fi.word = info.cpuid_edx;
-	efi.word = info.cpuid_ecx;
 	
 	if (CPU->arch.fi.bits.fxsr)
Index: kernel/arch/ia64/_link.ld.in
===================================================================
--- kernel/arch/ia64/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/ia64/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -16,5 +16,5 @@
 		ktext_start = .;
 		*(K_TEXT_START);
-		*(.text)
+		*(.text .text.*)
 		ktext_end = .;
 		
@@ -36,15 +36,14 @@
 		*(.bss)
 		*(COMMON);
-
+		
 		. = ALIGN(8);
-                symbol_table = .;
-                *(symtab.*);            /* Symbol table, must be LAST symbol!*/
-
+		symbol_table = .;
+		*(symtab.*);            /* Symbol table, must be LAST symbol!*/
+		
 		kdata_end = .;
 	}
-
+	
 	/DISCARD/ : {
 		*(*);
 	}
-
 }
Index: rnel/arch/ia64/include/memstr.h
===================================================================
--- kernel/arch/ia64/include/memstr.h	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2005 Sergey Bondari
- * 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.
- */
-
-/** @addtogroup ia64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_ia64_MEMSTR_H_
-#define KERN_ia64_MEMSTR_H_
-
-#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
-
-extern void memsetw(void *, size_t, uint16_t);
-extern void memsetb(void *, size_t, uint8_t);
-
-#endif
-
-/** @}
- */
Index: kernel/arch/ia64/src/asm.S
===================================================================
--- kernel/arch/ia64/src/asm.S	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/ia64/src/asm.S	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -30,5 +30,4 @@
 
 .text
-.global memcpy
 .global memcpy_from_uspace
 .global memcpy_to_uspace
@@ -39,5 +38,6 @@
  *
  * This memcpy() has been taken from the assembler output of
- * the generic _memcpy() and modified to have the failover part.
+ * a plain C implementation of memcpy() modified to have the
+ * failover part.
  *
  * @param in0 Destination address.
@@ -46,5 +46,4 @@
  *
  */
-memcpy:
 memcpy_from_uspace:
 memcpy_to_uspace:
@@ -141,12 +140,4 @@
 	br.ret.sptk.many rp
 
-.global memsetb
-memsetb:
-	br _memsetb
-
-.global memsetw
-memsetw:
-	br _memsetw
-
 .global cpu_halt
 cpu_halt:
Index: kernel/arch/ia64/src/mm/tlb.c
===================================================================
--- kernel/arch/ia64/src/mm/tlb.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/ia64/src/mm/tlb.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -475,12 +475,8 @@
 void alternate_instruction_tlb_fault(uint64_t vector, istate_t *istate)
 {
-	region_register_t rr;
-	rid_t rid;
 	uintptr_t va;
 	pte_t *t;
 	
 	va = istate->cr_ifa; /* faulting address */
-	rr.word = rr_read(VA2VRN(va));
-	rid = rr.map.rid;
 	
 	page_table_lock(AS, true);
@@ -649,12 +645,8 @@
 void data_dirty_bit_fault(uint64_t vector, istate_t *istate)
 {
-	region_register_t rr;
-	rid_t rid;
 	uintptr_t va;
 	pte_t *t;
 	
 	va = istate->cr_ifa;  /* faulting address */
-	rr.word = rr_read(VA2VRN(va));
-	rid = rr.map.rid;
 	
 	page_table_lock(AS, true);
@@ -686,12 +678,8 @@
 void instruction_access_bit_fault(uint64_t vector, istate_t *istate)
 {
-	region_register_t rr;
-	rid_t rid;
 	uintptr_t va;
 	pte_t *t;
 	
 	va = istate->cr_ifa;  /* faulting address */
-	rr.word = rr_read(VA2VRN(va));
-	rid = rr.map.rid;
 	
 	page_table_lock(AS, true);
@@ -723,12 +711,8 @@
 void data_access_bit_fault(uint64_t vector, istate_t *istate)
 {
-	region_register_t rr;
-	rid_t rid;
 	uintptr_t va;
 	pte_t *t;
 	
 	va = istate->cr_ifa;  /* faulting address */
-	rr.word = rr_read(VA2VRN(va));
-	rid = rr.map.rid;
 	
 	page_table_lock(AS, true);
@@ -760,12 +744,8 @@
 void data_access_rights_fault(uint64_t vector, istate_t *istate)
 {
-	region_register_t rr;
-	rid_t rid;
 	uintptr_t va;
 	pte_t *t;
 	
 	va = istate->cr_ifa;  /* faulting address */
-	rr.word = rr_read(VA2VRN(va));
-	rid = rr.map.rid;
 	
 	/*
@@ -792,12 +772,8 @@
 void page_not_present(uint64_t vector, istate_t *istate)
 {
-	region_register_t rr;
-	rid_t rid;
 	uintptr_t va;
 	pte_t *t;
 	
 	va = istate->cr_ifa;  /* faulting address */
-	rr.word = rr_read(VA2VRN(va));
-	rid = rr.map.rid;
 	
 	page_table_lock(AS, true);
Index: rnel/arch/mips32/include/memstr.h
===================================================================
--- kernel/arch/mips32/include/memstr.h	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2005 Sergey Bondari
- * 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.
- */
-
-/** @addtogroup mips32
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips32_MEMSTR_H_
-#define KERN_mips32_MEMSTR_H_
-
-#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
-
-extern void memsetw(void *, size_t, uint16_t);
-extern void memsetb(void *, size_t, uint8_t);
-
-#endif
-
-/** @}
- */
Index: kernel/arch/mips32/src/asm.S
===================================================================
--- kernel/arch/mips32/src/asm.S	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/mips32/src/asm.S	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -57,20 +57,8 @@
 	nop
 
-.global memsetb
-memsetb:
-	j _memsetb
-	nop
-
-.global memsetw
-memsetw:
-	j _memsetw
-	nop
-
-.global memcpy
 .global memcpy_from_uspace
 .global memcpy_to_uspace
 .global memcpy_from_uspace_failover_address
 .global memcpy_to_uspace_failover_address
-memcpy:
 memcpy_from_uspace:
 memcpy_to_uspace:
Index: kernel/arch/ppc32/_link.ld.in
===================================================================
--- kernel/arch/ppc32/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/ppc32/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -36,6 +36,5 @@
 		kdata_start = .;
 		*(K_DATA_START);
-		*(.rodata);
-		*(.rodata.*);
+		*(.rodata .rodata.*);
 		*(.data);       /* initialized data */
 		*(.sdata);
Index: rnel/arch/ppc32/include/memstr.h
===================================================================
--- kernel/arch/ppc32/include/memstr.h	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2005 Sergey Bondari
- * 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.
- */
-
-/** @addtogroup ppc32
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_ppc32_MEMSTR_H_
-#define KERN_ppc32_MEMSTR_H_
-
-#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
-
-extern void memsetw(void *, size_t, uint16_t);
-extern void memsetb(void *, size_t, uint8_t);
-
-#endif
-
-/** @}
- */
Index: kernel/arch/ppc32/src/asm.S
===================================================================
--- kernel/arch/ppc32/src/asm.S	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/ppc32/src/asm.S	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -35,7 +35,4 @@
 .global iret
 .global iret_syscall
-.global memsetb
-.global memsetw
-.global memcpy
 .global memcpy_from_uspace
 .global memcpy_to_uspace
@@ -208,11 +205,4 @@
 	rfi
 
-memsetb:
-	b _memsetb
-
-memsetw:
-	b _memsetw
-
-memcpy:
 memcpy_from_uspace:
 memcpy_to_uspace:
Index: kernel/arch/sparc64/_link.ld.in
===================================================================
--- kernel/arch/sparc64/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/sparc64/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -15,11 +15,10 @@
 		ktext_start = .;
 		*(K_TEXT_START)
-		*(.text);
+		*(.text .text.*);
 		ktext_end = .;
 		
 		kdata_start = .;
 		*(K_DATA_START)
-		*(.rodata);
-		*(.rodata.*);
+		*(.rodata .rodata.*);
 		*(.data);                   /* initialized data */
 		*(.sdata);
Index: rnel/arch/sparc64/include/memstr.h
===================================================================
--- kernel/arch/sparc64/include/memstr.h	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2005 Sergey Bondari
- * 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.
- */
-
-/** @addtogroup sparc64
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_sparc64_MEMSTR_H_
-#define KERN_sparc64_MEMSTR_H_
-
-#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
-
-extern void memsetw(void *, size_t, uint16_t);
-extern void memsetb(void *, size_t, uint8_t);
-
-#endif
-
-/** @}
- */
Index: kernel/arch/sparc64/src/asm.S
===================================================================
--- kernel/arch/sparc64/src/asm.S	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/sparc64/src/asm.S	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -34,78 +34,4 @@
 .register %g2, #scratch
 .register %g3, #scratch
-
-/*
- * This is the assembly language version of our _memcpy() generated by gcc.
- */
-.global memcpy
-memcpy:
-	mov %o0, %o3  /* save dst */
-	add %o1, 7, %g1
-	and %g1, -8, %g1
-	cmp %o1, %g1
-	be,pn %xcc, 3f
-	add %o0, 7, %g1
-	mov 0, %g3
-	
-	0:
-	
-		brz,pn %o2, 2f
-		mov 0, %g2
-	
-	1:
-	
-		ldub [%g3 + %o1], %g1
-		add %g2, 1, %g2
-		cmp %o2, %g2
-		stb %g1, [%g3 + %o0]
-		bne,pt %xcc, 1b
-		mov %g2, %g3
-	
-	2:
-	
-		jmp %o7 + 8  /* exit point */
-		mov %o3, %o0
-	
-	3:
-	
-		and %g1, -8, %g1
-		cmp %o0, %g1
-		bne,pt %xcc, 0b
-		mov 0, %g3
-		srlx %o2, 3, %g4
-		brz,pn %g4, 5f
-		mov 0, %g5
-	
-	4:
-	
-		sllx %g3, 3, %g2
-		add %g5, 1, %g3
-		ldx [%o1 + %g2], %g1
-		mov %g3, %g5
-		cmp %g4, %g3
-		bne,pt %xcc, 4b
-		stx %g1, [%o0 + %g2]
-	
-	5:
-	
-		and %o2, 7, %o2
-		brz,pn %o2, 2b
-		sllx %g4, 3, %g1
-		mov 0, %g2
-		add %g1, %o0, %o0
-		add %g1, %o1, %g4
-		mov 0, %g3
-	
-	6:
-	
-		ldub [%g2 + %g4], %g1
-		stb %g1, [%g2 + %o0]
-		add %g3, 1, %g2
-		cmp %o2, %g2
-		bne,pt %xcc, 6b
-		mov %g2, %g3
-		
-		jmp %o7 + 8  /* exit point */
-		mov %o3, %o0
 
 /*
@@ -264,14 +190,4 @@
 	mov %g0, %o0  /* return 0 on failure */
 
-.global memsetb
-memsetb:
-	ba %xcc, _memsetb
-	nop
-
-.global memsetw
-memsetw:
-	ba %xcc, _memsetw
-	nop
-
 .global early_putchar
 early_putchar:
Index: kernel/arch/sparc64/src/mm/sun4u/as.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4u/as.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/sparc64/src/mm/sun4u/as.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -43,5 +43,4 @@
 
 #include <arch/mm/tsb.h>
-#include <arch/memstr.h>
 #include <arch/asm.h>
 #include <mm/frame.h>
Index: kernel/arch/sparc64/src/mm/sun4v/as.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4v/as.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/arch/sparc64/src/mm/sun4v/as.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -46,5 +46,4 @@
 
 #include <arch/mm/tsb.h>
-#include <arch/memstr.h>
 #include <arch/asm.h>
 #include <mm/frame.h>
Index: kernel/genarch/src/drivers/via-cuda/cuda.c
===================================================================
--- kernel/genarch/src/drivers/via-cuda/cuda.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/genarch/src/drivers/via-cuda/cuda.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -239,9 +239,9 @@
 	cuda_instance_t *instance = irq->instance;
 	cuda_t *dev = instance->cuda;
-	uint8_t data, b;
-
+	uint8_t b;
+	
 	b = pio_read_8(&dev->b);
-	data = pio_read_8(&dev->sr);
-
+	pio_read_8(&dev->sr);
+	
 	if ((b & TREQ) == 0) {
 		instance->xstate = cx_receive;
@@ -251,7 +251,7 @@
 		cuda_send_start(instance);
 	}
-
-        memcpy(buf, instance->rcv_buf, instance->bidx);
-        *len = instance->bidx;
+	
+	memcpy(buf, instance->rcv_buf, instance->bidx);
+	*len = instance->bidx;
 	instance->bidx = 0;
 }
Index: kernel/genarch/src/ofw/ebus.c
===================================================================
--- kernel/genarch/src/ofw/ebus.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/genarch/src/ofw/ebus.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -39,5 +39,4 @@
 #include <genarch/ofw/ebus.h>
 #include <genarch/ofw/pci.h>
-#include <arch/memstr.h>
 #include <str.h>
 #include <panic.h>
Index: kernel/genarch/src/ofw/fhc.c
===================================================================
--- kernel/genarch/src/ofw/fhc.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/genarch/src/ofw/fhc.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -39,5 +39,4 @@
 #include <genarch/ofw/fhc.h>
 #include <arch/drivers/fhc.h>
-#include <arch/memstr.h>
 #include <str.h>
 #include <panic.h>
Index: kernel/genarch/src/ofw/ofw_tree.c
===================================================================
--- kernel/genarch/src/ofw/ofw_tree.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/genarch/src/ofw/ofw_tree.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -37,6 +37,6 @@
 
 #include <genarch/ofw/ofw_tree.h>
-#include <arch/memstr.h>
 #include <mm/slab.h>
+#include <memstr.h>
 #include <str.h>
 #include <panic.h>
Index: kernel/genarch/src/ofw/pci.c
===================================================================
--- kernel/genarch/src/ofw/pci.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/genarch/src/ofw/pci.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -40,5 +40,4 @@
 #include <arch/drivers/pci.h>
 #include <arch/trap/interrupt.h>
-#include <arch/memstr.h>
 #include <str.h>
 #include <panic.h>
Index: kernel/genarch/src/ofw/upa.c
===================================================================
--- kernel/genarch/src/ofw/upa.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/genarch/src/ofw/upa.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -38,5 +38,4 @@
 #include <genarch/ofw/ofw_tree.h>
 #include <genarch/ofw/upa.h>
-#include <arch/memstr.h>
 #include <func.h>
 #include <panic.h>
Index: kernel/generic/include/lib/memfnc.h
===================================================================
--- kernel/generic/include/lib/memfnc.h	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
+++ kernel/generic/include/lib/memfnc.h	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * 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.
+ */
+
+/** @addtogroup generic
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_LIB_MEMFNC_H_
+#define KERN_LIB_MEMFNC_H_
+
+#include <typedefs.h>
+
+extern void *memset(void *, int, size_t);
+extern void *memcpy(void *, const void *, size_t);
+
+#endif
+
+/** @}
+ */
Index: kernel/generic/include/memstr.h
===================================================================
--- kernel/generic/include/memstr.h	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/generic/include/memstr.h	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -37,13 +37,11 @@
 
 #include <typedefs.h>
-#include <arch/memstr.h>
 
-/*
- * Architecture independent variants.
- */
-extern void *_memcpy(void *dst, const void *src, size_t cnt);
-extern void _memsetb(void *dst, size_t cnt, uint8_t x);
-extern void _memsetw(void *dst, size_t cnt, uint16_t x);
-extern void *memmove(void *dst, const void *src, size_t cnt);
+#define memset(dst, val, cnt)  __builtin_memset((dst), (val), (cnt))
+#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
+
+extern void memsetb(void *, size_t, uint8_t);
+extern void memsetw(void *, size_t, uint16_t);
+extern void *memmove(void *, const void *, size_t);
 
 #endif
Index: kernel/generic/src/lib/memfnc.c
===================================================================
--- kernel/generic/src/lib/memfnc.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
+++ kernel/generic/src/lib/memfnc.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -0,0 +1,91 @@
+	/*
+ * Copyright (c) 2011 Martin Decky
+ * 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.
+ */
+
+/** @addtogroup generic
+ * @{
+ */
+
+/**
+ * @file
+ * @brief Memory string functions.
+ *
+ * This file provides architecture independent functions to manipulate blocks
+ * of memory. These functions are optimized as much as generic functions of
+ * this type can be.
+ */
+
+#include <lib/memfnc.h>
+#include <typedefs.h>
+
+/** Fill block of memory.
+ *
+ * Fill cnt bytes at dst address with the value val.
+ *
+ * @param dst Destination address to fill.
+ * @param val Value to fill.
+ * @param cnt Number of bytes to fill.
+ *
+ * @return Destination address.
+ *
+ */
+void *memset(void *dst, int val, size_t cnt)
+{
+	size_t i;
+	uint8_t *ptr = (uint8_t *) dst;
+	
+	for (i = 0; i < cnt; i++)
+		ptr[i] = val;
+	
+	return dst;
+}
+
+/** Move memory block without overlapping.
+ *
+ * Copy cnt bytes from src address to dst address. The source
+ * and destination memory areas cannot overlap.
+ *
+ * @param dst Destination address to copy to.
+ * @param src Source address to copy from.
+ * @param cnt Number of bytes to copy.
+ *
+ * @return Destination address.
+ *
+ */
+void *memcpy(void *dst, const void *src, size_t cnt)
+{
+	uint8_t *dp = (uint8_t *) dst;
+	const uint8_t *sp = (uint8_t *) src;
+	
+	while (cnt-- != 0)
+			*dp++ = *sp++;
+	
+	return dst;
+}
+
+/** @}
+ */
Index: kernel/generic/src/lib/memstr.c
===================================================================
--- kernel/generic/src/lib/memstr.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/generic/src/lib/memstr.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -28,5 +28,5 @@
  */
 
-/** @addtogroup generic	
+/** @addtogroup generic
  * @{
  */
@@ -34,129 +34,90 @@
 /**
  * @file
- * @brief	Memory string operations.
+ * @brief Memory string operations.
  *
- * This file provides architecture independent functions to manipulate blocks of
- * memory. These functions are optimized as much as generic functions of this
- * type can be. However, architectures are free to provide even more optimized
- * versions of these functions.
+ * This file provides architecture independent functions to manipulate blocks
+ * of memory. These functions are optimized as much as generic functions of
+ * this type can be.
  */
 
 #include <memstr.h>
 #include <typedefs.h>
-#include <align.h>
 
-/** Copy block of memory.
+/** Fill block of memory.
  *
- * Copy cnt bytes from src address to dst address.  The copying is done
- * word-by-word and then byte-by-byte.  The source and destination memory areas
- * cannot overlap.
+ * Fill cnt bytes at dst address with the value val.
  *
- * @param src		Source address to copy from.
- * @param dst		Destination address to copy to.
- * @param cnt		Number of bytes to copy.
+ * @param dst Destination address to fill.
+ * @param cnt Number of bytes to fill.
+ * @param val Value to fill.
  *
- * @return		Destination address.
  */
-void *_memcpy(void *dst, const void *src, size_t cnt)
+void memsetb(void *dst, size_t cnt, uint8_t val)
 {
-	unsigned int i, j;
+	memset(dst, val, cnt);
+}
+
+/** Fill block of memory.
+ *
+ * Fill cnt words at dst address with the value val. The filling
+ * is done word-by-word.
+ *
+ * @param dst Destination address to fill.
+ * @param cnt Number of words to fill.
+ * @param val Value to fill.
+ *
+ */
+void memsetw(void *dst, size_t cnt, uint16_t val)
+{
+	size_t i;
+	uint16_t *ptr = (uint16_t *) dst;
 	
-	if (ALIGN_UP((uintptr_t) src, sizeof(sysarg_t)) != (uintptr_t) src ||
-	    ALIGN_UP((uintptr_t) dst, sizeof(sysarg_t)) != (uintptr_t) dst) {
-		for (i = 0; i < cnt; i++)
-			((uint8_t *) dst)[i] = ((uint8_t *) src)[i];
-	} else { 
-		for (i = 0; i < cnt / sizeof(sysarg_t); i++)
-			((sysarg_t *) dst)[i] = ((sysarg_t *) src)[i];
-		
-		for (j = 0; j < cnt % sizeof(sysarg_t); j++)
-			((uint8_t *)(((sysarg_t *) dst) + i))[j] =
-			    ((uint8_t *)(((sysarg_t *) src) + i))[j];
-	}
-		
-	return (char *) dst;
+	for (i = 0; i < cnt; i++)
+		ptr[i] = val;
 }
 
 /** Move memory block with possible overlapping.
  *
- * Copy cnt bytes from src address to dst address. The source and destination
- * memory areas may overlap.
+ * Copy cnt bytes from src address to dst address. The source
+ * and destination memory areas may overlap.
  *
- * @param src		Source address to copy from.
- * @param dst		Destination address to copy to.
- * @param cnt		Number of bytes to copy.
+ * @param dst Destination address to copy to.
+ * @param src Source address to copy from.
+ * @param cnt Number of bytes to copy.
  *
- * @return		Destination address.
+ * @return Destination address.
+ *
  */
-void *memmove(void *dst, const void *src, size_t n)
+void *memmove(void *dst, const void *src, size_t cnt)
 {
-	const uint8_t *sp;
-	uint8_t *dp;
-
 	/* Nothing to do? */
 	if (src == dst)
 		return dst;
-
+	
 	/* Non-overlapping? */
-	if (dst >= src + n || src >= dst + n) {	
-		return memcpy(dst, src, n);
-	}
-
+	if ((dst >= src + cnt) || (src >= dst + cnt))
+		return memcpy(dst, src, cnt);
+	
+	uint8_t *dp;
+	const uint8_t *sp;
+	
 	/* Which direction? */
 	if (src > dst) {
 		/* Forwards. */
+		dp = dst;
 		sp = src;
-		dp = dst;
-
-		while (n-- != 0)
+		
+		while (cnt-- != 0)
 			*dp++ = *sp++;
 	} else {
 		/* Backwards. */
-		sp = src + (n - 1);
-		dp = dst + (n - 1);
-
-		while (n-- != 0)
+		dp = dst + (cnt - 1);
+		sp = src + (cnt - 1);
+		
+		while (cnt-- != 0)
 			*dp-- = *sp--;
 	}
-
+	
 	return dst;
-}
-
-/** Fill block of memory
- *
- * Fill cnt bytes at dst address with the value x.  The filling is done
- * byte-by-byte.
- *
- * @param dst		Destination address to fill.
- * @param cnt		Number of bytes to fill.
- * @param x		Value to fill.
- *
- */
-void _memsetb(void *dst, size_t cnt, uint8_t x)
-{
-	unsigned int i;
-	uint8_t *p = (uint8_t *) dst;
-	
-	for (i = 0; i < cnt; i++)
-		p[i] = x;
-}
-
-/** Fill block of memory.
- *
- * Fill cnt words at dst address with the value x.  The filling is done
- * word-by-word.
- *
- * @param dst		Destination address to fill.
- * @param cnt		Number of words to fill.
- * @param x		Value to fill.
- *
- */
-void _memsetw(void *dst, size_t cnt, uint16_t x)
-{
-	unsigned int i;
-	uint16_t *p = (uint16_t *) dst;
-	
-	for (i = 0; i < cnt; i++)
-		p[i] = x;	
 }
 
Index: kernel/generic/src/mm/backend_elf.c
===================================================================
--- kernel/generic/src/mm/backend_elf.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ kernel/generic/src/mm/backend_elf.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -91,7 +91,11 @@
 	if (!as_area_check_access(area, access))
 		return AS_PF_FAULT;
-
-	ASSERT((addr >= ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) &&
-	    (addr < entry->p_vaddr + entry->p_memsz));
+	
+	if (addr < ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE))
+		return AS_PF_FAULT;
+	
+	if (addr >= entry->p_vaddr + entry->p_memsz)
+		return AS_PF_FAULT;
+	
 	i = (addr - ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) >> PAGE_WIDTH;
 	base = (uintptr_t)
Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ tools/autotool.py	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -501,5 +501,5 @@
 		cross_prefix = os.environ['CROSS_PREFIX']
 	else:
-		cross_prefix = "/usr/local"
+		cross_prefix = "/usr/local/cross"
 	
 	# Prefix binutils tools on Solaris
Index: tools/toolchain.sh
===================================================================
--- tools/toolchain.sh	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ tools/toolchain.sh	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -52,4 +52,13 @@
 #endif
 EOF
+
+BINUTILS_VERSION="2.21"
+GCC_VERSION="4.6.0"
+
+BASEDIR="`pwd`"
+BINUTILS="binutils-${BINUTILS_VERSION}.tar.bz2"
+GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
+GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
+GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
 
 #
@@ -139,8 +148,9 @@
 	echo " sparc64    SPARC V9"
 	echo " all        build all targets"
+	echo " parallel   same as 'all', but in parallel"
 	echo
 	echo "The toolchain will be installed to the directory specified by"
 	echo "the CROSS_PREFIX environment variable. If the variable is not"
-	echo "defined, /usr/local will be used by default."
+	echo "defined, /usr/local/cross will be used by default."
 	echo
 	
@@ -194,5 +204,5 @@
 }
 
-download_check() {
+download_fetch() {
 	SOURCE="$1"
 	FILE="$2"
@@ -208,4 +218,15 @@
 }
 
+source_check() {
+	FILE="$1"
+	
+	if [ ! -f "${FILE}" ]; then
+		echo
+		echo "File ${FILE} not found."
+		
+		exit 4
+	fi
+}
+
 cleanup_dir() {
 	DIR="$1"
@@ -241,25 +262,16 @@
 }
 
-patch_binutils() {
-	PLATFORM="$1"
-	
-	if [ "${PLATFORM}" == "arm32" ] ; then
-		patch -p1 <<EOF
-diff -Naur binutils-2.20.orig/gas/config/tc-arm.c binutils-2.20/gas/config/tc-arm.c
---- binutils-2.20.orig/gas/config/tc-arm.c	2009-08-30 00:10:59.000000000 +0200
-+++ binutils-2.20/gas/config/tc-arm.c	2009-11-02 14:25:11.000000000 +0100
-@@ -2485,8 +2485,9 @@
-       know (frag->tc_frag_data.first_map == NULL);
-       frag->tc_frag_data.first_map = symbolP;
-     }
--  if (frag->tc_frag_data.last_map != NULL)
-+  if (frag->tc_frag_data.last_map != NULL) {
-     know (S_GET_VALUE (frag->tc_frag_data.last_map) < S_GET_VALUE (symbolP));
-+  }
-   frag->tc_frag_data.last_map = symbolP;
- }
-EOF
-		check_error $? "Error patching binutils"
-	fi
+prepare() {
+	show_dependencies
+	check_dependecies
+	show_countdown 10
+	
+	BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
+	GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
+	
+	download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "c84c5acc9d266f1a7044b51c85a823f5"
+	download_fetch "${GCC_SOURCE}" "${GCC_CORE}" "b1957f3209080b2f55bc3756d3a62b7c"
+	download_fetch "${GCC_SOURCE}" "${GCC_OBJC}" "120d4675366ee82ea52f9ed65b57da04"
+	download_fetch "${GCC_SOURCE}" "${GCC_CPP}" "a30090fa655d0db4c970740d353c81f1"
 }
 
@@ -268,16 +280,5 @@
 	TARGET="$2"
 	
-	BINUTILS_VERSION="2.20"
-	GCC_VERSION="4.5.1"
-	
-	BINUTILS="binutils-${BINUTILS_VERSION}.tar.bz2"
-	GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
-	GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
-	GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
-	
-	BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
-	GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
-	
-	WORKDIR="`pwd`"
+	WORKDIR="${BASEDIR}/${PLATFORM}"
 	BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
 	GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
@@ -285,5 +286,5 @@
 	
 	if [ -z "${CROSS_PREFIX}" ] ; then
-		CROSS_PREFIX="/usr/local"
+		CROSS_PREFIX="/usr/local/cross"
 	fi
 	
@@ -291,14 +292,12 @@
 	
 	echo ">>> Downloading tarballs"
-	download_check "${BINUTILS_SOURCE}" "${BINUTILS}" "ee2d3e996e9a2d669808713360fa96f8"
-	download_check "${GCC_SOURCE}" "${GCC_CORE}" "dc8959e31b01a65ce10d269614815054"
-	download_check "${GCC_SOURCE}" "${GCC_OBJC}" "3c11b7037896e967eddf8178af2ddd98"
-	download_check "${GCC_SOURCE}" "${GCC_CPP}" "b294953ff0bb2f20c7acb2bf005d832a"
+	source_check "${BASEDIR}/${BINUTILS}"
+	source_check "${BASEDIR}/${GCC_CORE}"
+	source_check "${BASEDIR}/${GCC_OBJC}"
+	source_check "${BASEDIR}/${GCC_CPP}"
 	
 	echo ">>> Removing previous content"
 	cleanup_dir "${PREFIX}"
-	cleanup_dir "${OBJDIR}"
-	cleanup_dir "${BINUTILSDIR}"
-	cleanup_dir "${GCCDIR}"
+	cleanup_dir "${WORKDIR}"
 	
 	create_dir "${PREFIX}" "destination directory"
@@ -306,13 +305,15 @@
 	
 	echo ">>> Unpacking tarballs"
-	unpack_tarball "${BINUTILS}" "binutils"
-	unpack_tarball "${GCC_CORE}" "GCC Core"
-	unpack_tarball "${GCC_OBJC}" "Objective C"
-	unpack_tarball "${GCC_CPP}" "C++"
+	cd "${WORKDIR}"
+	check_error $? "Change directory failed."
+	
+	unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils"
+	unpack_tarball "${BASEDIR}/${GCC_CORE}" "GCC Core"
+	unpack_tarball "${BASEDIR}/${GCC_OBJC}" "Objective C"
+	unpack_tarball "${BASEDIR}/${GCC_CPP}" "C++"
 	
 	echo ">>> Processing binutils (${PLATFORM})"
 	cd "${BINUTILSDIR}"
 	check_error $? "Change directory failed."
-	patch_binutils "${PLATFORM}"
 	
 	change_title "binutils: configure (${PLATFORM})"
@@ -336,11 +337,9 @@
 	check_error $? "Error compiling/installing GCC."
 	
-	cd "${WORKDIR}"
+	cd "${BASEDIR}"
 	check_error $? "Change directory failed."
 	
 	echo ">>> Cleaning up"
-	cleanup_dir "${OBJDIR}"
-	cleanup_dir "${BINUTILSDIR}"
-	cleanup_dir "${GCCDIR}"
+	cleanup_dir "${WORKDIR}"
 	
 	echo
@@ -352,47 +351,50 @@
 fi
 
-show_dependencies
-check_dependecies
-show_countdown 10
-
 case "$1" in
 	"amd64")
+		prepare
 		build_target "amd64" "amd64-linux-gnu"
 		;;
 	"arm32")
+		prepare
 		build_target "arm32" "arm-linux-gnu"
 		;;
 	"ia32")
+		prepare
 		build_target "ia32" "i686-pc-linux-gnu"
 		;;
 	"ia64")
+		prepare
 		build_target "ia64" "ia64-pc-linux-gnu"
 		;;
-	"ia64")
-		build_target "ia64" "ia64-pc-linux-gnu"
-		;;
 	"mips32")
+		prepare
 		build_target "mips32" "mipsel-linux-gnu"
 		;;
 	"mips32eb")
+		prepare
 		build_target "mips32eb" "mips-linux-gnu"
 		;;
 	"mips64")
+		prepare
 		build_target "mips64" "mips64el-linux-gnu"
 		;;
 	"ppc32")
+		prepare
 		build_target "ppc32" "ppc-linux-gnu"
 		;;
 	"ppc64")
+		prepare
 		build_target "ppc64" "ppc64-linux-gnu"
 		;;
 	"sparc64")
+		prepare
 		build_target "sparc64" "sparc64-linux-gnu"
 		;;
 	"all")
+		prepare
 		build_target "amd64" "amd64-linux-gnu"
 		build_target "arm32" "arm-linux-gnu"
 		build_target "ia32" "i686-pc-linux-gnu"
-		build_target "ia64" "ia64-pc-linux-gnu"
 		build_target "ia64" "ia64-pc-linux-gnu"
 		build_target "mips32" "mipsel-linux-gnu"
@@ -403,4 +405,18 @@
 		build_target "sparc64" "sparc64-linux-gnu"
 		;;
+	"parallel")
+		prepare
+		build_target "amd64" "amd64-linux-gnu" &
+		build_target "arm32" "arm-linux-gnu" &
+		build_target "ia32" "i686-pc-linux-gnu" &
+		build_target "ia64" "ia64-pc-linux-gnu" &
+		build_target "mips32" "mipsel-linux-gnu" &
+		build_target "mips32eb" "mips-linux-gnu" &
+		build_target "mips64" "mips64el-linux-gnu" &
+		build_target "ppc32" "ppc-linux-gnu" &
+		build_target "ppc64" "ppc64-linux-gnu" &
+		build_target "sparc64" "sparc64-linux-gnu" &
+		wait
+		;;
 	*)
 		show_usage
Index: uspace/app/bdsh/cmds/modules/cat/cat.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cat/cat.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/app/bdsh/cmds/modules/cat/cat.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -164,5 +164,4 @@
 {
 	int fd, bytes = 0, count = 0, reads = 0;
-	off64_t total = 0;
 	char *buff = NULL;
 	int i;
@@ -174,7 +173,4 @@
 		return 1;
 	}
-
-	total = lseek(fd, 0, SEEK_END);
-	lseek(fd, 0, SEEK_SET);
 
 	if (NULL == (buff = (char *) malloc(blen + 1))) {
Index: uspace/app/sbi/src/run_expr.c
===================================================================
--- uspace/app/sbi/src/run_expr.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/app/sbi/src/run_expr.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -2529,4 +2529,6 @@
 	if (rc1 == EOK)
 		rc2 = os_str_get_char(string->value, elem_index, &cval);
+	else
+		rc2 = EOK;
 
 	if (rc1 != EOK || rc2 != EOK) {
Index: uspace/app/tester/fault/fault2.c
===================================================================
--- uspace/app/tester/fault/fault2.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/app/tester/fault/fault2.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -29,4 +29,5 @@
 
 #include "../tester.h"
+#include <stdio.h>
 
 typedef int __attribute__((may_alias)) aliasing_int;
@@ -38,4 +39,5 @@
 	
 	var1 = *((aliasing_int *) (((char *) (&var)) + 1));
+	printf("Read %d\n", var1);
 	
 	return "Survived unaligned read";
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/app/trace/trace.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -872,5 +872,5 @@
 static display_mask_t parse_display_mask(const char *text)
 {
-	display_mask_t dm;
+	display_mask_t dm = 0;
 	const char *c = text;
 	
Index: uspace/lib/c/arch/abs32le/_link.ld.in
===================================================================
--- uspace/lib/c/arch/abs32le/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/lib/c/arch/abs32le/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -11,6 +11,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/amd64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/amd64/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/lib/c/arch/amd64/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -16,6 +16,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/arm32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/arm32/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/lib/c/arch/arm32/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -15,6 +15,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/ia32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ia32/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/lib/c/arch/ia32/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -16,6 +16,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/ia64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ia64/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/lib/c/arch/ia64/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -15,6 +15,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
@@ -23,5 +23,5 @@
 	.got : {
 		_gp = .;
-		*(.got*);
+		*(.got .got.*);
 	} :data
 	
Index: uspace/lib/c/arch/mips32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/mips32/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/lib/c/arch/mips32/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -15,6 +15,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/ppc32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ppc32/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/lib/c/arch/ppc32/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -15,6 +15,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/sparc64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/sparc64/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/lib/c/arch/sparc64/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -15,6 +15,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -756,8 +756,9 @@
 {
 	struct stat stat;
-	int rc;
-
-	rc = fstat(fildes, &stat);
-
+	
+	int rc = fstat(fildes, &stat);
+	if (rc != 0)
+		return rc;
+	
 	if (!stat.device)
 		return -1;
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.c
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -367,9 +367,9 @@
 static void cuda_irq_rcv_end(void *buf, size_t *len)
 {
-	uint8_t data, b;
-
+	uint8_t b;
+	
 	b = pio_read_8(&dev->b);
-	data = pio_read_8(&dev->sr);
-
+	pio_read_8(&dev->sr);
+	
 	if ((b & TREQ) == 0) {
 		instance->xstate = cx_receive;
@@ -379,7 +379,7 @@
 		cuda_send_start();
 	}
-
-        memcpy(buf, instance->rcv_buf, instance->bidx);
-        *len = instance->bidx;
+	
+	memcpy(buf, instance->rcv_buf, instance->bidx);
+	*len = instance->bidx;
 	instance->bidx = 0;
 }
Index: uspace/srv/hw/netif/ne2000/dp8390.c
===================================================================
--- uspace/srv/hw/netif/ne2000/dp8390.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/hw/netif/ne2000/dp8390.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -391,4 +391,5 @@
 	
 	if ((size < ETH_MIN_PACK_SIZE) || (size > ETH_MAX_PACK_SIZE_TAGGED)) {
+		fibril_mutex_unlock(&ne2k->sq_mutex);
 		fprintf(stderr, "%s: Frame dropped (invalid size %zu bytes)\n",
 		    NAME, size);
Index: uspace/srv/loader/arch/abs32le/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/abs32le/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/loader/arch/abs32le/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -21,6 +21,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/amd64/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/amd64/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/loader/arch/amd64/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -27,6 +27,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/arm32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/arm32/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/loader/arch/arm32/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -25,6 +25,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/ia32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/ia32/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/loader/arch/ia32/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -26,6 +26,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/ia64/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/ia64/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/loader/arch/ia64/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -21,6 +21,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
@@ -29,5 +29,5 @@
 	.got : {
 		_gp = .;
-		*(.got*);
+		*(.got .got.*);
 	} :data
 	
Index: uspace/srv/loader/arch/mips32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/mips32/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/loader/arch/mips32/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -25,6 +25,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/ppc32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/ppc32/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/loader/arch/ppc32/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -25,6 +25,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/sparc64/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/sparc64/_link.ld.in	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/loader/arch/sparc64/_link.ld.in	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -20,6 +20,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision e3a3e3adeedece840514d46619ebed5cb3be75fc)
+++ uspace/srv/loader/main.c	(revision beb6b3d6e20326397f9e424ddf9e80a5793ba573)
@@ -407,12 +407,10 @@
 			/* Not reached */
 		default:
-			retval = ENOENT;
+			retval = EINVAL;
 			break;
 		}
-		if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP) {
-			DPRINTF("Responding EINVAL to method %d.\n",
-			    IPC_GET_IMETHOD(call));
-			async_answer_0(callid, EINVAL);
-		}
+		
+		if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP)
+			async_answer_0(callid, retval);
 	}
 }
