kvx: New port.

This commit is contained in:
Paul Iannetta 2023-08-16 14:22:28 +01:00 committed by Nick Clifton
parent 7d6a2e34ee
commit 6e712424f5
125 changed files with 191062 additions and 15 deletions

View file

@ -122,6 +122,7 @@ ALL_MACHINES = \
cpu-ip2k.lo \
cpu-iq2000.lo \
cpu-lm32.lo \
cpu-kvx.lo \
cpu-loongarch.lo \
cpu-m10200.lo \
cpu-m10300.lo \
@ -201,6 +202,7 @@ ALL_MACHINES_CFILES = \
cpu-hppa.c \
cpu-i386.c \
cpu-iamcu.c \
cpu-kvx.c \
cpu-ia64.c \
cpu-ip2k.c \
cpu-iq2000.c \
@ -317,6 +319,8 @@ BFD32_BACKENDS = \
elfxx-x86.lo \
elf32-ip2k.lo \
elf32-iq2000.lo \
elf32-kvx.lo \
elfxx-kvx.lo \
elf32-lm32.lo \
elf32-m32c.lo \
elf32-m32r.lo \
@ -452,6 +456,7 @@ BFD32_BACKENDS_CFILES = \
elfxx-x86.c \
elf32-ip2k.c \
elf32-iq2000.c \
elfxx-kvx.c \
elf32-lm32.c \
elf32-m32c.c \
elf32-m32r.c \
@ -556,6 +561,8 @@ BFD64_BACKENDS = \
elf64-ia64.lo \
elf64-ia64-vms.lo \
elfxx-ia64.lo \
elfxx-kvx.lo \
elf64-kvx.lo \
elf32-loongarch.lo \
elf64-loongarch.lo \
elfxx-loongarch.lo \
@ -618,6 +625,7 @@ BFD64_BACKENDS_CFILES = \
elfn32-mips.c \
elfxx-aarch64.c \
elfxx-ia64.c \
elfxx-kvx.c \
elfxx-loongarch.c \
elfxx-mips.c \
elfxx-riscv.c \
@ -681,6 +689,7 @@ SOURCE_CFILES = \
BUILD_CFILES = \
elf32-aarch64.c elf64-aarch64.c \
elf32-kvx.c elf64-kvx.c \
elf32-ia64.c elf64-ia64.c \
elf32-loongarch.c elf64-loongarch.c \
elf32-riscv.c elf64-riscv.c \
@ -850,6 +859,18 @@ elf64-ia64.c : elfnn-ia64.c
$(AM_V_at)echo "#line 1 \"elfnn-ia64.c\"" > $@
$(AM_V_GEN)$(SED) -e s/NN/64/g < $< >> $@
elf32-kvx.c : elfnn-kvx.c
rm -f elf32-kvx.c
echo "#line 1 \"$(srcdir)/elfnn-kvx.c\"" > elf32-kvx.new
sed -e s/NN/32/g < $(srcdir)/elfnn-kvx.c >> elf32-kvx.new
mv -f elf32-kvx.new elf32-kvx.c
elf64-kvx.c : elfnn-kvx.c
rm -f elf64-kvx.c
echo "#line 1 \"$(srcdir)/elfnn-kvx.c\"" > elf64-kvx.new
sed -e s/NN/64/g < $(srcdir)/elfnn-kvx.c >> elf64-kvx.new
mv -f elf64-kvx.new elf64-kvx.c
elf32-loongarch.c : elfnn-loongarch.c
$(AM_V_at)echo "#line 1 \"elfnn-loongarch.c\"" > $@
$(AM_V_GEN)$(SED) -e s/NN/32/g < $< >> $@

View file

@ -468,6 +468,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -573,6 +574,7 @@ ALL_MACHINES = \
cpu-hppa.lo \
cpu-i386.lo \
cpu-iamcu.lo \
cpu-kvx.lo \
cpu-ia64.lo \
cpu-ip2k.lo \
cpu-iq2000.lo \
@ -656,6 +658,7 @@ ALL_MACHINES_CFILES = \
cpu-hppa.c \
cpu-i386.c \
cpu-iamcu.c \
cpu-kvx.c \
cpu-ia64.c \
cpu-ip2k.c \
cpu-iq2000.c \
@ -773,6 +776,8 @@ BFD32_BACKENDS = \
elfxx-x86.lo \
elf32-ip2k.lo \
elf32-iq2000.lo \
elf32-kvx.lo \
elfxx-kvx.lo \
elf32-lm32.lo \
elf32-m32c.lo \
elf32-m32r.lo \
@ -908,6 +913,7 @@ BFD32_BACKENDS_CFILES = \
elfxx-x86.c \
elf32-ip2k.c \
elf32-iq2000.c \
elfxx-kvx.c \
elf32-lm32.c \
elf32-m32c.c \
elf32-m32r.c \
@ -1013,6 +1019,8 @@ BFD64_BACKENDS = \
elf64-ia64.lo \
elf64-ia64-vms.lo \
elfxx-ia64.lo \
elfxx-kvx.lo \
elf64-kvx.lo \
elf32-loongarch.lo \
elf64-loongarch.lo \
elfxx-loongarch.lo \
@ -1075,6 +1083,7 @@ BFD64_BACKENDS_CFILES = \
elfn32-mips.c \
elfxx-aarch64.c \
elfxx-ia64.c \
elfxx-kvx.c \
elfxx-loongarch.c \
elfxx-mips.c \
elfxx-riscv.c \
@ -1137,6 +1146,7 @@ SOURCE_CFILES = \
BUILD_CFILES = \
elf32-aarch64.c elf64-aarch64.c \
elf32-kvx.c elf64-kvx.c \
elf32-ia64.c elf64-ia64.c \
elf32-loongarch.c elf64-loongarch.c \
elf32-riscv.c elf64-riscv.c \
@ -1483,6 +1493,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-iamcu.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-ip2k.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-iq2000.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-kvx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-lm32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-loongarch.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m10200.Plo@am__quote@
@ -1577,6 +1588,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-ia64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-ip2k.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-iq2000.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-kvx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-lm32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-loongarch.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-m32c.Plo@am__quote@
@ -1629,6 +1641,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-hppa.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-ia64-vms.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-ia64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-kvx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-loongarch.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-mips.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-mmix.Plo@am__quote@
@ -1644,6 +1657,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfn32-mips.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-aarch64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-ia64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-kvx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-loongarch.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-mips.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-riscv.Plo@am__quote@
@ -2348,6 +2362,18 @@ elf64-ia64.c : elfnn-ia64.c
$(AM_V_at)echo "#line 1 \"elfnn-ia64.c\"" > $@
$(AM_V_GEN)$(SED) -e s/NN/64/g < $< >> $@
elf32-kvx.c : elfnn-kvx.c
rm -f elf32-kvx.c
echo "#line 1 \"$(srcdir)/elfnn-kvx.c\"" > elf32-kvx.new
sed -e s/NN/32/g < $(srcdir)/elfnn-kvx.c >> elf32-kvx.new
mv -f elf32-kvx.new elf32-kvx.c
elf64-kvx.c : elfnn-kvx.c
rm -f elf64-kvx.c
echo "#line 1 \"$(srcdir)/elfnn-kvx.c\"" > elf64-kvx.new
sed -e s/NN/64/g < $(srcdir)/elfnn-kvx.c >> elf64-kvx.new
mv -f elf64-kvx.new elf64-kvx.c
elf32-loongarch.c : elfnn-loongarch.c
$(AM_V_at)echo "#line 1 \"elfnn-loongarch.c\"" > $@
$(AM_V_GEN)$(SED) -e s/NN/32/g < $< >> $@

View file

@ -515,6 +515,17 @@ DESCRIPTION
. bfd_arch_lm32, {* Lattice Mico32. *}
.#define bfd_mach_lm32 1
. bfd_arch_microblaze,{* Xilinx MicroBlaze. *}
. bfd_arch_kvx, {* Kalray VLIW core of the MPPA processor family *}
.#define bfd_mach_kv3_unknown 0
.#define bfd_mach_kv3_1 1
.#define bfd_mach_kv3_1_64 2
.#define bfd_mach_kv3_1_usr 3
.#define bfd_mach_kv3_2 4
.#define bfd_mach_kv3_2_64 5
.#define bfd_mach_kv3_2_usr 6
.#define bfd_mach_kv4_1 7
.#define bfd_mach_kv4_1_64 8
.#define bfd_mach_kv4_1_usr 9
. bfd_arch_tilepro, {* Tilera TILEPro. *}
. bfd_arch_tilegx, {* Tilera TILE-Gx. *}
.#define bfd_mach_tilepro 1
@ -642,6 +653,7 @@ extern const bfd_arch_info_type bfd_iamcu_arch;
extern const bfd_arch_info_type bfd_ia64_arch;
extern const bfd_arch_info_type bfd_ip2k_arch;
extern const bfd_arch_info_type bfd_iq2000_arch;
extern const bfd_arch_info_type bfd_kvx_arch;
extern const bfd_arch_info_type bfd_lm32_arch;
extern const bfd_arch_info_type bfd_loongarch_arch;
extern const bfd_arch_info_type bfd_m32c_arch;
@ -730,6 +742,7 @@ static const bfd_arch_info_type * const bfd_archures_list[] =
&bfd_ia64_arch,
&bfd_ip2k_arch,
&bfd_iq2000_arch,
&bfd_kvx_arch,
&bfd_lm32_arch,
&bfd_loongarch_arch,
&bfd_m32c_arch,

View file

@ -1771,6 +1771,17 @@ enum bfd_architecture
bfd_arch_lm32, /* Lattice Mico32. */
#define bfd_mach_lm32 1
bfd_arch_microblaze,/* Xilinx MicroBlaze. */
bfd_arch_kvx, /* Kalray VLIW core of the MPPA processor family */
#define bfd_mach_kv3_unknown 0
#define bfd_mach_kv3_1 1
#define bfd_mach_kv3_1_64 2
#define bfd_mach_kv3_1_usr 3
#define bfd_mach_kv3_2 4
#define bfd_mach_kv3_2_64 5
#define bfd_mach_kv3_2_usr 6
#define bfd_mach_kv4_1 7
#define bfd_mach_kv4_1_64 8
#define bfd_mach_kv4_1_usr 9
bfd_arch_tilepro, /* Tilera TILEPro. */
bfd_arch_tilegx, /* Tilera TILE-Gx. */
#define bfd_mach_tilepro 1
@ -6522,6 +6533,106 @@ value in two words (with an imm instruction). The relocation is
relative offset from start of TEXT. */
BFD_RELOC_MICROBLAZE_64_TEXTREL,
/* KVX pseudo relocation code to mark the start of the KVX
relocation enumerators. N.B. the order of the enumerators is
important as several tables in the KVX bfd backend are indexed
by these enumerators; make sure they are all synced."; */
BFD_RELOC_KVX_RELOC_START,
/* KVX null relocation code. */
BFD_RELOC_KVX_NONE,
/* KVX Relocations. */
BFD_RELOC_KVX_16,
BFD_RELOC_KVX_32,
BFD_RELOC_KVX_64,
BFD_RELOC_KVX_S16_PCREL,
BFD_RELOC_KVX_PCREL17,
BFD_RELOC_KVX_PCREL27,
BFD_RELOC_KVX_32_PCREL,
BFD_RELOC_KVX_S37_PCREL_LO10,
BFD_RELOC_KVX_S37_PCREL_UP27,
BFD_RELOC_KVX_S43_PCREL_LO10,
BFD_RELOC_KVX_S43_PCREL_UP27,
BFD_RELOC_KVX_S43_PCREL_EX6,
BFD_RELOC_KVX_S64_PCREL_LO10,
BFD_RELOC_KVX_S64_PCREL_UP27,
BFD_RELOC_KVX_S64_PCREL_EX27,
BFD_RELOC_KVX_64_PCREL,
BFD_RELOC_KVX_S16,
BFD_RELOC_KVX_S32_LO5,
BFD_RELOC_KVX_S32_UP27,
BFD_RELOC_KVX_S37_LO10,
BFD_RELOC_KVX_S37_UP27,
BFD_RELOC_KVX_S37_GOTOFF_LO10,
BFD_RELOC_KVX_S37_GOTOFF_UP27,
BFD_RELOC_KVX_S43_GOTOFF_LO10,
BFD_RELOC_KVX_S43_GOTOFF_UP27,
BFD_RELOC_KVX_S43_GOTOFF_EX6,
BFD_RELOC_KVX_32_GOTOFF,
BFD_RELOC_KVX_64_GOTOFF,
BFD_RELOC_KVX_32_GOT,
BFD_RELOC_KVX_S37_GOT_LO10,
BFD_RELOC_KVX_S37_GOT_UP27,
BFD_RELOC_KVX_S43_GOT_LO10,
BFD_RELOC_KVX_S43_GOT_UP27,
BFD_RELOC_KVX_S43_GOT_EX6,
BFD_RELOC_KVX_64_GOT,
BFD_RELOC_KVX_GLOB_DAT,
BFD_RELOC_KVX_COPY,
BFD_RELOC_KVX_JMP_SLOT,
BFD_RELOC_KVX_RELATIVE,
BFD_RELOC_KVX_S43_LO10,
BFD_RELOC_KVX_S43_UP27,
BFD_RELOC_KVX_S43_EX6,
BFD_RELOC_KVX_S64_LO10,
BFD_RELOC_KVX_S64_UP27,
BFD_RELOC_KVX_S64_EX27,
BFD_RELOC_KVX_S37_GOTADDR_LO10,
BFD_RELOC_KVX_S37_GOTADDR_UP27,
BFD_RELOC_KVX_S43_GOTADDR_LO10,
BFD_RELOC_KVX_S43_GOTADDR_UP27,
BFD_RELOC_KVX_S43_GOTADDR_EX6,
BFD_RELOC_KVX_S64_GOTADDR_LO10,
BFD_RELOC_KVX_S64_GOTADDR_UP27,
BFD_RELOC_KVX_S64_GOTADDR_EX27,
BFD_RELOC_KVX_64_DTPMOD,
BFD_RELOC_KVX_64_DTPOFF,
BFD_RELOC_KVX_S37_TLS_DTPOFF_LO10,
BFD_RELOC_KVX_S37_TLS_DTPOFF_UP27,
BFD_RELOC_KVX_S43_TLS_DTPOFF_LO10,
BFD_RELOC_KVX_S43_TLS_DTPOFF_UP27,
BFD_RELOC_KVX_S43_TLS_DTPOFF_EX6,
BFD_RELOC_KVX_S37_TLS_GD_LO10,
BFD_RELOC_KVX_S37_TLS_GD_UP27,
BFD_RELOC_KVX_S43_TLS_GD_LO10,
BFD_RELOC_KVX_S43_TLS_GD_UP27,
BFD_RELOC_KVX_S43_TLS_GD_EX6,
BFD_RELOC_KVX_S37_TLS_LD_LO10,
BFD_RELOC_KVX_S37_TLS_LD_UP27,
BFD_RELOC_KVX_S43_TLS_LD_LO10,
BFD_RELOC_KVX_S43_TLS_LD_UP27,
BFD_RELOC_KVX_S43_TLS_LD_EX6,
BFD_RELOC_KVX_64_TPOFF,
BFD_RELOC_KVX_S37_TLS_IE_LO10,
BFD_RELOC_KVX_S37_TLS_IE_UP27,
BFD_RELOC_KVX_S43_TLS_IE_LO10,
BFD_RELOC_KVX_S43_TLS_IE_UP27,
BFD_RELOC_KVX_S43_TLS_IE_EX6,
BFD_RELOC_KVX_S37_TLS_LE_LO10,
BFD_RELOC_KVX_S37_TLS_LE_UP27,
BFD_RELOC_KVX_S43_TLS_LE_LO10,
BFD_RELOC_KVX_S43_TLS_LE_UP27,
BFD_RELOC_KVX_S43_TLS_LE_EX6,
BFD_RELOC_KVX_8,
/* KVX pseudo relocation code to mark the end of the KVX
relocation enumerators that have direct mapping to ELF reloc codes.
There are a few more enumerators after this one; those are mainly
used by the KVX assembler for the internal fixup or to select
one of the above enumerators. */
BFD_RELOC_KVX_RELOC_END,
/* AArch64 pseudo relocation code to mark the start of the AArch64
relocation enumerators. N.B. the order of the enumerators is
important as several tables in the AArch64 bfd backend are indexed

View file

@ -196,6 +196,7 @@ fido*) targ_archs=bfd_m68k_arch ;;
hppa*) targ_archs=bfd_hppa_arch ;;
i[3-7]86) targ_archs=bfd_i386_arch ;;
ia16) targ_archs=bfd_i386_arch ;;
kvx) targ_archs=bfd_kvx_arch ;;
loongarch*) targ_archs=bfd_loongarch_arch ;;
m6811*|m68hc11*) targ_archs="bfd_m68hc11_arch bfd_m68hc12_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;;
m6812*|m68hc12*) targ_archs="bfd_m68hc12_arch bfd_m68hc11_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;;
@ -797,6 +798,21 @@ case "${targ}" in
targ_defvec=iq2000_elf32_vec
;;
#ifdef BFD64
kvx-*-linux*)
targ_defvec=kvx_elf64_vec
want64=true
;;
#endif
kvx-*-*)
targ_defvec=kvx_elf32_vec
targ_selvecs="kvx_elf32_vec"
#ifdef BFD64
targ64_selvecs=kvx_elf64_vec
#endif
;;
lm32-*-elf | lm32-*-rtems*)
targ_defvec=lm32_elf32_vec
targ_selvecs=lm32_elf32_fdpic_vec

3
bfd/configure vendored
View file

@ -13959,6 +13959,9 @@ do
ia64_pei_vec) tb="$tb pei-ia64.lo pepigen.lo $coff"; target_size=64 ;;
ip2k_elf32_vec) tb="$tb elf32-ip2k.lo elf32.lo $elf" ;;
iq2000_elf32_vec) tb="$tb elf32-iq2000.lo elf32.lo $elf" ;;
kvx_elf32_vec) tb="$tb elf32-kvx.lo elfxx-kvx.lo elf32.lo $elf $ipa" ;;
kvx_elf64_vec) tb="$tb elf64-kvx.lo elfxx-kvx.lo elf64.lo $elf $ipa" ;;
kvx_elf64_linux_vec) tb="$tb elf64-kvx.lo elfxx-kvx.lo elf64.lo $elf $ipa" ;;
lm32_elf32_vec) tb="$tb elf32-lm32.lo elf32.lo $elf" ;;
lm32_elf32_fdpic_vec) tb="$tb elf32-lm32.lo elf32.lo $elf" ;;
loongarch_elf32_vec) tb="$tb elf32-loongarch.lo elfxx-loongarch.lo elf32.lo elf-ifunc.lo $elf" ;;

View file

@ -495,6 +495,9 @@ do
ia64_pei_vec) tb="$tb pei-ia64.lo pepigen.lo $coff"; target_size=64 ;;
ip2k_elf32_vec) tb="$tb elf32-ip2k.lo elf32.lo $elf" ;;
iq2000_elf32_vec) tb="$tb elf32-iq2000.lo elf32.lo $elf" ;;
kvx_elf32_vec) tb="$tb elf32-kvx.lo elfxx-kvx.lo elf32.lo $elf $ipa" ;;
kvx_elf64_vec) tb="$tb elf64-kvx.lo elfxx-kvx.lo elf64.lo $elf $ipa" ;;
kvx_elf64_linux_vec) tb="$tb elf64-kvx.lo elfxx-kvx.lo elf64.lo $elf $ipa" ;;
lm32_elf32_vec) tb="$tb elf32-lm32.lo elf32.lo $elf" ;;
lm32_elf32_fdpic_vec) tb="$tb elf32-lm32.lo elf32.lo $elf" ;;
loongarch_elf32_vec) tb="$tb elf32-loongarch.lo elfxx-loongarch.lo elf32.lo elf-ifunc.lo $elf" ;;

124
bfd/cpu-kvx.c Normal file
View file

@ -0,0 +1,124 @@
/* BFD support for KVX.
Copyright (C) 2009-2023 Free Software Foundation, Inc.
Contributed by Kalray SA.
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"
/* This routine is provided two arch_infos and returns if machines
are compatible.
*/
static const bfd_arch_info_type *
kvx_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
{
long amach = a->mach, bmach = b->mach;
/* If a & b are for different architecture we can do nothing. */
if (a->arch != b->arch)
return NULL;
if ((amach == bfd_mach_kv3_1_64 && bmach == bfd_mach_kv3_1_usr)
|| (amach == bfd_mach_kv3_2_64 && bmach == bfd_mach_kv3_2_usr))
return b;
if ((bmach == bfd_mach_kv3_1_64 && amach == bfd_mach_kv3_1_usr)
|| (bmach == bfd_mach_kv3_2_64 && amach == bfd_mach_kv3_2_usr))
return a;
/* Otherwise if either a or b is the 'default' machine
* then it can be polymorphed into the other.
* This will enable to execute merge_private_bfd_data
*/
if (a->the_default)
return b;
if (b->the_default)
return a;
/* We do not want to transmute some machine into another one */
if (amach != bmach)
return NULL;
/* If a & b are for the same machine then all is well. */
if (amach == bmach)
return a;
return NULL;
}
static bool
scan (const struct bfd_arch_info *info, const char *string)
{
/* First test for an exact match. */
if (strcasecmp (string, info->printable_name) == 0)
return true;
/* Finally check for the default architecture. */
if (strcasecmp (string, "kvx") == 0)
return info->the_default;
return false;
}
#define N(addr_bits, machine, print, default, next) \
{ \
32, /* 32 bits in a word. */ \
addr_bits, /* bits in an address. */ \
8, /* 8 bits in a byte. */ \
bfd_arch_kvx, \
machine, /* Machine number. */ \
"kvx", /* Architecture name. */ \
print, /* Printable name. */ \
4, /* Section align power. */ \
default, /* Is this the default ? */ \
kvx_compatible, \
scan, \
bfd_arch_default_fill, \
next, \
0 \
}
const bfd_arch_info_type bfd_kv4_1_usr_arch =
N (64 , bfd_mach_kv4_1_usr , "kvx:kv4-1:usr" , false , NULL);
const bfd_arch_info_type bfd_kv3_2_usr_arch =
N (64 , bfd_mach_kv3_2_usr , "kvx:kv3-2:usr" , false , &bfd_kv4_1_usr_arch);
const bfd_arch_info_type bfd_kv3_1_usr_arch =
N (64 , bfd_mach_kv3_1_usr , "kvx:kv3-1:usr" , false , &bfd_kv3_2_usr_arch);
const bfd_arch_info_type bfd_kv4_1_64_arch =
N (64 , bfd_mach_kv4_1_64 , "kvx:kv4-1:64" , false , &bfd_kv3_1_usr_arch);
const bfd_arch_info_type bfd_kv3_2_64_arch =
N (64 , bfd_mach_kv3_2_64 , "kvx:kv3-2:64" , false , &bfd_kv4_1_64_arch);
const bfd_arch_info_type bfd_kv3_1_64_arch =
N (64 , bfd_mach_kv3_1_64 , "kvx:kv3-1:64" , false , &bfd_kv3_2_64_arch);
const bfd_arch_info_type bfd_kv4_1_arch =
N (32 , bfd_mach_kv4_1 , "kvx:kv4-1" , false , &bfd_kv3_1_64_arch);
const bfd_arch_info_type bfd_kv3_2_arch =
N (32 , bfd_mach_kv3_2 , "kvx:kv3-2" , false , &bfd_kv4_1_arch);
const bfd_arch_info_type bfd_kvx_arch =
N (32 , bfd_mach_kv3_1 , "kvx:kv3-1" , true , &bfd_kv3_2_arch);

View file

@ -545,6 +545,7 @@ enum elf_target_id
HPPA64_ELF_DATA,
I386_ELF_DATA,
IA64_ELF_DATA,
KVX_ELF_DATA,
LM32_ELF_DATA,
LARCH_ELF_DATA,
M32R_ELF_DATA,

4805
bfd/elfnn-kvx.c Normal file

File diff suppressed because it is too large Load diff

1105
bfd/elfxx-kvx-relocs.h Normal file

File diff suppressed because it is too large Load diff

218
bfd/elfxx-kvx.c Normal file
View file

@ -0,0 +1,218 @@
/* KVX-specific support for ELF.
Copyright (C) 2009-2023 Free Software Foundation, Inc.
Contributed by Kalray SA.
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 "elfxx-kvx.h"
#include <stdarg.h>
#include <string.h>
/* Return non-zero if the indicated VALUE has overflowed the maximum
range expressible by a unsigned number with the indicated number of
BITS. */
static bfd_reloc_status_type
kvx_unsigned_overflow (bfd_vma value, unsigned int bits)
{
bfd_vma lim;
if (bits >= sizeof (bfd_vma) * 8)
return bfd_reloc_ok;
lim = (bfd_vma) 1 << bits;
if (value >= lim)
return bfd_reloc_overflow;
return bfd_reloc_ok;
}
/* Return non-zero if the indicated VALUE has overflowed the maximum
range expressible by an signed number with the indicated number of
BITS. */
static bfd_reloc_status_type
kvx_signed_overflow (bfd_vma value, unsigned int bits)
{
bfd_signed_vma svalue = (bfd_signed_vma) value;
bfd_signed_vma lim;
if (bits >= sizeof (bfd_vma) * 8)
return bfd_reloc_ok;
lim = (bfd_signed_vma) 1 << (bits - 1);
if (svalue < -lim || svalue >= lim)
return bfd_reloc_overflow;
return bfd_reloc_ok;
}
/* Insert the addend/value into the instruction or data object being
relocated. */
bfd_reloc_status_type
_bfd_kvx_elf_put_addend (bfd *abfd,
bfd_byte *address, bfd_reloc_code_real_type r_type ATTRIBUTE_UNUSED,
reloc_howto_type *howto, bfd_signed_vma addend)
{
bfd_reloc_status_type status = bfd_reloc_ok;
bfd_vma contents;
int size;
size = bfd_get_reloc_size (howto);
switch (size)
{
case 2:
contents = bfd_get_16 (abfd, address);
break;
case 4:
if (howto->src_mask != 0xffffffff)
/* Must be 32-bit instruction, always little-endian. */
contents = bfd_getl32 (address);
else
/* Must be 32-bit data (endianness dependent). */
contents = bfd_get_32 (abfd, address);
break;
case 8:
contents = bfd_get_64 (abfd, address);
break;
default:
abort ();
}
switch (howto->complain_on_overflow)
{
case complain_overflow_dont:
break;
case complain_overflow_signed:
status = kvx_signed_overflow (addend,
howto->bitsize + howto->rightshift);
break;
case complain_overflow_unsigned:
status = kvx_unsigned_overflow (addend,
howto->bitsize + howto->rightshift);
break;
case complain_overflow_bitfield:
default:
abort ();
}
addend >>= howto->rightshift;
/* FIXME KVX : AARCH64 is "redoing" what the link_relocate bfd
* function does ie. extract bitfields and apply then to the
* existing content (insn) (howto's job) Not sure exactly
* why. Maybe because we need this even when not applying reloc
* against a input_bfd (eg. when doing PLT). On KVX, we have not
* reached a point where we would need to write similar
* functions for each insn. So we'll simply enrich the default
* case for handling a bit more than "right aligned bitfields"
*
* Beware that this won't be able to apply generic howto !
*/
/* if (howto->dst_mask & (howto->dst_mask + 1)) */
/* return bfd_reloc_notsupported; */
addend <<= howto->bitpos;
contents = ((contents & ~howto->dst_mask) | (addend & howto->dst_mask));
switch (size)
{
case 2:
bfd_put_16 (abfd, contents, address);
break;
case 4:
if (howto->dst_mask != 0xffffffff)
/* must be 32-bit instruction, always little-endian */
bfd_putl32 (contents, address);
else
/* must be 32-bit data (endianness dependent) */
bfd_put_32 (abfd, contents, address);
break;
case 8:
bfd_put_64 (abfd, contents, address);
break;
default:
abort ();
}
return status;
}
bfd_vma
_bfd_kvx_elf_resolve_relocation (bfd_reloc_code_real_type r_type ATTRIBUTE_UNUSED,
bfd_vma place ATTRIBUTE_UNUSED, bfd_vma value,
bfd_vma addend ATTRIBUTE_UNUSED, bool weak_undef_p ATTRIBUTE_UNUSED)
{
return value;
}
bool
_bfd_kvx_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
{
int offset;
size_t size;
switch (note->descsz)
{
case 680: /* sizeof(struct elf_prstatus) on Linux/kvx. */
/* pr_cursig */
elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 32);
/* pr_reg */
offset = 112;
size = 560;
break;
default:
return false;
}
/* Make a ".reg/999" section. */
return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
note->descpos + offset);
}
bool
_bfd_kvx_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
{
switch (note->descsz)
{
case 136: /* This is sizeof(struct elf_prpsinfo) on Linux/kvx. */
elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
elf_tdata (abfd)->core->program
= _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
elf_tdata (abfd)->core->command
= _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
break;
default:
return false;
}
/* Note that for some reason, a spurious space is tacked
onto the end of the args in some (at least one anyway)
implementations, so strip it off if it exists. */
{
char *command = elf_tdata (abfd)->core->command;
int n = strlen (command);
if (n > 0 && command[n - 1] == ' ')
command[n - 1] = 0;
}
return true;
}

71
bfd/elfxx-kvx.h Normal file
View file

@ -0,0 +1,71 @@
/* KVX-specific backend routines.
Copyright (C) 2009-2023 Free Software Foundation, Inc.
Contributed by Kalray SA.
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 "bfd.h"
#include "elf-bfd.h"
#include "stdint.h"
/* KVX stub generation support for ELF64. Called from the linker. */
extern int elf64_kvx_setup_section_lists
(bfd *, struct bfd_link_info *);
extern void elf64_kvx_next_input_section
(struct bfd_link_info *, struct bfd_section *);
extern bool elf64_kvx_size_stubs
(bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
struct bfd_section * (*) (const char *, struct bfd_section *),
void (*) (void));
extern bool elf64_kvx_build_stubs
(struct bfd_link_info *);
/* Kvx stub generation support for ELF32. Called from the linker. */
extern int elf32_kvx_setup_section_lists
(bfd *, struct bfd_link_info *);
extern void elf32_kvx_next_input_section
(struct bfd_link_info *, struct bfd_section *);
extern bool elf32_kvx_size_stubs
(bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
struct bfd_section * (*) (const char *, struct bfd_section *),
void (*) (void));
extern bool elf32_kvx_build_stubs
(struct bfd_link_info *);
extern bfd_reloc_status_type
_bfd_kvx_elf_put_addend (bfd *, bfd_byte *, bfd_reloc_code_real_type,
reloc_howto_type *, bfd_signed_vma);
bfd_vma
_bfd_kvx_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
bfd_vma place, bfd_vma value,
bfd_vma addend, bool weak_undef_p);
bool
kvx_elf32_init_stub_bfd (struct bfd_link_info *info,
bfd *stub_bfd);
bool
kvx_elf64_init_stub_bfd (struct bfd_link_info *info,
bfd *stub_bfd);
bool _bfd_kvx_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note);
bool _bfd_kvx_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note);
#define elf_backend_grok_prstatus _bfd_kvx_elf_grok_prstatus
#define elf_backend_grok_psinfo _bfd_kvx_elf_grok_psinfo

View file

@ -3031,6 +3031,91 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_MICROBLAZE_64_TLSTPREL",
"BFD_RELOC_MICROBLAZE_64_TEXTPCREL",
"BFD_RELOC_MICROBLAZE_64_TEXTREL",
"BFD_RELOC_KVX_RELOC_START",
"BFD_RELOC_KVX_NONE",
"BFD_RELOC_KVX_16",
"BFD_RELOC_KVX_32",
"BFD_RELOC_KVX_64",
"BFD_RELOC_KVX_S16_PCREL",
"BFD_RELOC_KVX_PCREL17",
"BFD_RELOC_KVX_PCREL27",
"BFD_RELOC_KVX_32_PCREL",
"BFD_RELOC_KVX_S37_PCREL_LO10",
"BFD_RELOC_KVX_S37_PCREL_UP27",
"BFD_RELOC_KVX_S43_PCREL_LO10",
"BFD_RELOC_KVX_S43_PCREL_UP27",
"BFD_RELOC_KVX_S43_PCREL_EX6",
"BFD_RELOC_KVX_S64_PCREL_LO10",
"BFD_RELOC_KVX_S64_PCREL_UP27",
"BFD_RELOC_KVX_S64_PCREL_EX27",
"BFD_RELOC_KVX_64_PCREL",
"BFD_RELOC_KVX_S16",
"BFD_RELOC_KVX_S32_LO5",
"BFD_RELOC_KVX_S32_UP27",
"BFD_RELOC_KVX_S37_LO10",
"BFD_RELOC_KVX_S37_UP27",
"BFD_RELOC_KVX_S37_GOTOFF_LO10",
"BFD_RELOC_KVX_S37_GOTOFF_UP27",
"BFD_RELOC_KVX_S43_GOTOFF_LO10",
"BFD_RELOC_KVX_S43_GOTOFF_UP27",
"BFD_RELOC_KVX_S43_GOTOFF_EX6",
"BFD_RELOC_KVX_32_GOTOFF",
"BFD_RELOC_KVX_64_GOTOFF",
"BFD_RELOC_KVX_32_GOT",
"BFD_RELOC_KVX_S37_GOT_LO10",
"BFD_RELOC_KVX_S37_GOT_UP27",
"BFD_RELOC_KVX_S43_GOT_LO10",
"BFD_RELOC_KVX_S43_GOT_UP27",
"BFD_RELOC_KVX_S43_GOT_EX6",
"BFD_RELOC_KVX_64_GOT",
"BFD_RELOC_KVX_GLOB_DAT",
"BFD_RELOC_KVX_COPY",
"BFD_RELOC_KVX_JMP_SLOT",
"BFD_RELOC_KVX_RELATIVE",
"BFD_RELOC_KVX_S43_LO10",
"BFD_RELOC_KVX_S43_UP27",
"BFD_RELOC_KVX_S43_EX6",
"BFD_RELOC_KVX_S64_LO10",
"BFD_RELOC_KVX_S64_UP27",
"BFD_RELOC_KVX_S64_EX27",
"BFD_RELOC_KVX_S37_GOTADDR_LO10",
"BFD_RELOC_KVX_S37_GOTADDR_UP27",
"BFD_RELOC_KVX_S43_GOTADDR_LO10",
"BFD_RELOC_KVX_S43_GOTADDR_UP27",
"BFD_RELOC_KVX_S43_GOTADDR_EX6",
"BFD_RELOC_KVX_S64_GOTADDR_LO10",
"BFD_RELOC_KVX_S64_GOTADDR_UP27",
"BFD_RELOC_KVX_S64_GOTADDR_EX27",
"BFD_RELOC_KVX_64_DTPMOD",
"BFD_RELOC_KVX_64_DTPOFF",
"BFD_RELOC_KVX_S37_TLS_DTPOFF_LO10",
"BFD_RELOC_KVX_S37_TLS_DTPOFF_UP27",
"BFD_RELOC_KVX_S43_TLS_DTPOFF_LO10",
"BFD_RELOC_KVX_S43_TLS_DTPOFF_UP27",
"BFD_RELOC_KVX_S43_TLS_DTPOFF_EX6",
"BFD_RELOC_KVX_S37_TLS_GD_LO10",
"BFD_RELOC_KVX_S37_TLS_GD_UP27",
"BFD_RELOC_KVX_S43_TLS_GD_LO10",
"BFD_RELOC_KVX_S43_TLS_GD_UP27",
"BFD_RELOC_KVX_S43_TLS_GD_EX6",
"BFD_RELOC_KVX_S37_TLS_LD_LO10",
"BFD_RELOC_KVX_S37_TLS_LD_UP27",
"BFD_RELOC_KVX_S43_TLS_LD_LO10",
"BFD_RELOC_KVX_S43_TLS_LD_UP27",
"BFD_RELOC_KVX_S43_TLS_LD_EX6",
"BFD_RELOC_KVX_64_TPOFF",
"BFD_RELOC_KVX_S37_TLS_IE_LO10",
"BFD_RELOC_KVX_S37_TLS_IE_UP27",
"BFD_RELOC_KVX_S43_TLS_IE_LO10",
"BFD_RELOC_KVX_S43_TLS_IE_UP27",
"BFD_RELOC_KVX_S43_TLS_IE_EX6",
"BFD_RELOC_KVX_S37_TLS_LE_LO10",
"BFD_RELOC_KVX_S37_TLS_LE_UP27",
"BFD_RELOC_KVX_S43_TLS_LE_LO10",
"BFD_RELOC_KVX_S43_TLS_LE_UP27",
"BFD_RELOC_KVX_S43_TLS_LE_EX6",
"BFD_RELOC_KVX_8",
"BFD_RELOC_KVX_RELOC_END",
"BFD_RELOC_AARCH64_RELOC_START",
"BFD_RELOC_AARCH64_NULL",
"BFD_RELOC_AARCH64_NONE",

View file

@ -1,11 +1,13 @@
bfdver.h
elf32-aarch64.c
elf32-ia64.c
elf32-kvx.c
elf32-loongarch.c
elf32-riscv.c
elf32-target.h
elf64-aarch64.c
elf64-ia64.c
elf64-kvx.c
elf64-loongarch.c
elf64-riscv.c
elf64-target.h

View file

@ -69,6 +69,7 @@ cpu-ia64.c
cpu-iamcu.c
cpu-ip2k.c
cpu-iq2000.c
cpu-kvx.c
cpu-lm32.c
cpu-loongarch.c
cpu-m10200.c
@ -261,6 +262,7 @@ elfxx-aarch64.c
elfxx-aarch64.h
elfxx-ia64.c
elfxx-ia64.h
elfxx-kvx.c
elfxx-loongarch.c
elfxx-loongarch.h
elfxx-mips.c

View file

@ -6786,7 +6786,191 @@ ENUMDOC
This is a 64 bit reloc that stores the 32 bit offset
value in two words (with an imm instruction). The relocation is
relative offset from start of TEXT.
ENUM
BFD_RELOC_KVX_RELOC_START
ENUMDOC
KVX pseudo relocation code to mark the start of the KVX
relocation enumerators. N.B. the order of the enumerators is
important as several tables in the KVX bfd backend are indexed
by these enumerators; make sure they are all synced.";
ENUM
BFD_RELOC_KVX_NONE
ENUMDOC
KVX null relocation code.
ENUM
BFD_RELOC_KVX_16
ENUMX
BFD_RELOC_KVX_32
ENUMX
BFD_RELOC_KVX_64
ENUMX
BFD_RELOC_KVX_S16_PCREL
ENUMX
BFD_RELOC_KVX_PCREL17
ENUMX
BFD_RELOC_KVX_PCREL27
ENUMX
BFD_RELOC_KVX_32_PCREL
ENUMX
BFD_RELOC_KVX_S37_PCREL_LO10
ENUMX
BFD_RELOC_KVX_S37_PCREL_UP27
ENUMX
BFD_RELOC_KVX_S43_PCREL_LO10
ENUMX
BFD_RELOC_KVX_S43_PCREL_UP27
ENUMX
BFD_RELOC_KVX_S43_PCREL_EX6
ENUMX
BFD_RELOC_KVX_S64_PCREL_LO10
ENUMX
BFD_RELOC_KVX_S64_PCREL_UP27
ENUMX
BFD_RELOC_KVX_S64_PCREL_EX27
ENUMX
BFD_RELOC_KVX_64_PCREL
ENUMX
BFD_RELOC_KVX_S16
ENUMX
BFD_RELOC_KVX_S32_LO5
ENUMX
BFD_RELOC_KVX_S32_UP27
ENUMX
BFD_RELOC_KVX_S37_LO10
ENUMX
BFD_RELOC_KVX_S37_UP27
ENUMX
BFD_RELOC_KVX_S37_GOTOFF_LO10
ENUMX
BFD_RELOC_KVX_S37_GOTOFF_UP27
ENUMX
BFD_RELOC_KVX_S43_GOTOFF_LO10
ENUMX
BFD_RELOC_KVX_S43_GOTOFF_UP27
ENUMX
BFD_RELOC_KVX_S43_GOTOFF_EX6
ENUMX
BFD_RELOC_KVX_32_GOTOFF
ENUMX
BFD_RELOC_KVX_64_GOTOFF
ENUMX
BFD_RELOC_KVX_32_GOT
ENUMX
BFD_RELOC_KVX_S37_GOT_LO10
ENUMX
BFD_RELOC_KVX_S37_GOT_UP27
ENUMX
BFD_RELOC_KVX_S43_GOT_LO10
ENUMX
BFD_RELOC_KVX_S43_GOT_UP27
ENUMX
BFD_RELOC_KVX_S43_GOT_EX6
ENUMX
BFD_RELOC_KVX_64_GOT
ENUMX
BFD_RELOC_KVX_GLOB_DAT
ENUMX
BFD_RELOC_KVX_COPY
ENUMX
BFD_RELOC_KVX_JMP_SLOT
ENUMX
BFD_RELOC_KVX_RELATIVE
ENUMX
BFD_RELOC_KVX_S43_LO10
ENUMX
BFD_RELOC_KVX_S43_UP27
ENUMX
BFD_RELOC_KVX_S43_EX6
ENUMX
BFD_RELOC_KVX_S64_LO10
ENUMX
BFD_RELOC_KVX_S64_UP27
ENUMX
BFD_RELOC_KVX_S64_EX27
ENUMX
BFD_RELOC_KVX_S37_GOTADDR_LO10
ENUMX
BFD_RELOC_KVX_S37_GOTADDR_UP27
ENUMX
BFD_RELOC_KVX_S43_GOTADDR_LO10
ENUMX
BFD_RELOC_KVX_S43_GOTADDR_UP27
ENUMX
BFD_RELOC_KVX_S43_GOTADDR_EX6
ENUMX
BFD_RELOC_KVX_S64_GOTADDR_LO10
ENUMX
BFD_RELOC_KVX_S64_GOTADDR_UP27
ENUMX
BFD_RELOC_KVX_S64_GOTADDR_EX27
ENUMX
BFD_RELOC_KVX_64_DTPMOD
ENUMX
BFD_RELOC_KVX_64_DTPOFF
ENUMX
BFD_RELOC_KVX_S37_TLS_DTPOFF_LO10
ENUMX
BFD_RELOC_KVX_S37_TLS_DTPOFF_UP27
ENUMX
BFD_RELOC_KVX_S43_TLS_DTPOFF_LO10
ENUMX
BFD_RELOC_KVX_S43_TLS_DTPOFF_UP27
ENUMX
BFD_RELOC_KVX_S43_TLS_DTPOFF_EX6
ENUMX
BFD_RELOC_KVX_S37_TLS_GD_LO10
ENUMX
BFD_RELOC_KVX_S37_TLS_GD_UP27
ENUMX
BFD_RELOC_KVX_S43_TLS_GD_LO10
ENUMX
BFD_RELOC_KVX_S43_TLS_GD_UP27
ENUMX
BFD_RELOC_KVX_S43_TLS_GD_EX6
ENUMX
BFD_RELOC_KVX_S37_TLS_LD_LO10
ENUMX
BFD_RELOC_KVX_S37_TLS_LD_UP27
ENUMX
BFD_RELOC_KVX_S43_TLS_LD_LO10
ENUMX
BFD_RELOC_KVX_S43_TLS_LD_UP27
ENUMX
BFD_RELOC_KVX_S43_TLS_LD_EX6
ENUMX
BFD_RELOC_KVX_64_TPOFF
ENUMX
BFD_RELOC_KVX_S37_TLS_IE_LO10
ENUMX
BFD_RELOC_KVX_S37_TLS_IE_UP27
ENUMX
BFD_RELOC_KVX_S43_TLS_IE_LO10
ENUMX
BFD_RELOC_KVX_S43_TLS_IE_UP27
ENUMX
BFD_RELOC_KVX_S43_TLS_IE_EX6
ENUMX
BFD_RELOC_KVX_S37_TLS_LE_LO10
ENUMX
BFD_RELOC_KVX_S37_TLS_LE_UP27
ENUMX
BFD_RELOC_KVX_S43_TLS_LE_LO10
ENUMX
BFD_RELOC_KVX_S43_TLS_LE_UP27
ENUMX
BFD_RELOC_KVX_S43_TLS_LE_EX6
ENUMX
BFD_RELOC_KVX_8
ENUMDOC
KVX Relocations.
ENUM
BFD_RELOC_KVX_RELOC_END
ENUMDOC
KVX pseudo relocation code to mark the end of the KVX
relocation enumerators that have direct mapping to ELF reloc codes.
There are a few more enumerators after this one; those are mainly
used by the KVX assembler for the internal fixup or to select
one of the above enumerators.
ENUM
BFD_RELOC_AARCH64_RELOC_START
ENUMDOC

View file

@ -769,6 +769,8 @@ extern const bfd_target ia64_elf64_vms_vec;
extern const bfd_target ia64_pei_vec;
extern const bfd_target ip2k_elf32_vec;
extern const bfd_target iq2000_elf32_vec;
extern const bfd_target kvx_elf32_vec;
extern const bfd_target kvx_elf64_vec;
extern const bfd_target lm32_elf32_vec;
extern const bfd_target lm32_elf32_fdpic_vec;
extern const bfd_target loongarch_elf64_vec;
@ -1128,6 +1130,12 @@ static const bfd_target * const _bfd_target_vector[] =
&ip2k_elf32_vec,
&iq2000_elf32_vec,
&kvx_elf32_vec,
#ifdef BFD64
&kvx_elf64_vec,
#endif
&lm32_elf32_vec,
&m32c_elf32_vec,

View file

@ -121,6 +121,7 @@
#include "elf/i960.h"
#include "elf/ia64.h"
#include "elf/ip2k.h"
#include "elf/kvx.h"
#include "elf/lm32.h"
#include "elf/iq2000.h"
#include "elf/m32c.h"
@ -1084,6 +1085,7 @@ guess_is_rela (unsigned int e_machine)
case EM_IP2K:
case EM_IP2K_OLD:
case EM_IQ2000:
case EM_KVX:
case EM_LATTICEMICO32:
case EM_M32C_OLD:
case EM_M32C:
@ -1768,6 +1770,10 @@ dump_relocations (Filedata *filedata,
rtype = elf_ia64_reloc_type (type);
break;
case EM_KVX:
rtype = elf_kvx_reloc_type (type);
break;
case EM_CRIS:
rtype = elf_cris_reloc_type (type);
break;
@ -4736,6 +4742,17 @@ get_machine_flags (Filedata * filedata, unsigned e_flags, unsigned e_machine)
out = stpcpy (out, ", relocatable module");
break;
case EM_KVX:
if ((e_flags & (ELF_KVX_CORE_MAJOR_MASK | ELF_KVX_CORE_MINOR_MASK)) == ELF_KVX_CORE_KV3_1)
strcat (buf, ", Kalray VLIW kv3-1");
else if ((e_flags & (ELF_KVX_CORE_MAJOR_MASK | ELF_KVX_CORE_MINOR_MASK)) == ELF_KVX_CORE_KV3_2)
strcat (buf, ", Kalray VLIW kv3-2");
else if ((e_flags & (ELF_KVX_CORE_MAJOR_MASK | ELF_KVX_CORE_MINOR_MASK)) == ELF_KVX_CORE_KV4_1)
strcat (buf, ", Kalray VLIW kv4-1");
else
strcat (buf, ", unknown KVX MPPA");
break;
case EM_MSP430:
out = decode_MSP430_machine_flags (out, e_flags);
break;
@ -14720,6 +14737,8 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
return reloc_type == 2; /* R_IP2K_32. */
case EM_IQ2000:
return reloc_type == 2; /* R_IQ2000_32. */
case EM_KVX:
return reloc_type == 2; /* R_KVX_32. */
case EM_LATTICEMICO32:
return reloc_type == 3; /* R_LM32_32. */
case EM_LOONGARCH:
@ -14917,6 +14936,8 @@ is_32bit_pcrel_reloc (Filedata * filedata, unsigned int reloc_type)
case EM_XTENSA_OLD:
case EM_XTENSA:
return reloc_type == 14; /* R_XTENSA_32_PCREL. */
case EM_KVX:
return reloc_type == 7; /* R_KVX_32_PCREL */
default:
/* Do not abort or issue an error message here. Not all targets use
pc-relative 32-bit relocs in their DWARF debug information and we
@ -14968,6 +14989,8 @@ is_64bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
return reloc_type == 1; /* R_TILEGX_64. */
case EM_MIPS:
return reloc_type == 18; /* R_MIPS_64. */
case EM_KVX:
return reloc_type == 3; /* R_KVX_64 */
default:
return false;
}
@ -15071,6 +15094,8 @@ is_16bit_abs_reloc (Filedata * filedata, unsigned int reloc_type)
case EM_CYGNUS_MN10300:
case EM_MN10300:
return reloc_type == 2; /* R_MN10300_16. */
case EM_KVX:
return reloc_type == 1; /* R_KVX_16 */
case EM_MSP430:
if (uses_msp430x_relocs (filedata))
return reloc_type == 2; /* R_MSP430_ABS16. */
@ -15333,6 +15358,7 @@ is_none_reloc (Filedata * filedata, unsigned int reloc_type)
case EM_FT32: /* R_FT32_NONE. */
case EM_IA_64: /* R_IA64_NONE. */
case EM_K1OM: /* R_X86_64_NONE. */
case EM_KVX: /* R_KVX_NONE. */
case EM_L1OM: /* R_X86_64_NONE. */
case EM_M32R: /* R_M32R_NONE. */
case EM_MIPS: /* R_MIPS_NONE. */

View file

@ -296,6 +296,7 @@ if [is_elf_format] {
setup_xfail "*-*-hpux*"
setup_xfail "mips*-*-*" "tx39*-*-*"
setup_xfail "msp430*-*-*"
setup_xfail "kvx*-*-*"
setup_xfail "visium*-*-*"
setup_xfail "x86_64-*-cloudabi*"

View file

@ -693,6 +693,7 @@ proc copy_setup { } {
}
if { [istarget *-*-linux*]
|| [istarget kvx-*-*]
|| [istarget *-*-gnu*] } {
foreach i $gcc_gas_flag {
set flags "additional_flags=$i $flags"

View file

@ -482,6 +482,8 @@ if { ![is_elf_format]
} else {
if { [istarget "or1k*-*-*"] } then {
set decodedline_testsrc $srcdir/$subdir/dw2-decodedline-1.S
} elseif { [istarget "kvx*-*-*"] } {
set decodedline_testsrc $srcdir/$subdir/dw2-decodedline-2.S
} else {
set decodedline_testsrc $srcdir/$subdir/dw2-decodedline.S
}

View file

@ -41,6 +41,7 @@ proc is_elf_format {} {
&& ![istarget *-*-irix5*]
&& ![istarget *-*-irix6*]
&& ![istarget *-*-kaos*]
&& ![istarget kvx-*-*]
&& ![istarget *-*-*linux*]
&& ![istarget *-*-lynxos*]
&& ![istarget *-*-nacl*]
@ -255,6 +256,7 @@ proc supports_gnu_osabi {} {
if { [istarget "arm*-*-*"]
|| [istarget "msp430-*-*"]
|| [istarget "hppa-unknown-elf"]
|| [istarget "kvx*-*-*"]
|| [istarget "visium-*-*"] } {
return 0
}
@ -371,6 +373,11 @@ proc check_pie_support { } {
global pie_available_saved
global ld
## kvx-*-* does support -shared but not PIE.
if { [istarget "kvx*-*-*"] && ![istarget "kvx*-linux-*"] } {
set pie_available_saved 0
}
if {![info exists pie_available_saved]} {
set ld_output [remote_exec host $ld "-pie"]
if { [ string first "not supported" $ld_output ] >= 0 } {

9
config.guess vendored
View file

@ -1042,6 +1042,15 @@ EOF
k1om:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
kvx:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
kvx:cos:*:*)
GUESS=$UNAME_MACHINE-unknown-cos
;;
kvx:mbr:*:*)
GUESS=$UNAME_MACHINE-unknown-mbr
;;
loongarch32:Linux:*:* | loongarch64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;

16
config.sub vendored
View file

@ -4,7 +4,7 @@
# shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2023-06-23'
timestamp='2023-06-26'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -145,7 +145,8 @@ case $1 in
nto-qnx* | linux-* | uclinux-uclibc* \
| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
| windows-* )
basic_machine=$field1
basic_os=$maybe_os
;;
@ -1205,6 +1206,7 @@ case $cpu-$vendor in
| i370 | i*86 | i860 | i960 | ia16 | ia64 \
| ip2k | iq2000 \
| k1om \
| kvx \
| le32 | le64 \
| lm32 \
| loongarch32 | loongarch64 \
@ -1758,7 +1760,7 @@ case $os in
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
| fiwix* | mlibc* )
| fiwix* | mlibc* | cos* | mbr* )
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
@ -1766,7 +1768,7 @@ case $os in
;;
none)
;;
kernel* )
kernel* | msvc* )
# Restricted further below
;;
*)
@ -1785,6 +1787,8 @@ case $kernel-$os in
;;
managarm-mlibc* | managarm-kernel* )
;;
windows*-gnu* | windows*-msvc*)
;;
-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
# These are just libc implementations, not actual OSes, and thus
# require a kernel.
@ -1799,6 +1803,10 @@ case $kernel-$os in
echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
exit 1
;;
*-msvc* )
echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
exit 1
;;
kfreebsd*-gnu* | kopensolaris*-gnu*)
;;
vxworks-simlinux | vxworks-simwindows | vxworks-spe)

12
configure vendored
View file

@ -3664,6 +3664,15 @@ case "${target}" in
cris-*-* | crisv32-*-*)
libgloss_dir=cris
;;
kvx-*-elf)
libgloss_dir=kvx-elf
;;
kvx-*-mbr)
libgloss_dir=kvx-mbr
;;
kvx-*-cos)
libgloss_dir=kvx-cos
;;
hppa*-*-*)
libgloss_dir=pa
;;
@ -3958,6 +3967,9 @@ case "${target}" in
i[3456789]86-*-rdos*)
noconfigdirs="$noconfigdirs gdb"
;;
kvx-*-*)
noconfigdirs="$noconfigdirs gdb sim"
;;
mmix-*-*)
noconfigdirs="$noconfigdirs gdb"
;;

View file

@ -891,6 +891,15 @@ case "${target}" in
cris-*-* | crisv32-*-*)
libgloss_dir=cris
;;
kvx-*-elf)
libgloss_dir=kvx-elf
;;
kvx-*-mbr)
libgloss_dir=kvx-mbr
;;
kvx-*-cos)
libgloss_dir=kvx-cos
;;
hppa*-*-*)
libgloss_dir=pa
;;
@ -1185,6 +1194,9 @@ case "${target}" in
i[[3456789]]86-*-rdos*)
noconfigdirs="$noconfigdirs gdb"
;;
kvx-*-*)
noconfigdirs="$noconfigdirs gdb gdbserver sim"
;;
mmix-*-*)
noconfigdirs="$noconfigdirs gdb"
;;

View file

@ -160,6 +160,7 @@ TARGET_CPU_CFILES = \
config/tc-i386.c \
config/tc-ip2k.c \
config/tc-iq2000.c \
config/tc-kvx.c \
config/tc-lm32.c \
config/tc-loongarch.c \
config/tc-m32c.c \
@ -235,6 +236,7 @@ TARGET_CPU_HFILES = \
config/tc-i386.h \
config/tc-ip2k.h \
config/tc-iq2000.h \
config/tc-kvx.h \
config/tc-lm32.h \
config/tc-m32c.h \
config/tc-m32r.h \
@ -286,7 +288,9 @@ TARGET_CPU_HFILES = \
TARGET_EXTRA_FILES = \
config/bfin-lex-wrapper.c \
config/xtensa-relax.c \
config/xtensa-relax.h
config/xtensa-relax.h \
config/kvx-parse.h \
config/kvx-parse.c
# OBJ files in config

View file

@ -176,8 +176,8 @@ am__objects_1 = app.$(OBJEXT) as.$(OBJEXT) atof-generic.$(OBJEXT) \
am_as_new_OBJECTS = $(am__objects_1)
am__dirstamp = $(am__leading_dot)dirstamp
as_new_OBJECTS = $(am_as_new_OBJECTS)
am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = ../bfd/libbfd.la ../libiberty/libiberty.a
am__DEPENDENCIES_1 = ../bfd/libbfd.la ../libiberty/libiberty.a
am__DEPENDENCIES_2 =
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
@ -185,7 +185,7 @@ am__v_lt_1 =
am_itbl_test_OBJECTS = itbl-parse.$(OBJEXT) itbl-lex.$(OBJEXT)
itbl_test_OBJECTS = $(am_itbl_test_OBJECTS)
itbl_test_DEPENDENCIES = itbl-tops.@OBJEXT@ itbl-test.@OBJEXT@ \
$(am__DEPENDENCIES_2)
$(am__DEPENDENCIES_1)
SCRIPTS = $(noinst_SCRIPTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@ -647,6 +647,7 @@ TARGET_CPU_CFILES = \
config/tc-i386.c \
config/tc-ip2k.c \
config/tc-iq2000.c \
config/tc-kvx.c \
config/tc-lm32.c \
config/tc-loongarch.c \
config/tc-m32c.c \
@ -722,6 +723,7 @@ TARGET_CPU_HFILES = \
config/tc-i386.h \
config/tc-ip2k.h \
config/tc-iq2000.h \
config/tc-kvx.h \
config/tc-lm32.h \
config/tc-m32c.h \
config/tc-m32r.h \
@ -773,7 +775,9 @@ TARGET_CPU_HFILES = \
TARGET_EXTRA_FILES = \
config/bfin-lex-wrapper.c \
config/xtensa-relax.c \
config/xtensa-relax.h
config/xtensa-relax.h \
config/kvx-parse.h \
config/kvx-parse.c
# OBJ files in config
@ -1128,6 +1132,8 @@ config/tc-ip2k.$(OBJEXT): config/$(am__dirstamp) \
config/$(DEPDIR)/$(am__dirstamp)
config/tc-iq2000.$(OBJEXT): config/$(am__dirstamp) \
config/$(DEPDIR)/$(am__dirstamp)
config/tc-kvx.$(OBJEXT): config/$(am__dirstamp) \
config/$(DEPDIR)/$(am__dirstamp)
config/tc-lm32.$(OBJEXT): config/$(am__dirstamp) \
config/$(DEPDIR)/$(am__dirstamp)
config/tc-loongarch.$(OBJEXT): config/$(am__dirstamp) \
@ -1230,6 +1236,8 @@ config/bfin-lex-wrapper.$(OBJEXT): config/$(am__dirstamp) \
config/$(DEPDIR)/$(am__dirstamp)
config/xtensa-relax.$(OBJEXT): config/$(am__dirstamp) \
config/$(DEPDIR)/$(am__dirstamp)
config/kvx-parse.$(OBJEXT): config/$(am__dirstamp) \
config/$(DEPDIR)/$(am__dirstamp)
config/te-vms.$(OBJEXT): config/$(am__dirstamp) \
config/$(DEPDIR)/$(am__dirstamp)
config/obj-aout.$(OBJEXT): config/$(am__dirstamp) \
@ -1344,6 +1352,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/e-i386coff.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/e-i386elf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/e-mipself.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/kvx-parse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/loongarch-lex.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/loongarch-parse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/m68k-parse.Po@am__quote@
@ -1382,6 +1391,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-ia64.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-ip2k.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-iq2000.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-kvx.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-lm32.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-loongarch.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@config/$(DEPDIR)/tc-m32c.Po@am__quote@

View file

@ -16,6 +16,8 @@
Changes in 2.41:
* Add support for the KVX instruction set.
* Add support for Intel FRED instructions.
* Add support for Intel LKGS instructions.

1012
gas/config/kvx-parse.c Normal file

File diff suppressed because it is too large Load diff

33815
gas/config/kvx-parse.h Normal file

File diff suppressed because it is too large Load diff

2676
gas/config/tc-kvx.c Normal file

File diff suppressed because it is too large Load diff

317
gas/config/tc-kvx.h Normal file
View file

@ -0,0 +1,317 @@
/* tc-kvx.h -- Header file for tc-kvx.c
Copyright (C) 2009-2023 Free Software Foundation, Inc.
Contributed by Kalray SA.
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_KVX
#define TC_KVX
#include "as.h"
#include "include/hashtab.h"
#include "opcode/kvx.h"
#ifdef OBJ_ELF
#include "elf/kvx.h"
#endif
#include <stdlib.h>
#define TARGET_ARCH bfd_arch_kvx
#define KVX_RA_REGNO (67)
#define KVX_SP_REGNO (12)
#define TOKEN_NAME(tok) ((tok) == -1 ? "unknown token" : env.tokens_names[(tok) - 1])
struct token_s {
char *insn;
int begin, end;
int category;
long long class_id;
unsigned long long val;
};
struct token_list
{
char *tok;
unsigned long long val;
long long class_id;
int category;
int loc;
struct token_list *next;
int len;
};
struct token_class {
const char ** class_values;
long long class_id;
int sz;
};
enum token_category {
CAT_INSTRUCTION,
CAT_MODIFIER,
CAT_IMMEDIATE,
CAT_SEPARATOR,
CAT_REGISTER,
CAT_INVALID
};
struct token_classes {
struct token_class *reg_classes;
struct token_class *mod_classes;
struct token_class *imm_classes;
struct token_class *insn_classes;
struct token_class *sep_classes;
};
struct steering_rule {
int steering;
int jump_target;
int stack_it;
};
struct rule {
struct steering_rule *rules;
};
/* Default kvx_registers array. */
extern const struct kvx_Register *kvx_registers;
/* Default kvx_modifiers array. */
extern const char ***kvx_modifiers;
/* Default kvx_regfiles array. */
extern const int *kvx_regfiles;
/* Default values used if no assume directive is given */
extern const struct kvx_core_info *kvx_core_info;
struct kvx_as_options {
/* Arch string passed as argument with -march option. */
char *march;
/* Resource usage checking. */
int check_resource_usage;
/* Generate illegal code: only use for debugging !*/
int generate_illegal_code;
/* Dump asm tables: for debugging */
int dump_table;
/* Dump instructions: for documentation */
int dump_insn;
/* Enable multiline diagnostics */
int diagnostics;
/* Enable more helpful error messages */
int more;
/* Used for HW validation: allows all SFR in GET/SET/WFX */
int allow_all_sfr;
};
extern struct kvx_as_options kvx_options;
struct kvx_as_params {
/* The target's ABI */
int abi;
/* The target's OS/ABI */
int osabi;
/* The target core (0: KV3-1, 1: KV3-2, 2: KV4-1) */
int core;
/* Guard to check if KVX_CORE has been set */
int core_set;
/* Guard to check if KVX_ABI has been set */
int abi_set;
/* Guard to check if KVX_OSABI has been set */
int osabi_set;
/* Flags controlling Position-Independent Code. */
flagword pic_flags;
/* Either 32 or 64. */
int arch_size;
};
extern struct kvx_as_params kvx_params;
struct kvx_as_env {
const char ** tokens_names;
int fst_reg, sys_reg, fst_mod;
int (*promote_immediate) (int);
struct rule *rules;
struct token_classes *token_classes;
struct node_s *insns;
/* Records enabled options. */
struct kvx_as_options opts;
/* Record the parameters of the target architecture. */
struct kvx_as_params params;
/* The hash table of instruction opcodes. */
htab_t opcode_hash;
/* The hash table of register symbols. */
htab_t reg_hash;
/* The hash table of relocations for immediates. */
htab_t reloc_hash;
};
extern struct kvx_as_env env;
struct token_list* parse (struct token_s tok);
void print_token_list (struct token_list *lst);
void free_token_list (struct token_list* tok_list);
void setup (int version);
void cleanup (void);
/* Hooks configuration. */
extern const char * kvx_target_format (void);
#undef TARGET_FORMAT
#define TARGET_FORMAT kvx_target_format ()
/* default little endian */
#define TARGET_BYTES_BIG_ENDIAN 0
#define md_number_to_chars number_to_chars_littleendian
/* for now we have no BFD target */
/* lexing macros */
/* Allow `$' in names. */
#define LEX_DOLLAR (LEX_BEGIN_NAME | LEX_NAME)
/* Disable legacy `broken words' processing. */
#define WORKING_DOT_WORD
extern void kvx_end (void);
#undef md_finish
#define md_finish kvx_end
#define TC_FIX_TYPE struct _symbol_struct *
#define TC_SYMFILED_TYPE struct list_info_struct *
#define TC_INIT_FIX_DATA(FIXP) ((FIXP)->tc_fix_data = NULL)
#define REPEAT_CONS_EXPRESSIONS
#define tc_frob_label(sym) kvx_frob_label(sym)
#define tc_check_label(sym) kvx_check_label(sym)
extern void kvx_frob_label (struct symbol *);
extern void kvx_check_label (struct symbol *);
/* GAS listings (enabled by `-a') */
#define LISTING_HEADER "KVX GAS LISTING"
#define LISTING_LHS_CONT_LINES 100
#define md_start_line_hook kvx_md_start_line_hook
extern void kvx_md_start_line_hook (void);
#define md_emit_single_noop kvx_emit_single_noop()
extern void kvx_emit_single_noop (void);
/* Values passed to md_apply_fix don't include the symbol value. */
#define MD_APPLY_SYM_VALUE(FIX) 0
/* Allow O_subtract in expressionS. */
#define DIFF_EXPR_OK 1
/* Controls the emission of relocations even when the symbol may be resolved
directly by the assembler. */
extern int kvx_force_reloc (struct fix *);
#undef TC_FORCE_RELOCATION
#define TC_FORCE_RELOCATION(fixP) kvx_force_reloc(fixP)
/* Force a relocation for global symbols. */
#define EXTERN_FORCE_RELOC 1
/* Controls the resolution of fixup expressions involving the difference of two
symbols. */
extern int kvx_force_reloc_sub_same (struct fix *, segT);
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
(! SEG_NORMAL (S_GET_SEGMENT((FIX)->fx_addsy)) \
|| kvx_force_reloc_sub_same(FIX, SEC))
/* This expression evaluates to true if the relocation is for a local object
for which we still want to do the relocation at runtime. False if we are
willing to perform this relocation while building the .o file.
We can't resolve references to the GOT or the PLT when creating the object
file, since these tables are only created by the linker. Also, if the symbol
is global, weak, common or not defined, the assembler can't compute the
appropriate reloc, since its location can only be determined at link time.
*/
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel || TC_FORCE_RELOCATION (FIX))
/* This expression evaluates to false if the relocation is for a local object
for which we still want to do the relocation at runtime. True if we are
willing to perform this relocation while building the .o file. This is only
used for pcrel relocations. Use this to ensure that a branch to a preemptible
symbol is not resolved by the assembler. */
#define TC_RELOC_RTSYM_LOC_FIXUP(FIX) \
((FIX)->fx_r_type != BFD_RELOC_KVX_23_PCREL \
|| (FIX)->fx_addsy == NULL \
|| (! S_IS_EXTERNAL ((FIX)->fx_addsy) \
&& ! S_IS_WEAK ((FIX)->fx_addsy) \
&& S_IS_DEFINED ((FIX)->fx_addsy) \
&& ! S_IS_COMMON ((FIX)->fx_addsy)))
/* Local symbols will be adjusted against the section symbol. */
#define tc_fix_adjustable(fixP) 1
/* This arranges for gas/write.c to not apply a relocation if
tc_fix_adjustable says it is not adjustable. The "! symbol_used_in_reloc_p"
test is there specifically to cover the case of non-global symbols in
linkonce sections. It's the generally correct thing to do though; If a
reloc is going to be emitted against a symbol then we don't want to adjust
the fixup by applying the reloc during assembly. The reloc will be applied
by the linker during final link. */
#define TC_FIX_ADJUSTABLE(fixP) \
(! symbol_used_in_reloc_p ((fixP)->fx_addsy) && tc_fix_adjustable (fixP))
/* Force this to avoid -g to fail because of dwarf2 expression .L0 - .L0 */
extern int kvx_validate_sub_fix (struct fix *fix);
#define TC_VALIDATE_FIX_SUB(FIX, SEG) \
(((FIX)->fx_r_type == BFD_RELOC_32 || (FIX)->fx_r_type == BFD_RELOC_16) \
&& kvx_validate_sub_fix((FIX)))
/* Generate a fix for a data allocation pseudo-op*/
#define TC_CONS_FIX_NEW(FRAG,OFF,LEN,EXP,RELOC) kvx_cons_fix_new(FRAG,OFF,LEN,EXP,RELOC)
extern void kvx_cons_fix_new (fragS *f, int where, int nbytes,
expressionS *exp, bfd_reloc_code_real_type);
/* No post-alignment of sections */
#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
/* Enable special handling for the alignment directive. */
extern void kvx_handle_align (fragS *);
#undef HANDLE_ALIGN
#define HANDLE_ALIGN kvx_handle_align
#ifdef OBJ_ELF
/* Enable CFI support. */
#define TARGET_USE_CFIPOP 1
extern void kvx_cfi_frame_initial_instructions (void);
#undef tc_cfi_frame_initial_instructions
#define tc_cfi_frame_initial_instructions kvx_cfi_frame_initial_instructions
extern int kvx_regname_to_dw2regnum (const char *regname);
#undef tc_regname_to_dw2regnum
#define tc_regname_to_dw2regnum kvx_regname_to_dw2regnum
/* All KVX instructions are multiples of 32 bits. */
#define DWARF2_LINE_MIN_INSN_LENGTH 1
#define DWARF2_DEFAULT_RETURN_COLUMN (KVX_RA_REGNO)
#define DWARF2_CIE_DATA_ALIGNMENT -4
#endif
#endif

11
gas/configure vendored
View file

@ -3123,6 +3123,9 @@ fi
AM_BACKSLASH='\'
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@ -12357,6 +12360,14 @@ _ACEOF
frv)
using_cgen=yes
;;
kvx)
for f in config/kvx-parse.o; do
case " $extra_objects " in
*" $f "*) ;;
*) extra_objects="$extra_objects $f" ;;
esac
done
;;
m68k)
f=config/m68k-parse.o
case " $extra_objects " in

View file

@ -475,6 +475,14 @@ changequote([,])dnl
frv)
using_cgen=yes
;;
kvx)
for f in config/kvx-parse.o; do
case " $extra_objects " in
*" $f "*) ;;
*) extra_objects="$extra_objects $f" ;;
esac
done
;;
m68k)
f=config/m68k-parse.o
case " $extra_objects " in

View file

@ -66,6 +66,7 @@ case ${cpu} in
ia64) cpu_type=ia64 ;;
ip2k) cpu_type=ip2k endian=big ;;
iq2000) cpu_type=iq2000 endian=big ;;
kvx) cpu_type=kvx endian=little ;;
lm32) cpu_type=lm32 ;;
loongarch32) cpu_type=loongarch arch=loongarch32;;
loongarch64) cpu_type=loongarch arch=loongarch64;;
@ -279,6 +280,9 @@ case ${generic_target} in
iq2000-*-elf) fmt=elf ;;
kvx-*-*) fmt=elf ;;
kvx-*-linux*) fmt=elf em=linux ;;
lm32-*-*) fmt=elf ;;
loongarch*) fmt=elf ;;
@ -447,7 +451,7 @@ case ${generic_target} in
esac
case ${cpu_type} in
aarch64 | alpha | arm | csky | i386 | ia64 | microblaze | mips | ns32k | \
aarch64 | alpha | arm | csky | i386 | ia64 | kvx | microblaze | mips | ns32k | \
or1k | or1knd | pdp11 | ppc | riscv | sh | sparc | z80 | z8k | loongarch)
bfd_gas=yes
;;

View file

@ -43,6 +43,7 @@
@set I80386
@set IA64
@set IP2K
@set KVX
@set LM32
@set M32C
@set M32R

View file

@ -8006,6 +8006,9 @@ subject, see the hardware manufacturer's manual.
@ifset LM32
* LM32-Dependent:: LM32 Dependent Features
@end ifset
@ifset KVX
* KVX-Dependent:: KVX Dependent Features
@end ifset
@ifset M32C
* M32C-Dependent:: M32C Dependent Features
@end ifset
@ -8231,6 +8234,10 @@ family.
@include c-loongarch.texi
@end ifset
@ifset KVX
@include c-kvx.texi
@end ifset
@ifset M32C
@include c-m32c.texi
@end ifset

147
gas/doc/c-kvx.texi Normal file
View file

@ -0,0 +1,147 @@
@c Copyright (C) 2023-2023 Free Software Foundation, Inc.
@c Contributed by Kalray SA.
@c This is part of the GAS manual.
@c For copying conditions, see the file as.texinfo.
@c man end
@ifset GENERIC
@page
@node KVX-Dependent
@chapter KVX Dependent Features
@end ifset
Labels followed by `::' are extern symbols.
@ifclear GENERIC
@node Machine Dependencies
@chapter KVX Dependent Features
@end ifclear
@cindex KVX support
@menu
* KVX Options:: Options
* KVX Directives:: KVX Machine Directives
@end menu
@node KVX Options
@section Options
@cindex KVX Options
@cindex options for KVX
@c man begin OPTIONS
@table @gcctabopt
@cindex @samp{--dump-insn} option, KVX
@item --dump-insn
Dump the full list of instructions.
@cindex @samp{-march} option, KVX
@item -march=
The assembler supports the following architectures: kv3-1, kv3-2.
@cindex @samp{--check-resources} option, KVX
@item --check-resources
Check that each bundle does not use more resources than available. This is the
default.
@cindex @samp{--no-check-resources} option, KVX
@item --no-check-resources
Do not check that each bundle does not use more resources than available.
@cindex @samp{--generate-illegal-code} option, KVX
@item --generate-illegal-code
For debugging purposes only. In order to properly work, the bundle is sorted
with respect to the issues it uses. If this option is turned on the assembler
will not sort the bundle instructions and illegal bundles might be formed unless
they were properly sorted by hand.
@cindex @samp{--dump-table} option, KVX
@item --dump-table
Dump the table of opcodes.
@cindex @samp{--mpic} option, KVX
@cindex @samp{--mPIC} option, KVX
@item --mpic | --mPIC
Generate position independent code.
@cindex @samp{--mnopic} option, KVX
@item --mnopic
Generate position dependent code.
@cindex @samp{-m32} option, KVX
@item -m32
Generate 32-bits code.
@cindex @samp{--all-sfr} option, KVX
@item --all-sfr
This switch enables the register class "system register". This register
class is used when performing system validation and allows the full class of
system registers to be used even on instructions that are only valid with some
specific system registers.
@cindex @samp{--diagnostics} option, KVX
@item --diagnostics
Print multi-line errors. This is the default.
@cindex @samp{--no-diagnostics} option, KVX
@item --no-diagnostics
Print succinct diagnostics on one line.
@end table
@c man end
@node KVX Directives
@section KVX Machine Directives
@cindex machine directives, AArch64
@cindex AArch64 machine directives
@table @code
@cindex @code{.align} directive, KVX
@item .align ALIGNEMENT
Pad with NOPs until the next boundary with the required ALIGNEMENT.
@cindex @code{.dword} directive, KVX
@item .dword
Declare a double-word-sized (8 bytes) constant.
@cindex @code{.endp} directive, KVX
@item .endp [PROC]
This directive marks the end of the procedure PROC. The name of the procedure
is always ignored (it is only here as a visual indicator).
@smallexample
.proc NAME
...
.endp NAME
@end smallexample
is equivalent to the more traditional
@smallexample
.type NAME, @@function
...
.size NAME,.-NAME
@end smallexample
@cindex @code{.file} directive, KVX
@item .file
This directive is only supported when producing ELF files.
@pxref{File,,@code{.file}} for details.
@cindex @code{.loc} directive, KVX
@item .loc FILENO LINENO
This directive is only supported when producting ELF files.
@pxref{Line,,@code{.line}} for details.
@cindex @code{.proc} directive, KVX
@item .proc PROC
This directive marks the start of procedure, the name of the procedure PROC is
mandatory and all @code{.proc} directive should be matched by exactly one
@code{.endp} directive.
@cindex @code{.word} directive, KVX
@item .word
Declare a word-sized (4 bytes) constant.
@end table

View file

@ -61,6 +61,7 @@ CPU_DOCS = \
%D%/c-hppa.texi \
%D%/c-i386.texi \
%D%/c-ip2k.texi \
%D%/c-kvx.texi \
%D%/c-lm32.texi \
%D%/c-m32c.texi \
%D%/c-m32r.texi \

View file

@ -1,3 +1,4 @@
#name: .org test 1
#as: -gdwarf2
#error_output: org-1.l
#target: !kvx-*-*

View file

@ -1,4 +1,4 @@
#name: bad .bss / .struct data allocation directives
#source: bss.s
#error_output: bad-bss.err
#target: i?86-*-* x86_64-*-* ia64-*-* arm-*-* aarch64-*-*
#target: i?86-*-* x86_64-*-* ia64-*-* arm-*-* aarch64-*-* kvx-*-*

View file

@ -2,7 +2,7 @@
#as: --defsym okay=1
#warning: Warning: zero assumed
#readelf: -sSW
#target: i?86-*-* x86_64-*-* ia64-*-* arm-*-* aarch64-*-*
#target: i?86-*-* x86_64-*-* ia64-*-* arm-*-* aarch64-*-* kvx-*-*
There are [1-9][0-9]* section headers, starting at offset 0x[0-9a-f]*:

View file

@ -239,6 +239,7 @@ if { [is_elf_format] } then {
|| [istarget "mips*-*-*"]
|| [istarget "msp*-*-*"]
|| [istarget "visium-*-*"]
|| [istarget "kvx*-*-*"]
|| ![supports_gnu_unique]
} then {
# hppa64 has a non-standard common directive

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,23 @@
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
# Contributed by Kalray SA.
# 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/>. */
# KVX base instruction set
if [istarget kvx-*-*] then {
set ASFLAGS "-no-diagnostics"
run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
}

View file

@ -0,0 +1,31 @@
#as: -march=kv3-1
#objdump: -dr --prefix-addresses
.*: +file format .*kvx.*
Disassembly of section .text:
[0-9a-f]+ <f> nop
[0-9a-f]+ <f\+0x4> nop;;
[0-9a-f]+ <f\+0x8> addw \$r0 = \$r1, \$r0;;
[0-9a-f]+ <f\+0xc> \*\*\* invalid opcode \*\*\*
[0-9a-f]+ <f\+0x10> ret
[0-9a-f]+ <f\+0x14> addw \$r0 = \$r2, \$r0;;
[0-9a-f]+ <g> addw \$r0 = \$r1, \$r0
[0-9a-f]+ <g\+0x4> addw \$r0 = \$r2, \$r0
[0-9a-f]+ <g\+0x8> addw \$r0 = \$r2, \$r0;;
[0-9a-f]+ <g\+0xc> nop
[0-9a-f]+ <g\+0x10> nop
[0-9a-f]+ <g\+0x14> nop
[0-9a-f]+ <g\+0x18> nop;;
[0-9a-f]+ <g\+0x1c> nop
[0-9a-f]+ <g\+0x20> nop
[0-9a-f]+ <g\+0x24> nop;;
[0-9a-f]+ <g\+0x28> ret
[0-9a-f]+ <g\+0x2c> addw \$r0 = \$r2, \$r0;;

View file

@ -0,0 +1,35 @@
.text
.align 8
.global f
.type f, @function
f:
nop
nop
;;
addw $r0 = $r1, $r0
;;
.byte 0xFF
.align 16
addw $r0 = $r2, $r0
ret
;;
.size f, .-f
.align 8
.global g
.type g, @function
g:
addw $r0 = $r1, $r0
addw $r0 = $r2, $r0
addw $r0 = $r2, $r0
;;
.p2align 6
addw $r0 = $r2, $r0
ret
;;
.size g, .-g

View file

@ -0,0 +1,33 @@
.file 1 "foo.c"
.loc 1 1
nop
nop
;;
.loc 1 2 3
nop
nop
;;
.loc 1 3 prologue_end
nop
nop
;;
.loc 1 4 0 epilogue_begin
nop
nop
;;
.loc 1 5 isa 1 basic_block
nop
nop
;;
.loc 1 6 is_stmt 0
nop
nop
;;
.loc 1 7 is_stmt 1
nop
nop
;;
.loc 1 7 discriminator 1
nop
nop
;;

View file

@ -45,6 +45,8 @@ if { ![istarget s390*-*-*] } {
run_dump_test "lns-common-1" { { source "lns-common-1-ia64.s" } }
} elseif { [istarget or1k*-*-*] } {
run_dump_test "lns-common-1" { { source "lns-common-1-or1k.s" } }
} elseif { [istarget kvx*-*-*] } {
run_dump_test "lns-common-1" { { source "lns-common-1-kvx.s" } }
} else {
run_dump_test "lns-common-1"
}

View file

@ -385,6 +385,7 @@ extern void print_ppc_disassembler_options (FILE *);
extern void print_riscv_disassembler_options (FILE *);
extern void print_arm_disassembler_options (FILE *);
extern void print_arc_disassembler_options (FILE *);
extern void print_kvx_disassembler_options(FILE *);
extern void print_s390_disassembler_options (FILE *);
extern void print_wasm32_disassembler_options (FILE *);
extern void print_loongarch_disassembler_options (FILE *);

115
include/elf/kvx.h Normal file
View file

@ -0,0 +1,115 @@
/* KVX ELF support for BFD.
Copyright (C) 2009-2023 Free Software Foundation, Inc.
Contributed by Kalray SA.
This file is part of 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; see the file COPYING3. If not,
see <http://www.gnu.org/licenses/>. */
#ifndef _ELF_KVX_H
#define _ELF_KVX_H
#include "elf/reloc-macros.h"
START_RELOC_NUMBERS (elf_kvx_reloc_type)
RELOC_NUMBER (R_KVX_NONE, 0)
RELOC_NUMBER (R_KVX_16, 1)
RELOC_NUMBER (R_KVX_32, 2)
RELOC_NUMBER (R_KVX_64, 3)
RELOC_NUMBER (R_KVX_S16_PCREL, 4)
RELOC_NUMBER (R_KVX_PCREL17, 5)
RELOC_NUMBER (R_KVX_PCREL27, 6)
RELOC_NUMBER (R_KVX_32_PCREL, 7)
RELOC_NUMBER (R_KVX_S37_PCREL_LO10, 8)
RELOC_NUMBER (R_KVX_S37_PCREL_UP27, 9)
RELOC_NUMBER (R_KVX_S43_PCREL_LO10, 10)
RELOC_NUMBER (R_KVX_S43_PCREL_UP27, 11)
RELOC_NUMBER (R_KVX_S43_PCREL_EX6, 12)
RELOC_NUMBER (R_KVX_S64_PCREL_LO10, 13)
RELOC_NUMBER (R_KVX_S64_PCREL_UP27, 14)
RELOC_NUMBER (R_KVX_S64_PCREL_EX27, 15)
RELOC_NUMBER (R_KVX_64_PCREL, 16)
RELOC_NUMBER (R_KVX_S16, 17)
RELOC_NUMBER (R_KVX_S32_LO5, 18)
RELOC_NUMBER (R_KVX_S32_UP27, 19)
RELOC_NUMBER (R_KVX_S37_LO10, 20)
RELOC_NUMBER (R_KVX_S37_UP27, 21)
RELOC_NUMBER (R_KVX_S37_GOTOFF_LO10, 22)
RELOC_NUMBER (R_KVX_S37_GOTOFF_UP27, 23)
RELOC_NUMBER (R_KVX_S43_GOTOFF_LO10, 24)
RELOC_NUMBER (R_KVX_S43_GOTOFF_UP27, 25)
RELOC_NUMBER (R_KVX_S43_GOTOFF_EX6, 26)
RELOC_NUMBER (R_KVX_32_GOTOFF, 27)
RELOC_NUMBER (R_KVX_64_GOTOFF, 28)
RELOC_NUMBER (R_KVX_32_GOT, 29)
RELOC_NUMBER (R_KVX_S37_GOT_LO10, 30)
RELOC_NUMBER (R_KVX_S37_GOT_UP27, 31)
RELOC_NUMBER (R_KVX_S43_GOT_LO10, 32)
RELOC_NUMBER (R_KVX_S43_GOT_UP27, 33)
RELOC_NUMBER (R_KVX_S43_GOT_EX6, 34)
RELOC_NUMBER (R_KVX_64_GOT, 35)
RELOC_NUMBER (R_KVX_GLOB_DAT, 36)
RELOC_NUMBER (R_KVX_COPY, 37)
RELOC_NUMBER (R_KVX_JMP_SLOT, 38)
RELOC_NUMBER (R_KVX_RELATIVE, 39)
RELOC_NUMBER (R_KVX_S43_LO10, 40)
RELOC_NUMBER (R_KVX_S43_UP27, 41)
RELOC_NUMBER (R_KVX_S43_EX6, 42)
RELOC_NUMBER (R_KVX_S64_LO10, 43)
RELOC_NUMBER (R_KVX_S64_UP27, 44)
RELOC_NUMBER (R_KVX_S64_EX27, 45)
RELOC_NUMBER (R_KVX_S37_GOTADDR_LO10, 46)
RELOC_NUMBER (R_KVX_S37_GOTADDR_UP27, 47)
RELOC_NUMBER (R_KVX_S43_GOTADDR_LO10, 48)
RELOC_NUMBER (R_KVX_S43_GOTADDR_UP27, 49)
RELOC_NUMBER (R_KVX_S43_GOTADDR_EX6, 50)
RELOC_NUMBER (R_KVX_S64_GOTADDR_LO10, 51)
RELOC_NUMBER (R_KVX_S64_GOTADDR_UP27, 52)
RELOC_NUMBER (R_KVX_S64_GOTADDR_EX27, 53)
RELOC_NUMBER (R_KVX_64_DTPMOD, 54)
RELOC_NUMBER (R_KVX_64_DTPOFF, 55)
RELOC_NUMBER (R_KVX_S37_TLS_DTPOFF_LO10, 56)
RELOC_NUMBER (R_KVX_S37_TLS_DTPOFF_UP27, 57)
RELOC_NUMBER (R_KVX_S43_TLS_DTPOFF_LO10, 58)
RELOC_NUMBER (R_KVX_S43_TLS_DTPOFF_UP27, 59)
RELOC_NUMBER (R_KVX_S43_TLS_DTPOFF_EX6, 60)
RELOC_NUMBER (R_KVX_S37_TLS_GD_LO10, 61)
RELOC_NUMBER (R_KVX_S37_TLS_GD_UP27, 62)
RELOC_NUMBER (R_KVX_S43_TLS_GD_LO10, 63)
RELOC_NUMBER (R_KVX_S43_TLS_GD_UP27, 64)
RELOC_NUMBER (R_KVX_S43_TLS_GD_EX6, 65)
RELOC_NUMBER (R_KVX_S37_TLS_LD_LO10, 66)
RELOC_NUMBER (R_KVX_S37_TLS_LD_UP27, 67)
RELOC_NUMBER (R_KVX_S43_TLS_LD_LO10, 68)
RELOC_NUMBER (R_KVX_S43_TLS_LD_UP27, 69)
RELOC_NUMBER (R_KVX_S43_TLS_LD_EX6, 70)
RELOC_NUMBER (R_KVX_64_TPOFF, 71)
RELOC_NUMBER (R_KVX_S37_TLS_IE_LO10, 72)
RELOC_NUMBER (R_KVX_S37_TLS_IE_UP27, 73)
RELOC_NUMBER (R_KVX_S43_TLS_IE_LO10, 74)
RELOC_NUMBER (R_KVX_S43_TLS_IE_UP27, 75)
RELOC_NUMBER (R_KVX_S43_TLS_IE_EX6, 76)
RELOC_NUMBER (R_KVX_S37_TLS_LE_LO10, 77)
RELOC_NUMBER (R_KVX_S37_TLS_LE_UP27, 78)
RELOC_NUMBER (R_KVX_S43_TLS_LE_LO10, 79)
RELOC_NUMBER (R_KVX_S43_TLS_LE_UP27, 80)
RELOC_NUMBER (R_KVX_S43_TLS_LE_EX6, 81)
RELOC_NUMBER (R_KVX_8, 82)
END_RELOC_NUMBERS (R_KVX_end)
#include "kvx_elfids.h"
#endif

81
include/elf/kvx_elfids.h Normal file
View file

@ -0,0 +1,81 @@
/* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */
/* KVX ELF IDs definitions.
Copyright (C) 2009-2023 Free Software Foundation, Inc.
Contributed by Kalray SA.
This file is part of 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; see the file COPYING3. If not,
see <http://www.gnu.org/licenses/>. */
/* This file holds definitions specific to the KV3 ELF IDs. */
#ifndef _KVX_ELFIDS_H_
#define _KVX_ELFIDS_H_
/* 16.15 8.7 4.3 0 */
/* +----------------------------+ */
/* | CUT | CORE |PIC |ABI | */
/* +----------------------------+ */
#define KVX_CUT_MASK 0x00ff0000
#define KVX_CORE_MASK 0x0000ff00
#define KVX_ABI_MASK 0x000000ff
#define KVX_MACH_MASK (KVX_CUT_MASK | KVX_CORE_MASK | KVX_ABI_MASK)
/*
* Machine private data :
* - byte 0 = ABI specific (PIC, OS, ...)
* - bit 0..3 = ABI ident
* - bit 4 = 32/64 bits addressing
* - bit 5 = PIC
* - byte 1 = Core info :
* - bits 0..3 = Core Major Version
* - bit 4..7 = Core Minor Version
*/
/* Core */
#define ELF_KVX_CORE_BIT_SHIFT (8)
#define ELF_KVX_CORE_MASK (0x7f<<ELF_KVX_CORE_BIT_SHIFT)
#define ELF_KVX_CORE_MAJOR_MASK (0x0F << ELF_KVX_CORE_BIT_SHIFT)
#define ELF_KVX_CORE_MINOR_MASK (0xF0 << ELF_KVX_CORE_BIT_SHIFT)
#define ELF_KVX_CORE_MAJOR_SHIFT (0 + ELF_KVX_CORE_BIT_SHIFT)
#define ELF_KVX_CORE_MINOR_SHIFT (4 + ELF_KVX_CORE_BIT_SHIFT)
#define ELF_KVX_CORE_KV3 (0x03 << ELF_KVX_CORE_BIT_SHIFT)
#define ELF_KVX_CORE_KV4 (0x04 << ELF_KVX_CORE_BIT_SHIFT)
#define ELF_KVX_CORE_KV3_1 (ELF_KVX_CORE_KV3 | (1 << (ELF_KVX_CORE_MINOR_SHIFT)))
#define ELF_KVX_CORE_KV3_2 (ELF_KVX_CORE_KV3 | (2 << (ELF_KVX_CORE_MINOR_SHIFT)))
#define ELF_KVX_CORE_KV4_1 (ELF_KVX_CORE_KV4 | (1 << (ELF_KVX_CORE_MINOR_SHIFT)))
#define ELF_KVX_IS_KV3(flags) (((flags) & ELF_KVX_CORE_MAJOR_MASK) == (ELF_KVX_CORE_KV3))
#define ELF_KVX_IS_KV4(flags) (((flags) & ELF_KVX_CORE_MAJOR_MASK) == (ELF_KVX_CORE_KV4))
#define ELF_KVX_CHECK_CORE(flags,m) (((flags) & ELF_KVX_CORE_MASK)==(m))
#define ELF_KVX_ABI_MASK (0xFF)
#define ELF_KVX_ABI_IDENT_MASK (0x7)
#define ELF_KVX_ABI_REGULAR (0x1)
#define ELF_KVX_ABI_UNDEF (0x0)
#define ELF_KVX_ABI_64B_ADDR_BIT (0x08)
#define ELF_KVX_ABI_PIC_BIT (0x10)
#endif /* _KVX_ELFIDS_H_ */

3159
include/opcode/kvx.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -237,6 +237,7 @@ ALL_EMULATION_SOURCES = \
eelf32ip2k.c \
eelf32iq10.c \
eelf32iq2000.c \
eelf32kvx.c \
eelf32lm32.c \
eelf32lm32fd.c \
eelf32lppc.c \
@ -448,6 +449,8 @@ ALL_64_EMULATION_SOURCES = \
eelf64lriscv_lp64f.c \
eelf64ltsmip.c \
eelf64ltsmip_fbsd.c \
eelf64kvx.c \
eelf64kvx_linux.c \
eelf64mmix.c \
eelf64ppc.c \
eelf64ppc_fbsd.c \
@ -735,6 +738,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ip2k.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32iq10.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32iq2000.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32kvx.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lm32.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lm32fd.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lppc.Pc@am__quote@
@ -937,6 +941,8 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64hppa.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc_fbsd.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64kvx.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64kvx_linux.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64loongarch.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv_lp64.Pc@am__quote@

View file

@ -738,6 +738,7 @@ ALL_EMULATION_SOURCES = \
eelf32ip2k.c \
eelf32iq10.c \
eelf32iq2000.c \
eelf32kvx.c \
eelf32lm32.c \
eelf32lm32fd.c \
eelf32lppc.c \
@ -948,6 +949,8 @@ ALL_64_EMULATION_SOURCES = \
eelf64lriscv_lp64f.c \
eelf64ltsmip.c \
eelf64ltsmip_fbsd.c \
eelf64kvx.c \
eelf64kvx_linux.c \
eelf64mmix.c \
eelf64ppc.c \
eelf64ppc_fbsd.c \
@ -1373,6 +1376,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ip2k.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32iq10.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32iq2000.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32kvx.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32l4300.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lm32.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lm32fd.Po@am__quote@
@ -1443,6 +1447,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64btsmip.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64btsmip_fbsd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64hppa.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64kvx.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64kvx_linux.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64loongarch.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc_fbsd.Po@am__quote@
@ -2621,6 +2627,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ebmipvxworks.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32elmip.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32elmipvxworks.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32kvx.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32l4300.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32loongarch.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lmip.Pc@am__quote@
@ -2654,6 +2661,8 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64btsmip.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64btsmip_fbsd.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64hppa.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64kvx_linux.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64kvx.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc_fbsd.Pc@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64loongarch.Pc@am__quote@

View file

@ -2,6 +2,8 @@
Changes in 2.41:
* Add support for the KVX instruction set.
* The linker now accepts a command line option of --remap-inputs
<PATTERN>=<FILE> to relace any input file that matches <PATTERN> with
<FILE>. In addition the option --remap-inputs-file=<FILE> can be used to

View file

@ -473,6 +473,11 @@ lm32-*-*linux*) targ_emul=elf32lm32fd
lm32-*-*) targ_emul=elf32lm32
targ_extra_emuls="elf32lm32fd"
;;
kvx-*-linux*) targ_emul=elf64kvx_linux
targ_extra_emuls="elf64kvx"
;;
kvx-*-*) targ_emul=elf64kvx; targ_extra_emuls="elf64kvx_linux elf32kvx"
;;
m32c-*-elf)
targ_emul=elf32m32c
;;

32
ld/emulparams/elf32kvx.sh Executable file
View file

@ -0,0 +1,32 @@
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
# Contributed by Kalray SA.
# 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/>. */
ARCH=kvx
MACHINE=
SCRIPT_NAME=elf
# bundle with 1 nop insn
NOP=0x00f0037f
TEMPLATE_NAME=elf
EXTRA_EM_FILE=kvxelf
OUTPUT_FORMAT="elf32-kvx"
TEXT_START_ADDR=0x10000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
WRITABLE_RODATA=
GENERATE_SHLIB_SCRIPT=yes

39
ld/emulparams/elf64kvx.sh Normal file
View file

@ -0,0 +1,39 @@
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
# Contributed by Kalray SA.
# 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/>. */
ARCH=kvx
MACHINE=
# bundle with 1 nop insn
NOP=0x00f0037f
SCRIPT_NAME=elf
ELFSIZE=64
OUTPUT_FORMAT="elf64-kvx"
NO_REL_RELOCS=yes
TEMPLATE_NAME=elf
EXTRA_EM_FILE=kvxelf
EMBEDDED=yes
TEXT_START_ADDR=0x10000
# No support for .s* sections.
NO_SMALL_DATA=yes
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
GENERATE_SHLIB_SCRIPT=yes

View file

@ -0,0 +1,41 @@
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
# Contributed by Kalray SA.
# 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/>. */
ARCH=kvx
MACHINE=
# bundle with 1 nop insn
NOP=0x00f0037f
SCRIPT_NAME=elf
ELFSIZE=64
OUTPUT_FORMAT="elf64-kvx"
NO_REL_RELOCS=yes
TEMPLATE_NAME=elf
EXTRA_EM_FILE=kvxelf
# first user page at 64K.
TEXT_START_ADDR=0x10000
# No support for .s* sections.
NO_SMALL_DATA=yes
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes

316
ld/emultempl/kvxelf.em Normal file
View file

@ -0,0 +1,316 @@
# This shell script emits a C file. -*- C -*-
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
# Contributed by Kalray 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; see the file COPYING3. If not,
# see <http://www.gnu.org/licenses/>.
#
# This file is sourced from elf32.em, and defines extra kvx-elf
# specific routines.
#
fragment <<EOF
#include "ldctor.h"
#include "elf/kvx.h"
#include "elfxx-kvx.h"
static void
elf${ELFSIZE}_kvx_before_allocation (void)
{
EOF
if test x"${EMULATION_NAME}" != x"elf64kvx_linux"; then
fragment <<EOF
if (bfd_link_pie (&link_info)) {
einfo (_("%F:%P: -pie not supported\n"));
}
EOF
fi
fragment <<EOF
/* Call the standard elf routine. */
gld${EMULATION_NAME}_before_allocation ();
}
/* Fake input file for stubs. */
static lang_input_statement_type *stub_file;
/* Whether we need to call gldarm_layout_sections_again. */
static int need_laying_out = 0;
/* Maximum size of a group of input sections that can be handled by
one stub section. A value of +/-1 indicates the bfd back-end
should use a suitable default size. */
static bfd_signed_vma group_size = -1;
struct hook_stub_info
{
lang_statement_list_type add;
asection *input_section;
};
/* Traverse the linker tree to find the spot where the stub goes. */
static bool
hook_in_stub (struct hook_stub_info *info, lang_statement_union_type **lp)
{
lang_statement_union_type *l;
bool ret;
for (; (l = *lp) != NULL; lp = &l->header.next)
{
switch (l->header.type)
{
case lang_constructors_statement_enum:
ret = hook_in_stub (info, &constructor_list.head);
if (ret)
return ret;
break;
case lang_output_section_statement_enum:
ret = hook_in_stub (info,
&l->output_section_statement.children.head);
if (ret)
return ret;
break;
case lang_wild_statement_enum:
ret = hook_in_stub (info, &l->wild_statement.children.head);
if (ret)
return ret;
break;
case lang_group_statement_enum:
ret = hook_in_stub (info, &l->group_statement.children.head);
if (ret)
return ret;
break;
case lang_input_section_enum:
if (l->input_section.section == info->input_section)
{
/* We've found our section. Insert the stub immediately
after its associated input section. */
*(info->add.tail) = l->header.next;
l->header.next = info->add.head;
return true;
}
break;
case lang_data_statement_enum:
case lang_reloc_statement_enum:
case lang_object_symbols_statement_enum:
case lang_output_statement_enum:
case lang_target_statement_enum:
case lang_input_statement_enum:
case lang_assignment_statement_enum:
case lang_padding_statement_enum:
case lang_address_statement_enum:
case lang_fill_statement_enum:
break;
default:
FAIL ();
break;
}
}
return false;
}
/* Call-back for elf${ELFSIZE}_kvx_size_stubs. */
/* Create a new stub section, and arrange for it to be linked
immediately after INPUT_SECTION. */
static asection *
elf${ELFSIZE}_kvx_add_stub_section (const char *stub_sec_name,
asection *input_section)
{
asection *stub_sec;
flagword flags;
asection *output_section;
lang_output_section_statement_type *os;
struct hook_stub_info info;
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
| SEC_HAS_CONTENTS | SEC_RELOC | SEC_IN_MEMORY | SEC_KEEP);
stub_sec = bfd_make_section_anyway_with_flags (stub_file->the_bfd,
stub_sec_name, flags);
if (stub_sec == NULL)
goto err_ret;
bfd_set_section_alignment (stub_sec, 2);
output_section = input_section->output_section;
os = lang_output_section_get (output_section);
info.input_section = input_section;
lang_list_init (&info.add);
lang_add_section (&info.add, stub_sec, NULL, NULL, os);
if (info.add.head == NULL)
goto err_ret;
if (hook_in_stub (&info, &os->children.head))
return stub_sec;
err_ret:
einfo ("%X%P: can not make stub section: %E\n");
return NULL;
}
/* Another call-back for elf${ELFSIZE}_kvx_size_stubs. */
static void
gldkvx_layout_sections_again (void)
{
/* If we have changed sizes of the stub sections, then we need
to recalculate all the section offsets. This may mean we need to
add even more stubs. */
ldelf_map_segments (true);
need_laying_out = -1;
}
static void
build_section_lists (lang_statement_union_type *statement)
{
if (statement->header.type == lang_input_section_enum)
{
asection *i = statement->input_section.section;
if (!((lang_input_statement_type *) i->owner->usrdata)->flags.just_syms
&& (i->flags & SEC_EXCLUDE) == 0
&& i->output_section != NULL
&& i->output_section->owner == link_info.output_bfd)
elf${ELFSIZE}_kvx_next_input_section (& link_info, i);
}
}
static void
gld${EMULATION_NAME}_after_allocation (void)
{
int ret;
/* bfd_elf32_discard_info just plays with debugging sections,
ie. doesn't affect any code, so we can delay resizing the
sections. It's likely we'll resize everything in the process of
adding stubs. */
ret = bfd_elf_discard_info (link_info.output_bfd, & link_info);
if (ret < 0)
{
einfo ("%X%P: .eh_frame/.stab edit: %E\n");
return;
}
else if (ret > 0)
need_laying_out = 1;
/* If generating a relocatable output file, then we don't
have to examine the relocs. */
if (stub_file != NULL && !bfd_link_relocatable (&link_info))
{
ret = elf${ELFSIZE}_kvx_setup_section_lists (link_info.output_bfd,
&link_info);
if (ret != 0)
{
if (ret < 0)
{
einfo ("%X%P: could not compute sections lists for stub generation: %E\n");
return;
}
lang_for_each_statement (build_section_lists);
/* Call into the BFD backend to do the real work. */
if (! elf${ELFSIZE}_kvx_size_stubs (link_info.output_bfd,
stub_file->the_bfd,
& link_info,
group_size,
& elf${ELFSIZE}_kvx_add_stub_section,
& gldkvx_layout_sections_again))
{
einfo ("%X%P: cannot size stub section: %E\n");
return;
}
}
}
if (need_laying_out != -1)
ldelf_map_segments (need_laying_out);
}
static void
gld${EMULATION_NAME}_finish (void)
{
if (!bfd_link_relocatable (&link_info))
{
/* Now build the linker stubs. */
if (stub_file != NULL
&& stub_file->the_bfd->sections != NULL)
{
if (! elf${ELFSIZE}_kvx_build_stubs (& link_info))
einfo ("%X%P: can not build stubs: %E\n");
}
}
finish_default ();
}
/* This is a convenient point to tell BFD about target specific flags.
After the output has been created, but before inputs are read. */
static void
kvx_elf_create_output_section_statements (void)
{
if (!(bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour
&& elf_object_id (link_info.output_bfd) == KVX_ELF_DATA))
return;
stub_file = lang_add_input_file ("linker stubs",
lang_input_file_is_fake_enum,
NULL);
stub_file->the_bfd = bfd_create ("linker stubs", link_info.output_bfd);
if (stub_file->the_bfd == NULL
|| ! bfd_set_arch_mach (stub_file->the_bfd,
bfd_get_arch (link_info.output_bfd),
bfd_get_mach (link_info.output_bfd)))
{
einfo ("%X%P: can not create BFD %E\n");
return;
}
stub_file->the_bfd->flags |= BFD_LINKER_CREATED;
ldlang_add_file (stub_file);
if (!kvx_elf${ELFSIZE}_init_stub_bfd (&link_info, stub_file->the_bfd))
einfo ("%F%P: can not init BFD: %E\n");
}
#define lang_for_each_input_file kvx_lang_for_each_input_file
EOF
LDEMUL_BEFORE_ALLOCATION=elf${ELFSIZE}_kvx_before_allocation
LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=kvx_elf_create_output_section_statements
# Call the extra arm-elf function
LDEMUL_FINISH=gld${EMULATION_NAME}_finish

View file

@ -115,6 +115,7 @@ eelf32ft32.c
eelf32ip2k.c
eelf32iq10.c
eelf32iq2000.c
eelf32kvx.c
eelf32l4300.c
eelf32lm32.c
eelf32lm32fd.c
@ -185,6 +186,8 @@ eelf64briscv_lp64f.c
eelf64btsmip.c
eelf64btsmip_fbsd.c
eelf64hppa.c
eelf64kvx.c
eelf64kvx_linux.c
eelf64loongarch.c
eelf64lppc.c
eelf64lppc_fbsd.c

View file

@ -15,7 +15,7 @@ Contents of CTF section .ctf:
#...
Function objects:
#...
foo -> 0x[0-9]*: \(kind 5\) int \(\*\) \(\(nonrepresentable type.*\)\) \(aligned at .*\)
foo -> 0x[0-9a-f]*: \(kind 5\) int \(\*\) \(\(nonrepresentable type.*\)\) \(aligned at .*\)
#...
Types:
#...

View file

@ -199,6 +199,7 @@ proc target_defaults_to_execstack {} {
|| [istarget "arc*-*-*"]
|| [istarget "cris*-*-*"]
|| [istarget "ia64*-*-*"]
|| [istarget "kvx*-*-*"]
|| [istarget "loongarch*-*-*"]
|| [istarget "nios2*-*-*"]
|| [istarget "powerpc64*-*-*"]

View file

@ -468,7 +468,7 @@ run_ld_link_tests [list \
# These targets don't copy dynamic variables into .bss.
setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" *loongarch*-*-*
# or don't have .data.rel.ro
setup_xfail "hppa*64*-*-hpux*" "tic6x-*-*"
setup_xfail "hppa*64*-*-hpux*" "tic6x-*-*" "kvx*-*-*"
# or complain about relocs in read-only sections
setup_xfail frv-*-* lm32-*-*
run_ld_link_tests [list \
@ -515,6 +515,7 @@ run_ld_link_tests {
}
if { [istarget *-*-linux*]
|| [istarget kvx-*-*]
|| [istarget *-*-nacl*]
|| [istarget *-*-gnu*] } {
run_ld_link_tests {

View file

@ -30,6 +30,7 @@ if { ![is_elf_format] || ![supports_gnu_osabi]
|| [istarget bfin-*-*]
|| [istarget cris*-*-*]
|| [istarget frv-*-*]
|| [istarget kvx*-*-*]
|| [istarget lm32-*-*]
|| [istarget m32r-*-*]
|| [istarget m68k-*-*]

View file

@ -0,0 +1,79 @@
#name: kvx-farcall-back
#source: farcall-back.s
#as:
#ld: -Ttext 0x1000 --section-start .foo=0x80001000
#objdump: -dr
#...
Disassembly of section .text:
.* <_start>:
.*: .. .. .. .. call .* <__bar1_veneer>;;
.*: .. .. .. .. goto .* <__bar1_veneer>;;
.*: .. .. .. .. call .* <__bar2_veneer>;;
.*: .. .. .. .. goto .* <__bar2_veneer>;;
.*: .. .. .. .. call .* <__bar3_veneer>;;
.*: .. .. .. .. goto .* <__bar3_veneer>;;
.*: 00 00 d0 0f ret;;
...
.* <_back>:
.*: 00 00 d0 0f ret;;
.* <__bar3_veneer>:
.*: 00 .. 40 e0 0c 00 20 00 make \$r16 = .* \(0x.*\);;
.*: 10 00 d8 0f igoto \$r16;;
.* <__bar2_veneer>:
.*: 00 .. 40 e0 08 00 20 00 make \$r16 = .* \(0x.*\);;
.*: 10 00 d8 0f igoto \$r16;;
.* <__bar1_veneer>:
.*: 00 .. 40 e0 04 00 20 00 make \$r16 = .* \(0x.*\);;
.*: 10 00 d8 0f igoto \$r16;;
Disassembly of section .foo:
.* <bar1>:
.*: 00 00 d0 0f ret;;
.*: .. .. .. .. goto .* <___start_veneer>;;
...
.* <bar2>:
.*: 00 00 d0 0f ret;;
.*: .. .. .. .. goto .* <___start_veneer>;;
...
.* <bar3>:
.*: 00 00 d0 0f ret;;
.*: .. .. .. .. goto .* <___back_veneer>;;
.* <___start_veneer>:
.*: 00 .. 40 e0 04 00 00 00 make \$r16 = .* \(0x.*\);;
.*: 10 00 d8 0f igoto \$r16;;
.* <___back_veneer>:
.*: 00 .. 40 e0 08 00 00 00 make \$r16 = .* \(0x.*\);;
.*: 10 00 d8 0f igoto \$r16;;

View file

@ -0,0 +1,54 @@
.global _start
.global _back
.global bar1
.global bar2
.global bar3
# We will place the section .text at 0x1000.
.text
.type _start, @function
_start:
call bar1
;;
goto bar1
;;
call bar2
;;
goto bar2
;;
call bar3
;;
goto bar3
;;
ret
;;
.space 0x1000
.type _back, @function
_back: ret
;;
# We will place the section .foo at 0x80001000.
.section .foo, "xa"
.type bar1, @function
bar1:
ret
;;
goto _start
;;
.space 0x1000
.type bar2, @function
bar2:
ret
;;
goto _start
;;
.space 0x1000
.type bar3, @function
bar3:
ret
;;
goto _back
;;

View file

@ -0,0 +1,14 @@
#name: kvx-farcall-call-defsym
#source: farcall-call-defsym.s
#as:
#ld: -Ttext 0x1000 --defsym=bar=0x8001000
#objdump: -dr
#...
Disassembly of section .text:
.* <_start>:
1000: 00 00 00 1a call 8001000 <bar>;;
1004: 00 00 d0 0f ret;;

View file

@ -0,0 +1,12 @@
.global _start
.global bar
# We will place the section .text at 0x1000.
.text
_start:
call bar
;;
ret
;;

View file

@ -0,0 +1,24 @@
#name: kvx-farcall-call-none-function
#source: farcall-call-none-function.s
#as:
#ld: -Ttext 0x1000 --section-start .foo=0x20001000
#objdump: -dr
#...
Disassembly of section .text:
.* <_start>:
.*: .. .. .. .. call .* <__bar_veneer>;;
.*: 00 00 d0 0f ret;;
.* <__bar_veneer>:
.*: .. .. 40 e0 .. .. .. .. make \$r16 = .* \(0x.*\);;
.*: 10 00 d8 0f igoto \$r16;;
Disassembly of section .foo:
.* <bar>:
.*: 00 00 d0 0f ret;;

View file

@ -0,0 +1,19 @@
.global _start
.global bar
# We will place the section .text at 0x1000.
.text
_start:
call bar
;;
ret
;;
# We will place the section .foo at 0x10001000.
.section .foo, "xa"
bar:
ret
;;

View file

@ -0,0 +1,31 @@
tmpdir/dump: file format elf32-kvx
Disassembly of section .plt:
.* <foo@plt-0x20>:
...
.* <foo@plt>:
.*: 10 00 c4 0f get \$r16 = \$pc;;
.*: .. .. 40 b0 .. .. .. 18 lwz \$r16 = [0-9]* \(0x[0-9a-f]*\)\[\$r16\];;
.*: 10 00 d8 0f igoto \$r16;;
Disassembly of section .text:
.* <_start>:
...
.*: .. .. 00 18 call .* <__foo_veneer>;;
.*: 00 00 d0 0f ret;;
.* <__foo_veneer>:
.*: .. .. 40 e0 00 00 00 00 make \$r16 = .* \(0x[0-9a-f]*\);;
.*: 10 00 d8 0f igoto \$r16;;

View file

@ -0,0 +1,34 @@
#name: kvx-farcall-call-plt
#source: farcall-call-plt.s
#as:
#ld: -shared
#objdump: -dr
#...
Disassembly of section .plt:
.* <.plt>:
...
.* <foo@plt>:
.*: 10 00 c4 0f get \$r16 = \$pc;;
.*: .. .. 40 .. .. .. .. 18 l[wzd]* \$r16 = [0-9]* \(0x[0-9a-f]*\)\[\$r16\];;
.*: 10 00 d8 0f igoto \$r16;;
Disassembly of section .text:
.* <_start>:
...
.*: .. .. 00 18 call .* <__foo_veneer>;;
.*: 00 00 d0 0f ret;;
.* <__foo_veneer>:
.*: .. .. 40 e0 00 00 00 00 make \$r16 = .* \(0x[0-9a-f]*\);;
.*: 10 00 d8 0f igoto \$r16;;

View file

@ -0,0 +1,14 @@
.global _start
.global foo
.type foo, @function
.text
_start:
# ((1 << 26) - 1) << 2
# PCREL27 relocation out of range to plt stub,
# we need long branch veneer.
.skip 268435452, 0
call foo
;;
ret
;;

View file

@ -0,0 +1,34 @@
#name: kvx-farcall-call-section
#source: farcall-call-section.s
#as:
#ld: -Ttext 0x1000 --section-start .foo=0x20001000
#objdump: -dr
#...
Disassembly of section .text:
.* <_start>:
.*: .. .. .. .. call .* <___veneer>;;
.*: .. .. .. .. call .* <___veneer>;;
.*: 00 00 d0 0f ret;;
.* <___veneer>:
.*: .. 00 40 e0 .. .. .. .. make \$r16 = .* \(0x.*\);;
.*: 10 00 d8 0f igoto \$r16;;
.* <___veneer>:
.*: .. 01 40 e0 .. .. .. .. make \$r16 = .* \(0x.*\);;
.*: 10 00 d8 0f igoto \$r16;;
Disassembly of section .foo:
.* <bar>:
.*: 00 00 d0 0f ret;;
.* <bar2>:
.*: 00 00 d0 0f ret;;

View file

@ -0,0 +1,25 @@
.global _start
# We will place the section .text at 0x1000.
.text
_start:
call bar
;;
call bar2
;;
ret
;;
# We will place the section .foo at 0x20001000.
.section .foo, "xa"
.type bar, @function
bar:
ret
;;
.type bar2, @function
bar2:
ret
;;

View file

@ -0,0 +1,25 @@
#name: kvx-farcall-call
#source: farcall-call.s
#as:
#ld: -Ttext 0x1000 --section-start .foo=0x20001000
#objdump: -dr
#...
Disassembly of section .text:
.* <_start>:
.*: .. .. .. 18 call .* <__bar_veneer>;;
.*: 00 00 d0 0f ret;;
.* <__bar_veneer>:
.*: .. .. 40 e0 .. .. .. .. make \$r16 = .* \(0x.*\);;
.*: 10 00 d8 0f igoto \$r16;;
Disassembly of section .foo:
.* <bar>:
.*: 00 00 d0 0f ret;;

View file

@ -0,0 +1,20 @@
.global _start
.global bar
# We will place the section .text at 0x1000.
.text
_start:
call bar
;;
ret
;;
# We will place the section .foo at 0x20001000.
.section .foo, "xa"
.type bar, @function
bar:
ret
;;

View file

@ -0,0 +1,14 @@
#name: kvx-farcall-goto-defsym
#source: farcall-goto-defsym.s
#as:
#ld: -Ttext 0x1000 --defsym=bar=0x8001000
#objdump: -dr
#...
Disassembly of section .text:
.* <_start>:
1000: 00 00 00 12 goto 8001000 <bar>;;
1004: 00 00 d0 0f ret;;

View file

@ -0,0 +1,12 @@
.global _start
.global bar
# We will place the section .text at 0x1000.
.text
_start:
goto bar
;;
ret
;;

View file

@ -0,0 +1,5 @@
#name: kvx-farcall-goto-gsym
#source: farcall-goto-gsym.s
#as:
#ld: -Ttext 0x1000
#error: .*\(.text\+0x0\): relocation truncated to fit: R_KVX_PCREL27 against symbol `bar_gsym'.*

View file

@ -0,0 +1,20 @@
.global _start
.global bar_gsym
# We will place the section .text at 0x1000.
.text
_start:
# for long jump (goto) to global symbol, we shouldn't insert veneer
# as the veneer will clobber r16/r17 which is caller saved, gcc only
# reserve them for function call relocation (call).
goto bar_gsym
;;
# ((1 << 26) - 1) << 2
.skip 268435452, 0
bar_gsym:
nop
;;
ret
;;

View file

@ -0,0 +1,26 @@
#name: kvx-farcall-goto-none-function
#source: farcall-goto-none-function.s
#as:
#ld: -Ttext 0x1000 --section-start .foo=0x20001000
#objdump: -dr
#...
Disassembly of section .text:
.* <_start>:
.*: .. .. .. .. goto .* <__bar_veneer>;;
.*: 00 00 d0 0f ret;;
.* <__bar_veneer>:
.*: .. .. 40 e0 .. .. .. .. make \$r16 = .* \(0x.*\);;
.*: 10 00 d8 0f igoto \$r16;;
Disassembly of section .foo:
.* <bar>:
.*: 00 00 d0 0f ret;;

View file

@ -0,0 +1,19 @@
.global _start
.global bar
# We will place the section .text at 0x1000.
.text
_start:
goto bar
;;
ret
;;
# We will place the section .foo at 0x20001000.
.section .foo, "xa"
bar:
ret
;;

View file

@ -0,0 +1,31 @@
tmpdir/dump: file format elf32-kvx
Disassembly of section .plt:
.* <.plt>:
...
.* <foo@plt>:
.*: 10 00 c4 0f get \$r16 = \$pc;;
.*: .. .. 40 .. .. .. .. .. l[wzd]* \$r16 = [0-9]* \(0x[0-9a-b]*\)\[\$r16\];;
.*: 10 00 d8 0f igoto \$r16;;
Disassembly of section .text:
.* <_start>:
...
.*: .. .. .. 10 goto .* <__foo_veneer>;;
.*: 00 00 d0 0f ret;;
.* <__foo_veneer>:
.*: .. .. 40 e0 00 00 00 00 make \$r16 = [0-9]* \(0x[0-9a-b]*\);;
.*: 10 00 d8 0f igoto \$r16;;

View file

@ -0,0 +1,34 @@
#name: kvx-farcall-goto-plt
#source: farcall-goto-plt.s
#as:
#ld: -shared
#objdump: -dr
#...
Disassembly of section .plt:
.* <.plt>:
...
.* <foo@plt>:
.*: 10 00 c4 0f get \$r16 = \$pc;;
.*: .. .. 40 .. .. .. .. .. l[wzd]* \$r16 = [0-9]* \(0x[0-9a-b]*\)\[\$r16\];;
.*: 10 00 d8 0f igoto \$r16;;
Disassembly of section .text:
.* <_start>:
...
.*: .. .. .. 10 goto .* <__foo_veneer>;;
.*: 00 00 d0 0f ret;;
.* <__foo_veneer>:
.*: .. .. 40 e0 00 00 00 00 make \$r16 = [0-9]* \(0x[0-9a-b]*\);;
.*: 10 00 d8 0f igoto \$r16;;

Some files were not shown because too many files have changed in this diff Show more