From 0f01145a89e6a294224c4693929487f45cc79225 Mon Sep 17 00:00:00 2001 From: d0p1 Date: Thu, 11 Aug 2022 16:48:53 +0200 Subject: [PATCH] Add Athena base configuration --- bfd/archures.c | 4 ++ bfd/bfd-in2.h | 2 + bfd/config.bfd | 6 ++ bfd/configure | 1 + bfd/cpu-athena.c | 65 +++++++++++++++++++ bfd/elf32-athena.c | 48 ++++++++++++++ bfd/targets.c | 3 + config.sub | 1 + gas/config/tc-athena.c | 121 +++++++++++++++++++++++++++++++++++ gas/config/tc-athena.h | 34 ++++++++++ gas/configure.tgt | 3 + include/elf/common.h | 1 + ld/Makefile.am | 2 + ld/Makefile.in | 2 + ld/configure.tgt | 2 + ld/emulparams/elf32athena.sh | 10 +++ opcodes/athena-dis.c | 1 + opcodes/athena-opc.c | 1 + opcodes/configure | 1 + 19 files changed, 308 insertions(+) create mode 100644 bfd/cpu-athena.c create mode 100644 bfd/elf32-athena.c create mode 100644 gas/config/tc-athena.c create mode 100644 gas/config/tc-athena.h create mode 100644 ld/emulparams/elf32athena.sh create mode 100644 opcodes/athena-dis.c create mode 100644 opcodes/athena-opc.c diff --git a/bfd/archures.c b/bfd/archures.c index c67bacddfdc..9dd6820573e 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -562,6 +562,8 @@ DESCRIPTION .#define bfd_mach_amdgcn_gfx1030 0x036 .#define bfd_mach_amdgcn_gfx1031 0x037 .#define bfd_mach_amdgcn_gfx1032 0x038 +. bfd_arch_athena, {* Athena CPU *} +.#define bfd_arch_athena 1 . bfd_arch_last . }; */ @@ -620,6 +622,7 @@ extern const bfd_arch_info_type bfd_alpha_arch; extern const bfd_arch_info_type bfd_amdgcn_arch; extern const bfd_arch_info_type bfd_arc_arch; extern const bfd_arch_info_type bfd_arm_arch; +extern const bfd_arch_info_type bfd_athena_arch; extern const bfd_arch_info_type bfd_avr_arch; extern const bfd_arch_info_type bfd_bfin_arch; extern const bfd_arch_info_type bfd_cr16_arch; @@ -708,6 +711,7 @@ static const bfd_arch_info_type * const bfd_archures_list[] = &bfd_amdgcn_arch, &bfd_arc_arch, &bfd_arm_arch, + &bfd_athena_arch, &bfd_avr_arch, &bfd_bfin_arch, &bfd_cr16_arch, diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 4ab7e2d6934..18b161e7531 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1387,6 +1387,8 @@ enum bfd_architecture { bfd_arch_unknown, /* File arch not known. */ bfd_arch_obscure, /* Arch known, not one of these. */ + bfd_arch_athena, /* Athena */ +#define bfd_mach_athena 1 bfd_arch_m68k, /* Motorola 68xxx. */ #define bfd_mach_m68000 1 #define bfd_mach_m68008 2 diff --git a/bfd/config.bfd b/bfd/config.bfd index c514479b1f2..05b6f301051 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -184,6 +184,7 @@ alpha*) targ_archs=bfd_alpha_arch ;; am33_2.0*) targ_archs=bfd_mn10300_arch ;; arc*) targ_archs=bfd_arc_arch ;; arm*) targ_archs=bfd_arm_arch ;; +athena*) targ_archs=bfd_athena_arch ;; amdgcn*) targ_archs=bfd_amdgcn_arch ;; bfin*) targ_archs=bfd_bfin_arch ;; c30*) targ_archs=bfd_tic30_arch ;; @@ -425,6 +426,11 @@ case "${targ}" in targ_selvecs=arm_elf32_be_vec ;; + athena-*-linux*) + targ_defvec=athena_elf32_vec + targ_selvecs=athena_elf32_vec + ;; + avr-*-*) targ_defvec=avr_elf32_vec ;; diff --git a/bfd/configure b/bfd/configure index b5e44e6af79..2362b32bed1 100755 --- a/bfd/configure +++ b/bfd/configure @@ -13354,6 +13354,7 @@ do arm_pei_wince_be_vec) tb="$tb pei-arm-wince.lo pei-arm.lo peigen.lo $coff" ;; arm_pei_wince_le_vec) tb="$tb pei-arm-wince.lo pei-arm.lo peigen.lo $coff" ;; arm_mach_o_vec) tb="$tb mach-o-arm.lo" ;; + athena_elf32_vec) tb="$tb elf32-athena.lo elf32.lo $elf" ;; avr_elf32_vec) tb="$tb elf32-avr.lo elf32.lo $elf" ;; bfin_elf32_vec) tb="$tb elf32-bfin.lo elf32.lo $elf" ;; bfin_elf32_fdpic_vec) tb="$tb elf32-bfin.lo elf32.lo $elf" ;; diff --git a/bfd/cpu-athena.c b/bfd/cpu-athena.c new file mode 100644 index 00000000000..625ce5b16d0 --- /dev/null +++ b/bfd/cpu-athena.c @@ -0,0 +1,65 @@ +/* BFD support for Athena. + Copyright (C) 2022 d0p1. + + 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 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; see the file COPYING3. If not, + see . */ + +#include "sysdep.h" +#include "bfd.h" +#include "libbfd.h" + +const bfd_arch_info_type bfd_athena_arch = +{ + /* word size */ + 32, + + /* address size */ + 32, + + /* byte size */ + 8, + + /* arch enum */ + bfd_arch_athena, + + /* machine num */ + bfd_mach_athena, + + /* arch name */ + "athena", + + /* printable name */ + "Athena", + + /* alligment */ + 4, + + /* is default */ + true, + + /* default check compat */ + bfd_default_compatible, + + /* */ + bfd_default_scan, + + /* memory alloc */ + bfd_arch_default_fill, + + NULL, + + 0 +}; diff --git a/bfd/elf32-athena.c b/bfd/elf32-athena.c new file mode 100644 index 00000000000..b45cc87a5c0 --- /dev/null +++ b/bfd/elf32-athena.c @@ -0,0 +1,48 @@ +/* 32-bit ELF support for Athena. + Copyright (C) 2022 d0p1. + + 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 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; see the file COPYING3. If not, + see . */ + +#include "sysdep.h" +#include "bfd.h" +#include "libbfd.h" +#include "elf-bfd.h" + +static reloc_howto_type * +bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, + bfd_reloc_code_real_type code) +{ + (void)code; + return NULL; +} + +static reloc_howto_type * +bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, + const char *r_name) +{ +(void)r_name; + return NULL; +} + +#define ELF_ARCH bfd_arch_athena +#define ELF_MAXPAGESIZE 4096 +#define ELF_MACHINE_CODE EM_ATHENA + +#define TARGET_BIG_SYM athena_elf32_vec +#define TARGET_BIG_NAME "elf32-athena" + +#include "elf32-target.h" diff --git a/bfd/targets.c b/bfd/targets.c index 8ad3ef366ce..8e5743f56fe 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -707,6 +707,7 @@ extern const bfd_target arm_pei_be_vec; extern const bfd_target arm_pei_le_vec; extern const bfd_target arm_pei_wince_be_vec; extern const bfd_target arm_pei_wince_le_vec; +extern const bfd_target athena_elf32_vec; extern const bfd_target avr_elf32_vec; extern const bfd_target bfin_elf32_vec; extern const bfd_target bfin_elf32_fdpic_vec; @@ -1033,6 +1034,8 @@ static const bfd_target * const _bfd_target_vector[] = &arm_pei_wince_be_vec, &arm_pei_wince_le_vec, + &athena_elf32_vec, + &avr_elf32_vec, &bfin_elf32_vec, diff --git a/config.sub b/config.sub index dba16e84c77..293411be36d 100755 --- a/config.sub +++ b/config.sub @@ -1189,6 +1189,7 @@ case $cpu-$vendor in | amdgcn \ | arc | arceb | arc32 | arc64 \ | arm | arm[lb]e | arme[lb] | armv* \ + | athena \ | avr | avr32 \ | asmjs \ | ba \ diff --git a/gas/config/tc-athena.c b/gas/config/tc-athena.c new file mode 100644 index 00000000000..3aabe36a6a9 --- /dev/null +++ b/gas/config/tc-athena.c @@ -0,0 +1,121 @@ +/* tc-athena.c -- Assemble for the Athena ISA + + Copyright (C) 2022 d0p1. + + This file is part of GAS. + + GAS 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. + + GAS 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; see the file COPYING3. If not, + see . */ + +#include "as.h" +#include "bfd.h" + + +const char *md_shortopts = ""; +struct option md_longopts[] = {}; +size_t md_longopts_size = sizeof(md_longopts); + +const char comment_chars[] = ""; +const char line_comment_chars[] = "//"; +const char line_separator_chars[] = ";"; + +const char EXP_CHARS[] = ""; +const char FLT_CHARS[] = ""; + +const pseudo_typeS md_pseudo_table[] = +{ + { NULL, NULL, 0 } +}; + +int md_parse_option(int c, const char *arg) +{ + (void)c; + (void)arg; + return (0); +} + +void md_show_usage(FILE *stream) +{ + fprintf(stream, "Athena Hello\n"); +} + +void md_begin(void) +{ + +} + +void md_assemble(char *insn_str) +{ + (void)insn_str; +} + +symbolS *md_undefined_symbol(char *name) +{ + (void)name; + + return (NULL); +} + +const char *md_atof(int type, char *lit, int *size) +{ + (void)type; + (void)lit; + (void)size; + return (NULL); +} + +valueT md_section_align(asection *seg, valueT val) +{ + (void)seg; + (void)val; + + return (0); +} + +void md_convert_frag(bfd *abfd, asection *seg, fragS *fragp) +{ + (void)abfd; + (void)seg; + (void)fragp; +} + +void md_apply_fix(fixS *fixp, valueT *val, segT seg) +{ + (void)fixp; + (void)val; + (void)seg; +} + +arelent *tc_gen_reloc(asection *seg, fixS *fixp) +{ + (void)seg; + (void)fixp; + + return (NULL); +} + +long md_pcrel_from(fixS *fixp) +{ + (void)fixp; + return 0; +} + +int md_estimate_size_before_relax(fragS *fragp, asection *seg) +{ + (void)fragp; + (void)seg; + + as_fatal(_("wtf bro")); + return (0); +} diff --git a/gas/config/tc-athena.h b/gas/config/tc-athena.h new file mode 100644 index 00000000000..aa73eea2828 --- /dev/null +++ b/gas/config/tc-athena.h @@ -0,0 +1,34 @@ +/* tc-athena.h -- Assemble for the Athena ISA + + Copyright (C) 2022 d0p1. + + This file is part of GAS. + + GAS 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. + + GAS 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; see the file COPYING3. If not, + see . */ + +#ifndef TC_ATHENA_H +#define TC_ATHENA_H + +#define TARGET_FORMAT "elf32-athena" +#define TARGET_ARCH bfd_arch_athena +#define TARGET_MARCH bfd_mach_athena + + +#define md_operand(x) +#define md_number_to_chars number_to_chars_bigendian +#define WORKING_DOT_WORD + + +#endif diff --git a/gas/configure.tgt b/gas/configure.tgt index 62f806bdfe8..a8790c13437 100644 --- a/gas/configure.tgt +++ b/gas/configure.tgt @@ -53,6 +53,7 @@ case ${cpu} in arc*eb) cpu_type=arc endian=big ;; arm*be|arm*b) cpu_type=arm endian=big ;; arm*) cpu_type=arm endian=little ;; + athena*) cpu_type=athena endian=big ;; bfin*) cpu_type=bfin endian=little ;; c4x*) cpu_type=tic4x ;; cr16*) cpu_type=cr16 endian=little ;; @@ -166,6 +167,8 @@ case ${generic_target} in arm-*-fuchsia*) fmt=elf ;; arm-*-haiku*) fmt=elf em=haiku ;; + athena-*-*) fmt=elf ;; + avr-*-*) fmt=elf bfd_gas=yes ;; bfin-*-linux-uclibc) fmt=fdpicelf em=linux ;; diff --git a/include/elf/common.h b/include/elf/common.h index ebcd8f9e82c..7f5ed7f0143 100644 --- a/include/elf/common.h +++ b/include/elf/common.h @@ -360,6 +360,7 @@ #define EM_U16_U8CORE 260 /* LAPIS nX-U16/U8 */ #define EM_TACHYUM 261 /* Tachyum */ #define EM_56800EF 262 /* NXP 56800EF Digital Signal Controller (DSC) */ +#define EM_ATHENA 666 /* If it is necessary to assign new unofficial EM_* values, please pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision diff --git a/ld/Makefile.am b/ld/Makefile.am index d31021c13e2..a01b59017fe 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -224,6 +224,7 @@ ALL_EMULATION_SOURCES = \ eelf32_tic6x_linux_be.c \ eelf32_tic6x_linux_le.c \ eelf32am33lin.c \ + eelf32athena.c \ eelf32bfin.c \ eelf32bfinfd.c \ eelf32cr16.c \ @@ -715,6 +716,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS) @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32_tic6x_linux_be.Pc@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32_tic6x_linux_le.Pc@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32am33lin.Pc@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32athena.Pc@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32bfin.Pc@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32bfinfd.Pc@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32cr16.Pc@am__quote@ diff --git a/ld/Makefile.in b/ld/Makefile.in index ee0c98f65b0..34e4764f3fe 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -721,6 +721,7 @@ ALL_EMULATION_SOURCES = \ eelf32_tic6x_linux_be.c \ eelf32_tic6x_linux_le.c \ eelf32am33lin.c \ + eelf32athena.c \ eelf32bfin.c \ eelf32bfinfd.c \ eelf32cr16.c \ @@ -2529,6 +2530,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS) @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ez8001.Pc@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ez8002.Pc@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32athena.Pc@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64cloudabi.Pc@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64cloudabib.Pc@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64elf.Pc@am__quote@ diff --git a/ld/configure.tgt b/ld/configure.tgt index 2bae9099b6a..fe94b4fe21f 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -242,6 +242,8 @@ arm*-*-fuchsia*) targ_emul=armelf_fuchsia arm*-*-haiku*) targ_emul=armelf_haiku targ_extra_emuls=armelf ;; +athena-*-*) targ_emul=elf32athena + ;; avr-*-*) targ_emul=avr2 targ_extra_emuls="avr1 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 avrxmega1 avrxmega2 avrxmega3 avrxmega4 avrxmega5 avrxmega6 avrxmega7 avrtiny" ;; diff --git a/ld/emulparams/elf32athena.sh b/ld/emulparams/elf32athena.sh new file mode 100644 index 00000000000..54a6b41e1f3 --- /dev/null +++ b/ld/emulparams/elf32athena.sh @@ -0,0 +1,10 @@ +ARCH=athena +MACHINE= +SCRIPT_NAME=elf +OUTPUT_FORMAT="elf32-athena" +MAXPAGESIZE=0x1000 +EMBEDDED=yes +TEMPLATE_NAME=elf +TEXT_START_ADDR=0x0000 +DYNAMIC_LINK=false +ALIGNMENT=4 diff --git a/opcodes/athena-dis.c b/opcodes/athena-dis.c new file mode 100644 index 00000000000..8f414f586f2 --- /dev/null +++ b/opcodes/athena-dis.c @@ -0,0 +1 @@ +/* TODO */ diff --git a/opcodes/athena-opc.c b/opcodes/athena-opc.c new file mode 100644 index 00000000000..8f414f586f2 --- /dev/null +++ b/opcodes/athena-opc.c @@ -0,0 +1 @@ +/* TODO */ diff --git a/opcodes/configure b/opcodes/configure index a5951b9b362..7796ec9c40b 100755 --- a/opcodes/configure +++ b/opcodes/configure @@ -12500,6 +12500,7 @@ if test x${all_targets} = xfalse ; then bfd_amdgcn_arch) ;; bfd_arc_arch) ta="$ta arc-dis.lo arc-opc.lo arc-ext.lo" ;; bfd_arm_arch) ta="$ta arm-dis.lo" ;; + bfd_athena_arch) ta="$ta athena-dis.lo athena-opc.lo" ;; bfd_avr_arch) ta="$ta avr-dis.lo" ;; bfd_bfin_arch) ta="$ta bfin-dis.lo" ;; bfd_cr16_arch) ta="$ta cr16-dis.lo cr16-opc.lo" ;;