LoongArch bfd support
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn> Zhensong Liu <liuzhensong@loongson.cn> Weinan Liu <liuweinan@loongson.cn> bfd/ * Makefile.am: Add LoongArch. * archures.c: Likewise. * config.bfd: Likewise. * configure.ac: Likewise. * cpu-loongarch.c: New. * elf-bfd.h: Add LoongArch. * elf.c: Add LoongArch elfcore_grok_xxx. * elfnn-loongarch.c: New. * elfxx-loongarch.c: New. * elfxx-loongarch.h: New. * reloc.c: Add LoongArch BFD RELOC ENUM. * targets.c: Add LoongArch target. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * configure: Regenerate. * libbfd.h: Regenerate. * po/BLD-POTFILES.in: Regenerate. * po/SRC-POTFILES.in: Regenerate. include/ * elf/common.h: Add NT_LARCH_{CPUCFG,CSR,LSX,LASX}. * elf/loongarch.h: New.
This commit is contained in:
parent
e515d93264
commit
e214f8db56
@ -118,6 +118,7 @@ ALL_MACHINES = \
|
||||
cpu-ip2k.lo \
|
||||
cpu-iq2000.lo \
|
||||
cpu-lm32.lo \
|
||||
cpu-loongarch.lo \
|
||||
cpu-m10200.lo \
|
||||
cpu-m10300.lo \
|
||||
cpu-m32c.lo \
|
||||
@ -202,6 +203,7 @@ ALL_MACHINES_CFILES = \
|
||||
cpu-ip2k.c \
|
||||
cpu-iq2000.c \
|
||||
cpu-lm32.c \
|
||||
cpu-loongarch.c \
|
||||
cpu-m10200.c \
|
||||
cpu-m10300.c \
|
||||
cpu-m32c.c \
|
||||
@ -548,6 +550,9 @@ BFD64_BACKENDS = \
|
||||
elf64-ia64.lo \
|
||||
elf64-ia64-vms.lo \
|
||||
elfxx-ia64.lo \
|
||||
elf32-loongarch.lo \
|
||||
elf64-loongarch.lo \
|
||||
elfxx-loongarch.lo \
|
||||
elfn32-mips.lo \
|
||||
elf64-mips.lo \
|
||||
elfxx-mips.lo \
|
||||
@ -601,6 +606,7 @@ BFD64_BACKENDS_CFILES = \
|
||||
elfn32-mips.c \
|
||||
elfxx-aarch64.c \
|
||||
elfxx-ia64.c \
|
||||
elfxx-loongarch.c \
|
||||
elfxx-mips.c \
|
||||
elfxx-riscv.c \
|
||||
mach-o-aarch64.c \
|
||||
@ -665,6 +671,7 @@ SOURCE_CFILES = \
|
||||
BUILD_CFILES = \
|
||||
elf32-aarch64.c elf64-aarch64.c \
|
||||
elf32-ia64.c elf64-ia64.c \
|
||||
elf32-loongarch.c elf64-loongarch.c \
|
||||
elf32-riscv.c elf64-riscv.c \
|
||||
peigen.c pepigen.c pex64igen.c
|
||||
|
||||
@ -686,7 +693,7 @@ SOURCE_HFILES = \
|
||||
elf-bfd.h elfcode.h elfcore.h elf-hppa.h elf-linker-x86.h \
|
||||
elf-linux-core.h elf-nacl.h elf-s390.h elf-vxworks.h \
|
||||
elfxx-aarch64.h elfxx-ia64.h elfxx-mips.h elfxx-riscv.h \
|
||||
elfxx-sparc.h elfxx-tilegx.h elfxx-x86.h \
|
||||
elfxx-sparc.h elfxx-tilegx.h elfxx-x86.h elfxx-loongarch.h \
|
||||
genlink.h go32stub.h \
|
||||
libaout.h libbfd.h libcoff.h libecoff.h libhppa.h \
|
||||
libpei.h libxcoff.h \
|
||||
@ -842,6 +849,14 @@ elf64-ia64.c : elfnn-ia64.c
|
||||
echo "#line 1 \"elfnn-ia64.c\"" > $@
|
||||
$(SED) -e s/NN/64/g < $< >> $@
|
||||
|
||||
elf32-loongarch.c : elfnn-loongarch.c
|
||||
echo "#line 1 \"elfnn-loongarch.c\"" > $@
|
||||
$(SED) -e s/NN/32/g < $< >> $@
|
||||
|
||||
elf64-loongarch.c : elfnn-loongarch.c
|
||||
echo "#line 1 \"elfnn-loongarch.c\"" > $@
|
||||
$(SED) -e s/NN/64/g < $< >> $@
|
||||
|
||||
elf32-riscv.c : elfnn-riscv.c
|
||||
echo "#line 1 \"elfnn-riscv.c\"" > $@
|
||||
$(SED) -e s/NN/32/g < $< >> $@
|
||||
|
@ -543,6 +543,7 @@ ALL_MACHINES = \
|
||||
cpu-ip2k.lo \
|
||||
cpu-iq2000.lo \
|
||||
cpu-lm32.lo \
|
||||
cpu-loongarch.lo \
|
||||
cpu-m10200.lo \
|
||||
cpu-m10300.lo \
|
||||
cpu-m32c.lo \
|
||||
@ -627,6 +628,7 @@ ALL_MACHINES_CFILES = \
|
||||
cpu-ip2k.c \
|
||||
cpu-iq2000.c \
|
||||
cpu-lm32.c \
|
||||
cpu-loongarch.c \
|
||||
cpu-m10200.c \
|
||||
cpu-m10300.c \
|
||||
cpu-m32c.c \
|
||||
@ -975,6 +977,9 @@ BFD64_BACKENDS = \
|
||||
elf64-ia64.lo \
|
||||
elf64-ia64-vms.lo \
|
||||
elfxx-ia64.lo \
|
||||
elf32-loongarch.lo \
|
||||
elf64-loongarch.lo \
|
||||
elfxx-loongarch.lo \
|
||||
elfn32-mips.lo \
|
||||
elf64-mips.lo \
|
||||
elfxx-mips.lo \
|
||||
@ -1028,6 +1033,7 @@ BFD64_BACKENDS_CFILES = \
|
||||
elfn32-mips.c \
|
||||
elfxx-aarch64.c \
|
||||
elfxx-ia64.c \
|
||||
elfxx-loongarch.c \
|
||||
elfxx-mips.c \
|
||||
elfxx-riscv.c \
|
||||
mach-o-aarch64.c \
|
||||
@ -1091,6 +1097,7 @@ SOURCE_CFILES = \
|
||||
BUILD_CFILES = \
|
||||
elf32-aarch64.c elf64-aarch64.c \
|
||||
elf32-ia64.c elf64-ia64.c \
|
||||
elf32-loongarch.c elf64-loongarch.c \
|
||||
elf32-riscv.c elf64-riscv.c \
|
||||
peigen.c pepigen.c pex64igen.c
|
||||
|
||||
@ -1109,7 +1116,7 @@ SOURCE_HFILES = \
|
||||
elf-bfd.h elfcode.h elfcore.h elf-hppa.h elf-linker-x86.h \
|
||||
elf-linux-core.h elf-nacl.h elf-s390.h elf-vxworks.h \
|
||||
elfxx-aarch64.h elfxx-ia64.h elfxx-mips.h elfxx-riscv.h \
|
||||
elfxx-sparc.h elfxx-tilegx.h elfxx-x86.h \
|
||||
elfxx-sparc.h elfxx-tilegx.h elfxx-x86.h elfxx-loongarch.h \
|
||||
genlink.h go32stub.h \
|
||||
libaout.h libbfd.h libcoff.h libecoff.h libhppa.h \
|
||||
libpei.h libxcoff.h \
|
||||
@ -1349,6 +1356,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-k1om.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-l1om.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@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m10300.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m32c.Plo@am__quote@
|
||||
@ -1442,6 +1450,7 @@ distclean-compile:
|
||||
@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-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@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-m32r.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-m68hc11.Plo@am__quote@
|
||||
@ -1492,6 +1501,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-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@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-nfp.Plo@am__quote@
|
||||
@ -1506,6 +1516,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-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@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-sparc.Plo@am__quote@
|
||||
@ -1972,6 +1983,14 @@ elf64-ia64.c : elfnn-ia64.c
|
||||
echo "#line 1 \"elfnn-ia64.c\"" > $@
|
||||
$(SED) -e s/NN/64/g < $< >> $@
|
||||
|
||||
elf32-loongarch.c : elfnn-loongarch.c
|
||||
echo "#line 1 \"elfnn-loongarch.c\"" > $@
|
||||
$(SED) -e s/NN/32/g < $< >> $@
|
||||
|
||||
elf64-loongarch.c : elfnn-loongarch.c
|
||||
echo "#line 1 \"elfnn-loongarch.c\"" > $@
|
||||
$(SED) -e s/NN/64/g < $< >> $@
|
||||
|
||||
elf32-riscv.c : elfnn-riscv.c
|
||||
echo "#line 1 \"elfnn-riscv.c\"" > $@
|
||||
$(SED) -e s/NN/32/g < $< >> $@
|
||||
|
@ -555,6 +555,9 @@ DESCRIPTION
|
||||
.#define bfd_mach_ck807 6
|
||||
.#define bfd_mach_ck810 7
|
||||
.#define bfd_mach_ck860 8
|
||||
. bfd_arch_loongarch, {* LoongArch *}
|
||||
.#define bfd_mach_loongarch32 1
|
||||
.#define bfd_mach_loongarch64 2
|
||||
. bfd_arch_last
|
||||
. };
|
||||
*/
|
||||
@ -635,6 +638,7 @@ extern const bfd_arch_info_type bfd_iq2000_arch;
|
||||
extern const bfd_arch_info_type bfd_k1om_arch;
|
||||
extern const bfd_arch_info_type bfd_l1om_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;
|
||||
extern const bfd_arch_info_type bfd_m32r_arch;
|
||||
extern const bfd_arch_info_type bfd_m68hc11_arch;
|
||||
@ -724,6 +728,7 @@ static const bfd_arch_info_type * const bfd_archures_list[] =
|
||||
&bfd_k1om_arch,
|
||||
&bfd_l1om_arch,
|
||||
&bfd_lm32_arch,
|
||||
&bfd_loongarch_arch,
|
||||
&bfd_m32c_arch,
|
||||
&bfd_m32r_arch,
|
||||
&bfd_m68hc11_arch,
|
||||
|
@ -1937,6 +1937,9 @@ enum bfd_architecture
|
||||
#define bfd_mach_ck807 6
|
||||
#define bfd_mach_ck810 7
|
||||
#define bfd_mach_ck860 8
|
||||
bfd_arch_loongarch, /* LoongArch */
|
||||
#define bfd_mach_loongarch32 1
|
||||
#define bfd_mach_loongarch64 2
|
||||
bfd_arch_last
|
||||
};
|
||||
|
||||
@ -6268,6 +6271,51 @@ assembler and not (currently) written to any object files. */
|
||||
|
||||
/* S12Z relocations. */
|
||||
BFD_RELOC_S12Z_OPR,
|
||||
|
||||
/* LARCH relocations. */
|
||||
BFD_RELOC_LARCH_TLS_DTPMOD32,
|
||||
BFD_RELOC_LARCH_TLS_DTPREL32,
|
||||
BFD_RELOC_LARCH_TLS_DTPMOD64,
|
||||
BFD_RELOC_LARCH_TLS_DTPREL64,
|
||||
BFD_RELOC_LARCH_TLS_TPREL32,
|
||||
BFD_RELOC_LARCH_TLS_TPREL64,
|
||||
BFD_RELOC_LARCH_MARK_LA,
|
||||
BFD_RELOC_LARCH_MARK_PCREL,
|
||||
BFD_RELOC_LARCH_SOP_PUSH_PCREL,
|
||||
BFD_RELOC_LARCH_SOP_PUSH_ABSOLUTE,
|
||||
BFD_RELOC_LARCH_SOP_PUSH_DUP,
|
||||
BFD_RELOC_LARCH_SOP_PUSH_GPREL,
|
||||
BFD_RELOC_LARCH_SOP_PUSH_TLS_TPREL,
|
||||
BFD_RELOC_LARCH_SOP_PUSH_TLS_GOT,
|
||||
BFD_RELOC_LARCH_SOP_PUSH_TLS_GD,
|
||||
BFD_RELOC_LARCH_SOP_PUSH_PLT_PCREL,
|
||||
BFD_RELOC_LARCH_SOP_ASSERT,
|
||||
BFD_RELOC_LARCH_SOP_NOT,
|
||||
BFD_RELOC_LARCH_SOP_SUB,
|
||||
BFD_RELOC_LARCH_SOP_SL,
|
||||
BFD_RELOC_LARCH_SOP_SR,
|
||||
BFD_RELOC_LARCH_SOP_ADD,
|
||||
BFD_RELOC_LARCH_SOP_AND,
|
||||
BFD_RELOC_LARCH_SOP_IF_ELSE,
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_10_5,
|
||||
BFD_RELOC_LARCH_SOP_POP_32_U_10_12,
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_10_12,
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_10_16,
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_10_16_S2,
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_5_20,
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_0_5_10_16_S2,
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_0_10_10_16_S2,
|
||||
BFD_RELOC_LARCH_SOP_POP_32_U,
|
||||
BFD_RELOC_LARCH_ADD8,
|
||||
BFD_RELOC_LARCH_ADD16,
|
||||
BFD_RELOC_LARCH_ADD24,
|
||||
BFD_RELOC_LARCH_ADD32,
|
||||
BFD_RELOC_LARCH_ADD64,
|
||||
BFD_RELOC_LARCH_SUB8,
|
||||
BFD_RELOC_LARCH_SUB16,
|
||||
BFD_RELOC_LARCH_SUB24,
|
||||
BFD_RELOC_LARCH_SUB32,
|
||||
BFD_RELOC_LARCH_SUB64,
|
||||
BFD_RELOC_UNUSED };
|
||||
|
||||
typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
|
||||
|
@ -197,6 +197,7 @@ hppa*) targ_archs=bfd_hppa_arch ;;
|
||||
i[3-7]86) targ_archs=bfd_i386_arch ;;
|
||||
ia16) targ_archs=bfd_i386_arch ;;
|
||||
lm32) targ_archs=bfd_lm32_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" ;;
|
||||
m68*) targ_archs=bfd_m68k_arch ;;
|
||||
@ -1458,6 +1459,20 @@ case "${targ}" in
|
||||
targ_underscore=yes
|
||||
;;
|
||||
|
||||
#ifdef BFD64
|
||||
loongarch32-*)
|
||||
targ_defvec=loongarch_elf32_vec
|
||||
targ_selvecs="loongarch_elf32_vec"
|
||||
want64=false
|
||||
;;
|
||||
|
||||
loongarch64-*)
|
||||
targ_defvec=loongarch_elf64_vec
|
||||
targ_selvecs="loongarch_elf32_vec loongarch_elf64_vec"
|
||||
want64=true
|
||||
;;
|
||||
#endif
|
||||
|
||||
# END OF targmatch.h
|
||||
bpf-*-*)
|
||||
echo "*** Configuration $targ is not fully supported." >&2
|
||||
|
2
bfd/configure
vendored
2
bfd/configure
vendored
@ -13348,6 +13348,8 @@ do
|
||||
l1om_elf64_fbsd_vec) tb="$tb elf64-x86-64.lo elfxx-x86.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
|
||||
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" ;;
|
||||
loongarch_elf64_vec) tb="$tb elf64-loongarch.lo elf64.lo elfxx-loongarch.lo elf32.lo elf-ifunc.lo $elf"; target_size=64 ;;
|
||||
m32c_elf32_vec) tb="$tb elf32-m32c.lo elf32.lo $elf" ;;
|
||||
m32r_elf32_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
|
||||
m32r_elf32_le_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
|
||||
|
@ -527,6 +527,8 @@ do
|
||||
l1om_elf64_fbsd_vec) tb="$tb elf64-x86-64.lo elfxx-x86.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
|
||||
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" ;;
|
||||
loongarch_elf64_vec) tb="$tb elf64-loongarch.lo elf64.lo elfxx-loongarch.lo elf32.lo elf-ifunc.lo $elf"; target_size=64 ;;
|
||||
m32c_elf32_vec) tb="$tb elf32-m32c.lo elf32.lo $elf" ;;
|
||||
m32r_elf32_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
|
||||
m32r_elf32_le_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
|
||||
|
61
bfd/cpu-loongarch.c
Normal file
61
bfd/cpu-loongarch.c
Normal file
@ -0,0 +1,61 @@
|
||||
/* BFD support for LoongArch.
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
Contributed by Loongson Ltd.
|
||||
|
||||
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"
|
||||
|
||||
static const bfd_arch_info_type bfd_loongarch32_arch =
|
||||
{
|
||||
32, /* 32 bits in a word. */
|
||||
32, /* 64 bits in an address. */
|
||||
8, /* 8 bits in a byte. */
|
||||
bfd_arch_loongarch, /* Architecture. */
|
||||
bfd_mach_loongarch32, /* Machine number - 0 for now. */
|
||||
"loongarch32", /* Architecture name. */
|
||||
"Loongarch32", /* Printable name. */
|
||||
3, /* Section align power. */
|
||||
false, /* This is the default architecture. */
|
||||
bfd_default_compatible, /* Architecture comparison function. */
|
||||
bfd_default_scan, /* String to architecture conversion. */
|
||||
bfd_arch_default_fill, /* Default fill. */
|
||||
NULL, /* Next in list. */
|
||||
0,
|
||||
};
|
||||
|
||||
const bfd_arch_info_type bfd_loongarch_arch =
|
||||
{
|
||||
32, /* 32 bits in a word. */
|
||||
64, /* 64 bits in an address. */
|
||||
8, /* 8 bits in a byte. */
|
||||
bfd_arch_loongarch, /* Architecture. */
|
||||
/* Machine number of LoongArch64 is larger
|
||||
* so that LoongArch64 is compatible to LoongArch32. */
|
||||
bfd_mach_loongarch64,
|
||||
"loongarch64", /* Architecture name. */
|
||||
"Loongarch64", /* Printable name. */
|
||||
3, /* Section align power. */
|
||||
true, /* This is the default architecture. */
|
||||
bfd_default_compatible, /* Architecture comparison function. */
|
||||
bfd_default_scan, /* String to architecture conversion. */
|
||||
bfd_arch_default_fill, /* Default fill. */
|
||||
&bfd_loongarch32_arch, /* Next in list. */
|
||||
0,
|
||||
};
|
@ -508,6 +508,7 @@ enum elf_target_id
|
||||
I386_ELF_DATA,
|
||||
IA64_ELF_DATA,
|
||||
LM32_ELF_DATA,
|
||||
LARCH_ELF_DATA,
|
||||
M32R_ELF_DATA,
|
||||
M68HC11_ELF_DATA,
|
||||
M68K_ELF_DATA,
|
||||
@ -2849,6 +2850,14 @@ extern char *elfcore_write_register_note
|
||||
(bfd *, char *, int *, const char *, const void *, int);
|
||||
extern char *elfcore_write_file_note
|
||||
(bfd *, char *, int *, const void*, int);
|
||||
extern char *elfcore_write_loongarch_cpucfg
|
||||
(bfd *, char *, int *, const void*, int);
|
||||
extern char *elfcore_write_loongarch_lbt
|
||||
(bfd *, char *, int *, const void*, int);
|
||||
extern char *elfcore_write_loongarch_lsx
|
||||
(bfd *, char *, int *, const void*, int);
|
||||
extern char *elfcore_write_loongarch_lasx
|
||||
(bfd *, char *, int *, const void*, int);
|
||||
|
||||
/* Internal structure which holds information to be included in the
|
||||
PRPSINFO section of Linux core files.
|
||||
|
109
bfd/elf.c
109
bfd/elf.c
@ -9951,6 +9951,30 @@ elfcore_grok_gdb_tdesc (bfd *abfd, Elf_Internal_Note *note)
|
||||
return elfcore_make_note_pseudosection (abfd, ".gdb-tdesc", note);
|
||||
}
|
||||
|
||||
static bool
|
||||
elfcore_grok_loongarch_cpucfg (bfd *abfd, Elf_Internal_Note *note)
|
||||
{
|
||||
return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-cpucfg", note);
|
||||
}
|
||||
|
||||
static bool
|
||||
elfcore_grok_loongarch_lbt (bfd *abfd, Elf_Internal_Note *note)
|
||||
{
|
||||
return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-lbt", note);
|
||||
}
|
||||
|
||||
static bool
|
||||
elfcore_grok_loongarch_lsx (bfd *abfd, Elf_Internal_Note *note)
|
||||
{
|
||||
return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-lsx", note);
|
||||
}
|
||||
|
||||
static bool
|
||||
elfcore_grok_loongarch_lasx (bfd *abfd, Elf_Internal_Note *note)
|
||||
{
|
||||
return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-lasx", note);
|
||||
}
|
||||
|
||||
#if defined (HAVE_PRPSINFO_T)
|
||||
typedef prpsinfo_t elfcore_psinfo_t;
|
||||
#if defined (HAVE_PRPSINFO32_T) /* Sparc64 cross Sparc32 */
|
||||
@ -10630,6 +10654,34 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
|
||||
else
|
||||
return true;
|
||||
|
||||
case NT_LARCH_CPUCFG:
|
||||
if (note->namesz == 6
|
||||
&& strcmp (note->namedata, "LINUX") == 0)
|
||||
return elfcore_grok_loongarch_cpucfg (abfd, note);
|
||||
else
|
||||
return true;
|
||||
|
||||
case NT_LARCH_LBT:
|
||||
if (note->namesz == 6
|
||||
&& strcmp (note->namedata, "LINUX") == 0)
|
||||
return elfcore_grok_loongarch_lbt (abfd, note);
|
||||
else
|
||||
return true;
|
||||
|
||||
case NT_LARCH_LSX:
|
||||
if (note->namesz == 6
|
||||
&& strcmp (note->namedata, "LINUX") == 0)
|
||||
return elfcore_grok_loongarch_lsx (abfd, note);
|
||||
else
|
||||
return true;
|
||||
|
||||
case NT_LARCH_LASX:
|
||||
if (note->namesz == 6
|
||||
&& strcmp (note->namedata, "LINUX") == 0)
|
||||
return elfcore_grok_loongarch_lasx (abfd, note);
|
||||
else
|
||||
return true;
|
||||
|
||||
case NT_PRPSINFO:
|
||||
case NT_PSINFO:
|
||||
if (bed->elf_backend_grok_psinfo)
|
||||
@ -12210,6 +12262,55 @@ elfcore_write_arc_v2 (bfd *abfd,
|
||||
note_name, NT_ARC_V2, arc_v2, size);
|
||||
}
|
||||
|
||||
char *
|
||||
elfcore_write_loongarch_cpucfg (bfd *abfd,
|
||||
char *buf,
|
||||
int *bufsiz,
|
||||
const void *loongarch_cpucfg,
|
||||
int size)
|
||||
{
|
||||
char *note_name = "LINUX";
|
||||
return elfcore_write_note (abfd, buf, bufsiz,
|
||||
note_name, NT_LARCH_CPUCFG,
|
||||
loongarch_cpucfg, size);
|
||||
}
|
||||
|
||||
char *
|
||||
elfcore_write_loongarch_lbt (bfd *abfd,
|
||||
char *buf,
|
||||
int *bufsiz,
|
||||
const void *loongarch_lbt,
|
||||
int size)
|
||||
{
|
||||
char *note_name = "LINUX";
|
||||
return elfcore_write_note (abfd, buf, bufsiz,
|
||||
note_name, NT_LARCH_LBT, loongarch_lbt, size);
|
||||
}
|
||||
|
||||
char *
|
||||
elfcore_write_loongarch_lsx (bfd *abfd,
|
||||
char *buf,
|
||||
int *bufsiz,
|
||||
const void *loongarch_lsx,
|
||||
int size)
|
||||
{
|
||||
char *note_name = "LINUX";
|
||||
return elfcore_write_note (abfd, buf, bufsiz,
|
||||
note_name, NT_LARCH_LSX, loongarch_lsx, size);
|
||||
}
|
||||
|
||||
char *
|
||||
elfcore_write_loongarch_lasx (bfd *abfd,
|
||||
char *buf,
|
||||
int *bufsiz,
|
||||
const void *loongarch_lasx,
|
||||
int size)
|
||||
{
|
||||
char *note_name = "LINUX";
|
||||
return elfcore_write_note (abfd, buf, bufsiz,
|
||||
note_name, NT_LARCH_LASX, loongarch_lasx, size);
|
||||
}
|
||||
|
||||
/* Write the buffer of csr values in CSRS (length SIZE) into the note
|
||||
buffer BUF and update *BUFSIZ. ABFD is the bfd the note is being
|
||||
written into. Return a pointer to the new start of the note buffer, to
|
||||
@ -12334,6 +12435,14 @@ elfcore_write_register_note (bfd *abfd,
|
||||
return elfcore_write_gdb_tdesc (abfd, buf, bufsiz, data, size);
|
||||
if (strcmp (section, ".reg-riscv-csr") == 0)
|
||||
return elfcore_write_riscv_csr (abfd, buf, bufsiz, data, size);
|
||||
if (strcmp (section, ".reg-loongarch-cpucfg") == 0)
|
||||
return elfcore_write_loongarch_cpucfg (abfd, buf, bufsiz, data, size);
|
||||
if (strcmp (section, ".reg-loongarch-lbt") == 0)
|
||||
return elfcore_write_loongarch_lbt (abfd, buf, bufsiz, data, size);
|
||||
if (strcmp (section, ".reg-loongarch-lsx") == 0)
|
||||
return elfcore_write_loongarch_lsx (abfd, buf, bufsiz, data, size);
|
||||
if (strcmp (section, ".reg-loongarch-lasx") == 0)
|
||||
return elfcore_write_loongarch_lasx (abfd, buf, bufsiz, data, size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
3265
bfd/elfnn-loongarch.c
Normal file
3265
bfd/elfnn-loongarch.c
Normal file
File diff suppressed because it is too large
Load Diff
661
bfd/elfxx-loongarch.c
Normal file
661
bfd/elfxx-loongarch.c
Normal file
@ -0,0 +1,661 @@
|
||||
/* LoongArch-specific support for ELF.
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
Contributed by Loongson Ltd.
|
||||
|
||||
Based on RISC-V target.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING3. If not,
|
||||
see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "sysdep.h"
|
||||
#include "bfd.h"
|
||||
#include "libbfd.h"
|
||||
#include "elf-bfd.h"
|
||||
#include "elf/loongarch.h"
|
||||
#include "elfxx-loongarch.h"
|
||||
|
||||
#define ALL_ONES (~ (bfd_vma) 0)
|
||||
|
||||
/* This does not include any relocation information, but should be
|
||||
good enough for GDB or objdump to read the file. */
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
#define LOONGARCH_HOWTO(r_name) \
|
||||
HOWTO (R_LARCH_##r_name, 0, 2, 32, false, 0, complain_overflow_signed, \
|
||||
bfd_elf_generic_reloc, "R_LARCH_" #r_name, false, 0, 0xffffffff, false)
|
||||
|
||||
/* No relocation. */
|
||||
HOWTO (R_LARCH_NONE, /* type (0). */
|
||||
0, /* rightshift */
|
||||
3, /* size */
|
||||
0, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_NONE", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
/* 32 bit relocation. */
|
||||
HOWTO (R_LARCH_32, /* type (1). */
|
||||
0, /* rightshift */
|
||||
2, /* size */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_32", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
/* 64 bit relocation. */
|
||||
HOWTO (R_LARCH_64, /* type (2). */
|
||||
0, /* rightshift */
|
||||
4, /* size */
|
||||
64, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_64", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
ALL_ONES, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LARCH_RELATIVE, /* type (3). */
|
||||
0, /* rightshift */
|
||||
2, /* size */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_RELATIVE", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LARCH_COPY, /* type (4). */
|
||||
0, /* rightshift */
|
||||
0, /* this one is variable size */
|
||||
0, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_COPY", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LARCH_JUMP_SLOT, /* type (5). */
|
||||
0, /* rightshift */
|
||||
4, /* size */
|
||||
64, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_JUMP_SLOT", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
/* Dynamic TLS relocations. */
|
||||
HOWTO (R_LARCH_TLS_DTPMOD32, /* type (6). */
|
||||
0, /* rightshift */
|
||||
2, /* size */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_TLS_DTPMOD32", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LARCH_TLS_DTPMOD64, /* type (7). */
|
||||
0, /* rightshift */
|
||||
4, /* size */
|
||||
64, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_TLS_DTPMOD64", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
ALL_ONES, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LARCH_TLS_DTPREL32, /* type (8). */
|
||||
0, /* rightshift */
|
||||
2, /* size */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_TLS_DTPREL32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LARCH_TLS_DTPREL64, /* type (9). */
|
||||
0, /* rightshift */
|
||||
4, /* size */
|
||||
64, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_TLS_DTPREL64", /* name */
|
||||
true, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
ALL_ONES, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LARCH_TLS_TPREL32, /* type (10). */
|
||||
0, /* rightshift */
|
||||
2, /* size */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_TLS_TPREL32", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LARCH_TLS_TPREL64, /* type (11). */
|
||||
0, /* rightshift */
|
||||
4, /* size */
|
||||
64, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_TLS_TPREL64", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
ALL_ONES, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LARCH_IRELATIVE, /* type (12). */
|
||||
0, /* rightshift */
|
||||
2, /* size */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_LARCH_IRELATIVE", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
|
||||
EMPTY_HOWTO(13),
|
||||
EMPTY_HOWTO(14),
|
||||
EMPTY_HOWTO(15),
|
||||
EMPTY_HOWTO(16),
|
||||
EMPTY_HOWTO(17),
|
||||
EMPTY_HOWTO(18),
|
||||
EMPTY_HOWTO(19),
|
||||
|
||||
HOWTO (R_LARCH_MARK_LA, /* type (20). */
|
||||
0, /* rightshift. */
|
||||
3, /* size. */
|
||||
0, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_MARK_LA", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask. */
|
||||
0, /* dst_mask. */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_MARK_PCREL, /* type (21). */
|
||||
0, /* rightshift. */
|
||||
3, /* size. */
|
||||
0, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_MARK_PCREL", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask. */
|
||||
0, /* dst_mask. */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SOP_PUSH_PCREL, /* type (22). */
|
||||
2, /* rightshift. */
|
||||
2, /* size. */
|
||||
32, /* bitsize. */
|
||||
true /* FIXME: somewhat use this. */, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SOP_PUSH_PCREL", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0x03ffffff, /* src_mask. */
|
||||
0x03ffffff, /* dst_mask. */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
/* type 23-37. */
|
||||
LOONGARCH_HOWTO (SOP_PUSH_ABSOLUTE),
|
||||
LOONGARCH_HOWTO (SOP_PUSH_DUP),
|
||||
LOONGARCH_HOWTO (SOP_PUSH_GPREL),
|
||||
LOONGARCH_HOWTO (SOP_PUSH_TLS_TPREL),
|
||||
LOONGARCH_HOWTO (SOP_PUSH_TLS_GOT),
|
||||
LOONGARCH_HOWTO (SOP_PUSH_TLS_GD),
|
||||
LOONGARCH_HOWTO (SOP_PUSH_PLT_PCREL),
|
||||
LOONGARCH_HOWTO (SOP_ASSERT),
|
||||
LOONGARCH_HOWTO (SOP_NOT),
|
||||
LOONGARCH_HOWTO (SOP_SUB),
|
||||
LOONGARCH_HOWTO (SOP_SL),
|
||||
LOONGARCH_HOWTO (SOP_SR),
|
||||
LOONGARCH_HOWTO (SOP_ADD),
|
||||
LOONGARCH_HOWTO (SOP_AND),
|
||||
LOONGARCH_HOWTO (SOP_IF_ELSE),
|
||||
|
||||
HOWTO (R_LARCH_SOP_POP_32_S_10_5, /* type (38). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
5, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
10, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SOP_POP_32_S_10_5", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0x7c00, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SOP_POP_32_U_10_12, /* type (39). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
12, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
10, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SOP_POP_32_U_10_12", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0x3ffc00, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SOP_POP_32_S_10_12, /* type (40). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
12, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
10, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SOP_POP_32_S_10_12", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0x3ffc00, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SOP_POP_32_S_10_16, /* type (41). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
16, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
10, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SOP_POP_32_S_10_16", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0x3fffc00, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SOP_POP_32_S_10_16_S2, /* type (42). */
|
||||
2, /* rightshift. */
|
||||
2, /* size. */
|
||||
16, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
10, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SOP_POP_32_S_10_16_S2", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0x3fffc00, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SOP_POP_32_S_5_20, /* type (43). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
20, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
5, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SOP_POP_32_S_5_20", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0x1fffe0, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SOP_POP_32_S_0_5_10_16_S2, /* type (44). */
|
||||
2, /* rightshift. */
|
||||
2, /* size. */
|
||||
21, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SOP_POP_32_S_0_5_10_16_S2", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0xfc0003e0, /* src_mask */
|
||||
0xfc0003e0, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SOP_POP_32_S_0_10_10_16_S2, /* type (45). */
|
||||
2, /* rightshift. */
|
||||
2, /* size. */
|
||||
26, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SOP_POP_32_S_0_10_10_16_S2", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0xfc000000, /* src_mask */
|
||||
0xfc000000, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SOP_POP_32_U, /* type (46). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
32, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SOP_POP_32_S_U", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_ADD8, /* type (47). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
8, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_ADD8", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_ADD16, /* type (48). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
16, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_ADD16", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_ADD24, /* type (49). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
24, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_ADD24", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_ADD32, /* type (50). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
32, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_ADD32", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_ADD64, /* type (51). */
|
||||
0, /* rightshift. */
|
||||
4, /* size. */
|
||||
64, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_ADD64", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
ALL_ONES, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SUB8, /* type (52). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
8, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SUB8", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SUB16, /* type (53). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
16, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SUB16", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SUB24, /* type (54). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
24, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SUB24", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SUB32, /* type (55). */
|
||||
0, /* rightshift. */
|
||||
2, /* size. */
|
||||
32, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SUB32", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
HOWTO (R_LARCH_SUB64, /* type (56). */
|
||||
0, /* rightshift. */
|
||||
4, /* size. */
|
||||
64, /* bitsize. */
|
||||
false, /* pc_relative. */
|
||||
0, /* bitpos. */
|
||||
complain_overflow_signed, /* complain_on_overflow. */
|
||||
bfd_elf_generic_reloc, /* special_function. */
|
||||
"R_LARCH_SUB64", /* name. */
|
||||
false, /* partial_inplace. */
|
||||
0, /* src_mask */
|
||||
ALL_ONES, /* dst_mask */
|
||||
false), /* pcrel_offset. */
|
||||
|
||||
};
|
||||
|
||||
struct elf_reloc_map
|
||||
{
|
||||
bfd_reloc_code_real_type bfd_val;
|
||||
enum elf_loongarch_reloc_type elf_val;
|
||||
};
|
||||
|
||||
static const struct elf_reloc_map larch_reloc_map[] =
|
||||
{
|
||||
{ BFD_RELOC_NONE, R_LARCH_NONE },
|
||||
{ BFD_RELOC_32, R_LARCH_32 },
|
||||
{ BFD_RELOC_64, R_LARCH_64 },
|
||||
|
||||
#define LOONGARCH_reloc_map(r_name) \
|
||||
{ \
|
||||
BFD_RELOC_LARCH_##r_name, R_LARCH_##r_name \
|
||||
}
|
||||
LOONGARCH_reloc_map (TLS_DTPMOD32),
|
||||
LOONGARCH_reloc_map (TLS_DTPMOD64),
|
||||
LOONGARCH_reloc_map (TLS_DTPREL32),
|
||||
LOONGARCH_reloc_map (TLS_DTPREL64),
|
||||
LOONGARCH_reloc_map (TLS_TPREL32),
|
||||
LOONGARCH_reloc_map (TLS_TPREL64),
|
||||
|
||||
LOONGARCH_reloc_map (MARK_LA),
|
||||
LOONGARCH_reloc_map (MARK_PCREL),
|
||||
LOONGARCH_reloc_map (SOP_PUSH_PCREL),
|
||||
LOONGARCH_reloc_map (SOP_PUSH_ABSOLUTE),
|
||||
LOONGARCH_reloc_map (SOP_PUSH_DUP),
|
||||
LOONGARCH_reloc_map (SOP_PUSH_GPREL),
|
||||
LOONGARCH_reloc_map (SOP_PUSH_TLS_TPREL),
|
||||
LOONGARCH_reloc_map (SOP_PUSH_TLS_GOT),
|
||||
LOONGARCH_reloc_map (SOP_PUSH_TLS_GD),
|
||||
LOONGARCH_reloc_map (SOP_PUSH_PLT_PCREL),
|
||||
LOONGARCH_reloc_map (SOP_ASSERT),
|
||||
LOONGARCH_reloc_map (SOP_NOT),
|
||||
LOONGARCH_reloc_map (SOP_SUB),
|
||||
LOONGARCH_reloc_map (SOP_SL),
|
||||
LOONGARCH_reloc_map (SOP_SR),
|
||||
LOONGARCH_reloc_map (SOP_ADD),
|
||||
LOONGARCH_reloc_map (SOP_AND),
|
||||
LOONGARCH_reloc_map (SOP_IF_ELSE),
|
||||
LOONGARCH_reloc_map (SOP_POP_32_S_10_5),
|
||||
LOONGARCH_reloc_map (SOP_POP_32_U_10_12),
|
||||
LOONGARCH_reloc_map (SOP_POP_32_S_10_12),
|
||||
LOONGARCH_reloc_map (SOP_POP_32_S_10_16),
|
||||
LOONGARCH_reloc_map (SOP_POP_32_S_10_16_S2),
|
||||
LOONGARCH_reloc_map (SOP_POP_32_S_5_20),
|
||||
LOONGARCH_reloc_map (SOP_POP_32_S_0_5_10_16_S2),
|
||||
LOONGARCH_reloc_map (SOP_POP_32_S_0_10_10_16_S2),
|
||||
LOONGARCH_reloc_map (SOP_POP_32_U),
|
||||
LOONGARCH_reloc_map (ADD8),
|
||||
LOONGARCH_reloc_map (ADD16),
|
||||
LOONGARCH_reloc_map (ADD24),
|
||||
LOONGARCH_reloc_map (ADD32),
|
||||
LOONGARCH_reloc_map (ADD64),
|
||||
LOONGARCH_reloc_map (SUB8),
|
||||
LOONGARCH_reloc_map (SUB16),
|
||||
LOONGARCH_reloc_map (SUB24),
|
||||
LOONGARCH_reloc_map (SUB32),
|
||||
LOONGARCH_reloc_map (SUB64),
|
||||
};
|
||||
|
||||
reloc_howto_type *
|
||||
loongarch_elf_rtype_to_howto (bfd *abfd, unsigned int r_type)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < ARRAY_SIZE (howto_table); i++)
|
||||
if (howto_table[i].type == r_type)
|
||||
return &howto_table[i];
|
||||
|
||||
(*_bfd_error_handler) (_("%pB: unsupported relocation type %#x"),
|
||||
abfd, r_type);
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
reloc_howto_type *
|
||||
loongarch_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
bfd_reloc_code_real_type code)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < ARRAY_SIZE (larch_reloc_map); i++)
|
||||
if (larch_reloc_map[i].bfd_val == code)
|
||||
return loongarch_elf_rtype_to_howto (abfd,
|
||||
(int) larch_reloc_map[i].elf_val);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
reloc_howto_type *
|
||||
loongarch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (howto_table); i++)
|
||||
if (howto_table[i].name && strcasecmp (howto_table[i].name, r_name) == 0)
|
||||
return &howto_table[i];
|
||||
|
||||
return NULL;
|
||||
}
|
31
bfd/elfxx-loongarch.h
Normal file
31
bfd/elfxx-loongarch.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* LoongArch-specific backend routines.
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
Contributed by Loongson Ltd.
|
||||
|
||||
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 "elf/common.h"
|
||||
#include "elf/internal.h"
|
||||
|
||||
extern reloc_howto_type *
|
||||
loongarch_elf_rtype_to_howto (bfd *abfd, unsigned int r_type);
|
||||
|
||||
extern reloc_howto_type *
|
||||
loongarch_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code);
|
||||
|
||||
extern reloc_howto_type *
|
||||
loongarch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name);
|
43
bfd/libbfd.h
43
bfd/libbfd.h
@ -3416,6 +3416,49 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
|
||||
"BFD_RELOC_CKCORE_PCREL_BLOOP_IMM4BY4",
|
||||
"BFD_RELOC_CKCORE_PCREL_BLOOP_IMM12BY4",
|
||||
"BFD_RELOC_S12Z_OPR",
|
||||
"BFD_RELOC_LARCH_TLS_DTPMOD32",
|
||||
"BFD_RELOC_LARCH_TLS_DTPREL32",
|
||||
"BFD_RELOC_LARCH_TLS_DTPMOD64",
|
||||
"BFD_RELOC_LARCH_TLS_DTPREL64",
|
||||
"BFD_RELOC_LARCH_TLS_TPREL32",
|
||||
"BFD_RELOC_LARCH_TLS_TPREL64",
|
||||
"BFD_RELOC_LARCH_MARK_LA",
|
||||
"BFD_RELOC_LARCH_MARK_PCREL",
|
||||
"BFD_RELOC_LARCH_SOP_PUSH_PCREL",
|
||||
"BFD_RELOC_LARCH_SOP_PUSH_ABSOLUTE",
|
||||
"BFD_RELOC_LARCH_SOP_PUSH_DUP",
|
||||
"BFD_RELOC_LARCH_SOP_PUSH_GPREL",
|
||||
"BFD_RELOC_LARCH_SOP_PUSH_TLS_TPREL",
|
||||
"BFD_RELOC_LARCH_SOP_PUSH_TLS_GOT",
|
||||
"BFD_RELOC_LARCH_SOP_PUSH_TLS_GD",
|
||||
"BFD_RELOC_LARCH_SOP_PUSH_PLT_PCREL",
|
||||
"BFD_RELOC_LARCH_SOP_ASSERT",
|
||||
"BFD_RELOC_LARCH_SOP_NOT",
|
||||
"BFD_RELOC_LARCH_SOP_SUB",
|
||||
"BFD_RELOC_LARCH_SOP_SL",
|
||||
"BFD_RELOC_LARCH_SOP_SR",
|
||||
"BFD_RELOC_LARCH_SOP_ADD",
|
||||
"BFD_RELOC_LARCH_SOP_AND",
|
||||
"BFD_RELOC_LARCH_SOP_IF_ELSE",
|
||||
"BFD_RELOC_LARCH_SOP_POP_32_S_10_5",
|
||||
"BFD_RELOC_LARCH_SOP_POP_32_U_10_12",
|
||||
"BFD_RELOC_LARCH_SOP_POP_32_S_10_12",
|
||||
"BFD_RELOC_LARCH_SOP_POP_32_S_10_16",
|
||||
"BFD_RELOC_LARCH_SOP_POP_32_S_10_16_S2",
|
||||
"BFD_RELOC_LARCH_SOP_POP_32_S_5_20",
|
||||
"BFD_RELOC_LARCH_SOP_POP_32_S_0_5_10_16_S2",
|
||||
"BFD_RELOC_LARCH_SOP_POP_32_S_0_10_10_16_S2",
|
||||
"BFD_RELOC_LARCH_SOP_POP_32_U",
|
||||
"BFD_RELOC_LARCH_ADD8",
|
||||
"BFD_RELOC_LARCH_ADD16",
|
||||
"BFD_RELOC_LARCH_ADD24",
|
||||
"BFD_RELOC_LARCH_ADD32",
|
||||
"BFD_RELOC_LARCH_ADD64",
|
||||
"BFD_RELOC_LARCH_SUB8",
|
||||
"BFD_RELOC_LARCH_SUB16",
|
||||
"BFD_RELOC_LARCH_SUB24",
|
||||
"BFD_RELOC_LARCH_SUB32",
|
||||
"BFD_RELOC_LARCH_SUB64",
|
||||
"@@overflow: BFD_RELOC_UNUSED@@",
|
||||
};
|
||||
#endif
|
||||
|
@ -1,10 +1,12 @@
|
||||
bfdver.h
|
||||
elf32-aarch64.c
|
||||
elf32-ia64.c
|
||||
elf32-loongarch.c
|
||||
elf32-riscv.c
|
||||
elf32-target.h
|
||||
elf64-aarch64.c
|
||||
elf64-ia64.c
|
||||
elf64-loongarch.c
|
||||
elf64-riscv.c
|
||||
elf64-target.h
|
||||
peigen.c
|
||||
|
@ -72,6 +72,7 @@ cpu-iq2000.c
|
||||
cpu-k1om.c
|
||||
cpu-l1om.c
|
||||
cpu-lm32.c
|
||||
cpu-loongarch.c
|
||||
cpu-m10200.c
|
||||
cpu-m10300.c
|
||||
cpu-m32c.c
|
||||
@ -262,6 +263,8 @@ elfxx-aarch64.c
|
||||
elfxx-aarch64.h
|
||||
elfxx-ia64.c
|
||||
elfxx-ia64.h
|
||||
elfxx-loongarch.c
|
||||
elfxx-loongarch.h
|
||||
elfxx-mips.c
|
||||
elfxx-mips.h
|
||||
elfxx-riscv.c
|
||||
|
89
bfd/reloc.c
89
bfd/reloc.c
@ -8171,6 +8171,95 @@ ENUM
|
||||
ENUMDOC
|
||||
S12Z relocations.
|
||||
|
||||
ENUM
|
||||
BFD_RELOC_LARCH_TLS_DTPMOD32
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_TLS_DTPREL32
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_TLS_DTPMOD64
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_TLS_DTPREL64
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_TLS_TPREL32
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_TLS_TPREL64
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_MARK_LA
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_MARK_PCREL
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_PUSH_PCREL
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_PUSH_ABSOLUTE
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_PUSH_DUP
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_PUSH_GPREL
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_PUSH_TLS_TPREL
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_PUSH_TLS_GOT
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_PUSH_TLS_GD
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_PUSH_PLT_PCREL
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_ASSERT
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_NOT
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_SUB
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_SL
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_SR
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_ADD
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_AND
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_IF_ELSE
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_10_5
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_POP_32_U_10_12
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_10_12
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_10_16
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_10_16_S2
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_5_20
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_0_5_10_16_S2
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_POP_32_S_0_10_10_16_S2
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SOP_POP_32_U
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_ADD8
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_ADD16
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_ADD24
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_ADD32
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_ADD64
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SUB8
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SUB16
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SUB24
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SUB32
|
||||
ENUMX
|
||||
BFD_RELOC_LARCH_SUB64
|
||||
ENUMDOC
|
||||
LARCH relocations.
|
||||
|
||||
ENDSENUM
|
||||
BFD_RELOC_UNUSED
|
||||
CODE_FRAGMENT
|
||||
|
@ -768,6 +768,8 @@ extern const bfd_target l1om_elf64_vec;
|
||||
extern const bfd_target l1om_elf64_fbsd_vec;
|
||||
extern const bfd_target lm32_elf32_vec;
|
||||
extern const bfd_target lm32_elf32_fdpic_vec;
|
||||
extern const bfd_target loongarch_elf64_vec;
|
||||
extern const bfd_target loongarch_elf32_vec;
|
||||
extern const bfd_target m32c_elf32_vec;
|
||||
extern const bfd_target m32r_elf32_vec;
|
||||
extern const bfd_target m32r_elf32_le_vec;
|
||||
@ -1359,6 +1361,12 @@ static const bfd_target * const _bfd_target_vector[] =
|
||||
&z80_elf32_vec,
|
||||
|
||||
&z8k_coff_vec,
|
||||
|
||||
#ifdef BFD64
|
||||
&loongarch_elf32_vec,
|
||||
&loongarch_elf64_vec,
|
||||
#endif
|
||||
|
||||
#endif /* not SELECT_VECS */
|
||||
|
||||
/* Always support S-records, for convenience. */
|
||||
|
@ -686,8 +686,18 @@
|
||||
/* note name must be "LINUX". */
|
||||
#define NT_ARC_V2 0x600 /* ARC HS accumulator/extra registers. */
|
||||
/* note name must be "LINUX". */
|
||||
#define NT_RISCV_CSR 0x900 /* RISC-V Control and Status Registers */
|
||||
#define NT_LARCH_CPUCFG 0xa00 /* LoongArch CPU config registers */
|
||||
/* note name must be "LINUX". */
|
||||
#define NT_LARCH_CSR 0xa01 /* LoongArch Control State Registers */
|
||||
/* note name must be "LINUX". */
|
||||
#define NT_LARCH_LSX 0xa02 /* LoongArch SIMD eXtension registers */
|
||||
/* note name must be "LINUX". */
|
||||
#define NT_LARCH_LASX 0xa03 /* LoongArch Advanced SIMD eXtension registers */
|
||||
/* note name must be "LINUX". */
|
||||
#define NT_LARCH_LBT 0xa04 /* LoongArch Binary Translation registers */
|
||||
/* note name must be "CORE". */
|
||||
#define NT_RISCV_CSR 0x900 /* RISC-V Control and Status Registers */
|
||||
/* note name must be "LINUX". */
|
||||
#define NT_SIGINFO 0x53494749 /* Fields of siginfo_t. */
|
||||
#define NT_FILE 0x46494c45 /* Description of mapped files. */
|
||||
|
||||
|
119
include/elf/loongarch.h
Normal file
119
include/elf/loongarch.h
Normal file
@ -0,0 +1,119 @@
|
||||
/* Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
Contributed by Loongson Ltd.
|
||||
|
||||
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_LOONGARCH_H
|
||||
#define _ELF_LOONGARCH_H
|
||||
|
||||
#include "elf/reloc-macros.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
START_RELOC_NUMBERS (elf_loongarch_reloc_type)
|
||||
/* Used by the dynamic linker. */
|
||||
RELOC_NUMBER (R_LARCH_NONE, 0)
|
||||
RELOC_NUMBER (R_LARCH_32, 1)
|
||||
RELOC_NUMBER (R_LARCH_64, 2)
|
||||
RELOC_NUMBER (R_LARCH_RELATIVE, 3)
|
||||
RELOC_NUMBER (R_LARCH_COPY, 4)
|
||||
RELOC_NUMBER (R_LARCH_JUMP_SLOT, 5)
|
||||
RELOC_NUMBER (R_LARCH_TLS_DTPMOD32, 6)
|
||||
RELOC_NUMBER (R_LARCH_TLS_DTPMOD64, 7)
|
||||
RELOC_NUMBER (R_LARCH_TLS_DTPREL32, 8)
|
||||
RELOC_NUMBER (R_LARCH_TLS_DTPREL64, 9)
|
||||
RELOC_NUMBER (R_LARCH_TLS_TPREL32, 10)
|
||||
RELOC_NUMBER (R_LARCH_TLS_TPREL64, 11)
|
||||
RELOC_NUMBER (R_LARCH_IRELATIVE, 12)
|
||||
|
||||
/* Reserved for future relocs that the dynamic linker must understand. */
|
||||
|
||||
/* Used by the static linker for relocating .text. */
|
||||
RELOC_NUMBER (R_LARCH_MARK_LA, 20)
|
||||
RELOC_NUMBER (R_LARCH_MARK_PCREL, 21)
|
||||
|
||||
RELOC_NUMBER (R_LARCH_SOP_PUSH_PCREL, 22)
|
||||
|
||||
RELOC_NUMBER (R_LARCH_SOP_PUSH_ABSOLUTE, 23)
|
||||
|
||||
RELOC_NUMBER (R_LARCH_SOP_PUSH_DUP, 24)
|
||||
RELOC_NUMBER (R_LARCH_SOP_PUSH_GPREL, 25)
|
||||
RELOC_NUMBER (R_LARCH_SOP_PUSH_TLS_TPREL, 26)
|
||||
RELOC_NUMBER (R_LARCH_SOP_PUSH_TLS_GOT, 27)
|
||||
RELOC_NUMBER (R_LARCH_SOP_PUSH_TLS_GD, 28)
|
||||
RELOC_NUMBER (R_LARCH_SOP_PUSH_PLT_PCREL, 29)
|
||||
|
||||
RELOC_NUMBER (R_LARCH_SOP_ASSERT, 30)
|
||||
RELOC_NUMBER (R_LARCH_SOP_NOT, 31)
|
||||
RELOC_NUMBER (R_LARCH_SOP_SUB, 32)
|
||||
RELOC_NUMBER (R_LARCH_SOP_SL, 33)
|
||||
RELOC_NUMBER (R_LARCH_SOP_SR, 34)
|
||||
RELOC_NUMBER (R_LARCH_SOP_ADD, 35)
|
||||
RELOC_NUMBER (R_LARCH_SOP_AND, 36)
|
||||
RELOC_NUMBER (R_LARCH_SOP_IF_ELSE, 37)
|
||||
RELOC_NUMBER (R_LARCH_SOP_POP_32_S_10_5, 38)
|
||||
RELOC_NUMBER (R_LARCH_SOP_POP_32_U_10_12, 39)
|
||||
RELOC_NUMBER (R_LARCH_SOP_POP_32_S_10_12, 40)
|
||||
RELOC_NUMBER (R_LARCH_SOP_POP_32_S_10_16, 41)
|
||||
RELOC_NUMBER (R_LARCH_SOP_POP_32_S_10_16_S2, 42)
|
||||
RELOC_NUMBER (R_LARCH_SOP_POP_32_S_5_20, 43)
|
||||
RELOC_NUMBER (R_LARCH_SOP_POP_32_S_0_5_10_16_S2, 44)
|
||||
RELOC_NUMBER (R_LARCH_SOP_POP_32_S_0_10_10_16_S2, 45)
|
||||
RELOC_NUMBER (R_LARCH_SOP_POP_32_U, 46)
|
||||
|
||||
/* Used by the static linker for relocating non .text. */
|
||||
RELOC_NUMBER (R_LARCH_ADD8, 47)
|
||||
RELOC_NUMBER (R_LARCH_ADD16, 48)
|
||||
RELOC_NUMBER (R_LARCH_ADD24, 49)
|
||||
RELOC_NUMBER (R_LARCH_ADD32, 50)
|
||||
RELOC_NUMBER (R_LARCH_ADD64, 51)
|
||||
RELOC_NUMBER (R_LARCH_SUB8, 52)
|
||||
RELOC_NUMBER (R_LARCH_SUB16, 53)
|
||||
RELOC_NUMBER (R_LARCH_SUB24, 54)
|
||||
RELOC_NUMBER (R_LARCH_SUB32, 55)
|
||||
RELOC_NUMBER (R_LARCH_SUB64, 56)
|
||||
|
||||
/* I don't know what it is. Existing in almost all other arch. */
|
||||
RELOC_NUMBER (R_LARCH_GNU_VTINHERIT, 57)
|
||||
RELOC_NUMBER (R_LARCH_GNU_VTENTRY, 58)
|
||||
|
||||
END_RELOC_NUMBERS (R_LARCH_count)
|
||||
|
||||
/* Processor specific flags for the ELF header e_flags field. */
|
||||
#define EF_LOONGARCH_ABI_ILP32 0b01
|
||||
#define EF_LOONGARCH_ABI_LP64 0b11
|
||||
#define EF_LOONGARCH_ABI_MASK 0b11
|
||||
|
||||
#define EF_LOONGARCH_FLOAT_ABI_SOFT 0b001100
|
||||
#define EF_LOONGARCH_FLOAT_ABI_SINGLE 0b001000
|
||||
#define EF_LOONGARCH_FLOAT_ABI_DOUBLE 0b000000
|
||||
#define EF_LOONGARCH_FLOAT_ABI_MASK 0b111100
|
||||
|
||||
#define EF_LOONGARCH_IS_LP64(abi) \
|
||||
((abi & EF_LOONGARCH_ABI_MASK) == EF_LOONGARCH_ABI_LP64)
|
||||
#define EF_LOONGARCH_IS_ILP32(abi) \
|
||||
((abi & EF_LOONGARCH_ABI_MASK) == EF_LOONGARCH_ABI_ILP32)
|
||||
|
||||
#define EF_LOONGARCH_IS_SOFT_FLOAT(abi) \
|
||||
((abi & EF_LOONGARCH_FLOAT_ABI_MASK) == EF_LOONGARCH_FLOAT_ABI_SOFT)
|
||||
#define EF_LOONGARCH_IS_SINGLE_FLOAT(abi) \
|
||||
((abi & EF_LOONGARCH_FLOAT_ABI_MASK) == EF_LOONGARCH_FLOAT_ABI_SINGLE)
|
||||
#define EF_LOONGARCH_IS_DOUBLE_FLOAT(abi) \
|
||||
((abi & EF_LOONGARCH_FLOAT_ABI_MASK) == EF_LOONGARCH_FLOAT_ABI_DOUBLE)
|
||||
|
||||
#define EF_LOONGARCH_ABI (EF_LOONGARCH_ABI_MASK | EF_LOONGARCH_FLOAT_ABI_MASK)
|
||||
|
||||
#endif /* _ELF_LOONGARCH_H */
|
Loading…
x
Reference in New Issue
Block a user