This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] blackfin: add support for L1 code/data flags
- From: Mike Frysinger <vapier at gentoo dot org>
- To: binutils at sourceware dot org
- Cc: Jie Zhang <jie dot zhang at analog dot com>
- Date: Tue, 21 Sep 2010 06:23:28 -0400
- Subject: [PATCH] blackfin: add support for L1 code/data flags
From: Jie Zhang <jie.zhang@analog.com>
Add new linker options for marking programs to load into L1 memory
at runtime. This needs new EF flag bits, so declare them.
Signed-off-by: Jie Zhang <jie.zhang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
include/:
2010-09-21 Jie Zhang <jie.zhang@analog.com>
* elf/bfin.h (EF_BFIN_CODE_IN_L1): Define.
(EF_BFIN_DATA_IN_L1): Define.
bfd/:
2010-09-21 Jie Zhang <jie.zhang@analog.com>
* elf32-bfin.c (elf32_bfin_code_in_l1): New variable.
(elf32_bfin_data_in_l1): New variable.
(elf32_bfin_final_write_processing): New.
(elf_backend_final_write_processing): Define.
ld/:
2010-09-21 Jie Zhang <jie.zhang@analog.com>
* Makefile.am (eelf32bfinfd.c, eelf32bfin.c): Depend on bfin.em.
* Makefile.in: Regenerated.
* emulparams/bfin.sh (EXTRA_EM_FILE): Set.
* emulparams/elf32bfinfd.sh (EXTRA_EM_FILE): Likewise.
* emultempl/bfin.em: New.
binutils/:
2010-09-21 Jie Zhang <jie.zhang@analog.com>
* readelf.c (get_machine_flags): Deal with Blackfin specific
flags.
---
bfd/elf32-bfin.c | 18 +++++++++++
binutils/readelf.c | 15 +++++++++
include/elf/bfin.h | 3 ++
ld/Makefile.am | 7 ++--
ld/Makefile.in | 7 ++--
ld/emulparams/bfin.sh | 1 +
ld/emulparams/elf32bfinfd.sh | 1 +
ld/emultempl/bfin.em | 65 ++++++++++++++++++++++++++++++++++++++++++
8 files changed, 111 insertions(+), 6 deletions(-)
create mode 100644 ld/emultempl/bfin.em
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index e329f43..2384095 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -1120,6 +1120,22 @@ bfin_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
return (reloc_howto_type *) NULL;
}
+/* Set by ld emulation if --code-in-l1. */
+bfd_boolean elf32_bfin_code_in_l1 = 0;
+
+/* Set by ld emulation if --data-in-l1. */
+bfd_boolean elf32_bfin_data_in_l1 = 0;
+
+static void
+elf32_bfin_final_write_processing (bfd *abfd,
+ bfd_boolean linker ATTRIBUTE_UNUSED)
+{
+ if (elf32_bfin_code_in_l1)
+ elf_elfheader (abfd)->e_flags |= EF_BFIN_CODE_IN_L1;
+ if (elf32_bfin_data_in_l1)
+ elf_elfheader (abfd)->e_flags |= EF_BFIN_DATA_IN_L1;
+}
+
/* Return TRUE if the name is a local label.
bfin local labels begin with L$. */
static bfd_boolean
@@ -5808,6 +5824,8 @@ struct bfd_elf_special_section const elf32_bfin_special_sections[] =
elf32_bfin_set_private_flags
#define bfd_elf32_bfd_print_private_bfd_data \
elf32_bfin_print_private_bfd_data
+#define elf_backend_final_write_processing \
+ elf32_bfin_final_write_processing
#define elf_backend_reloc_type_class elf32_bfin_reloc_type_class
#define elf_backend_can_gc_sections 1
#define elf_backend_special_sections elf32_bfin_special_sections
diff --git a/binutils/readelf.c b/binutils/readelf.c
index b91c5ba..4328769 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -2237,6 +2237,21 @@ get_machine_flags (unsigned e_flags, unsigned e_machine)
decode_ARM_machine_flags (e_flags, buf);
break;
+ case EM_BLACKFIN:
+ if (e_flags & EF_BFIN_PIC)
+ strcat (buf, ", PIC");
+
+ if (e_flags & EF_BFIN_FDPIC)
+ strcat (buf, ", FDPIC");
+
+ if (e_flags & EF_BFIN_CODE_IN_L1)
+ strcat (buf, ", code in L1");
+
+ if (e_flags & EF_BFIN_DATA_IN_L1)
+ strcat (buf, ", data in L1");
+
+ break;
+
case EM_CYGNUS_FRV:
switch (e_flags & EF_FRV_CPU_MASK)
{
diff --git a/include/elf/bfin.h b/include/elf/bfin.h
index 851873f..8d92906 100644
--- a/include/elf/bfin.h
+++ b/include/elf/bfin.h
@@ -88,5 +88,8 @@ END_RELOC_NUMBERS (R_BFIN_max)
#define EF_BFIN_PIC 0x00000001 /* -fpic */
#define EF_BFIN_FDPIC 0x00000002 /* -mfdpic */
+#define EF_BFIN_CODE_IN_L1 0x00000010 /* --code-in-l1 */
+#define EF_BFIN_DATA_IN_L1 0x00000020 /* --data-in-l1 */
+
#define EF_BFIN_PIC_FLAGS (EF_BFIN_PIC | EF_BFIN_FDPIC)
#endif /* _ELF_BFIN_H */
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 9eaf0e2..72d3870 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -771,11 +771,12 @@ edelta68.c: $(srcdir)/emulparams/delta68.sh \
$(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/delta68.sc ${GEN_DEPENDS}
${GENSCRIPTS} delta68 "$(tdir_delta68)"
eelf32bfin.c: $(srcdir)/emulparams/bfin.sh \
- $(ELF_DEPS) \
+ $(ELF_DEPS) $(srcdir)/emultempl/bfin.em \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf32bfin "$(tdir_elf32bfin)" bfin
-eelf32bfinfd.c: $(srcdir)/emulparams/elf32bfinfd.sh $(srcdir)/emulparams/bfin.sh \
- $(ELF_DEPS) \
+eelf32bfinfd.c: $(srcdir)/emulparams/elf32bfinfd.sh \
+ $(srcdir)/emulparams/bfin.sh \
+ $(ELF_DEPS) $(srcdir)/emultempl/bfin.em \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf32bfinfd "$(tdir_elf32bfinfd)" elf32bfinfd
eelf32_dlx.c: $(srcdir)/emulparams/elf32_dlx.sh \
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 831eb0e..80eacaf 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -1797,11 +1797,12 @@ edelta68.c: $(srcdir)/emulparams/delta68.sh \
$(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/delta68.sc ${GEN_DEPENDS}
${GENSCRIPTS} delta68 "$(tdir_delta68)"
eelf32bfin.c: $(srcdir)/emulparams/bfin.sh \
- $(ELF_DEPS) \
+ $(ELF_DEPS) $(srcdir)/emultempl/bfin.em \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf32bfin "$(tdir_elf32bfin)" bfin
-eelf32bfinfd.c: $(srcdir)/emulparams/elf32bfinfd.sh $(srcdir)/emulparams/bfin.sh \
- $(ELF_DEPS) \
+eelf32bfinfd.c: $(srcdir)/emulparams/elf32bfinfd.sh \
+ $(srcdir)/emulparams/bfin.sh \
+ $(ELF_DEPS) $(srcdir)/emultempl/bfin.em \
$(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf32bfinfd "$(tdir_elf32bfinfd)" elf32bfinfd
eelf32_dlx.c: $(srcdir)/emulparams/elf32_dlx.sh \
diff --git a/ld/emulparams/bfin.sh b/ld/emulparams/bfin.sh
index 3de8921..6c0bb40 100755
--- a/ld/emulparams/bfin.sh
+++ b/ld/emulparams/bfin.sh
@@ -9,3 +9,4 @@ TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
EMBEDDED=yes
USER_LABEL_PREFIX=_
+EXTRA_EM_FILE=bfin
diff --git a/ld/emulparams/elf32bfinfd.sh b/ld/emulparams/elf32bfinfd.sh
index 3e0420e..26f8f47 100644
--- a/ld/emulparams/elf32bfinfd.sh
+++ b/ld/emulparams/elf32bfinfd.sh
@@ -43,3 +43,4 @@ OTHER_SECTIONS="
*(.l1.text)
}
"
+EXTRA_EM_FILE=bfin
diff --git a/ld/emultempl/bfin.em b/ld/emultempl/bfin.em
new file mode 100644
index 0000000..ca57ac1
--- /dev/null
+++ b/ld/emultempl/bfin.em
@@ -0,0 +1,65 @@
+# This shell script emits a C file. -*- C -*-
+# Copyright 2010 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+# This file is sourced from elf32.em, and defines extra bfin-elf
+# specific routines.
+#
+fragment <<EOF
+
+#include "elf-bfd.h"
+
+/* Whether to put code in Blackfin L1 SRAM. */
+extern bfd_boolean elf32_bfin_code_in_l1;
+
+/* Whether to put (writable) data in Blackfin L1 SRAM. */
+extern bfd_boolean elf32_bfin_data_in_l1;
+
+EOF
+
+
+# Define some shell vars to insert bits of code into the standard elf
+# parse_args and list_options functions.
+#
+PARSE_AND_LIST_PROLOGUE='
+#define OPTION_CODE_IN_L1 300
+#define OPTION_DATA_IN_L1 301
+'
+
+PARSE_AND_LIST_LONGOPTS='
+ { "code-in-l1", no_argument, NULL, OPTION_CODE_IN_L1 },
+ { "data-in-l1", no_argument, NULL, OPTION_DATA_IN_L1 },
+'
+
+PARSE_AND_LIST_OPTIONS='
+ fprintf (file, _("\
+ --code-in-l1 Put code in L1.\n\
+ --data-in-l1 Put data in L1.\n"
+ ));
+'
+
+PARSE_AND_LIST_ARGS_CASES='
+ case OPTION_CODE_IN_L1:
+ elf32_bfin_code_in_l1 = TRUE;
+ break;
+ case OPTION_DATA_IN_L1:
+ elf32_bfin_data_in_l1 = TRUE;
+ break;
+'
--
1.7.2