Skip to content

Commit

Permalink
Add Athena base configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
d0p1s4m4 committed Aug 12, 2022
1 parent 537710a commit 0f01145
Show file tree
Hide file tree
Showing 19 changed files with 308 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bfd/archures.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
. };
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions bfd/bfd-in2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions bfd/config.bfd
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;;
Expand Down Expand Up @@ -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
;;
Expand Down
1 change: 1 addition & 0 deletions bfd/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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" ;;
Expand Down
65 changes: 65 additions & 0 deletions bfd/cpu-athena.c
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>. */

#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
};
48 changes: 48 additions & 0 deletions bfd/elf32-athena.c
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>. */

#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"
3 changes: 3 additions & 0 deletions bfd/targets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions config.sub
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
121 changes: 121 additions & 0 deletions gas/config/tc-athena.c
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>. */

#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);
}
34 changes: 34 additions & 0 deletions gas/config/tc-athena.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>. */

#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
3 changes: 3 additions & 0 deletions gas/configure.tgt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;;
Expand Down Expand Up @@ -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 ;;
Expand Down
1 change: 1 addition & 0 deletions include/elf/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ld/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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@
Expand Down
Loading

0 comments on commit 0f01145

Please sign in to comment.