aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/avr/driver-avr.c
diff options
context:
space:
mode:
authorAnatoly Sokolov <aesok@post.ru>2009-06-23 23:14:11 +0400
committerAnatoly Sokolov <aesok@gcc.gnu.org>2009-06-23 23:14:11 +0400
commit59ab92d2918a7e7ee914bf86cff5bcbabb68d9b9 (patch)
tree32802b739934030c58f3589d23ed35b2f3eaede3 /gcc/config/avr/driver-avr.c
parent33436e29779504361151f07a6a75970d03b5fe4c (diff)
downloadgcc-59ab92d2918a7e7ee914bf86cff5bcbabb68d9b9.zip
gcc-59ab92d2918a7e7ee914bf86cff5bcbabb68d9b9.tar.gz
gcc-59ab92d2918a7e7ee914bf86cff5bcbabb68d9b9.tar.bz2
config.gcc (avr-*-rtems*, avr-*-*): Set extra_gcc_objs and extra_objs.
* config.gcc (avr-*-rtems*, avr-*-*): Set extra_gcc_objs and extra_objs. * config/avr/avr.c (avr_current_device): New variable. (avr_arch_types, avr_mcu_types): Move to avr-deveces.c. (avr_arch, mcu_type_s): Move to avr.h. * config/avr/avr.h (base_arch_s). Add reserved2, arch_name and default_data_section_start fields. (avr_arch): Moved from avr.c. (mcu_type_s): Moved from avr.c. Add short_sp, data_section_start and library_name fields. (avr_current_device, avr_mcu_types, avr_arch_types, avr_device_to_arch, avr_device_to_data_start, avr_device_to_startfiles, avr_device_to_devicelib): Declare. (EXTRA_SPEC_FUNCTIONS): Define. (LINK_SPEC): Remove device name to '-m ...' and '-Tdata ...' linker options mapping. Use device_to_arch and device_to_data_start insted. (STARTFILE_SPEC): Use device_to_startfile instead of crt_binutils. (CRT_BINUTILS_SPECS, EXTRA_SPECS): Remove. * config/avr/t-avr (driver-avr.o, avr-devices.o): New rules. * config/avr/driver-avr.c: New file. * config/avr/avr-devices.c: New file. From-SVN: r148868
Diffstat (limited to 'gcc/config/avr/driver-avr.c')
-rwxr-xr-xgcc/config/avr/driver-avr.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/gcc/config/avr/driver-avr.c b/gcc/config/avr/driver-avr.c
new file mode 100755
index 0000000..218c406
--- /dev/null
+++ b/gcc/config/avr/driver-avr.c
@@ -0,0 +1,115 @@
+/* Subroutines for the gcc driver.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Anatoly Sokolov <aesok@post.ru>
+
+This file is part of GCC.
+
+GCC 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 3, or (at your option)
+any later version.
+
+GCC 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 GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include <stdlib.h>
+
+/* Current architecture. */
+const struct base_arch_s *avr_current_arch = NULL;
+
+/* Current device. */
+const struct mcu_type_s *avr_current_device = NULL;
+
+/* Initialize avr_current_arch and avr_current_device variables. */
+
+static void
+avr_set_current_device (const char *name)
+{
+
+ if (NULL != avr_current_arch)
+ return;
+
+ for (avr_current_device = avr_mcu_types; avr_current_device->name;
+ avr_current_device++)
+ {
+ if (strcmp (avr_current_device->name, name) == 0)
+ break;
+ }
+
+ avr_current_arch = &avr_arch_types[avr_current_device->arch];
+}
+
+/* Returns command line parameters that describe the device architecture. */
+
+const char *
+avr_device_to_arch (int argc, const char **argv)
+{
+ if (0 == argc)
+ return;
+
+ avr_set_current_device (argv[0]);
+
+ return concat ("-m ", avr_current_arch->arch_name, NULL);
+}
+
+/* Returns command line parameters that describe start of date section. */
+
+const char *
+avr_device_to_data_start (int argc, const char **argv)
+{
+ unsigned long data_section_start;
+ char data_section_start_str[16];
+
+ if (0 == argc)
+ return;
+
+ avr_set_current_device (argv[0]);
+
+ if (avr_current_device->data_section_start
+ == avr_current_arch->default_data_section_start)
+ return NULL;
+
+ data_section_start = 0x800000 + avr_current_device->data_section_start;
+
+ snprintf (data_section_start_str, sizeof(data_section_start_str) - 1,
+ "0x%lX", data_section_start);
+
+ return concat ("-Tdata ", data_section_start_str, NULL);
+}
+
+/* Returns command line parameters that describe the device startfile. */
+
+const char *
+avr_device_to_startfiles (int argc, const char **argv)
+{
+ if (0 == argc)
+ return;
+
+ avr_set_current_device (argv[0]);
+
+ return concat ("crt", avr_current_device->library_name, ".o%s", NULL);
+}
+
+/* Returns command line parameters that describe the device library. */
+
+const char *
+avr_device_to_devicelib (int argc, const char **argv)
+{
+ if (0 == argc)
+ return;
+
+ avr_set_current_device (argv[0]);
+
+ return concat ("-l", avr_current_device->library_name, NULL);
+}
+