add support for the AVR32 platform, namely the ATNGW100 board - joint work with wigyori

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7533 3c298f89-4303-0410-b956-a3cf2f4a3e73
master
Imre Kaloz 2007-06-08 10:44:01 +00:00
parent d442289f60
commit 15a51103e8
38 changed files with 136282 additions and 1 deletions

View File

@ -21,6 +21,9 @@ endif
ifneq (,$(findstring ppc,$(BOARD)))
KERNELNAME="uImage"
endif
ifneq (,$(findstring avr32,$(BOARD)))
KERNELNAME="uImage"
endif
KERNEL_MAKEOPTS := -C $(LINUX_DIR) \
CROSS_COMPILE="$(KERNEL_CROSS)" \

View File

@ -0,0 +1,31 @@
#!/bin/sh
ac_cv_c_littleendian=${ac_cv_c_littleendian=no}
ac_cv_c_bigendian=${ac_cv_c_bigendian=yes}
ac_cv_sizeof___int64=0
ac_cv_sizeof_char=1
ac_cv_sizeof_int=4
ac_cv_sizeof_int16_t=2
ac_cv_sizeof_int32_t=4
ac_cv_sizeof_int64_t=8
ac_cv_sizeof_long_int=4
ac_cv_sizeof_long_long=8
ac_cv_sizeof_long=4
ac_cv_sizeof_off_t=8
ac_cv_sizeof_short_int=2
ac_cv_sizeof_short=2
ac_cv_sizeof_size_t=4
ac_cv_sizeof_u_int16_t=2
ac_cv_sizeof_u_int32_t=4
ac_cv_sizeof_u_int64_t=8
ac_cv_sizeof_uint16_t=2
ac_cv_sizeof_uint32_t=4
ac_cv_sizeof_uint64_t=8
ac_cv_sizeof_unsigned_int=4
ac_cv_sizeof_unsigned_long=4
ac_cv_sizeof_unsigned_short=2
ac_cv_sizeof_void_p=4
. $TOPDIR/include/site/linux-uclibc

View File

@ -72,6 +72,7 @@ endef
define Package/libgcc
$(call Package/gcc/Default)
TITLE:=GCC support library
DEPENDS:=@!LINUX_2_6_AVR32
endef
define Package/libssp

View File

@ -57,6 +57,10 @@ config armeb
select BIG_ENDIAN
bool
config avr32
select BIG_ENDIAN
bool
config cris
bool
@ -92,6 +96,7 @@ config ARCH
string
default "arm" if arm
default "armeb" if armeb
default "avr32" if avr32
default "cris" if cris
default "i386" if i386
default "m68k" if m68k

View File

@ -0,0 +1,25 @@
#
# Copyright (C) 2007 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
ARCH:=avr32
BOARD:=avr32
BOARDNAME:=Atmel AVR32
FEATURES:=squashfs
define Target/Description
Build firmware images for ATNGW100 board
endef
KERNEL:=2.6
include $(INCLUDE_DIR)/kernel-build.mk
#include the profiles
-include profiles/*.mk
$(eval $(call BuildKernel))

View File

@ -0,0 +1,85 @@
CONFIG_AP7000_16_BIT_SMC=y
# CONFIG_AP7000_32_BIT_SMC is not set
# CONFIG_AP7000_8_BIT_SMC is not set
# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
CONFIG_AVR32=y
CONFIG_BOARD_ATNGW100=y
# CONFIG_BOARD_ATSTK1000 is not set
CONFIG_CPU_AT32AP7000=y
CONFIG_DW_DMAC=y
CONFIG_ENTRY_ADDRESS=0x90000000
# CONFIG_GEN_RTC is not set
# CONFIG_HZ_100 is not set
CONFIG_HZ=250
CONFIG_HZ_250=y
# CONFIG_HW_RANDOM is not set
# CONFIG_I2C is not set
# CONFIG_IDE is not set
CONFIG_INITRAMFS_SOURCE=""
CONFIG_MACB=y
# CONFIG_MTD_ABSENT is not set
CONFIG_MTD_BLKDEVS=y
# CONFIG_MTD_BLOCK2MTD is not set
CONFIG_MTD_BLOCK=y
# CONFIG_MTD_CFI_ADV_OPTIONS is not set
CONFIG_MTD_CFI_AMDSTD=y
CONFIG_MTD_CFI_I1=y
CONFIG_MTD_CFI_I2=y
# CONFIG_MTD_CFI_I4 is not set
# CONFIG_MTD_CFI_I8 is not set
# CONFIG_MTD_CFI_INTELEXT is not set
# CONFIG_MTD_CFI_STAA is not set
CONFIG_MTD_CFI_UTIL=y
CONFIG_MTD_CFI=y
CONFIG_MTD_CHAR=y
CONFIG_MTD_CMDLINE_PARTS=y
# CONFIG_MTD_COMPLEX_MAPPINGS is not set
# CONFIG_MTD_CONCAT is not set
CONFIG_MTD_DATAFLASH=y
# CONFIG_MTD_DEBUG is not set
# CONFIG_MTD_DOC2000 is not set
# CONFIG_MTD_DOC2001 is not set
# CONFIG_MTD_DOC2001PLUS is not set
CONFIG_MTD_GEN_PROBE=y
# CONFIG_MTD_JEDECPROBE is not set
# CONFIG_MTD_M25P80 is not set
# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
CONFIG_MTD_MAP_BANK_WIDTH_1=y
CONFIG_MTD_MAP_BANK_WIDTH_2=y
# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
CONFIG_MTD_MAP_BANK_WIDTH_4=y
# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
# CONFIG_MTD_MTDRAM is not set
# CONFIG_MTD_NAND is not set
# CONFIG_MTD_OBSOLETE_CHIPS is not set
# CONFIG_MTD_ONENAND is not set
CONFIG_MTD_PARTITIONS=y
# CONFIG_MTD_PHRAM is not set
CONFIG_MTD_PHYSMAP_BANKWIDTH=2
CONFIG_MTD_PHYSMAP_LEN=0x0
CONFIG_MTD_PHYSMAP_START=0x80000000
CONFIG_MTD_PHYSMAP=y
# CONFIG_MTD_PLATRAM is not set
# CONFIG_MTD_RAM is not set
# CONFIG_MTD_REDBOOT_PARTS is not set
# CONFIG_MTD_ROM is not set
# CONFIG_MTD_SLRAM is not set
CONFIG_MTD_SPLIT_ROOTFS=y
CONFIG_MTD=y
# CONFIG_OWNERSHIP_TRACE is not set
CONFIG_PHYS_OFFSET=0x10000000
CONFIG_PLATFORM_AT32AP=y
# CONFIG_RTC is not set
# CONFIG_SERIAL_8250 is not set
CONFIG_SERIAL_ATMEL_CONSOLE=y
# CONFIG_SERIAL_ATMEL_TTYAT is not set
CONFIG_SERIAL_ATMEL=y
# CONFIG_SPI_AT25 is not set
CONFIG_SPI_ATMEL=y
# CONFIG_SPI_BITBANG is not set
# CONFIG_SPI_DEBUG is not set
CONFIG_SPI_MASTER=y
CONFIG_SPI=y
CONFIG_SUBARCH_AVR32B=y
# CONFIG_UNUSED_SYMBOLS is not set
# CONFIG_WATCHDOG is not set

View File

@ -0,0 +1,37 @@
#
# Copyright (C) 2007 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
define Image/Prepare
cp $(LINUX_DIR)/arch/avr32/boot/images/uImage $(KDIR)/uImage
endef
define Image/BuildKernel
cp $(KDIR)/uImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-uImage
endef
define Image/Build
$(call Image/Build/$(1),$(1))
endef
define Image/Build/squashfs
$(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
( \
dd if=$(KDIR)/uImage bs=1024k conv=sync; \
dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
) > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
endef
define Image/Build/jffs2-64k
( \
dd if=$(KDIR)/uImage bs=1024k conv=sync; \
dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
) > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
endef
$(eval $(call BuildImage))

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
diff -Nur linux-2.6.21.3/arch/avr32/boards/atngw100/flash.c linux-2.6.21.3-owrt/arch/avr32/boards/atngw100/flash.c
--- linux-2.6.21.3/arch/avr32/boards/atngw100/flash.c 2007-06-07 18:34:04.000000000 +0200
+++ linux-2.6.21.3-owrt/arch/avr32/boards/atngw100/flash.c 2007-06-07 18:36:02.000000000 +0200
@@ -43,9 +43,14 @@
.mask_flags = MTD_WRITEABLE,
},
{
- .name = "root",
+ .name = "kernel",
.offset = 0x00020000,
- .size = 0x007d0000,
+ .size = 0x00100000,
+ },
+ {
+ .name = "rootfs",
+ .offset = 0x00120000,
+ .size = 0x006d0000,
},
{
.name = "env",

View File

@ -1943,7 +1943,7 @@ diff -urN linux-2.6.21.1.old/fs/mini_fo/fist.h linux-2.6.21.1.dev/fs/mini_fo/fis
+#include <linux/swap.h>
+
+#include <asm/system.h>
+#include <asm/segment.h>
+/* #include <asm/segment.h> */
+#include <asm/mman.h>
+#include <linux/seq_file.h>
+

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,103 @@
Index: binutils/bfd/elf32-avr32.c
===================================================================
--- binutils/bfd/elf32-avr32.c (revision 8769)
+++ binutils/bfd/elf32-avr32.c (working copy)
@@ -298,7 +298,7 @@
/* Shortcuts to get to dynamic linker sections. */
asection *sgot;
asection *srelgot;
- asection *sreldyn;
+ /* asection *sreldyn; */
asection *sstub;
/* We use a variation of Pigeonhole Sort to sort the GOT. After the
@@ -506,14 +506,14 @@
if (!avr32_elf_create_got_section (dynobj, info))
return FALSE;
- if (!htab->sreldyn)
+ /* if (!htab->sreldyn)
htab->sreldyn = create_dynamic_section(dynobj, ".rela.dyn",
- flags | SEC_READONLY, 2);
+ flags | SEC_READONLY, 2); */
if (!htab->sstub)
htab->sstub = create_dynamic_section(dynobj, ".stub",
flags | SEC_READONLY | SEC_CODE, 2);
- if (!htab->sreldyn || !htab->sstub)
+ if (/* !htab->sreldyn || */ !htab->sstub)
return FALSE;
return TRUE;
@@ -669,12 +669,12 @@
if ((info->shared || h != NULL)
&& (sec->flags & SEC_ALLOC))
{
- if (htab->sreldyn == NULL)
+ if (htab->srelgot == NULL)
{
- htab->sreldyn = create_dynamic_section(dynobj, ".rela.dyn",
+ htab->srelgot = create_dynamic_section(dynobj, ".rela.got",
bed->dynamic_sec_flags
| SEC_READONLY, 2);
- if (htab->sreldyn == NULL)
+ if (htab->srelgot == NULL)
return FALSE;
}
@@ -1062,7 +1062,7 @@
{
pr_debug("Allocating %d dynamic reloc against symbol %s...\n",
havr->possibly_dynamic_relocs, h->root.root.string);
- htab->sreldyn->size += (havr->possibly_dynamic_relocs
+ htab->srelgot->size += (havr->possibly_dynamic_relocs
* sizeof(Elf32_External_Rela));
}
@@ -1156,7 +1156,7 @@
/* Allocate space for local sym dynamic relocs */
BFD_ASSERT(htab->local_dynamic_relocs == 0 || info->shared);
if (htab->local_dynamic_relocs)
- htab->sreldyn->size += (htab->local_dynamic_relocs
+ htab->srelgot->size += (htab->local_dynamic_relocs
* sizeof(Elf32_External_Rela));
/* We now have determined the sizes of the various dynamic
@@ -3191,7 +3191,6 @@
struct got_entry **local_got_ents;
asection *sgot;
asection *srelgot;
- asection *sreldyn;
pr_debug("(6) relocate section %s:<%s> (size 0x%lx)\n",
input_bfd->filename, input_section->name, input_section->size);
@@ -3207,7 +3206,6 @@
local_got_ents = elf_local_got_ents(input_bfd);
sgot = htab->sgot;
srelgot = htab->srelgot;
- sreldyn = htab->sreldyn;
relend = relocs + input_section->reloc_count;
for (rel = relocs; rel < relend; rel++)
@@ -3444,15 +3442,15 @@
}
}
- pr_debug("sreldyn reloc_count: %d, size %lu\n",
- sreldyn->reloc_count, sreldyn->size);
+ pr_debug("srelgot reloc_count: %d, size %lu\n",
+ srelgot->reloc_count, srelgot->size);
- loc = sreldyn->contents;
- loc += sreldyn->reloc_count++ * sizeof(Elf32_External_Rela);
+ loc = srelgot->contents;
+ loc += srelgot->reloc_count++ * sizeof(Elf32_External_Rela);
bfd_elf32_swap_reloca_out(output_bfd, &outrel, loc);
- BFD_ASSERT(sreldyn->reloc_count * sizeof(Elf32_External_Rela)
- <= sreldyn->size);
+ BFD_ASSERT(srelgot->reloc_count * sizeof(Elf32_External_Rela)
+ <= srelgot->size);
if (!relocate)
continue;

View File

@ -0,0 +1,19 @@
Index: binutils/bfd/elf32-avr32.c
===================================================================
--- binutils/bfd/elf32-avr32.c (revision 24565)
+++ binutils/bfd/elf32-avr32.c (working copy)
@@ -2446,9 +2446,13 @@
after the relaxation code is done, so we can't really
trust that our "distance" is correct. There's really no
easy solution to this problem, so we'll just disallow
- direct references to SEC_DATA sections. */
+ direct references to SEC_DATA sections.
+
+ Oh, and .bss isn't actually SEC_DATA, so we disallow
+ !SEC_HAS_CONTENTS as well. */
if (!dynamic && defined
&& !(sym_sec->flags & SEC_DATA)
+ && (sym_sec->flags & SEC_HAS_CONTENTS)
&& next_state->direct)
{
next_state = &relax_state[next_state->direct];

View File

@ -0,0 +1,11 @@
--- a/bfd/elf32-avr32.c 2007-05-31 17:00:13.000000000 +0200
+++ b/bfd/elf32-avr32.c 2007-05-30 14:07:25.000000000 +0200
@@ -395,6 +395,8 @@ avr32_elf_link_hash_table_create(bfd *ab
/* Prevent the BFD core from creating bogus got_entry pointers */
ret->root.init_got_refcount.glist = NULL;
ret->root.init_plt_refcount.glist = NULL;
+ ret->root.init_got_offset.glist = NULL;
+ ret->root.init_plt_offset.glist = NULL;
return &ret->root.root;
}

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,7 @@ UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
-e 's/i.86/i386/' \
-e 's/sparc.*/sparc/' \
-e 's/arm.*/arm/g' \
-e 's/avr32.*/avr32/g' \
-e 's/m68k.*/m68k/' \
-e 's/ppc/powerpc/g' \
-e 's/v850.*/v850/g' \

View File

@ -3,6 +3,7 @@
#
# TARGET_alpha is not set
TARGET_arm=y
# TARGET_avr32 is not set
# TARGET_bfin is not set
# TARGET_cris is not set
# TARGET_e1 is not set

View File

@ -3,6 +3,7 @@
#
# TARGET_alpha is not set
TARGET_arm=y
# TARGET_avr32 is not set
# TARGET_bfin is not set
# TARGET_cris is not set
# TARGET_e1 is not set

View File

@ -0,0 +1,160 @@
#
# Automatically generated make config: don't edit
#
# TARGET_alpha is not set
# TARGET_arm is not set
TARGET_avr32=y
# TARGET_bfin is not set
# TARGET_cris is not set
# TARGET_e1 is not set
# TARGET_frv is not set
# TARGET_h8300 is not set
# TARGET_i386 is not set
# TARGET_i960 is not set
# TARGET_m68k is not set
# TARGET_microblaze is not set
# TARGET_mips is not set
# TARGET_nios is not set
# TARGET_nios2 is not set
# TARGET_powerpc is not set
# TARGET_sh is not set
# TARGET_sh64 is not set
# TARGET_sparc is not set
# TARGET_v850 is not set
# TARGET_x86_64 is not set
#
# Target Architecture Features and Options
#
HAVE_ELF=y
TARGET_ARCH="avr32"
ARCH_SUPPORTS_BIG_ENDIAN=y
UCLIBC_COMPLETELY_PIC=y
CONFIG_AP7000=y
LINKRELAX=y
# ARCH_LITTLE_ENDIAN is not set
ARCH_BIG_ENDIAN=y
# ARCH_HAS_NO_MMU is not set
ARCH_HAS_MMU=y
UCLIBC_HAS_FLOATS=y
# HAS_FPU is not set
UCLIBC_HAS_SOFT_FLOAT=y
# DO_C99_MATH is not set
KERNEL_SOURCE="./toolchain_build_avr32/linux"
C_SYMBOL_PREFIX=""
HAVE_DOT_CONFIG=y
#
# General Library Settings
#
# HAVE_NO_PIC is not set
DOPIC=y
# HAVE_NO_SHARED is not set
HAVE_SHARED=y
# ARCH_HAS_NO_LDSO is not set
BUILD_UCLIBC_LDSO=y
FORCE_SHAREABLE_TEXT_SEGMENTS=y
LDSO_LDD_SUPPORT=y
LDSO_CACHE_SUPPORT=y
# LDSO_PRELOAD_FILE_SUPPORT is not set
LDSO_BASE_FILENAME="ld.so"
# LDSO_RUNPATH is not set
# DL_FINI_CRT_COMPAT is not set
UCLIBC_CTOR_DTOR=y
# HAS_NO_THREADS is not set
UCLIBC_HAS_THREADS=y
# PTHREADS_DEBUG_SUPPORT is not set
UCLIBC_HAS_LFS=y
# UCLIBC_STATIC_LDCONFIG is not set
# MALLOC is not set
# MALLOC_SIMPLE is not set
MALLOC_STANDARD=y
MALLOC_GLIBC_COMPAT=y
UCLIBC_DYNAMIC_ATEXIT=y
HAS_SHADOW=y
UNIX98PTY_ONLY=y
ASSUME_DEVPTS=y
UCLIBC_HAS_TM_EXTENSIONS=y
UCLIBC_HAS_TZ_CACHING=y
UCLIBC_HAS_TZ_FILE=y
UCLIBC_HAS_TZ_FILE_READ_MANY=y
UCLIBC_TZ_FILE_PATH="/etc/TZ"
#
# Networking Support
#
UCLIBC_HAS_IPV6=y
UCLIBC_HAS_RPC=y
UCLIBC_HAS_FULL_RPC=y
#
# String and Stdio Support
#
UCLIBC_HAS_STRING_GENERIC_OPT=y
# UCLIBC_HAS_STRING_ARCH_OPT is not set
UCLIBC_HAS_CTYPE_TABLES=y
UCLIBC_HAS_CTYPE_SIGNED=y
# UCLIBC_HAS_CTYPE_UNSAFE is not set
UCLIBC_HAS_CTYPE_CHECKED=y
# UCLIBC_HAS_CTYPE_ENFORCED is not set
UCLIBC_HAS_WCHAR=y
# UCLIBC_HAS_LOCALE is not set
UCLIBC_HAS_HEXADECIMAL_FLOATS=y
UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
# UCLIBC_HAS_SCANF_GLIBC_A_FLAG is not set
# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
UCLIBC_HAS_STDIO_BUFSIZ_4096=y
# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
UCLIBC_HAS_STDIO_GETC_MACRO=y
UCLIBC_HAS_STDIO_PUTC_MACRO=y
UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
UCLIBC_HAS_PRINTF_M_SPEC=y
UCLIBC_HAS_ERRNO_MESSAGES=y
# UCLIBC_HAS_SYS_ERRLIST is not set
UCLIBC_HAS_SIGNUM_MESSAGES=y
# UCLIBC_HAS_SYS_SIGLIST is not set
UCLIBC_HAS_GNU_GETOPT=y
#
# Big and Tall
#
UCLIBC_HAS_REGEX=y
UCLIBC_HAS_WORDEXP=y
UCLIBC_HAS_FTW=y
UCLIBC_HAS_GLOB=y
#
# Library Installation Options
#
SHARED_LIB_LOADER_PREFIX="/lib"
RUNTIME_PREFIX="/"
DEVEL_PREFIX="/usr/"
#
# uClibc security related options
#
# UCLIBC_SECURITY is not set
#
# uClibc development/debugging options
#
CROSS_COMPILER_PREFIX=""
# DODEBUG is not set
# DODEBUG_PT is not set
# DOASSERTS is not set
# SUPPORT_LD_DEBUG is not set
# SUPPORT_LD_DEBUG_EARLY is not set
WARNINGS="-Wall"
# UCLIBC_MJN3_ONLY is not set

View File

@ -3,6 +3,7 @@
#
# TARGET_alpha is not set
# TARGET_arm is not set
# TARGET_avr32 is not set
# TARGET_bfin is not set
TARGET_cris=y
# TARGET_e1 is not set

View File

@ -10,6 +10,7 @@
#
# TARGET_alpha is not set
# TARGET_arm is not set
# TARGET_avr32 is not set
# TARGET_bfin is not set
# TARGET_cris is not set
# TARGET_e1 is not set

View File

@ -10,6 +10,7 @@
#
# TARGET_alpha is not set
# TARGET_arm is not set
# TARGET_avr32 is not set
# TARGET_bfin is not set
# TARGET_cris is not set
# TARGET_e1 is not set

View File

@ -10,6 +10,7 @@
#
# TARGET_alpha is not set
# TARGET_arm is not set
# TARGET_avr32 is not set
# TARGET_bfin is not set
# TARGET_cris is not set
# TARGET_e1 is not set

View File

@ -10,6 +10,7 @@
#
# TARGET_alpha is not set
# TARGET_arm is not set
# TARGET_avr32 is not set
# TARGET_bfin is not set
# TARGET_cris is not set
# TARGET_e1 is not set

View File

@ -3,6 +3,7 @@
#
# TARGET_alpha is not set
# TARGET_arm is not set
# TARGET_avr32 is not set
# TARGET_bfin is not set
# TARGET_cris is not set
# TARGET_e1 is not set

View File

@ -0,0 +1,28 @@
From 7b2f125425cf777e7937b533217588e27952b87d Mon Sep 17 00:00:00 2001
From: Haavard Skinnemoen <hskinnemoen@atmel.com>
Date: Mon, 7 Aug 2006 11:12:50 +0200
Subject: [PATCH] Let optimized stringops override default ones
The default, slow stringops must be archived _before_ the optimized
stringops if there is to be any point doing the optimizations in the
first place.
---
libc/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libc/Makefile b/libc/Makefile
index 31e4bab..687eac5 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -59,7 +59,7 @@ # will evaluate to no files :(.
$(AR) dN 2 $(LIBNAME) $$objs && \
$(AR) dN 2 $(LIBNAME) $$objs
@for objfile in obj.signal \
- obj.string.generic obj.string.$(TARGET_ARCH) obj.string \
+ obj.string obj.string.generic obj.string.$(TARGET_ARCH) \
obj.sysdeps.common obj.sysdeps.$(TARGET_ARCH) ; do \
if [ -e $$objfile ] ; then \
if [ "$(MAKE_IS_SILENT)" = "n" ] ; then \
--
1.4.1.1

View File

@ -0,0 +1,19 @@
Subject: [PATCH] Fix getrusage argument type
The first argument to getrusage is of type __rusage_who_t, not int.
This patch fixes that.
---
libc/sysdeps/linux/common/getrusage.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: uClibc-0.9.28/libc/sysdeps/linux/common/getrusage.c
===================================================================
--- uClibc-0.9.28.orig/libc/sysdeps/linux/common/getrusage.c 2006-02-07 17:18:22.000000000 +0100
+++ uClibc-0.9.28/libc/sysdeps/linux/common/getrusage.c 2006-02-07 17:18:31.000000000 +0100
@@ -10,4 +10,4 @@
#include "syscalls.h"
#include <unistd.h>
#include <wait.h>
-_syscall2(int, getrusage, int, who, struct rusage *, usage);
+_syscall2(int, getrusage, __rusage_who_t, who, struct rusage *, usage);

View File

@ -0,0 +1,24 @@
Subject: [PATCH] Fix __libc_fcntl64 prototype in __syscall_fcntl.c
__libc_fcntl64 is a varargs function and should be declared as such.
Otherwise, the gcc compiler for AVR32, and perhaps other architectures,
will use the wrong calling convention.
---
libc/sysdeps/linux/common/__syscall_fcntl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: uClibc-0.9.28/libc/sysdeps/linux/common/__syscall_fcntl.c
===================================================================
--- uClibc-0.9.28.orig/libc/sysdeps/linux/common/__syscall_fcntl.c 2006-02-07 16:48:32.000000000 +0100
+++ uClibc-0.9.28/libc/sysdeps/linux/common/__syscall_fcntl.c 2006-02-07 17:19:09.000000000 +0100
@@ -12,7 +12,7 @@
#include <fcntl.h>
#if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
-extern int __libc_fcntl64(int fd, int cmd, long arg);
+extern int __libc_fcntl64(int fd, int cmd, ...);
#endif
#define __NR___syscall_fcntl __NR_fcntl

View File

@ -0,0 +1,30 @@
From nobody Mon Sep 17 00:00:00 2001
From: Håvard Skinnemoen <hskinnemoen@atmel.com>
Date: Fri Apr 7 17:10:32 2006 +0200
Subject: [PATCH] Fix broken __libc_open declaration in open64.c
__libc_open is a vararg function and should therefore be declared as
such. Fixes bug #4190.
---
libc/sysdeps/linux/common/open64.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
70f2c81903327a8a346e370830932b80045ab04e
diff --git a/libc/sysdeps/linux/common/open64.c b/libc/sysdeps/linux/common/open64.c
index 543aa13..d9a27a7 100644
--- a/libc/sysdeps/linux/common/open64.c
+++ b/libc/sysdeps/linux/common/open64.c
@@ -26,7 +26,7 @@
#endif
#ifdef __UCLIBC_HAS_LFS__
-extern int __libc_open (__const char *file, int oflag, mode_t mode);
+extern int __libc_open (__const char *file, int oflag, ...);
/* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
a third argument is the file protection. */
--
1.2.4

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,40 @@
From nobody Mon Sep 17 00:00:00 2001
Subject: [PATCH] Make linkrelax configurable
From: Håvard Skinnemoen <hskinnemoen@atmel.com>
Date: 1133951618 +0100
Add a linkrelax option to the configure system which will give
appropriate options to the compiler, assembler and linker to enable
link-time optimizations.
---
Rules.mak | 2 ++
extra/Configs/Config.avr32 | 4 ++++
2 files changed, 6 insertions(+)
Index: uClibc-0.9.28/Rules.mak
===================================================================
--- uClibc-0.9.28.orig/Rules.mak 2006-02-08 17:58:53.000000000 +0100
+++ uClibc-0.9.28/Rules.mak 2006-02-08 17:59:07.000000000 +0100
@@ -233,6 +233,8 @@ endif
ifeq ($(strip $(TARGET_ARCH)),avr32)
CPU_CFLAGS-$(CONFIG_AP7000) += -mcpu=ap7000
+ CPU_CFLAGS-$(LINKRELAX) += -masm-addr-pseudos -Wa,--pic,--linkrelax
+ CPU_LDFLAGS-$(LINKRELAX) += --relax
endif
# Keep the check_gcc from being needlessly executed
Index: uClibc-0.9.28/extra/Configs/Config.avr32
===================================================================
--- uClibc-0.9.28.orig/extra/Configs/Config.avr32 2006-02-08 17:58:53.000000000 +0100
+++ uClibc-0.9.28/extra/Configs/Config.avr32 2006-02-08 17:59:07.000000000 +0100
@@ -36,3 +36,7 @@ config CONFIG_AP7000
bool "AP7000"
endchoice
+
+config LINKRELAX
+ bool "Enable linker optimizations"
+ default n

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
Subject: [PATCH] Don't include create_module() for AVR32
The create_module() system call is obsolete in Linux 2.6, so the
AVR32 kernel doesn't even have it.
Come to think about it, this should be completely unnecessary as the
create_module function is only a stub when __NR_create_module is
undefined.
---
libc/sysdeps/linux/common/create_module.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: uClibc-0.9.28/libc/sysdeps/linux/common/create_module.c
===================================================================
--- uClibc-0.9.28.orig/libc/sysdeps/linux/common/create_module.c 2006-02-07 16:48:38.000000000 +0100
+++ uClibc-0.9.28/libc/sysdeps/linux/common/create_module.c 2006-02-07 17:17:14.000000000 +0100
@@ -61,7 +61,8 @@ unsigned long create_module(const char *
{
return __create_module(name, size, 0, 0);
}
-#else
+/* create_module is obsolete in Linux 2.6, so AVR32 doesn't have it */
+#elif !defined(__avr32__)
/* Sparc, MIPS, etc don't mistake return values for errors. */
_syscall2(unsigned long, create_module, const char *, name, size_t, size);
#endif

View File

@ -0,0 +1,526 @@
Subject: [PATCH] ldso: AVR32 support
This implements the AVR32-specific parts of the dynamic linker.
---
ldso/ldso/avr32/dl-debug.h | 45 +++++++++
ldso/ldso/avr32/dl-startup.h | 110 ++++++++++++++++++++++++
ldso/ldso/avr32/dl-syscalls.h | 5 +
ldso/ldso/avr32/dl-sysdep.h | 103 ++++++++++++++++++++++
ldso/ldso/avr32/elfinterp.c | 191 ++++++++++++++++++++++++++++++++++++++++++
ldso/ldso/avr32/resolve.S | 28 ++++++
6 files changed, 482 insertions(+)
Index: uClibc-0.9.28/ldso/ldso/avr32/dl-debug.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.28/ldso/ldso/avr32/dl-debug.h 2006-05-05 09:30:43.000000000 +0200
@@ -0,0 +1,45 @@
+/*
+ * AVR32 ELF shared libary loader support
+ *
+ * Copyright (C) 2005 Atmel Norway
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the above contributors may not be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``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 CONTRIBUTORS 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.
+ */
+
+static const char *_dl_reltypes_tab[] = {
+ "R_AVR32_NONE",
+ "R_AVR32_32", "R_AVR32_16", "R_AVR32_8",
+ "R_AVR32_32_PCREL", "R_AVR32_16_PCREL", "R_AVR32_8_PCREL",
+ "R_AVR32_DIFF32", "R_AVR32_DIFF16", "R_AVR32_DIFF8",
+ "R_AVR32_GOT32", "R_AVR32_GOT16", "R_AVR32_GOT8",
+ "R_AVR32_21S", "R_AVR32_16U", "R_AVR32_16S", "R_AVR32_8S", "R_AVR32_8S_EXT",
+ "R_AVR32_22H_PCREL", "R_AVR32_18W_PCREL", "R_AVR32_16B_PCREL",
+ "R_AVR32_16N_PCREL", "R_AVR32_14UW_PCREL", "R_AVR32_11H_PCREL",
+ "R_AVR32_10UW_PCREL", "R_AVR32_9H_PCREL", "R_AVR32_9UW_PCREL",
+ "R_AVR32_HI16", "R_AVR32_LO16",
+ "R_AVR32_GOTPC", "R_AVR32_GOTCALL", "R_AVR32_LDA_GOT",
+ "R_AVR32_GOT21S", "R_AVR32_GOT18SW", "R_AVR32_GOT16S", "R_AVR32_GOT7UW",
+ "R_AVR32_32_CPENT", "R_AVR32_CPCALL", "R_AVR32_16_CP", "R_AVR32_9W_CP",
+ "R_AVR32_RELATIVE", "R_AVR32_GLOB_DAT", "R_AVR32_JMP_SLOT",
+ "R_AVR32_ALIGN",
+};
Index: uClibc-0.9.28/ldso/ldso/avr32/dl-startup.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.28/ldso/ldso/avr32/dl-startup.h 2006-05-05 09:29:45.000000000 +0200
@@ -0,0 +1,110 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Architecture specific code used by dl-startup.c
+ * Copyright (C) 2005 Atmel Norway
+ */
+
+/* This is the library loader's main entry point. Let _dl_boot2 do its
+ * initializations and jump to the application's entry point
+ * afterwards. */
+asm( " .text\n"
+ " .global _start\n"
+ " .type _start,@function\n"
+ "_start:\n"
+ /* All arguments are on the stack initially */
+ " mov r12, sp\n"
+ " rcall _dl_start\n"
+ /* Returns user entry point in r12. Save it. */
+ " mov r0, r12\n"
+ /* We're PIC, so get the Global Offset Table */
+ " lddpc r6, .L_GOT\n"
+ ".L_RGOT:\n"
+ " rsub r6, pc\n"
+ /* Adjust argc and argv according to _dl_skip_args */
+ " ld.w r1, r6[_dl_skip_args@got]\n"
+ " ld.w r1, r1[0]\n"
+ " ld.w r2, sp++\n"
+ " sub r2, r1\n"
+ " add sp, sp, r1 << 2\n"
+ " st.w --sp, r2\n"
+ /* Load the finalizer function */
+ " ld.w r12, r6[_dl_fini@got]\n"
+ /* Jump to the user's entry point */
+ " mov pc, r0\n\n"
+
+ " .align 2\n"
+ ".L_GOT:"
+ " .long .L_RGOT - _GLOBAL_OFFSET_TABLE_\n"
+ " .size _start, . - _start\n"
+ " .previous\n");
+
+/* Get a pointer to the argv array. On many platforms this can be just
+ * the address if the first argument, on other platforms we need to
+ * do something a little more subtle here. */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *)ARGS + 1)
+
+
+/* We can't call functions before the GOT has been initialized */
+#define NO_FUNCS_BEFORE_BOOTSTRAP
+
+/*
+ * Relocate the GOT during dynamic loader bootstrap. This will add
+ * the load address to all entries in the GOT, which is necessary
+ * because the linker doesn't generate R_AVR32_RELATIVE relocs for the
+ * GOT.
+ */
+static __always_inline
+void PERFORM_BOOTSTRAP_GOT(struct elf_resolve *tpnt)
+{
+ Elf32_Addr i, nr_got;
+ register Elf32_Addr *__r6 __asm__("r6");
+ Elf32_Addr *got = __r6;
+
+ nr_got = tpnt->dynamic_info[DT_AVR32_GOTSZ_IDX] / sizeof(*got);
+ for (i = 2; i < nr_got; i++)
+ got[i] += tpnt->loadaddr;
+}
+
+#define PERFORM_BOOTSTRAP_GOT(tpnt) PERFORM_BOOTSTRAP_GOT(tpnt)
+
+/* Handle relocation of the symbols in the dynamic loader. */
+static __always_inline
+void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
+ unsigned long symbol_addr,
+ unsigned long load_addr, Elf32_Sym *symtab)
+{
+ switch(ELF32_R_TYPE(rpnt->r_info)) {
+ case R_AVR32_NONE:
+ break;
+ case R_AVR32_GLOB_DAT:
+ case R_AVR32_JMP_SLOT:
+ *reloc_addr = symbol_addr;
+ break;
+ case R_AVR32_RELATIVE:
+ SEND_STDERR_DEBUG("Applying RELATIVE relocation: ");
+ SEND_ADDRESS_STDERR_DEBUG(load_addr, 0);
+ SEND_STDERR_DEBUG(" + ");
+ SEND_ADDRESS_STDERR_DEBUG(rpnt->r_addend, 1);
+ *reloc_addr = load_addr + rpnt->r_addend;
+ break;
+ default:
+ SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc_type ");
+ SEND_NUMBER_STDERR(ELF32_R_TYPE(rpnt->r_info), 1);
+ SEND_STDERR("REL, SYMBOL, LOAD: ");
+ SEND_ADDRESS_STDERR(reloc_addr, 0);
+ SEND_STDERR(", ");
+ SEND_ADDRESS_STDERR(symbol_addr, 0);
+ SEND_STDERR(", ");
+ SEND_ADDRESS_STDERR(load_addr, 1);
+ _dl_exit(1);
+ }
+}
+
+/* Transfer control to the user's application, once the dynamic loader
+ * is done. This routine has to exit the current function, then call
+ * the _dl_elf_main function.
+ *
+ * Since our _dl_boot will simply call whatever is returned by
+ * _dl_boot2, we can just return the address we're supposed to
+ * call. */
+#define START() return _dl_elf_main;
Index: uClibc-0.9.28/ldso/ldso/avr32/dl-syscalls.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.28/ldso/ldso/avr32/dl-syscalls.h 2006-05-05 09:29:25.000000000 +0200
@@ -0,0 +1,5 @@
+/* We can't use the real errno in ldso, since it has not yet
+ * been dynamicly linked in yet. */
+extern int _dl_errno;
+#define __set_errno(X) {(_dl_errno) = (X);}
+#include "sys/syscall.h"
Index: uClibc-0.9.28/ldso/ldso/avr32/dl-sysdep.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.28/ldso/ldso/avr32/dl-sysdep.h 2006-05-05 09:30:43.000000000 +0200
@@ -0,0 +1,103 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Various assembly language/system dependent hacks that are required
+ * so that we can minimize the amount of platform specific code.
+ * Copyright (C) 2004-2005 Atmel Norway
+ */
+
+/* Define this if the system uses RELOCA. */
+#define ELF_USES_RELOCA
+
+#include <elf.h>
+
+#define ARCH_NUM 1
+#define DT_AVR32_GOTSZ_IDX (DT_NUM + OS_NUM)
+
+#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \
+ do { \
+ if (dpnt->d_tag == DT_AVR32_GOTSZ) \
+ dynamic[DT_AVR32_GOTSZ_IDX] = dpnt->d_un.d_val; \
+ } while (0)
+
+/* Initialization sequence for the application/library GOT. */
+#define INIT_GOT(GOT_BASE,MODULE) \
+ do { \
+ unsigned long i, nr_got; \
+ \
+ GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \
+ GOT_BASE[1] = (unsigned long) MODULE; \
+ \
+ /* Add load address displacement to all GOT entries */ \
+ nr_got = MODULE->dynamic_info[DT_AVR32_GOTSZ_IDX] / 4; \
+ for (i = 2; i < nr_got; i++) \
+ GOT_BASE[i] += (unsigned long)MODULE->loadaddr; \
+ } while (0)
+
+#define do_rem(result, n, base) ((result) = (n) % (base))
+
+/* Here we define the magic numbers that this dynamic loader should accept */
+#define MAGIC1 EM_AVR32
+#undef MAGIC2
+
+/* Used for error messages */
+#define ELF_TARGET "AVR32"
+
+unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
+
+#define elf_machine_type_class(type) \
+ ((type == R_AVR32_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)
+
+/* AVR32 doesn't need any COPY relocs */
+#define DL_NO_COPY_RELOCS
+
+/* Return the link-time address of _DYNAMIC. Conveniently, this is the
+ first element of the GOT. This must be inlined in a function which
+ uses global data. */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+ register Elf32_Addr *got asm ("r6");
+ return *got;
+}
+
+/* Return the run-time load address of the shared object. */
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+ extern void __dl_start asm("_dl_start");
+ Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
+ Elf32_Addr pcrel_addr;
+
+ asm (" lddpc %0, 2f\n"
+ "1: add %0, pc\n"
+ " rjmp 3f\n"
+ " .align 2\n"
+ "2: .long _dl_start - 1b\n"
+ "3:\n"
+ : "=r"(pcrel_addr) : : "cc");
+
+ return pcrel_addr - got_addr;
+}
+
+/*
+ * Perform any RELATIVE relocations specified by DT_RELCOUNT.
+ * Currently, we don't use that tag, but we might in the future as
+ * this would reduce the startup time somewhat (although probably not by much).
+ */
+static inline void
+elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
+ Elf32_Word relative_count)
+{
+ Elf32_Rela *rpnt = (void *)rel_addr;
+
+ do {
+ Elf32_Addr *reloc_addr;
+ reloc_addr = (void *)(load_off + (rpnt++)->r_offset);
+ *reloc_addr = load_off + rpnt->r_addend;
+ } while (--relative_count);
+}
Index: uClibc-0.9.28/ldso/ldso/avr32/elfinterp.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.28/ldso/ldso/avr32/elfinterp.c 2006-05-05 09:30:43.000000000 +0200
@@ -0,0 +1,191 @@
+/*
+ * AVR32 ELF shared library loader suppport
+ *
+ * Copyright (C) 2004-2006 Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the above contributors may not be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``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 CONTRIBUTORS 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.
+ */
+
+unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got)
+{
+ struct elf_resolve *tpnt = (struct elf_resolve *)got[1];
+ Elf32_Sym *sym;
+ unsigned long local_gotno;
+ unsigned long gotsym;
+ unsigned long new_addr;
+ char *strtab, *symname;
+ unsigned long *entry;
+ unsigned long sym_index = got_offset / 4;
+
+#if 0
+ local_gotno = tpnt->dynamic_info[DT_AVR32_LOCAL_GOTNO];
+ gotsym = tpnt->dynamic_info[DT_AVR32_GOTSYM];
+
+ sym = ((Elf32_Sym *)(tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr))
+ + sym_index;
+ strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
+ symname = strtab + sym->st_name;
+
+#if 0
+ new_addr = (unsigned long) _dl_find_hash(strtab + sym->st_name,
+ tpnt->symbol_scope, tpnt,
+ resolver);
+#endif
+
+ entry = (unsigned long *)(got + local_gotno + sym_index - gotsym);
+ *entry = new_addr;
+#endif
+
+ return new_addr;
+}
+
+static int
+_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+ unsigned long rel_addr, unsigned long rel_size,
+ int (*reloc_func)(struct elf_resolve *tpnt, struct dyn_elf *scope,
+ Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab))
+{
+ Elf32_Sym *symtab;
+ Elf32_Rela *rpnt;
+ char *strtab;
+ int i;
+
+ rpnt = (Elf32_Rela *)rel_addr;
+ rel_size /= sizeof(Elf32_Rela);
+ symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+
+ for (i = 0; i < rel_size; i++, rpnt++) {
+ int symtab_index, res;
+
+ symtab_index = ELF32_R_SYM(rpnt->r_info);
+
+ debug_sym(symtab, strtab, symtab_index);
+ debug_reloc(symtab, strtab, rpnt);
+
+ res = reloc_func(tpnt, scope, rpnt, symtab, strtab);
+
+ if (res == 0)
+ continue;
+
+ _dl_dprintf(2, "\n%s: ", _dl_progname);
+
+ if (symtab_index)
+ _dl_dprintf(2, "symbol '%s': ",
+ strtab + symtab[symtab_index].st_name);
+
+ if (res < 0) {
+ int reloc_type = ELF32_R_TYPE(rpnt->r_info);
+#if defined(__SUPPORT_LD_DEBUG__)
+ _dl_dprintf(2, "can't handle reloc type %s\n",
+ _dl_reltypes(reloc_type));
+#else
+ _dl_dprintf(2, "can't handle reloc type %x\n",
+ reloc_type);
+#endif
+ _dl_exit(-res);
+ } else {
+ _dl_dprintf(2, "can't resolve symbol\n");
+ return res;
+ }
+ }
+
+ return 0;
+}
+
+static int _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
+ Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab)
+{
+ int reloc_type;
+ int symtab_index;
+ char *symname;
+ unsigned long *reloc_addr;
+ unsigned long symbol_addr;
+#if defined(__SUPPORT_LD_DEBUG__)
+ unsigned long old_val;
+#endif
+
+ reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
+ reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ symtab_index = ELF32_R_SYM(rpnt->r_info);
+ symbol_addr = 0;
+ symname = strtab + symtab[symtab_index].st_name;
+
+ if (symtab_index) {
+ symbol_addr = (unsigned long)
+ _dl_find_hash(strtab + symtab[symtab_index].st_name,
+ tpnt->symbol_scope, tpnt,
+ elf_machine_type_class(reloc_type));
+
+ /* Allow undefined references to weak symbols */
+ if (!symbol_addr &&
+ ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
+ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_progname, symname);
+ return 0;
+ }
+ }
+
+#if defined(__SUPPORT_LD_DEBUG__)
+ old_val = *reloc_addr;
+#endif
+ switch (reloc_type) {
+ case R_AVR32_NONE:
+ break;
+ case R_AVR32_GLOB_DAT:
+ case R_AVR32_JMP_SLOT:
+ *reloc_addr = symbol_addr + rpnt->r_addend;
+ break;
+ case R_AVR32_RELATIVE:
+ *reloc_addr = (unsigned long)tpnt->loadaddr
+ + rpnt->r_addend;
+ break;
+ default:
+ return -1;
+ }
+
+#if defined(__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail)
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
+ old_val, *reloc_addr);
+#endif
+
+ return 0;
+}
+
+void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
+ unsigned long rel_addr,
+ unsigned long rel_size)
+{
+ /* TODO: Might want to support this in order to get faster
+ * startup times... */
+}
+
+int _dl_parse_relocation_information(struct dyn_elf *rpnt,
+ unsigned long rel_addr,
+ unsigned long rel_size)
+{
+ return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size,
+ _dl_do_reloc);
+}
Index: uClibc-0.9.28/ldso/ldso/avr32/resolve.S
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.28/ldso/ldso/avr32/resolve.S 2006-05-05 09:29:25.000000000 +0200
@@ -0,0 +1,28 @@
+/*
+ * Linux dynamic resolving code for AVR32. Fixes up the GOT entry as
+ * indicated in register r12 and jumps to the resolved address.
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser General
+ * Public License. See the file "COPYING.LIB" in the main directory of this
+ * archive for more details.
+ *
+ * Copyright (C) 2004 Atmel Norway
+ */
+
+#define ip r5
+
+ .text
+ .global _dl_linux_resolve
+ .type _dl_linux_resolve,@function
+_dl_linux_resolve:
+ /* The PLT code pushed r8 for us. It contains the address of this
+ function's GOT entry, that is entry 0. ip contains the address
+ of the GOT entry of the function we wanted to call. */
+ stm --sp, r9-r12, lr
+ mov r11, r8
+ sub r12, ip, r8
+ rcall _dl_linux_resolver
+ mov ip, r12
+ popm r8-r12,lr
+ mov pc, ip
+ .size _dl_linux_resolve, . - _dl_linux_resolve

View File

@ -0,0 +1,40 @@
Subject: [PATCH] ldso: AVR32 startup hack
AVR32 needs to do both PERFORM_BOOTSTRAP_GOT and a full relocation of
the GOT. I don't quite remember why, but I think it's because some GOT
entries just need the load address added to them, while the rest need
the full relocation code.
This patch should be revisited to figure out whether we're processing
relocations against undefined symbols and whether that's something we
should be doing...
---
ldso/ldso/dl-startup.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Index: uClibc-0.9.28/ldso/ldso/dl-startup.c
===================================================================
--- uClibc-0.9.28.orig/ldso/ldso/dl-startup.c 2006-02-07 16:49:27.000000000 +0100
+++ uClibc-0.9.28/ldso/ldso/dl-startup.c 2006-02-07 17:12:09.000000000 +0100
@@ -217,7 +217,9 @@ static void * __attribute_used__ _dl_sta
/* some arches (like MIPS) we have to tweak the GOT before relocations */
PERFORM_BOOTSTRAP_GOT(tpnt);
-#else
+#endif
+
+#if !defined(PERFORM_BOOTSTRAP_GOT) || defined(__avr32__)
/* OK, now do the relocations. We do not do a lazy binding here, so
that once we are done, we have considerably more flexibility. */
@@ -259,7 +261,7 @@ static void * __attribute_used__ _dl_sta
rel_addr += relative_count * sizeof(ELF_RELOC);;
}
- rpnt = (ELF_RELOC *) (rel_addr + load_addr);
+ rpnt = (ELF_RELOC *) (rel_addr /* + load_addr */);
for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
reloc_addr = (unsigned long *) (load_addr + (unsigned long) rpnt->r_offset);
symtab_index = ELF_R_SYM(rpnt->r_info);

View File

@ -0,0 +1,25 @@
Subject: [PATCH] ldd: AVR32 support
Add AVR32-specific definitions to ldd.
---
utils/ldd.c | 5 +++++
1 file changed, 5 insertions(+)
Index: uClibc-0.9.28/utils/ldd.c
===================================================================
--- uClibc-0.9.28.orig/utils/ldd.c 2006-02-07 16:48:02.000000000 +0100
+++ uClibc-0.9.28/utils/ldd.c 2006-02-07 17:13:00.000000000 +0100
@@ -56,6 +56,11 @@
#define ELFCLASSM ELFCLASS32
#endif
+#if defined(__avr32__)
+#define MATCH_MACHINE(x) (x == EM_AVR32)
+#define ELFCLASSM ELFCLASS32
+#endif
+
#if defined(__s390__)
#define MATCH_MACHINE(x) (x == EM_S390)
#define ELFCLASSM ELFCLASS32

View File

@ -0,0 +1,105 @@
Subject: [PATCH] libpthread: AVR32 support
Implement pt-machine.h for AVR32.
---
libpthread/linuxthreads/sysdeps/avr32/pt-machine.h | 92 +++++++++++++++++++++
1 file changed, 92 insertions(+)
Index: uClibc-0.9.28/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ uClibc-0.9.28/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h 2006-02-07 17:14:47.000000000 +0100
@@ -0,0 +1,92 @@
+/* Machine-dependent pthreads configuration and inline functions.
+
+ Copyright (C) 2005 Atmel Norway
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#include <features.h>
+
+static inline int
+_test_and_set (int *p, int v) __THROW
+{
+ int result;
+
+ __asm__ __volatile__(
+ "/* Inline test and set */\n"
+ "1: ssrf 5\n"
+ " ld.w %0, %2\n"
+ " tst %0, %3\n"
+ " breq 2f\n"
+ " stcond %1, %3\n"
+ " brne 1b\n"
+ "2:"
+ : "=&r"(result), "=m"(*p)
+ : "m"(*p), "r"(v)
+ : "memory", "cc");
+
+ return result;
+}
+
+#ifndef PT_EI
+# define PT_EI extern inline
+#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+/* Spinlock implementation; required. */
+PT_EI long int
+testandset (int *spinlock)
+{
+ return _test_and_set(spinlock, 1);
+}
+
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME stack_pointer
+register char * stack_pointer __asm__ ("sp");
+
+/* Compare-and-swap for semaphores. */
+
+#define HAS_COMPARE_AND_SWAP
+PT_EI int
+__compare_and_swap(long int *p, long int oldval, long int newval)
+{
+ long int result, tmp;
+
+ __asm__ __volatile__(
+ "/* Inline compare and swap */\n"
+ "1: ssrf 5\n"
+ " ld.w %1, %3\n"
+ " cp.w %1, %5\n"
+ " sreq %0\n"
+ " brne 2f\n"
+ " stcond %2, %4\n"
+ " brne 1b\n"
+ "2:"
+ : "=&r"(result), "=&r"(tmp), "=m"(*p)
+ : "m"(*p), "r"(newval), "r"(oldval)
+ : "cc", "memory");
+
+ return result;
+}
+
+#endif /* pt-machine.h */

View File

@ -0,0 +1,54 @@
---
libc/sysdeps/linux/avr32/bits/fcntl.h | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
Index: uClibc-0.9.28-avr32/libc/sysdeps/linux/avr32/bits/fcntl.h
===================================================================
--- uClibc-0.9.28-avr32.orig/libc/sysdeps/linux/avr32/bits/fcntl.h 2006-11-23 17:38:30.000000000 +0100
+++ uClibc-0.9.28-avr32/libc/sysdeps/linux/avr32/bits/fcntl.h 2006-11-23 17:52:15.000000000 +0100
@@ -11,28 +11,29 @@
/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
located on an ext2 file system */
-#define O_ACCMODE 0003
-#define O_RDONLY 00
-#define O_WRONLY 01
-#define O_RDWR 02
-#define O_CREAT 0100 /* not fcntl */
-#define O_EXCL 0200 /* not fcntl */
-#define O_NOCTTY 0400 /* not fcntl */
-#define O_TRUNC 01000 /* not fcntl */
-#define O_APPEND 02000
-#define O_NONBLOCK 04000
+#define O_ACCMODE 00000003
+#define O_RDONLY 00000000
+#define O_WRONLY 00000001
+#define O_RDWR 00000002
+#define O_CREAT 00000100 /* not fcntl */
+#define O_EXCL 00000200 /* not fcntl */
+#define O_NOCTTY 00000400 /* not fcntl */
+#define O_TRUNC 00001000 /* not fcntl */
+#define O_APPEND 00002000
+#define O_NONBLOCK 00004000
#define O_NDELAY O_NONBLOCK
-#define O_SYNC 010000
-#define O_ASYNC 020000
+#define O_SYNC 00010000
+#define O_ASYNC 00020000
#ifdef __USE_GNU
-# define O_DIRECTORY 040000 /* must be a directory */
-# define O_NOFOLLOW 0100000 /* don't follow links */
-# define O_DIRECT 0200000 /* direct disk access */
+# define O_DIRECT 00040000 /* must be a directory */
+# define O_DIRECTORY 00200000 /* direct disk access */
+# define O_NOFOLLOW 00400000 /* don't follow links */
+# define O_NOATIME 01000000 /* don't set atime */
#endif
#ifdef __USE_LARGEFILE64
-# define O_LARGEFILE 0400000
+# define O_LARGEFILE 00100000
#endif
/* For now Linux has synchronisity options for data and read operations.