summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2012-07-31 15:17:21 +1000
committerChris Johns <chrisj@rtems.org>2012-07-31 15:17:21 +1000
commit99bdd39271de093920b34d217a5a4b7f0a6f2e80 (patch)
treef73c646e5eb6173b63dacc4097794d5c8d1af274
parent328fbd26ed0213af7e328de105921f4eb7927e55 (diff)
Add ARM support. Cleaned up the waf support.
Adding ARM support has changed the architecture relocation interface. All architectures updated. Cleaned up the RTEMS waf support to only look for tools when the arch is being processed. Add filter support to allow a user to make sure a BSP is present or to remove BSPs that will not build. Added the Init support because ARM BSPs do not contain the support.
-rw-r--r--bspinit.c95
-rw-r--r--libbsd/include/arch/arm/machine/ansi.h67
-rw-r--r--libbsd/include/arch/arm/machine/asm.h168
-rw-r--r--libbsd/include/arch/arm/machine/cdefs.h20
-rw-r--r--libbsd/include/arch/arm/machine/elf_machdep.h117
-rw-r--r--libbsd/include/arch/arm/machine/int_types.h68
-rw-r--r--main.c42
-rw-r--r--rtems.py76
-rw-r--r--rtl-elf.c21
-rw-r--r--rtl-elf.h24
-rw-r--r--rtl-mdreloc-arm.c195
-rw-r--r--rtl-mdreloc-i386.c24
-rw-r--r--rtl-mdreloc-m68k.c24
-rw-r--r--rtl-mdreloc-sparc.c22
-rw-r--r--rtl-obj.h12
-rw-r--r--rtl-sym.h1
-rw-r--r--wscript27
17 files changed, 830 insertions, 173 deletions
diff --git a/bspinit.c b/bspinit.c
new file mode 100644
index 0000000..9c50d03
--- /dev/null
+++ b/bspinit.c
@@ -0,0 +1,95 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <bsp.h>
+#include <bsp/bootcard.h>
+#ifdef RTEMS_NETWORKING
+ #include <rtems/rtems_bsdnet.h>
+#endif
+
+/*
+ * This routine calls main from a confdefs.h default Init task
+ * set up. The bootcard will provide the task argument as
+ * command line string (ASCIIZ).
+ */
+
+int main (int argc, char* argv[]);
+void Init (rtems_task_argument arg);
+
+void Init (rtems_task_argument arg)
+{
+ const char* boot_cmdline = *((const char**) arg);
+ char* cmdline = 0;
+ char* command;
+ int argc = 0;
+ char** argv = NULL;
+ int result = -124;
+
+ if (boot_cmdline)
+ {
+ cmdline = malloc (strlen (boot_cmdline) + 1);
+
+ if (cmdline)
+ {
+ strcpy (cmdline, boot_cmdline);
+
+ command = cmdline;
+
+ /*
+ * Break the line up into arguments with "" being ignored.
+ */
+ while (true)
+ {
+ command = strtok (command, " \t\r\n");
+ if (command == NULL)
+ break;
+ argc++;
+ command = '\0';
+ }
+
+ argv = calloc (argc, sizeof (char*));
+
+ if (argv)
+ {
+ int a;
+
+ command = cmdline;
+ argv[0] = command;
+
+ for (a = 1; a < argc; a++)
+ {
+ command += strlen (command) + 1;
+ argv[a] = command;
+ }
+ }
+ else
+ argc = 0;
+ }
+ }
+
+#ifdef RTEMS_NETWORKING
+ rtems_bsdnet_initialize_network ();
+#endif
+
+ result = main (argc, argv);
+
+ free (argv);
+ free (cmdline);
+
+ exit (result);
+}
+
+/*
+ * By making this a weak alias and a user can provide there own.
+ */
+
+void Init (rtems_task_argument arg) __attribute__ ((weak));
diff --git a/libbsd/include/arch/arm/machine/ansi.h b/libbsd/include/arch/arm/machine/ansi.h
new file mode 100644
index 0000000..a8271d9
--- /dev/null
+++ b/libbsd/include/arch/arm/machine/ansi.h
@@ -0,0 +1,67 @@
+/* $NetBSD: ansi.h,v 1.12 2010/03/27 22:14:09 tnozaki Exp $ */
+
+/*
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. 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. 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND 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 REGENTS OR 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.
+ *
+ * from: @(#)ansi.h 8.2 (Berkeley) 1/4/94
+ */
+
+#ifndef _ANSI_H_
+#define _ANSI_H_
+
+#include <sys/cdefs.h>
+
+#include <machine/int_types.h>
+
+/*
+ * Types which are fundamental to the implementation and may appear in
+ * more than one standard header are defined here. Standard headers
+ * then use:
+ * #ifdef _BSD_SIZE_T_
+ * typedef _BSD_SIZE_T_ size_t;
+ * #undef _BSD_SIZE_T_
+ * #endif
+ */
+#define _BSD_CLOCK_T_ unsigned int /* clock() */
+#define _BSD_PTRDIFF_T_ long int /* ptr1 - ptr2 */
+#define _BSD_SIZE_T_ unsigned long int /* sizeof() */
+#define _BSD_SSIZE_T_ long int /* byte count or error */
+#define _BSD_TIME_T_ __int64_t /* time() */
+#if __GNUC_PREREQ__(2, 96)
+#define _BSD_VA_LIST_ __builtin_va_list /* GCC built-in type */
+#else
+#define _BSD_VA_LIST_ char * /* va_list */
+#endif
+#define _BSD_CLOCKID_T_ int /* clockid_t */
+#define _BSD_TIMER_T_ int /* timer_t */
+#define _BSD_SUSECONDS_T_ int /* suseconds_t */
+#define _BSD_USECONDS_T_ unsigned int /* useconds_t */
+#define _BSD_WCHAR_T_ int /* wchar_t */
+#define _BSD_WINT_T_ int /* wint_t */
+
+#endif /* _ANSI_H_ */
diff --git a/libbsd/include/arch/arm/machine/asm.h b/libbsd/include/arch/arm/machine/asm.h
new file mode 100644
index 0000000..9b68afa
--- /dev/null
+++ b/libbsd/include/arch/arm/machine/asm.h
@@ -0,0 +1,168 @@
+/* $NetBSD: asm.h,v 1.12 2008/08/29 19:00:25 matt Exp $ */
+
+/*
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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. 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND 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 REGENTS OR 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.
+ *
+ * from: @(#)asm.h 5.5 (Berkeley) 5/7/91
+ */
+
+#ifndef _ARM32_ASM_H_
+#define _ARM32_ASM_H_
+
+#include <arm/cdefs.h>
+
+#define _C_LABEL(x) x
+#define _ASM_LABEL(x) x
+
+#ifdef __STDC__
+# define __CONCAT(x,y) x ## y
+# define __STRING(x) #x
+#else
+# define __CONCAT(x,y) x/**/y
+# define __STRING(x) "x"
+#endif
+
+#ifndef _ALIGN_TEXT
+# define _ALIGN_TEXT .align 0
+#endif
+
+/*
+ * gas/arm uses @ as a single comment character and thus cannot be used here
+ * Instead it recognised the # instead of an @ symbols in .type directives
+ * We define a couple of macros so that assembly code will not be dependant
+ * on one or the other.
+ */
+#define _ASM_TYPE_FUNCTION %function
+#define _ASM_TYPE_OBJECT %object
+#ifdef __thumb__
+#define _ENTRY(x) \
+ .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; .thumb_func; x:
+#else
+#define _ENTRY(x) \
+ .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x:
+#endif
+#define _END(x) .size x,.-x
+
+#ifdef GPROF
+# define _PROF_PROLOGUE \
+ mov ip, lr; bl __mcount
+#else
+# define _PROF_PROLOGUE
+#endif
+
+#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
+#define ENTRY_NP(y) _ENTRY(_C_LABEL(y))
+#define END(y) _END(_C_LABEL(y))
+#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
+#define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y))
+#define ASEND(y) _END(_ASM_LABEL(y))
+
+#define ASMSTR .asciz
+
+#if defined(PIC)
+#ifdef __thumb__
+#define PLT_SYM(x) x
+#define GOT_SYM(x) PIC_SYM(x, GOTOFF)
+#define GOT_GET(x,got,sym) \
+ ldr x, sym; \
+ add x, got; \
+ ldr x, [x]
+#else
+#define PLT_SYM(x) PIC_SYM(x, PLT)
+#define GOT_SYM(x) PIC_SYM(x, GOT)
+#define GOT_GET(x,got,sym) \
+ ldr x, sym; \
+ ldr x, [x, got]
+#endif /* __thumb__ */
+
+#define GOT_INIT(got,gotsym,pclabel) \
+ ldr got, gotsym; \
+ add got, got, pc; \
+ pclabel:
+#define GOT_INITSYM(gotsym,pclabel) \
+ gotsym: .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) + (. - (pclabel+4))
+
+#ifdef __STDC__
+#define PIC_SYM(x,y) x ## ( ## y ## )
+#else
+#define PIC_SYM(x,y) x/**/(/**/y/**/)
+#endif
+
+#else
+#define PLT_SYM(x) x
+#define GOT_SYM(x) x
+#define GOT_GET(x,got,sym) \
+ ldr x, sym;
+#define GOT_INIT(got,gotsym,pclabel)
+#define GOT_INITSYM(gotsym,pclabel)
+#define PIC_SYM(x,y) x
+#endif /* PIC */
+
+#define RCSID(x) .pushsection ".ident"; .asciz x; .popsection
+
+#define WEAK_ALIAS(alias,sym) \
+ .weak alias; \
+ alias = sym
+
+/*
+ * STRONG_ALIAS: create a strong alias.
+ */
+#define STRONG_ALIAS(alias,sym) \
+ .globl alias; \
+ alias = sym
+
+#define WARN_REFERENCES(sym,msg) \
+ .stabs msg,30,0,0,0 ; \
+ .stabs __STRING(_C_LABEL(sym)),1,0,0,0
+
+#ifdef __thumb__
+# define XPUSH push
+# define XPOP pop
+# define XPOPRET pop {pc}
+#else
+# define XPUSH stmfd sp!,
+# define XPOP ldmfd sp!,
+# ifdef _ARM_ARCH_5
+# define XPOPRET ldmfd sp!, {pc}
+# else
+# define XPOPRET ldmfd sp!, {lr}; mov pc, lr
+# endif
+#endif
+
+#if defined (_ARM_ARCH_4T)
+# define RET bx lr
+# define RETc(c) __CONCAT(bx,c) lr
+#else
+# define RET mov pc, lr
+# define RETc(c) __CONCAT(mov,c) pc, lr
+#endif
+
+#endif /* !_ARM_ASM_H_ */
diff --git a/libbsd/include/arch/arm/machine/cdefs.h b/libbsd/include/arch/arm/machine/cdefs.h
new file mode 100644
index 0000000..3811187
--- /dev/null
+++ b/libbsd/include/arch/arm/machine/cdefs.h
@@ -0,0 +1,20 @@
+/* $NetBSD: cdefs.h,v 1.3 2007/10/17 19:53:41 garbled Exp $ */
+
+#ifndef _MACHINE_CDEFS_H_
+#define _MACHINE_CDEFS_H_
+
+#if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__)
+#define _ARM_ARCH_6
+#endif
+
+#if defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5__) || \
+ defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5TE__) || \
+ defined (__ARM_ARCH_5TEJ__)
+#define _ARM_ARCH_5
+#endif
+
+#if defined (_ARM_ARCH_5) || defined (__ARM_ARCH_4T__)
+#define _ARM_ARCH_4T
+#endif
+
+#endif /* !_MACHINE_CDEFS_H_ */
diff --git a/libbsd/include/arch/arm/machine/elf_machdep.h b/libbsd/include/arch/arm/machine/elf_machdep.h
new file mode 100644
index 0000000..963ff64
--- /dev/null
+++ b/libbsd/include/arch/arm/machine/elf_machdep.h
@@ -0,0 +1,117 @@
+/* $NetBSD: elf_machdep.h,v 1.8 2009/05/30 05:56:52 skrll Exp $ */
+
+#if defined(__ARMEB__)
+#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB
+#else
+#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB
+#endif
+
+#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */
+#define ELF64_MACHDEP_ID_CASES \
+ /* no 64-bit ELF machine types supported */
+
+/* Processor specific flags for the ELF header e_flags field. */
+#define EF_ARM_RELEXEC 0x00000001
+#define EF_ARM_HASENTRY 0x00000002
+#define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */
+#define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */
+#define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */
+#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */
+#define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */
+#define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */
+#define EF_ARM_PIC 0x00000020
+#define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */
+#define EF_ARM_NEW_ABI 0x00000080
+#define EF_ARM_OLD_ABI 0x00000100
+#define EF_ARM_SOFT_FLOAT 0x00000200
+#define EF_ARM_EABIMASK 0xff000000
+
+#define ELF32_MACHDEP_ID_CASES \
+ case EM_ARM: \
+ break;
+
+#define ELF32_MACHDEP_ID EM_ARM
+
+#define ARCH_ELFSIZE 32 /* MD native binary size */
+
+/* Processor specific relocation types */
+
+#define R_ARM_NONE 0
+#define R_ARM_PC24 1
+#define R_ARM_ABS32 2
+#define R_ARM_REL32 3
+#define R_ARM_PC13 4
+#define R_ARM_ABS16 5
+#define R_ARM_ABS12 6
+#define R_ARM_THM_ABS5 7
+#define R_ARM_ABS8 8
+#define R_ARM_SBREL32 9
+#define R_ARM_THM_PC22 10
+#define R_ARM_THM_PC8 11
+#define R_ARM_AMP_VCALL9 12
+#define R_ARM_SWI24 13
+#define R_ARM_THM_SWI8 14
+#define R_ARM_XPC25 15
+#define R_ARM_THM_XPC22 16
+
+/* TLS relocations */
+#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */
+#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */
+#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */
+
+/* 20-31 are reserved for ARM Linux. */
+#define R_ARM_COPY 20
+#define R_ARM_GLOB_DAT 21
+#define R_ARM_JUMP_SLOT 22
+#define R_ARM_RELATIVE 23
+#define R_ARM_GOTOFF 24
+#define R_ARM_GOTPC 25
+#define R_ARM_GOT32 26
+#define R_ARM_PLT32 27
+
+#define R_ARM_ALU_PCREL_7_0 32
+#define R_ARM_ALU_PCREL_15_8 33
+#define R_ARM_ALU_PCREL_23_15 34
+#define R_ARM_ALU_SBREL_11_0 35
+#define R_ARM_ALU_SBREL_19_12 36
+#define R_ARM_ALU_SBREL_27_20 37
+
+/* 96-111 are reserved to G++. */
+#define R_ARM_GNU_VTENTRY 100
+#define R_ARM_GNU_VTINHERIT 101
+#define R_ARM_THM_PC11 102
+#define R_ARM_THM_PC9 103
+
+/* More TLS relocations */
+#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic */
+#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic */
+#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS */
+#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of */
+#define R_ARM_TLS_LE32 108
+#define R_ARM_TLS_LDO12 109
+#define R_ARM_TLS_LE12 110
+#define R_ARM_TLS_IE12GP 111
+
+/* 112-127 are reserved for private experiments. */
+
+#define R_ARM_RXPC25 249
+#define R_ARM_RSBREL32 250
+#define R_ARM_THM_RPC22 251
+#define R_ARM_RREL32 252
+#define R_ARM_RABS32 253
+#define R_ARM_RPC24 254
+#define R_ARM_RBASE 255
+
+#define R_TYPE(name) __CONCAT(R_ARM_,name)
+
+/* Processor specific program header flags */
+#define PF_ARM_SB 0x10000000
+#define PF_ARM_PI 0x20000000
+#define PF_ARM_ENTRY 0x80000000
+
+/* Processor specific section header flags */
+#define SHF_ENTRYSECT 0x10000000
+#define SHF_COMDEF 0x80000000
+
+/* Processor specific symbol types */
+#define STT_ARM_TFUNC STT_LOPROC
diff --git a/libbsd/include/arch/arm/machine/int_types.h b/libbsd/include/arch/arm/machine/int_types.h
new file mode 100644
index 0000000..89b0b1d
--- /dev/null
+++ b/libbsd/include/arch/arm/machine/int_types.h
@@ -0,0 +1,68 @@
+/* $NetBSD: int_types.h,v 1.9 2008/08/29 19:08:29 matt Exp $ */
+
+/*
+ * Copyright (c) 1990 The Regents of the University of California.
+ * 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. 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND 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 REGENTS OR 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.
+ *
+ * from: @(#)types.h 7.5 (Berkeley) 3/9/91
+ */
+
+#ifndef _ARM32_INT_TYPES_H_
+#define _ARM32_INT_TYPES_H_
+
+#include <sys/cdefs.h>
+
+/*
+ * 7.18.1 Integer types
+ */
+
+/* 7.18.1.1 Exact-width integer types */
+
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef short int __int16_t;
+typedef unsigned short int __uint16_t;
+typedef int __int32_t;
+typedef unsigned int __uint32_t;
+#ifdef __COMPILER_INT64__
+typedef __COMPILER_INT64__ __int64_t;
+typedef __COMPILER_UINT64__ __uint64_t;
+#else
+/* LONGLONG */
+typedef long long int __int64_t;
+/* LONGLONG */
+typedef unsigned long long int __uint64_t;
+#endif
+
+#define __BIT_TYPES_DEFINED__
+
+/* 7.18.1.4 Integer types capable of holding object pointers */
+
+typedef long int __intptr_t;
+typedef unsigned long int __uintptr_t;
+
+#endif /* !_ARM32_INT_TYPES_H_ */
diff --git a/main.c b/main.c
index 188d4b3..9586502 100644
--- a/main.c
+++ b/main.c
@@ -229,7 +229,7 @@ setup_ramdisk (void)
{
rtems_device_major_number major;
rtems_status_code sc;
-
+
/*
* Register the RAM Disk driver.
*/
@@ -243,7 +243,7 @@ setup_ramdisk (void)
rtems_status_text (sc));
return 1;
}
-
+
printf ("successful\n");
return 0;
@@ -255,7 +255,7 @@ setup_flashdisk (void)
#if RTEMS_APP_FLASHDISK
rtems_device_major_number major;
rtems_status_code sc;
-
+
/*
* Register the Flash Disk driver.
*/
@@ -269,7 +269,7 @@ setup_flashdisk (void)
rtems_status_text (sc));
return 1;
}
-
+
printf ("successful\n");
#endif
return 0;
@@ -304,9 +304,9 @@ static int
setup_rootfs (void)
{
rtems_status_code sc;
-
+
printf("Loading filesystem: ");
-
+
sc = Untar_FromMemory((void *)(&TARFILE_START), (size_t)&TARFILE_SIZE);
if (sc != RTEMS_SUCCESSFUL)
@@ -314,7 +314,7 @@ setup_rootfs (void)
printf ("error: untar failed: %s\n", rtems_status_text (sc));
return 1;
}
-
+
printf ("successful\n");
return 0;
@@ -327,7 +327,7 @@ shell_flash_erase (int argc, char* argv[])
const char* driver = NULL;
int arg;
int fd;
-
+
for (arg = 1; arg < argc; arg++)
{
if (argv[arg][0] == '-')
@@ -346,24 +346,24 @@ shell_flash_erase (int argc, char* argv[])
}
}
}
-
+
printf ("erase flash disk: %s\n", driver);
-
+
fd = open (driver, O_WRONLY, 0);
if (fd < 0)
{
printf ("error: flash driver open failed: %s\n", strerror (errno));
return 1;
}
-
+
if (ioctl (fd, RTEMS_FDISK_IOCTL_ERASE_DISK) < 0)
{
printf ("error: flash driver erase failed: %s\n", strerror (errno));
return 1;
}
-
+
close (fd);
-
+
printf ("flash disk erased successful\n");
#endif
return 0;
@@ -388,21 +388,21 @@ main (int argc, char* argv[])
cfsetospeed (&term, B115200);
if (tcsetattr (fileno(stdout), TCSADRAIN, &term) < 0)
printf ("error: cannot set terminal attributes: %s\n", strerror (errno));
-
+
if (tcgetattr(fileno(stdin), &term) < 0)
printf ("error: cannot get terminal attributes: %s\n", strerror (errno));
cfsetispeed (&term, B115200);
cfsetospeed (&term, B115200);
if (tcsetattr (fileno(stdin), TCSADRAIN, &term) < 0)
printf ("error: cannot set terminal attributes: %s\n", strerror (errno));
-
+
printf ("\nRTEMS Run Time Link Editor Test, Version " \
PACKAGE_VERSION "\n\n");
ret = setup_ramdisk ();
if (ret)
exit (ret);
-
+
ret = setup_flashdisk ();
if (ret)
exit (ret);
@@ -410,11 +410,11 @@ main (int argc, char* argv[])
ret = setup_idedisk ("/dev/hda");
if (ret)
exit (ret);
-
+
ret = setup_idedisk ("/dev/hdb");
if (ret)
exit (ret);
-
+
ret = setup_rootfs ();
if (ret)
exit (ret);
@@ -424,7 +424,7 @@ main (int argc, char* argv[])
"RLT trace",
rtems_rtl_trace_shell_command);
#endif
-
+
rtems_shell_add_cmd ("fderase", "misc",
"fderase driver", shell_flash_erase);
rtems_shell_add_cmd ("rtl", "misc",
@@ -437,12 +437,12 @@ main (int argc, char* argv[])
"symbol search file", shell_dlsym);
rtems_shell_add_cmd ("dlx", "misc",
"execute a call to the symbol", shell_dlcall);
-
+
shell_init_script ();
while (true)
shell_start ();
-
+
rtems_task_delete (RTEMS_SELF);
return 0;
diff --git a/rtems.py b/rtems.py
index ec441e1..b3b8118 100644
--- a/rtems.py
+++ b/rtems.py
@@ -12,6 +12,8 @@ default_version = '4.11'
default_label = 'rtems-' + default_version
default_path = '/opt/' + default_label
+rtems_filters = None
+
def options(opt):
opt.add_option('--rtems',
default = default_path,
@@ -39,7 +41,9 @@ def options(opt):
dest = 'show_commands',
help = 'Print the commands as strings.')
-def init(ctx):
+def init(ctx, filters = None):
+ global rtems_filters
+
try:
import waflib.Options
import waflib.ConfigSet
@@ -51,6 +55,11 @@ def init(ctx):
env.load(waflib.Options.lockfile)
#
+ # Set the RTEMS filter to the context.
+ #
+ rtems_filters = filters
+
+ #
# Check the tools, architectures and bsps.
#
rtems_tools, archs, arch_bsps = check_options(ctx,
@@ -100,15 +109,17 @@ def configure(conf):
conf.options.rtems_bsps)
_log_header(conf)
- conf.to_log('Architectures: ' + ','.join(archs))
- tools = _find_tools(conf, archs, rtems_tools)
+ conf.msg('Architectures', ', '.join(archs), 'YELLOW')
+ tools = {}
env = conf.env
for ab in arch_bsps:
conf.setenv(ab, env)
+ conf.msg('Board Support Package', ab, 'YELLOW')
+
arch = _arch_from_arch_bsp(ab)
conf.env.RTEMS_PATH = conf.options.rtems_path
@@ -118,6 +129,7 @@ def configure(conf):
conf.env.RTEMS_ARCH_RTEMS = arch
conf.env.RTEMS_BSP = _bsp_from_arch_bsp(ab)
+ tools = _find_tools(conf, arch, rtems_tools, tools)
for t in tools[arch]:
conf.env[t] = tools[arch][t]
@@ -135,11 +147,11 @@ def configure(conf):
# Hack to work around NIOS2 naming.
#
if conf.env.RTEMS_ARCH in ['nios2']:
- objcopy_format = 'elf32-little' + conf.env.RTEMS_ARCH
+ conf.env.OBJCOPY_FLAGS = ['-O', 'elf32-littlenios2']
+ elif conf.env.RTEMS_ARCH in ['arm']:
+ conf.env.OBJCOPY_FLAGS = ['-I', 'binary', '-O', 'elf32-littlearm']
else:
- objcopy_format = 'elf32-' + conf.env.RTEMS_ARCH
-
- conf.env.OBJCOPY_FLAGS = ['-O ', objcopy_format]
+ conf.env.OBJCOPY_FLAGS = ['-O', 'elf32-' + conf.env.RTEMS_ARCH]
conf.env.SHOW_COMMANDS = show_commands
@@ -185,6 +197,11 @@ def check_options(ctx, rtems_tools, rtems_path, rtems_version, rtems_archs, rtem
tools = None
#
+ # Filter the tools.
+ #
+ tools = filter(ctx, 'tools', tools)
+
+ #
# Match the archs requested against the ones found. If the user
# wants all (default) set all used.
#
@@ -193,6 +210,14 @@ def check_options(ctx, rtems_tools, rtems_path, rtems_version, rtems_archs, rtem
else:
archs = _check_archs(rtems_config, rtems_archs, rtems_path, rtems_version)
+ #
+ # Filter the architectures.
+ #
+ archs = filter(ctx, 'archs', archs)
+
+ #
+ # We some.
+ #
if len(archs) == 0:
ctx.fatal('Could not find any architectures')
@@ -208,6 +233,11 @@ def check_options(ctx, rtems_tools, rtems_path, rtems_version, rtems_archs, rtem
if len(arch_bsps) == 0:
ctx.fatal('No valid arch/bsps found')
+ #
+ # Filter the bsps.
+ #
+ arch_bsps = filter(ctx, 'bsps', arch_bsps)
+
return tools, archs, arch_bsps
def arch(arch_bsp):
@@ -222,6 +252,33 @@ def arch_bsps(ctx):
def arch_bsp_env(ctx, arch_bsp):
return ctx.env_of_name(arch_bsp).derive()
+def filter(ctx, filter, items):
+ if rtems_filters is None:
+ return items
+ if type(rtems_filters) is not dict:
+ ctx.fatal("Invalid RTEMS filter type, ie { 'tools': { 'in': [], 'out': [] }, 'arch': {}, 'bsps': {} }")
+ if filter not in rtems_filters:
+ return items
+ items_in = []
+ items_out = []
+ filtered_items = []
+ if 'in' in rtems_filters[filter]:
+ items_in = rtems_filters[filter]['in']
+ if 'out' in rtems_filters[filter]:
+ items_out = rtems_filters[filter]['out']
+ for i in items:
+ ab = '%s/%s' % (arch(i), bsp(i))
+ if ab in items_out:
+ i = None
+ elif ab in items_in:
+ items_in.remove(ab)
+ if i is not None:
+ filtered_items += [i]
+ if len(items_in) != 0:
+ ctx.fatal('Following %s not found: %s' % (filter, ', '.join(items_in)))
+ filtered_items.sort()
+ return filtered_items
+
def clone_tasks(bld):
if bld.cmd == 'build':
for obj in bld.all_task_gen[:]:
@@ -272,9 +329,8 @@ def output_command_line():
Task.__str__ = display
-def _find_tools(conf, archs, paths):
- tools = {}
- for arch in archs:
+def _find_tools(conf, arch, paths, tools):
+ if arch not in tools:
arch_tools = {}
arch_tools['CC'] = conf.find_program([arch + '-gcc'], path_list = paths)
arch_tools['CXX'] = conf.find_program([arch + '-g++'], path_list = paths)
diff --git a/rtl-elf.c b/rtl-elf.c
index b8a7847..3b7d231 100644
--- a/rtl-elf.c
+++ b/rtl-elf.c
@@ -234,19 +234,21 @@ rtems_rtl_elf_relocator (rtems_rtl_obj_t* obj,
if (is_rela)
{
if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
- printf ("rtl: rela: sym:%-2d type:%-2d off:%08lx addend:%d\n",
- (int) ELF_R_SYM (rela->r_info), (int) ELF_R_TYPE (rela->r_info),
+ printf ("rtl: rela: sym:%s(%-2d) type:%-2d off:%08lx addend:%d\n",
+ symname, (int) ELF_R_SYM (rela->r_info), (int) ELF_R_TYPE (rela->r_info),
rela->r_offset, (int) rela->r_addend);
- if (!rtems_rtl_elf_relocate_rela (obj, rela, targetsect, symvalue))
+ if (!rtems_rtl_elf_relocate_rela (obj, rela, targetsect,
+ symname, sym.st_info, symvalue))
return false;
}
else
{
if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
- printf ("rtl: rel: sym:%-2d type:%-2d off:%08lx\n",
- (int) ELF_R_SYM (rel->r_info), (int) ELF_R_TYPE (rel->r_info),
+ printf ("rtl: rel: sym:%s(%-2d) type:%-2d off:%08lx\n",
+ symname, (int) ELF_R_SYM (rel->r_info), (int) ELF_R_TYPE (rel->r_info),
rel->r_offset);
- if (!rtems_rtl_elf_relocate_rel (obj, rel, targetsect, symvalue))
+ if (!rtems_rtl_elf_relocate_rel (obj, rel, targetsect,
+ symname, sym.st_info, symvalue))
return false;
}
}
@@ -289,7 +291,8 @@ rtems_rtl_obj_relocate_unresolved (rtems_rtl_unresolv_reloc_t* reloc,
printf ("rtl: rela: sym:%-2d type:%-2d off:%08lx addend:%d\n",
(int) ELF_R_SYM (rela.r_info), (int) ELF_R_TYPE (rela.r_info),
rela.r_offset, (int) rela.r_addend);
- if (!rtems_rtl_elf_relocate_rela (reloc->obj, &rela, sect, symvalue))
+ if (!rtems_rtl_elf_relocate_rela (reloc->obj, &rela, sect,
+ sym->name, sym->data, symvalue))
return false;
}
else
@@ -301,7 +304,8 @@ rtems_rtl_obj_relocate_unresolved (rtems_rtl_unresolv_reloc_t* reloc,
printf ("rtl: rel: sym:%-2d type:%-2d off:%08lx\n",
(int) ELF_R_SYM (rel.r_info), (int) ELF_R_TYPE (rel.r_info),
rel.r_offset);
- if (!rtems_rtl_elf_relocate_rel (reloc->obj, &rel, sect, symvalue))
+ if (!rtems_rtl_elf_relocate_rel (reloc->obj, &rel, sect,
+ sym->name, sym->data, symvalue))
return false;
}
@@ -468,6 +472,7 @@ rtems_rtl_elf_symbols (rtems_rtl_obj_t* obj,
gsym->name = string;
string += strlen (name) + 1;
gsym->value = symbol.st_value + (uint8_t*) symsect->base;
+ gsym->data = symbol.st_info;
if (rtems_rtl_trace (RTEMS_RTL_TRACE_SYMBOL))
printf ("rtl: sym:add:%-2d name:%-2d:%-20s bind:%-2d type:%-2d val:%8p sect:%d size:%d\n",
diff --git a/rtl-elf.h b/rtl-elf.h
index a07c848..cafc4ce 100644
--- a/rtl-elf.h
+++ b/rtl-elf.h
@@ -72,14 +72,18 @@ bool rtems_rtl_elf_rel_resolve_sym (Elf_Word type);
* @param obj The object file being relocated.
* @param rel The ELF relocation record.
* @param sect The section of the object file the relocation is for.
+ * @param symname The symbol's name.
+ * @param syminfo The ELF symbol info field.
* @param symvalue If a symbol is referenced, this is the symbols value.
* @retval bool The relocation has been applied.
* @retval bool The relocation could not be applied.
*/
-bool rtems_rtl_elf_relocate_rel (rtems_rtl_obj_t* obj,
- const Elf_Rel* rel,
- rtems_rtl_obj_sect_t* sect,
- Elf_Word symvalue);
+bool rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj,
+ const Elf_Rel* rel,
+ const rtems_rtl_obj_sect_t* sect,
+ const char* symname,
+ const Elf_Byte syminfo,
+ const Elf_Word symvalue);
/**
* Architecture specific relocation handler compiled in for a specific
@@ -89,14 +93,18 @@ bool rtems_rtl_elf_relocate_rel (rtems_rtl_obj_t* obj,
* @param obj The object file being relocated.
* @param rela The ELF addend relocation record.
* @param sect The section of the object file the relocation is for.
+ * @param symname The symbol's name.
+ * @param syminfo The ELF symbol info field.
* @param symvalue If a symbol is referenced, this is the symbols value.
* @retval bool The relocation has been applied.
* @retval bool The relocation could not be applied.
*/
-bool rtems_rtl_elf_relocate_rela (rtems_rtl_obj_t* obj,
- const Elf_Rela* rela,
- rtems_rtl_obj_sect_t* sect,
- Elf_Word symvalue);
+bool rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
+ const Elf_Rela* rela,
+ const rtems_rtl_obj_sect_t* sect,
+ const char* symname,
+ const Elf_Byte syminfo,
+ const Elf_Word symvalue);
/**
* Find the symbol. The symbol is passed as an ELF type symbol with the name
diff --git a/rtl-mdreloc-arm.c b/rtl-mdreloc-arm.c
index 0e4f3e9..e55da1f 100644
--- a/rtl-mdreloc-arm.c
+++ b/rtl-mdreloc-arm.c
@@ -20,132 +20,149 @@
* It is possible for the compiler to emit relocations for unaligned data.
* We handle this situation with these inlines.
*/
-#define RELOC_ALIGNED_P(x) \
- (((uintptr_t)(x) & (sizeof(void *) - 1)) == 0)
+#define RELOC_ALIGNED_P(x) \
+ (((uintptr_t)(x) & (sizeof(void *) - 1)) == 0)
static inline Elf_Addr
-load_ptr (void *where)
+load_ptr(void *where)
{
- Elf_Addr res;
- memcpy (&res, where, sizeof(res));
- return (res);
+ Elf_Addr res;
+
+ memcpy(&res, where, sizeof(res));
+
+ return (res);
}
static inline void
-store_ptr (void *where, Elf_Addr val)
+store_ptr(void *where, Elf_Addr val)
+{
+
+ memcpy(where, &val, sizeof(val));
+}
+
+bool
+rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
{
- memcpy(where, &val, sizeof(val));
+ return true;
}
bool
-rtems_rtl_elf_relocate_rela (rtems_rtl_obj_t* obj,
- const Elf_Rela* rela,
- rtems_rtl_obj_sect_t* sect,
- const Elf_Sym* sym,
- const char* symname)
+rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
+ const Elf_Rela* rela,
+ const rtems_rtl_obj_sect_t* sect,
+ const char* symname,
+ const Elf_Byte syminfo,
+ const Elf_Word symvalue)
{
- printf ("rtl: rela record not supported; please report\n");
+ rtems_rtl_set_error (EINVAL, "rela type record not supported");
return false;
}
bool
-rtems_rtl_elf_relocate_rel (rtems_rtl_obj_t* obj,
- const Elf_Rel* rel,
- rtems_rtl_obj_sect_t* sect,
- const Elf_Sym* sym,
- const char* symname)
+rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj,
+ const Elf_Rel* rel,
+ const rtems_rtl_obj_sect_t* sect,
+ const char* symname,
+ const Elf_Byte syminfo,
+ const Elf_Word symvalue)
{
- Elf_Addr target = 0;
- Elf_Addr* where;
+ Elf_Addr *where;
Elf_Addr tmp;
- Elf_Word symvalue;
where = (Elf_Addr *)(sect->base + rel->r_offset);
switch (ELF_R_TYPE(rel->r_info)) {
- case R_TYPE(NONE):
- break;
+ case R_TYPE(NONE):
+ break;
- case R_TYPE(PC24): { /* word32 S - P + A */
- Elf32_Sword addend;
+#if 1 /* XXX should not occur */
+ case R_TYPE(PC24): { /* word32 S - P + A */
+ Elf32_Sword addend;
- /*
- * Extract addend and sign-extend if needed.
- */
- addend = *where;
- if (addend & 0x00800000)
- addend |= 0xff000000;
+ /*
+ * Extract addend and sign-extend if needed.
+ */
+ addend = *where;
+ if (addend & 0x00800000)
+ addend |= 0xff000000;
- if (!rtems_rtl_elf_find_symbol (obj, sym, symname, &symvalue))
- return false;
+ tmp = (Elf_Addr)sect->base + symvalue
+ - (Elf_Addr)where + (addend << 2);
- tmp = (Elf_Addr) symvalue - (Elf_Addr) where + (addend << 2);
if ((tmp & 0xfe000000) != 0xfe000000 &&
- (tmp & 0xfe000000) != 0) {
- rtems_rtl_set_error ("%s: R_ARM_PC24 relocation @ %p to %s failed "
+ (tmp & 0xfe000000) != 0) {
+ rtems_rtl_set_error (EINVAL,
+ "R_ARM_PC24 in %s relocation @ %p failed " \
"(displacement %ld (%#lx) out of range)",
- obj->oname, where, symname,
- (long) tmp, (long) tmp);
- return false;
- }
- tmp >>= 2;
- *where = (*where & 0xff000000) | (tmp & 0x00ffffff);
+ rtems_rtl_obj_oname (obj), where, (long) tmp, (long) tmp);
+ return false;
+ }
+
+ tmp >>= 2;
+ *where = (*where & 0xff000000) | (tmp & 0x00ffffff);
if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
- printf ("rtl: reloc PC24 %s in %s --> %p @ %p\n",
- symname, obj->oname, (void *)*where, where);
- break;
- }
-
- case R_TYPE(ABS32): /* word32 B + S + A */
- case R_TYPE(GLOB_DAT): /* word32 B + S */
- if (!rtems_rtl_elf_find_symbol (obj, sym, symname, &symvalue))
- return false;
-
- if (__predict_true (RELOC_ALIGNED_P (where))) {
- tmp = *where + symvalue;
- /* Set the Thumb bit, if needed. */
- if (ELF_ST_TYPE(def->st_info) == STT_ARM_TFUNC)
- tmp |= 1;
- *where = tmp;
- } else {
- tmp = load_ptr (where) + symvalue;
- /* Set the Thumb bit, if needed. */
- if (ELF_ST_TYPE(def->st_info) == STT_ARM_TFUNC)
+ printf ("rtl: PC24 %p @ %p in %s",
+ (void *)*where, where, rtems_rtl_obj_oname (obj));
+ break;
+ }
+#endif
+
+ case R_TYPE(ABS32): /* word32 B + S + A */
+ case R_TYPE(GLOB_DAT): /* word32 B + S */
+ if (__predict_true(RELOC_ALIGNED_P(where))) {
+ tmp = *where + (Elf_Addr)sect->base + symvalue;
+ /* Set the Thumb bit, if needed. */
+ if (ELF_ST_TYPE(syminfo) == STT_ARM_TFUNC)
tmp |= 1;
- store_ptr (where, tmp);
- }
+ *where = tmp;
+ } else {
+ tmp = load_ptr(where) + symvalue;
+ /* Set the Thumb bit, if needed. */
+ if (ELF_ST_TYPE(syminfo) == STT_ARM_TFUNC)
+ tmp |= 1;
+ store_ptr(where, tmp);
+ }
if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
- printf ("rtl: reloc ABS32/GLOB_DAT %s in %s --> %p @ %p\n",
- symname, obj->oname, (void *)tmp, where);
- break;
-
- case R_TYPE(RELATIVE): /* word32 B + A */
- if (__predict_true (RELOC_ALIGNED_P (where))) {
- tmp = *where + (Elf_Addr) sect->base;
- *where = tmp;
- } else {
- tmp = load_ptr (where) + (Elf_Addr) sect->base;
- store_ptr (where, tmp);
- }
+ printf ("rtl: ABS32/GLOB_DAT %p @ %p in %s",
+ (void *)tmp, where, rtems_rtl_obj_oname (obj));
+ break;
+
+ case R_TYPE(RELATIVE): /* word32 B + A */
+ if (__predict_true(RELOC_ALIGNED_P(where))) {
+ tmp = *where + (Elf_Addr)sect->base;
+ *where = tmp;
+ } else {
+ tmp = load_ptr(where) + (Elf_Addr)sect->base;
+ store_ptr(where, tmp);
+ }
if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
- printf ("rtl: reloc RELATIVE in %s --> %p", obj->oname, (void *)tmp));
- break;
-
- case R_TYPE(COPY):
- printf ("rtl: reloc COPY (please report)\n");
- break;
+ printf ("rtl: RELATIVE in %s --> %p",
+ rtems_rtl_obj_oname (obj), (void *)tmp);
+ break;
+
+ case R_TYPE(COPY):
+ /*
+ * These are deferred until all other relocations have
+ * been done. All we do here is make sure that the
+ * COPY relocation is not in a shared library. They
+ * are allowed only in executable files.
+ */
+ if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
+ printf ("rtl: COPY (avoid in main)");
+ break;
- default:
+ default:
printf ("rtl: reloc unknown: sym = %lu, type = %lu, offset = %p, "
- "contents = %p, symbol = %s\n",
+ "contents = %p\n",
ELF_R_SYM(rel->r_info), (uint32_t) ELF_R_TYPE(rel->r_info),
- (void *)rel->r_offset, (void *)*where, symname);
+ (void *)rel->r_offset, (void *)*where);
rtems_rtl_set_error (EINVAL,
"%s: Unsupported relocation type %ld "
"in non-PLT relocations",
sect->name, (uint32_t) ELF_R_TYPE(rel->r_info));
- return false;
+ return false;
}
-
- return true;
+
+ return true;
}
+
diff --git a/rtl-mdreloc-i386.c b/rtl-mdreloc-i386.c
index db46cb3..309498f 100644
--- a/rtl-mdreloc-i386.c
+++ b/rtl-mdreloc-i386.c
@@ -23,20 +23,24 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
}
bool
-rtems_rtl_elf_relocate_rela (rtems_rtl_obj_t* obj,
- const Elf_Rela* rela,
- rtems_rtl_obj_sect_t* sect,
- Elf_Word symvalue)
+rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj,
+ const Elf_Rel* rel,
+ const rtems_rtl_obj_sect_t* sect,
+ const char* symname,
+ const Elf_Byte syminfo,
+ const Elf_Word symvalue)
{
- printf ("rtl: rela record not supported; please report\n");
+ rtems_rtl_set_error (EINVAL, "rela type record not supported");
return false;
}
bool
-rtems_rtl_elf_relocate_rel (rtems_rtl_obj_t* obj,
- const Elf_Rel* rel,
- rtems_rtl_obj_sect_t* sect,
- Elf_Word symvalue)
+rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
+ const Elf_Rela* rel,
+ const rtems_rtl_obj_sect_t* sect,
+ const char* symname,
+ const Elf_Byte syminfo,
+ const Elf_Word symvalue)
{
Elf_Addr target = 0;
Elf_Addr* where;
@@ -94,6 +98,6 @@ rtems_rtl_elf_relocate_rel (rtems_rtl_obj_t* obj,
sect->name, (uint32_t) ELF_R_TYPE(rel->r_info));
return false;
}
-
+
return true;
}
diff --git a/rtl-mdreloc-m68k.c b/rtl-mdreloc-m68k.c
index 917d052..d9459ff 100644
--- a/rtl-mdreloc-m68k.c
+++ b/rtl-mdreloc-m68k.c
@@ -23,14 +23,16 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
}
bool
-rtems_rtl_elf_relocate_rela (rtems_rtl_obj_t* obj,
- const Elf_Rela* rela,
- rtems_rtl_obj_sect_t* sect,
- Elf_Word symvalue)
+rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
+ const Elf_Rela* rela,
+ const rtems_rtl_obj_sect_t* sect,
+ const char* symnane,
+ const Elf_Byte syminfo,
+ const Elf_Word symvalue)
{
Elf_Addr target = 0;
Elf_Addr* where;
-
+
where = (Elf_Addr *)(sect->base + rela->r_offset);
switch (ELF_R_TYPE(rela->r_info)) {
@@ -94,11 +96,13 @@ rtems_rtl_elf_relocate_rela (rtems_rtl_obj_t* obj,
}
bool
-rtems_rtl_elf_relocate_rel (rtems_rtl_obj_t* obj,
- const Elf_Rel* rel,
- rtems_rtl_obj_sect_t* sect,
- Elf_Word symvalue)
+rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj,
+ const Elf_Rel* rel,
+ const rtems_rtl_obj_sect_t* sect,
+ const char* symname,
+ const Elf_Byte syminfo,
+ const Elf_Word symvalue)
{
- printf ("rtl: rel type record not supported; please report\n");
+ rtems_rtl_set_error (EINVAL, "rel type record not supported");
return false;
}
diff --git a/rtl-mdreloc-sparc.c b/rtl-mdreloc-sparc.c
index 697f039..7bc3412 100644
--- a/rtl-mdreloc-sparc.c
+++ b/rtl-mdreloc-sparc.c
@@ -124,7 +124,7 @@ static const int reloc_target_bitmask[] = {
_BM(22), _BM(22), /* HI22, _22 */
_BM(13), _BM(10), /* RELOC_13, _LO10 */
_BM(10), _BM(13), _BM(22), /* GOT10, GOT13, GOT22 */
- _BM(10), _BM(22), /* _PC10, _PC22 */
+ _BM(10), _BM(22), /* _PC10, _PC22 */
_BM(30), 0, /* _WPLT30, _COPY */
-1, -1, -1, /* _GLOB_DAT, JMP_SLOT, _RELATIVE */
_BM(32) /* _UA32 */
@@ -139,10 +139,12 @@ rtems_rtl_elf_rel_resolve_sym (Elf_Word type)
}
bool
-rtems_rtl_elf_relocate_rela (rtems_rtl_obj_t* obj,
- const Elf_Rela* rela,
- rtems_rtl_obj_sect_t* sect,
- Elf_Word symvalue)
+rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
+ const Elf_Rela* rela,
+ const rtems_rtl_obj_sect_t* sect,
+ const char* symname,
+ const Elf_Byte syminfo,
+ const Elf_Word symvalue)
{
Elf_Addr *where;
Elf_Word type, value, mask;
@@ -246,10 +248,12 @@ rtems_rtl_elf_relocate_rela (rtems_rtl_obj_t* obj,
}
bool
-rtems_rtl_elf_relocate_rel (rtems_rtl_obj_t* obj,
- const Elf_Rel* rel,
- rtems_rtl_obj_sect_t* sect,
- Elf_Word symvalue)
+rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj,
+ const Elf_Rel* rel,
+ const rtems_rtl_obj_sect_t* sect,
+ const char* symname,
+ const Elf_Byte syminfo,
+ const Elf_Word symvalue)
{
printf ("rtl: rel type record not supported; please report\n");
return false;
diff --git a/rtl-obj.h b/rtl-obj.h
index dcf2b65..d1c9387 100644
--- a/rtl-obj.h
+++ b/rtl-obj.h
@@ -135,7 +135,7 @@ typedef bool (*rtems_rtl_obj_sect_handler_t)(rtems_rtl_obj_t* obj,
* @param obj The object file.
* @return const char* The string.
*/
-static inline const char* rtems_rtl_obj_fname (rtems_rtl_obj_t* obj)
+static inline const char* rtems_rtl_obj_fname (const rtems_rtl_obj_t* obj)
{
return obj->fname;
}
@@ -146,7 +146,7 @@ static inline const char* rtems_rtl_obj_fname (rtems_rtl_obj_t* obj)
* @param obj The object file.
* @return bool There is a file name
*/
-static inline bool rtems_rtl_obj_fname_valid (rtems_rtl_obj_t* obj)
+static inline bool rtems_rtl_obj_fname_valid (const rtems_rtl_obj_t* obj)
{
return obj->fname;
}
@@ -157,7 +157,7 @@ static inline bool rtems_rtl_obj_fname_valid (rtems_rtl_obj_t* obj)
* @param obj The object file.
* @return const char* The string.
*/
-static inline const char* rtems_rtl_obj_oname (rtems_rtl_obj_t* obj)
+static inline const char* rtems_rtl_obj_oname (const rtems_rtl_obj_t* obj)
{
return obj->oname;
}
@@ -168,7 +168,7 @@ static inline const char* rtems_rtl_obj_oname (rtems_rtl_obj_t* obj)
* @param obj The object file.
* @return bool There is an object name
*/
-static inline bool rtems_rtl_obj_oname_valid (rtems_rtl_obj_t* obj)
+static inline bool rtems_rtl_obj_oname_valid (const rtems_rtl_obj_t* obj)
{
return obj->oname;
}
@@ -179,7 +179,7 @@ static inline bool rtems_rtl_obj_oname_valid (rtems_rtl_obj_t* obj)
* @param obj The object file.
* @return const char* The string.
*/
-static inline const char* rtems_rtl_obj_aname (rtems_rtl_obj_t* obj)
+static inline const char* rtems_rtl_obj_aname (const rtems_rtl_obj_t* obj)
{
return obj->aname;
}
@@ -190,7 +190,7 @@ static inline const char* rtems_rtl_obj_aname (rtems_rtl_obj_t* obj)
* @param obj The object file.
* @return bool There is an archive name
*/
-static inline bool rtems_rtl_obj_aname_valid (rtems_rtl_obj_t* obj)
+static inline bool rtems_rtl_obj_aname_valid (const rtems_rtl_obj_t* obj)
{
return obj->aname;
}
diff --git a/rtl-sym.h b/rtl-sym.h
index 26e6902..761c23b 100644
--- a/rtl-sym.h
+++ b/rtl-sym.h
@@ -31,6 +31,7 @@ typedef struct rtems_rtl_obj_sym_s
rtems_chain_node node; /**< The node's link in the chain. */
const char* name; /**< The symbol's name. */
void* value; /**< The value of the symbol. */
+ uint32_t data; /**< Format specific data. */
} rtems_rtl_obj_sym_t;
/**
diff --git a/wscript b/wscript
index 7584fa5..74e8a64 100644
--- a/wscript
+++ b/wscript
@@ -5,8 +5,22 @@ import rtems
version = "1.0.0"
+#
+# Filter out BSPs in the ARM architecture which it cannot fit in or have other
+# issues.
+#
+filters = {
+ 'bsps': {
+ 'out': ['arm/rtl22xx',
+ 'arm/lpc32xx_mzx_stage_1',
+ 'arm/lpc23xx_tli800',
+ 'arm/lpc2362',
+ 'arm/nds']
+ }
+ }
+
def init(ctx):
- rtems.init(ctx)
+ rtems.init(ctx, filters)
def options(opt):
rtems.options(opt)
@@ -36,6 +50,7 @@ def build(bld):
bld.defines += ['RTL_GSYM_EMBEDDED=1']
rtl_source(bld, arch)
+ rtl_bspinit(bld, arch)
rtl_liba(bld, arch)
rtl_root_fs(bld)
rtl_gsyms(bld)
@@ -48,7 +63,7 @@ def build(bld):
includes = bld.includes,
defines = bld.defines,
cflags = '-g',
- use = ['rtl', 'rootfs', 'rtld-gsyms'],
+ use = ['rtl', 'bspinit', 'rootfs', 'rtld-gsyms'],
depends_on = 'gsyms')
if bld.env.ASCIIDOC:
@@ -84,6 +99,14 @@ def rtl_source(bld, arch):
'rtl-unresolved.c',
'rtl-mdreloc-' + arch + '.c'])
+def rtl_bspinit(bld, arch):
+ if arch == 'arm':
+ bld(target = 'bspinit',
+ features = 'c',
+ includes = bld.includes,
+ defines = bld.defines,
+ source = ['bspinit.c'])
+
def rtl_liba(bld, arch):
bld(target = 'x',
features = 'c cstlib',