From e77fe99962337e339262ea579487eeb3ff50c4b4 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 18 Jun 2009 19:45:50 +0000 Subject: mknxflat is now in the ballpark git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1904 42af7a65-404d-4744-a932-0658087f49c3 --- misc/buildroot/toolchain/nxflat/arm/arch.h | 157 ++++++ misc/buildroot/toolchain/nxflat/arm/arm.h | 157 ------ misc/buildroot/toolchain/nxflat/arm/disarm.c | 2 +- .../toolchain/nxflat/arm/dyncall_skeleton.def | 572 +-------------------- misc/buildroot/toolchain/nxflat/ldnxflat.c | 2 +- misc/buildroot/toolchain/nxflat/mknxflat.c | 190 +------ misc/buildroot/toolchain/nxflat/nxflat.mk | 6 + misc/buildroot/toolchain/nxflat/thumb2/Makefile | 50 ++ misc/buildroot/toolchain/nxflat/thumb2/arch.h | 157 ++++++ misc/buildroot/toolchain/nxflat/thumb2/disthumb2.c | 16 + .../toolchain/nxflat/thumb2/dyncall_skeleton.def | 180 +++++++ 11 files changed, 582 insertions(+), 907 deletions(-) create mode 100644 misc/buildroot/toolchain/nxflat/arm/arch.h delete mode 100644 misc/buildroot/toolchain/nxflat/arm/arm.h create mode 100644 misc/buildroot/toolchain/nxflat/thumb2/Makefile create mode 100644 misc/buildroot/toolchain/nxflat/thumb2/arch.h create mode 100644 misc/buildroot/toolchain/nxflat/thumb2/disthumb2.c create mode 100644 misc/buildroot/toolchain/nxflat/thumb2/dyncall_skeleton.def (limited to 'misc') diff --git a/misc/buildroot/toolchain/nxflat/arm/arch.h b/misc/buildroot/toolchain/nxflat/arm/arch.h new file mode 100644 index 000000000..61ace0dd4 --- /dev/null +++ b/misc/buildroot/toolchain/nxflat/arm/arch.h @@ -0,0 +1,157 @@ +/*********************************************************************** + * xflat/tools/arm/arch.h + * ARM ELF support for BFD. + * + * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Derived from XFLAT: + * + * Copyright (c) 2006, Cadenux, LLC. All rights reserved. + * Copyright (c) 2006, Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Which simply lifted it from the BFD: + * + * Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + * This file is part of BFD, the Binary File Descriptor library. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ***********************************************************************/ + +#ifndef _ELF_ARM_H +#define _ELF_ARM_H + +#include "reloc-macros.h" + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x01 +#define EF_ARM_HASENTRY 0x02 +#define EF_INTERWORK 0x04 +#define EF_APCS_26 0x08 +#define EF_APCS_FLOAT 0x10 +#define EF_PIC 0x20 +#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use */ +#define EF_NEW_ABI 0x80 +#define EF_OLD_ABI 0x100 +#define EF_SOFT_FLOAT 0x200 +#define EF_VFP_FLOAT 0x400 + +/* Other constants defined in the ARM ELF spec. version B-01. */ +#define EF_SYMSARESORTED 0x04 /* NB conflicts with EF_INTERWORK */ +#define EF_DYNSYMSUSESEGIDX 0x08 /* NB conflicts with EF_APCS26 */ +#define EF_MAPSYMSFIRST 0x10 /* NB conflicts with EF_APCS_FLOAT */ +#define EF_EABIMASK 0xFF000000 + +#define EF_EABI_VERSION(flags) ((flags) & EF_EABIMASK) +#define EF_EABI_UNKNOWN 0x00000000 +#define EF_EABI_VER1 0x01000000 +#define EF_EABI_VER2 0x02000000 + +/* Local aliases for some flags to match names used by COFF port. */ +#define F_INTERWORK EF_INTERWORK +#define F_APCS26 EF_APCS_26 +#define F_APCS_FLOAT EF_APCS_FLOAT +#define F_PIC EF_PIC +#define F_SOFT_FLOAT EF_SOFT_FLOAT +#define F_VFP_FLOAT EF_VFP_FLOAT + +/* Additional symbol types for Thumb */ +#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */ +#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */ + +/* ARM-specific values for sh_flags */ +#define SHF_ENTRYSECT 0x10000000 /* Section contains an entry point. */ +#define SHF_COMDEF 0x80000000 /* Section may be multiply defined in the input to a link step. */ + +/* ARM-specific program header flags. */ +#define PF_ARM_SB 0x10000000 /* Segment contains the location addressed by the static base. */ +#define PF_ARM_PI 0x20000000 /* Segment is position-independent. */ +#define PF_ARM_ABS 0x40000000 /* Segment must be loaded at its base address. */ + +/* Relocation types. */ + +START_RELOC_NUMBERS (elf_arm_reloc_type) + RELOC_NUMBER (R_ARM_NONE, 0) + RELOC_NUMBER (R_ARM_PC24, 1) + RELOC_NUMBER (R_ARM_ABS32, 2) + RELOC_NUMBER (R_ARM_REL32, 3) +#ifdef OLD_ARM_ABI + RELOC_NUMBER (R_ARM_ABS8, 4) + RELOC_NUMBER (R_ARM_ABS16, 5) + RELOC_NUMBER (R_ARM_ABS12, 6) + RELOC_NUMBER (R_ARM_THM_ABS5, 7) + RELOC_NUMBER (R_ARM_THM_PC22, 8) + RELOC_NUMBER (R_ARM_SBREL32, 9) + RELOC_NUMBER (R_ARM_AMP_VCALL9, 10) + RELOC_NUMBER (R_ARM_THM_PC11, 11) /* Cygnus extension to abi: Thumb unconditional branch. */ + RELOC_NUMBER (R_ARM_THM_PC9, 12) /* Cygnus extension to abi: Thumb conditional branch. */ + RELOC_NUMBER (R_ARM_GNU_VTINHERIT, 13) + RELOC_NUMBER (R_ARM_GNU_VTENTRY, 14) +#else /* not OLD_ARM_ABI */ + RELOC_NUMBER (R_ARM_PC13, 4) + RELOC_NUMBER (R_ARM_ABS16, 5) + RELOC_NUMBER (R_ARM_ABS12, 6) + RELOC_NUMBER (R_ARM_THM_ABS5, 7) + RELOC_NUMBER (R_ARM_ABS8, 8) + RELOC_NUMBER (R_ARM_SBREL32, 9) + RELOC_NUMBER (R_ARM_THM_PC22, 10) + RELOC_NUMBER (R_ARM_THM_PC8, 11) + RELOC_NUMBER (R_ARM_AMP_VCALL9, 12) + RELOC_NUMBER (R_ARM_SWI24, 13) + RELOC_NUMBER (R_ARM_THM_SWI8, 14) + RELOC_NUMBER (R_ARM_XPC25, 15) + RELOC_NUMBER (R_ARM_THM_XPC22, 16) +#endif /* not OLD_ARM_ABI */ + RELOC_NUMBER (R_ARM_COPY, 20) /* Copy symbol at runtime. */ + RELOC_NUMBER (R_ARM_GLOB_DAT, 21) /* Create GOT entry. */ + RELOC_NUMBER (R_ARM_JUMP_SLOT, 22) /* Create PLT entry. */ + RELOC_NUMBER (R_ARM_RELATIVE, 23) /* Adjust by program base. */ + RELOC_NUMBER (R_ARM_GOTOFF, 24) /* 32 bit offset to GOT. */ + RELOC_NUMBER (R_ARM_GOTPC, 25) /* 32 bit PC relative offset to GOT. */ + RELOC_NUMBER (R_ARM_GOT32, 26) /* 32 bit GOT entry. */ + RELOC_NUMBER (R_ARM_PLT32, 27) /* 32 bit PLT address. */ +#ifdef OLD_ARM_ABI + FAKE_RELOC (FIRST_INVALID_RELOC, 28) + FAKE_RELOC (LAST_INVALID_RELOC, 249) +#else /* not OLD_ARM_ABI */ + FAKE_RELOC (FIRST_INVALID_RELOC1, 28) + FAKE_RELOC (LAST_INVALID_RELOC1, 31) + RELOC_NUMBER (R_ARM_ALU_PCREL7_0, 32) + RELOC_NUMBER (R_ARM_ALU_PCREL15_8, 33) + RELOC_NUMBER (R_ARM_ALU_PCREL23_15, 34) + RELOC_NUMBER (R_ARM_LDR_SBREL11_0, 35) + RELOC_NUMBER (R_ARM_ALU_SBREL19_12, 36) + RELOC_NUMBER (R_ARM_ALU_SBREL27_20, 37) + FAKE_RELOC (FIRST_INVALID_RELOC2, 38) + FAKE_RELOC (LAST_INVALID_RELOC2, 99) + RELOC_NUMBER (R_ARM_GNU_VTENTRY, 100) + RELOC_NUMBER (R_ARM_GNU_VTINHERIT, 101) + RELOC_NUMBER (R_ARM_THM_PC11, 102) /* Cygnus extension to abi: Thumb unconditional branch. */ + RELOC_NUMBER (R_ARM_THM_PC9, 103) /* Cygnus extension to abi: Thumb conditional branch. */ + FAKE_RELOC (FIRST_INVALID_RELOC3, 104) + FAKE_RELOC (LAST_INVALID_RELOC3, 248) + RELOC_NUMBER (R_ARM_RXPC25, 249) +#endif /* not OLD_ARM_ABI */ + RELOC_NUMBER (R_ARM_RSBREL32, 250) + RELOC_NUMBER (R_ARM_THM_RPC22, 251) + RELOC_NUMBER (R_ARM_RREL32, 252) + RELOC_NUMBER (R_ARM_RABS32, 253) + RELOC_NUMBER (R_ARM_RPC24, 254) + RELOC_NUMBER (R_ARM_RBASE, 255) +END_RELOC_NUMBERS + +#endif /* _ELF_ARM_H */ diff --git a/misc/buildroot/toolchain/nxflat/arm/arm.h b/misc/buildroot/toolchain/nxflat/arm/arm.h deleted file mode 100644 index e761dfe68..000000000 --- a/misc/buildroot/toolchain/nxflat/arm/arm.h +++ /dev/null @@ -1,157 +0,0 @@ -/*********************************************************************** - * xflat/tools/arm/arm.h - * ARM ELF support for BFD. - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Derived from XFLAT: - * - * Copyright (c) 2006, Cadenux, LLC. All rights reserved. - * Copyright (c) 2006, Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Which simply lifted it from the BFD: - * - * Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. - * This file is part of BFD, the Binary File Descriptor library. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - ***********************************************************************/ - -#ifndef _ELF_ARM_H -#define _ELF_ARM_H - -#include "reloc-macros.h" - -/* Processor specific flags for the ELF header e_flags field. */ -#define EF_ARM_RELEXEC 0x01 -#define EF_ARM_HASENTRY 0x02 -#define EF_INTERWORK 0x04 -#define EF_APCS_26 0x08 -#define EF_APCS_FLOAT 0x10 -#define EF_PIC 0x20 -#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use */ -#define EF_NEW_ABI 0x80 -#define EF_OLD_ABI 0x100 -#define EF_SOFT_FLOAT 0x200 -#define EF_VFP_FLOAT 0x400 - -/* Other constants defined in the ARM ELF spec. version B-01. */ -#define EF_SYMSARESORTED 0x04 /* NB conflicts with EF_INTERWORK */ -#define EF_DYNSYMSUSESEGIDX 0x08 /* NB conflicts with EF_APCS26 */ -#define EF_MAPSYMSFIRST 0x10 /* NB conflicts with EF_APCS_FLOAT */ -#define EF_EABIMASK 0xFF000000 - -#define EF_EABI_VERSION(flags) ((flags) & EF_EABIMASK) -#define EF_EABI_UNKNOWN 0x00000000 -#define EF_EABI_VER1 0x01000000 -#define EF_EABI_VER2 0x02000000 - -/* Local aliases for some flags to match names used by COFF port. */ -#define F_INTERWORK EF_INTERWORK -#define F_APCS26 EF_APCS_26 -#define F_APCS_FLOAT EF_APCS_FLOAT -#define F_PIC EF_PIC -#define F_SOFT_FLOAT EF_SOFT_FLOAT -#define F_VFP_FLOAT EF_VFP_FLOAT - -/* Additional symbol types for Thumb */ -#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */ -#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */ - -/* ARM-specific values for sh_flags */ -#define SHF_ENTRYSECT 0x10000000 /* Section contains an entry point. */ -#define SHF_COMDEF 0x80000000 /* Section may be multiply defined in the input to a link step. */ - -/* ARM-specific program header flags. */ -#define PF_ARM_SB 0x10000000 /* Segment contains the location addressed by the static base. */ -#define PF_ARM_PI 0x20000000 /* Segment is position-independent. */ -#define PF_ARM_ABS 0x40000000 /* Segment must be loaded at its base address. */ - -/* Relocation types. */ - -START_RELOC_NUMBERS (elf_arm_reloc_type) - RELOC_NUMBER (R_ARM_NONE, 0) - RELOC_NUMBER (R_ARM_PC24, 1) - RELOC_NUMBER (R_ARM_ABS32, 2) - RELOC_NUMBER (R_ARM_REL32, 3) -#ifdef OLD_ARM_ABI - RELOC_NUMBER (R_ARM_ABS8, 4) - RELOC_NUMBER (R_ARM_ABS16, 5) - RELOC_NUMBER (R_ARM_ABS12, 6) - RELOC_NUMBER (R_ARM_THM_ABS5, 7) - RELOC_NUMBER (R_ARM_THM_PC22, 8) - RELOC_NUMBER (R_ARM_SBREL32, 9) - RELOC_NUMBER (R_ARM_AMP_VCALL9, 10) - RELOC_NUMBER (R_ARM_THM_PC11, 11) /* Cygnus extension to abi: Thumb unconditional branch. */ - RELOC_NUMBER (R_ARM_THM_PC9, 12) /* Cygnus extension to abi: Thumb conditional branch. */ - RELOC_NUMBER (R_ARM_GNU_VTINHERIT, 13) - RELOC_NUMBER (R_ARM_GNU_VTENTRY, 14) -#else /* not OLD_ARM_ABI */ - RELOC_NUMBER (R_ARM_PC13, 4) - RELOC_NUMBER (R_ARM_ABS16, 5) - RELOC_NUMBER (R_ARM_ABS12, 6) - RELOC_NUMBER (R_ARM_THM_ABS5, 7) - RELOC_NUMBER (R_ARM_ABS8, 8) - RELOC_NUMBER (R_ARM_SBREL32, 9) - RELOC_NUMBER (R_ARM_THM_PC22, 10) - RELOC_NUMBER (R_ARM_THM_PC8, 11) - RELOC_NUMBER (R_ARM_AMP_VCALL9, 12) - RELOC_NUMBER (R_ARM_SWI24, 13) - RELOC_NUMBER (R_ARM_THM_SWI8, 14) - RELOC_NUMBER (R_ARM_XPC25, 15) - RELOC_NUMBER (R_ARM_THM_XPC22, 16) -#endif /* not OLD_ARM_ABI */ - RELOC_NUMBER (R_ARM_COPY, 20) /* Copy symbol at runtime. */ - RELOC_NUMBER (R_ARM_GLOB_DAT, 21) /* Create GOT entry. */ - RELOC_NUMBER (R_ARM_JUMP_SLOT, 22) /* Create PLT entry. */ - RELOC_NUMBER (R_ARM_RELATIVE, 23) /* Adjust by program base. */ - RELOC_NUMBER (R_ARM_GOTOFF, 24) /* 32 bit offset to GOT. */ - RELOC_NUMBER (R_ARM_GOTPC, 25) /* 32 bit PC relative offset to GOT. */ - RELOC_NUMBER (R_ARM_GOT32, 26) /* 32 bit GOT entry. */ - RELOC_NUMBER (R_ARM_PLT32, 27) /* 32 bit PLT address. */ -#ifdef OLD_ARM_ABI - FAKE_RELOC (FIRST_INVALID_RELOC, 28) - FAKE_RELOC (LAST_INVALID_RELOC, 249) -#else /* not OLD_ARM_ABI */ - FAKE_RELOC (FIRST_INVALID_RELOC1, 28) - FAKE_RELOC (LAST_INVALID_RELOC1, 31) - RELOC_NUMBER (R_ARM_ALU_PCREL7_0, 32) - RELOC_NUMBER (R_ARM_ALU_PCREL15_8, 33) - RELOC_NUMBER (R_ARM_ALU_PCREL23_15, 34) - RELOC_NUMBER (R_ARM_LDR_SBREL11_0, 35) - RELOC_NUMBER (R_ARM_ALU_SBREL19_12, 36) - RELOC_NUMBER (R_ARM_ALU_SBREL27_20, 37) - FAKE_RELOC (FIRST_INVALID_RELOC2, 38) - FAKE_RELOC (LAST_INVALID_RELOC2, 99) - RELOC_NUMBER (R_ARM_GNU_VTENTRY, 100) - RELOC_NUMBER (R_ARM_GNU_VTINHERIT, 101) - RELOC_NUMBER (R_ARM_THM_PC11, 102) /* Cygnus extension to abi: Thumb unconditional branch. */ - RELOC_NUMBER (R_ARM_THM_PC9, 103) /* Cygnus extension to abi: Thumb conditional branch. */ - FAKE_RELOC (FIRST_INVALID_RELOC3, 104) - FAKE_RELOC (LAST_INVALID_RELOC3, 248) - RELOC_NUMBER (R_ARM_RXPC25, 249) -#endif /* not OLD_ARM_ABI */ - RELOC_NUMBER (R_ARM_RSBREL32, 250) - RELOC_NUMBER (R_ARM_THM_RPC22, 251) - RELOC_NUMBER (R_ARM_RREL32, 252) - RELOC_NUMBER (R_ARM_RABS32, 253) - RELOC_NUMBER (R_ARM_RPC24, 254) - RELOC_NUMBER (R_ARM_RBASE, 255) -END_RELOC_NUMBERS - -#endif /* _ELF_ARM_H */ diff --git a/misc/buildroot/toolchain/nxflat/arm/disarm.c b/misc/buildroot/toolchain/nxflat/arm/disarm.c index ad430472f..5826df3b4 100644 --- a/misc/buildroot/toolchain/nxflat/arm/disarm.c +++ b/misc/buildroot/toolchain/nxflat/arm/disarm.c @@ -1,5 +1,5 @@ /*********************************************************************** - * toolchain/nxflat/disasm.c + * toolchain/nxflat/arm/disarm.c * ARM Disassembler * * Copyright (C) 2009 Gregory Nutt. All rights reserved. diff --git a/misc/buildroot/toolchain/nxflat/arm/dyncall_skeleton.def b/misc/buildroot/toolchain/nxflat/arm/dyncall_skeleton.def index 29551163b..8f58267bc 100644 --- a/misc/buildroot/toolchain/nxflat/arm/dyncall_skeleton.def +++ b/misc/buildroot/toolchain/nxflat/arm/dyncall_skeleton.def @@ -69,100 +69,9 @@ static const char file_prologue[] = " *******************************************************************/\n\n" "/*******************************************************************\n" " * Definitions\n" - " *******************************************************************/\n\n" - "/* Register definitions */\n\n" - "#define PIC_REG r10\t/* The PIC base register */\n" - "#define RINFO r4\t/* Pointer to dyninfo structure */\n" - "#define MYPIC r5\t/* Saved PIC base register value */\n" - "#define FRAME r6\t/* Current state save frame */\n" - "#define SAVEREG1 r4\t/* First pushed register */\n" - "#define SAVEREG2 r7\t/* Last pushed register */\n" - "#define TMP3 r5\t/* Careful, overlaps MYPIC */\n" - "#define WORK r7\t/* Safe to used */\n" - "#define TMP1 ip\n" - "#define TMP2 lr\n\n" - "/* This is the EXIT software interrupt code. */\n\n" - "#define DFR_EXIT_SWINO 0x900001\n"; - -#ifdef CONFIG_ARCH_DSC25 -static const char dyntrace_enable[] = - "\n/* Conditional Compilation */\n\n" - "#define __DYNTRACE 1\n" - "#define __DYNTRACE_USE_HARDWARE 1\n" - "#define __DYNTRACE_CONFIG_DSC25 1\n"; -#else -static const char dyntrace_enable[] = - "\n/* Conditional Compilation */\n\n" - "#define __DYNTRACE 1\n"; -#endif - -static const char import_prologue[] = - "\n/* This is an assembly language representation of the\n" - " * struct nxflat_import_s structure:\n" - " */\n\n" - "#define RINFO_FCNNAME 0\t/* Offset to the function name */\n" - "#define RINFO_FCNADDR 4\t/* Offset to the function address */\n" - "#define RINFO_PICBASE 8\t/* Offset to the PIC base value */\n\n" - "/* The common dynamic call logic receives the following C stack frame.\n" - " * NOTE: The number of registers should be SAVEREG2-SAVEREG1+2.\n" - " */\n\n" - "#define SP_OFFSET_CREG1 0\n" - "#define SP_OFFSET_CREG2 4\n" - "#define SP_OFFSET_CREG3 8\n" - "#define SP_OFFSET_CREG4 12\n" - "#define SP_OFFSET_CREG5 16\n" - "#define SP_FRAME_SIZE 20\n\n" - "/* The common dynamic call logic will create the following dynamic\n" - " * frame:\n" - " */\n\n" - "#define DFR_OFFSET_ALLOCATED 0\n" - "#define DFR_OFFSET_REFCOUNT 1\n" - "#define DFR_OFFSET_UNUSED1 2\n" - "#define DFR_OFFSET_UNUSED2 3\n" - "#define DFR_OFFSET_CREG1 4\n" - "#define DFR_OFFSET_CREG2 8\n" - "#define DFR_OFFSET_CREG3 12\n" - "#define DFR_OFFSET_CREG4 16\n" - "#define DFR_OFFSET_CREG5 20\n\n" - "#define DFR_FRAME_SIZE_BYTES 24\n" - "#define DFR_FRAME_SIZE_WORDS (DFR_FRAME_SIZE_BYTES >> 2)\n\n" - "/* These definitions determine that memory that will be set aside\n" - " * for frame storage:\n" - " */\n"; + " *******************************************************************/\n"; -static const char import_frame_size[] = - "\n#define DFR_NUM_FRAMES %d\n" - "#define DFR_FRAME_ALLOC_BYTES (DFR_FRAME_SIZE_BYTES*DFR_NUM_FRAMES)\n" - "#define DFR_FRAME_ALLOC_WORDS (DFR_FRAME_ALLOC_BYTES >> 2)\n"; - -static const char dynamic_frames[] = - "\n/*******************************************************************\n" - " * The Dynamic Frame Storage\n" - " *******************************************************************/\n\n" - "/* This defines an array of state save frames the will used by the\n" - " * dynamic call logic to hold information needed to manage a \"thunk.\"\n" - " */\n\n" - "\t.bss\n" - "\t.align\t2\n" - "\t.local\t__dynframes\n" - "\t.type\t__dynframes, object\n" - "__dynframes:\n" - "\t.fill\tDFR_FRAME_ALLOC_WORDS, 4, 0\n" - "\t.size\t__dynframes, .-__dynframes\n"; - -static const char nonreturning_dynamic_frame[] = - "\n/* This defines a special storage location for functions that don't\n" - " * (normally) return. It is kept separate from other frames to prevent\n" - " * overwriting; this storage only exists in case the function does\n" - " * return (which can happen on an error condition).\n" - " */\n\n" - "\t.bss\n" - "\t.align\t2\n" - "\t.local\t__dynnrframe\n" - "\t.type\t__dynnrframe, object\n" - "__dynnrframe:\n" - "\t.fill\tDFR_FRAME_SIZE_WORDS, 4, 0\n" - "\t.size\t__dynnrframe, .-__dynnrframe\n"; +static const char import_prologue[] = ""; /******************************************************************* * Import Function Name String Table @@ -189,7 +98,7 @@ static const char import_name_strtab_format[] = "\t.size\t__dynimport%04d, .-__dynimport%04d\n"; /******************************************************************* - * Per Import Dyanamic Call Information + * Dyanamic Call Information *******************************************************************/ static const char dynimport_decl_prologue[] = @@ -222,7 +131,6 @@ static const char dynimport_array_format[] = "__dyninfo%04d:\t\t\t/* Dynamic info for imported symbol %s */\n" "\t.word\t__dynimport%04d\t/* Offset to name of imported function */\n" "\t.word\t0\t\t/* Resolved address of imported function */\n" - "\t.word\t0\t\t/* Data segment address for imported func */\n" "\t.size\t__dyninfo%04d, .-__dyninfo%04d\n"; static const char dynimport_array_epilogue[] = @@ -231,7 +139,7 @@ static const char dynimport_array_epilogue[] = static const char dyncall_decl_prologue[] = "\n/*******************************************************************\n" - " * Per Import Dynamic Call Logic\n" + " * Dynamic Call Logic\n" " *******************************************************************/\n\n" "\t.text\n" "\t.align\t2\n"; @@ -243,17 +151,10 @@ static const char dyncall_format[] = "\t.global\t%s\n" "\t.type\t%s, function\n\n" "%s:\n" - "\tldr\tTMP1, =__dyninfo%04d\n" - "\tb\t__dyncall1\n" - "\t.size\t%s, .-%s\n"; - -static const char dyncall_format2[] = - "\n/* Dynamic call logic for special imported symbol %s */\n\n" - "\t.global\t%s\n" - "\t.type\t%s, function\n\n" - "%s:\n" - "\tldr\tTMP1, =__dyninfo%04d\n" - "\tb\t__dyncall2\n" + "\tstmdb\tsp!,{r4, lr}\n" + "\tldr\tr4, =__dyninfo%04d\n" + "\tbl\t[r4]\n" + "\tldmia\tsp!,{r4, pc}\n" "\t.size\t%s, .-%s\n"; static const char nonreturning_dyncall_format[] = @@ -261,465 +162,14 @@ static const char nonreturning_dyncall_format[] = "\t.global\t%s\n" "\t.type\t%s, function\n\n" "%s:\n" - "\tldr\tTMP1, =__dyninfo%04d\n" - "\tb\t__dynnoreturn\n" + "\tldr\tr4, =__dyninfo%04d\n" + "\tb\t[r4]\n" "\t.size\t%s, .-%s\n"; /******************************************************************* - * Dynamic Call Trace Logic - *******************************************************************/ - -static const char dyntrace_function[] = - "\n/* This is constant data used to by the __dyntrace function */\n\n" - "#ifdef __DYNTRACE\n\n" - "\t.section\t.rodata\n\n" - "# ifdef __DYNTRACE_USE_HARDWARE\n" - "# define __DYNTRACE_LBRACE_SIZE 3\n" - "# define __DYNTRACE_RBRACE_SIZE 3\n\n" - "\t.local\t.LC_lbrace\n" - "\t.type\t.LC_lbrace, object\n" - "\t.size\t.LC_lbrace, __DYNTRACE_LBRACE_SIZE\n" - ".LC_lbrace:\n" - "\t.ascii\t\"\\r\\n[\"\n\n" - "\t.local\t.LC_rbrace\n" - "\t.type\t.LC_rbrace, object\n" - "\t.size\t.LC_rbrace, __DYNTRACE_RBRACE_SIZE\n" - ".LC_rbrace:\n" - "\t.ascii\t\"]\\r\\n\"\n\n" - "# else\n\n" - "# define __DYNTRACE_LBRACE_SIZE 2\n" - "# define __DYNTRACE_RBRACE_SIZE 2\n\n" - "\t.local\t.LC_lbrace\n" - "\t.type\t.LC_lbrace, object\n" - "\t.size\t.LC_lbrace, __DYNTRACE_LBRACE_SIZE\n" - ".LC_lbrace:\n" - "\t.ascii\t\"\\n[\"\n\n" - "\t.local\t.LC_rbrace\n" - "\t.type\t.LC_rbrace, object\n" - "\t.size\t.LC_rbrace, __DYNTRACE_RBRACE_SIZE\n" - ".LC_rbrace:\n" - "\t.ascii\t\"]\\n\"\n\n" - "#endif /* __DYNTRACE_USE_HARDWARE */\n\n" - "#define __DYNTRACE_EXITTING_SIZE 8\n" - "\t.local\t.LC_exitting\n" - "\t.type\t.LC_exitting, object\n" - "\t.size\t.LC_exitting, __DYNTRACE_EXITTING_SIZE\n" - ".LC_exitting:\n" - "\t.ascii\t\"ABORTING\"\n\n" - "/* Macros to write trace information to the console/stderr\n" - " *\n" - " * r1 = write buffer address\n" - " * r2 = write buffer size\n" - " *\n" - " * Will use all registers normally altered on a C subroutine call:\n" - " * r0-r3, ip (r12), and lr (r14).\n" - " */\n\n" - "#ifdef __DYNTRACE_USE_HARDWARE\n" - "\t/* These are the same macros that can be found in\n" - "\t * linux/arch/armnommu/kernel/debug-armv.S for the 2.4 kernel\n" - "\t */\n\n" - "#ifdef __DYNTRACE_CONFIG_DSC25\n" - "\t.macro\taddruart,rx\n" - "\tldr\t\\rx, =0x00030300\t@ UART0 base\n" - "\t.endm\n\n" - "\t.macro\tsenduart,rd,rx\n" - "\tstrh\t\\rd, [\\rx, #0x00]\t@ UARTx_DTRR Offset\n" - "\t.endm\n\n" - "\t.macro\twaituart,rd,rx\n" - "1001:\tldrh\t\\rd, [\\rx, #0x0c]\t@ UARTx_SR Offset\n" - "\ttst\t\\rd, #0x0400\t\t@ Check TX fifo ind.\n" - "\tbeq\t1001b\t\t\t@ loop til 1=room in TX fifo\n" - "\t.endm\n\n" - "\t.macro\tbusyuart,rd,rx\n" - "1002:\tldrh\t\\rd, [\\rx, #0x0c]\t@ UARTx_SR Offset\n" - "\ttst\t\\rd, #0x0001\t\t@ Check TX empty bit\n" - "\tbne\t1002b\t\t\t@ loop til 0=TX fifo empty\n" - "\t.endm\n" - "#else\n" - "# error Unsupported architecture\n" - "#endif\n" - "\t.macro __dyntrace_write\n" - "\tbl\t__dynwrite\n" - "\t.endm\n\n" - "/* Write directly to the uart hardware:\n" - " * r1 = addr, r2 = number of bytes.\n" - " */\n\n" - "\t.text\n" - "\t.align\t2\n" - "\t.local\t__dynwrite\n" - "\t.type\t__dynwrite, function\n" - "__dynwrite:\n\n" - "\taddruart r3\t\t\t@ Get the UART address\n" - "1:\twaituart r0, r3\t\t\t@ Wait for UART available\n" - "\tldrb\tr0, [r1], #1\t\t@ Fetch the next byte\n" - "\tsenduart r0, r3\t\t\t@ Send the byte\n" - "\tbusyuart r0, r3\t\t\t@ Wait for the byte to go\n" - "\tsubs\tr2, r2, #1\t\t@ Decr # bytes sent\n" - "\tbne\t1b\t\t\t@ Done?\n" - "\tmov\tpc, lr\t\t\t@ Yes, Return\n" - "#else\n" - "/* This macro uses the write syscall to output trace information: */\n\n" - "\t.macro __dyntrace_write\n" - "\tmov\tr0, #1\n" - "\tswi\t0x900004\n" - "\t.endm\n" - "#endif\n\n" - "/* If enabled, the __dyntrace function will be called just before\n" - " * each call into a shared library is performed. The __dyntrace\n" - " * function will print the name of the called function on stderr\n" - " * in the follow format: \\n[name]\\n. WARNING: This function uses\n" - " * the write syscall directly!\n" - " *\n" - " * The following register state is assume on entry:\n" - " * o WORK is available for use\n" - " * o [PIC_REG] points to our data segment\n" - " * o [RINFO] holds the offset to the info structure\n" - " * [RINFO]+RINFO_FCNAME points to the symbol name.\n" - " */\n\n" - "\t.text\n" - "\t.align\t2\n" - "\t.local\t__dyntrace\n" - "\t.type\t__dyntrace, function\n" - "__dyntrace:\n\n" - "\t/* Save all registers normally altered on a C subroutine call:\n" - "\t * r0-r3, ip (r12), and lr (r14).\n" - "\t */\n\n" - "\tstmfd\tsp!, {r0-r3, ip, lr}\n\n" - "\t/* Write the leading \"\\n[\" */\n\n" - "\tldr\tr1, .Llbrace_addr\n" - "\tadd\tr1, PIC_REG, r1\n" - "\tmov\tr2, #__DYNTRACE_LBRACE_SIZE\n" - "\t__dyntrace_write\n\n" - "\t/* Determine the length of the name string */\n\n" - "\tadd\tr3, PIC_REG, RINFO\n" - "\tldr\tr1, [r3, #RINFO_FCNNAME]\n" - "\tmov\tr2, #0\n" - ".Lstrlen_loop:\n" - "\tldrb\tr0, [r1], #1\n" - "\tcmp\tr0, #0\n" - "\taddne\tr2, r2, #1\n" - "\tbne\t.Lstrlen_loop\n\n" - "\t/* Then write the name string */\n\n" - "\tldr\tr1, [r3, #RINFO_FCNNAME]\n" - "\t__dyntrace_write\n\n" - "\t/* Write the trailing \"\\n[\" */\n\n" - "\tldr\tr1, .Lrbrace_addr\n" - "\tadd\tr1, PIC_REG, r1\n" - "\tmov\tr2, #__DYNTRACE_LBRACE_SIZE\n" - "\t__dyntrace_write\n\n" - "\tldmfd\tsp!, {r0-r3, ip, pc}\n\n" - "\t.align\t2\n" - ".Llbrace_addr:\n" - "\t.word\t.LC_lbrace\n" - ".Lrbrace_addr:\n" - "\t.word\t.LC_rbrace\n" - "\t.size\t __dyntrace, .-__dyntrace\n" - "#endif /* __DYNTRACE */\n"; - -/******************************************************************* - * Common Dyanamic Call Information + * File Epilogue *******************************************************************/ -static const char frame_macros[] = - "\n/*******************************************************************\n" - " * Frame Management Macros\n" - " *******************************************************************/\n\n" - "\t.macro\tget_frame, frame, refcount, tmp1, tmp2\n\n" - "\t/* Get frame = first frame in the __dynframes list, and\n" - "\t * tmp2 = the first address past the __dynframe list.\n" - "\t */\n\n" - "\tldr\t\\tmp2, =DFR_FRAME_ALLOC_BYTES\n" - "\tldr\t\\tmp1, =__dynframes\n" - "\tadd\t\\frame, PIC_REG, \\tmp1\n" - "\tadd\t\\tmp2, \\tmp2, \\frame\n\n" - "\t/* Loop until an unsused frame is found our until the\n" - "\t * end of the __dynframes list is encountered. Normally,\n" - "\t * this will be very fast -- because the first frame should\n" - "\t * be available.\n" - "\t */\n\n" - "1:\n" - "\tmov\t\\tmp1, #1\n" - "\tswpb\t\\tmp1, \\tmp1, [\\frame]\n" - "\tcmp\t\\tmp1, #0\n" - "\tbeq\t2f\n\n" - "\t/* Increment to the next frame in the list and check if this\n" - "\t * next frame lies beyond the __dynframes list.\n" - "\t */\n\n" - "\tadd\t\\frame, \\frame, #DFR_FRAME_SIZE_BYTES\n" - "\tcmp\t\\frame, \\tmp2\n" - "\tbcc\t1b\n\n" - "\t/* Failure! The list is full! We don't have many options\n" - "\t * here so we will just exit with error number = 1.\n" - "\t */\n\n" - "#ifdef __DYNTRACE\n" - "\tldr\tr1, =.LC_exitting\n" - "\tmov\tr2, #__DYNTRACE_EXITTING_SIZE\n" - "\t__dyntrace_write\n" - "#endif\n\n" - "\tmov\tr0, #1\n" - "\tswi\tDFR_EXIT_SWINO\n\n" - "\t/* Set the reference count on the frame and continue with\n" - "\t * frame = the available frame */\n" - "2:\n" - "\tstrb\t\\refcount, [\\frame, #DFR_OFFSET_REFCOUNT]\n" - "\t.endm\n\n" - "\t.macro release_frame, frame, tmp1\n" - "\tldrb\t\\tmp1, [\\frame, #DFR_OFFSET_REFCOUNT]\n" - "\tcmp\t\\tmp1, #0\n" - "\tsub\t\\tmp1, \\tmp1, #1\n" - "\tble\t3f\n" - "\tcmp\t\\tmp1, #0\n" - "\tstrb\t\\tmp1, [\\frame, #DFR_OFFSET_REFCOUNT]\n" - "\tstreqb\t\\tmp1, [\\frame, #DFR_OFFSET_ALLOCATED]\n" - "3:\n" - "\t.endm\n"; - -static const char nonreturning_frame_macros[] = - "\t.macro\tget_nrframe, frame, refcount, tmp1, tmp2\n\n" - "\tldr\t\\frame, =__dynnrframe\n" - "\tadd\t\\frame, PIC_REG, \\frame\n" - "\t.endm\n\n" - "\t.macro release_nrframe, frame, tmp1\n" - "\t.endm\n"; - -static const char dyncall_prologue[] = - "\n/*******************************************************************\n" - " *\n" - " * This the dynamic call logic.\n" - " *\n" - " *\t1. SAVEREG1-SAVEREG2, and lr stored on the C stack\n" - " *\t2. [PIC_REG] = Points to our data segment\n" - " *\t3. [RINFO] = Offset to info structure in data segment\n" - " *\t4. [WORK] = Reference count to be applied to the frame\n" - " *\t5. TMP1, TMP2 and TMP3 are available for use.\n" - " *******************************************************************/\n\n" - "\t.text\n" - "\t.align\t2\n" - "\t.local\t__dyncall\n" - "\t.type\t__dyncall, function\n" - "\t.local\t__dyncall1\n" - "\t.type\t__dyncall1, function\n" - "\t.local\t__dyncall2\n" - "\t.type\t__dyncall2, function\n\n" - "__dyncall1:\n" - "\tstmdb\tsp!, {SAVEREG1-SAVEREG2, lr}\n" - "\tmov\tRINFO, TMP1\n" - "\tmov\tWORK, #1\n" - "\tb\t__dyncall\n" - "\t.size\t__dyncall1, .-__dyncall1\n\n" - "__dyncall2:\n" - "\tstmdb\tsp!, {SAVEREG1-SAVEREG2, lr}\n" - "\tmov\tRINFO, TMP1\n" - "\tmov\tWORK, #2\n" - "\t.size\t__dyncall2, .-__dyncall2\n\n" - "__dyncall:\n"; - -static const char dyntrace_call[] = - "\n#ifdef __DYNTRACE\n" - "\tbl\t__dyntrace\n" - "#endif /* __DYNTRACE */\n"; - -static const char dyncall_epilogue[] = - "\n\t/***********************************************************\n" - "\t * Transfer all of the information saved on the C stack to\n" - "\t * a dynamic frame.\n" - "\t ***********************************************************/\n\n" - "\t/* Get FRAME = the dynamic frame. */\n\n" - "\tget_frame\tFRAME, WORK, TMP1, TMP2\n\n" - "\t/* Copy the current C stack frame in the dynamic frame */\n\n" - "\tldr\tTMP2, [sp, #SP_OFFSET_CREG1]\n" - "\tstr\tTMP2, [FRAME, #DFR_OFFSET_CREG1]\n" - "\tldr\tTMP2, [sp, #SP_OFFSET_CREG2]\n" - "\tstr\tTMP2, [FRAME, #DFR_OFFSET_CREG2]\n" - "\tldr\tTMP2, [sp, #SP_OFFSET_CREG3]\n" - "\tstr\tTMP2, [FRAME, #DFR_OFFSET_CREG3]\n" - "\tldr\tTMP2, [sp, #SP_OFFSET_CREG4]\n" - "\tstr\tTMP2, [FRAME, #DFR_OFFSET_CREG4]\n" - "\tldr\tTMP2, [sp, #SP_OFFSET_CREG5]\n" - "\tstr\tTMP2, [FRAME, #DFR_OFFSET_CREG5]\n\n" - "\t/***********************************************************\n" - "\t * And release the C stack frame.\n" - "\t * At this point, the entire call stack should be pristine.\n" - "\t ***********************************************************/\n\n" - "\tadd\tsp, sp, #SP_FRAME_SIZE\n\n" - "\t/***********************************************************\n" - "\t * Get the dyncall information.\n" - "\t * Before the following section:\n" - "\t *\t[PIC_REG] = Points to our PIC base\n" - "\t *\t[FRAME] = Reference to dynamic frame\n" - "\t *\t[RINFO] = Offset to info structure in data segment\n" - "\t *\tRWORK, TMP1-3 are available\n" - "\t *\n" - "\t * After the following:\n" - "\t *\t[RINFO] = Dyncall info pointer\n" - "\t *\t[MYPIC] = Points to our PIC base\n" - "\t *\t[FRAME] = Reference to dynamic frame\n" - "\t *\t[PIC_REG] = Holds the new PIC base for the target\n" - "\t *\t[WORK] = Target function entry point\n" - "\t *\tTMP1-3 are still available\n" - "\t ***********************************************************/\n\n" - "\tadd\tRINFO, PIC_REG, RINFO\n" - "\tmov\tMYPIC, PIC_REG\n" - "\tldr\tPIC_REG, [RINFO, #RINFO_PICBASE]\n" - "\tldr\tWORK, [RINFO, #RINFO_FCNADDR]\n\n" - "\t/***********************************************************\n" - "\t * Call the function entry point.\n" - "\t *\n" - "\t * This logic performs a 32-bit, register version of the\n" - "\t * the bl instruction. \n" - "\t ***********************************************************/\n\n" - "\tmov\tlr, pc\n" - "\tmov\tpc, WORK\n\n" - "\t/***********************************************************\n" - "\t * Return from the thunked function\n" - "\t *\n" - "\t * At this point:\n" - "\t *\t1. We should have our PIC base in MYPIC.\n" - "\t *\t2. We should have the reference to the dynamic frame in FRAME\n" - "\t *\t3. We are free to use: r0-r3, RINFO, PIC_REG, FRAME-2, TMP1-2\n" - "\t *\n" - "\t ***********************************************************/\n\n" - "\t/* First, recover our PIC base into from a register that will\n" - "\t * have been restored.\n" - "\t */\n\n" - "\tmov\tPIC_REG, MYPIC\n\n" - "\t/***********************************************************\n" - "\t * Restore the C stack frame and release the dynamic frame\n" - "\t ***********************************************************/\n\n" - "\t/* Re-allocate the stack frame */\n\n" - "\tsub\tsp, sp, #SP_FRAME_SIZE\n\n" - "\t/* Then transfer the information into the C stack frame\n" - "\t * that was saved in the dynamic frame\n" - "\t */\n\n" - "\tldr\tTMP2, [FRAME, #DFR_OFFSET_CREG1]\n" - "\tstr\tTMP2, [sp, #SP_OFFSET_CREG1]\n" - "\tldr\tTMP2, [FRAME, #DFR_OFFSET_CREG2]\n" - "\tstr\tTMP2, [sp, #SP_OFFSET_CREG2]\n" - "\tldr\tTMP2, [FRAME, #DFR_OFFSET_CREG3]\n" - "\tstr\tTMP2, [sp, #SP_OFFSET_CREG3]\n" - "\tldr\tTMP2, [FRAME, #DFR_OFFSET_CREG4]\n" - "\tstr\tTMP2, [sp, #SP_OFFSET_CREG4]\n" - "\tldr\tTMP2, [FRAME, #DFR_OFFSET_CREG5]\n" - "\tstr\tTMP2, [sp, #SP_OFFSET_CREG5]\n\n" - "\t/* Release the dynamic frame */\n\n" - "\trelease_frame\tFRAME, TMP1\n\n" - "\t/***********************************************************\n" - "\t * And return to the caller\n" - "\t ***********************************************************/\n\n" - "\tldmia\tsp!, {SAVEREG1-SAVEREG2, pc}\n" - "\t.size\t__dyncall, .-__dyncall\n"; - -static const char nonreturning_dyncall_prologue[] = - "\n/*******************************************************************\n" - " *\n" - " * This is special dynamic call logic for functions that do not\n" - " * (normally) return.\n" - " *\n" - " *\t1. SAVEREG1-SAVEREG2, and lr stored on the C stack\n" - " *\t2. [PIC_REG] = Points to our data segment\n" - " *\t3. [RINFO] = Offset to info structure in data segment\n" - " *\t3. [WORK] = Reference count to be applied to the frame\n" - " *\t4. TMP1 and TMP2 are available for use.\n" - " *******************************************************************/\n\n" - "\t.text\n" - "\t.align\t2\n" - "\t.local\t__dynnoreturn\n" - "\t.type\t__dynnoreturn, function\n\n" - "__dynnoreturn:\n" - "\tstmdb\tsp!, {SAVEREG1-SAVEREG2, lr}\n" - "\tmov\tRINFO, TMP1\n" - "\tmov\tWORK, #0\n"; - -static const char nonreturning_dyncall_epilogue[] = - "\n\t/***********************************************************\n" - "\t * Transfer all of the information saved on the C stack to\n" - "\t * a dynamic frame.\n" - "\t ***********************************************************/\n\n" - "\t/* Get FRAME = the dynamic frame. */\n\n" - "\tget_nrframe\tFRAME, WORK, TMP1, TMP2\n\n" - "\t/* Copy the current C stack frame in the dynamic frame */\n\n" - "\tldr\tTMP2, [sp, #SP_OFFSET_CREG1]\n" - "\tstr\tTMP2, [FRAME, #DFR_OFFSET_CREG1]\n" - "\tldr\tTMP2, [sp, #SP_OFFSET_CREG2]\n" - "\tstr\tTMP2, [FRAME, #DFR_OFFSET_CREG2]\n" - "\tldr\tTMP2, [sp, #SP_OFFSET_CREG3]\n" - "\tstr\tTMP2, [FRAME, #DFR_OFFSET_CREG3]\n" - "\tldr\tTMP2, [sp, #SP_OFFSET_CREG4]\n" - "\tstr\tTMP2, [FRAME, #DFR_OFFSET_CREG4]\n" - "\tldr\tTMP2, [sp, #SP_OFFSET_CREG5]\n" - "\tstr\tTMP2, [FRAME, #DFR_OFFSET_CREG5]\n\n" - "\t/***********************************************************\n" - "\t * And release the C stack frame.\n" - "\t * At this point, the entire call stack should be pristine.\n" - "\t ***********************************************************/\n\n" - "\tadd\tsp, sp, #SP_FRAME_SIZE\n\n" - "\t/***********************************************************\n" - "\t * Get the dyncall information.\n" - "\t * Before the following section:\n" - "\t *\t[PIC_REG] = Points to our PIC base\n" - "\t *\t[FRAME] = Reference to dynamic frame\n" - "\t *\t[RINFO] = Offset to info structure in data segment\n" - "\t *\tRWORK, TMP1-3 are available\n" - "\t *\n" - "\t * After the following:\n" - "\t *\t[RINFO] = Dyncall info pointer\n" - "\t *\t[MYPIC] = Points to our PIC base\n" - "\t *\t[FRAME] = Reference to dynamic frame\n" - "\t *\t[PIC_REG] = Holds the new PIC base for the target\n" - "\t *\t[WORK] = Target function entry point\n" - "\t *\tTMP1-3 are still available\n" - "\t ***********************************************************/\n\n" - "\tadd\tRINFO, PIC_REG, RINFO\n" - "\tmov\tMYPIC, PIC_REG\n" - "\tldr\tPIC_REG, [RINFO, #RINFO_PICBASE]\n" - "\tldr\tWORK, [RINFO, #RINFO_FCNADDR]\n\n" - "\t/***********************************************************\n" - "\t * Call the function entry point.\n" - "\t *\n" - "\t * This logic performs a 32-bit, register version of the\n" - "\t * the bl instruction. \n" - "\t ***********************************************************/\n\n" - "\tmov\tlr, pc\n" - "\tmov\tpc, WORK\n\n" - "\t/***********************************************************\n" - "\t * Return from the thunked function\n" - "\t *\n" - "\t * At this point:\n" - "\t *\t1. We should have our PIC base in MYPIC.\n" - "\t *\t2. We should have a reference to the dynamic frame in FRAME\n" - "\t *\t3. We are free to use: r0-r3, RINFO, PIC_REG, FRAME-2, TMP1-2\n" - "\t *\n" - "\t ***********************************************************/\n\n" - "\t/* First, recover our PIC base from a register the will have\n" - "\t * been restored.\n" - "\t */\n\n" - "\tmov\tPIC_REG, MYPIC\n\n" - "\t/***********************************************************\n" - "\t * Restore the C stack frame\n" - "\t ***********************************************************/\n\n" - "\t/* Re-allocate the stack frame */\n\n" - "\tsub\tsp, sp, #SP_FRAME_SIZE\n\n" - "\t/* Then transfer the information into the C stack frame\n" - "\t * that was saved in the dynamic frame.\n" - "\t */\n\n" - "\tldr\tTMP2, [FRAME, #DFR_OFFSET_CREG1]\n" - "\tstr\tTMP2, [sp, #SP_OFFSET_CREG1]\n" - "\tldr\tTMP2, [FRAME, #DFR_OFFSET_CREG2]\n" - "\tstr\tTMP2, [sp, #SP_OFFSET_CREG2]\n" - "\tldr\tTMP2, [FRAME, #DFR_OFFSET_CREG3]\n" - "\tstr\tTMP2, [sp, #SP_OFFSET_CREG3]\n" - "\tldr\tTMP2, [FRAME, #DFR_OFFSET_CREG4]\n" - "\tstr\tTMP2, [sp, #SP_OFFSET_CREG4]\n" - "\tldr\tTMP2, [FRAME, #DFR_OFFSET_CREG5]\n" - "\tstr\tTMP2, [sp, #SP_OFFSET_CREG5]\n\n" - "\t/* Release the dynamic frame */\n\n" - "\trelease_nrframe\tFRAME, TMP1\n\n" - "\t/***********************************************************\n" - "\t * And return to the caller\n" - "\t ***********************************************************/\n\n" - "\tldmia\tsp!, {SAVEREG1-SAVEREG2, pc}\n" - "\t.size\t__dynnoreturn, .-__dynnoreturn\n"; - static const char file_epilogue[] = "\t.end\n"; diff --git a/misc/buildroot/toolchain/nxflat/ldnxflat.c b/misc/buildroot/toolchain/nxflat/ldnxflat.c index c2026f97d..83c0ca67e 100644 --- a/misc/buildroot/toolchain/nxflat/ldnxflat.c +++ b/misc/buildroot/toolchain/nxflat/ldnxflat.c @@ -76,7 +76,7 @@ #include #include "bfd.h" -#include "arch/arm.h" +#include "arch/arch.h" #include "nxflat.h" /*********************************************************************** diff --git a/misc/buildroot/toolchain/nxflat/mknxflat.c b/misc/buildroot/toolchain/nxflat/mknxflat.c index 7f1987486..bf29b7df0 100644 --- a/misc/buildroot/toolchain/nxflat/mknxflat.c +++ b/misc/buildroot/toolchain/nxflat/mknxflat.c @@ -54,7 +54,7 @@ #include #include "nxflat.h" -#include "arch/arm.h" +#include "arch/arch.h" /*********************************************************************** * Definitions @@ -74,8 +74,6 @@ #define IS_WEAK(x) ((((x)->flags)&(BSF_WEAK))!=0) #define MAX_EXPORT_NAMES 1024 -#define DEFAULT_MAX_THREADS 6 -#define MIN_THREADS 3 /*********************************************************************** * Private Types @@ -93,12 +91,9 @@ typedef int (*namefunc_type) (const char *name, void *arg); static int verbose = 0; static int weak_imports = 0; static int dsyms = 0; -static int enable_trace = 0; -static int max_threads = DEFAULT_MAX_THREADS; /* Characteristics of things */ static int calls_nonreturning_functions = 0; -static int calls_forkers = 0; /* Sizes of things */ @@ -141,41 +136,12 @@ static const char dyn_symbol_prefix[] = "__dyn"; static const char *const nonreturners[] = { "abort", /* Never returns */ - "err", /* Never returns */ - "errx", /* Never returns */ - "execl", /* Usually doesn't return */ - "execle", /* Usually doesn't return */ - "execlp", /* Usually doesn't return */ - "execv", /* Usually doesn't return */ - "execv", /* Usually doesn't return */ - "execve", /* Usually doesn't return */ - "execvp", /* Usually doesn't return */ - "execvp", /* Usually doesn't return */ "exit", /* Never returns */ "_exit", /* Never returns */ - "_Exit", /* Never returns */ "longjmp", /* Never returns */ "_longjmp", /* Never returns */ "pthread_exit", /* Never returns */ "siglongjmp", /* Never returns */ - "__uClibc_main", /* Never returns */ - "__uClibc_start_main", /* Never returns */ - "verr", /* Never returns */ - "verrx", /* Never returns */ - NULL /* End of list */ -}; - -/* This is the list of names of libc functions that behave very - * strangely: They return twice. - */ - -static const char *const forkers[] = { - "clone", - "fork", - "setjmp", - "_setjmp", - "__sigsetjmp", - "vfork", NULL /* End of list */ }; @@ -198,12 +164,6 @@ static void show_usage(void) fprintf(stderr, " Take next commands from [cmd-line]\n"); fprintf(stderr, " -o \n"); fprintf(stderr, " Output to [stdout]\n"); - fprintf(stderr, " -p \n"); - fprintf(stderr, - " The maximum number of threads that can make simultaneous\n"); - fprintf(stderr, " make calls into a shared library [6]\n"); - fprintf(stderr, " -t Enable tracing of outbound shared library function\n"); - fprintf(stderr, " calls. [no tracing]\n"); fprintf(stderr, " -v Verbose output [no output]\n"); fprintf(stderr, " -w Import weakly declared functions, i.e., weakly\n"); fprintf(stderr, " declared functions are expected to be provided at\n"); @@ -356,51 +316,6 @@ static void check_for_nonreturning_functions(void) traverse_undefined_functions(NULL, does_not_return_sym); } -/*********************************************************************** - * is_forker_name/sym - ***********************************************************************/ - -static int is_forker_name(const char *func_name) -{ - int i; - - /* Check every name in the list of forkers */ - - for (i = 0; forkers[i] != NULL; i++) - { - /* Is this function name in the list */ - - if (strcmp(func_name, forkers[i]) == 0) - { - /* Yes, return true now. */ - - return 1; - } - } - - /* Its not in the list, return false */ - - return 0; -} - -static int is_forker_sym(asymbol * sym, void *arg) -{ - const char *func_name = sym->name; - if (func_name) - return does_not_return_name(func_name); - else - return 0; -} - -/*********************************************************************** - * check_for_forkers - ***********************************************************************/ - -static void check_for_forkers(void) -{ - calls_forkers = traverse_undefined_functions(NULL, is_forker_sym); -} - /*********************************************************************** * count_undefined ***********************************************************************/ @@ -472,14 +387,7 @@ static int put_nxflat_import(asymbol * sym, void *arg) { /* The special case for functions that may not return */ - sprintf(thunk, nonreturning_dyncall_format, - MKCALLARGS(func_name, counter)); - } - else if (is_forker_name(func_name) != 0) - { - /* The special case for functions that fork */ - - sprintf(thunk, dyncall_format2, MKCALLARGS(func_name, counter)); + sprintf(thunk, nonreturning_dyncall_format, MKCALLARGS(func_name, counter)); } else { @@ -565,68 +473,6 @@ static void inline put_import_name_strtab(int fd) static void inline put_file_epilogue(int fd) { - /* Is it necessary to generate any thunk logic? */ - - if (number_undefined > 0) - { - /* Yes, was tracing enabled? */ - - if (enable_trace > 0) - { - /* Yes, generate the function to output the trace */ - - put_string(fd, dyntrace_function); - } - - /* Output macros for managing the frame storage */ - - put_string(fd, frame_macros); - - if (calls_nonreturning_functions) - { - /* Output special macros for managing frames for noreturning - * functions */ - - put_string(fd, nonreturning_frame_macros); - } - - /* Output the beginning of the dynamic call function. */ - - put_string(fd, dyncall_prologue); - - /* If tracing is enabled, then insert a call to the the trace generation - * function. */ - - if (enable_trace > 0) - { - put_string(fd, dyntrace_call); - } - - /* Output the rest of the dynamic call function. */ - - put_string(fd, dyncall_epilogue); - - /* Does the module call any non-returning functions? */ - - if (calls_nonreturning_functions) - { - /* Yes, output the beginning of a special dynamic call function. */ - - put_string(fd, nonreturning_dyncall_prologue); - - /* If tracing is enabled, then insert a call to the the trace - * generation function. */ - - if (enable_trace > 0) - { - put_string(fd, dyntrace_call); - } - - /* Output the rest of the special dynamic call function. */ - - put_string(fd, nonreturning_dyncall_epilogue); - } - } put_string(fd, file_epilogue); } @@ -637,23 +483,13 @@ static void inline put_file_epilogue(int fd) static void inline put_file_prologue(int fd) { put_string(fd, file_prologue); - if (enable_trace > 0) - { - put_string(fd, dyntrace_enable); - } + if (number_undefined > 0) { char frame_size[1024]; put_string(fd, import_prologue); - sprintf(frame_size, import_frame_size, max_threads); put_string(fd, frame_size); - put_string(fd, dynamic_frames); - - if (calls_nonreturning_functions) - { - put_string(fd, nonreturning_dynamic_frame); - } } } @@ -844,25 +680,6 @@ static void parse_args(int argc, char **argv) out_filename = get_arg(&argno, argc, argv); break; - case 'p': - { - int nthreads = atoi(get_arg(&argno, argc, argv)); - if (nthreads < MIN_THREADS) - { - fprintf(stderr, "Invalid number of threads (%d) using %d\n", - nthreads, max_threads); - } - else - { - max_threads = nthreads; - } - } - break; - - case 't': - enable_trace++; - break; - case 'v': verbose++; break; @@ -924,7 +741,6 @@ int main(int argc, char **argv, char **envp) * will require some additional setup. */ check_for_nonreturning_functions(); - check_for_forkers(); /* Make sure that we can open the output file if one is specified. If no * out_filename is specified, we'll use stdout. */ diff --git a/misc/buildroot/toolchain/nxflat/nxflat.mk b/misc/buildroot/toolchain/nxflat/nxflat.mk index 2a0728e6c..f9df712f2 100644 --- a/misc/buildroot/toolchain/nxflat/nxflat.mk +++ b/misc/buildroot/toolchain/nxflat/nxflat.mk @@ -36,9 +36,15 @@ NXFLAT_DIR = $(TOPDIR)/toolchain/nxflat $(NXFLAT_DIR)/.compiled: +ifeq ($(strip $(BR2_GCC_TARGET_ARCH)),"armv7-m") + echo "NUTTX_DIR: $(NUTTX_DIR)" + $(MAKE) -C $(NXFLAT_DIR) BINUTILS_DIR="$(BINUTILS_DIR1)" \ + ARCH=thumb2 CC="$(HOSTCC)" +else echo "NUTTX_DIR: $(NUTTX_DIR)" $(MAKE) -C $(NXFLAT_DIR) BINUTILS_DIR="$(BINUTILS_DIR1)" \ ARCH=$(BR2_ARCH) CC="$(HOSTCC)" +endif touch $@ $(NXFLAT_DIR)/.installed: $(NXFLAT_DIR)/.compiled diff --git a/misc/buildroot/toolchain/nxflat/thumb2/Makefile b/misc/buildroot/toolchain/nxflat/thumb2/Makefile new file mode 100644 index 000000000..dc00867e0 --- /dev/null +++ b/misc/buildroot/toolchain/nxflat/thumb2/Makefile @@ -0,0 +1,50 @@ +############################################################################ +# toolchain/nxflat/thumb2/Makefile +# +# Copyright (C) 2009 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# 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 NuttX 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 COPYRIGHT HOLDERS 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 +# COPYRIGHT OWNER 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. +# +############################################################################ + +CFLAGS += -Wall +BIN = libarch.a +OBJS = disthumb2.o + +all: $(BIN) + +$(OBJS): %.o: %.c + $(CC) -c $(CFLAGS) -o $@ $< + +$(BIN): $(OBJS) + $(AR) rcs $@ $< + +clean: + rm -f *.o *.a *~ .*.swp core + diff --git a/misc/buildroot/toolchain/nxflat/thumb2/arch.h b/misc/buildroot/toolchain/nxflat/thumb2/arch.h new file mode 100644 index 000000000..9725e4cd1 --- /dev/null +++ b/misc/buildroot/toolchain/nxflat/thumb2/arch.h @@ -0,0 +1,157 @@ +/*********************************************************************** + * xflat/tools/thumb2/arch.h + * ARM thumb2 ELF support for BFD. + * + * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Derived from XFLAT: + * + * Copyright (c) 2006, Cadenux, LLC. All rights reserved. + * Copyright (c) 2006, Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Which simply lifted it from the BFD: + * + * Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + * This file is part of BFD, the Binary File Descriptor library. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + ***********************************************************************/ + +#ifndef _ELF_ARM_H +#define _ELF_ARM_H + +#include "reloc-macros.h" + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x01 +#define EF_ARM_HASENTRY 0x02 +#define EF_INTERWORK 0x04 +#define EF_APCS_26 0x08 +#define EF_APCS_FLOAT 0x10 +#define EF_PIC 0x20 +#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use */ +#define EF_NEW_ABI 0x80 +#define EF_OLD_ABI 0x100 +#define EF_SOFT_FLOAT 0x200 +#define EF_VFP_FLOAT 0x400 + +/* Other constants defined in the ARM ELF spec. version B-01. */ +#define EF_SYMSARESORTED 0x04 /* NB conflicts with EF_INTERWORK */ +#define EF_DYNSYMSUSESEGIDX 0x08 /* NB conflicts with EF_APCS26 */ +#define EF_MAPSYMSFIRST 0x10 /* NB conflicts with EF_APCS_FLOAT */ +#define EF_EABIMASK 0xFF000000 + +#define EF_EABI_VERSION(flags) ((flags) & EF_EABIMASK) +#define EF_EABI_UNKNOWN 0x00000000 +#define EF_EABI_VER1 0x01000000 +#define EF_EABI_VER2 0x02000000 + +/* Local aliases for some flags to match names used by COFF port. */ +#define F_INTERWORK EF_INTERWORK +#define F_APCS26 EF_APCS_26 +#define F_APCS_FLOAT EF_APCS_FLOAT +#define F_PIC EF_PIC +#define F_SOFT_FLOAT EF_SOFT_FLOAT +#define F_VFP_FLOAT EF_VFP_FLOAT + +/* Additional symbol types for Thumb */ +#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */ +#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */ + +/* ARM-specific values for sh_flags */ +#define SHF_ENTRYSECT 0x10000000 /* Section contains an entry point. */ +#define SHF_COMDEF 0x80000000 /* Section may be multiply defined in the input to a link step. */ + +/* ARM-specific program header flags. */ +#define PF_ARM_SB 0x10000000 /* Segment contains the location addressed by the static base. */ +#define PF_ARM_PI 0x20000000 /* Segment is position-independent. */ +#define PF_ARM_ABS 0x40000000 /* Segment must be loaded at its base address. */ + +/* Relocation types. */ + +START_RELOC_NUMBERS (elf_arm_reloc_type) + RELOC_NUMBER (R_ARM_NONE, 0) + RELOC_NUMBER (R_ARM_PC24, 1) + RELOC_NUMBER (R_ARM_ABS32, 2) + RELOC_NUMBER (R_ARM_REL32, 3) +#ifdef OLD_ARM_ABI + RELOC_NUMBER (R_ARM_ABS8, 4) + RELOC_NUMBER (R_ARM_ABS16, 5) + RELOC_NUMBER (R_ARM_ABS12, 6) + RELOC_NUMBER (R_ARM_THM_ABS5, 7) + RELOC_NUMBER (R_ARM_THM_PC22, 8) + RELOC_NUMBER (R_ARM_SBREL32, 9) + RELOC_NUMBER (R_ARM_AMP_VCALL9, 10) + RELOC_NUMBER (R_ARM_THM_PC11, 11) /* Cygnus extension to abi: Thumb unconditional branch. */ + RELOC_NUMBER (R_ARM_THM_PC9, 12) /* Cygnus extension to abi: Thumb conditional branch. */ + RELOC_NUMBER (R_ARM_GNU_VTINHERIT, 13) + RELOC_NUMBER (R_ARM_GNU_VTENTRY, 14) +#else /* not OLD_ARM_ABI */ + RELOC_NUMBER (R_ARM_PC13, 4) + RELOC_NUMBER (R_ARM_ABS16, 5) + RELOC_NUMBER (R_ARM_ABS12, 6) + RELOC_NUMBER (R_ARM_THM_ABS5, 7) + RELOC_NUMBER (R_ARM_ABS8, 8) + RELOC_NUMBER (R_ARM_SBREL32, 9) + RELOC_NUMBER (R_ARM_THM_PC22, 10) + RELOC_NUMBER (R_ARM_THM_PC8, 11) + RELOC_NUMBER (R_ARM_AMP_VCALL9, 12) + RELOC_NUMBER (R_ARM_SWI24, 13) + RELOC_NUMBER (R_ARM_THM_SWI8, 14) + RELOC_NUMBER (R_ARM_XPC25, 15) + RELOC_NUMBER (R_ARM_THM_XPC22, 16) +#endif /* not OLD_ARM_ABI */ + RELOC_NUMBER (R_ARM_COPY, 20) /* Copy symbol at runtime. */ + RELOC_NUMBER (R_ARM_GLOB_DAT, 21) /* Create GOT entry. */ + RELOC_NUMBER (R_ARM_JUMP_SLOT, 22) /* Create PLT entry. */ + RELOC_NUMBER (R_ARM_RELATIVE, 23) /* Adjust by program base. */ + RELOC_NUMBER (R_ARM_GOTOFF, 24) /* 32 bit offset to GOT. */ + RELOC_NUMBER (R_ARM_GOTPC, 25) /* 32 bit PC relative offset to GOT. */ + RELOC_NUMBER (R_ARM_GOT32, 26) /* 32 bit GOT entry. */ + RELOC_NUMBER (R_ARM_PLT32, 27) /* 32 bit PLT address. */ +#ifdef OLD_ARM_ABI + FAKE_RELOC (FIRST_INVALID_RELOC, 28) + FAKE_RELOC (LAST_INVALID_RELOC, 249) +#else /* not OLD_ARM_ABI */ + FAKE_RELOC (FIRST_INVALID_RELOC1, 28) + FAKE_RELOC (LAST_INVALID_RELOC1, 31) + RELOC_NUMBER (R_ARM_ALU_PCREL7_0, 32) + RELOC_NUMBER (R_ARM_ALU_PCREL15_8, 33) + RELOC_NUMBER (R_ARM_ALU_PCREL23_15, 34) + RELOC_NUMBER (R_ARM_LDR_SBREL11_0, 35) + RELOC_NUMBER (R_ARM_ALU_SBREL19_12, 36) + RELOC_NUMBER (R_ARM_ALU_SBREL27_20, 37) + FAKE_RELOC (FIRST_INVALID_RELOC2, 38) + FAKE_RELOC (LAST_INVALID_RELOC2, 99) + RELOC_NUMBER (R_ARM_GNU_VTENTRY, 100) + RELOC_NUMBER (R_ARM_GNU_VTINHERIT, 101) + RELOC_NUMBER (R_ARM_THM_PC11, 102) /* Cygnus extension to abi: Thumb unconditional branch. */ + RELOC_NUMBER (R_ARM_THM_PC9, 103) /* Cygnus extension to abi: Thumb conditional branch. */ + FAKE_RELOC (FIRST_INVALID_RELOC3, 104) + FAKE_RELOC (LAST_INVALID_RELOC3, 248) + RELOC_NUMBER (R_ARM_RXPC25, 249) +#endif /* not OLD_ARM_ABI */ + RELOC_NUMBER (R_ARM_RSBREL32, 250) + RELOC_NUMBER (R_ARM_THM_RPC22, 251) + RELOC_NUMBER (R_ARM_RREL32, 252) + RELOC_NUMBER (R_ARM_RABS32, 253) + RELOC_NUMBER (R_ARM_RPC24, 254) + RELOC_NUMBER (R_ARM_RBASE, 255) +END_RELOC_NUMBERS + +#endif /* _ELF_ARM_H */ diff --git a/misc/buildroot/toolchain/nxflat/thumb2/disthumb2.c b/misc/buildroot/toolchain/nxflat/thumb2/disthumb2.c new file mode 100644 index 000000000..79352ce8b --- /dev/null +++ b/misc/buildroot/toolchain/nxflat/thumb2/disthumb2.c @@ -0,0 +1,16 @@ +/*********************************************************************** + * toolchain/nxflat/thumb2/disasm.c + * ARM Thumb2 Disassembler + * + * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + ***********************************************************************/ + +#include +#include + +int print_insn_arm(u_int32_t pc, FILE *stream, u_int32_t given) +{ + return -1; +} diff --git a/misc/buildroot/toolchain/nxflat/thumb2/dyncall_skeleton.def b/misc/buildroot/toolchain/nxflat/thumb2/dyncall_skeleton.def new file mode 100644 index 000000000..4bddcd7db --- /dev/null +++ b/misc/buildroot/toolchain/nxflat/thumb2/dyncall_skeleton.def @@ -0,0 +1,180 @@ +/*********************************************************************** + * toolchain/nxflat/thumb2/dyncall_skeleton.def + * + * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 NuttX 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT OWNER 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. + * + ***********************************************************************/ + +/******************************************************************* + * File Prologue + *******************************************************************/ + +static const char file_prologue[] = + "/*******************************************************************\n" + " *\n" + " * This file contains the dynamic call logic that performs the thunk\n" + " * for outound calls from one module to another.\n" + " *\n" + " * ARM register quick reference:\n" + " *\n" + " * Name Number ARM Procedure Calling Standard Role\n" + " *\n" + " * a1 r0 argument 1/integer result/scratch register/argc\n" + " * a2 r1 argument 2/scratch register/argv\n" + " * a3 r2 argument 3/scratch register/envp\n" + " * a4 r3 argument 4/scratch register\n" + " * v1 r4 register variable\n" + " * v2 r5 register variable\n" + " * v3 r6 register variable\n" + " * v4 r7 register variable\n" + " * v5 r8 register variable\n" + " * sb/v6 r9 static base/register variable\n" + " * sl/v7 r10 stack limit/stack chunk handle/reg. variable\n" + " * fp r11 frame pointer\n" + " * ip r12 scratch register/new-sb in inter-link-unit calls\n" + " * sp r13 lower end of current stack frame\n" + " * lr r14 link address/scratch register\n" + " * pc r15 program counter\n" + " *******************************************************************/\n\n" + "\t.syntax\tunified\n" + "\t.thumb\n\n" + "/*******************************************************************\n" + " * Included Files\n" + " *******************************************************************/\n\n" + "/*******************************************************************\n" + " * Definitions\n" + " *******************************************************************/\n"; + +static const char import_prologue[] = ""; + +/******************************************************************* + * Import Function Name String Table + *******************************************************************/ + +static const char import_name_strtab_prologue[] = + "\n/*******************************************************************\n" + " * Import Function Names\n" + " *******************************************************************/\n\n" + "/* These are the names of all of the functions that are imported.\n" + " * Notice that all data associated with the library names is retained\n" + " * in the .text section." + " */\n\n" + "\t.text\n" + "\t.align\t0\n"; + +#define MKIMPSTRTABARG(fn,i) (i), (i), (i), (fn), (i), (i) + +static const char import_name_strtab_format[] = + "\n\t.local\t__dynimport%04d\n" + "\t.type\t__dynimport%04d, object\n\n" + "__dynimport%04d:\n" + "\t.asciz\t\"%s\"\n" + "\t.size\t__dynimport%04d, .-__dynimport%04d\n"; + +/******************************************************************* + * Dyanamic Call Information + *******************************************************************/ + +static const char dynimport_decl_prologue[] = + "\n/*******************************************************************\n" + " * Imported Symbol Table (an array of type struct flat_import)\n" + " *******************************************************************/\n\n" + "/* Notice that, unlike most other arrays in this file, this array\n" + " * is declared to reside in .data. Because of this, there will be\n" + " * per-process instances of this table.\n" + " */\n\n" + "\t.data\n" + "\t.align\t2\n\n" + "\t.global\t__dynimport_begin\n" + "\t.type\t__dynimport_begin, object\n" + "\t.global\t__dynimport_end\n" + "\t.type\t__dynimport_end, object\n\n"; + +#define MKINFODECLARGS(fn, i) (i), (fn), (i) + +static const char dynimport_decl_format[] = + "\t.local\t__dyninfo%04d\t/* Dynamic info for imported symbol %s */\n" + "\t.type\t__dyninfo%04d, object\n"; + +static const char dynimport_array_prologue[] = + "\n__dynimport_begin:\n"; + +#define MKINFOARGS(fn, i) (i), (fn), (i), (i), (i) + +static const char dynimport_array_format[] = + "__dyninfo%04d:\t\t\t/* Dynamic info for imported symbol %s */\n" + "\t.word\t__dynimport%04d\t/* Offset to name of imported function */\n" + "\t.word\t0\t\t/* Resolved address of imported function */\n" + "\t.size\t__dyninfo%04d, .-__dyninfo%04d\n"; + +static const char dynimport_array_epilogue[] = + "__dynimport_end:\n" + "\t.size\t__dynimport_begin, __dynimport_end-__dynimport_begin\n"; + +static const char dyncall_decl_prologue[] = + "\n/*******************************************************************\n" + " * Dynamic Call Logic\n" + " *******************************************************************/\n\n" + "\t.text\n" + "\t.align\t2\n"; + +#define MKCALLARGS(fn, i) (fn), (fn), (fn), (fn), (i), (fn), (fn) + +static const char dyncall_format[] = + "\n/* Dynamic call logic for imported symbol %s */\n\n" + "\t.global\t%s\n" + "\t.type\t%s, function\n\n" + "%s:\n" + "\tstmdb\tsp!,{r4, lr}\n" + "\tldr\tr4, =__dyninfo%04d\n" + "\tbl\t[r4]\n" + "\tldmia\tsp!,{r4, pc}\n" + "\t.size\t%s, .-%s\n"; + +static const char nonreturning_dyncall_format[] = + "\n/* Dynamic call logic for imported, non-returning symbol %s */\n\n" + "\t.global\t%s\n" + "\t.type\t%s, function\n\n" + "%s:\n" + "\tldr\tr4, =__dyninfo%04d\n" + "\tb\t[r4]\n" + "\t.size\t%s, .-%s\n"; + +/******************************************************************* + * File Epilogue + *******************************************************************/ + +static const char file_epilogue[] = + "\t.end\n"; + + + + -- cgit v1.2.3