From 8fc206b2e22d215a0bb7c651c14ae73c7793f376 Mon Sep 17 00:00:00 2001 From: Liu Hanxu Date: Mon, 3 Mar 2025 13:35:52 +0800 Subject: [PATCH] Add support for SW64 --- gdb-14.1-add-support-for-SW64.patch | 33565 ++++++++++++++++++++++++++ gdb.spec | 10 +- 2 files changed, 33572 insertions(+), 3 deletions(-) create mode 100644 gdb-14.1-add-support-for-SW64.patch diff --git a/gdb-14.1-add-support-for-SW64.patch b/gdb-14.1-add-support-for-SW64.patch new file mode 100644 index 0000000..de72111 --- /dev/null +++ b/gdb-14.1-add-support-for-SW64.patch @@ -0,0 +1,33565 @@ +diff -Naur gdb-14.1-after-patch/bfd/archures.c gdb-14.1-sw64/bfd/archures.c +--- gdb-14.1-after-patch/bfd/archures.c 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/bfd/archures.c 2025-03-03 10:59:12.950000000 +0800 +@@ -303,6 +303,10 @@ + .#define bfd_mach_alpha_ev4 0x10 + .#define bfd_mach_alpha_ev5 0x20 + .#define bfd_mach_alpha_ev6 0x30 ++. bfd_arch_sw64, {* SW64 *} ++.#define bfd_mach_sw64 0x10 ++.#define bfd_mach_sw64_sw6b 0x20 ++.#define bfd_mach_sw64_sw8a 0x30 + . bfd_arch_arm, {* Advanced Risc Machines ARM. *} + .#define bfd_mach_arm_unknown 0 + .#define bfd_mach_arm_2 1 +@@ -629,6 +633,7 @@ + */ + + extern const bfd_arch_info_type bfd_aarch64_arch; ++extern const bfd_arch_info_type bfd_sw64_arch; + extern const bfd_arch_info_type bfd_alpha_arch; + extern const bfd_arch_info_type bfd_amdgcn_arch; + extern const bfd_arch_info_type bfd_arc_arch; +@@ -718,6 +723,7 @@ + SELECT_ARCHITECTURES, + #else + &bfd_aarch64_arch, ++ &bfd_sw64_arch, + &bfd_alpha_arch, + &bfd_amdgcn_arch, + &bfd_arc_arch, +diff -Naur gdb-14.1-after-patch/bfd/bfd-in2.h gdb-14.1-sw64/bfd/bfd-in2.h +--- gdb-14.1-after-patch/bfd/bfd-in2.h 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/bfd/bfd-in2.h 2025-03-03 10:59:12.950000000 +0800 +@@ -1555,6 +1555,10 @@ + #define bfd_mach_sh4a 0x4a + #define bfd_mach_sh4a_nofpu 0x4b + #define bfd_mach_sh4al_dsp 0x4d ++ bfd_arch_sw64, /* SW64 */ ++#define bfd_mach_sw64 0x10 ++#define bfd_mach_sw64_sw6b 0x20 ++#define bfd_mach_sw64_sw8a 0x30 + bfd_arch_alpha, /* Dec Alpha. */ + #define bfd_mach_alpha_ev4 0x10 + #define bfd_mach_alpha_ev5 0x20 +@@ -3564,6 +3568,108 @@ + BFD_RELOC_ALPHA_TPREL_LO16, + BFD_RELOC_ALPHA_TPREL16, + ++/* SW64 ECOFF and ELF relocations. Some of these treat the symbol or ++"addend" in some special way. ++For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when ++writing; when reading, it will be the absolute section symbol. The ++addend is the displacement in bytes of the "lda" instruction from ++the "ldah" instruction (which is at the address of this reloc). */ ++ BFD_RELOC_SW64_GPDISP_HI16, ++ ++/* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as ++with GPDISP_HI16 relocs. The addend is ignored when writing the ++relocations out, and is filled in with the file's GP value on ++reading, for convenience. */ ++ BFD_RELOC_SW64_GPDISP_LO16, ++ ++/* The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 ++relocation except that there is no accompanying GPDISP_LO16 ++relocation. */ ++ BFD_RELOC_SW64_GPDISP, ++ ++/* The SW64 LITERAL/LITUSE relocs are produced by a symbol reference; ++the assembler turns it into a LDQ instruction to load the address of ++the symbol, and then fills in a register in the real instruction. ++ ++The LITERAL reloc, at the LDQ instruction, refers to the .lita ++section symbol. The addend is ignored when writing, but is filled ++in with the file's GP value on reading, for convenience, as with the ++GPDISP_LO16 reloc. ++ ++The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. ++It should refer to the symbol to be referenced, as with 16_GOTOFF, ++but it generates output not based on the position within the .got ++section, but relative to the GP value chosen for the file during the ++final link stage. ++ ++The LITUSE reloc, on the instruction using the loaded address, gives ++information to the linker that it might be able to use to optimize ++away some literal section references. The symbol is ignored (read ++as the absolute section symbol), and the "addend" indicates the type ++of instruction using the register: ++1 - "memory" fmt insn ++2 - byte-manipulation (byte offset reg) ++3 - jsr (target of branch) */ ++ BFD_RELOC_SW64_LITERAL, ++ BFD_RELOC_SW64_ELF_LITERAL, ++ BFD_RELOC_SW64_ELF_LITERAL_GOT, ++ BFD_RELOC_SW64_LITUSE, ++ ++/* The HINT relocation indicates a value that should be filled into the ++"hint" field of a jmp/jsr/ret instruction, for possible branch- ++prediction logic which may be provided on some processors. */ ++ BFD_RELOC_SW64_HINT, ++ ++/* The LINKAGE relocation outputs a linkage pair in the object file, ++which is filled by the linker. */ ++ BFD_RELOC_SW64_LINKAGE, ++ ++/* The CODEADDR relocation outputs a STO_CA in the object file, ++which is filled by the linker. */ ++ BFD_RELOC_SW64_CODEADDR, ++ ++/* The GPREL_HI/LO relocations together form a 32-bit offset from the ++GP register. */ ++ BFD_RELOC_SW64_GPREL_HI16, ++ BFD_RELOC_SW64_GPREL_LO16, ++ ++/* Like BFD_RELOC_23_PCREL_S2, except that the source and target must ++share a common GP, and the target address is adjusted for ++STO_SW64_STD_GPLOAD. */ ++ BFD_RELOC_SW64_BRSGP, ++ ++/* The NOP relocation outputs a NOP if the longword displacement ++between two procedure entry points is < 2^21. */ ++ BFD_RELOC_SW64_NOP, ++ ++/* The BSR relocation outputs a BSR if the longword displacement ++between two procedure entry points is < 2^21. */ ++ BFD_RELOC_SW64_BSR, ++ ++/* The LDA relocation outputs a LDA if the longword displacement ++between two procedure entry points is < 2^16. */ ++ BFD_RELOC_SW64_LDA, ++ ++/* The BOH relocation outputs a BSR if the longword displacement ++between two procedure entry points is < 2^21, or else a hint. */ ++ BFD_RELOC_SW64_BOH, ++ ++/* SW64 thread-local storage relocations. */ ++ BFD_RELOC_SW64_TLSGD, ++ BFD_RELOC_SW64_TLSLDM, ++ BFD_RELOC_SW64_DTPMOD64, ++ BFD_RELOC_SW64_GOTDTPREL16, ++ BFD_RELOC_SW64_DTPREL64, ++ BFD_RELOC_SW64_DTPREL_HI16, ++ BFD_RELOC_SW64_DTPREL_LO16, ++ BFD_RELOC_SW64_DTPREL16, ++ BFD_RELOC_SW64_GOTTPREL16, ++ BFD_RELOC_SW64_TPREL64, ++ BFD_RELOC_SW64_TPREL_HI16, ++ BFD_RELOC_SW64_TPREL_LO16, ++ BFD_RELOC_SW64_TPREL16, ++ BFD_RELOC_SW64_BR26, ++ + /* The MIPS jump instruction. */ + BFD_RELOC_MIPS_JMP, + BFD_RELOC_MICROMIPS_JMP, +diff -Naur gdb-14.1-after-patch/bfd/coffcode.h gdb-14.1-sw64/bfd/coffcode.h +--- gdb-14.1-after-patch/bfd/coffcode.h 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/bfd/coffcode.h 2025-03-03 10:59:12.960000000 +0800 +@@ -2235,6 +2235,12 @@ + machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK; + break; + #endif ++#ifdef SW64MAGIC ++ case SW64MAGIC: ++ arch = bfd_arch_sw64; ++ machine = internal_f->f_flags & F_SW64_ARCHITECTURE_MASK; ++ break; ++#endif + #ifdef Z80MAGIC + case Z80MAGIC: + arch = bfd_arch_z80; +@@ -2806,6 +2812,12 @@ + return true; + #endif + ++#ifdef SW64MAGIC ++ case bfd_arch_sw64: ++ * magicp = SW64MAGIC; ++ return true; ++#endif ++ + #ifdef ARMMAGIC + case bfd_arch_arm: + #ifdef ARM_WINCE +@@ -4060,6 +4072,11 @@ + #define __A_MAGIC_SET__ + internal_a.magic = ZMAGIC; + #endif ++ ++#if defined(SW64) ++#define __A_MAGIC_SET__ ++ internal_a.magic = ZMAGIC; ++#endif + + #if defined MCORE_PE + #define __A_MAGIC_SET__ +diff -Naur gdb-14.1-after-patch/bfd/coff-sw64.c gdb-14.1-sw64/bfd/coff-sw64.c +--- gdb-14.1-after-patch/bfd/coff-sw64.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/bfd/coff-sw64.c 2025-03-03 10:59:12.950000000 +0800 +@@ -0,0 +1,2482 @@ ++/* BFD back-end for SW64 Extended-Coff files. ++ Copyright (C) 1993-2023 Free Software Foundation, Inc. ++ Modified from coff-mips.c by Steve Chamberlain and ++ Ian Lance Taylor . ++ ++ 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; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++ MA 02110-1301, USA. */ ++ ++#include "sysdep.h" ++#include "bfd.h" ++#include "bfdlink.h" ++#include "libbfd.h" ++#include "coff/internal.h" ++#include "coff/sym.h" ++#include "coff/symconst.h" ++#include "coff/ecoff.h" ++#include "coff/sw64.h" ++#include "aout/ar.h" ++#include "libcoff.h" ++#include "libecoff.h" ++ ++/* Prototypes for static functions. */ ++ ++ ++ ++/* ECOFF has COFF sections, but the debugging information is stored in ++ a completely different format. ECOFF targets use some of the ++ swapping routines from coffswap.h, and some of the generic COFF ++ routines in coffgen.c, but, unlike the real COFF targets, do not ++ use coffcode.h itself. ++ ++ Get the generic COFF swapping routines, except for the reloc, ++ symbol, and lineno ones. Give them ecoff names. Define some ++ accessor macros for the large sizes used for SW64 ECOFF. */ ++ ++#define GET_FILEHDR_SYMPTR H_GET_64 ++#define PUT_FILEHDR_SYMPTR H_PUT_64 ++#define GET_AOUTHDR_TSIZE H_GET_64 ++#define PUT_AOUTHDR_TSIZE H_PUT_64 ++#define GET_AOUTHDR_DSIZE H_GET_64 ++#define PUT_AOUTHDR_DSIZE H_PUT_64 ++#define GET_AOUTHDR_BSIZE H_GET_64 ++#define PUT_AOUTHDR_BSIZE H_PUT_64 ++#define GET_AOUTHDR_ENTRY H_GET_64 ++#define PUT_AOUTHDR_ENTRY H_PUT_64 ++#define GET_AOUTHDR_TEXT_START H_GET_64 ++#define PUT_AOUTHDR_TEXT_START H_PUT_64 ++#define GET_AOUTHDR_DATA_START H_GET_64 ++#define PUT_AOUTHDR_DATA_START H_PUT_64 ++#define GET_SCNHDR_PADDR H_GET_64 ++#define PUT_SCNHDR_PADDR H_PUT_64 ++#define GET_SCNHDR_VADDR H_GET_64 ++#define PUT_SCNHDR_VADDR H_PUT_64 ++#define GET_SCNHDR_SIZE H_GET_64 ++#define PUT_SCNHDR_SIZE H_PUT_64 ++#define GET_SCNHDR_SCNPTR H_GET_64 ++#define PUT_SCNHDR_SCNPTR H_PUT_64 ++#define GET_SCNHDR_RELPTR H_GET_64 ++#define PUT_SCNHDR_RELPTR H_PUT_64 ++#define GET_SCNHDR_LNNOPTR H_GET_64 ++#define PUT_SCNHDR_LNNOPTR H_PUT_64 ++ ++#define SW64ECOFF ++ ++#define NO_COFF_RELOCS ++#define NO_COFF_SYMBOLS ++#define NO_COFF_LINENOS ++#define coff_swap_filehdr_in sw64_ecoff_swap_filehdr_in ++#define coff_swap_filehdr_out sw64_ecoff_swap_filehdr_out ++#define coff_swap_aouthdr_in sw64_ecoff_swap_aouthdr_in ++#define coff_swap_aouthdr_out sw64_ecoff_swap_aouthdr_out ++#define coff_swap_scnhdr_in sw64_ecoff_swap_scnhdr_in ++#define coff_swap_scnhdr_out sw64_ecoff_swap_scnhdr_out ++#include "coffswap.h" ++ ++/* Get the ECOFF swapping routines. */ ++#define ECOFF_64 ++#include "ecoffswap.h" ++ ++/* How to process the various reloc types. */ ++ ++static bfd_reloc_status_type ++reloc_nil (bfd *abfd ATTRIBUTE_UNUSED, ++ arelent *reloc ATTRIBUTE_UNUSED, ++ asymbol *sym ATTRIBUTE_UNUSED, ++ void * data ATTRIBUTE_UNUSED, ++ asection *sec ATTRIBUTE_UNUSED, ++ bfd *output_bfd ATTRIBUTE_UNUSED, ++ char **error_message ATTRIBUTE_UNUSED) ++{ ++ return bfd_reloc_ok; ++} ++ ++/* In case we're on a 32-bit machine, construct a 64-bit "-1" value ++ from smaller values. Start with zero, widen, *then* decrement. */ ++#define MINUS_ONE (((bfd_vma)0) - 1) ++ ++static reloc_howto_type sw64_howto_table[] = ++{ ++ /* Reloc type 0 is ignored by itself. However, it appears after a ++ GPDISP reloc to identify the location where the low order 16 bits ++ of the gp register are loaded. */ ++ HOWTO (SW64_R_IGNORE, /* type */ ++ 0, /* rightshift */ ++ 1, /* size */ ++ 8, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ reloc_nil, /* special_function */ ++ "IGNORE", /* name */ ++ true, /* partial_inplace */ ++ 0, /* src_mask */ ++ 0, /* dst_mask */ ++ true), /* pcrel_offset */ ++ ++ /* A 32 bit reference to a symbol. */ ++ HOWTO (SW64_R_REFLONG, /* type */ ++ 0, /* rightshift */ ++ 4, /* size */ ++ 32, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_bitfield, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "REFLONG", /* name */ ++ true, /* partial_inplace */ ++ 0xffffffff, /* src_mask */ ++ 0xffffffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A 64 bit reference to a symbol. */ ++ HOWTO (SW64_R_REFQUAD, /* type */ ++ 0, /* rightshift */ ++ 8, /* size */ ++ 64, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_bitfield, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "REFQUAD", /* name */ ++ true, /* partial_inplace */ ++ MINUS_ONE, /* src_mask */ ++ MINUS_ONE, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A 32 bit GP relative offset. This is just like REFLONG except ++ that when the value is used the value of the gp register will be ++ added in. */ ++ HOWTO (SW64_R_GPREL32, /* type */ ++ 0, /* rightshift */ ++ 4, /* size */ ++ 32, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_bitfield, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "GPREL32", /* name */ ++ true, /* partial_inplace */ ++ 0xffffffff, /* src_mask */ ++ 0xffffffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Used for an instruction that refers to memory off the GP ++ register. The offset is 16 bits of the 32 bit instruction. This ++ reloc always seems to be against the .lita section. */ ++ HOWTO (SW64_R_LITERAL, /* type */ ++ 0, /* rightshift */ ++ 4, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "LITERAL", /* name */ ++ true, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* This reloc only appears immediately following a LITERAL reloc. ++ It identifies a use of the literal. It seems that the linker can ++ use this to eliminate a portion of the .lita section. The symbol ++ index is special: 1 means the literal address is in the base ++ register of a memory format instruction; 2 means the literal ++ address is in the byte offset register of a byte-manipulation ++ instruction; 3 means the literal address is in the target ++ register of a jsr instruction. This does not actually do any ++ relocation. */ ++ HOWTO (SW64_R_LITUSE, /* type */ ++ 0, /* rightshift */ ++ 4, /* size */ ++ 32, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ reloc_nil, /* special_function */ ++ "LITUSE", /* name */ ++ false, /* partial_inplace */ ++ 0, /* src_mask */ ++ 0, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Load the gp register. This is always used for a ldah instruction ++ which loads the upper 16 bits of the gp register. The next reloc ++ will be an IGNORE reloc which identifies the location of the lda ++ instruction which loads the lower 16 bits. The symbol index of ++ the GPDISP instruction appears to actually be the number of bytes ++ between the ldah and lda instructions. This gives two different ++ ways to determine where the lda instruction is; I don't know why ++ both are used. The value to use for the relocation is the ++ difference between the GP value and the current location; the ++ load will always be done against a register holding the current ++ address. */ ++ HOWTO (SW64_R_GPDISP, /* type */ ++ 16, /* rightshift */ ++ 4, /* size */ ++ 16, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ reloc_nil, /* special_function */ ++ "GPDISP", /* name */ ++ true, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ true), /* pcrel_offset */ ++ ++ /* A 21 bit branch. The native assembler generates these for ++ branches within the text segment, and also fills in the PC ++ relative offset in the instruction. */ ++ HOWTO (SW64_R_BRADDR, /* type */ ++ 2, /* rightshift */ ++ 4, /* size */ ++ 21, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "BRADDR", /* name */ ++ true, /* partial_inplace */ ++ 0x1fffff, /* src_mask */ ++ 0x1fffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A hint for a jump to a register. */ ++ HOWTO (SW64_R_HINT, /* type */ ++ 2, /* rightshift */ ++ 4, /* size */ ++ 14, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "HINT", /* name */ ++ true, /* partial_inplace */ ++ 0x3fff, /* src_mask */ ++ 0x3fff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* 16 bit PC relative offset. */ ++ HOWTO (SW64_R_SREL16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "SREL16", /* name */ ++ true, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* 32 bit PC relative offset. */ ++ HOWTO (SW64_R_SREL32, /* type */ ++ 0, /* rightshift */ ++ 4, /* size */ ++ 32, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "SREL32", /* name */ ++ true, /* partial_inplace */ ++ 0xffffffff, /* src_mask */ ++ 0xffffffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A 64 bit PC relative offset. */ ++ HOWTO (SW64_R_SREL64, /* type */ ++ 0, /* rightshift */ ++ 8, /* size */ ++ 64, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "SREL64", /* name */ ++ true, /* partial_inplace */ ++ MINUS_ONE, /* src_mask */ ++ MINUS_ONE, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Push a value on the reloc evaluation stack. */ ++ HOWTO (SW64_R_OP_PUSH, /* type */ ++ 0, /* rightshift */ ++ 0, /* size */ ++ 0, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "OP_PUSH", /* name */ ++ false, /* partial_inplace */ ++ 0, /* src_mask */ ++ 0, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Store the value from the stack at the given address. Store it in ++ a bitfield of size r_size starting at bit position r_offset. */ ++ HOWTO (SW64_R_OP_STORE, /* type */ ++ 0, /* rightshift */ ++ 8, /* size */ ++ 64, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "OP_STORE", /* name */ ++ false, /* partial_inplace */ ++ 0, /* src_mask */ ++ MINUS_ONE, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Subtract the reloc address from the value on the top of the ++ relocation stack. */ ++ HOWTO (SW64_R_OP_PSUB, /* type */ ++ 0, /* rightshift */ ++ 0, /* size */ ++ 0, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "OP_PSUB", /* name */ ++ false, /* partial_inplace */ ++ 0, /* src_mask */ ++ 0, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Shift the value on the top of the relocation stack right by the ++ given value. */ ++ HOWTO (SW64_R_OP_PRSHIFT, /* type */ ++ 0, /* rightshift */ ++ 0, /* size */ ++ 0, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "OP_PRSHIFT", /* name */ ++ false, /* partial_inplace */ ++ 0, /* src_mask */ ++ 0, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Adjust the GP value for a new range in the object file. */ ++ HOWTO (SW64_R_GPVALUE, /* type */ ++ 0, /* rightshift */ ++ 0, /* size */ ++ 0, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ 0, /* special_function */ ++ "GPVALUE", /* name */ ++ false, /* partial_inplace */ ++ 0, /* src_mask */ ++ 0, /* dst_mask */ ++ false) /* pcrel_offset */ ++}; ++ ++/* Recognize an SW64 ECOFF file. */ ++ ++static bfd_cleanup ++sw64_ecoff_object_p (bfd *abfd) ++{ ++ bfd_cleanup ret; ++ ++ ret = coff_object_p (abfd); ++ ++ if (ret != NULL) ++ { ++ asection *sec; ++ ++ /* SW64 ECOFF has a .pdata section. The lnnoptr field of the ++ .pdata section is the number of entries it contains. Each ++ entry takes up 8 bytes. The number of entries is required ++ since the section is aligned to a 16 byte boundary. When we ++ link .pdata sections together, we do not want to include the ++ alignment bytes. We handle this on input by faking the size ++ of the .pdata section to remove the unwanted alignment bytes. ++ On output we will set the lnnoptr field and force the ++ alignment. */ ++ sec = bfd_get_section_by_name (abfd, _PDATA); ++ if (sec != (asection *) NULL) ++ { ++ bfd_size_type size; ++ ++ size = (bfd_size_type) sec->line_filepos * 8; ++ BFD_ASSERT (size == sec->size ++ || size + 8 == sec->size); ++ if (!bfd_set_section_size (sec, size)) ++ return NULL; ++ } ++ } ++ ++ return ret; ++} ++ ++/* See whether the magic number matches. */ ++ ++static bool ++sw64_ecoff_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, ++ void * filehdr) ++{ ++ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; ++ ++ if (! SW64_ECOFF_BADMAG (*internal_f)) ++ return true; ++ ++ if (SW64_ECOFF_COMPRESSEDMAG (*internal_f)) ++ _bfd_error_handler ++ (_("%pB: cannot handle compressed SW64 binaries; " ++ "use compiler flags, or objZ, to generate uncompressed binaries"), ++ abfd); ++ ++ return false; ++} ++ ++/* This is a hook called by coff_real_object_p to create any backend ++ specific information. */ ++ ++static void * ++sw64_ecoff_mkobject_hook (bfd *abfd, void * filehdr, void * aouthdr) ++{ ++ void * ecoff; ++ ++ ecoff = _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr); ++ ++ if (ecoff != NULL) ++ { ++ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; ++ ++ /* Set additional BFD flags according to the object type from the ++ machine specific file header flags. */ ++ switch (internal_f->f_flags & F_SW64_OBJECT_TYPE_MASK) ++ { ++ case F_SW64_SHARABLE: ++ abfd->flags |= DYNAMIC; ++ break; ++ case F_SW64_CALL_SHARED: ++ /* Always executable if using shared libraries as the run time ++ loader might resolve undefined references. */ ++ abfd->flags |= (DYNAMIC | EXEC_P); ++ break; ++ } ++ } ++ return ecoff; ++} ++ ++/* Reloc handling. */ ++ ++/* Swap a reloc in. */ ++ ++static void ++sw64_ecoff_swap_reloc_in (bfd *abfd, ++ void * ext_ptr, ++ struct internal_reloc *intern) ++{ ++ const RELOC *ext = (RELOC *) ext_ptr; ++ ++ intern->r_vaddr = H_GET_64 (abfd, ext->r_vaddr); ++ intern->r_symndx = H_GET_32 (abfd, ext->r_symndx); ++ ++ BFD_ASSERT (bfd_header_little_endian (abfd)); ++ ++ intern->r_type = ((ext->r_bits[0] & RELOC_BITS0_TYPE_LITTLE) ++ >> RELOC_BITS0_TYPE_SH_LITTLE); ++ intern->r_extern = (ext->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0; ++ intern->r_offset = ((ext->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE) ++ >> RELOC_BITS1_OFFSET_SH_LITTLE); ++ /* Ignored the reserved bits. */ ++ intern->r_size = ((ext->r_bits[3] & RELOC_BITS3_SIZE_LITTLE) ++ >> RELOC_BITS3_SIZE_SH_LITTLE); ++ ++ if (intern->r_type == SW64_R_LITUSE ++ || intern->r_type == SW64_R_GPDISP) ++ { ++ /* Handle the LITUSE and GPDISP relocs specially. Its symndx ++ value is not actually a symbol index, but is instead a ++ special code. We put the code in the r_size field, and ++ clobber the symndx. */ ++ if (intern->r_size != 0) ++ abort (); ++ intern->r_size = intern->r_symndx; ++ intern->r_symndx = RELOC_SECTION_NONE; ++ } ++ else if (intern->r_type == SW64_R_IGNORE) ++ { ++ /* The IGNORE reloc generally follows a GPDISP reloc, and is ++ against the .lita section. The section is irrelevant. */ ++ if (! intern->r_extern && ++ intern->r_symndx == RELOC_SECTION_ABS) ++ abort (); ++ if (! intern->r_extern && intern->r_symndx == RELOC_SECTION_LITA) ++ intern->r_symndx = RELOC_SECTION_ABS; ++ } ++} ++ ++/* Swap a reloc out. */ ++ ++static void ++sw64_ecoff_swap_reloc_out (bfd *abfd, ++ const struct internal_reloc *intern, ++ void * dst) ++{ ++ RELOC *ext = (RELOC *) dst; ++ long symndx; ++ unsigned char size; ++ ++ /* Undo the hackery done in swap_reloc_in. */ ++ if (intern->r_type == SW64_R_LITUSE ++ || intern->r_type == SW64_R_GPDISP) ++ { ++ symndx = intern->r_size; ++ size = 0; ++ } ++ else if (intern->r_type == SW64_R_IGNORE ++ && ! intern->r_extern ++ && intern->r_symndx == RELOC_SECTION_ABS) ++ { ++ symndx = RELOC_SECTION_LITA; ++ size = intern->r_size; ++ } ++ else ++ { ++ symndx = intern->r_symndx; ++ size = intern->r_size; ++ } ++ ++ /* XXX FIXME: The maximum symndx value used to be 14 but this ++ fails with object files produced by DEC's C++ compiler. ++ Where does the value 14 (or 15) come from anyway ? */ ++ BFD_ASSERT (intern->r_extern ++ || (intern->r_symndx >= 0 && intern->r_symndx <= 15)); ++ ++ H_PUT_64 (abfd, intern->r_vaddr, ext->r_vaddr); ++ H_PUT_32 (abfd, symndx, ext->r_symndx); ++ ++ BFD_ASSERT (bfd_header_little_endian (abfd)); ++ ++ ext->r_bits[0] = ((intern->r_type << RELOC_BITS0_TYPE_SH_LITTLE) ++ & RELOC_BITS0_TYPE_LITTLE); ++ ext->r_bits[1] = ((intern->r_extern ? RELOC_BITS1_EXTERN_LITTLE : 0) ++ | ((intern->r_offset << RELOC_BITS1_OFFSET_SH_LITTLE) ++ & RELOC_BITS1_OFFSET_LITTLE)); ++ ext->r_bits[2] = 0; ++ ext->r_bits[3] = ((size << RELOC_BITS3_SIZE_SH_LITTLE) ++ & RELOC_BITS3_SIZE_LITTLE); ++} ++ ++/* Finish canonicalizing a reloc. Part of this is generic to all ++ ECOFF targets, and that part is in ecoff.c. The rest is done in ++ this backend routine. It must fill in the howto field. */ ++ ++static void ++sw64_adjust_reloc_in (bfd *abfd, ++ const struct internal_reloc *intern, ++ arelent *rptr) ++{ ++ if (intern->r_type > SW64_R_GPVALUE) ++ { ++ /* xgettext:c-format */ ++ _bfd_error_handler (_("%pB: unsupported relocation type %#x"), ++ abfd, intern->r_type); ++ bfd_set_error (bfd_error_bad_value); ++ rptr->addend = 0; ++ rptr->howto = NULL; ++ return; ++ } ++ ++ switch (intern->r_type) ++ { ++ case SW64_R_BRADDR: ++ case SW64_R_SREL16: ++ case SW64_R_SREL32: ++ case SW64_R_SREL64: ++ /* This relocs appear to be fully resolved when they are against ++ internal symbols. Against external symbols, BRADDR at least ++ appears to be resolved against the next instruction. */ ++ if (! intern->r_extern) ++ rptr->addend = 0; ++ else ++ rptr->addend = - (intern->r_vaddr + 4); ++ break; ++ ++ case SW64_R_GPREL32: ++ case SW64_R_LITERAL: ++ /* Copy the gp value for this object file into the addend, to ++ ensure that we are not confused by the linker. */ ++ if (! intern->r_extern) ++ rptr->addend += ecoff_data (abfd)->gp; ++ break; ++ ++ case SW64_R_LITUSE: ++ case SW64_R_GPDISP: ++ /* The LITUSE and GPDISP relocs do not use a symbol, or an ++ addend, but they do use a special code. Put this code in the ++ addend field. */ ++ rptr->addend = intern->r_size; ++ break; ++ ++ case SW64_R_OP_STORE: ++ /* The STORE reloc needs the size and offset fields. We store ++ them in the addend. */ ++ BFD_ASSERT (intern->r_offset <= 256); ++ rptr->addend = (intern->r_offset << 8) + intern->r_size; ++ break; ++ ++ case SW64_R_OP_PUSH: ++ case SW64_R_OP_PSUB: ++ case SW64_R_OP_PRSHIFT: ++ /* The PUSH, PSUB and PRSHIFT relocs do not actually use an ++ address. I believe that the address supplied is really an ++ addend. */ ++ rptr->addend = intern->r_vaddr; ++ break; ++ ++ case SW64_R_GPVALUE: ++ /* Set the addend field to the new GP value. */ ++ rptr->addend = intern->r_symndx + ecoff_data (abfd)->gp; ++ break; ++ ++ case SW64_R_IGNORE: ++ /* If the type is SW64_R_IGNORE, make sure this is a reference ++ to the absolute section so that the reloc is ignored. For ++ some reason the address of this reloc type is not adjusted by ++ the section vma. We record the gp value for this object file ++ here, for convenience when doing the GPDISP relocation. */ ++ rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; ++ rptr->address = intern->r_vaddr; ++ rptr->addend = ecoff_data (abfd)->gp; ++ break; ++ ++ default: ++ break; ++ } ++ ++ rptr->howto = &sw64_howto_table[intern->r_type]; ++} ++ ++/* When writing out a reloc we need to pull some values back out of ++ the addend field into the reloc. This is roughly the reverse of ++ sw64_adjust_reloc_in, except that there are several changes we do ++ not need to undo. */ ++ ++static void ++sw64_adjust_reloc_out (bfd *abfd ATTRIBUTE_UNUSED, ++ const arelent *rel, ++ struct internal_reloc *intern) ++{ ++ switch (intern->r_type) ++ { ++ case SW64_R_LITUSE: ++ case SW64_R_GPDISP: ++ intern->r_size = rel->addend; ++ break; ++ ++ case SW64_R_OP_STORE: ++ intern->r_size = rel->addend & 0xff; ++ intern->r_offset = (rel->addend >> 8) & 0xff; ++ break; ++ ++ case SW64_R_OP_PUSH: ++ case SW64_R_OP_PSUB: ++ case SW64_R_OP_PRSHIFT: ++ intern->r_vaddr = rel->addend; ++ break; ++ ++ case SW64_R_IGNORE: ++ intern->r_vaddr = rel->address; ++ break; ++ ++ default: ++ break; ++ } ++} ++ ++/* The size of the stack for the relocation evaluator. */ ++#define RELOC_STACKSIZE (10) ++ ++/* SW64 ECOFF relocs have a built in expression evaluator as well as ++ other interdependencies. Rather than use a bunch of special ++ functions and global variables, we use a single routine to do all ++ the relocation for a section. I haven't yet worked out how the ++ assembler is going to handle this. */ ++ ++static bfd_byte * ++sw64_ecoff_get_relocated_section_contents (bfd *abfd, ++ struct bfd_link_info *link_info, ++ struct bfd_link_order *link_order, ++ bfd_byte *data, ++ bool relocatable, ++ asymbol **symbols) ++{ ++ bfd *input_bfd = link_order->u.indirect.section->owner; ++ asection *input_section = link_order->u.indirect.section; ++ long reloc_size; ++ arelent **reloc_vector; ++ long reloc_count; ++ bfd *output_bfd = relocatable ? abfd : (bfd *) NULL; ++ bfd_vma gp; ++ bool gp_undefined; ++ bfd_vma stack[RELOC_STACKSIZE]; ++ int tos = 0; ++ ++ reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); ++ if (reloc_size < 0) ++ return NULL; ++ ++ bfd_byte *orig_data = data; ++ if (!bfd_get_full_section_contents (input_bfd, input_section, &data)) ++ return NULL; ++ ++ if (data == NULL) ++ return NULL; ++ ++ if (reloc_size == 0) ++ return data; ++ ++ reloc_vector = (arelent **) bfd_malloc (reloc_size); ++ if (reloc_vector == NULL) ++ goto error_return; ++ ++ reloc_count = bfd_canonicalize_reloc (input_bfd, input_section, ++ reloc_vector, symbols); ++ if (reloc_count < 0) ++ goto error_return; ++ if (reloc_count == 0) ++ goto successful_return; ++ ++ /* Get the GP value for the output BFD. */ ++ gp_undefined = false; ++ gp = _bfd_get_gp_value (abfd); ++ if (gp == 0) ++ { ++ if (relocatable) ++ { ++ asection *sec; ++ bfd_vma lo; ++ ++ /* Make up a value. */ ++ lo = (bfd_vma) -1; ++ for (sec = abfd->sections; sec != NULL; sec = sec->next) ++ { ++ if (sec->vma < lo ++ && (strcmp (sec->name, ".sbss") == 0 ++ || strcmp (sec->name, ".sdata") == 0 ++ || strcmp (sec->name, ".lit4") == 0 ++ || strcmp (sec->name, ".lit8") == 0 ++ || strcmp (sec->name, ".lita") == 0)) ++ lo = sec->vma; ++ } ++ gp = lo + 0x8000; ++ _bfd_set_gp_value (abfd, gp); ++ } ++ else ++ { ++ struct bfd_link_hash_entry *h; ++ ++ h = bfd_link_hash_lookup (link_info->hash, "_gp", false, false, ++ true); ++ if (h == (struct bfd_link_hash_entry *) NULL ++ || h->type != bfd_link_hash_defined) ++ gp_undefined = true; ++ else ++ { ++ gp = (h->u.def.value ++ + h->u.def.section->output_section->vma ++ + h->u.def.section->output_offset); ++ _bfd_set_gp_value (abfd, gp); ++ } ++ } ++ } ++ ++ for (; *reloc_vector != (arelent *) NULL; reloc_vector++) ++ { ++ arelent *rel; ++ bfd_reloc_status_type r; ++ char *err; ++ ++ rel = *reloc_vector; ++ r = bfd_reloc_ok; ++ switch (rel->howto->type) ++ { ++ case SW64_R_IGNORE: ++ rel->address += input_section->output_offset; ++ break; ++ ++ case SW64_R_REFLONG: ++ case SW64_R_REFQUAD: ++ case SW64_R_BRADDR: ++ case SW64_R_HINT: ++ case SW64_R_SREL16: ++ case SW64_R_SREL32: ++ case SW64_R_SREL64: ++ if (relocatable ++ && ((*rel->sym_ptr_ptr)->flags & BSF_SECTION_SYM) == 0) ++ { ++ rel->address += input_section->output_offset; ++ break; ++ } ++ r = bfd_perform_relocation (input_bfd, rel, data, input_section, ++ output_bfd, &err); ++ break; ++ ++ case SW64_R_GPREL32: ++ /* This relocation is used in a switch table. It is a 32 ++ bit offset from the current GP value. We must adjust it ++ by the different between the original GP value and the ++ current GP value. The original GP value is stored in the ++ addend. We adjust the addend and let ++ bfd_perform_relocation finish the job. */ ++ rel->addend -= gp; ++ r = bfd_perform_relocation (input_bfd, rel, data, input_section, ++ output_bfd, &err); ++ if (r == bfd_reloc_ok && gp_undefined) ++ { ++ r = bfd_reloc_dangerous; ++ err = (char *) _("GP relative relocation used when GP not defined"); ++ } ++ break; ++ ++ case SW64_R_LITERAL: ++ /* This is a reference to a literal value, generally ++ (always?) in the .lita section. This is a 16 bit GP ++ relative relocation. Sometimes the subsequent reloc is a ++ LITUSE reloc, which indicates how this reloc is used. ++ This sometimes permits rewriting the two instructions ++ referred to by the LITERAL and the LITUSE into different ++ instructions which do not refer to .lita. This can save ++ a memory reference, and permits removing a value from ++ .lita thus saving GP relative space. ++ ++ We do not these optimizations. To do them we would need ++ to arrange to link the .lita section first, so that by ++ the time we got here we would know the final values to ++ use. This would not be particularly difficult, but it is ++ not currently implemented. */ ++ ++ { ++ unsigned long insn; ++ ++ /* I believe that the LITERAL reloc will only apply to a ++ ldq or ldl instruction, so check my assumption. */ ++ insn = bfd_get_32 (input_bfd, data + rel->address); ++ BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29 ++ || ((insn >> 26) & 0x3f) == 0x28); ++ ++ rel->addend -= gp; ++ r = bfd_perform_relocation (input_bfd, rel, data, input_section, ++ output_bfd, &err); ++ if (r == bfd_reloc_ok && gp_undefined) ++ { ++ r = bfd_reloc_dangerous; ++ err = ++ (char *) _("GP relative relocation used when GP not defined"); ++ } ++ } ++ break; ++ ++ case SW64_R_LITUSE: ++ /* See SW64_R_LITERAL above for the uses of this reloc. It ++ does not cause anything to happen, itself. */ ++ rel->address += input_section->output_offset; ++ break; ++ ++ case SW64_R_GPDISP: ++ /* This marks the ldah of an ldah/lda pair which loads the ++ gp register with the difference of the gp value and the ++ current location. The second of the pair is r_size bytes ++ ahead; it used to be marked with an SW64_R_IGNORE reloc, ++ but that no longer happens in OSF/1 3.2. */ ++ { ++ unsigned long insn1, insn2; ++ bfd_vma addend; ++ ++ /* Get the two instructions. */ ++ insn1 = bfd_get_32 (input_bfd, data + rel->address); ++ insn2 = bfd_get_32 (input_bfd, data + rel->address + rel->addend); ++ ++ BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */ ++ BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */ ++ ++ /* Get the existing addend. We must account for the sign ++ extension done by lda and ldah. */ ++ addend = ((insn1 & 0xffff) << 16) + (insn2 & 0xffff); ++ if (insn1 & 0x8000) ++ { ++ addend -= 0x80000000; ++ addend -= 0x80000000; ++ } ++ if (insn2 & 0x8000) ++ addend -= 0x10000; ++ ++ /* The existing addend includes the different between the ++ gp of the input BFD and the address in the input BFD. ++ Subtract this out. */ ++ addend -= (ecoff_data (input_bfd)->gp ++ - (input_section->vma + rel->address)); ++ ++ /* Now add in the final gp value, and subtract out the ++ final address. */ ++ addend += (gp ++ - (input_section->output_section->vma ++ + input_section->output_offset ++ + rel->address)); ++ ++ /* Change the instructions, accounting for the sign ++ extension, and write them out. */ ++ if (addend & 0x8000) ++ addend += 0x10000; ++ insn1 = (insn1 & 0xffff0000) | ((addend >> 16) & 0xffff); ++ insn2 = (insn2 & 0xffff0000) | (addend & 0xffff); ++ ++ bfd_put_32 (input_bfd, (bfd_vma) insn1, data + rel->address); ++ bfd_put_32 (input_bfd, (bfd_vma) insn2, ++ data + rel->address + rel->addend); ++ ++ rel->address += input_section->output_offset; ++ } ++ break; ++ ++ case SW64_R_OP_PUSH: ++ /* Push a value on the reloc evaluation stack. */ ++ { ++ asymbol *symbol; ++ bfd_vma relocation; ++ ++ if (relocatable) ++ { ++ rel->address += input_section->output_offset; ++ break; ++ } ++ ++ /* Figure out the relocation of this symbol. */ ++ symbol = *rel->sym_ptr_ptr; ++ ++ if (bfd_is_und_section (symbol->section)) ++ r = bfd_reloc_undefined; ++ ++ if (bfd_is_com_section (symbol->section)) ++ relocation = 0; ++ else ++ relocation = symbol->value; ++ relocation += symbol->section->output_section->vma; ++ relocation += symbol->section->output_offset; ++ relocation += rel->addend; ++ ++ if (tos >= RELOC_STACKSIZE) ++ abort (); ++ ++ stack[tos++] = relocation; ++ } ++ break; ++ ++ case SW64_R_OP_STORE: ++ /* Store a value from the reloc stack into a bitfield. */ ++ { ++ bfd_vma val; ++ int offset, size; ++ ++ if (relocatable) ++ { ++ rel->address += input_section->output_offset; ++ break; ++ } ++ ++ if (tos == 0) ++ abort (); ++ ++ /* The offset and size for this reloc are encoded into the ++ addend field by sw64_adjust_reloc_in. */ ++ offset = (rel->addend >> 8) & 0xff; ++ size = rel->addend & 0xff; ++ ++ val = bfd_get_64 (abfd, data + rel->address); ++ val &=~ (((1 << size) - 1) << offset); ++ val |= (stack[--tos] & ((1 << size) - 1)) << offset; ++ bfd_put_64 (abfd, val, data + rel->address); ++ } ++ break; ++ ++ case SW64_R_OP_PSUB: ++ /* Subtract a value from the top of the stack. */ ++ { ++ asymbol *symbol; ++ bfd_vma relocation; ++ ++ if (relocatable) ++ { ++ rel->address += input_section->output_offset; ++ break; ++ } ++ ++ /* Figure out the relocation of this symbol. */ ++ symbol = *rel->sym_ptr_ptr; ++ ++ if (bfd_is_und_section (symbol->section)) ++ r = bfd_reloc_undefined; ++ ++ if (bfd_is_com_section (symbol->section)) ++ relocation = 0; ++ else ++ relocation = symbol->value; ++ relocation += symbol->section->output_section->vma; ++ relocation += symbol->section->output_offset; ++ relocation += rel->addend; ++ ++ if (tos == 0) ++ abort (); ++ ++ stack[tos - 1] -= relocation; ++ } ++ break; ++ ++ case SW64_R_OP_PRSHIFT: ++ /* Shift the value on the top of the stack. */ ++ { ++ asymbol *symbol; ++ bfd_vma relocation; ++ ++ if (relocatable) ++ { ++ rel->address += input_section->output_offset; ++ break; ++ } ++ ++ /* Figure out the relocation of this symbol. */ ++ symbol = *rel->sym_ptr_ptr; ++ ++ if (bfd_is_und_section (symbol->section)) ++ r = bfd_reloc_undefined; ++ ++ if (bfd_is_com_section (symbol->section)) ++ relocation = 0; ++ else ++ relocation = symbol->value; ++ relocation += symbol->section->output_section->vma; ++ relocation += symbol->section->output_offset; ++ relocation += rel->addend; ++ ++ if (tos == 0) ++ abort (); ++ ++ stack[tos - 1] >>= relocation; ++ } ++ break; ++ ++ case SW64_R_GPVALUE: ++ /* I really don't know if this does the right thing. */ ++ gp = rel->addend; ++ gp_undefined = false; ++ break; ++ ++ default: ++ abort (); ++ } ++ ++ if (relocatable) ++ { ++ asection *os = input_section->output_section; ++ ++ /* A partial link, so keep the relocs. */ ++ os->orelocation[os->reloc_count] = rel; ++ os->reloc_count++; ++ } ++ ++ if (r != bfd_reloc_ok) ++ { ++ switch (r) ++ { ++ case bfd_reloc_undefined: ++ (*link_info->callbacks->undefined_symbol) ++ (link_info, bfd_asymbol_name (*rel->sym_ptr_ptr), ++ input_bfd, input_section, rel->address, true); ++ break; ++ case bfd_reloc_dangerous: ++ (*link_info->callbacks->reloc_dangerous) ++ (link_info, err, input_bfd, input_section, rel->address); ++ break; ++ case bfd_reloc_overflow: ++ (*link_info->callbacks->reloc_overflow) ++ (link_info, NULL, bfd_asymbol_name (*rel->sym_ptr_ptr), ++ rel->howto->name, rel->addend, input_bfd, ++ input_section, rel->address); ++ break; ++ case bfd_reloc_outofrange: ++ default: ++ abort (); ++ break; ++ } ++ } ++ } ++ ++ if (tos != 0) ++ abort (); ++ ++ successful_return: ++ free (reloc_vector); ++ return data; ++ ++ error_return: ++ free (reloc_vector); ++ if (orig_data == NULL) ++ free (data); ++ return NULL; ++} ++ ++/* Get the howto structure for a generic reloc type. */ ++ ++static reloc_howto_type * ++sw64_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, ++ bfd_reloc_code_real_type code) ++{ ++ int sw64_type; ++ ++ switch (code) ++ { ++ case BFD_RELOC_32: ++ sw64_type = SW64_R_REFLONG; ++ break; ++ case BFD_RELOC_64: ++ case BFD_RELOC_CTOR: ++ sw64_type = SW64_R_REFQUAD; ++ break; ++ case BFD_RELOC_GPREL32: ++ sw64_type = SW64_R_GPREL32; ++ break; ++ case BFD_RELOC_SW64_LITERAL: ++ sw64_type = SW64_R_LITERAL; ++ break; ++ case BFD_RELOC_SW64_LITUSE: ++ sw64_type = SW64_R_LITUSE; ++ break; ++ case BFD_RELOC_SW64_GPDISP_HI16: ++ sw64_type = SW64_R_GPDISP; ++ break; ++ case BFD_RELOC_SW64_GPDISP_LO16: ++ sw64_type = SW64_R_IGNORE; ++ break; ++ case BFD_RELOC_23_PCREL_S2: ++ sw64_type = SW64_R_BRADDR; ++ break; ++ case BFD_RELOC_SW64_HINT: ++ sw64_type = SW64_R_HINT; ++ break; ++ case BFD_RELOC_16_PCREL: ++ sw64_type = SW64_R_SREL16; ++ break; ++ case BFD_RELOC_32_PCREL: ++ sw64_type = SW64_R_SREL32; ++ break; ++ case BFD_RELOC_64_PCREL: ++ sw64_type = SW64_R_SREL64; ++ break; ++ default: ++ return (reloc_howto_type *) NULL; ++ } ++ ++ return &sw64_howto_table[sw64_type]; ++} ++ ++static reloc_howto_type * ++sw64_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, ++ const char *r_name) ++{ ++ unsigned int i; ++ ++ for (i = 0; ++ i < sizeof (sw64_howto_table) / sizeof (sw64_howto_table[0]); ++ i++) ++ if (sw64_howto_table[i].name != NULL ++ && strcasecmp (sw64_howto_table[i].name, r_name) == 0) ++ return &sw64_howto_table[i]; ++ ++ return NULL; ++} ++ ++/* A helper routine for sw64_relocate_section which converts an ++ external reloc when generating relocatable output. Returns the ++ relocation amount. */ ++ ++static bfd_vma ++sw64_convert_external_reloc (bfd *output_bfd ATTRIBUTE_UNUSED, ++ struct bfd_link_info *info, ++ bfd *input_bfd, ++ struct external_reloc *ext_rel, ++ struct ecoff_link_hash_entry *h) ++{ ++ unsigned long r_symndx; ++ bfd_vma relocation; ++ ++ BFD_ASSERT (bfd_link_relocatable (info)); ++ ++ if (h->root.type == bfd_link_hash_defined ++ || h->root.type == bfd_link_hash_defweak) ++ { ++ asection *hsec; ++ const char *name; ++ ++ /* This symbol is defined in the output. Convert the reloc from ++ being against the symbol to being against the section. */ ++ ++ /* Clear the r_extern bit. */ ++ ext_rel->r_bits[1] &=~ RELOC_BITS1_EXTERN_LITTLE; ++ ++ /* Compute a new r_symndx value. */ ++ hsec = h->root.u.def.section; ++ name = bfd_section_name (hsec->output_section); ++ ++ r_symndx = (unsigned long) -1; ++ switch (name[1]) ++ { ++ case 'A': ++ if (strcmp (name, "*ABS*") == 0) ++ r_symndx = RELOC_SECTION_ABS; ++ break; ++ case 'b': ++ if (strcmp (name, ".bss") == 0) ++ r_symndx = RELOC_SECTION_BSS; ++ break; ++ case 'd': ++ if (strcmp (name, ".data") == 0) ++ r_symndx = RELOC_SECTION_DATA; ++ break; ++ case 'f': ++ if (strcmp (name, ".fini") == 0) ++ r_symndx = RELOC_SECTION_FINI; ++ break; ++ case 'i': ++ if (strcmp (name, ".init") == 0) ++ r_symndx = RELOC_SECTION_INIT; ++ break; ++ case 'l': ++ if (strcmp (name, ".lita") == 0) ++ r_symndx = RELOC_SECTION_LITA; ++ else if (strcmp (name, ".lit8") == 0) ++ r_symndx = RELOC_SECTION_LIT8; ++ else if (strcmp (name, ".lit4") == 0) ++ r_symndx = RELOC_SECTION_LIT4; ++ break; ++ case 'p': ++ if (strcmp (name, ".pdata") == 0) ++ r_symndx = RELOC_SECTION_PDATA; ++ break; ++ case 'r': ++ if (strcmp (name, ".rdata") == 0) ++ r_symndx = RELOC_SECTION_RDATA; ++ else if (strcmp (name, ".rconst") == 0) ++ r_symndx = RELOC_SECTION_RCONST; ++ break; ++ case 's': ++ if (strcmp (name, ".sdata") == 0) ++ r_symndx = RELOC_SECTION_SDATA; ++ else if (strcmp (name, ".sbss") == 0) ++ r_symndx = RELOC_SECTION_SBSS; ++ break; ++ case 't': ++ if (strcmp (name, ".text") == 0) ++ r_symndx = RELOC_SECTION_TEXT; ++ break; ++ case 'x': ++ if (strcmp (name, ".xdata") == 0) ++ r_symndx = RELOC_SECTION_XDATA; ++ break; ++ } ++ ++ if (r_symndx == (unsigned long) -1) ++ abort (); ++ ++ /* Add the section VMA and the symbol value. */ ++ relocation = (h->root.u.def.value ++ + hsec->output_section->vma ++ + hsec->output_offset); ++ } ++ else ++ { ++ /* Change the symndx value to the right one for ++ the output BFD. */ ++ r_symndx = h->indx; ++ if (r_symndx == (unsigned long) -1) ++ { ++ /* Caller must give an error. */ ++ r_symndx = 0; ++ } ++ relocation = 0; ++ } ++ ++ /* Write out the new r_symndx value. */ ++ H_PUT_32 (input_bfd, r_symndx, ext_rel->r_symndx); ++ ++ return relocation; ++} ++ ++/* Relocate a section while linking an SW64 ECOFF file. This is ++ quite similar to get_relocated_section_contents. Perhaps they ++ could be combined somehow. */ ++ ++static bool ++sw64_relocate_section (bfd *output_bfd, ++ struct bfd_link_info *info, ++ bfd *input_bfd, ++ asection *input_section, ++ bfd_byte *contents, ++ void * external_relocs) ++{ ++ asection **symndx_to_section, *lita_sec; ++ struct ecoff_link_hash_entry **sym_hashes; ++ bfd_vma gp; ++ bool gp_undefined; ++ bfd_vma stack[RELOC_STACKSIZE]; ++ int tos = 0; ++ struct external_reloc *ext_rel; ++ struct external_reloc *ext_rel_end; ++ bfd_size_type amt; ++ ++ /* We keep a table mapping the symndx found in an internal reloc to ++ the appropriate section. This is faster than looking up the ++ section by name each time. */ ++ symndx_to_section = ecoff_data (input_bfd)->symndx_to_section; ++ if (symndx_to_section == (asection **) NULL) ++ { ++ amt = NUM_RELOC_SECTIONS * sizeof (asection *); ++ symndx_to_section = (asection **) bfd_alloc (input_bfd, amt); ++ if (!symndx_to_section) ++ return false; ++ ++ symndx_to_section[RELOC_SECTION_NONE] = NULL; ++ symndx_to_section[RELOC_SECTION_TEXT] = ++ bfd_get_section_by_name (input_bfd, ".text"); ++ symndx_to_section[RELOC_SECTION_RDATA] = ++ bfd_get_section_by_name (input_bfd, ".rdata"); ++ symndx_to_section[RELOC_SECTION_DATA] = ++ bfd_get_section_by_name (input_bfd, ".data"); ++ symndx_to_section[RELOC_SECTION_SDATA] = ++ bfd_get_section_by_name (input_bfd, ".sdata"); ++ symndx_to_section[RELOC_SECTION_SBSS] = ++ bfd_get_section_by_name (input_bfd, ".sbss"); ++ symndx_to_section[RELOC_SECTION_BSS] = ++ bfd_get_section_by_name (input_bfd, ".bss"); ++ symndx_to_section[RELOC_SECTION_INIT] = ++ bfd_get_section_by_name (input_bfd, ".init"); ++ symndx_to_section[RELOC_SECTION_LIT8] = ++ bfd_get_section_by_name (input_bfd, ".lit8"); ++ symndx_to_section[RELOC_SECTION_LIT4] = ++ bfd_get_section_by_name (input_bfd, ".lit4"); ++ symndx_to_section[RELOC_SECTION_XDATA] = ++ bfd_get_section_by_name (input_bfd, ".xdata"); ++ symndx_to_section[RELOC_SECTION_PDATA] = ++ bfd_get_section_by_name (input_bfd, ".pdata"); ++ symndx_to_section[RELOC_SECTION_FINI] = ++ bfd_get_section_by_name (input_bfd, ".fini"); ++ symndx_to_section[RELOC_SECTION_LITA] = ++ bfd_get_section_by_name (input_bfd, ".lita"); ++ symndx_to_section[RELOC_SECTION_ABS] = bfd_abs_section_ptr; ++ symndx_to_section[RELOC_SECTION_RCONST] = ++ bfd_get_section_by_name (input_bfd, ".rconst"); ++ ++ ecoff_data (input_bfd)->symndx_to_section = symndx_to_section; ++ } ++ ++ sym_hashes = ecoff_data (input_bfd)->sym_hashes; ++ ++ /* On the SW64, the .lita section must be addressable by the global ++ pointer. To support large programs, we need to allow multiple ++ global pointers. This works as long as each input .lita section ++ is <64KB big. This implies that when producing relocatable ++ output, the .lita section is limited to 64KB. . */ ++ ++ lita_sec = symndx_to_section[RELOC_SECTION_LITA]; ++ gp = _bfd_get_gp_value (output_bfd); ++ if (! bfd_link_relocatable (info) && lita_sec != NULL) ++ { ++ struct ecoff_section_tdata *lita_sec_data; ++ ++ /* Make sure we have a section data structure to which we can ++ hang on to the gp value we pick for the section. */ ++ lita_sec_data = ecoff_section_data (input_bfd, lita_sec); ++ if (lita_sec_data == NULL) ++ { ++ amt = sizeof (struct ecoff_section_tdata); ++ lita_sec_data = ((struct ecoff_section_tdata *) ++ bfd_zalloc (input_bfd, amt)); ++ lita_sec->used_by_bfd = lita_sec_data; ++ } ++ ++ if (lita_sec_data->gp != 0) ++ { ++ /* If we already assigned a gp to this section, we better ++ stick with that value. */ ++ gp = lita_sec_data->gp; ++ } ++ else ++ { ++ bfd_vma lita_vma; ++ bfd_size_type lita_size; ++ ++ lita_vma = lita_sec->output_offset + lita_sec->output_section->vma; ++ lita_size = lita_sec->size; ++ ++ if (gp == 0 ++ || lita_vma < gp - 0x8000 ++ || lita_vma + lita_size >= gp + 0x8000) ++ { ++ /* Either gp hasn't been set at all or the current gp ++ cannot address this .lita section. In both cases we ++ reset the gp to point into the "middle" of the ++ current input .lita section. */ ++ if (gp && !ecoff_data (output_bfd)->issued_multiple_gp_warning) ++ { ++ (*info->callbacks->warning) (info, ++ _("using multiple gp values"), ++ (char *) NULL, output_bfd, ++ (asection *) NULL, (bfd_vma) 0); ++ ecoff_data (output_bfd)->issued_multiple_gp_warning = true; ++ } ++ if (lita_vma < gp - 0x8000) ++ gp = lita_vma + lita_size - 0x8000; ++ else ++ gp = lita_vma + 0x8000; ++ ++ } ++ ++ lita_sec_data->gp = gp; ++ } ++ ++ _bfd_set_gp_value (output_bfd, gp); ++ } ++ ++ gp_undefined = (gp == 0); ++ ++ BFD_ASSERT (bfd_header_little_endian (output_bfd)); ++ BFD_ASSERT (bfd_header_little_endian (input_bfd)); ++ ++ ext_rel = (struct external_reloc *) external_relocs; ++ ext_rel_end = ext_rel + input_section->reloc_count; ++ for (; ext_rel < ext_rel_end; ext_rel++) ++ { ++ bfd_vma r_vaddr; ++ unsigned long r_symndx; ++ int r_type; ++ int r_extern; ++ int r_offset; ++ int r_size; ++ bool relocatep; ++ bool adjust_addrp; ++ bool gp_usedp; ++ bfd_vma addend; ++ ++ r_vaddr = H_GET_64 (input_bfd, ext_rel->r_vaddr); ++ r_symndx = H_GET_32 (input_bfd, ext_rel->r_symndx); ++ ++ r_type = ((ext_rel->r_bits[0] & RELOC_BITS0_TYPE_LITTLE) ++ >> RELOC_BITS0_TYPE_SH_LITTLE); ++ r_extern = (ext_rel->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0; ++ r_offset = ((ext_rel->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE) ++ >> RELOC_BITS1_OFFSET_SH_LITTLE); ++ /* Ignored the reserved bits. */ ++ r_size = ((ext_rel->r_bits[3] & RELOC_BITS3_SIZE_LITTLE) ++ >> RELOC_BITS3_SIZE_SH_LITTLE); ++ ++ relocatep = false; ++ adjust_addrp = true; ++ gp_usedp = false; ++ addend = 0; ++ ++ switch (r_type) ++ { ++ case SW64_R_GPRELHIGH: ++ _bfd_error_handler (_("%pB: %s unsupported"), ++ input_bfd, "SW64_R_GPRELHIGH"); ++ bfd_set_error (bfd_error_bad_value); ++ continue; ++ ++ case SW64_R_GPRELLOW: ++ _bfd_error_handler (_("%pB: %s unsupported"), ++ input_bfd, "SW64_R_GPRELLOW"); ++ bfd_set_error (bfd_error_bad_value); ++ continue; ++ ++ default: ++ /* xgettext:c-format */ ++ _bfd_error_handler (_("%pB: unsupported relocation type %#x"), ++ input_bfd, (int) r_type); ++ bfd_set_error (bfd_error_bad_value); ++ continue; ++ ++ case SW64_R_IGNORE: ++ /* This reloc appears after a GPDISP reloc. On earlier ++ versions of OSF/1, It marked the position of the second ++ instruction to be altered by the GPDISP reloc, but it is ++ not otherwise used for anything. For some reason, the ++ address of the relocation does not appear to include the ++ section VMA, unlike the other relocation types. */ ++ if (bfd_link_relocatable (info)) ++ H_PUT_64 (input_bfd, input_section->output_offset + r_vaddr, ++ ext_rel->r_vaddr); ++ adjust_addrp = false; ++ break; ++ ++ case SW64_R_REFLONG: ++ case SW64_R_REFQUAD: ++ case SW64_R_HINT: ++ relocatep = true; ++ break; ++ ++ case SW64_R_BRADDR: ++ case SW64_R_SREL16: ++ case SW64_R_SREL32: ++ case SW64_R_SREL64: ++ if (r_extern) ++ addend += - (r_vaddr + 4); ++ relocatep = true; ++ break; ++ ++ case SW64_R_GPREL32: ++ /* This relocation is used in a switch table. It is a 32 ++ bit offset from the current GP value. We must adjust it ++ by the different between the original GP value and the ++ current GP value. */ ++ relocatep = true; ++ addend = ecoff_data (input_bfd)->gp - gp; ++ gp_usedp = true; ++ break; ++ ++ case SW64_R_LITERAL: ++ /* This is a reference to a literal value, generally ++ (always?) in the .lita section. This is a 16 bit GP ++ relative relocation. Sometimes the subsequent reloc is a ++ LITUSE reloc, which indicates how this reloc is used. ++ This sometimes permits rewriting the two instructions ++ referred to by the LITERAL and the LITUSE into different ++ instructions which do not refer to .lita. This can save ++ a memory reference, and permits removing a value from ++ .lita thus saving GP relative space. ++ ++ We do not these optimizations. To do them we would need ++ to arrange to link the .lita section first, so that by ++ the time we got here we would know the final values to ++ use. This would not be particularly difficult, but it is ++ not currently implemented. */ ++ ++ /* I believe that the LITERAL reloc will only apply to a ldq ++ or ldl instruction, so check my assumption. */ ++ { ++ unsigned long insn; ++ ++ insn = bfd_get_32 (input_bfd, ++ contents + r_vaddr - input_section->vma); ++ BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29 ++ || ((insn >> 26) & 0x3f) == 0x28); ++ } ++ ++ relocatep = true; ++ addend = ecoff_data (input_bfd)->gp - gp; ++ gp_usedp = true; ++ break; ++ ++ case SW64_R_LITUSE: ++ /* See SW64_R_LITERAL above for the uses of this reloc. It ++ does not cause anything to happen, itself. */ ++ break; ++ ++ case SW64_R_GPDISP: ++ /* This marks the ldah of an ldah/lda pair which loads the ++ gp register with the difference of the gp value and the ++ current location. The second of the pair is r_symndx ++ bytes ahead. It used to be marked with an SW64_R_IGNORE ++ reloc, but OSF/1 3.2 no longer does that. */ ++ { ++ unsigned long insn1, insn2; ++ ++ /* Get the two instructions. */ ++ insn1 = bfd_get_32 (input_bfd, ++ contents + r_vaddr - input_section->vma); ++ insn2 = bfd_get_32 (input_bfd, ++ (contents ++ + r_vaddr ++ - input_section->vma ++ + r_symndx)); ++ ++ BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */ ++ BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */ ++ ++ /* Get the existing addend. We must account for the sign ++ extension done by lda and ldah. */ ++ addend = ((insn1 & 0xffff) << 16) + (insn2 & 0xffff); ++ if (insn1 & 0x8000) ++ { ++ /* This is addend -= 0x100000000 without causing an ++ integer overflow on a 32 bit host. */ ++ addend -= 0x80000000; ++ addend -= 0x80000000; ++ } ++ if (insn2 & 0x8000) ++ addend -= 0x10000; ++ ++ /* The existing addend includes the difference between the ++ gp of the input BFD and the address in the input BFD. ++ We want to change this to the difference between the ++ final GP and the final address. */ ++ addend += (gp ++ - ecoff_data (input_bfd)->gp ++ + input_section->vma ++ - (input_section->output_section->vma ++ + input_section->output_offset)); ++ ++ /* Change the instructions, accounting for the sign ++ extension, and write them out. */ ++ if (addend & 0x8000) ++ addend += 0x10000; ++ insn1 = (insn1 & 0xffff0000) | ((addend >> 16) & 0xffff); ++ insn2 = (insn2 & 0xffff0000) | (addend & 0xffff); ++ ++ bfd_put_32 (input_bfd, (bfd_vma) insn1, ++ contents + r_vaddr - input_section->vma); ++ bfd_put_32 (input_bfd, (bfd_vma) insn2, ++ contents + r_vaddr - input_section->vma + r_symndx); ++ ++ gp_usedp = true; ++ } ++ break; ++ ++ case SW64_R_OP_PUSH: ++ case SW64_R_OP_PSUB: ++ case SW64_R_OP_PRSHIFT: ++ /* Manipulate values on the reloc evaluation stack. The ++ r_vaddr field is not an address in input_section, it is ++ the current value (including any addend) of the object ++ being used. */ ++ if (! r_extern) ++ { ++ asection *s; ++ ++ s = symndx_to_section[r_symndx]; ++ if (s == (asection *) NULL) ++ abort (); ++ addend = s->output_section->vma + s->output_offset - s->vma; ++ } ++ else ++ { ++ struct ecoff_link_hash_entry *h; ++ ++ h = sym_hashes[r_symndx]; ++ if (h == (struct ecoff_link_hash_entry *) NULL) ++ abort (); ++ ++ if (! bfd_link_relocatable (info)) ++ { ++ if (h->root.type == bfd_link_hash_defined ++ || h->root.type == bfd_link_hash_defweak) ++ addend = (h->root.u.def.value ++ + h->root.u.def.section->output_section->vma ++ + h->root.u.def.section->output_offset); ++ else ++ { ++ /* Note that we pass the address as 0, since we ++ do not have a meaningful number for the ++ location within the section that is being ++ relocated. */ ++ (*info->callbacks->undefined_symbol) ++ (info, h->root.root.string, input_bfd, ++ input_section, (bfd_vma) 0, true); ++ addend = 0; ++ } ++ } ++ else ++ { ++ if (h->root.type != bfd_link_hash_defined ++ && h->root.type != bfd_link_hash_defweak ++ && h->indx == -1) ++ { ++ /* This symbol is not being written out. Pass ++ the address as 0, as with undefined_symbol, ++ above. */ ++ (*info->callbacks->unattached_reloc) ++ (info, h->root.root.string, ++ input_bfd, input_section, (bfd_vma) 0); ++ } ++ ++ addend = sw64_convert_external_reloc (output_bfd, info, ++ input_bfd, ++ ext_rel, h); ++ } ++ } ++ ++ addend += r_vaddr; ++ ++ if (bfd_link_relocatable (info)) ++ { ++ /* Adjust r_vaddr by the addend. */ ++ H_PUT_64 (input_bfd, addend, ext_rel->r_vaddr); ++ } ++ else ++ { ++ switch (r_type) ++ { ++ case SW64_R_OP_PUSH: ++ if (tos >= RELOC_STACKSIZE) ++ abort (); ++ stack[tos++] = addend; ++ break; ++ ++ case SW64_R_OP_PSUB: ++ if (tos == 0) ++ abort (); ++ stack[tos - 1] -= addend; ++ break; ++ ++ case SW64_R_OP_PRSHIFT: ++ if (tos == 0) ++ abort (); ++ stack[tos - 1] >>= addend; ++ break; ++ } ++ } ++ ++ adjust_addrp = false; ++ break; ++ ++ case SW64_R_OP_STORE: ++ /* Store a value from the reloc stack into a bitfield. If ++ we are generating relocatable output, all we do is ++ adjust the address of the reloc. */ ++ if (! bfd_link_relocatable (info)) ++ { ++ bfd_vma mask; ++ bfd_vma val; ++ ++ if (tos == 0) ++ abort (); ++ ++ /* Get the relocation mask. The separate steps and the ++ casts to bfd_vma are attempts to avoid a bug in the ++ SW64 OSF 1.3 C compiler. See reloc.c for more ++ details. */ ++ mask = 1; ++ mask <<= (bfd_vma) r_size; ++ mask -= 1; ++ ++ /* FIXME: I don't know what kind of overflow checking, ++ if any, should be done here. */ ++ val = bfd_get_64 (input_bfd, ++ contents + r_vaddr - input_section->vma); ++ val &=~ mask << (bfd_vma) r_offset; ++ val |= (stack[--tos] & mask) << (bfd_vma) r_offset; ++ bfd_put_64 (input_bfd, val, ++ contents + r_vaddr - input_section->vma); ++ } ++ break; ++ ++ case SW64_R_GPVALUE: ++ /* I really don't know if this does the right thing. */ ++ gp = ecoff_data (input_bfd)->gp + r_symndx; ++ gp_undefined = false; ++ break; ++ } ++ ++ if (relocatep) ++ { ++ reloc_howto_type *howto; ++ struct ecoff_link_hash_entry *h = NULL; ++ asection *s = NULL; ++ bfd_vma relocation; ++ bfd_reloc_status_type r; ++ ++ /* Perform a relocation. */ ++ ++ howto = &sw64_howto_table[r_type]; ++ ++ if (r_extern) ++ { ++ h = sym_hashes[r_symndx]; ++ /* If h is NULL, that means that there is a reloc ++ against an external symbol which we thought was just ++ a debugging symbol. This should not happen. */ ++ if (h == (struct ecoff_link_hash_entry *) NULL) ++ abort (); ++ } ++ else ++ { ++ if (r_symndx >= NUM_RELOC_SECTIONS) ++ s = NULL; ++ else ++ s = symndx_to_section[r_symndx]; ++ ++ if (s == (asection *) NULL) ++ abort (); ++ } ++ ++ if (bfd_link_relocatable (info)) ++ { ++ /* We are generating relocatable output, and must ++ convert the existing reloc. */ ++ if (r_extern) ++ { ++ if (h->root.type != bfd_link_hash_defined ++ && h->root.type != bfd_link_hash_defweak ++ && h->indx == -1) ++ { ++ /* This symbol is not being written out. */ ++ (*info->callbacks->unattached_reloc) ++ (info, h->root.root.string, input_bfd, ++ input_section, r_vaddr - input_section->vma); ++ } ++ ++ relocation = sw64_convert_external_reloc (output_bfd, ++ info, ++ input_bfd, ++ ext_rel, ++ h); ++ } ++ else ++ { ++ /* This is a relocation against a section. Adjust ++ the value by the amount the section moved. */ ++ relocation = (s->output_section->vma ++ + s->output_offset ++ - s->vma); ++ } ++ ++ /* If this is PC relative, the existing object file ++ appears to already have the reloc worked out. We ++ must subtract out the old value and add in the new ++ one. */ ++ if (howto->pc_relative) ++ relocation -= (input_section->output_section->vma ++ + input_section->output_offset ++ - input_section->vma); ++ ++ /* Put in any addend. */ ++ relocation += addend; ++ ++ /* Adjust the contents. */ ++ r = _bfd_relocate_contents (howto, input_bfd, relocation, ++ (contents ++ + r_vaddr ++ - input_section->vma)); ++ } ++ else ++ { ++ /* We are producing a final executable. */ ++ if (r_extern) ++ { ++ /* This is a reloc against a symbol. */ ++ if (h->root.type == bfd_link_hash_defined ++ || h->root.type == bfd_link_hash_defweak) ++ { ++ asection *hsec; ++ ++ hsec = h->root.u.def.section; ++ relocation = (h->root.u.def.value ++ + hsec->output_section->vma ++ + hsec->output_offset); ++ } ++ else ++ { ++ (*info->callbacks->undefined_symbol) ++ (info, h->root.root.string, input_bfd, input_section, ++ r_vaddr - input_section->vma, true); ++ relocation = 0; ++ } ++ } ++ else ++ { ++ /* This is a reloc against a section. */ ++ relocation = (s->output_section->vma ++ + s->output_offset ++ - s->vma); ++ ++ /* Adjust a PC relative relocation by removing the ++ reference to the original source section. */ ++ if (howto->pc_relative) ++ relocation += input_section->vma; ++ } ++ ++ r = _bfd_final_link_relocate (howto, ++ input_bfd, ++ input_section, ++ contents, ++ r_vaddr - input_section->vma, ++ relocation, ++ addend); ++ } ++ ++ if (r != bfd_reloc_ok) ++ { ++ switch (r) ++ { ++ default: ++ case bfd_reloc_outofrange: ++ abort (); ++ case bfd_reloc_overflow: ++ { ++ const char *name; ++ ++ if (r_extern) ++ name = sym_hashes[r_symndx]->root.root.string; ++ else ++ name = bfd_section_name (symndx_to_section[r_symndx]); ++ (*info->callbacks->reloc_overflow) ++ (info, NULL, name, sw64_howto_table[r_type].name, ++ (bfd_vma) 0, input_bfd, input_section, ++ r_vaddr - input_section->vma); ++ } ++ break; ++ } ++ } ++ } ++ ++ if (bfd_link_relocatable (info) && adjust_addrp) ++ { ++ /* Change the address of the relocation. */ ++ H_PUT_64 (input_bfd, ++ (input_section->output_section->vma ++ + input_section->output_offset ++ - input_section->vma ++ + r_vaddr), ++ ext_rel->r_vaddr); ++ } ++ ++ if (gp_usedp && gp_undefined) ++ { ++ (*info->callbacks->reloc_dangerous) ++ (info, _("GP relative relocation used when GP not defined"), ++ input_bfd, input_section, r_vaddr - input_section->vma); ++ /* Only give the error once per link. */ ++ gp = 4; ++ _bfd_set_gp_value (output_bfd, gp); ++ gp_undefined = false; ++ } ++ } ++ ++ if (tos != 0) ++ abort (); ++ ++ return true; ++} ++ ++/* Do final adjustments to the filehdr and the aouthdr. This routine ++ sets the dynamic bits in the file header. */ ++ ++static bool ++sw64_adjust_headers (bfd *abfd, ++ struct internal_filehdr *fhdr, ++ struct internal_aouthdr *ahdr ATTRIBUTE_UNUSED) ++{ ++ if ((abfd->flags & (DYNAMIC | EXEC_P)) == (DYNAMIC | EXEC_P)) ++ fhdr->f_flags |= F_SW64_CALL_SHARED; ++ else if ((abfd->flags & DYNAMIC) != 0) ++ fhdr->f_flags |= F_SW64_SHARABLE; ++ return true; ++} ++ ++/* Archive handling. In OSF/1 (or Digital Unix) v3.2, Digital ++ introduced archive packing, in which the elements in an archive are ++ optionally compressed using a simple dictionary scheme. We know ++ how to read such archives, but we don't write them. */ ++ ++#define sw64_ecoff_slurp_armap _bfd_ecoff_slurp_armap ++#define sw64_ecoff_slurp_extended_name_table \ ++ _bfd_ecoff_slurp_extended_name_table ++#define sw64_ecoff_construct_extended_name_table \ ++ _bfd_ecoff_construct_extended_name_table ++#define sw64_ecoff_truncate_arname _bfd_ecoff_truncate_arname ++#define sw64_ecoff_write_armap _bfd_ecoff_write_armap ++#define sw64_ecoff_write_ar_hdr _bfd_generic_write_ar_hdr ++#define sw64_ecoff_generic_stat_arch_elt _bfd_ecoff_generic_stat_arch_elt ++#define sw64_ecoff_update_armap_timestamp _bfd_ecoff_update_armap_timestamp ++ ++/* A compressed file uses this instead of ARFMAG. */ ++ ++#define ARFZMAG "Z\012" ++ ++/* Read an archive header. This is like the standard routine, but it ++ also accepts ARFZMAG. */ ++ ++static void * ++sw64_ecoff_read_ar_hdr (bfd *abfd) ++{ ++ struct areltdata *ret; ++ struct ar_hdr *h; ++ ++ ret = (struct areltdata *) _bfd_generic_read_ar_hdr_mag (abfd, ARFZMAG); ++ if (ret == NULL) ++ return NULL; ++ ++ h = (struct ar_hdr *) ret->arch_header; ++ if (strncmp (h->ar_fmag, ARFZMAG, 2) == 0) ++ { ++ bfd_byte ab[8]; ++ ++ /* This is a compressed file. We must set the size correctly. ++ The size is the eight bytes after the dummy file header. */ ++ if (bfd_seek (abfd, FILHSZ, SEEK_CUR) != 0 ++ || bfd_read (ab, 8, abfd) != 8 ++ || bfd_seek (abfd, -(FILHSZ + 8), SEEK_CUR) != 0) ++ { ++ free (ret); ++ return NULL; ++ } ++ ++ ret->parsed_size = H_GET_64 (abfd, ab); ++ } ++ ++ return ret; ++} ++ ++/* Get an archive element at a specified file position. This is where ++ we uncompress the archive element if necessary. */ ++ ++static bfd * ++sw64_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos, ++ struct bfd_link_info *info) ++{ ++ bfd *nbfd = NULL; ++ struct areltdata *tdata; ++ struct ar_hdr *hdr; ++ bfd_byte ab[8]; ++ bfd_size_type size; ++ bfd_byte *buf, *p; ++ struct bfd_in_memory *bim; ++ ufile_ptr filesize; ++ ++ buf = NULL; ++ nbfd = _bfd_get_elt_at_filepos (archive, filepos, info); ++ if (nbfd == NULL) ++ goto error_return; ++ ++ if ((nbfd->flags & BFD_IN_MEMORY) != 0) ++ { ++ /* We have already expanded this BFD. */ ++ return nbfd; ++ } ++ ++ tdata = (struct areltdata *) nbfd->arelt_data; ++ hdr = (struct ar_hdr *) tdata->arch_header; ++ if (strncmp (hdr->ar_fmag, ARFZMAG, 2) != 0) ++ return nbfd; ++ ++ /* We must uncompress this element. We do this by copying it into a ++ memory buffer, and making bfd_read and bfd_seek use that buffer. ++ This can use a lot of memory, but it's simpler than getting a ++ temporary file, making that work with the file descriptor caching ++ code, and making sure that it is deleted at all appropriate ++ times. It can be changed if it ever becomes important. */ ++ ++ /* The compressed file starts with a dummy ECOFF file header. */ ++ if (bfd_seek (nbfd, FILHSZ, SEEK_SET) != 0) ++ goto error_return; ++ ++ /* The next eight bytes are the real file size. */ ++ if (bfd_read (ab, 8, nbfd) != 8) ++ goto error_return; ++ size = H_GET_64 (nbfd, ab); ++ ++ /* The decompression algorithm will at most expand by eight times. */ ++ filesize = bfd_get_file_size (archive); ++ if (filesize != 0 && size / 8 > filesize) ++ { ++ bfd_set_error (bfd_error_malformed_archive); ++ goto error_return; ++ } ++ ++ if (size != 0) ++ { ++ bfd_size_type left; ++ bfd_byte dict[4096]; ++ unsigned int h; ++ bfd_byte b; ++ ++ buf = (bfd_byte *) bfd_malloc (size); ++ if (buf == NULL) ++ goto error_return; ++ p = buf; ++ ++ left = size; ++ ++ /* I don't know what the next eight bytes are for. */ ++ if (bfd_read (ab, 8, nbfd) != 8) ++ goto error_return; ++ ++ /* This is the uncompression algorithm. It's a simple ++ dictionary based scheme in which each character is predicted ++ by a hash of the previous three characters. A control byte ++ indicates whether the character is predicted or whether it ++ appears in the input stream; each control byte manages the ++ next eight bytes in the output stream. */ ++ memset (dict, 0, sizeof dict); ++ h = 0; ++ while (bfd_read (&b, 1, nbfd) == 1) ++ { ++ unsigned int i; ++ ++ for (i = 0; i < 8; i++, b >>= 1) ++ { ++ bfd_byte n; ++ ++ if ((b & 1) == 0) ++ n = dict[h]; ++ else ++ { ++ if (bfd_read (&n, 1, nbfd) != 1) ++ goto error_return; ++ dict[h] = n; ++ } ++ ++ *p++ = n; ++ ++ --left; ++ if (left == 0) ++ break; ++ ++ h <<= 4; ++ h ^= n; ++ h &= sizeof dict - 1; ++ } ++ ++ if (left == 0) ++ break; ++ } ++ } ++ ++ /* Now the uncompressed file contents are in buf. */ ++ bim = ((struct bfd_in_memory *) ++ bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory))); ++ if (bim == NULL) ++ goto error_return; ++ bim->size = size; ++ bim->buffer = buf; ++ ++ nbfd->mtime_set = true; ++ nbfd->mtime = strtol (hdr->ar_date, (char **) NULL, 10); ++ ++ nbfd->flags |= BFD_IN_MEMORY; ++ nbfd->iostream = bim; ++ nbfd->iovec = &_bfd_memory_iovec; ++ nbfd->origin = 0; ++ nbfd->size = 0; ++ BFD_ASSERT (! nbfd->cacheable); ++ ++ return nbfd; ++ ++ error_return: ++ free (buf); ++ if (nbfd != NULL) ++ bfd_close (nbfd); ++ return NULL; ++} ++ ++/* Open the next archived file. */ ++ ++static bfd * ++sw64_ecoff_openr_next_archived_file (bfd *archive, bfd *last_file) ++{ ++ ufile_ptr filestart; ++ ++ if (last_file == NULL) ++ filestart = bfd_ardata (archive)->first_file_filepos; ++ else ++ { ++ struct areltdata *t; ++ struct ar_hdr *h; ++ bfd_size_type size; ++ ++ /* We can't use arelt_size here, because that uses parsed_size, ++ which is the uncompressed size. We need the compressed size. */ ++ t = (struct areltdata *) last_file->arelt_data; ++ h = (struct ar_hdr *) t->arch_header; ++ size = strtol (h->ar_size, (char **) NULL, 10); ++ ++ /* Pad to an even boundary... ++ Note that last_file->origin can be odd in the case of ++ BSD-4.4-style element with a long odd size. */ ++ filestart = last_file->proxy_origin + size; ++ filestart += filestart % 2; ++ if (filestart < last_file->proxy_origin) ++ { ++ /* Prevent looping. See PR19256. */ ++ bfd_set_error (bfd_error_malformed_archive); ++ return NULL; ++ } ++ } ++ ++ return sw64_ecoff_get_elt_at_filepos (archive, filestart, NULL); ++} ++ ++/* Open the archive file given an index into the armap. */ ++ ++static bfd * ++sw64_ecoff_get_elt_at_index (bfd *abfd, symindex sym_index) ++{ ++ carsym *entry; ++ ++ entry = bfd_ardata (abfd)->symdefs + sym_index; ++ return sw64_ecoff_get_elt_at_filepos (abfd, entry->file_offset, ++ NULL); ++} ++ ++static void ++sw64_ecoff_swap_coff_aux_in (bfd *abfd ATTRIBUTE_UNUSED, ++ void *ext1 ATTRIBUTE_UNUSED, ++ int type ATTRIBUTE_UNUSED, ++ int in_class ATTRIBUTE_UNUSED, ++ int indx ATTRIBUTE_UNUSED, ++ int numaux ATTRIBUTE_UNUSED, ++ void *in1 ATTRIBUTE_UNUSED) ++{ ++} ++ ++static void ++sw64_ecoff_swap_coff_sym_in (bfd *abfd ATTRIBUTE_UNUSED, ++ void *ext1 ATTRIBUTE_UNUSED, ++ void *in1 ATTRIBUTE_UNUSED) ++{ ++} ++ ++static void ++sw64_ecoff_swap_coff_lineno_in (bfd *abfd ATTRIBUTE_UNUSED, ++ void *ext1 ATTRIBUTE_UNUSED, ++ void *in1 ATTRIBUTE_UNUSED) ++{ ++} ++ ++static unsigned int ++sw64_ecoff_swap_coff_aux_out (bfd *abfd ATTRIBUTE_UNUSED, ++ void *inp ATTRIBUTE_UNUSED, ++ int type ATTRIBUTE_UNUSED, ++ int in_class ATTRIBUTE_UNUSED, ++ int indx ATTRIBUTE_UNUSED, ++ int numaux ATTRIBUTE_UNUSED, ++ void *extp ATTRIBUTE_UNUSED) ++{ ++ return 0; ++} ++ ++static unsigned int ++sw64_ecoff_swap_coff_sym_out (bfd *abfd ATTRIBUTE_UNUSED, ++ void *inp ATTRIBUTE_UNUSED, ++ void *extp ATTRIBUTE_UNUSED) ++{ ++ return 0; ++} ++ ++static unsigned int ++sw64_ecoff_swap_coff_lineno_out (bfd *abfd ATTRIBUTE_UNUSED, ++ void *inp ATTRIBUTE_UNUSED, ++ void *extp ATTRIBUTE_UNUSED) ++{ ++ return 0; ++} ++ ++static unsigned int ++sw64_ecoff_swap_coff_reloc_out (bfd *abfd ATTRIBUTE_UNUSED, ++ void *inp ATTRIBUTE_UNUSED, ++ void *extp ATTRIBUTE_UNUSED) ++{ ++ return 0; ++} ++ ++/* This is the ECOFF backend structure. The backend field of the ++ target vector points to this. */ ++ ++static const struct ecoff_backend_data sw64_ecoff_backend_data = ++{ ++ /* COFF backend structure. */ ++ { ++ sw64_ecoff_swap_coff_aux_in, sw64_ecoff_swap_coff_sym_in, ++ sw64_ecoff_swap_coff_lineno_in, sw64_ecoff_swap_coff_aux_out, ++ sw64_ecoff_swap_coff_sym_out, sw64_ecoff_swap_coff_lineno_out, ++ sw64_ecoff_swap_coff_reloc_out, ++ sw64_ecoff_swap_filehdr_out, sw64_ecoff_swap_aouthdr_out, ++ sw64_ecoff_swap_scnhdr_out, ++ FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, true, ++ ECOFF_NO_LONG_SECTION_NAMES, 4, false, 2, 32768, ++ sw64_ecoff_swap_filehdr_in, sw64_ecoff_swap_aouthdr_in, ++ sw64_ecoff_swap_scnhdr_in, NULL, ++ sw64_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook, ++ sw64_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags, ++ _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table, ++ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ++ NULL, NULL, NULL, NULL ++ }, ++ /* Supported architecture. */ ++ bfd_arch_sw64, ++ /* Initial portion of armap string. */ ++ "________64", ++ /* The page boundary used to align sections in a demand-paged ++ executable file. E.g., 0x1000. */ ++ 0x2000, ++ /* TRUE if the .rdata section is part of the text segment, as on the ++ SW64. FALSE if .rdata is part of the data segment, as on the ++ MIPS. */ ++ true, ++ /* Bitsize of constructor entries. */ ++ 64, ++ /* Reloc to use for constructor entries. */ ++ &sw64_howto_table[SW64_R_REFQUAD], ++ { ++ /* Symbol table magic number. */ ++ magicSym2, ++ /* Alignment of debugging information. E.g., 4. */ ++ 8, ++ /* Sizes of external symbolic information. */ ++ sizeof (struct hdr_ext), ++ sizeof (struct dnr_ext), ++ sizeof (struct pdr_ext), ++ sizeof (struct sym_ext), ++ sizeof (struct opt_ext), ++ sizeof (struct fdr_ext), ++ sizeof (struct rfd_ext), ++ sizeof (struct ext_ext), ++ /* Functions to swap in external symbolic data. */ ++ ecoff_swap_hdr_in, ++ ecoff_swap_dnr_in, ++ ecoff_swap_pdr_in, ++ ecoff_swap_sym_in, ++ ecoff_swap_opt_in, ++ ecoff_swap_fdr_in, ++ ecoff_swap_rfd_in, ++ ecoff_swap_ext_in, ++ _bfd_ecoff_swap_tir_in, ++ _bfd_ecoff_swap_rndx_in, ++ /* Functions to swap out external symbolic data. */ ++ ecoff_swap_hdr_out, ++ ecoff_swap_dnr_out, ++ ecoff_swap_pdr_out, ++ ecoff_swap_sym_out, ++ ecoff_swap_opt_out, ++ ecoff_swap_fdr_out, ++ ecoff_swap_rfd_out, ++ ecoff_swap_ext_out, ++ _bfd_ecoff_swap_tir_out, ++ _bfd_ecoff_swap_rndx_out, ++ /* Function to read in symbolic data. */ ++ _bfd_ecoff_slurp_symbolic_info ++ }, ++ /* External reloc size. */ ++ RELSZ, ++ /* Reloc swapping functions. */ ++ sw64_ecoff_swap_reloc_in, ++ sw64_ecoff_swap_reloc_out, ++ /* Backend reloc tweaking. */ ++ sw64_adjust_reloc_in, ++ sw64_adjust_reloc_out, ++ /* Relocate section contents while linking. */ ++ sw64_relocate_section, ++ /* Do final adjustments to filehdr and aouthdr. */ ++ sw64_adjust_headers, ++ /* Read an element from an archive at a given file position. */ ++ sw64_ecoff_get_elt_at_filepos ++}; ++ ++/* Looking up a reloc type is SW64 specific. */ ++#define _bfd_ecoff_bfd_reloc_type_lookup sw64_bfd_reloc_type_lookup ++#define _bfd_ecoff_bfd_reloc_name_lookup \ ++ sw64_bfd_reloc_name_lookup ++ ++/* So is getting relocated section contents. */ ++#define _bfd_ecoff_bfd_get_relocated_section_contents \ ++ sw64_ecoff_get_relocated_section_contents ++ ++/* Handling file windows is generic. */ ++#define _bfd_ecoff_get_section_contents_in_window \ ++ _bfd_generic_get_section_contents_in_window ++ ++/* Input section flag lookup is generic. */ ++#define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags ++ ++/* Relaxing sections is generic. */ ++#define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section ++#define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections ++#define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections ++#define _bfd_ecoff_bfd_is_group_section bfd_generic_is_group_section ++#define _bfd_ecoff_bfd_group_name bfd_generic_group_name ++#define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group ++#define _bfd_ecoff_section_already_linked \ ++ _bfd_coff_section_already_linked ++#define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol ++#define _bfd_ecoff_bfd_link_hide_symbol _bfd_generic_link_hide_symbol ++#define _bfd_ecoff_bfd_define_start_stop bfd_generic_define_start_stop ++#define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs ++ ++/* Installing internal relocations in a section is also generic. */ ++#define _bfd_ecoff_set_reloc _bfd_generic_set_reloc ++ ++const bfd_target sw64_ecoff_le_vec = ++{ ++ "ecoff-littlesw64", /* name */ ++ bfd_target_ecoff_flavour, ++ BFD_ENDIAN_LITTLE, /* data byte order is little */ ++ BFD_ENDIAN_LITTLE, /* header byte order is little */ ++ ++ (HAS_RELOC | EXEC_P /* object flags */ ++ | HAS_LINENO | HAS_DEBUG ++ | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), ++ ++ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE ++ | SEC_DATA | SEC_SMALL_DATA), ++ 0, /* leading underscore */ ++ ' ', /* ar_pad_char */ ++ 15, /* ar_max_namelen */ ++ 0, /* match priority. */ ++ TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols. */ ++ bfd_getl64, bfd_getl_signed_64, bfd_putl64, ++ bfd_getl32, bfd_getl_signed_32, bfd_putl32, ++ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ ++ bfd_getl64, bfd_getl_signed_64, bfd_putl64, ++ bfd_getl32, bfd_getl_signed_32, bfd_putl32, ++ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ ++ ++ { /* bfd_check_format */ ++ _bfd_dummy_target, ++ sw64_ecoff_object_p, ++ bfd_generic_archive_p, ++ _bfd_dummy_target ++ }, ++ { /* bfd_set_format */ ++ _bfd_bool_bfd_false_error, ++ _bfd_ecoff_mkobject, ++ _bfd_generic_mkarchive, ++ _bfd_bool_bfd_false_error ++ }, ++ { /* bfd_write_contents */ ++ _bfd_bool_bfd_false_error, ++ _bfd_ecoff_write_object_contents, ++ _bfd_write_archive_contents, ++ _bfd_bool_bfd_false_error ++ }, ++ ++ BFD_JUMP_TABLE_GENERIC (_bfd_ecoff), ++ BFD_JUMP_TABLE_COPY (_bfd_ecoff), ++ BFD_JUMP_TABLE_CORE (_bfd_nocore), ++ BFD_JUMP_TABLE_ARCHIVE (sw64_ecoff), ++ BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff), ++ BFD_JUMP_TABLE_RELOCS (_bfd_ecoff), ++ BFD_JUMP_TABLE_WRITE (_bfd_ecoff), ++ BFD_JUMP_TABLE_LINK (_bfd_ecoff), ++ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), ++ ++ NULL, ++ ++ &sw64_ecoff_backend_data ++}; +diff -Naur gdb-14.1-after-patch/bfd/config.bfd gdb-14.1-sw64/bfd/config.bfd +--- gdb-14.1-after-patch/bfd/config.bfd 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/bfd/config.bfd 2025-03-03 10:59:12.960000000 +0800 +@@ -217,6 +217,7 @@ + sh*) targ_archs=bfd_sh_arch ;; + sparc*) targ_archs=bfd_sparc_arch ;; + spu*) targ_archs=bfd_spu_arch ;; ++sw64*) targ_archs=bfd_sw64_arch ;; + tilegx*) targ_archs=bfd_tilegx_arch ;; + tilepro*) targ_archs=bfd_tilepro_arch ;; + v850*) targ_archs="bfd_v850_arch bfd_v850_rh850_arch" ;; +@@ -328,6 +329,11 @@ + targ_defvec=alpha_ecoff_le_vec + want64=true + ;; ++ sw64*-*-linux-* | sw64*-*-elf*) ++ targ_defvec=sw64_elf64_vec ++ targ_selvecs=sw64_ecoff_le_vec ++ want64=true ++ ;; + amdgcn-*-*) + targ_defvec=amdgcn_elf64_le_vec + want64=true +diff -Naur gdb-14.1-after-patch/bfd/configure gdb-14.1-sw64/bfd/configure +--- gdb-14.1-after-patch/bfd/configure 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/bfd/configure 2025-03-03 10:59:12.960000000 +0800 +@@ -13873,6 +13873,8 @@ + aarch64_mach_o_vec) tb="$tb mach-o-aarch64.lo"; target_size=64 ;; + aarch64_pei_le_vec) tb="$tb pei-aarch64.lo pe-aarch64igen.lo $coff"; target_size=64 ;; + aarch64_pe_le_vec) tb="$tb pe-aarch64.lo pe-aarch64igen.lo $coff"; target_size=64 ;; ++ sw64_ecoff_le_vec) tb="$tb coff-sw64.lo ecoff.lo $ecoff"; target_size=64 ;; ++ sw64_elf64_vec) tb="$tb elf64-sw64.lo elf64.lo $elf"; target_size=64 ;; + alpha_ecoff_le_vec) tb="$tb coff-alpha.lo ecoff.lo $ecoff"; target_size=64 ;; + alpha_elf64_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;; + alpha_elf64_fbsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;; +diff -Naur gdb-14.1-after-patch/bfd/configure.ac gdb-14.1-sw64/bfd/configure.ac +--- gdb-14.1-after-patch/bfd/configure.ac 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/bfd/configure.ac 2025-03-03 10:59:12.960000000 +0800 +@@ -409,6 +409,8 @@ + aarch64_mach_o_vec) tb="$tb mach-o-aarch64.lo"; target_size=64 ;; + aarch64_pei_le_vec) tb="$tb pei-aarch64.lo pe-aarch64igen.lo $coff"; target_size=64 ;; + aarch64_pe_le_vec) tb="$tb pe-aarch64.lo pe-aarch64igen.lo $coff"; target_size=64 ;; ++ sw64_ecoff_le_vec) tb="$tb coff-sw64.lo ecoff.lo $ecoff"; target_size=64 ;; ++ sw64_elf64_vec) tb="$tb elf64-sw64.lo elf64.lo $elf"; target_size=64 ;; + alpha_ecoff_le_vec) tb="$tb coff-alpha.lo ecoff.lo $ecoff"; target_size=64 ;; + alpha_elf64_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;; + alpha_elf64_fbsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;; +diff -Naur gdb-14.1-after-patch/bfd/cpu-sw64.c gdb-14.1-sw64/bfd/cpu-sw64.c +--- gdb-14.1-after-patch/bfd/cpu-sw64.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/bfd/cpu-sw64.c 2025-03-03 10:59:12.960000000 +0800 +@@ -0,0 +1,54 @@ ++/* BFD support for the SW64 architecture. ++ Copyright (C) 1992-2022 Free Software Foundation, Inc. ++ ++ 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; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++ MA 02110-1301, USA. */ ++ ++#include "sysdep.h" ++#include "bfd.h" ++#include "libbfd.h" ++ ++#define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT) \ ++ { \ ++ BITS_WORD, /* Bits in a word. */ \ ++ BITS_ADDR, /* Bits in an address. */ \ ++ 8, /* Bits in a byte. */ \ ++ bfd_arch_sw64, \ ++ NUMBER, \ ++ "sw64", \ ++ PRINT, \ ++ 3, /* Section alignment power. */ \ ++ DEFAULT, \ ++ bfd_default_compatible, \ ++ bfd_default_scan, \ ++ bfd_arch_default_fill, \ ++ NEXT, \ ++ 0 /* Maximum offset of a reloc from the start of an insn. */ \ ++ } ++ ++#define NN(index) (&arch_info_struct[index]) ++ ++/* These exist only so that we can reasonably disassemble PALcode. */ ++static const bfd_arch_info_type arch_info_struct[] = ++{ ++ N (64, 64, bfd_mach_sw64, "sw64", false, NN(1)), ++ N (64, 64, bfd_mach_sw64_sw6b, "sw64:sw6b", false, NN(2)), ++ N (64, 64, bfd_mach_sw64_sw8a, "sw64:sw8a", false, 0), ++}; ++ ++const bfd_arch_info_type bfd_sw64_arch = ++ N (64, 64, 0, "sw64", true, NN(0)); +diff -Naur gdb-14.1-after-patch/bfd/doc/aoutx.texi gdb-14.1-sw64/bfd/doc/aoutx.texi +--- gdb-14.1-after-patch/bfd/doc/aoutx.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/aoutx.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,170 +0,0 @@ +-@section a.out backends +- +- +-BFD supports a number of different flavours of a.out format, +-though the major differences are only the sizes of the +-structures on disk, and the shape of the relocation +-information. +- +-The support is split into a basic support file @file{aoutx.h} +-and other files which derive functions from the base. One +-derivation file is @file{aoutf1.h} (for a.out flavour 1), and +-adds to the basic a.out functions support for sun3, sun4, and +-386 a.out files, to create a target jump vector for a specific +-target. +- +-This information is further split out into more specific files +-for each machine, including @file{sunos.c} for sun3 and sun4, +-and @file{demo64.c} for a demonstration of a 64 bit a.out format. +- +-The base file @file{aoutx.h} defines general mechanisms for +-reading and writing records to and from disk and various +-other methods which BFD requires. It is included by +-@file{aout32.c} and @file{aout64.c} to form the names +-@code{aout_32_swap_exec_header_in}, @code{aout_64_swap_exec_header_in}, etc. +- +-As an example, this is what goes on to make the back end for a +-sun4, from @file{aout32.c}: +- +-@example +- #define ARCH_SIZE 32 +- #include "aoutx.h" +-@end example +- +-Which exports names: +- +-@example +- ... +- aout_32_canonicalize_reloc +- aout_32_find_nearest_line +- aout_32_get_lineno +- aout_32_get_reloc_upper_bound +- ... +-@end example +- +-from @file{sunos.c}: +- +-@example +- #define TARGET_NAME "a.out-sunos-big" +- #define VECNAME sparc_aout_sunos_be_vec +- #include "aoutf1.h" +-@end example +- +-requires all the names from @file{aout32.c}, and produces the jump vector +- +-@example +- sparc_aout_sunos_be_vec +-@end example +- +-The file @file{host-aout.c} is a special case. It is for a large set +-of hosts that use ``more or less standard'' a.out files, and +-for which cross-debugging is not interesting. It uses the +-standard 32-bit a.out support routines, but determines the +-file offsets and addresses of the text, data, and BSS +-sections, the machine architecture and machine type, and the +-entry point address, in a host-dependent manner. Once these +-values have been determined, generic code is used to handle +-the object file. +- +-When porting it to run on a new system, you must supply: +- +-@example +- HOST_PAGE_SIZE +- HOST_SEGMENT_SIZE +- HOST_MACHINE_ARCH (optional) +- HOST_MACHINE_MACHINE (optional) +- HOST_TEXT_START_ADDR +- HOST_STACK_END_ADDR +-@end example +- +-in the file @file{../include/sys/h-@var{XXX}.h} (for your host). These +-values, plus the structures and macros defined in @file{a.out.h} on +-your host system, will produce a BFD target that will access +-ordinary a.out files on your host. To configure a new machine +-to use @file{host-aout.c}, specify: +- +-@example +- TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec +- TDEPFILES= host-aout.o trad-core.o +-@end example +- +-in the @file{config/@var{XXX}.mt} file, and modify @file{configure.ac} +-to use the +-@file{@var{XXX}.mt} file (by setting "@code{bfd_target=XXX}") when your +-configuration is selected. +- +-@subsection Relocations +- +- +-The file @file{aoutx.h} provides for both the @emph{standard} +-and @emph{extended} forms of a.out relocation records. +- +-The standard records contain only an address, a symbol index, +-and a type field. The extended records also have a full +-integer for an addend. +- +-@subsection Internal entry points +- +- +-@file{aoutx.h} exports several routines for accessing the +-contents of an a.out file, which are gathered and exported in +-turn by various format specific files (eg sunos.c). +- +-@findex aout_@var{size}_swap_exec_header_in +-@subsubsection @code{aout_@var{size}_swap_exec_header_in} +-@deftypefn {Function} void aout_@var{size}_swap_exec_header_in, (bfd *abfd, struct external_exec *bytes, struct internal_exec *execp); +-Swap the information in an executable header @var{raw_bytes} taken +-from a raw byte stream memory image into the internal exec header +-structure @var{execp}. +- +-@end deftypefn +-@findex aout_@var{size}_swap_exec_header_out +-@subsubsection @code{aout_@var{size}_swap_exec_header_out} +-@deftypefn {Function} void aout_@var{size}_swap_exec_header_out (bfd *abfd, struct internal_exec *execp, struct external_exec *raw_bytes); +-Swap the information in an internal exec header structure +-@var{execp} into the buffer @var{raw_bytes} ready for writing to disk. +- +-@end deftypefn +-@findex aout_@var{size}_some_aout_object_p +-@subsubsection @code{aout_@var{size}_some_aout_object_p} +-@deftypefn {Function} bfd_cleanup aout_@var{size}_some_aout_object_p (bfd *abfd, struct internal_exec *execp, bfd_cleanup (*callback_to_real_object_p) (bfd *)); +-Some a.out variant thinks that the file open in @var{abfd} +-checking is an a.out file. Do some more checking, and set up +-for access if it really is. Call back to the calling +-environment's "finish up" function just before returning, to +-handle any last-minute setup. +- +-@end deftypefn +-@findex aout_@var{size}_mkobject +-@subsubsection @code{aout_@var{size}_mkobject} +-@deftypefn {Function} bool aout_@var{size}_mkobject, (bfd *abfd); +-Initialize BFD @var{abfd} for use with a.out files. +- +-@end deftypefn +-@findex aout_@var{size}_machine_type +-@subsubsection @code{aout_@var{size}_machine_type} +-@deftypefn {Function} enum machine_type aout_@var{size}_machine_type (enum bfd_architecture arch, unsigned long machine, bool *unknown); +-Keep track of machine architecture and machine type for +-a.out's. Return the @code{machine_type} for a particular +-architecture and machine, or @code{M_UNKNOWN} if that exact architecture +-and machine can't be represented in a.out format. +- +-If the architecture is understood, machine type 0 (default) +-is always understood. +- +-@end deftypefn +-@findex aout_@var{size}_set_arch_mach +-@subsubsection @code{aout_@var{size}_set_arch_mach} +-@deftypefn {Function} bool aout_@var{size}_set_arch_mach, (bfd *, enum bfd_architecture arch, unsigned long machine); +-Set the architecture and the machine of the BFD @var{abfd} to the +-values @var{arch} and @var{machine}. Verify that @var{abfd}'s format +-can support the architecture required. +- +-@end deftypefn +-@findex aout_@var{size}_new_section_hook +-@subsubsection @code{aout_@var{size}_new_section_hook} +-@deftypefn {Function} bool aout_@var{size}_new_section_hook, (bfd *abfd, asection *newsect); +-Called by the BFD in response to a @code{bfd_make_section} +-request. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/archive.texi gdb-14.1-sw64/bfd/doc/archive.texi +--- gdb-14.1-after-patch/bfd/doc/archive.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/archive.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,95 +0,0 @@ +-@section Archives +- +- +-An archive (or library) is just another BFD. It has a symbol +-table, although there's not much a user program will do with it. +- +-The big difference between an archive BFD and an ordinary BFD +-is that the archive doesn't have sections. Instead it has a +-chain of BFDs that are considered its contents. These BFDs can +-be manipulated like any other. The BFDs contained in an +-archive opened for reading will all be opened for reading. You +-may put either input or output BFDs into an archive opened for +-output; they will be handled correctly when the archive is closed. +- +-Use @code{bfd_openr_next_archived_file} to step through +-the contents of an archive opened for input. You don't +-have to read the entire archive if you don't want +-to! Read it until you find what you want. +- +-A BFD returned by @code{bfd_openr_next_archived_file} can be +-closed manually with @code{bfd_close}. If you do not close it, +-then a second iteration through the members of an archive may +-return the same BFD. If you close the archive BFD, then all +-the member BFDs will automatically be closed as well. +- +-Archive contents of output BFDs are chained through the +-@code{archive_next} pointer in a BFD. The first one is findable +-through the @code{archive_head} slot of the archive. Set it with +-@code{bfd_set_archive_head} (q.v.). A given BFD may be in only +-one open output archive at a time. +- +-As expected, the BFD archive code is more general than the +-archive code of any given environment. BFD archives may +-contain files of different formats (e.g., a.out and coff) and +-even different architectures. You may even place archives +-recursively into archives! +- +-This can cause unexpected confusion, since some archive +-formats are more expressive than others. For instance, Intel +-COFF archives can preserve long filenames; SunOS a.out archives +-cannot. If you move a file from the first to the second +-format and back again, the filename may be truncated. +-Likewise, different a.out environments have different +-conventions as to how they truncate filenames, whether they +-preserve directory names in filenames, etc. When +-interoperating with native tools, be sure your files are +-homogeneous. +- +-Beware: most of these formats do not react well to the +-presence of spaces in filenames. We do the best we can, but +-can't always handle this case due to restrictions in the format of +-archives. Many Unix utilities are braindead in regards to +-spaces and such in filenames anyway, so this shouldn't be much +-of a restriction. +- +-Archives are supported in BFD in @code{archive.c}. +- +-@subsection Archive functions +- +- +-@findex bfd_get_next_mapent +-@subsubsection @code{bfd_get_next_mapent} +-@deftypefn {Function} symindex bfd_get_next_mapent (bfd *abfd, symindex previous, carsym **sym); +-Step through archive @var{abfd}'s symbol table (if it +-has one). Successively update @var{sym} with the next symbol's +-information, returning that symbol's (internal) index into the +-symbol table. +- +-Supply @code{BFD_NO_MORE_SYMBOLS} as the @var{previous} entry to get +-the first one; returns @code{BFD_NO_MORE_SYMBOLS} when you've already +-got the last one. +- +-A @code{carsym} is a canonical archive symbol. The only +-user-visible element is its name, a null-terminated string. +- +-@end deftypefn +-@findex bfd_set_archive_head +-@subsubsection @code{bfd_set_archive_head} +-@deftypefn {Function} bool bfd_set_archive_head (bfd *output, bfd *new_head); +-Set the head of the chain of +-BFDs contained in the archive @var{output} to @var{new_head}. +- +-@end deftypefn +-@findex bfd_openr_next_archived_file +-@subsubsection @code{bfd_openr_next_archived_file} +-@deftypefn {Function} bfd *bfd_openr_next_archived_file (bfd *archive, bfd *previous); +-Provided a BFD, @var{archive}, containing an archive and NULL, open +-an input BFD on the first contained element and returns that. +-Subsequent calls should pass the archive and the previous return +-value to return a created BFD to the next contained element. NULL +-is returned when there are no more. +-Note - if you want to process the bfd returned by this call be +-sure to call bfd_check_format() on it first. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/archures.texi gdb-14.1-sw64/bfd/doc/archures.texi +--- gdb-14.1-after-patch/bfd/doc/archures.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/archures.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,743 +0,0 @@ +-@section Architectures +-BFD keeps one atom in a BFD describing the +-architecture of the data attached to the BFD: a pointer to a +-@code{bfd_arch_info_type}. +- +-Pointers to structures can be requested independently of a BFD +-so that an architecture's information can be interrogated +-without access to an open BFD. +- +-The architecture information is provided by each architecture package. +-The set of default architectures is selected by the macro +-@code{SELECT_ARCHITECTURES}. This is normally set up in the +-@file{config/@var{target}.mt} file of your choice. If the name is not +-defined, then all the architectures supported are included. +- +-When BFD starts up, all the architectures are called with an +-initialize method. It is up to the architecture back end to +-insert as many items into the list of architectures as it wants to; +-generally this would be one for each machine and one for the +-default case (an item with a machine field of 0). +- +-BFD's idea of an architecture is implemented in @file{archures.c}. +- +-@subsection bfd_architecture +- +- +-This enum gives the object file's CPU architecture, in a +-global sense---i.e., what processor family does it belong to? +-Another field indicates which processor within +-the family is in use. The machine gives a number which +-distinguishes different versions of the architecture, +-containing, for example, 68020 for Motorola 68020. +-@example +-enum bfd_architecture +-@{ +- bfd_arch_unknown, /* File arch not known. */ +- bfd_arch_obscure, /* Arch known, not one of these. */ +- bfd_arch_m68k, /* Motorola 68xxx. */ +-#define bfd_mach_m68000 1 +-#define bfd_mach_m68008 2 +-#define bfd_mach_m68010 3 +-#define bfd_mach_m68020 4 +-#define bfd_mach_m68030 5 +-#define bfd_mach_m68040 6 +-#define bfd_mach_m68060 7 +-#define bfd_mach_cpu32 8 +-#define bfd_mach_fido 9 +-#define bfd_mach_mcf_isa_a_nodiv 10 +-#define bfd_mach_mcf_isa_a 11 +-#define bfd_mach_mcf_isa_a_mac 12 +-#define bfd_mach_mcf_isa_a_emac 13 +-#define bfd_mach_mcf_isa_aplus 14 +-#define bfd_mach_mcf_isa_aplus_mac 15 +-#define bfd_mach_mcf_isa_aplus_emac 16 +-#define bfd_mach_mcf_isa_b_nousp 17 +-#define bfd_mach_mcf_isa_b_nousp_mac 18 +-#define bfd_mach_mcf_isa_b_nousp_emac 19 +-#define bfd_mach_mcf_isa_b 20 +-#define bfd_mach_mcf_isa_b_mac 21 +-#define bfd_mach_mcf_isa_b_emac 22 +-#define bfd_mach_mcf_isa_b_float 23 +-#define bfd_mach_mcf_isa_b_float_mac 24 +-#define bfd_mach_mcf_isa_b_float_emac 25 +-#define bfd_mach_mcf_isa_c 26 +-#define bfd_mach_mcf_isa_c_mac 27 +-#define bfd_mach_mcf_isa_c_emac 28 +-#define bfd_mach_mcf_isa_c_nodiv 29 +-#define bfd_mach_mcf_isa_c_nodiv_mac 30 +-#define bfd_mach_mcf_isa_c_nodiv_emac 31 +- bfd_arch_vax, /* DEC Vax. */ +- +- bfd_arch_or1k, /* OpenRISC 1000. */ +-#define bfd_mach_or1k 1 +-#define bfd_mach_or1knd 2 +- +- bfd_arch_sparc, /* SPARC. */ +-#define bfd_mach_sparc 1 +-/* The difference between v8plus and v9 is that v9 is a true 64 bit env. */ +-#define bfd_mach_sparc_sparclet 2 +-#define bfd_mach_sparc_sparclite 3 +-#define bfd_mach_sparc_v8plus 4 +-#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns. */ +-#define bfd_mach_sparc_sparclite_le 6 +-#define bfd_mach_sparc_v9 7 +-#define bfd_mach_sparc_v9a 8 /* with ultrasparc add'ns. */ +-#define bfd_mach_sparc_v8plusb 9 /* with cheetah add'ns. */ +-#define bfd_mach_sparc_v9b 10 /* with cheetah add'ns. */ +-#define bfd_mach_sparc_v8plusc 11 /* with UA2005 and T1 add'ns. */ +-#define bfd_mach_sparc_v9c 12 /* with UA2005 and T1 add'ns. */ +-#define bfd_mach_sparc_v8plusd 13 /* with UA2007 and T3 add'ns. */ +-#define bfd_mach_sparc_v9d 14 /* with UA2007 and T3 add'ns. */ +-#define bfd_mach_sparc_v8pluse 15 /* with OSA2001 and T4 add'ns (no IMA). */ +-#define bfd_mach_sparc_v9e 16 /* with OSA2001 and T4 add'ns (no IMA). */ +-#define bfd_mach_sparc_v8plusv 17 /* with OSA2011 and T4 and IMA and FJMAU add'ns. */ +-#define bfd_mach_sparc_v9v 18 /* with OSA2011 and T4 and IMA and FJMAU add'ns. */ +-#define bfd_mach_sparc_v8plusm 19 /* with OSA2015 and M7 add'ns. */ +-#define bfd_mach_sparc_v9m 20 /* with OSA2015 and M7 add'ns. */ +-#define bfd_mach_sparc_v8plusm8 21 /* with OSA2017 and M8 add'ns. */ +-#define bfd_mach_sparc_v9m8 22 /* with OSA2017 and M8 add'ns. */ +-/* Nonzero if MACH has the v9 instruction set. */ +-#define bfd_mach_sparc_v9_p(mach) \ +- ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9m8 \ +- && (mach) != bfd_mach_sparc_sparclite_le) +-/* Nonzero if MACH is a 64 bit sparc architecture. */ +-#define bfd_mach_sparc_64bit_p(mach) \ +- ((mach) >= bfd_mach_sparc_v9 \ +- && (mach) != bfd_mach_sparc_v8plusb \ +- && (mach) != bfd_mach_sparc_v8plusc \ +- && (mach) != bfd_mach_sparc_v8plusd \ +- && (mach) != bfd_mach_sparc_v8pluse \ +- && (mach) != bfd_mach_sparc_v8plusv \ +- && (mach) != bfd_mach_sparc_v8plusm \ +- && (mach) != bfd_mach_sparc_v8plusm8) +- bfd_arch_spu, /* PowerPC SPU. */ +-#define bfd_mach_spu 256 +- bfd_arch_mips, /* MIPS Rxxxx. */ +-#define bfd_mach_mips3000 3000 +-#define bfd_mach_mips3900 3900 +-#define bfd_mach_mips4000 4000 +-#define bfd_mach_mips4010 4010 +-#define bfd_mach_mips4100 4100 +-#define bfd_mach_mips4111 4111 +-#define bfd_mach_mips4120 4120 +-#define bfd_mach_mips4300 4300 +-#define bfd_mach_mips4400 4400 +-#define bfd_mach_mips4600 4600 +-#define bfd_mach_mips4650 4650 +-#define bfd_mach_mips5000 5000 +-#define bfd_mach_mips5400 5400 +-#define bfd_mach_mips5500 5500 +-#define bfd_mach_mips5900 5900 +-#define bfd_mach_mips6000 6000 +-#define bfd_mach_mips7000 7000 +-#define bfd_mach_mips8000 8000 +-#define bfd_mach_mips9000 9000 +-#define bfd_mach_mips10000 10000 +-#define bfd_mach_mips12000 12000 +-#define bfd_mach_mips14000 14000 +-#define bfd_mach_mips16000 16000 +-#define bfd_mach_mips16 16 +-#define bfd_mach_mips5 5 +-#define bfd_mach_mips_allegrex 10111431 /* octal 'AL', 31. */ +-#define bfd_mach_mips_loongson_2e 3001 +-#define bfd_mach_mips_loongson_2f 3002 +-#define bfd_mach_mips_gs464 3003 +-#define bfd_mach_mips_gs464e 3004 +-#define bfd_mach_mips_gs264e 3005 +-#define bfd_mach_mips_sb1 12310201 /* octal 'SB', 01. */ +-#define bfd_mach_mips_octeon 6501 +-#define bfd_mach_mips_octeonp 6601 +-#define bfd_mach_mips_octeon2 6502 +-#define bfd_mach_mips_octeon3 6503 +-#define bfd_mach_mips_xlr 887682 /* decimal 'XLR'. */ +-#define bfd_mach_mips_interaptiv_mr2 736550 /* decimal 'IA2'. */ +-#define bfd_mach_mipsisa32 32 +-#define bfd_mach_mipsisa32r2 33 +-#define bfd_mach_mipsisa32r3 34 +-#define bfd_mach_mipsisa32r5 36 +-#define bfd_mach_mipsisa32r6 37 +-#define bfd_mach_mipsisa64 64 +-#define bfd_mach_mipsisa64r2 65 +-#define bfd_mach_mipsisa64r3 66 +-#define bfd_mach_mipsisa64r5 68 +-#define bfd_mach_mipsisa64r6 69 +-#define bfd_mach_mips_micromips 96 +- bfd_arch_i386, /* Intel 386. */ +-#define bfd_mach_i386_intel_syntax (1 << 0) +-#define bfd_mach_i386_i8086 (1 << 1) +-#define bfd_mach_i386_i386 (1 << 2) +-#define bfd_mach_x86_64 (1 << 3) +-#define bfd_mach_x64_32 (1 << 4) +-#define bfd_mach_i386_i386_intel_syntax (bfd_mach_i386_i386 | bfd_mach_i386_intel_syntax) +-#define bfd_mach_x86_64_intel_syntax (bfd_mach_x86_64 | bfd_mach_i386_intel_syntax) +-#define bfd_mach_x64_32_intel_syntax (bfd_mach_x64_32 | bfd_mach_i386_intel_syntax) +- bfd_arch_iamcu, /* Intel MCU. */ +-#define bfd_mach_iamcu (1 << 8) +-#define bfd_mach_i386_iamcu (bfd_mach_i386_i386 | bfd_mach_iamcu) +-#define bfd_mach_i386_iamcu_intel_syntax (bfd_mach_i386_iamcu | bfd_mach_i386_intel_syntax) +- bfd_arch_romp, /* IBM ROMP PC/RT. */ +- bfd_arch_convex, /* Convex. */ +- bfd_arch_m98k, /* Motorola 98xxx. */ +- bfd_arch_pyramid, /* Pyramid Technology. */ +- bfd_arch_h8300, /* Renesas H8/300 (formerly Hitachi H8/300). */ +-#define bfd_mach_h8300 1 +-#define bfd_mach_h8300h 2 +-#define bfd_mach_h8300s 3 +-#define bfd_mach_h8300hn 4 +-#define bfd_mach_h8300sn 5 +-#define bfd_mach_h8300sx 6 +-#define bfd_mach_h8300sxn 7 +- bfd_arch_pdp11, /* DEC PDP-11. */ +- bfd_arch_powerpc, /* PowerPC. */ +-#define bfd_mach_ppc 32 +-#define bfd_mach_ppc64 64 +-#define bfd_mach_ppc_403 403 +-#define bfd_mach_ppc_403gc 4030 +-#define bfd_mach_ppc_405 405 +-#define bfd_mach_ppc_505 505 +-#define bfd_mach_ppc_601 601 +-#define bfd_mach_ppc_602 602 +-#define bfd_mach_ppc_603 603 +-#define bfd_mach_ppc_ec603e 6031 +-#define bfd_mach_ppc_604 604 +-#define bfd_mach_ppc_620 620 +-#define bfd_mach_ppc_630 630 +-#define bfd_mach_ppc_750 750 +-#define bfd_mach_ppc_860 860 +-#define bfd_mach_ppc_a35 35 +-#define bfd_mach_ppc_rs64ii 642 +-#define bfd_mach_ppc_rs64iii 643 +-#define bfd_mach_ppc_7400 7400 +-#define bfd_mach_ppc_e500 500 +-#define bfd_mach_ppc_e500mc 5001 +-#define bfd_mach_ppc_e500mc64 5005 +-#define bfd_mach_ppc_e5500 5006 +-#define bfd_mach_ppc_e6500 5007 +-#define bfd_mach_ppc_titan 83 +-#define bfd_mach_ppc_vle 84 +- bfd_arch_rs6000, /* IBM RS/6000. */ +-#define bfd_mach_rs6k 6000 +-#define bfd_mach_rs6k_rs1 6001 +-#define bfd_mach_rs6k_rsc 6003 +-#define bfd_mach_rs6k_rs2 6002 +- bfd_arch_hppa, /* HP PA RISC. */ +-#define bfd_mach_hppa10 10 +-#define bfd_mach_hppa11 11 +-#define bfd_mach_hppa20 20 +-#define bfd_mach_hppa20w 25 +- bfd_arch_d10v, /* Mitsubishi D10V. */ +-#define bfd_mach_d10v 1 +-#define bfd_mach_d10v_ts2 2 +-#define bfd_mach_d10v_ts3 3 +- bfd_arch_d30v, /* Mitsubishi D30V. */ +- bfd_arch_dlx, /* DLX. */ +- bfd_arch_m68hc11, /* Motorola 68HC11. */ +- bfd_arch_m68hc12, /* Motorola 68HC12. */ +-#define bfd_mach_m6812_default 0 +-#define bfd_mach_m6812 1 +-#define bfd_mach_m6812s 2 +- bfd_arch_m9s12x, /* Freescale S12X. */ +- bfd_arch_m9s12xg, /* Freescale XGATE. */ +- bfd_arch_s12z, /* Freescale S12Z. */ +-#define bfd_mach_s12z_default 0 +- bfd_arch_z8k, /* Zilog Z8000. */ +-#define bfd_mach_z8001 1 +-#define bfd_mach_z8002 2 +- bfd_arch_sh, /* Renesas / SuperH SH (formerly Hitachi SH). */ +-#define bfd_mach_sh 1 +-#define bfd_mach_sh2 0x20 +-#define bfd_mach_sh_dsp 0x2d +-#define bfd_mach_sh2a 0x2a +-#define bfd_mach_sh2a_nofpu 0x2b +-#define bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu 0x2a1 +-#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2 +-#define bfd_mach_sh2a_or_sh4 0x2a3 +-#define bfd_mach_sh2a_or_sh3e 0x2a4 +-#define bfd_mach_sh2e 0x2e +-#define bfd_mach_sh3 0x30 +-#define bfd_mach_sh3_nommu 0x31 +-#define bfd_mach_sh3_dsp 0x3d +-#define bfd_mach_sh3e 0x3e +-#define bfd_mach_sh4 0x40 +-#define bfd_mach_sh4_nofpu 0x41 +-#define bfd_mach_sh4_nommu_nofpu 0x42 +-#define bfd_mach_sh4a 0x4a +-#define bfd_mach_sh4a_nofpu 0x4b +-#define bfd_mach_sh4al_dsp 0x4d +- bfd_arch_alpha, /* Dec Alpha. */ +-#define bfd_mach_alpha_ev4 0x10 +-#define bfd_mach_alpha_ev5 0x20 +-#define bfd_mach_alpha_ev6 0x30 +- bfd_arch_arm, /* Advanced Risc Machines ARM. */ +-#define bfd_mach_arm_unknown 0 +-#define bfd_mach_arm_2 1 +-#define bfd_mach_arm_2a 2 +-#define bfd_mach_arm_3 3 +-#define bfd_mach_arm_3M 4 +-#define bfd_mach_arm_4 5 +-#define bfd_mach_arm_4T 6 +-#define bfd_mach_arm_5 7 +-#define bfd_mach_arm_5T 8 +-#define bfd_mach_arm_5TE 9 +-#define bfd_mach_arm_XScale 10 +-#define bfd_mach_arm_ep9312 11 +-#define bfd_mach_arm_iWMMXt 12 +-#define bfd_mach_arm_iWMMXt2 13 +-#define bfd_mach_arm_5TEJ 14 +-#define bfd_mach_arm_6 15 +-#define bfd_mach_arm_6KZ 16 +-#define bfd_mach_arm_6T2 17 +-#define bfd_mach_arm_6K 18 +-#define bfd_mach_arm_7 19 +-#define bfd_mach_arm_6M 20 +-#define bfd_mach_arm_6SM 21 +-#define bfd_mach_arm_7EM 22 +-#define bfd_mach_arm_8 23 +-#define bfd_mach_arm_8R 24 +-#define bfd_mach_arm_8M_BASE 25 +-#define bfd_mach_arm_8M_MAIN 26 +-#define bfd_mach_arm_8_1M_MAIN 27 +-#define bfd_mach_arm_9 28 +- bfd_arch_nds32, /* Andes NDS32. */ +-#define bfd_mach_n1 1 +-#define bfd_mach_n1h 2 +-#define bfd_mach_n1h_v2 3 +-#define bfd_mach_n1h_v3 4 +-#define bfd_mach_n1h_v3m 5 +- bfd_arch_ns32k, /* National Semiconductors ns32000. */ +- bfd_arch_tic30, /* Texas Instruments TMS320C30. */ +- bfd_arch_tic4x, /* Texas Instruments TMS320C3X/4X. */ +-#define bfd_mach_tic3x 30 +-#define bfd_mach_tic4x 40 +- bfd_arch_tic54x, /* Texas Instruments TMS320C54X. */ +- bfd_arch_tic6x, /* Texas Instruments TMS320C6X. */ +- bfd_arch_v850, /* NEC V850. */ +- bfd_arch_v850_rh850,/* NEC V850 (using RH850 ABI). */ +-#define bfd_mach_v850 1 +-#define bfd_mach_v850e 'E' +-#define bfd_mach_v850e1 '1' +-#define bfd_mach_v850e2 0x4532 +-#define bfd_mach_v850e2v3 0x45325633 +-#define bfd_mach_v850e3v5 0x45335635 /* ('E'|'3'|'V'|'5'). */ +- bfd_arch_arc, /* ARC Cores. */ +-#define bfd_mach_arc_a4 0 +-#define bfd_mach_arc_a5 1 +-#define bfd_mach_arc_arc600 2 +-#define bfd_mach_arc_arc601 4 +-#define bfd_mach_arc_arc700 3 +-#define bfd_mach_arc_arcv2 5 +- bfd_arch_m32c, /* Renesas M16C/M32C. */ +-#define bfd_mach_m16c 0x75 +-#define bfd_mach_m32c 0x78 +- bfd_arch_m32r, /* Renesas M32R (formerly Mitsubishi M32R/D). */ +-#define bfd_mach_m32r 1 /* For backwards compatibility. */ +-#define bfd_mach_m32rx 'x' +-#define bfd_mach_m32r2 '2' +- bfd_arch_mn10200, /* Matsushita MN10200. */ +- bfd_arch_mn10300, /* Matsushita MN10300. */ +-#define bfd_mach_mn10300 300 +-#define bfd_mach_am33 330 +-#define bfd_mach_am33_2 332 +- bfd_arch_fr30, +-#define bfd_mach_fr30 0x46523330 +- bfd_arch_frv, +-#define bfd_mach_frv 1 +-#define bfd_mach_frvsimple 2 +-#define bfd_mach_fr300 300 +-#define bfd_mach_fr400 400 +-#define bfd_mach_fr450 450 +-#define bfd_mach_frvtomcat 499 /* fr500 prototype. */ +-#define bfd_mach_fr500 500 +-#define bfd_mach_fr550 550 +- bfd_arch_moxie, /* The moxie processor. */ +-#define bfd_mach_moxie 1 +- bfd_arch_ft32, /* The ft32 processor. */ +-#define bfd_mach_ft32 1 +-#define bfd_mach_ft32b 2 +- bfd_arch_mcore, +- bfd_arch_mep, +-#define bfd_mach_mep 1 +-#define bfd_mach_mep_h1 0x6831 +-#define bfd_mach_mep_c5 0x6335 +- bfd_arch_metag, +-#define bfd_mach_metag 1 +- bfd_arch_ia64, /* HP/Intel ia64. */ +-#define bfd_mach_ia64_elf64 64 +-#define bfd_mach_ia64_elf32 32 +- bfd_arch_ip2k, /* Ubicom IP2K microcontrollers. */ +-#define bfd_mach_ip2022 1 +-#define bfd_mach_ip2022ext 2 +- bfd_arch_iq2000, /* Vitesse IQ2000. */ +-#define bfd_mach_iq2000 1 +-#define bfd_mach_iq10 2 +- bfd_arch_bpf, /* Linux eBPF. */ +-#define bfd_mach_bpf 1 +-#define bfd_mach_xbpf 2 +- bfd_arch_epiphany, /* Adapteva EPIPHANY. */ +-#define bfd_mach_epiphany16 1 +-#define bfd_mach_epiphany32 2 +- bfd_arch_mt, +-#define bfd_mach_ms1 1 +-#define bfd_mach_mrisc2 2 +-#define bfd_mach_ms2 3 +- bfd_arch_pj, +- bfd_arch_avr, /* Atmel AVR microcontrollers. */ +-#define bfd_mach_avr1 1 +-#define bfd_mach_avr2 2 +-#define bfd_mach_avr25 25 +-#define bfd_mach_avr3 3 +-#define bfd_mach_avr31 31 +-#define bfd_mach_avr35 35 +-#define bfd_mach_avr4 4 +-#define bfd_mach_avr5 5 +-#define bfd_mach_avr51 51 +-#define bfd_mach_avr6 6 +-#define bfd_mach_avrtiny 100 +-#define bfd_mach_avrxmega1 101 +-#define bfd_mach_avrxmega2 102 +-#define bfd_mach_avrxmega3 103 +-#define bfd_mach_avrxmega4 104 +-#define bfd_mach_avrxmega5 105 +-#define bfd_mach_avrxmega6 106 +-#define bfd_mach_avrxmega7 107 +- bfd_arch_bfin, /* ADI Blackfin. */ +-#define bfd_mach_bfin 1 +- bfd_arch_cr16, /* National Semiconductor CompactRISC (ie CR16). */ +-#define bfd_mach_cr16 1 +- bfd_arch_crx, /* National Semiconductor CRX. */ +-#define bfd_mach_crx 1 +- bfd_arch_cris, /* Axis CRIS. */ +-#define bfd_mach_cris_v0_v10 255 +-#define bfd_mach_cris_v32 32 +-#define bfd_mach_cris_v10_v32 1032 +- bfd_arch_riscv, +-#define bfd_mach_riscv32 132 +-#define bfd_mach_riscv64 164 +- bfd_arch_rl78, +-#define bfd_mach_rl78 0x75 +- bfd_arch_rx, /* Renesas RX. */ +-#define bfd_mach_rx 0x75 +-#define bfd_mach_rx_v2 0x76 +-#define bfd_mach_rx_v3 0x77 +- bfd_arch_s390, /* IBM s390. */ +-#define bfd_mach_s390_31 31 +-#define bfd_mach_s390_64 64 +- bfd_arch_score, /* Sunplus score. */ +-#define bfd_mach_score3 3 +-#define bfd_mach_score7 7 +- bfd_arch_mmix, /* Donald Knuth's educational processor. */ +- bfd_arch_xstormy16, +-#define bfd_mach_xstormy16 1 +- bfd_arch_msp430, /* Texas Instruments MSP430 architecture. */ +-#define bfd_mach_msp11 11 +-#define bfd_mach_msp110 110 +-#define bfd_mach_msp12 12 +-#define bfd_mach_msp13 13 +-#define bfd_mach_msp14 14 +-#define bfd_mach_msp15 15 +-#define bfd_mach_msp16 16 +-#define bfd_mach_msp20 20 +-#define bfd_mach_msp21 21 +-#define bfd_mach_msp22 22 +-#define bfd_mach_msp23 23 +-#define bfd_mach_msp24 24 +-#define bfd_mach_msp26 26 +-#define bfd_mach_msp31 31 +-#define bfd_mach_msp32 32 +-#define bfd_mach_msp33 33 +-#define bfd_mach_msp41 41 +-#define bfd_mach_msp42 42 +-#define bfd_mach_msp43 43 +-#define bfd_mach_msp44 44 +-#define bfd_mach_msp430x 45 +-#define bfd_mach_msp46 46 +-#define bfd_mach_msp47 47 +-#define bfd_mach_msp54 54 +- bfd_arch_xgate, /* Freescale XGATE. */ +-#define bfd_mach_xgate 1 +- bfd_arch_xtensa, /* Tensilica's Xtensa cores. */ +-#define bfd_mach_xtensa 1 +- bfd_arch_z80, +-/* Zilog Z80 without undocumented opcodes. */ +-#define bfd_mach_z80strict 1 +-/* Zilog Z180: successor with additional instructions, but without +- halves of ix and iy. */ +-#define bfd_mach_z180 2 +-/* Zilog Z80 with ixl, ixh, iyl, and iyh. */ +-#define bfd_mach_z80 3 +-/* Zilog eZ80 (successor of Z80 & Z180) in Z80 (16-bit address) mode. */ +-#define bfd_mach_ez80_z80 4 +-/* Zilog eZ80 (successor of Z80 & Z180) in ADL (24-bit address) mode. */ +-#define bfd_mach_ez80_adl 5 +-/* Z80N */ +-#define bfd_mach_z80n 6 +-/* Zilog Z80 with all undocumented instructions. */ +-#define bfd_mach_z80full 7 +-/* GameBoy Z80 (reduced instruction set). */ +-#define bfd_mach_gbz80 8 +-/* ASCII R800: successor with multiplication. */ +-#define bfd_mach_r800 11 +- 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 +-#define bfd_mach_tilegx 1 +-#define bfd_mach_tilegx32 2 +- bfd_arch_aarch64, /* AArch64. */ +-#define bfd_mach_aarch64 0 +-#define bfd_mach_aarch64_8R 1 +-#define bfd_mach_aarch64_ilp32 32 +-#define bfd_mach_aarch64_llp64 64 +- bfd_arch_nios2, /* Nios II. */ +-#define bfd_mach_nios2 0 +-#define bfd_mach_nios2r1 1 +-#define bfd_mach_nios2r2 2 +- bfd_arch_visium, /* Visium. */ +-#define bfd_mach_visium 1 +- bfd_arch_wasm32, /* WebAssembly. */ +-#define bfd_mach_wasm32 1 +- bfd_arch_pru, /* PRU. */ +-#define bfd_mach_pru 0 +- bfd_arch_nfp, /* Netronome Flow Processor */ +-#define bfd_mach_nfp3200 0x3200 +-#define bfd_mach_nfp6000 0x6000 +- bfd_arch_csky, /* C-SKY. */ +-#define bfd_mach_ck_unknown 0 +-#define bfd_mach_ck510 1 +-#define bfd_mach_ck610 2 +-#define bfd_mach_ck801 3 +-#define bfd_mach_ck802 4 +-#define bfd_mach_ck803 5 +-#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_amdgcn, /* AMDGCN */ +-#define bfd_mach_amdgcn_unknown 0x000 +-#define bfd_mach_amdgcn_gfx900 0x02c +-#define bfd_mach_amdgcn_gfx904 0x02e +-#define bfd_mach_amdgcn_gfx906 0x02f +-#define bfd_mach_amdgcn_gfx908 0x030 +-#define bfd_mach_amdgcn_gfx90a 0x03f +-#define bfd_mach_amdgcn_gfx1010 0x033 +-#define bfd_mach_amdgcn_gfx1011 0x034 +-#define bfd_mach_amdgcn_gfx1012 0x035 +-#define bfd_mach_amdgcn_gfx1030 0x036 +-#define bfd_mach_amdgcn_gfx1031 0x037 +-#define bfd_mach_amdgcn_gfx1032 0x038 +- bfd_arch_last +- @}; +-@end example +- +-@subsection bfd_arch_info +- +- +-This structure contains information on architectures for use +-within BFD. +-@example +- +-typedef struct bfd_arch_info +-@{ +- int bits_per_word; +- int bits_per_address; +- int bits_per_byte; +- enum bfd_architecture arch; +- unsigned long mach; +- const char *arch_name; +- const char *printable_name; +- unsigned int section_align_power; +- /* TRUE if this is the default machine for the architecture. +- The default arch should be the first entry for an arch so that +- all the entries for that arch can be accessed via @code{next}. */ +- bool the_default; +- const struct bfd_arch_info * (*compatible) (const struct bfd_arch_info *, +- const struct bfd_arch_info *); +- +- bool (*scan) (const struct bfd_arch_info *, const char *); +- +- /* Allocate via bfd_malloc and return a fill buffer of size COUNT. If +- IS_BIGENDIAN is TRUE, the order of bytes is big endian. If CODE is +- TRUE, the buffer contains code. */ +- void *(*fill) (bfd_size_type count, bool is_bigendian, bool code); +- +- const struct bfd_arch_info *next; +- +- /* On some architectures the offset for a relocation can point into +- the middle of an instruction. This field specifies the maximum +- offset such a relocation can have (in octets). This affects the +- behaviour of the disassembler, since a value greater than zero +- means that it may need to disassemble an instruction twice, once +- to get its length and then a second time to display it. If the +- value is negative then this has to be done for every single +- instruction, regardless of the offset of the reloc. */ +- signed int max_reloc_offset_into_insn; +-@} +-bfd_arch_info_type; +- +-@end example +- +-@findex bfd_printable_name +-@subsubsection @code{bfd_printable_name} +-@deftypefn {Function} const char *bfd_printable_name (bfd *abfd); +-Return a printable string representing the architecture and machine +-from the pointer to the architecture info structure. +- +-@end deftypefn +-@findex bfd_scan_arch +-@subsubsection @code{bfd_scan_arch} +-@deftypefn {Function} const bfd_arch_info_type *bfd_scan_arch (const char *string); +-Figure out if BFD supports any cpu which could be described with +-the name @var{string}. Return a pointer to an @code{arch_info} +-structure if a machine is found, otherwise NULL. +- +-@end deftypefn +-@findex bfd_arch_list +-@subsubsection @code{bfd_arch_list} +-@deftypefn {Function} const char **bfd_arch_list (void); +-Return a freshly malloced NULL-terminated vector of the names +-of all the valid BFD architectures. Do not modify the names. +- +-@end deftypefn +-@findex bfd_arch_get_compatible +-@subsubsection @code{bfd_arch_get_compatible} +-@deftypefn {Function} const bfd_arch_info_type *bfd_arch_get_compatible (const bfd *abfd, const bfd *bbfd, bool accept_unknowns); +-Determine whether two BFDs' architectures and machine types +-are compatible. Calculates the lowest common denominator +-between the two architectures and machine types implied by +-the BFDs and returns a pointer to an @code{arch_info} structure +-describing the compatible machine. +- +-@end deftypefn +-@findex bfd_default_arch_struct +-@subsubsection @code{bfd_default_arch_struct} +-The @code{bfd_default_arch_struct} is an item of +-@code{bfd_arch_info_type} which has been initialized to a fairly +-generic state. A BFD starts life by pointing to this +-structure, until the correct back end has determined the real +-architecture of the file. +-@example +-extern const bfd_arch_info_type bfd_default_arch_struct; +- +-@end example +- +-@findex bfd_set_arch_info +-@subsubsection @code{bfd_set_arch_info} +-@deftypefn {Function} void bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg); +-Set the architecture info of @var{abfd} to @var{arg}. +- +-@end deftypefn +-@findex bfd_default_set_arch_mach +-@subsubsection @code{bfd_default_set_arch_mach} +-@deftypefn {Function} bool bfd_default_set_arch_mach (bfd *abfd, enum bfd_architecture arch, unsigned long mach); +-Set the architecture and machine type in BFD @var{abfd} +-to @var{arch} and @var{mach}. Find the correct +-pointer to a structure and insert it into the @code{arch_info} +-pointer. +- +-@end deftypefn +-@findex bfd_get_arch +-@subsubsection @code{bfd_get_arch} +-@deftypefn {Function} enum bfd_architecture bfd_get_arch (const bfd *abfd); +-Return the enumerated type which describes the BFD @var{abfd}'s +-architecture. +- +-@end deftypefn +-@findex bfd_get_mach +-@subsubsection @code{bfd_get_mach} +-@deftypefn {Function} unsigned long bfd_get_mach (const bfd *abfd); +-Return the long type which describes the BFD @var{abfd}'s +-machine. +- +-@end deftypefn +-@findex bfd_arch_bits_per_byte +-@subsubsection @code{bfd_arch_bits_per_byte} +-@deftypefn {Function} unsigned int bfd_arch_bits_per_byte (const bfd *abfd); +-Return the number of bits in one of the BFD @var{abfd}'s +-architecture's bytes. +- +-@end deftypefn +-@findex bfd_arch_bits_per_address +-@subsubsection @code{bfd_arch_bits_per_address} +-@deftypefn {Function} unsigned int bfd_arch_bits_per_address (const bfd *abfd); +-Return the number of bits in one of the BFD @var{abfd}'s +-architecture's addresses. +- +-@end deftypefn +-@findex bfd_default_compatible +-@subsubsection @code{bfd_default_compatible} +-@deftypefn {Function} const bfd_arch_info_type *bfd_default_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b); +-The default function for testing for compatibility. +- +-@end deftypefn +-@findex bfd_default_scan +-@subsubsection @code{bfd_default_scan} +-@deftypefn {Function} bool bfd_default_scan (const struct bfd_arch_info *info, const char *string); +-The default function for working out whether this is an +-architecture hit and a machine hit. +- +-@end deftypefn +-@findex bfd_get_arch_info +-@subsubsection @code{bfd_get_arch_info} +-@deftypefn {Function} const bfd_arch_info_type *bfd_get_arch_info (bfd *abfd); +-Return the architecture info struct in @var{abfd}. +- +-@end deftypefn +-@findex bfd_lookup_arch +-@subsubsection @code{bfd_lookup_arch} +-@deftypefn {Function} const bfd_arch_info_type *bfd_lookup_arch (enum bfd_architecture arch, unsigned long machine); +-Look for the architecture info structure which matches the +-arguments @var{arch} and @var{machine}. A machine of 0 matches the +-machine/architecture structure which marks itself as the +-default. +- +-@end deftypefn +-@findex bfd_printable_arch_mach +-@subsubsection @code{bfd_printable_arch_mach} +-@deftypefn {Function} const char *bfd_printable_arch_mach (enum bfd_architecture arch, unsigned long machine); +-Return a printable string representing the architecture and +-machine type. +- +-This routine is depreciated. +- +-@end deftypefn +-@findex bfd_octets_per_byte +-@subsubsection @code{bfd_octets_per_byte} +-@deftypefn {Function} unsigned int bfd_octets_per_byte (const bfd *abfd, const asection *sec); +-Return the number of octets (8-bit quantities) per target byte +-(minimum addressable unit). In most cases, this will be one, but some +-DSP targets have 16, 32, or even 48 bits per byte. +- +-@end deftypefn +-@findex bfd_arch_mach_octets_per_byte +-@subsubsection @code{bfd_arch_mach_octets_per_byte} +-@deftypefn {Function} unsigned int bfd_arch_mach_octets_per_byte (enum bfd_architecture arch, unsigned long machine); +-See bfd_octets_per_byte. +- +-This routine is provided for those cases where a bfd * is not +-available +- +-@end deftypefn +-@findex bfd_arch_default_fill +-@subsubsection @code{bfd_arch_default_fill} +-@deftypefn {Function} void *bfd_arch_default_fill (bfd_size_type count, bool is_bigendian, bool code); +-Allocate via bfd_malloc and return a fill buffer of size COUNT. +-If IS_BIGENDIAN is TRUE, the order of bytes is big endian. If +-CODE is TRUE, the buffer contains code. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/bfdio.texi gdb-14.1-sw64/bfd/doc/bfdio.texi +--- gdb-14.1-after-patch/bfd/doc/bfdio.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/bfdio.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,146 +0,0 @@ +-@findex struct bfd_iovec +-@subsubsection @code{struct bfd_iovec} +-The @code{struct bfd_iovec} contains the internal file I/O class. +-Each @code{BFD} has an instance of this class and all file I/O is +-routed through it (it is assumed that the instance implements +-all methods listed below). +-@example +-struct bfd_iovec +-@{ +- /* To avoid problems with macros, a "b" rather than "f" +- prefix is prepended to each method name. */ +- /* Attempt to read/write NBYTES on ABFD's IOSTREAM storing/fetching +- bytes starting at PTR. Return the number of bytes actually +- transfered (a read past end-of-file returns less than NBYTES), +- or -1 (setting @code{bfd_error}) if an error occurs. */ +- file_ptr (*bread) (struct bfd *abfd, void *ptr, file_ptr nbytes); +- file_ptr (*bwrite) (struct bfd *abfd, const void *ptr, +- file_ptr nbytes); +- /* Return the current IOSTREAM file offset, or -1 (setting @code{bfd_error} +- if an error occurs. */ +- file_ptr (*btell) (struct bfd *abfd); +- /* For the following, on successful completion a value of 0 is returned. +- Otherwise, a value of -1 is returned (and @code{bfd_error} is set). */ +- int (*bseek) (struct bfd *abfd, file_ptr offset, int whence); +- int (*bclose) (struct bfd *abfd); +- int (*bflush) (struct bfd *abfd); +- int (*bstat) (struct bfd *abfd, struct stat *sb); +- /* Mmap a part of the files. ADDR, LEN, PROT, FLAGS and OFFSET are the usual +- mmap parameter, except that LEN and OFFSET do not need to be page +- aligned. Returns (void *)-1 on failure, mmapped address on success. +- Also write in MAP_ADDR the address of the page aligned buffer and in +- MAP_LEN the size mapped (a page multiple). Use unmap with MAP_ADDR and +- MAP_LEN to unmap. */ +- void *(*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len, +- int prot, int flags, file_ptr offset, +- void **map_addr, bfd_size_type *map_len); +-@}; +-extern const struct bfd_iovec _bfd_memory_iovec; +- +-@end example +- +-@findex bfd_read +-@subsubsection @code{bfd_read} +-@deftypefn {Function} bfd_size_type bfd_read (void *, bfd_size_type, bfd *) ATTRIBUTE_WARN_UNUSED_RESULT; +-Attempt to read SIZE bytes from ABFD's iostream to PTR. +-Return the amount read. +- +-@end deftypefn +-@findex bfd_write +-@subsubsection @code{bfd_write} +-@deftypefn {Function} bfd_size_type bfd_write (const void *, bfd_size_type, bfd *) ATTRIBUTE_WARN_UNUSED_RESULT; +-Attempt to write SIZE bytes to ABFD's iostream from PTR. +-Return the amount written. +- +-@end deftypefn +-@findex bfd_tell +-@subsubsection @code{bfd_tell} +-@deftypefn {Function} file_ptr bfd_tell (bfd *) ATTRIBUTE_WARN_UNUSED_RESULT; +-Return ABFD's iostream file position. +- +-@end deftypefn +-@findex bfd_flush +-@subsubsection @code{bfd_flush} +-@deftypefn {Function} int bfd_flush (bfd *); +-Flush ABFD's iostream pending IO. +- +-@end deftypefn +-@findex bfd_stat +-@subsubsection @code{bfd_stat} +-@deftypefn {Function} int bfd_stat (bfd *, struct stat *) ATTRIBUTE_WARN_UNUSED_RESULT; +-Call fstat on ABFD's iostream. Return 0 on success, and a +-negative value on failure. +- +-@end deftypefn +-@findex bfd_seek +-@subsubsection @code{bfd_seek} +-@deftypefn {Function} int bfd_seek (bfd *, file_ptr, int) ATTRIBUTE_WARN_UNUSED_RESULT; +-Call fseek on ABFD's iostream. Return 0 on success, and a +-negative value on failure. +- +-@end deftypefn +-@findex bfd_get_mtime +-@subsubsection @code{bfd_get_mtime} +-@deftypefn {Function} long bfd_get_mtime (bfd *abfd); +-Return the file modification time (as read from the file system, or +-from the archive header for archive members). +- +-@end deftypefn +-@findex bfd_get_size +-@subsubsection @code{bfd_get_size} +-@deftypefn {Function} ufile_ptr bfd_get_size (bfd *abfd); +-Return the file size (as read from file system) for the file +-associated with BFD @var{abfd}. +- +-The initial motivation for, and use of, this routine is not +-so we can get the exact size of the object the BFD applies to, since +-that might not be generally possible (archive members for example). +-It would be ideal if someone could eventually modify +-it so that such results were guaranteed. +- +-Instead, we want to ask questions like "is this NNN byte sized +-object I'm about to try read from file offset YYY reasonable?" +-As as example of where we might do this, some object formats +-use string tables for which the first @code{sizeof (long)} bytes of the +-table contain the size of the table itself, including the size bytes. +-If an application tries to read what it thinks is one of these +-string tables, without some way to validate the size, and for +-some reason the size is wrong (byte swapping error, wrong location +-for the string table, etc.), the only clue is likely to be a read +-error when it tries to read the table, or a "virtual memory +-exhausted" error when it tries to allocate 15 bazillon bytes +-of space for the 15 bazillon byte table it is about to read. +-This function at least allows us to answer the question, "is the +-size reasonable?". +- +-A return value of zero indicates the file size is unknown. +- +-@end deftypefn +-@findex bfd_get_file_size +-@subsubsection @code{bfd_get_file_size} +-@deftypefn {Function} ufile_ptr bfd_get_file_size (bfd *abfd); +-Return the file size (as read from file system) for the file +-associated with BFD @var{abfd}. It supports both normal files +-and archive elements. +- +-@end deftypefn +-@findex bfd_mmap +-@subsubsection @code{bfd_mmap} +-@deftypefn {Function} void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len, int prot, int flags, file_ptr offset, void **map_addr, bfd_size_type *map_len) ATTRIBUTE_WARN_UNUSED_RESULT; +-Return mmap()ed region of the file, if possible and implemented. +-LEN and OFFSET do not need to be page aligned. The page aligned +-address and length are written to MAP_ADDR and MAP_LEN. +- +-@end deftypefn +-@findex bfd_get_current_time +-@subsubsection @code{bfd_get_current_time} +-@deftypefn {Function} time_t bfd_get_current_time (time_t now); +-Returns the current time. +- +-If the environment variable SOURCE_DATE_EPOCH is defined +-then this is parsed and its value is returned. Otherwise +-if the paramter NOW is non-zero, then that is returned. +-Otherwise the result of the system call "time(NULL)" is +-returned. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/bfdt.texi gdb-14.1-sw64/bfd/doc/bfdt.texi +--- gdb-14.1-after-patch/bfd/doc/bfdt.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/bfdt.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,895 +0,0 @@ +-@node typedef bfd, Error reporting, BFD front end, BFD front end +-@section @code{typedef bfd} +-A BFD has type @code{bfd}; objects of this type are the +-cornerstone of any application using BFD. Using BFD +-consists of making references though the BFD and to data in the BFD. +- +-Here is the structure that defines the type @code{bfd}. It +-contains the major data about the file and pointers +-to the rest of the data. +- +- +-@example +-struct bfd +-@{ +- /* The filename the application opened the BFD with. */ +- const char *filename; +- +- /* A pointer to the target jump table. */ +- const struct bfd_target *xvec; +- +- /* The IOSTREAM, and corresponding IO vector that provide access +- to the file backing the BFD. */ +- void *iostream; +- const struct bfd_iovec *iovec; +- +- /* The caching routines use these to maintain a +- least-recently-used list of BFDs. */ +- struct bfd *lru_prev, *lru_next; +- +- /* Track current file position (or current buffer offset for +- in-memory BFDs). When a file is closed by the caching routines, +- BFD retains state information on the file here. */ +- ufile_ptr where; +- +- /* File modified time, if mtime_set is TRUE. */ +- long mtime; +- +- /* A unique identifier of the BFD */ +- unsigned int id; +- +- /* Format_specific flags. */ +- flagword flags; +- +- /* Values that may appear in the flags field of a BFD. These also +- appear in the object_flags field of the bfd_target structure, where +- they indicate the set of flags used by that backend (not all flags +- are meaningful for all object file formats) (FIXME: at the moment, +- the object_flags values have mostly just been copied from backend +- to another, and are not necessarily correct). */ +- +-#define BFD_NO_FLAGS 0x0 +- +- /* BFD contains relocation entries. */ +-#define HAS_RELOC 0x1 +- +- /* BFD is directly executable. */ +-#define EXEC_P 0x2 +- +- /* BFD has line number information (basically used for F_LNNO in a +- COFF header). */ +-#define HAS_LINENO 0x4 +- +- /* BFD has debugging information. */ +-#define HAS_DEBUG 0x08 +- +- /* BFD has symbols. */ +-#define HAS_SYMS 0x10 +- +- /* BFD has local symbols (basically used for F_LSYMS in a COFF +- header). */ +-#define HAS_LOCALS 0x20 +- +- /* BFD is a dynamic object. */ +-#define DYNAMIC 0x40 +- +- /* Text section is write protected (if D_PAGED is not set, this is +- like an a.out NMAGIC file) (the linker sets this by default, but +- clears it for -r or -N). */ +-#define WP_TEXT 0x80 +- +- /* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the +- linker sets this by default, but clears it for -r or -n or -N). */ +-#define D_PAGED 0x100 +- +- /* BFD is relaxable (this means that bfd_relax_section may be able to +- do something) (sometimes bfd_relax_section can do something even if +- this is not set). */ +-#define BFD_IS_RELAXABLE 0x200 +- +- /* This may be set before writing out a BFD to request using a +- traditional format. For example, this is used to request that when +- writing out an a.out object the symbols not be hashed to eliminate +- duplicates. */ +-#define BFD_TRADITIONAL_FORMAT 0x400 +- +- /* This flag indicates that the BFD contents are actually cached +- in memory. If this is set, iostream points to a bfd_in_memory +- struct. */ +-#define BFD_IN_MEMORY 0x800 +- +- /* This BFD has been created by the linker and doesn't correspond +- to any input file. */ +-#define BFD_LINKER_CREATED 0x1000 +- +- /* This may be set before writing out a BFD to request that it +- be written using values for UIDs, GIDs, timestamps, etc. that +- will be consistent from run to run. */ +-#define BFD_DETERMINISTIC_OUTPUT 0x2000 +- +- /* Compress sections in this BFD. */ +-#define BFD_COMPRESS 0x4000 +- +- /* Decompress sections in this BFD. */ +-#define BFD_DECOMPRESS 0x8000 +- +- /* BFD is a dummy, for plugins. */ +-#define BFD_PLUGIN 0x10000 +- +- /* Compress sections in this BFD with SHF_COMPRESSED from gABI. */ +-#define BFD_COMPRESS_GABI 0x20000 +- +- /* Convert ELF common symbol type to STT_COMMON or STT_OBJECT in this +- BFD. */ +-#define BFD_CONVERT_ELF_COMMON 0x40000 +- +- /* Use the ELF STT_COMMON type in this BFD. */ +-#define BFD_USE_ELF_STT_COMMON 0x80000 +- +- /* Put pathnames into archives (non-POSIX). */ +-#define BFD_ARCHIVE_FULL_PATH 0x100000 +- +-#define BFD_CLOSED_BY_CACHE 0x200000 +- /* Compress sections in this BFD with SHF_COMPRESSED zstd. */ +-#define BFD_COMPRESS_ZSTD 0x400000 +- +- /* Don't generate ELF section header. */ +-#define BFD_NO_SECTION_HEADER 0x800000 +- +- /* Flags bits which are for BFD use only. */ +-#define BFD_FLAGS_FOR_BFD_USE_MASK \ +- (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \ +- | BFD_PLUGIN | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT \ +- | BFD_COMPRESS_GABI | BFD_CONVERT_ELF_COMMON | BFD_USE_ELF_STT_COMMON \ +- | BFD_NO_SECTION_HEADER) +- +- /* The format which belongs to the BFD. (object, core, etc.) */ +- ENUM_BITFIELD (bfd_format) format : 3; +- +- /* The direction with which the BFD was opened. */ +- ENUM_BITFIELD (bfd_direction) direction : 2; +- +- /* POSIX.1-2017 (IEEE Std 1003.1) says of fopen : "When a file is +- opened with update mode ('+' as the second or third character in +- the mode argument), both input and output may be performed on +- the associated stream. However, the application shall ensure +- that output is not directly followed by input without an +- intervening call to fflush() or to a file positioning function +- (fseek(), fsetpos(), or rewind()), and input is not directly +- followed by output without an intervening call to a file +- positioning function, unless the input operation encounters +- end-of-file." +- This field tracks the last IO operation, so that bfd can insert +- a seek when IO direction changes. */ +- ENUM_BITFIELD (bfd_last_io) last_io : 2; +- +- /* Is the file descriptor being cached? That is, can it be closed as +- needed, and re-opened when accessed later? */ +- unsigned int cacheable : 1; +- +- /* Marks whether there was a default target specified when the +- BFD was opened. This is used to select which matching algorithm +- to use to choose the back end. */ +- unsigned int target_defaulted : 1; +- +- /* ... and here: (``once'' means at least once). */ +- unsigned int opened_once : 1; +- +- /* Set if we have a locally maintained mtime value, rather than +- getting it from the file each time. */ +- unsigned int mtime_set : 1; +- +- /* Flag set if symbols from this BFD should not be exported. */ +- unsigned int no_export : 1; +- +- /* Remember when output has begun, to stop strange things +- from happening. */ +- unsigned int output_has_begun : 1; +- +- /* Have archive map. */ +- unsigned int has_armap : 1; +- +- /* Set if this is a thin archive. */ +- unsigned int is_thin_archive : 1; +- +- /* Set if this archive should not cache element positions. */ +- unsigned int no_element_cache : 1; +- +- /* Set if only required symbols should be added in the link hash table for +- this object. Used by VMS linkers. */ +- unsigned int selective_search : 1; +- +- /* Set if this is the linker output BFD. */ +- unsigned int is_linker_output : 1; +- +- /* Set if this is the linker input BFD. */ +- unsigned int is_linker_input : 1; +- +- /* If this is an input for a compiler plug-in library. */ +- ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2; +- +- /* Set if this is a plugin output file. */ +- unsigned int lto_output : 1; +- +- /* Set if this is a slim LTO object not loaded with a compiler plugin. */ +- unsigned int lto_slim_object : 1; +- +- /* Do not attempt to modify this file. Set when detecting errors +- that BFD is not prepared to handle for objcopy/strip. */ +- unsigned int read_only : 1; +- +- /* Set to dummy BFD created when claimed by a compiler plug-in +- library. */ +- bfd *plugin_dummy_bfd; +- +- /* The offset of this bfd in the file, typically 0 if it is not +- contained in an archive. */ +- ufile_ptr origin; +- +- /* The origin in the archive of the proxy entry. This will +- normally be the same as origin, except for thin archives, +- when it will contain the current offset of the proxy in the +- thin archive rather than the offset of the bfd in its actual +- container. */ +- ufile_ptr proxy_origin; +- +- /* A hash table for section names. */ +- struct bfd_hash_table section_htab; +- +- /* Pointer to linked list of sections. */ +- struct bfd_section *sections; +- +- /* The last section on the section list. */ +- struct bfd_section *section_last; +- +- /* The number of sections. */ +- unsigned int section_count; +- +- /* The archive plugin file descriptor. */ +- int archive_plugin_fd; +- +- /* The number of opens on the archive plugin file descriptor. */ +- unsigned int archive_plugin_fd_open_count; +- +- /* A field used by _bfd_generic_link_add_archive_symbols. This will +- be used only for archive elements. */ +- int archive_pass; +- +- /* The total size of memory from bfd_alloc. */ +- bfd_size_type alloc_size; +- +- /* Stuff only useful for object files: +- The start address. */ +- bfd_vma start_address; +- +- /* Symbol table for output BFD (with symcount entries). +- Also used by the linker to cache input BFD symbols. */ +- struct bfd_symbol **outsymbols; +- +- /* Used for input and output. */ +- unsigned int symcount; +- +- /* Used for slurped dynamic symbol tables. */ +- unsigned int dynsymcount; +- +- /* Pointer to structure which contains architecture information. */ +- const struct bfd_arch_info *arch_info; +- +- /* Cached length of file for bfd_get_size. 0 until bfd_get_size is +- called, 1 if stat returns an error or the file size is too large to +- return in ufile_ptr. Both 0 and 1 should be treated as "unknown". */ +- ufile_ptr size; +- +- /* Stuff only useful for archives. */ +- void *arelt_data; +- struct bfd *my_archive; /* The containing archive BFD. */ +- struct bfd *archive_next; /* The next BFD in the archive. */ +- struct bfd *archive_head; /* The first BFD in the archive. */ +- struct bfd *nested_archives; /* List of nested archive in a flattened +- thin archive. */ +- +- union @{ +- /* For input BFDs, a chain of BFDs involved in a link. */ +- struct bfd *next; +- /* For output BFD, the linker hash table. */ +- struct bfd_link_hash_table *hash; +- @} link; +- +- /* Used by the back end to hold private data. */ +- union +- @{ +- struct aout_data_struct *aout_data; +- struct artdata *aout_ar_data; +- struct coff_tdata *coff_obj_data; +- struct pe_tdata *pe_obj_data; +- struct xcoff_tdata *xcoff_obj_data; +- struct ecoff_tdata *ecoff_obj_data; +- struct srec_data_struct *srec_data; +- struct verilog_data_struct *verilog_data; +- struct ihex_data_struct *ihex_data; +- struct tekhex_data_struct *tekhex_data; +- struct elf_obj_tdata *elf_obj_data; +- struct mmo_data_struct *mmo_data; +- struct trad_core_struct *trad_core_data; +- struct som_data_struct *som_data; +- struct hpux_core_struct *hpux_core_data; +- struct hppabsd_core_struct *hppabsd_core_data; +- struct sgi_core_struct *sgi_core_data; +- struct lynx_core_struct *lynx_core_data; +- struct osf_core_struct *osf_core_data; +- struct cisco_core_struct *cisco_core_data; +- struct netbsd_core_struct *netbsd_core_data; +- struct mach_o_data_struct *mach_o_data; +- struct mach_o_fat_data_struct *mach_o_fat_data; +- struct plugin_data_struct *plugin_data; +- struct bfd_pef_data_struct *pef_data; +- struct bfd_pef_xlib_data_struct *pef_xlib_data; +- struct bfd_sym_data_struct *sym_data; +- void *any; +- @} +- tdata; +- +- /* Used by the application to hold private data. */ +- void *usrdata; +- +- /* Where all the allocated stuff under this BFD goes. This is a +- struct objalloc *, but we use void * to avoid requiring the inclusion +- of objalloc.h. */ +- void *memory; +- +- /* For input BFDs, the build ID, if the object has one. */ +- const struct bfd_build_id *build_id; +-@}; +- +-@end example +-@node Error reporting, Initialization, typedef bfd, BFD front end +-@section Error reporting +-Most BFD functions return nonzero on success (check their +-individual documentation for precise semantics). On an error, +-they call @code{bfd_set_error} to set an error condition that callers +-can check by calling @code{bfd_get_error}. +-If that returns @code{bfd_error_system_call}, then check +-@code{errno}. +- +-The easiest way to report a BFD error to the user is to +-use @code{bfd_perror}. +- +-@subsection Type @code{bfd_error_type} +-The values returned by @code{bfd_get_error} are defined by the +-enumerated type @code{bfd_error_type}. +- +- +-@example +-typedef enum bfd_error +-@{ +- bfd_error_no_error = 0, +- bfd_error_system_call, +- bfd_error_invalid_target, +- bfd_error_wrong_format, +- bfd_error_wrong_object_format, +- bfd_error_invalid_operation, +- bfd_error_no_memory, +- bfd_error_no_symbols, +- bfd_error_no_armap, +- bfd_error_no_more_archived_files, +- bfd_error_malformed_archive, +- bfd_error_missing_dso, +- bfd_error_file_not_recognized, +- bfd_error_file_ambiguously_recognized, +- bfd_error_no_contents, +- bfd_error_nonrepresentable_section, +- bfd_error_no_debug_section, +- bfd_error_bad_value, +- bfd_error_file_truncated, +- bfd_error_file_too_big, +- bfd_error_sorry, +- bfd_error_on_input, +- bfd_error_invalid_error_code +-@} +-bfd_error_type; +- +-@end example +-@findex bfd_get_error +-@subsubsection @code{bfd_get_error} +-@deftypefn {Function} bfd_error_type bfd_get_error (void); +-Return the current BFD error condition. +- +-@end deftypefn +-@findex bfd_set_error +-@subsubsection @code{bfd_set_error} +-@deftypefn {Function} void bfd_set_error (bfd_error_type error_tag); +-Set the BFD error condition to be @var{error_tag}. +- +-@var{error_tag} must not be bfd_error_on_input. Use +-bfd_set_input_error for input errors instead. +- +-@end deftypefn +-@findex bfd_set_input_error +-@subsubsection @code{bfd_set_input_error} +-@deftypefn {Function} void bfd_set_input_error (bfd *input, bfd_error_type error_tag); +-Set the BFD error condition to be bfd_error_on_input. +-@var{input} is the input bfd where the error occurred, and +-@var{error_tag} the bfd_error_type error. +- +-@end deftypefn +-@findex bfd_errmsg +-@subsubsection @code{bfd_errmsg} +-@deftypefn {Function} const char *bfd_errmsg (bfd_error_type error_tag); +-Return a string describing the error @var{error_tag}, or +-the system error if @var{error_tag} is @code{bfd_error_system_call}. +- +-@end deftypefn +-@findex bfd_perror +-@subsubsection @code{bfd_perror} +-@deftypefn {Function} void bfd_perror (const char *message); +-Print to the standard error stream a string describing the +-last BFD error that occurred, or the last system error if +-the last BFD error was a system call failure. If @var{message} +-is non-NULL and non-empty, the error string printed is preceded +-by @var{message}, a colon, and a space. It is followed by a newline. +- +-@end deftypefn +-@findex bfd_asprintf +-@subsubsection @code{bfd_asprintf} +-@deftypefn {Function} char *bfd_asprintf (const char *fmt, ...); +-Primarily for error reporting, this function is like +-libiberty's xasprintf except that it can return NULL on no +-memory and the returned string should not be freed. Uses a +-single malloc'd buffer managed by libbfd, _bfd_error_buf. +-Be aware that a call to this function frees the result of any +-previous call. bfd_errmsg (bfd_error_on_input) also calls +-this function. +- +-@end deftypefn +-@subsection BFD error handler +-Some BFD functions want to print messages describing the +-problem. They call a BFD error handler function. This +-function may be overridden by the program. +- +-The BFD error handler acts like vprintf. +- +- +-@example +-typedef void (*bfd_error_handler_type) (const char *, va_list); +- +-@end example +-@findex _bfd_error_handler +-@subsubsection @code{_bfd_error_handler} +-@deftypefn {Function} void _bfd_error_handler (const char *fmt, ...) ATTRIBUTE_PRINTF_1; +-This is the default routine to handle BFD error messages. +-Like fprintf (stderr, ...), but also handles some extra format +-specifiers. +- +-%pA section name from section. For group components, prints +-group name too. +-%pB file name from bfd. For archive components, prints +-archive too. +- +-Beware: Only supports a maximum of 9 format arguments. +- +-@end deftypefn +-@findex bfd_set_error_handler +-@subsubsection @code{bfd_set_error_handler} +-@deftypefn {Function} bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type); +-Set the BFD error handler function. Returns the previous +-function. +- +-@end deftypefn +-@findex _bfd_set_error_handler_caching +-@subsubsection @code{_bfd_set_error_handler_caching} +-@deftypefn {Function} bfd_error_handler_type _bfd_set_error_handler_caching (bfd *); +-Set the BFD error handler function to one that stores messages +-to the per_xvec_warn array. Returns the previous function. +- +-@end deftypefn +-@findex bfd_set_error_program_name +-@subsubsection @code{bfd_set_error_program_name} +-@deftypefn {Function} void bfd_set_error_program_name (const char *); +-Set the program name to use when printing a BFD error. This +-is printed before the error message followed by a colon and +-space. The string must not be changed after it is passed to +-this function. +- +-@end deftypefn +-@findex _bfd_get_error_program_name +-@subsubsection @code{_bfd_get_error_program_name} +-@deftypefn {Function} const char *_bfd_get_error_program_name (void); +-Get the program name used when printing a BFD error. +- +-@end deftypefn +-@subsection BFD assert handler +-If BFD finds an internal inconsistency, the bfd assert +-handler is called with information on the BFD version, BFD +-source file and line. If this happens, most programs linked +-against BFD are expected to want to exit with an error, or mark +-the current BFD operation as failed, so it is recommended to +-override the default handler, which just calls +-_bfd_error_handler and continues. +- +- +-@example +-typedef void (*bfd_assert_handler_type) (const char *bfd_formatmsg, +- const char *bfd_version, +- const char *bfd_file, +- int bfd_line); +- +-@end example +-@findex bfd_set_assert_handler +-@subsubsection @code{bfd_set_assert_handler} +-@deftypefn {Function} bfd_assert_handler_type bfd_set_assert_handler (bfd_assert_handler_type); +-Set the BFD assert handler function. Returns the previous +-function. +- +-@end deftypefn +-@node Initialization, Miscellaneous, Error reporting, BFD front end +-@findex bfd_init +-@subsubsection @code{bfd_init} +-@deftypefn {Function} unsigned int bfd_init (void); +-This routine must be called before any other BFD function to +-initialize magical internal data structures. +-Returns a magic number, which may be used to check +-that the bfd library is configured as expected by users. +-@example +-/* Value returned by bfd_init. */ +-#define BFD_INIT_MAGIC (sizeof (struct bfd_section)) +- +-@end example +- +-@end deftypefn +-@node Miscellaneous, Memory Usage, Initialization, BFD front end +-@section Miscellaneous +- +- +-@subsection Miscellaneous functions +- +- +-@findex bfd_get_reloc_upper_bound +-@subsubsection @code{bfd_get_reloc_upper_bound} +-@deftypefn {Function} long bfd_get_reloc_upper_bound (bfd *abfd, asection *sect); +-Return the number of bytes required to store the +-relocation information associated with section @var{sect} +-attached to bfd @var{abfd}. If an error occurs, return -1. +- +-@end deftypefn +-@findex bfd_canonicalize_reloc +-@subsubsection @code{bfd_canonicalize_reloc} +-@deftypefn {Function} long bfd_canonicalize_reloc (bfd *abfd, asection *sec, arelent **loc, asymbol **syms); +-Call the back end associated with the open BFD +-@var{abfd} and translate the external form of the relocation +-information attached to @var{sec} into the internal canonical +-form. Place the table into memory at @var{loc}, which has +-been preallocated, usually by a call to +-@code{bfd_get_reloc_upper_bound}. Returns the number of relocs, or +--1 on error. +- +-The @var{syms} table is also needed for horrible internal magic +-reasons. +- +-@end deftypefn +-@findex bfd_set_reloc +-@subsubsection @code{bfd_set_reloc} +-@deftypefn {Function} void bfd_set_reloc (bfd *abfd, asection *sec, arelent **rel, unsigned int count); +-Set the relocation pointer and count within +-section @var{sec} to the values @var{rel} and @var{count}. +-The argument @var{abfd} is ignored. +-@example +-#define bfd_set_reloc(abfd, asect, location, count) \ +- BFD_SEND (abfd, _bfd_set_reloc, (abfd, asect, location, count)) +-@end example +- +-@end deftypefn +-@findex bfd_set_file_flags +-@subsubsection @code{bfd_set_file_flags} +-@deftypefn {Function} bool bfd_set_file_flags (bfd *abfd, flagword flags); +-Set the flag word in the BFD @var{abfd} to the value @var{flags}. +- +-Possible errors are: +-@itemize @bullet +- +-@item +-@code{bfd_error_wrong_format} - The target bfd was not of object format. +-@item +-@code{bfd_error_invalid_operation} - The target bfd was open for reading. +-@item +-@code{bfd_error_invalid_operation} - +-The flag word contained a bit which was not applicable to the +-type of file. E.g., an attempt was made to set the @code{D_PAGED} bit +-on a BFD format which does not support demand paging. +-@end itemize +- +-@end deftypefn +-@findex bfd_get_arch_size +-@subsubsection @code{bfd_get_arch_size} +-@deftypefn {Function} int bfd_get_arch_size (bfd *abfd); +-Returns the normalized architecture address size, in bits, as +-determined by the object file's format. By normalized, we mean +-either 32 or 64. For ELF, this information is included in the +-header. Use bfd_arch_bits_per_address for number of bits in +-the architecture address. +- +-Returns the arch size in bits if known, @code{-1} otherwise. +- +-@end deftypefn +-@findex bfd_get_sign_extend_vma +-@subsubsection @code{bfd_get_sign_extend_vma} +-@deftypefn {Function} int bfd_get_sign_extend_vma (bfd *abfd); +-Indicates if the target architecture "naturally" sign extends +-an address. Some architectures implicitly sign extend address +-values when they are converted to types larger than the size +-of an address. For instance, bfd_get_start_address() will +-return an address sign extended to fill a bfd_vma when this is +-the case. +- +-Returns @code{1} if the target architecture is known to sign +-extend addresses, @code{0} if the target architecture is known to +-not sign extend addresses, and @code{-1} otherwise. +- +-@end deftypefn +-@findex bfd_set_start_address +-@subsubsection @code{bfd_set_start_address} +-@deftypefn {Function} bool bfd_set_start_address (bfd *abfd, bfd_vma vma); +-Make @var{vma} the entry point of output BFD @var{abfd}. +- +-Returns @code{TRUE} on success, @code{FALSE} otherwise. +- +-@end deftypefn +-@findex bfd_get_gp_size +-@subsubsection @code{bfd_get_gp_size} +-@deftypefn {Function} unsigned int bfd_get_gp_size (bfd *abfd); +-Return the maximum size of objects to be optimized using the GP +-register under MIPS ECOFF. This is typically set by the @code{-G} +-argument to the compiler, assembler or linker. +- +-@end deftypefn +-@findex bfd_set_gp_size +-@subsubsection @code{bfd_set_gp_size} +-@deftypefn {Function} void bfd_set_gp_size (bfd *abfd, unsigned int i); +-Set the maximum size of objects to be optimized using the GP +-register under ECOFF or MIPS ELF. This is typically set by +-the @code{-G} argument to the compiler, assembler or linker. +- +-@end deftypefn +-@findex bfd_set_gp_value +-@subsubsection @code{bfd_set_gp_value} +-@deftypefn {Function} void bfd_set_gp_value (bfd *abfd, bfd_vma v); +-Allow external access to the fucntion to set the GP value. +-This is specifically added for gdb-compile support. +- +-@end deftypefn +-@findex bfd_scan_vma +-@subsubsection @code{bfd_scan_vma} +-@deftypefn {Function} bfd_vma bfd_scan_vma (const char *string, const char **end, int base); +-Convert, like @code{strtoul}, a numerical expression +-@var{string} into a @code{bfd_vma} integer, and return that integer. +-(Though without as many bells and whistles as @code{strtoul}.) +-The expression is assumed to be unsigned (i.e., positive). +-If given a @var{base}, it is used as the base for conversion. +-A base of 0 causes the function to interpret the string +-in hex if a leading "0x" or "0X" is found, otherwise +-in octal if a leading zero is found, otherwise in decimal. +- +-If the value would overflow, the maximum @code{bfd_vma} value is +-returned. +- +-@end deftypefn +-@findex bfd_copy_private_header_data +-@subsubsection @code{bfd_copy_private_header_data} +-@deftypefn {Function} bool bfd_copy_private_header_data (bfd *ibfd, bfd *obfd); +-Copy private BFD header information from the BFD @var{ibfd} to the +-the BFD @var{obfd}. This copies information that may require +-sections to exist, but does not require symbol tables. Return +-@code{true} on success, @code{false} on error. +-Possible error returns are: +- +-@itemize @bullet +- +-@item +-@code{bfd_error_no_memory} - +-Not enough memory exists to create private data for @var{obfd}. +-@end itemize +-@example +-#define bfd_copy_private_header_data(ibfd, obfd) \ +- BFD_SEND (obfd, _bfd_copy_private_header_data, \ +- (ibfd, obfd)) +-@end example +- +-@end deftypefn +-@findex bfd_copy_private_bfd_data +-@subsubsection @code{bfd_copy_private_bfd_data} +-@deftypefn {Function} bool bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd); +-Copy private BFD information from the BFD @var{ibfd} to the +-the BFD @var{obfd}. Return @code{TRUE} on success, @code{FALSE} on error. +-Possible error returns are: +- +-@itemize @bullet +- +-@item +-@code{bfd_error_no_memory} - +-Not enough memory exists to create private data for @var{obfd}. +-@end itemize +-@example +-#define bfd_copy_private_bfd_data(ibfd, obfd) \ +- BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ +- (ibfd, obfd)) +-@end example +- +-@end deftypefn +-@findex bfd_set_private_flags +-@subsubsection @code{bfd_set_private_flags} +-@deftypefn {Function} bool bfd_set_private_flags (bfd *abfd, flagword flags); +-Set private BFD flag information in the BFD @var{abfd}. +-Return @code{TRUE} on success, @code{FALSE} on error. Possible error +-returns are: +- +-@itemize @bullet +- +-@item +-@code{bfd_error_no_memory} - +-Not enough memory exists to create private data for @var{obfd}. +-@end itemize +-@example +-#define bfd_set_private_flags(abfd, flags) \ +- BFD_SEND (abfd, _bfd_set_private_flags, (abfd, flags)) +-@end example +- +-@end deftypefn +-@findex Other functions +-@subsubsection @code{Other functions} +-The following functions exist but have not yet been documented. +-@example +-#define bfd_sizeof_headers(abfd, info) \ +- BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, info)) +- +-#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ +- BFD_SEND (abfd, _bfd_find_nearest_line, \ +- (abfd, syms, sec, off, file, func, line, NULL)) +- +-#define bfd_find_nearest_line_with_alt(abfd, alt_filename, sec, syms, off, \ +- file, func, line, disc) \ +- BFD_SEND (abfd, _bfd_find_nearest_line_with_alt, \ +- (abfd, alt_filename, syms, sec, off, file, func, line, disc)) +- +-#define bfd_find_nearest_line_discriminator(abfd, sec, syms, off, file, func, \ +- line, disc) \ +- BFD_SEND (abfd, _bfd_find_nearest_line, \ +- (abfd, syms, sec, off, file, func, line, disc)) +- +-#define bfd_find_line(abfd, syms, sym, file, line) \ +- BFD_SEND (abfd, _bfd_find_line, \ +- (abfd, syms, sym, file, line)) +- +-#define bfd_find_inliner_info(abfd, file, func, line) \ +- BFD_SEND (abfd, _bfd_find_inliner_info, \ +- (abfd, file, func, line)) +- +-#define bfd_debug_info_start(abfd) \ +- BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) +- +-#define bfd_debug_info_end(abfd) \ +- BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) +- +-#define bfd_debug_info_accumulate(abfd, section) \ +- BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) +- +-#define bfd_stat_arch_elt(abfd, stat) \ +- BFD_SEND (abfd->my_archive ? abfd->my_archive : abfd, \ +- _bfd_stat_arch_elt, (abfd, stat)) +- +-#define bfd_update_armap_timestamp(abfd) \ +- BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd)) +- +-#define bfd_set_arch_mach(abfd, arch, mach)\ +- BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) +- +-#define bfd_relax_section(abfd, section, link_info, again) \ +- BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) +- +-#define bfd_gc_sections(abfd, link_info) \ +- BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info)) +- +-#define bfd_lookup_section_flags(link_info, flag_info, section) \ +- BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info, section)) +- +-#define bfd_merge_sections(abfd, link_info) \ +- BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info)) +- +-#define bfd_is_group_section(abfd, sec) \ +- BFD_SEND (abfd, _bfd_is_group_section, (abfd, sec)) +- +-#define bfd_group_name(abfd, sec) \ +- BFD_SEND (abfd, _bfd_group_name, (abfd, sec)) +- +-#define bfd_discard_group(abfd, sec) \ +- BFD_SEND (abfd, _bfd_discard_group, (abfd, sec)) +- +-#define bfd_link_hash_table_create(abfd) \ +- BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) +- +-#define bfd_link_add_symbols(abfd, info) \ +- BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) +- +-#define bfd_link_just_syms(abfd, sec, info) \ +- BFD_SEND (abfd, _bfd_link_just_syms, (sec, info)) +- +-#define bfd_final_link(abfd, info) \ +- BFD_SEND (abfd, _bfd_final_link, (abfd, info)) +- +-#define bfd_free_cached_info(abfd) \ +- BFD_SEND (abfd, _bfd_free_cached_info, (abfd)) +- +-#define bfd_get_dynamic_symtab_upper_bound(abfd) \ +- BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd)) +- +-#define bfd_print_private_bfd_data(abfd, file)\ +- BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file)) +- +-#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \ +- BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols)) +- +-#define bfd_get_synthetic_symtab(abfd, count, syms, dyncount, dynsyms, ret) \ +- BFD_SEND (abfd, _bfd_get_synthetic_symtab, (abfd, count, syms, \ +- dyncount, dynsyms, ret)) +- +-#define bfd_get_dynamic_reloc_upper_bound(abfd) \ +- BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd)) +- +-#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \ +- BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms)) +- +-@end example +- +-@findex bfd_get_relocated_section_contents +-@subsubsection @code{bfd_get_relocated_section_contents} +-@deftypefn {Function} bfd_byte *bfd_get_relocated_section_contents (bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *, bool, asymbol **); +-Read and relocate the indirect link_order section, into DATA +-(if non-NULL) or to a malloc'd buffer. Return the buffer, or +-NULL on errors. +- +-@end deftypefn +-@findex bfd_record_phdr +-@subsubsection @code{bfd_record_phdr} +-@deftypefn {Function} bool bfd_record_phdr (bfd *, unsigned long, bool, flagword, bool, bfd_vma, bool, bool, unsigned int, struct bfd_section **); +-Record information about an ELF program header. +- +-@end deftypefn +-@findex bfd_sprintf_vma +-@subsubsection @code{bfd_sprintf_vma} +-@deftypefn {Function} void bfd_sprintf_vma (bfd *, char *, bfd_vma); void bfd_fprintf_vma (bfd *, void *, bfd_vma); +-bfd_sprintf_vma and bfd_fprintf_vma display an address in the +-target's address size. +- +-@end deftypefn +-@findex bfd_alt_mach_code +-@subsubsection @code{bfd_alt_mach_code} +-@deftypefn {Function} bool bfd_alt_mach_code (bfd *abfd, int alternative); +-When more than one machine code number is available for the +-same machine type, this function can be used to switch between +-the preferred one (alternative == 0) and any others. Currently, +-only ELF supports this feature, with up to two alternate +-machine codes. +- +-@end deftypefn +-@findex bfd_emul_get_maxpagesize +-@subsubsection @code{bfd_emul_get_maxpagesize} +-@deftypefn {Function} bfd_vma bfd_emul_get_maxpagesize (const char *); +-Returns the maximum page size, in bytes, as determined by +-emulation. +- +-@end deftypefn +-@findex bfd_emul_get_commonpagesize +-@subsubsection @code{bfd_emul_get_commonpagesize} +-@deftypefn {Function} bfd_vma bfd_emul_get_commonpagesize (const char *); +-Returns the common page size, in bytes, as determined by +-emulation. +- +-@end deftypefn +-@findex bfd_demangle +-@subsubsection @code{bfd_demangle} +-@deftypefn {Function} char *bfd_demangle (bfd *, const char *, int); +-Wrapper around cplus_demangle. Strips leading underscores and +-other such chars that would otherwise confuse the demangler. +-If passed a g++ v3 ABI mangled name, returns a buffer allocated +-with malloc holding the demangled name. Returns NULL otherwise +-and on memory alloc failure. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/bfdver.texi gdb-14.1-sw64/bfd/doc/bfdver.texi +--- gdb-14.1-after-patch/bfd/doc/bfdver.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/bfdver.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,4 +0,0 @@ +-@set VERSION 2.41.50 +-@set VERSION_PACKAGE (GNU Binutils) +-@set UPDATED December 2023 +-@set BUGURL @uref{https://sourceware.org/bugzilla/} +diff -Naur gdb-14.1-after-patch/bfd/doc/bfdwin.texi gdb-14.1-sw64/bfd/doc/bfdwin.texi +--- gdb-14.1-after-patch/bfd/doc/bfdwin.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/bfdwin.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,18 +0,0 @@ +-@findex bfd_init_window +-@subsubsection @code{bfd_init_window} +-@deftypefn {Function} void bfd_init_window (bfd_window *); +-Initialise mmap window. +- +-@end deftypefn +-@findex bfd_free_window +-@subsubsection @code{bfd_free_window} +-@deftypefn {Function} void bfd_free_window (bfd_window *); +-Finalise mmap window struct. +- +-@end deftypefn +-@findex bfd_get_file_window +-@subsubsection @code{bfd_get_file_window} +-@deftypefn {Function} bool bfd_get_file_window (bfd *, file_ptr, bfd_size_type, bfd_window *, bool {*writable*}); +-mmap from a bfd's iostream. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/cache.texi gdb-14.1-sw64/bfd/doc/cache.texi +--- gdb-14.1-after-patch/bfd/doc/cache.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/cache.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,53 +0,0 @@ +-@section File caching +-The file caching mechanism is embedded within BFD and allows +-the application to open as many BFDs as it wants without +-regard to the underlying operating system's file descriptor +-limit (often as low as 20 open files). The module in +-@code{cache.c} maintains a least recently used list of +-@code{bfd_cache_max_open} files, and exports the name +-@code{bfd_cache_lookup}, which runs around and makes sure that +-the required BFD is open. If not, then it chooses a file to +-close, closes it and opens the one wanted, returning its file +-handle. +- +-@subsection Caching functions +- +- +-@findex bfd_cache_init +-@subsubsection @code{bfd_cache_init} +-@deftypefn {Function} bool bfd_cache_init (bfd *abfd); +-Add a newly opened BFD to the cache. +- +-@end deftypefn +-@findex bfd_cache_close +-@subsubsection @code{bfd_cache_close} +-@deftypefn {Function} bool bfd_cache_close (bfd *abfd); +-Remove the BFD @var{abfd} from the cache. If the attached file is open, +-then close it too. +- +-@code{FALSE} is returned if closing the file fails, @code{TRUE} is +-returned if all is well. +- +-@end deftypefn +-@findex bfd_cache_close_all +-@subsubsection @code{bfd_cache_close_all} +-@deftypefn {Function} bool bfd_cache_close_all (void); +-Remove all BFDs from the cache. If the attached file is open, +-then close it too. Note - despite its name this function will +-close a BFD even if it is not marked as being cacheable, ie +-even if bfd_get_cacheable() returns false. +- +-@code{FALSE} is returned if closing one of the file fails, @code{TRUE} is +-returned if all is well. +- +-@end deftypefn +-@findex bfd_open_file +-@subsubsection @code{bfd_open_file} +-@deftypefn {Function} FILE* bfd_open_file (bfd *abfd); +-Call the OS to open a file for @var{abfd}. Return the @code{FILE *} +-(possibly @code{NULL}) that results from this operation. Set up the +-BFD so that future accesses know the file is open. If the @code{FILE *} +-returned is @code{NULL}, then it won't have been put in the +-cache, so it won't have to be removed from it. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/coffcode.texi gdb-14.1-sw64/bfd/doc/coffcode.texi +--- gdb-14.1-after-patch/bfd/doc/coffcode.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/coffcode.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,526 +0,0 @@ +-@section coff backends +-BFD supports a number of different flavours of coff format. +-The major differences between formats are the sizes and +-alignments of fields in structures on disk, and the occasional +-extra field. +- +-Coff in all its varieties is implemented with a few common +-files and a number of implementation specific files. For +-example, the i386 coff format is implemented in the file +-@file{coff-i386.c}. This file @code{#include}s +-@file{coff/i386.h} which defines the external structure of the +-coff format for the i386, and @file{coff/internal.h} which +-defines the internal structure. @file{coff-i386.c} also +-defines the relocations used by the i386 coff format +-@xref{Relocations}. +- +-@subsection Porting to a new version of coff +-The recommended method is to select from the existing +-implementations the version of coff which is most like the one +-you want to use. For example, we'll say that i386 coff is +-the one you select, and that your coff flavour is called foo. +-Copy @file{i386coff.c} to @file{foocoff.c}, copy +-@file{../include/coff/i386.h} to @file{../include/coff/foo.h}, +-and add the lines to @file{targets.c} and @file{Makefile.in} +-so that your new back end is used. Alter the shapes of the +-structures in @file{../include/coff/foo.h} so that they match +-what you need. You will probably also have to add +-@code{#ifdef}s to the code in @file{coff/internal.h} and +-@file{coffcode.h} if your version of coff is too wild. +- +-You can verify that your new BFD backend works quite simply by +-building @file{objdump} from the @file{binutils} directory, +-and making sure that its version of what's going on and your +-host system's idea (assuming it has the pretty standard coff +-dump utility, usually called @code{att-dump} or just +-@code{dump}) are the same. Then clean up your code, and send +-what you've done to Cygnus. Then your stuff will be in the +-next release, and you won't have to keep integrating it. +- +-@subsection How the coff backend works +- +- +-@subsubsection File layout +-The Coff backend is split into generic routines that are +-applicable to any Coff target and routines that are specific +-to a particular target. The target-specific routines are +-further split into ones which are basically the same for all +-Coff targets except that they use the external symbol format +-or use different values for certain constants. +- +-The generic routines are in @file{coffgen.c}. These routines +-work for any Coff target. They use some hooks into the target +-specific code; the hooks are in a @code{bfd_coff_backend_data} +-structure, one of which exists for each target. +- +-The essentially similar target-specific routines are in +-@file{coffcode.h}. This header file includes executable C code. +-The various Coff targets first include the appropriate Coff +-header file, make any special defines that are needed, and +-then include @file{coffcode.h}. +- +-Some of the Coff targets then also have additional routines in +-the target source file itself. +- +-@subsubsection Coff long section names +-In the standard Coff object format, section names are limited to +-the eight bytes available in the @code{s_name} field of the +-@code{SCNHDR} section header structure. The format requires the +-field to be NUL-padded, but not necessarily NUL-terminated, so +-the longest section names permitted are a full eight characters. +- +-The Microsoft PE variants of the Coff object file format add +-an extension to support the use of long section names. This +-extension is defined in section 4 of the Microsoft PE/COFF +-specification (rev 8.1). If a section name is too long to fit +-into the section header's @code{s_name} field, it is instead +-placed into the string table, and the @code{s_name} field is +-filled with a slash ("/") followed by the ASCII decimal +-representation of the offset of the full name relative to the +-string table base. +- +-Note that this implies that the extension can only be used in object +-files, as executables do not contain a string table. The standard +-specifies that long section names from objects emitted into executable +-images are to be truncated. +- +-However, as a GNU extension, BFD can generate executable images +-that contain a string table and long section names. This +-would appear to be technically valid, as the standard only says +-that Coff debugging information is deprecated, not forbidden, +-and in practice it works, although some tools that parse PE files +-expecting the MS standard format may become confused; @file{PEview} is +-one known example. +- +-The functionality is supported in BFD by code implemented under +-the control of the macro @code{COFF_LONG_SECTION_NAMES}. If not +-defined, the format does not support long section names in any way. +-If defined, it is used to initialise a flag, +-@code{_bfd_coff_long_section_names}, and a hook function pointer, +-@code{_bfd_coff_set_long_section_names}, in the Coff backend data +-structure. The flag controls the generation of long section names +-in output BFDs at runtime; if it is false, as it will be by default +-when generating an executable image, long section names are truncated; +-if true, the long section names extension is employed. The hook +-points to a function that allows the value of a copy of the flag +-in coff object tdata to be altered at runtime, on formats that +-support long section names at all; on other formats it points +-to a stub that returns an error indication. +- +-With input BFDs, the flag is set according to whether any long section +-names are detected while reading the section headers. For a completely +-new BFD, the flag is set to the default for the target format. This +-information can be used by a client of the BFD library when deciding +-what output format to generate, and means that a BFD that is opened +-for read and subsequently converted to a writeable BFD and modified +-in-place will retain whatever format it had on input. +- +-If @code{COFF_LONG_SECTION_NAMES} is simply defined (blank), or is +-defined to the value "1", then long section names are enabled by +-default; if it is defined to the value zero, they are disabled by +-default (but still accepted in input BFDs). The header @file{coffcode.h} +-defines a macro, @code{COFF_DEFAULT_LONG_SECTION_NAMES}, which is +-used in the backends to initialise the backend data structure fields +-appropriately; see the comments for further detail. +- +-@subsubsection Bit twiddling +-Each flavour of coff supported in BFD has its own header file +-describing the external layout of the structures. There is also +-an internal description of the coff layout, in +-@file{coff/internal.h}. A major function of the +-coff backend is swapping the bytes and twiddling the bits to +-translate the external form of the structures into the normal +-internal form. This is all performed in the +-@code{bfd_swap}_@i{thing}_@i{direction} routines. Some +-elements are different sizes between different versions of +-coff; it is the duty of the coff version specific include file +-to override the definitions of various packing routines in +-@file{coffcode.h}. E.g., the size of line number entry in coff is +-sometimes 16 bits, and sometimes 32 bits. @code{#define}ing +-@code{PUT_LNSZ_LNNO} and @code{GET_LNSZ_LNNO} will select the +-correct one. No doubt, some day someone will find a version of +-coff which has a varying field size not catered to at the +-moment. To port BFD, that person will have to add more @code{#defines}. +-Three of the bit twiddling routines are exported to +-@code{gdb}; @code{coff_swap_aux_in}, @code{coff_swap_sym_in} +-and @code{coff_swap_lineno_in}. @code{GDB} reads the symbol +-table on its own, but uses BFD to fix things up. More of the +-bit twiddlers are exported for @code{gas}; +-@code{coff_swap_aux_out}, @code{coff_swap_sym_out}, +-@code{coff_swap_lineno_out}, @code{coff_swap_reloc_out}, +-@code{coff_swap_filehdr_out}, @code{coff_swap_aouthdr_out}, +-@code{coff_swap_scnhdr_out}. @code{Gas} currently keeps track +-of all the symbol table and reloc drudgery itself, thereby +-saving the internal BFD overhead, but uses BFD to swap things +-on the way out, making cross ports much safer. Doing so also +-allows BFD (and thus the linker) to use the same header files +-as @code{gas}, which makes one avenue to disaster disappear. +- +-@subsubsection Symbol reading +-The simple canonical form for symbols used by BFD is not rich +-enough to keep all the information available in a coff symbol +-table. The back end gets around this problem by keeping the original +-symbol table around, "behind the scenes". +- +-When a symbol table is requested (through a call to +-@code{bfd_canonicalize_symtab}), a request gets through to +-@code{coff_get_normalized_symtab}. This reads the symbol table from +-the coff file and swaps all the structures inside into the +-internal form. It also fixes up all the pointers in the table +-(represented in the file by offsets from the first symbol in +-the table) into physical pointers to elements in the new +-internal table. This involves some work since the meanings of +-fields change depending upon context: a field that is a +-pointer to another structure in the symbol table at one moment +-may be the size in bytes of a structure at the next. Another +-pass is made over the table. All symbols which mark file names +-(@code{C_FILE} symbols) are modified so that the internal +-string points to the value in the auxent (the real filename) +-rather than the normal text associated with the symbol +-(@code{".file"}). +- +-At this time the symbol names are moved around. Coff stores +-all symbols less than nine characters long physically +-within the symbol table; longer strings are kept at the end of +-the file in the string table. This pass moves all strings +-into memory and replaces them with pointers to the strings. +- +-The symbol table is massaged once again, this time to create +-the canonical table used by the BFD application. Each symbol +-is inspected in turn, and a decision made (using the +-@code{sclass} field) about the various flags to set in the +-@code{asymbol}. @xref{Symbols}. The generated canonical table +-shares strings with the hidden internal symbol table. +- +-Any linenumbers are read from the coff file too, and attached +-to the symbols which own the functions the linenumbers belong to. +- +-@subsubsection Symbol writing +-Writing a symbol to a coff file which didn't come from a coff +-file will lose any debugging information. The @code{asymbol} +-structure remembers the BFD from which the symbol was taken, and on +-output the back end makes sure that the same destination target as +-source target is present. +- +-When the symbols have come from a coff file then all the +-debugging information is preserved. +- +-Symbol tables are provided for writing to the back end in a +-vector of pointers to pointers. This allows applications like +-the linker to accumulate and output large symbol tables +-without having to do too much byte copying. +- +-This function runs through the provided symbol table and +-patches each symbol marked as a file place holder +-(@code{C_FILE}) to point to the next file place holder in the +-list. It also marks each @code{offset} field in the list with +-the offset from the first symbol of the current symbol. +- +-Another function of this procedure is to turn the canonical +-value form of BFD into the form used by coff. Internally, BFD +-expects symbol values to be offsets from a section base; so a +-symbol physically at 0x120, but in a section starting at +-0x100, would have the value 0x20. Coff expects symbols to +-contain their final value, so symbols have their values +-changed at this point to reflect their sum with their owning +-section. This transformation uses the +-@code{output_section} field of the @code{asymbol}'s +-@code{asection} @xref{Sections}. +- +-@itemize @bullet +- +-@item +-@code{coff_mangle_symbols} +-@end itemize +-This routine runs though the provided symbol table and uses +-the offsets generated by the previous pass and the pointers +-generated when the symbol table was read in to create the +-structured hierarchy required by coff. It changes each pointer +-to a symbol into the index into the symbol table of the asymbol. +- +-@itemize @bullet +- +-@item +-@code{coff_write_symbols} +-@end itemize +-This routine runs through the symbol table and patches up the +-symbols from their internal form into the coff way, calls the +-bit twiddlers, and writes out the table to the file. +- +-@findex coff_symbol_type +-@subsubsection @code{coff_symbol_type} +-The hidden information for an @code{asymbol} is described in a +-@code{combined_entry_type}: +- +- +-@example +-typedef struct coff_ptr_struct +-@{ +- /* Remembers the offset from the first symbol in the file for +- this symbol. Generated by coff_renumber_symbols. */ +- unsigned int offset; +- +- /* Selects between the elements of the union below. */ +- unsigned int is_sym : 1; +- +- /* Selects between the elements of the x_sym.x_tagndx union. If set, +- p is valid and the field will be renumbered. */ +- unsigned int fix_tag : 1; +- +- /* Selects between the elements of the x_sym.x_fcnary.x_fcn.x_endndx +- union. If set, p is valid and the field will be renumbered. */ +- unsigned int fix_end : 1; +- +- /* Selects between the elements of the x_csect.x_scnlen union. If set, +- p is valid and the field will be renumbered. */ +- unsigned int fix_scnlen : 1; +- +- /* If set, u.syment.n_value contains a pointer to a symbol. The final +- value will be the offset field. Used for XCOFF C_BSTAT symbols. */ +- unsigned int fix_value : 1; +- +- /* If set, u.syment.n_value is an index into the line number entries. +- Used for XCOFF C_BINCL/C_EINCL symbols. */ +- unsigned int fix_line : 1; +- +- /* The container for the symbol structure as read and translated +- from the file. */ +- union +- @{ +- union internal_auxent auxent; +- struct internal_syment syment; +- @} u; +- +- /* An extra pointer which can used by format based on COFF (like XCOFF) +- to provide extra information to their backend. */ +- void *extrap; +-@} combined_entry_type; +- +-/* Each canonical asymbol really looks like this: */ +- +-typedef struct coff_symbol_struct +-@{ +- /* The actual symbol which the rest of BFD works with */ +- asymbol symbol; +- +- /* A pointer to the hidden information for this symbol */ +- combined_entry_type *native; +- +- /* A pointer to the linenumber information for this symbol */ +- struct lineno_cache_entry *lineno; +- +- /* Have the line numbers been relocated yet ? */ +- bool done_lineno; +-@} coff_symbol_type; +- +-@end example +-@findex bfd_coff_backend_data +-@subsubsection @code{bfd_coff_backend_data} +- +-@example +-typedef struct +-@{ +- void (*_bfd_coff_swap_aux_in) +- (bfd *, void *, int, int, int, int, void *); +- +- void (*_bfd_coff_swap_sym_in) +- (bfd *, void *, void *); +- +- void (*_bfd_coff_swap_lineno_in) +- (bfd *, void *, void *); +- +- unsigned int (*_bfd_coff_swap_aux_out) +- (bfd *, void *, int, int, int, int, void *); +- +- unsigned int (*_bfd_coff_swap_sym_out) +- (bfd *, void *, void *); +- +- unsigned int (*_bfd_coff_swap_lineno_out) +- (bfd *, void *, void *); +- +- unsigned int (*_bfd_coff_swap_reloc_out) +- (bfd *, void *, void *); +- +- unsigned int (*_bfd_coff_swap_filehdr_out) +- (bfd *, void *, void *); +- +- unsigned int (*_bfd_coff_swap_aouthdr_out) +- (bfd *, void *, void *); +- +- unsigned int (*_bfd_coff_swap_scnhdr_out) +- (bfd *, void *, void *); +- +- unsigned int _bfd_filhsz; +- unsigned int _bfd_aoutsz; +- unsigned int _bfd_scnhsz; +- unsigned int _bfd_symesz; +- unsigned int _bfd_auxesz; +- unsigned int _bfd_relsz; +- unsigned int _bfd_linesz; +- unsigned int _bfd_filnmlen; +- bool _bfd_coff_long_filenames; +- +- bool _bfd_coff_long_section_names; +- bool (*_bfd_coff_set_long_section_names) +- (bfd *, int); +- +- unsigned int _bfd_coff_default_section_alignment_power; +- bool _bfd_coff_force_symnames_in_strings; +- unsigned int _bfd_coff_debug_string_prefix_length; +- unsigned int _bfd_coff_max_nscns; +- +- void (*_bfd_coff_swap_filehdr_in) +- (bfd *, void *, void *); +- +- void (*_bfd_coff_swap_aouthdr_in) +- (bfd *, void *, void *); +- +- void (*_bfd_coff_swap_scnhdr_in) +- (bfd *, void *, void *); +- +- void (*_bfd_coff_swap_reloc_in) +- (bfd *abfd, void *, void *); +- +- bool (*_bfd_coff_bad_format_hook) +- (bfd *, void *); +- +- bool (*_bfd_coff_set_arch_mach_hook) +- (bfd *, void *); +- +- void * (*_bfd_coff_mkobject_hook) +- (bfd *, void *, void *); +- +- bool (*_bfd_styp_to_sec_flags_hook) +- (bfd *, void *, const char *, asection *, flagword *); +- +- void (*_bfd_set_alignment_hook) +- (bfd *, asection *, void *); +- +- bool (*_bfd_coff_slurp_symbol_table) +- (bfd *); +- +- bool (*_bfd_coff_symname_in_debug) +- (bfd *, struct internal_syment *); +- +- bool (*_bfd_coff_pointerize_aux_hook) +- (bfd *, combined_entry_type *, combined_entry_type *, +- unsigned int, combined_entry_type *); +- +- bool (*_bfd_coff_print_aux) +- (bfd *, FILE *, combined_entry_type *, combined_entry_type *, +- combined_entry_type *, unsigned int); +- +- bool (*_bfd_coff_reloc16_extra_cases) +- (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *, +- bfd_byte *, size_t *, size_t *); +- +- int (*_bfd_coff_reloc16_estimate) +- (bfd *, asection *, arelent *, unsigned int, +- struct bfd_link_info *); +- +- enum coff_symbol_classification (*_bfd_coff_classify_symbol) +- (bfd *, struct internal_syment *); +- +- bool (*_bfd_coff_compute_section_file_positions) +- (bfd *); +- +- bool (*_bfd_coff_start_final_link) +- (bfd *, struct bfd_link_info *); +- +- bool (*_bfd_coff_relocate_section) +- (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, +- struct internal_reloc *, struct internal_syment *, asection **); +- +- reloc_howto_type *(*_bfd_coff_rtype_to_howto) +- (bfd *, asection *, struct internal_reloc *, +- struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *); +- +- bool (*_bfd_coff_adjust_symndx) +- (bfd *, struct bfd_link_info *, bfd *, asection *, +- struct internal_reloc *, bool *); +- +- bool (*_bfd_coff_link_add_one_symbol) +- (struct bfd_link_info *, bfd *, const char *, flagword, +- asection *, bfd_vma, const char *, bool, bool, +- struct bfd_link_hash_entry **); +- +- bool (*_bfd_coff_link_output_has_begun) +- (bfd *, struct coff_final_link_info *); +- +- bool (*_bfd_coff_final_link_postscript) +- (bfd *, struct coff_final_link_info *); +- +- bool (*_bfd_coff_print_pdata) +- (bfd *, void *); +- +-@} bfd_coff_backend_data; +- +-@end example +-@subsubsection Writing relocations +-To write relocations, the back end steps though the +-canonical relocation table and create an +-@code{internal_reloc}. The symbol index to use is removed from +-the @code{offset} field in the symbol table supplied. The +-address comes directly from the sum of the section base +-address and the relocation offset; the type is dug directly +-from the howto field. Then the @code{internal_reloc} is +-swapped into the shape of an @code{external_reloc} and written +-out to disk. +- +-@subsubsection Reading linenumbers +-Creating the linenumber table is done by reading in the entire +-coff linenumber table, and creating another table for internal use. +- +-A coff linenumber table is structured so that each function +-is marked as having a line number of 0. Each line within the +-function is an offset from the first line in the function. The +-base of the line number information for the table is stored in +-the symbol associated with the function. +- +-Note: The PE format uses line number 0 for a flag indicating a +-new source file. +- +-The information is copied from the external to the internal +-table, and each symbol which marks a function is marked by +-pointing its... +- +-How does this work ? +- +-@subsubsection Reading relocations +-Coff relocations are easily transformed into the internal BFD form +-(@code{arelent}). +- +-Reading a coff relocation table is done in the following stages: +- +-@itemize @bullet +- +-@item +-Read the entire coff relocation table into memory. +- +-@item +-Process each relocation in turn; first swap it from the +-external to the internal form. +- +-@item +-Turn the symbol referenced in the relocation's symbol index +-into a pointer into the canonical symbol table. +-This table is the same as the one returned by a call to +-@code{bfd_canonicalize_symtab}. The back end will call that +-routine and save the result if a canonicalization hasn't been done. +- +-@item +-The reloc index is turned into a pointer to a howto +-structure, in a back end specific way. For instance, the 386 +-uses the @code{r_type} to directly produce an index +-into a howto table vector. +- +-@item +-Note that @code{arelent.addend} for COFF is often not what +-most people understand as a relocation addend, but rather an +-adjustment to the relocation addend stored in section contents +-of relocatable object files. The value found in section +-contents may also be confusing, depending on both symbol value +-and addend somewhat similar to the field value for a +-final-linked object. See @code{CALC_ADDEND}. +-@end itemize +- +diff -Naur gdb-14.1-after-patch/bfd/doc/corefile.texi gdb-14.1-sw64/bfd/doc/corefile.texi +--- gdb-14.1-after-patch/bfd/doc/corefile.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/corefile.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,52 +0,0 @@ +-@section Core files +- +- +-@subsection Core file functions +- +- +-These are functions pertaining to core files. +- +-@findex bfd_core_file_failing_command +-@subsubsection @code{bfd_core_file_failing_command} +-@deftypefn {Function} const char *bfd_core_file_failing_command (bfd *abfd); +-Return a read-only string explaining which program was running +-when it failed and produced the core file @var{abfd}. +- +-@end deftypefn +-@findex bfd_core_file_failing_signal +-@subsubsection @code{bfd_core_file_failing_signal} +-@deftypefn {Function} int bfd_core_file_failing_signal (bfd *abfd); +-Returns the signal number which caused the core dump which +-generated the file the BFD @var{abfd} is attached to. +- +-@end deftypefn +-@findex bfd_core_file_pid +-@subsubsection @code{bfd_core_file_pid} +-@deftypefn {Function} int bfd_core_file_pid (bfd *abfd); +-Returns the PID of the process the core dump the BFD +-@var{abfd} is attached to was generated from. +- +-@end deftypefn +-@findex core_file_matches_executable_p +-@subsubsection @code{core_file_matches_executable_p} +-@deftypefn {Function} bool core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd); +-Return @code{TRUE} if the core file attached to @var{core_bfd} +-was generated by a run of the executable file attached to +-@var{exec_bfd}, @code{FALSE} otherwise. +- +-@end deftypefn +-@findex generic_core_file_matches_executable_p +-@subsubsection @code{generic_core_file_matches_executable_p} +-@deftypefn {Function} bool generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd); +-Return TRUE if the core file attached to @var{core_bfd} +-was generated by a run of the executable file attached +-to @var{exec_bfd}. The match is based on executable +-basenames only. +- +-Note: When not able to determine the core file failing +-command or the executable name, we still return TRUE even +-though we're not sure that core file and executable match. +-This is to avoid generating a false warning in situations +-where we really don't know whether they match or not. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/elf.texi gdb-14.1-sw64/bfd/doc/elf.texi +--- gdb-14.1-after-patch/bfd/doc/elf.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/elf.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,9 +0,0 @@ +-@section ELF backends +-BFD support for ELF formats is being worked on. +-Currently, the best supported back ends are for sparc and i386 +-(running svr4 or Solaris 2). +- +-Documentation of the internals of the support code still needs +-to be written. The code is changing quickly enough that we +-haven't bothered yet. +- +diff -Naur gdb-14.1-after-patch/bfd/doc/format.texi gdb-14.1-sw64/bfd/doc/format.texi +--- gdb-14.1-after-patch/bfd/doc/format.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/format.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,99 +0,0 @@ +-@section File formats +-A format is a BFD concept of high level file contents type. The +-formats supported by BFD are: +- +-@itemize @bullet +- +-@item +-@code{bfd_object} +-@end itemize +-The BFD may contain data, symbols, relocations and debug info. +- +-@itemize @bullet +- +-@item +-@code{bfd_archive} +-@end itemize +-The BFD contains other BFDs and an optional index. +- +-@itemize @bullet +- +-@item +-@code{bfd_core} +-@end itemize +-The BFD contains the result of an executable core dump. +- +-@subsection File format functions +- +- +-@findex bfd_check_format +-@subsubsection @code{bfd_check_format} +-@deftypefn {Function} bool bfd_check_format (bfd *abfd, bfd_format format); +-Verify if the file attached to the BFD @var{abfd} is compatible +-with the format @var{format} (i.e., one of @code{bfd_object}, +-@code{bfd_archive} or @code{bfd_core}). +- +-If the BFD has been set to a specific target before the +-call, only the named target and format combination is +-checked. If the target has not been set, or has been set to +-@code{default}, then all the known target backends is +-interrogated to determine a match. If the default target +-matches, it is used. If not, exactly one target must recognize +-the file, or an error results. +- +-The function returns @code{TRUE} on success, otherwise @code{FALSE} +-with one of the following error codes: +- +-@itemize @bullet +- +-@item +-@code{bfd_error_invalid_operation} - +-if @code{format} is not one of @code{bfd_object}, @code{bfd_archive} or +-@code{bfd_core}. +- +-@item +-@code{bfd_error_system_call} - +-if an error occured during a read - even some file mismatches +-can cause bfd_error_system_calls. +- +-@item +-@code{file_not_recognised} - +-none of the backends recognised the file format. +- +-@item +-@code{bfd_error_file_ambiguously_recognized} - +-more than one backend recognised the file format. +-@end itemize +- +-@end deftypefn +-@findex bfd_check_format_matches +-@subsubsection @code{bfd_check_format_matches} +-@deftypefn {Function} bool bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching); +-Like @code{bfd_check_format}, except when it returns FALSE with +-@code{bfd_errno} set to @code{bfd_error_file_ambiguously_recognized}. In that +-case, if @var{matching} is not NULL, it will be filled in with +-a NULL-terminated list of the names of the formats that matched, +-allocated with @code{malloc}. +-Then the user may choose a format and try again. +- +-When done with the list that @var{matching} points to, the caller +-should free it. +- +-@end deftypefn +-@findex bfd_set_format +-@subsubsection @code{bfd_set_format} +-@deftypefn {Function} bool bfd_set_format (bfd *abfd, bfd_format format); +-This function sets the file format of the BFD @var{abfd} to the +-format @var{format}. If the target set in the BFD does not +-support the format requested, the format is invalid, or the BFD +-is not open for writing, then an error occurs. +- +-@end deftypefn +-@findex bfd_format_string +-@subsubsection @code{bfd_format_string} +-@deftypefn {Function} const char *bfd_format_string (bfd_format format); +-Return a pointer to a const string +-@code{invalid}, @code{object}, @code{archive}, @code{core}, or @code{unknown}, +-depending upon the value of @var{format}. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/hash.texi gdb-14.1-sw64/bfd/doc/hash.texi +--- gdb-14.1-after-patch/bfd/doc/hash.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/hash.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,354 +0,0 @@ +-@section Hash Tables +-@cindex Hash tables +-BFD provides a simple set of hash table functions. Routines +-are provided to initialize a hash table, to free a hash table, +-to look up a string in a hash table and optionally create an +-entry for it, and to traverse a hash table. There is +-currently no routine to delete an string from a hash table. +- +-The basic hash table does not permit any data to be stored +-with a string. However, a hash table is designed to present a +-base class from which other types of hash tables may be +-derived. These derived types may store additional information +-with the string. Hash tables were implemented in this way, +-rather than simply providing a data pointer in a hash table +-entry, because they were designed for use by the linker back +-ends. The linker may create thousands of hash table entries, +-and the overhead of allocating private data and storing and +-following pointers becomes noticeable. +- +-The basic hash table code is in @code{hash.c}. +- +-@menu +-* Creating and Freeing a Hash Table:: +-* Looking Up or Entering a String:: +-* Traversing a Hash Table:: +-* Deriving a New Hash Table Type:: +-@end menu +- +-@node Creating and Freeing a Hash Table, Looking Up or Entering a String, Hash Tables, Hash Tables +-@subsection Creating and freeing a hash table +-@findex bfd_hash_table_init +-@findex bfd_hash_table_init_n +-To create a hash table, create an instance of a @code{struct +-bfd_hash_table} (defined in @code{bfd.h}) and call +-@code{bfd_hash_table_init} (if you know approximately how many +-entries you will need, the function @code{bfd_hash_table_init_n}, +-which takes a @var{size} argument, may be used). +-@code{bfd_hash_table_init} returns @code{FALSE} if some sort of +-error occurs. +- +-@findex bfd_hash_newfunc +-The function @code{bfd_hash_table_init} take as an argument a +-function to use to create new entries. For a basic hash +-table, use the function @code{bfd_hash_newfunc}. @xref{Deriving +-a New Hash Table Type}, for why you would want to use a +-different value for this argument. +- +-@findex bfd_hash_allocate +-@code{bfd_hash_table_init} will create an objalloc which will be +-used to allocate new entries. You may allocate memory on this +-objalloc using @code{bfd_hash_allocate}. +- +-@findex bfd_hash_table_free +-Use @code{bfd_hash_table_free} to free up all the memory that has +-been allocated for a hash table. This will not free up the +-@code{struct bfd_hash_table} itself, which you must provide. +- +-@findex bfd_hash_set_default_size +-Use @code{bfd_hash_set_default_size} to set the default size of +-hash table to use. +- +-@node Looking Up or Entering a String, Traversing a Hash Table, Creating and Freeing a Hash Table, Hash Tables +-@subsection Looking up or entering a string +-@findex bfd_hash_lookup +-The function @code{bfd_hash_lookup} is used both to look up a +-string in the hash table and to create a new entry. +- +-If the @var{create} argument is @code{FALSE}, @code{bfd_hash_lookup} +-will look up a string. If the string is found, it will +-returns a pointer to a @code{struct bfd_hash_entry}. If the +-string is not found in the table @code{bfd_hash_lookup} will +-return @code{NULL}. You should not modify any of the fields in +-the returns @code{struct bfd_hash_entry}. +- +-If the @var{create} argument is @code{TRUE}, the string will be +-entered into the hash table if it is not already there. +-Either way a pointer to a @code{struct bfd_hash_entry} will be +-returned, either to the existing structure or to a newly +-created one. In this case, a @code{NULL} return means that an +-error occurred. +- +-If the @var{create} argument is @code{TRUE}, and a new entry is +-created, the @var{copy} argument is used to decide whether to +-copy the string onto the hash table objalloc or not. If +-@var{copy} is passed as @code{FALSE}, you must be careful not to +-deallocate or modify the string as long as the hash table +-exists. +- +-@node Traversing a Hash Table, Deriving a New Hash Table Type, Looking Up or Entering a String, Hash Tables +-@subsection Traversing a hash table +-@findex bfd_hash_traverse +-The function @code{bfd_hash_traverse} may be used to traverse a +-hash table, calling a function on each element. The traversal +-is done in a random order. +- +-@code{bfd_hash_traverse} takes as arguments a function and a +-generic @code{void *} pointer. The function is called with a +-hash table entry (a @code{struct bfd_hash_entry *}) and the +-generic pointer passed to @code{bfd_hash_traverse}. The function +-must return a @code{boolean} value, which indicates whether to +-continue traversing the hash table. If the function returns +-@code{FALSE}, @code{bfd_hash_traverse} will stop the traversal and +-return immediately. +- +-@node Deriving a New Hash Table Type, , Traversing a Hash Table, Hash Tables +-@subsection Deriving a new hash table type +-Many uses of hash tables want to store additional information +-which each entry in the hash table. Some also find it +-convenient to store additional information with the hash table +-itself. This may be done using a derived hash table. +- +-Since C is not an object oriented language, creating a derived +-hash table requires sticking together some boilerplate +-routines with a few differences specific to the type of hash +-table you want to create. +- +-An example of a derived hash table is the linker hash table. +-The structures for this are defined in @code{bfdlink.h}. The +-functions are in @code{linker.c}. +- +-You may also derive a hash table from an already derived hash +-table. For example, the a.out linker backend code uses a hash +-table derived from the linker hash table. +- +-@menu +-* Define the Derived Structures:: +-* Write the Derived Creation Routine:: +-* Write Other Derived Routines:: +-@end menu +- +-@node Define the Derived Structures, Write the Derived Creation Routine, Deriving a New Hash Table Type, Deriving a New Hash Table Type +-@subsubsection Define the derived structures +-You must define a structure for an entry in the hash table, +-and a structure for the hash table itself. +- +-The first field in the structure for an entry in the hash +-table must be of the type used for an entry in the hash table +-you are deriving from. If you are deriving from a basic hash +-table this is @code{struct bfd_hash_entry}, which is defined in +-@code{bfd.h}. The first field in the structure for the hash +-table itself must be of the type of the hash table you are +-deriving from itself. If you are deriving from a basic hash +-table, this is @code{struct bfd_hash_table}. +- +-For example, the linker hash table defines @code{struct +-bfd_link_hash_entry} (in @code{bfdlink.h}). The first field, +-@code{root}, is of type @code{struct bfd_hash_entry}. Similarly, +-the first field in @code{struct bfd_link_hash_table}, @code{table}, +-is of type @code{struct bfd_hash_table}. +- +-@node Write the Derived Creation Routine, Write Other Derived Routines, Define the Derived Structures, Deriving a New Hash Table Type +-@subsubsection Write the derived creation routine +-You must write a routine which will create and initialize an +-entry in the hash table. This routine is passed as the +-function argument to @code{bfd_hash_table_init}. +- +-In order to permit other hash tables to be derived from the +-hash table you are creating, this routine must be written in a +-standard way. +- +-The first argument to the creation routine is a pointer to a +-hash table entry. This may be @code{NULL}, in which case the +-routine should allocate the right amount of space. Otherwise +-the space has already been allocated by a hash table type +-derived from this one. +- +-After allocating space, the creation routine must call the +-creation routine of the hash table type it is derived from, +-passing in a pointer to the space it just allocated. This +-will initialize any fields used by the base hash table. +- +-Finally the creation routine must initialize any local fields +-for the new hash table type. +- +-Here is a boilerplate example of a creation routine. +-@var{function_name} is the name of the routine. +-@var{entry_type} is the type of an entry in the hash table you +-are creating. @var{base_newfunc} is the name of the creation +-routine of the hash table type your hash table is derived +-from. +- +- +-@example +-struct bfd_hash_entry * +-@var{function_name} (struct bfd_hash_entry *entry, +- struct bfd_hash_table *table, +- const char *string) +-@{ +- struct @var{entry_type} *ret = (@var{entry_type} *) entry; +- +- /* Allocate the structure if it has not already been allocated by a +- derived class. */ +- if (ret == NULL) +- @{ +- ret = bfd_hash_allocate (table, sizeof (* ret)); +- if (ret == NULL) +- return NULL; +- @} +- +- /* Call the allocation method of the base class. */ +- ret = ((@var{entry_type} *) +- @var{base_newfunc} ((struct bfd_hash_entry *) ret, table, string)); +- +- /* Initialize the local fields here. */ +- +- return (struct bfd_hash_entry *) ret; +-@} +-@end example +-The creation routine for the linker hash table, which is in +-@code{linker.c}, looks just like this example. +-@var{function_name} is @code{_bfd_link_hash_newfunc}. +-@var{entry_type} is @code{struct bfd_link_hash_entry}. +-@var{base_newfunc} is @code{bfd_hash_newfunc}, the creation +-routine for a basic hash table. +- +-@code{_bfd_link_hash_newfunc} also initializes the local fields +-in a linker hash table entry: @code{type}, @code{written} and +-@code{next}. +- +-@node Write Other Derived Routines, , Write the Derived Creation Routine, Deriving a New Hash Table Type +-@subsubsection Write other derived routines +-You will want to write other routines for your new hash table, +-as well. +- +-You will want an initialization routine which calls the +-initialization routine of the hash table you are deriving from +-and initializes any other local fields. For the linker hash +-table, this is @code{_bfd_link_hash_table_init} in @code{linker.c}. +- +-You will want a lookup routine which calls the lookup routine +-of the hash table you are deriving from and casts the result. +-The linker hash table uses @code{bfd_link_hash_lookup} in +-@code{linker.c} (this actually takes an additional argument which +-it uses to decide how to return the looked up value). +- +-You may want a traversal routine. This should just call the +-traversal routine of the hash table you are deriving from with +-appropriate casts. The linker hash table uses +-@code{bfd_link_hash_traverse} in @code{linker.c}. +- +-These routines may simply be defined as macros. For example, +-the a.out backend linker hash table, which is derived from the +-linker hash table, uses macros for the lookup and traversal +-routines. These are @code{aout_link_hash_lookup} and +-@code{aout_link_hash_traverse} in aoutx.h. +- +-@findex bfd_hash_table_init_n +-@subsubsection @code{bfd_hash_table_init_n} +-@deftypefn {Function} bool bfd_hash_table_init_n (struct bfd_hash_table *, struct bfd_hash_entry *(* {*newfunc*}) (struct bfd_hash_entry *, struct bfd_hash_table *, const char *), unsigned int {*entsize*}, unsigned int {*size*}); +-Create a new hash table, given a number of entries. +- +-@end deftypefn +-@findex bfd_hash_table_init +-@subsubsection @code{bfd_hash_table_init} +-@deftypefn {Function} bool bfd_hash_table_init (struct bfd_hash_table *, struct bfd_hash_entry *(* {*newfunc*}) (struct bfd_hash_entry *, struct bfd_hash_table *, const char *), unsigned int {*entsize*}); +-Create a new hash table with the default number of entries. +- +-@end deftypefn +-@findex bfd_hash_table_free +-@subsubsection @code{bfd_hash_table_free} +-@deftypefn {Function} void bfd_hash_table_free (struct bfd_hash_table *); +-Free a hash table. +- +-@end deftypefn +-@findex bfd_hash_lookup +-@subsubsection @code{bfd_hash_lookup} +-@deftypefn {Function} struct bfd_hash_entry *bfd_hash_lookup (struct bfd_hash_table *, const char *, bool {*create*}, bool {*copy*}); +-Look up a string in a hash table. +- +-@end deftypefn +-@findex bfd_hash_insert +-@subsubsection @code{bfd_hash_insert} +-@deftypefn {Function} struct bfd_hash_entry *bfd_hash_insert (struct bfd_hash_table *, const char *, unsigned long {*hash*}); +-Insert an entry in a hash table. +- +-@end deftypefn +-@findex bfd_hash_rename +-@subsubsection @code{bfd_hash_rename} +-@deftypefn {Function} void bfd_hash_rename (struct bfd_hash_table *, const char *, struct bfd_hash_entry *); +-Rename an entry in a hash table. +- +-@end deftypefn +-@findex bfd_hash_replace +-@subsubsection @code{bfd_hash_replace} +-@deftypefn {Function} void bfd_hash_replace (struct bfd_hash_table *, struct bfd_hash_entry * {*old*}, struct bfd_hash_entry * {*new*}); +-Replace an entry in a hash table. +- +-@end deftypefn +-@findex bfd_hash_allocate +-@subsubsection @code{bfd_hash_allocate} +-@deftypefn {Function} void *bfd_hash_allocate (struct bfd_hash_table *, unsigned int {*size*}); +-Allocate space in a hash table. +- +-@end deftypefn +-@findex bfd_hash_newfunc +-@subsubsection @code{bfd_hash_newfunc} +-@deftypefn {Function} struct bfd_hash_entry *bfd_hash_newfunc (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); +-Base method for creating a new hash table entry. +- +-@end deftypefn +-@findex bfd_hash_traverse +-@subsubsection @code{bfd_hash_traverse} +-@deftypefn {Function} void bfd_hash_traverse (struct bfd_hash_table *, bool (*) (struct bfd_hash_entry *, void *), void *); +-Traverse a hash table. +- +-@end deftypefn +-@findex bfd_hash_set_default_size +-@subsubsection @code{bfd_hash_set_default_size} +-@deftypefn {Function} unsigned int bfd_hash_set_default_size (unsigned int); +-Set hash table default size. +- +-@end deftypefn +-@findex _bfd_stringtab_init +-@subsubsection @code{_bfd_stringtab_init} +-@deftypefn {Function} struct bfd_strtab_hash *_bfd_stringtab_init (void); +-Create a new strtab. +- +-@end deftypefn +-@findex _bfd_xcoff_stringtab_init +-@subsubsection @code{_bfd_xcoff_stringtab_init} +-@deftypefn {Function} struct bfd_strtab_hash *_bfd_xcoff_stringtab_init (bool {*isxcoff64*}); +-Create a new strtab in which the strings are output in the format +-used in the XCOFF .debug section: a two byte length precedes each +-string. +- +-@end deftypefn +-@findex _bfd_stringtab_free +-@subsubsection @code{_bfd_stringtab_free} +-@deftypefn {Function} void _bfd_stringtab_free (struct bfd_strtab_hash *); +-Free a strtab. +- +-@end deftypefn +-@findex _bfd_stringtab_add +-@subsubsection @code{_bfd_stringtab_add} +-@deftypefn {Function} bfd_size_type _bfd_stringtab_add (struct bfd_strtab_hash *, const char *, bool {*hash*}, bool {*copy*}); +-Get the index of a string in a strtab, adding it if it is not +-already present. If HASH is FALSE, we don't really use the hash +-table, and we don't eliminate duplicate strings. If COPY is true +-then store a copy of STR if creating a new entry. +- +-@end deftypefn +-@findex _bfd_stringtab_size +-@subsubsection @code{_bfd_stringtab_size} +-@deftypefn {Function} bfd_size_type _bfd_stringtab_size (struct bfd_strtab_hash *); +-Get the number of bytes in a strtab. +- +-@end deftypefn +-@findex _bfd_stringtab_emit +-@subsubsection @code{_bfd_stringtab_emit} +-@deftypefn {Function} bool _bfd_stringtab_emit (bfd *, struct bfd_strtab_hash *); +-Write out a strtab. ABFD must already be at the right location in +-the file. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/libbfd.texi gdb-14.1-sw64/bfd/doc/libbfd.texi +--- gdb-14.1-after-patch/bfd/doc/libbfd.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/libbfd.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,274 +0,0 @@ +-@section Implementation details +- +- +-@subsection Internal functions +- +- +-These routines are used within BFD. +-They are not intended for export, but are documented here for +-completeness. +- +-@findex bfd_malloc +-@subsubsection @code{bfd_malloc} +-@deftypefn {Function} void *bfd_malloc (bfd_size_type {*size*}); +-Returns a pointer to an allocated block of memory that is at least +-SIZE bytes long. If SIZE is 0 then it will be treated as if it were +-1. If SIZE is too big then NULL will be returned. +-Returns NULL upon error and sets bfd_error. +- +-@end deftypefn +-@findex bfd_realloc +-@subsubsection @code{bfd_realloc} +-@deftypefn {Function} void *bfd_realloc (void *{*mem*}, bfd_size_type {*size*}); +-Returns a pointer to an allocated block of memory that is at least +-SIZE bytes long. If SIZE is 0 then it will be treated as if it were +-1. If SIZE is too big then NULL will be returned. +-If MEM is not NULL then it must point to an allocated block of memory. +-If this block is large enough then MEM may be used as the return +-value for this function, but this is not guaranteed. +- +-If MEM is not returned then the first N bytes in the returned block +-will be identical to the first N bytes in region pointed to by MEM, +-where N is the lessor of SIZE and the length of the region of memory +-currently addressed by MEM. +- +-Returns NULL upon error and sets bfd_error. +- +-@end deftypefn +-@findex bfd_realloc_or_free +-@subsubsection @code{bfd_realloc_or_free} +-@deftypefn {Function} void *bfd_realloc_or_free (void *{*mem*}, bfd_size_type {*size*}); +-Returns a pointer to an allocated block of memory that is at least +-SIZE bytes long. If SIZE is 0 then no memory will be allocated, +-MEM will be freed, and NULL will be returned. This will not cause +-bfd_error to be set. +- +-If SIZE is too big then NULL will be returned and bfd_error will be +-set. +-If MEM is not NULL then it must point to an allocated block of memory. +-If this block is large enough then MEM may be used as the return +-value for this function, but this is not guaranteed. +- +-If MEM is not returned then the first N bytes in the returned block +-will be identical to the first N bytes in region pointed to by MEM, +-where N is the lessor of SIZE and the length of the region of memory +-currently addressed by MEM. +- +-@end deftypefn +-@findex bfd_zmalloc +-@subsubsection @code{bfd_zmalloc} +-@deftypefn {Function} void *bfd_zmalloc (bfd_size_type {*size*}); +-Returns a pointer to an allocated block of memory that is at least +-SIZE bytes long. If SIZE is 0 then it will be treated as if it were +-1. If SIZE is too big then NULL will be returned. +-Returns NULL upon error and sets bfd_error. +- +-If NULL is not returned then the allocated block of memory will +-have been cleared. +- +-@end deftypefn +-@findex bfd_alloc +-@subsubsection @code{bfd_alloc} +-@deftypefn {Function} void *bfd_alloc (bfd *abfd, bfd_size_type wanted); +-Allocate a block of @var{wanted} bytes of memory attached to +-@code{abfd} and return a pointer to it. +- +-@end deftypefn +-@findex bfd_zalloc +-@subsubsection @code{bfd_zalloc} +-@deftypefn {Function} void *bfd_zalloc (bfd *abfd, bfd_size_type wanted); +-Allocate a block of @var{wanted} bytes of zeroed memory +-attached to @code{abfd} and return a pointer to it. +- +-@end deftypefn +-@findex bfd_release +-@subsubsection @code{bfd_release} +-@deftypefn {Function} void bfd_release (bfd *, void *); +-Free a block allocated for a BFD. +-Note: Also frees all more recently allocated blocks! +- +-@end deftypefn +-@findex bfd_write_bigendian_4byte_int +-@subsubsection @code{bfd_write_bigendian_4byte_int} +-@deftypefn {Function} bool bfd_write_bigendian_4byte_int (bfd *, unsigned int); +-Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big +-endian order regardless of what else is going on. This is useful in +-archives. +- +-@end deftypefn +-@findex bfd_put_size +-@subsubsection @code{bfd_put_size} +-@findex bfd_get_size +-@subsubsection @code{bfd_get_size} +-These macros as used for reading and writing raw data in +-sections; each access (except for bytes) is vectored through +-the target format of the BFD and mangled accordingly. The +-mangling performs any necessary endian translations and +-removes alignment restrictions. Note that types accepted and +-returned by these macros are identical so they can be swapped +-around in macros---for example, @file{libaout.h} defines @code{GET_WORD} +-to either @code{bfd_get_32} or @code{bfd_get_64}. +- +-In the put routines, @var{val} must be a @code{bfd_vma}. If we are on a +-system without prototypes, the caller is responsible for making +-sure that is true, with a cast if necessary. We don't cast +-them in the macro definitions because that would prevent @code{lint} +-or @code{gcc -Wall} from detecting sins such as passing a pointer. +-To detect calling these with less than a @code{bfd_vma}, use +-@code{gcc -Wconversion} on a host with 64 bit @code{bfd_vma}'s. +-@example +- +-/* Byte swapping macros for user section data. */ +- +-#define bfd_put_8(abfd, val, ptr) \ +- ((void) (*((bfd_byte *) (ptr)) = (val) & 0xff)) +-#define bfd_put_signed_8 \ +- bfd_put_8 +-#define bfd_get_8(abfd, ptr) \ +- ((bfd_vma) *(const bfd_byte *) (ptr) & 0xff) +-#define bfd_get_signed_8(abfd, ptr) \ +- ((((bfd_signed_vma) *(const bfd_byte *) (ptr) & 0xff) ^ 0x80) - 0x80) +- +-#define bfd_put_16(abfd, val, ptr) \ +- BFD_SEND (abfd, bfd_putx16, ((val),(ptr))) +-#define bfd_put_signed_16 \ +- bfd_put_16 +-#define bfd_get_16(abfd, ptr) \ +- BFD_SEND (abfd, bfd_getx16, (ptr)) +-#define bfd_get_signed_16(abfd, ptr) \ +- BFD_SEND (abfd, bfd_getx_signed_16, (ptr)) +- +-#define bfd_put_24(abfd, val, ptr) \ +- do \ +- if (bfd_big_endian (abfd)) \ +- bfd_putb24 ((val), (ptr)); \ +- else \ +- bfd_putl24 ((val), (ptr)); \ +- while (0) +- +-bfd_vma bfd_getb24 (const void *p); +-bfd_vma bfd_getl24 (const void *p); +- +-#define bfd_get_24(abfd, ptr) \ +- (bfd_big_endian (abfd) ? bfd_getb24 (ptr) : bfd_getl24 (ptr)) +- +-#define bfd_put_32(abfd, val, ptr) \ +- BFD_SEND (abfd, bfd_putx32, ((val),(ptr))) +-#define bfd_put_signed_32 \ +- bfd_put_32 +-#define bfd_get_32(abfd, ptr) \ +- BFD_SEND (abfd, bfd_getx32, (ptr)) +-#define bfd_get_signed_32(abfd, ptr) \ +- BFD_SEND (abfd, bfd_getx_signed_32, (ptr)) +- +-#define bfd_put_64(abfd, val, ptr) \ +- BFD_SEND (abfd, bfd_putx64, ((val), (ptr))) +-#define bfd_put_signed_64 \ +- bfd_put_64 +-#define bfd_get_64(abfd, ptr) \ +- BFD_SEND (abfd, bfd_getx64, (ptr)) +-#define bfd_get_signed_64(abfd, ptr) \ +- BFD_SEND (abfd, bfd_getx_signed_64, (ptr)) +- +-#define bfd_get(bits, abfd, ptr) \ +- ((bits) == 8 ? bfd_get_8 (abfd, ptr) \ +- : (bits) == 16 ? bfd_get_16 (abfd, ptr) \ +- : (bits) == 32 ? bfd_get_32 (abfd, ptr) \ +- : (bits) == 64 ? bfd_get_64 (abfd, ptr) \ +- : (abort (), (bfd_vma) - 1)) +- +-#define bfd_put(bits, abfd, val, ptr) \ +- ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \ +- : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \ +- : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \ +- : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \ +- : (abort (), (void) 0)) +- +-@end example +- +-@findex bfd_h_put_size +-@subsubsection @code{bfd_h_put_size} +-These macros have the same function as their @code{bfd_get_x} +-brethren, except that they are used for removing information +-for the header records of object files. Believe it or not, +-some object files keep their header records in big endian +-order and their data in little endian order. +-@example +- +-/* Byte swapping macros for file header data. */ +- +-#define bfd_h_put_8(abfd, val, ptr) \ +- bfd_put_8 (abfd, val, ptr) +-#define bfd_h_put_signed_8(abfd, val, ptr) \ +- bfd_put_8 (abfd, val, ptr) +-#define bfd_h_get_8(abfd, ptr) \ +- bfd_get_8 (abfd, ptr) +-#define bfd_h_get_signed_8(abfd, ptr) \ +- bfd_get_signed_8 (abfd, ptr) +- +-#define bfd_h_put_16(abfd, val, ptr) \ +- BFD_SEND (abfd, bfd_h_putx16, (val, ptr)) +-#define bfd_h_put_signed_16 \ +- bfd_h_put_16 +-#define bfd_h_get_16(abfd, ptr) \ +- BFD_SEND (abfd, bfd_h_getx16, (ptr)) +-#define bfd_h_get_signed_16(abfd, ptr) \ +- BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr)) +- +-#define bfd_h_put_32(abfd, val, ptr) \ +- BFD_SEND (abfd, bfd_h_putx32, (val, ptr)) +-#define bfd_h_put_signed_32 \ +- bfd_h_put_32 +-#define bfd_h_get_32(abfd, ptr) \ +- BFD_SEND (abfd, bfd_h_getx32, (ptr)) +-#define bfd_h_get_signed_32(abfd, ptr) \ +- BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr)) +- +-#define bfd_h_put_64(abfd, val, ptr) \ +- BFD_SEND (abfd, bfd_h_putx64, (val, ptr)) +-#define bfd_h_put_signed_64 \ +- bfd_h_put_64 +-#define bfd_h_get_64(abfd, ptr) \ +- BFD_SEND (abfd, bfd_h_getx64, (ptr)) +-#define bfd_h_get_signed_64(abfd, ptr) \ +- BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr)) +- +-/* Aliases for the above, which should eventually go away. */ +- +-#define H_PUT_64 bfd_h_put_64 +-#define H_PUT_32 bfd_h_put_32 +-#define H_PUT_16 bfd_h_put_16 +-#define H_PUT_8 bfd_h_put_8 +-#define H_PUT_S64 bfd_h_put_signed_64 +-#define H_PUT_S32 bfd_h_put_signed_32 +-#define H_PUT_S16 bfd_h_put_signed_16 +-#define H_PUT_S8 bfd_h_put_signed_8 +-#define H_GET_64 bfd_h_get_64 +-#define H_GET_32 bfd_h_get_32 +-#define H_GET_16 bfd_h_get_16 +-#define H_GET_8 bfd_h_get_8 +-#define H_GET_S64 bfd_h_get_signed_64 +-#define H_GET_S32 bfd_h_get_signed_32 +-#define H_GET_S16 bfd_h_get_signed_16 +-#define H_GET_S8 bfd_h_get_signed_8 +- +- +-@end example +- +-@findex Byte swapping routines. +-@subsubsection @code{Byte swapping routines.} +-@deftypefn {Function} uint64_t bfd_getb64 (const void *); uint64_t bfd_getl64 (const void *); int64_t bfd_getb_signed_64 (const void *); int64_t bfd_getl_signed_64 (const void *); bfd_vma bfd_getb32 (const void *); bfd_vma bfd_getl32 (const void *); bfd_signed_vma bfd_getb_signed_32 (const void *); bfd_signed_vma bfd_getl_signed_32 (const void *); bfd_vma bfd_getb16 (const void *); bfd_vma bfd_getl16 (const void *); bfd_signed_vma bfd_getb_signed_16 (const void *); bfd_signed_vma bfd_getl_signed_16 (const void *); void bfd_putb64 (uint64_t, void *); void bfd_putl64 (uint64_t, void *); void bfd_putb32 (bfd_vma, void *); void bfd_putl32 (bfd_vma, void *); void bfd_putb24 (bfd_vma, void *); void bfd_putl24 (bfd_vma, void *); void bfd_putb16 (bfd_vma, void *); void bfd_putl16 (bfd_vma, void *); uint64_t bfd_get_bits (const void *, int, bool); void bfd_put_bits (uint64_t, void *, int, bool); +-Read and write integers in a particular endian order. getb +-and putb functions handle big-endian, getl and putl handle +-little-endian. bfd_get_bits and bfd_put_bits specify +-big-endian by passing TRUE in the last parameter, +-little-endian by passing FALSE. +- +-@end deftypefn +-@findex bfd_log2 +-@subsubsection @code{bfd_log2} +-@deftypefn {Function} unsigned int bfd_log2 (bfd_vma x); +-Return the log base 2 of the value supplied, rounded up. E.g., an +-@var{x} of 1025 returns 11. A @var{x} of 0 returns 0. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/linker.texi gdb-14.1-sw64/bfd/doc/linker.texi +--- gdb-14.1-after-patch/bfd/doc/linker.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/linker.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,470 +0,0 @@ +-@section Linker Functions +-@cindex Linker +-The linker uses three special entry points in the BFD target +-vector. It is not necessary to write special routines for +-these entry points when creating a new BFD back end, since +-generic versions are provided. However, writing them can +-speed up linking and make it use significantly less runtime +-memory. +- +-The first routine creates a hash table used by the other +-routines. The second routine adds the symbols from an object +-file to the hash table. The third routine takes all the +-object files and links them together to create the output +-file. These routines are designed so that the linker proper +-does not need to know anything about the symbols in the object +-files that it is linking. The linker merely arranges the +-sections as directed by the linker script and lets BFD handle +-the details of symbols and relocs. +- +-The second routine and third routines are passed a pointer to +-a @code{struct bfd_link_info} structure (defined in +-@code{bfdlink.h}) which holds information relevant to the link, +-including the linker hash table (which was created by the +-first routine) and a set of callback functions to the linker +-proper. +- +-The generic linker routines are in @code{linker.c}, and use the +-header file @code{genlink.h}. As of this writing, the only back +-ends which have implemented versions of these routines are +-a.out (in @code{aoutx.h}) and ECOFF (in @code{ecoff.c}). The a.out +-routines are used as examples throughout this section. +- +-@menu +-* Creating a Linker Hash Table:: +-* Adding Symbols to the Hash Table:: +-* Performing the Final Link:: +-@end menu +- +-@node Creating a Linker Hash Table, Adding Symbols to the Hash Table, Linker Functions, Linker Functions +-@subsection Creating a linker hash table +-@cindex _bfd_link_hash_table_create in target vector +-@cindex target vector (_bfd_link_hash_table_create) +-The linker routines must create a hash table, which must be +-derived from @code{struct bfd_link_hash_table} described in +-@code{bfdlink.c}. @xref{Hash Tables}, for information on how to +-create a derived hash table. This entry point is called using +-the target vector of the linker output file. +- +-The @code{_bfd_link_hash_table_create} entry point must allocate +-and initialize an instance of the desired hash table. If the +-back end does not require any additional information to be +-stored with the entries in the hash table, the entry point may +-simply create a @code{struct bfd_link_hash_table}. Most likely, +-however, some additional information will be needed. +- +-For example, with each entry in the hash table the a.out +-linker keeps the index the symbol has in the final output file +-(this index number is used so that when doing a relocatable +-link the symbol index used in the output file can be quickly +-filled in when copying over a reloc). The a.out linker code +-defines the required structures and functions for a hash table +-derived from @code{struct bfd_link_hash_table}. The a.out linker +-hash table is created by the function +-@code{NAME(aout,link_hash_table_create)}; it simply allocates +-space for the hash table, initializes it, and returns a +-pointer to it. +- +-When writing the linker routines for a new back end, you will +-generally not know exactly which fields will be required until +-you have finished. You should simply create a new hash table +-which defines no additional fields, and then simply add fields +-as they become necessary. +- +-@node Adding Symbols to the Hash Table, Performing the Final Link, Creating a Linker Hash Table, Linker Functions +-@subsection Adding symbols to the hash table +-@cindex _bfd_link_add_symbols in target vector +-@cindex target vector (_bfd_link_add_symbols) +-The linker proper will call the @code{_bfd_link_add_symbols} +-entry point for each object file or archive which is to be +-linked (typically these are the files named on the command +-line, but some may also come from the linker script). The +-entry point is responsible for examining the file. For an +-object file, BFD must add any relevant symbol information to +-the hash table. For an archive, BFD must determine which +-elements of the archive should be used and adding them to the +-link. +- +-The a.out version of this entry point is +-@code{NAME(aout,link_add_symbols)}. +- +-@menu +-* Differing file formats:: +-* Adding symbols from an object file:: +-* Adding symbols from an archive:: +-@end menu +- +-@node Differing file formats, Adding symbols from an object file, Adding Symbols to the Hash Table, Adding Symbols to the Hash Table +-@subsubsection Differing file formats +-Normally all the files involved in a link will be of the same +-format, but it is also possible to link together different +-format object files, and the back end must support that. The +-@code{_bfd_link_add_symbols} entry point is called via the target +-vector of the file to be added. This has an important +-consequence: the function may not assume that the hash table +-is the type created by the corresponding +-@code{_bfd_link_hash_table_create} vector. All the +-@code{_bfd_link_add_symbols} function can assume about the hash +-table is that it is derived from @code{struct +-bfd_link_hash_table}. +- +-Sometimes the @code{_bfd_link_add_symbols} function must store +-some information in the hash table entry to be used by the +-@code{_bfd_final_link} function. In such a case the output bfd +-xvec must be checked to make sure that the hash table was +-created by an object file of the same format. +- +-The @code{_bfd_final_link} routine must be prepared to handle a +-hash entry without any extra information added by the +-@code{_bfd_link_add_symbols} function. A hash entry without +-extra information will also occur when the linker script +-directs the linker to create a symbol. Note that, regardless +-of how a hash table entry is added, all the fields will be +-initialized to some sort of null value by the hash table entry +-initialization function. +- +-See @code{ecoff_link_add_externals} for an example of how to +-check the output bfd before saving information (in this +-case, the ECOFF external symbol debugging information) in a +-hash table entry. +- +-@node Adding symbols from an object file, Adding symbols from an archive, Differing file formats, Adding Symbols to the Hash Table +-@subsubsection Adding symbols from an object file +-When the @code{_bfd_link_add_symbols} routine is passed an object +-file, it must add all externally visible symbols in that +-object file to the hash table. The actual work of adding the +-symbol to the hash table is normally handled by the function +-@code{_bfd_generic_link_add_one_symbol}. The +-@code{_bfd_link_add_symbols} routine is responsible for reading +-all the symbols from the object file and passing the correct +-information to @code{_bfd_generic_link_add_one_symbol}. +- +-The @code{_bfd_link_add_symbols} routine should not use +-@code{bfd_canonicalize_symtab} to read the symbols. The point of +-providing this routine is to avoid the overhead of converting +-the symbols into generic @code{asymbol} structures. +- +-@findex _bfd_generic_link_add_one_symbol +-@code{_bfd_generic_link_add_one_symbol} handles the details of +-combining common symbols, warning about multiple definitions, +-and so forth. It takes arguments which describe the symbol to +-add, notably symbol flags, a section, and an offset. The +-symbol flags include such things as @code{BSF_WEAK} or +-@code{BSF_INDIRECT}. The section is a section in the object +-file, or something like @code{bfd_und_section_ptr} for an undefined +-symbol or @code{bfd_com_section_ptr} for a common symbol. +- +-If the @code{_bfd_final_link} routine is also going to need to +-read the symbol information, the @code{_bfd_link_add_symbols} +-routine should save it somewhere attached to the object file +-BFD. However, the information should only be saved if the +-@code{keep_memory} field of the @code{info} argument is TRUE, so +-that the @code{-no-keep-memory} linker switch is effective. +- +-The a.out function which adds symbols from an object file is +-@code{aout_link_add_object_symbols}, and most of the interesting +-work is in @code{aout_link_add_symbols}. The latter saves +-pointers to the hash tables entries created by +-@code{_bfd_generic_link_add_one_symbol} indexed by symbol number, +-so that the @code{_bfd_final_link} routine does not have to call +-the hash table lookup routine to locate the entry. +- +-@node Adding symbols from an archive, , Adding symbols from an object file, Adding Symbols to the Hash Table +-@subsubsection Adding symbols from an archive +-When the @code{_bfd_link_add_symbols} routine is passed an +-archive, it must look through the symbols defined by the +-archive and decide which elements of the archive should be +-included in the link. For each such element it must call the +-@code{add_archive_element} linker callback, and it must add the +-symbols from the object file to the linker hash table. (The +-callback may in fact indicate that a replacement BFD should be +-used, in which case the symbols from that BFD should be added +-to the linker hash table instead.) +- +-@findex _bfd_generic_link_add_archive_symbols +-In most cases the work of looking through the symbols in the +-archive should be done by the +-@code{_bfd_generic_link_add_archive_symbols} function. +-@code{_bfd_generic_link_add_archive_symbols} is passed a function +-to call to make the final decision about adding an archive +-element to the link and to do the actual work of adding the +-symbols to the linker hash table. If the element is to +-be included, the @code{add_archive_element} linker callback +-routine must be called with the element as an argument, and +-the element's symbols must be added to the linker hash table +-just as though the element had itself been passed to the +-@code{_bfd_link_add_symbols} function. +- +-When the a.out @code{_bfd_link_add_symbols} function receives an +-archive, it calls @code{_bfd_generic_link_add_archive_symbols} +-passing @code{aout_link_check_archive_element} as the function +-argument. @code{aout_link_check_archive_element} calls +-@code{aout_link_check_ar_symbols}. If the latter decides to add +-the element (an element is only added if it provides a real, +-non-common, definition for a previously undefined or common +-symbol) it calls the @code{add_archive_element} callback and then +-@code{aout_link_check_archive_element} calls +-@code{aout_link_add_symbols} to actually add the symbols to the +-linker hash table - possibly those of a substitute BFD, if the +-@code{add_archive_element} callback avails itself of that option. +- +-The ECOFF back end is unusual in that it does not normally +-call @code{_bfd_generic_link_add_archive_symbols}, because ECOFF +-archives already contain a hash table of symbols. The ECOFF +-back end searches the archive itself to avoid the overhead of +-creating a new hash table. +- +-@node Performing the Final Link, , Adding Symbols to the Hash Table, Linker Functions +-@subsection Performing the final link +-@cindex _bfd_link_final_link in target vector +-@cindex target vector (_bfd_final_link) +-When all the input files have been processed, the linker calls +-the @code{_bfd_final_link} entry point of the output BFD. This +-routine is responsible for producing the final output file, +-which has several aspects. It must relocate the contents of +-the input sections and copy the data into the output sections. +-It must build an output symbol table including any local +-symbols from the input files and the global symbols from the +-hash table. When producing relocatable output, it must +-modify the input relocs and write them into the output file. +-There may also be object format dependent work to be done. +- +-The linker will also call the @code{write_object_contents} entry +-point when the BFD is closed. The two entry points must work +-together in order to produce the correct output file. +- +-The details of how this works are inevitably dependent upon +-the specific object file format. The a.out +-@code{_bfd_final_link} routine is @code{NAME(aout,final_link)}. +- +-@menu +-* Information provided by the linker:: +-* Relocating the section contents:: +-* Writing the symbol table:: +-@end menu +- +-@node Information provided by the linker, Relocating the section contents, Performing the Final Link, Performing the Final Link +-@subsubsection Information provided by the linker +-Before the linker calls the @code{_bfd_final_link} entry point, +-it sets up some data structures for the function to use. +- +-The @code{input_bfds} field of the @code{bfd_link_info} structure +-will point to a list of all the input files included in the +-link. These files are linked through the @code{link.next} field +-of the @code{bfd} structure. +- +-Each section in the output file will have a list of +-@code{link_order} structures attached to the @code{map_head.link_order} +-field (the @code{link_order} structure is defined in +-@code{bfdlink.h}). These structures describe how to create the +-contents of the output section in terms of the contents of +-various input sections, fill constants, and, eventually, other +-types of information. They also describe relocs that must be +-created by the BFD backend, but do not correspond to any input +-file; this is used to support -Ur, which builds constructors +-while generating a relocatable object file. +- +-@node Relocating the section contents, Writing the symbol table, Information provided by the linker, Performing the Final Link +-@subsubsection Relocating the section contents +-The @code{_bfd_final_link} function should look through the +-@code{link_order} structures attached to each section of the +-output file. Each @code{link_order} structure should either be +-handled specially, or it should be passed to the function +-@code{_bfd_default_link_order} which will do the right thing +-(@code{_bfd_default_link_order} is defined in @code{linker.c}). +- +-For efficiency, a @code{link_order} of type +-@code{bfd_indirect_link_order} whose associated section belongs +-to a BFD of the same format as the output BFD must be handled +-specially. This type of @code{link_order} describes part of an +-output section in terms of a section belonging to one of the +-input files. The @code{_bfd_final_link} function should read the +-contents of the section and any associated relocs, apply the +-relocs to the section contents, and write out the modified +-section contents. If performing a relocatable link, the +-relocs themselves must also be modified and written out. +- +-@findex _bfd_relocate_contents +-@findex _bfd_final_link_relocate +-The functions @code{_bfd_relocate_contents} and +-@code{_bfd_final_link_relocate} provide some general support for +-performing the actual relocations, notably overflow checking. +-Their arguments include information about the symbol the +-relocation is against and a @code{reloc_howto_type} argument +-which describes the relocation to perform. These functions +-are defined in @code{reloc.c}. +- +-The a.out function which handles reading, relocating, and +-writing section contents is @code{aout_link_input_section}. The +-actual relocation is done in @code{aout_link_input_section_std} +-and @code{aout_link_input_section_ext}. +- +-@node Writing the symbol table, , Relocating the section contents, Performing the Final Link +-@subsubsection Writing the symbol table +-The @code{_bfd_final_link} function must gather all the symbols +-in the input files and write them out. It must also write out +-all the symbols in the global hash table. This must be +-controlled by the @code{strip} and @code{discard} fields of the +-@code{bfd_link_info} structure. +- +-The local symbols of the input files will not have been +-entered into the linker hash table. The @code{_bfd_final_link} +-routine must consider each input file and include the symbols +-in the output file. It may be convenient to do this when +-looking through the @code{link_order} structures, or it may be +-done by stepping through the @code{input_bfds} list. +- +-The @code{_bfd_final_link} routine must also traverse the global +-hash table to gather all the externally visible symbols. It +-is possible that most of the externally visible symbols may be +-written out when considering the symbols of each input file, +-but it is still necessary to traverse the hash table since the +-linker script may have defined some symbols that are not in +-any of the input files. +- +-The @code{strip} field of the @code{bfd_link_info} structure +-controls which symbols are written out. The possible values +-are listed in @code{bfdlink.h}. If the value is @code{strip_some}, +-then the @code{keep_hash} field of the @code{bfd_link_info} +-structure is a hash table of symbols to keep; each symbol +-should be looked up in this hash table, and only symbols which +-are present should be included in the output file. +- +-If the @code{strip} field of the @code{bfd_link_info} structure +-permits local symbols to be written out, the @code{discard} field +-is used to further controls which local symbols are included +-in the output file. If the value is @code{discard_l}, then all +-local symbols which begin with a certain prefix are discarded; +-this is controlled by the @code{bfd_is_local_label_name} entry point. +- +-The a.out backend handles symbols by calling +-@code{aout_link_write_symbols} on each input BFD and then +-traversing the global hash table with the function +-@code{aout_link_write_other_symbol}. It builds a string table +-while writing out the symbols, which is written to the output +-file at the end of @code{NAME(aout,final_link)}. +- +-@findex bfd_link_split_section +-@subsubsection @code{bfd_link_split_section} +-@deftypefn {Function} bool bfd_link_split_section (bfd *abfd, asection *sec); +-Return nonzero if @var{sec} should be split during a +-reloceatable or final link. +-@example +-#define bfd_link_split_section(abfd, sec) \ +- BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec)) +- +-@end example +- +-@end deftypefn +-@findex bfd_section_already_linked +-@subsubsection @code{bfd_section_already_linked} +-@deftypefn {Function} bool bfd_section_already_linked (bfd *abfd, asection *sec, struct bfd_link_info *info); +-Check if @var{data} has been already linked during a reloceatable +-or final link. Return TRUE if it has. +-@example +-#define bfd_section_already_linked(abfd, sec, info) \ +- BFD_SEND (abfd, _section_already_linked, (abfd, sec, info)) +- +-@end example +- +-@end deftypefn +-@findex bfd_generic_define_common_symbol +-@subsubsection @code{bfd_generic_define_common_symbol} +-@deftypefn {Function} bool bfd_generic_define_common_symbol (bfd *output_bfd, struct bfd_link_info *info, struct bfd_link_hash_entry *h); +-Convert common symbol @var{h} into a defined symbol. +-Return TRUE on success and FALSE on failure. +-@example +-#define bfd_define_common_symbol(output_bfd, info, h) \ +- BFD_SEND (output_bfd, _bfd_define_common_symbol, (output_bfd, info, h)) +- +-@end example +- +-@end deftypefn +-@findex _bfd_generic_link_hide_symbol +-@subsubsection @code{_bfd_generic_link_hide_symbol} +-@deftypefn {Function} void _bfd_generic_link_hide_symbol (bfd *output_bfd, struct bfd_link_info *info, struct bfd_link_hash_entry *h); +-Hide symbol @var{h}. +-This is an internal function. It should not be called from +-outside the BFD library. +-@example +-#define bfd_link_hide_symbol(output_bfd, info, h) \ +- BFD_SEND (output_bfd, _bfd_link_hide_symbol, (output_bfd, info, h)) +- +-@end example +- +-@end deftypefn +-@findex bfd_generic_define_start_stop +-@subsubsection @code{bfd_generic_define_start_stop} +-@deftypefn {Function} struct bfd_link_hash_entry *bfd_generic_define_start_stop (struct bfd_link_info *info, const char *symbol, asection *sec); +-Define a __start, __stop, .startof. or .sizeof. symbol. +-Return the symbol or NULL if no such undefined symbol exists. +-@example +-#define bfd_define_start_stop(output_bfd, info, symbol, sec) \ +- BFD_SEND (output_bfd, _bfd_define_start_stop, (info, symbol, sec)) +- +-@end example +- +-@end deftypefn +-@findex bfd_find_version_for_sym +-@subsubsection @code{bfd_find_version_for_sym} +-@deftypefn {Function} struct bfd_elf_version_tree * bfd_find_version_for_sym (struct bfd_elf_version_tree *verdefs, const char *sym_name, bool *hide); +-Search an elf version script tree for symbol versioning +-info and export / don't-export status for a given symbol. +-Return non-NULL on success and NULL on failure; also sets +-the output @samp{hide} boolean parameter. +- +-@end deftypefn +-@findex bfd_hide_sym_by_version +-@subsubsection @code{bfd_hide_sym_by_version} +-@deftypefn {Function} bool bfd_hide_sym_by_version (struct bfd_elf_version_tree *verdefs, const char *sym_name); +-Search an elf version script tree for symbol versioning +-info for a given symbol. Return TRUE if the symbol is hidden. +- +-@end deftypefn +-@findex bfd_link_check_relocs +-@subsubsection @code{bfd_link_check_relocs} +-@deftypefn {Function} bool bfd_link_check_relocs (bfd *abfd, struct bfd_link_info *info); +-Checks the relocs in ABFD for validity. +-Does not execute the relocs. +-Return TRUE if everything is OK, FALSE otherwise. +-This is the external entry point to this code. +- +-@end deftypefn +-@findex _bfd_generic_link_check_relocs +-@subsubsection @code{_bfd_generic_link_check_relocs} +-@deftypefn {Function} bool _bfd_generic_link_check_relocs (bfd *abfd, struct bfd_link_info *info); +-Stub function for targets that do not implement reloc checking. +-Return TRUE. +-This is an internal function. It should not be called from +-outside the BFD library. +- +-@end deftypefn +-@findex bfd_merge_private_bfd_data +-@subsubsection @code{bfd_merge_private_bfd_data} +-@deftypefn {Function} bool bfd_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info); +-Merge private BFD information from the BFD @var{ibfd} to the +-the output file BFD when linking. Return @code{TRUE} on success, +-@code{FALSE} on error. Possible error returns are: +- +-@itemize @bullet +- +-@item +-@code{bfd_error_no_memory} - +-Not enough memory exists to create private data for @var{obfd}. +-@end itemize +-@example +-#define bfd_merge_private_bfd_data(ibfd, info) \ +- BFD_SEND ((info)->output_bfd, _bfd_merge_private_bfd_data, \ +- (ibfd, info)) +- +-@end example +- +-@end deftypefn +-@findex _bfd_generic_verify_endian_match +-@subsubsection @code{_bfd_generic_verify_endian_match} +-@deftypefn {Function} bool _bfd_generic_verify_endian_match (bfd *ibfd, struct bfd_link_info *info); +-Can be used from / for bfd_merge_private_bfd_data to check that +-endianness matches between input and output file. Returns +-TRUE for a match, otherwise returns FALSE and emits an error. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/mmo.texi gdb-14.1-sw64/bfd/doc/mmo.texi +--- gdb-14.1-after-patch/bfd/doc/mmo.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/mmo.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,369 +0,0 @@ +-@section mmo backend +-The mmo object format is used exclusively together with Professor +-Donald E.@: Knuth's educational 64-bit processor MMIX. The simulator +-@command{mmix} which is available at +-@url{http://mmix.cs.hm.edu/src/index.html} +-understands this format. That package also includes a combined +-assembler and linker called @command{mmixal}. The mmo format has +-no advantages feature-wise compared to e.g. ELF. It is a simple +-non-relocatable object format with no support for archives or +-debugging information, except for symbol value information and +-line numbers (which is not yet implemented in BFD). See +-@url{http://mmix.cs.hm.edu/} for more +-information about MMIX. The ELF format is used for intermediate +-object files in the BFD implementation. +- +-@c We want to xref the symbol table node. A feature in "chew" +-@c requires that "commands" do not contain spaces in the +-@c arguments. Hence the hyphen in "Symbol-table". +-@menu +-* File layout:: +-* Symbol-table:: +-* mmo section mapping:: +-@end menu +- +-@node File layout, Symbol-table, mmo, mmo +-@subsection File layout +-The mmo file contents is not partitioned into named sections as +-with e.g.@: ELF. Memory areas is formed by specifying the +-location of the data that follows. Only the memory area +-@samp{0x0000@dots{}00} to @samp{0x01ff@dots{}ff} is executable, so +-it is used for code (and constants) and the area +-@samp{0x2000@dots{}00} to @samp{0x20ff@dots{}ff} is used for +-writable data. @xref{mmo section mapping}. +- +-There is provision for specifying ``special data'' of 65536 +-different types. We use type 80 (decimal), arbitrarily chosen the +-same as the ELF @code{e_machine} number for MMIX, filling it with +-section information normally found in ELF objects. @xref{mmo +-section mapping}. +- +-Contents is entered as 32-bit words, xor:ed over previous +-contents, always zero-initialized. A word that starts with the +-byte @samp{0x98} forms a command called a @samp{lopcode}, where +-the next byte distinguished between the thirteen lopcodes. The +-two remaining bytes, called the @samp{Y} and @samp{Z} fields, or +-the @samp{YZ} field (a 16-bit big-endian number), are used for +-various purposes different for each lopcode. As documented in +-@url{http://mmix.cs.hm.edu/doc/mmixal.pdf}, +-the lopcodes are: +- +-@table @code +-@item lop_quote +-0x98000001. The next word is contents, regardless of whether it +-starts with 0x98 or not. +- +-@item lop_loc +-0x9801YYZZ, where @samp{Z} is 1 or 2. This is a location +-directive, setting the location for the next data to the next +-32-bit word (for @math{Z = 1}) or 64-bit word (for @math{Z = 2}), +-plus @math{Y * 2^56}. Normally @samp{Y} is 0 for the text segment +-and 2 for the data segment. Beware that the low bits of non- +-tetrabyte-aligned values are silently discarded when being +-automatically incremented and when storing contents (in contrast +-to e.g. its use as current location when followed by lop_fixo +-et al before the next possibly-quoted tetrabyte contents). +- +-@item lop_skip +-0x9802YYZZ. Increase the current location by @samp{YZ} bytes. +- +-@item lop_fixo +-0x9803YYZZ, where @samp{Z} is 1 or 2. Store the current location +-as 64 bits into the location pointed to by the next 32-bit +-(@math{Z = 1}) or 64-bit (@math{Z = 2}) word, plus @math{Y * +-2^56}. +- +-@item lop_fixr +-0x9804YYZZ. @samp{YZ} is stored into the current location plus +-@math{2 - 4 * YZ}. +- +-@item lop_fixrx +-0x980500ZZ. @samp{Z} is 16 or 24. A value @samp{L} derived from +-the following 32-bit word are used in a manner similar to +-@samp{YZ} in lop_fixr: it is xor:ed into the current location +-minus @math{4 * L}. The first byte of the word is 0 or 1. If it +-is 1, then @math{L = (@var{lowest 24 bits of word}) - 2^Z}, if 0, +-then @math{L = (@var{lowest 24 bits of word})}. +- +-@item lop_file +-0x9806YYZZ. @samp{Y} is the file number, @samp{Z} is count of +-32-bit words. Set the file number to @samp{Y} and the line +-counter to 0. The next @math{Z * 4} bytes contain the file name, +-padded with zeros if the count is not a multiple of four. The +-same @samp{Y} may occur multiple times, but @samp{Z} must be 0 for +-all but the first occurrence. +- +-@item lop_line +-0x9807YYZZ. @samp{YZ} is the line number. Together with +-lop_file, it forms the source location for the next 32-bit word. +-Note that for each non-lopcode 32-bit word, line numbers are +-assumed incremented by one. +- +-@item lop_spec +-0x9808YYZZ. @samp{YZ} is the type number. Data until the next +-lopcode other than lop_quote forms special data of type @samp{YZ}. +-@xref{mmo section mapping}. +- +-Other types than 80, (or type 80 with a content that does not +-parse) is stored in sections named @code{.MMIX.spec_data.@var{n}} +-where @var{n} is the @samp{YZ}-type. The flags for such a +-sections say not to allocate or load the data. The vma is 0. +-Contents of multiple occurrences of special data @var{n} is +-concatenated to the data of the previous lop_spec @var{n}s. The +-location in data or code at which the lop_spec occurred is lost. +- +-@item lop_pre +-0x980901ZZ. The first lopcode in a file. The @samp{Z} field forms the +-length of header information in 32-bit words, where the first word +-tells the time in seconds since @samp{00:00:00 GMT Jan 1 1970}. +- +-@item lop_post +-0x980a00ZZ. @math{Z > 32}. This lopcode follows after all +-content-generating lopcodes in a program. The @samp{Z} field +-denotes the value of @samp{rG} at the beginning of the program. +-The following @math{256 - Z} big-endian 64-bit words are loaded +-into global registers @samp{$G} @dots{} @samp{$255}. +- +-@item lop_stab +-0x980b0000. The next-to-last lopcode in a program. Must follow +-immediately after the lop_post lopcode and its data. After this +-lopcode follows all symbols in a compressed format +-(@pxref{Symbol-table}). +- +-@item lop_end +-0x980cYYZZ. The last lopcode in a program. It must follow the +-lop_stab lopcode and its data. The @samp{YZ} field contains the +-number of 32-bit words of symbol table information after the +-preceding lop_stab lopcode. +-@end table +- +-Note that the lopcode "fixups"; @code{lop_fixr}, @code{lop_fixrx} and +-@code{lop_fixo} are not generated by BFD, but are handled. They are +-generated by @code{mmixal}. +- +-This trivial one-label, one-instruction file: +- +-@example +- :Main TRAP 1,2,3 +-@end example +- +-can be represented this way in mmo: +- +-@example +- 0x98090101 - lop_pre, one 32-bit word with timestamp. +- +- 0x98010002 - lop_loc, text segment, using a 64-bit address. +- Note that mmixal does not emit this for the file above. +- 0x00000000 - Address, high 32 bits. +- 0x00000000 - Address, low 32 bits. +- 0x98060002 - lop_file, 2 32-bit words for file-name. +- 0x74657374 - "test" +- 0x2e730000 - ".s\0\0" +- 0x98070001 - lop_line, line 1. +- 0x00010203 - TRAP 1,2,3 +- 0x980a00ff - lop_post, setting $255 to 0. +- 0x00000000 +- 0x00000000 +- 0x980b0000 - lop_stab for ":Main" = 0, serial 1. +- 0x203a4040 @xref{Symbol-table}. +- 0x10404020 +- 0x4d206120 +- 0x69016e00 +- 0x81000000 +- 0x980c0005 - lop_end; symbol table contained five 32-bit words. +-@end example +-@node Symbol-table, mmo section mapping, File layout, mmo +-@subsection Symbol table format +-From mmixal.w (or really, the generated mmixal.tex) in the +-MMIXware package which also contains the @command{mmix} simulator: +-``Symbols are stored and retrieved by means of a @samp{ternary +-search trie}, following ideas of Bentley and Sedgewick. (See +-ACM--SIAM Symp.@: on Discrete Algorithms @samp{8} (1997), 360--369; +-R.@:Sedgewick, @samp{Algorithms in C} (Reading, Mass.@: +-Addison--Wesley, 1998), @samp{15.4}.) Each trie node stores a +-character, and there are branches to subtries for the cases where +-a given character is less than, equal to, or greater than the +-character in the trie. There also is a pointer to a symbol table +-entry if a symbol ends at the current node.'' +- +-So it's a tree encoded as a stream of bytes. The stream of bytes +-acts on a single virtual global symbol, adding and removing +-characters and signalling complete symbol points. Here, we read +-the stream and create symbols at the completion points. +- +-First, there's a control byte @code{m}. If any of the listed bits +-in @code{m} is nonzero, we execute what stands at the right, in +-the listed order: +- +-@example +- (MMO3_LEFT) +- 0x40 - Traverse left trie. +- (Read a new command byte and recurse.) +- +- (MMO3_SYMBITS) +- 0x2f - Read the next byte as a character and store it in the +- current character position; increment character position. +- Test the bits of @code{m}: +- +- (MMO3_WCHAR) +- 0x80 - The character is 16-bit (so read another byte, +- merge into current character. +- +- (MMO3_TYPEBITS) +- 0xf - We have a complete symbol; parse the type, value +- and serial number and do what should be done +- with a symbol. The type and length information +- is in j = (m & 0xf). +- +- (MMO3_REGQUAL_BITS) +- j == 0xf: A register variable. The following +- byte tells which register. +- j <= 8: An absolute symbol. Read j bytes as the +- big-endian number the symbol equals. +- A j = 2 with two zero bytes denotes an +- unknown symbol. +- j > 8: As with j <= 8, but add (0x20 << 56) +- to the value in the following j - 8 +- bytes. +- +- Then comes the serial number, as a variant of +- uleb128, but better named ubeb128: +- Read bytes and shift the previous value left 7 +- (multiply by 128). Add in the new byte, repeat +- until a byte has bit 7 set. The serial number +- is the computed value minus 128. +- +- (MMO3_MIDDLE) +- 0x20 - Traverse middle trie. (Read a new command byte +- and recurse.) Decrement character position. +- +- (MMO3_RIGHT) +- 0x10 - Traverse right trie. (Read a new command byte and +- recurse.) +-@end example +- +-Let's look again at the @code{lop_stab} for the trivial file +-(@pxref{File layout}). +- +-@example +- 0x980b0000 - lop_stab for ":Main" = 0, serial 1. +- 0x203a4040 +- 0x10404020 +- 0x4d206120 +- 0x69016e00 +- 0x81000000 +-@end example +- +-This forms the trivial trie (note that the path between ``:'' and +-``M'' is redundant): +- +-@example +- 203a ":" +- 40 / +- 40 / +- 10 \ +- 40 / +- 40 / +- 204d "M" +- 2061 "a" +- 2069 "i" +- 016e "n" is the last character in a full symbol, and +- with a value represented in one byte. +- 00 The value is 0. +- 81 The serial number is 1. +-@end example +- +-@node mmo section mapping, , Symbol-table, mmo +-@subsection mmo section mapping +-The implementation in BFD uses special data type 80 (decimal) to +-encapsulate and describe named sections, containing e.g.@: debug +-information. If needed, any datum in the encapsulation will be +-quoted using lop_quote. First comes a 32-bit word holding the +-number of 32-bit words containing the zero-terminated zero-padded +-segment name. After the name there's a 32-bit word holding flags +-describing the section type. Then comes a 64-bit big-endian word +-with the section length (in bytes), then another with the section +-start address. Depending on the type of section, the contents +-might follow, zero-padded to 32-bit boundary. For a loadable +-section (such as data or code), the contents might follow at some +-later point, not necessarily immediately, as a lop_loc with the +-same start address as in the section description, followed by the +-contents. This in effect forms a descriptor that must be emitted +-before the actual contents. Sections described this way must not +-overlap. +- +-For areas that don't have such descriptors, synthetic sections are +-formed by BFD. Consecutive contents in the two memory areas +-@samp{0x0000@dots{}00} to @samp{0x01ff@dots{}ff} and +-@samp{0x2000@dots{}00} to @samp{0x20ff@dots{}ff} are entered in +-sections named @code{.text} and @code{.data} respectively. If an area +-is not otherwise described, but would together with a neighboring +-lower area be less than @samp{0x40000000} bytes long, it is joined +-with the lower area and the gap is zero-filled. For other cases, +-a new section is formed, named @code{.MMIX.sec.@var{n}}. Here, +-@var{n} is a number, a running count through the mmo file, +-starting at 0. +- +-A loadable section specified as: +- +-@example +- .section secname,"ax" +- TETRA 1,2,3,4,-1,-2009 +- BYTE 80 +-@end example +- +-and linked to address @samp{0x4}, is represented by the sequence: +- +-@example +- 0x98080050 - lop_spec 80 +- 0x00000002 - two 32-bit words for the section name +- 0x7365636e - "secn" +- 0x616d6500 - "ame\0" +- 0x00000033 - flags CODE, READONLY, LOAD, ALLOC +- 0x00000000 - high 32 bits of section length +- 0x0000001c - section length is 28 bytes; 6 * 4 + 1 + alignment to 32 bits +- 0x00000000 - high 32 bits of section address +- 0x00000004 - section address is 4 +- 0x98010002 - 64 bits with address of following data +- 0x00000000 - high 32 bits of address +- 0x00000004 - low 32 bits: data starts at address 4 +- 0x00000001 - 1 +- 0x00000002 - 2 +- 0x00000003 - 3 +- 0x00000004 - 4 +- 0xffffffff - -1 +- 0xfffff827 - -2009 +- 0x50000000 - 80 as a byte, padded with zeros. +-@end example +- +-Note that the lop_spec wrapping does not include the section +-contents. Compare this to a non-loaded section specified as: +- +-@example +- .section thirdsec +- TETRA 200001,100002 +- BYTE 38,40 +-@end example +- +-This, when linked to address @samp{0x200000000000001c}, is +-represented by: +- +-@example +- 0x98080050 - lop_spec 80 +- 0x00000002 - two 32-bit words for the section name +- 0x7365636e - "thir" +- 0x616d6500 - "dsec" +- 0x00000010 - flag READONLY +- 0x00000000 - high 32 bits of section length +- 0x0000000c - section length is 12 bytes; 2 * 4 + 2 + alignment to 32 bits +- 0x20000000 - high 32 bits of address +- 0x0000001c - low 32 bits of address 0x200000000000001c +- 0x00030d41 - 200001 +- 0x000186a2 - 100002 +- 0x26280000 - 38, 40 as bytes, padded with zeros +-@end example +- +-For the latter example, the section contents must not be +-loaded in memory, and is therefore specified as part of the +-special data. The address is usually unimportant but might +-provide information for e.g.@: the DWARF 2 debugging format. +diff -Naur gdb-14.1-after-patch/bfd/doc/opncls.texi gdb-14.1-sw64/bfd/doc/opncls.texi +--- gdb-14.1-after-patch/bfd/doc/opncls.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/opncls.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,373 +0,0 @@ +-@section Opening and closing BFDs +- +- +-@subsection Functions for opening and closing +- +- +-@findex _bfd_new_bfd +-@subsubsection @code{_bfd_new_bfd} +-@deftypefn {Function} bfd *_bfd_new_bfd (void); +-Return a new BFD. All BFD's are allocated through this routine. +- +-@end deftypefn +-@findex _bfd_new_bfd_contained_in +-@subsubsection @code{_bfd_new_bfd_contained_in} +-@deftypefn {Function} bfd *_bfd_new_bfd_contained_in (bfd *); +-Allocate a new BFD as a member of archive OBFD. +- +-@end deftypefn +-@findex _bfd_free_cached_info +-@subsubsection @code{_bfd_free_cached_info} +-@deftypefn {Function} bool _bfd_free_cached_info (bfd *); +-Free objalloc memory. +- +-@end deftypefn +-@findex bfd_fopen +-@subsubsection @code{bfd_fopen} +-@deftypefn {Function} bfd *bfd_fopen (const char *filename, const char *target, const char *mode, int fd); +-Open the file @var{filename} with the target @var{target}. +-Return a pointer to the created BFD. If @var{fd} is not -1, +-then @code{fdopen} is used to open the file; otherwise, @code{fopen} +-is used. @var{mode} is passed directly to @code{fopen} or +-@code{fdopen}. +- +-Calls @code{bfd_find_target}, so @var{target} is interpreted as by +-that function. +- +-The new BFD is marked as cacheable iff @var{fd} is -1. +- +-If @code{NULL} is returned then an error has occured. Possible errors +-are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} or +-@code{system_call} error. +- +-On error, @var{fd} is always closed. +- +-A copy of the @var{filename} argument is stored in the newly created +-BFD. It can be accessed via the bfd_get_filename() macro. +- +-@end deftypefn +-@findex bfd_openr +-@subsubsection @code{bfd_openr} +-@deftypefn {Function} bfd *bfd_openr (const char *filename, const char *target); +-Open the file @var{filename} (using @code{fopen}) with the target +-@var{target}. Return a pointer to the created BFD. +- +-Calls @code{bfd_find_target}, so @var{target} is interpreted as by +-that function. +- +-If @code{NULL} is returned then an error has occured. Possible errors +-are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} or +-@code{system_call} error. +- +-A copy of the @var{filename} argument is stored in the newly created +-BFD. It can be accessed via the bfd_get_filename() macro. +- +-@end deftypefn +-@findex bfd_fdopenr +-@subsubsection @code{bfd_fdopenr} +-@deftypefn {Function} bfd *bfd_fdopenr (const char *filename, const char *target, int fd); +-@code{bfd_fdopenr} is to @code{bfd_fopenr} much like @code{fdopen} is to +-@code{fopen}. It opens a BFD on a file already described by the +-@var{fd} supplied. +- +-When the file is later @code{bfd_close}d, the file descriptor will +-be closed. If the caller desires that this file descriptor be +-cached by BFD (opened as needed, closed as needed to free +-descriptors for other opens), with the supplied @var{fd} used as +-an initial file descriptor (but subject to closure at any time), +-call bfd_set_cacheable(bfd, 1) on the returned BFD. The default +-is to assume no caching; the file descriptor will remain open +-until @code{bfd_close}, and will not be affected by BFD operations +-on other files. +- +-Possible errors are @code{bfd_error_no_memory}, +-@code{bfd_error_invalid_target} and @code{bfd_error_system_call}. +- +-On error, @var{fd} is closed. +- +-A copy of the @var{filename} argument is stored in the newly created +-BFD. It can be accessed via the bfd_get_filename() macro. +- +-@end deftypefn +-@findex bfd_fdopenw +-@subsubsection @code{bfd_fdopenw} +-@deftypefn {Function} bfd *bfd_fdopenw (const char *filename, const char *target, int fd); +-@code{bfd_fdopenw} is exactly like @code{bfd_fdopenr} with the exception that +-the resulting BFD is suitable for output. +- +-@end deftypefn +-@findex bfd_openstreamr +-@subsubsection @code{bfd_openstreamr} +-@deftypefn {Function} bfd *bfd_openstreamr (const char * filename, const char * target, void * stream); +-Open a BFD for read access on an existing stdio stream. When +-the BFD is passed to @code{bfd_close}, the stream will be closed. +- +-A copy of the @var{filename} argument is stored in the newly created +-BFD. It can be accessed via the bfd_get_filename() macro. +- +-@end deftypefn +-@findex bfd_openr_iovec +-@subsubsection @code{bfd_openr_iovec} +-@deftypefn {Function} bfd *bfd_openr_iovec (const char *filename, const char *target, void *(*open_func) (struct bfd *nbfd, void *open_closure), void *open_closure, file_ptr (*pread_func) (struct bfd *nbfd, void *stream, void *buf, file_ptr nbytes, file_ptr offset), int (*close_func) (struct bfd *nbfd, void *stream), int (*stat_func) (struct bfd *abfd, void *stream, struct stat *sb)); +-Create and return a BFD backed by a read-only @var{stream}. +-The @var{stream} is created using @var{open_func}, accessed using +-@var{pread_func} and destroyed using @var{close_func}. +- +-Calls @code{bfd_find_target}, so @var{target} is interpreted as by +-that function. +- +-Calls @var{open_func} (which can call @code{bfd_zalloc} and +-@code{bfd_get_filename}) to obtain the read-only stream backing +-the BFD. @var{open_func} either succeeds returning the +-non-@code{NULL} @var{stream}, or fails returning @code{NULL} +-(setting @code{bfd_error}). +- +-Calls @var{pread_func} to request @var{nbytes} of data from +-@var{stream} starting at @var{offset} (e.g., via a call to +-@code{bfd_read}). @var{pread_func} either succeeds returning the +-number of bytes read (which can be less than @var{nbytes} when +-end-of-file), or fails returning -1 (setting @code{bfd_error}). +- +-Calls @var{close_func} when the BFD is later closed using +-@code{bfd_close}. @var{close_func} either succeeds returning 0, or +-fails returning -1 (setting @code{bfd_error}). +- +-Calls @var{stat_func} to fill in a stat structure for bfd_stat, +-bfd_get_size, and bfd_get_mtime calls. @var{stat_func} returns 0 +-on success, or returns -1 on failure (setting @code{bfd_error}). +- +-If @code{bfd_openr_iovec} returns @code{NULL} then an error has +-occurred. Possible errors are @code{bfd_error_no_memory}, +-@code{bfd_error_invalid_target} and @code{bfd_error_system_call}. +- +-A copy of the @var{filename} argument is stored in the newly created +-BFD. It can be accessed via the bfd_get_filename() macro. +- +-@end deftypefn +-@findex bfd_openw +-@subsubsection @code{bfd_openw} +-@deftypefn {Function} bfd *bfd_openw (const char *filename, const char *target); +-Create a BFD, associated with file @var{filename}, using the +-file format @var{target}, and return a pointer to it. +- +-Possible errors are @code{bfd_error_system_call}, @code{bfd_error_no_memory}, +-@code{bfd_error_invalid_target}. +- +-A copy of the @var{filename} argument is stored in the newly created +-BFD. It can be accessed via the bfd_get_filename() macro. +- +-@end deftypefn +-@findex bfd_elf_bfd_from_remote_memory +-@subsubsection @code{bfd_elf_bfd_from_remote_memory} +-@deftypefn {Function} bfd *bfd_elf_bfd_from_remote_memory (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep, int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, bfd_size_type len)); +-Create a new BFD as if by bfd_openr. Rather than opening a +-file, reconstruct an ELF file by reading the segments out of +-remote memory based on the ELF file header at EHDR_VMA and the +-ELF program headers it points to. If non-zero, SIZE is the +-known extent of the object. If not null, *LOADBASEP is filled +-in with the difference between the VMAs from which the +-segments were read, and the VMAs the file headers (and hence +-BFD's idea of each section's VMA) put them at. +- +-The function TARGET_READ_MEMORY is called to copy LEN bytes +-from the remote memory at target address VMA into the local +-buffer at MYADDR; it should return zero on success or an +-errno code on failure. TEMPL must be a BFD for an ELF +-target with the word size and byte order found in the remote +-memory. +- +-@end deftypefn +-@findex bfd_close +-@subsubsection @code{bfd_close} +-@deftypefn {Function} bool bfd_close (bfd *abfd); +-Close a BFD. If the BFD was open for writing, then pending +-operations are completed and the file written out and closed. +-If the created file is executable, then @code{chmod} is called +-to mark it as such. +- +-All memory attached to the BFD is released. +- +-The file descriptor associated with the BFD is closed (even +-if it was passed in to BFD by @code{bfd_fdopenr}). +- +-@code{TRUE} is returned if all is ok, otherwise @code{FALSE}. +- +-@end deftypefn +-@findex bfd_close_all_done +-@subsubsection @code{bfd_close_all_done} +-@deftypefn {Function} bool bfd_close_all_done (bfd *); +-Close a BFD. Differs from @code{bfd_close} since it does not +-complete any pending operations. This routine would be used +-if the application had just used BFD for swapping and didn't +-want to use any of the writing code. +- +-If the created file is executable, then @code{chmod} is called +-to mark it as such. +- +-All memory attached to the BFD is released. +- +-@code{TRUE} is returned if all is ok, otherwise @code{FALSE}. +- +-@end deftypefn +-@findex bfd_create +-@subsubsection @code{bfd_create} +-@deftypefn {Function} bfd *bfd_create (const char *filename, bfd *templ); +-Create a new BFD in the manner of @code{bfd_openw}, but without +-opening a file. The new BFD takes the target from the target +-used by @var{templ}. The format is always set to @code{bfd_object}. +- +-A copy of the @var{filename} argument is stored in the newly created +-BFD. It can be accessed via the bfd_get_filename() macro. +- +-@end deftypefn +-@findex bfd_make_writable +-@subsubsection @code{bfd_make_writable} +-@deftypefn {Function} bool bfd_make_writable (bfd *abfd); +-Takes a BFD as created by @code{bfd_create} and converts it +-into one like as returned by @code{bfd_openw}. It does this +-by converting the BFD to BFD_IN_MEMORY. It's assumed that +-you will call @code{bfd_make_readable} on this bfd later. +- +-@code{TRUE} is returned if all is ok, otherwise @code{FALSE}. +- +-@end deftypefn +-@findex bfd_make_readable +-@subsubsection @code{bfd_make_readable} +-@deftypefn {Function} bool bfd_make_readable (bfd *abfd); +-Takes a BFD as created by @code{bfd_create} and +-@code{bfd_make_writable} and converts it into one like as +-returned by @code{bfd_openr}. It does this by writing the +-contents out to the memory buffer, then reversing the +-direction. +- +-@code{TRUE} is returned if all is ok, otherwise @code{FALSE}. +- +-@end deftypefn +-@findex bfd_calc_gnu_debuglink_crc32 +-@subsubsection @code{bfd_calc_gnu_debuglink_crc32} +-@deftypefn {Function} uint32_t bfd_calc_gnu_debuglink_crc32 (uint32_t crc, const bfd_byte *buf, bfd_size_type len); +-Computes a CRC value as used in the .gnu_debuglink section. +-Advances the previously computed @var{crc} value by computing +-and adding in the crc32 for @var{len} bytes of @var{buf}. +- +-Return the updated CRC32 value. +- +-@end deftypefn +-@findex bfd_get_debug_link_info +-@subsubsection @code{bfd_get_debug_link_info} +-@deftypefn {Function} char *bfd_get_debug_link_info (bfd *abfd, uint32_t *crc32_out); +-Extracts the filename and CRC32 value for any separate debug +-information file associated with @var{abfd}. +- +-Returns the filename of the associated debug information file, +-or NULL if there is no such file. If the filename was found +-then the contents of @var{crc32_out} are updated to hold the +-corresponding CRC32 value for the file. +- +-The returned filename is allocated with @code{malloc}; freeing +-it is the responsibility of the caller. +- +-@end deftypefn +-@findex bfd_get_alt_debug_link_info +-@subsubsection @code{bfd_get_alt_debug_link_info} +-@deftypefn {Function} char *bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len, bfd_byte **buildid_out); +-Fetch the filename and BuildID value for any alternate debuginfo +-associated with @var{abfd}. Return NULL if no such info found, +-otherwise return filename and update @var{buildid_len} and +-@var{buildid_out}. The returned filename and build_id are +-allocated with @code{malloc}; freeing them is the responsibility +-of the caller. +- +-@end deftypefn +-@findex bfd_follow_gnu_debuglink +-@subsubsection @code{bfd_follow_gnu_debuglink} +-@deftypefn {Function} char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir); +-Takes a BFD and searches it for a .gnu_debuglink section. If this +-section is found, it examines the section for the name and checksum +-of a '.debug' file containing auxiliary debugging information. It +-then searches the filesystem for this .debug file in some standard +-locations, including the directory tree rooted at @var{dir}, and if +-found returns the full filename. +- +-If @var{dir} is NULL, the search will take place starting at +-the current directory. +- +-Returns @code{NULL} on any errors or failure to locate the .debug +-file, otherwise a pointer to a heap-allocated string +-containing the filename. The caller is responsible for +-freeing this string. +- +-@end deftypefn +-@findex bfd_follow_gnu_debugaltlink +-@subsubsection @code{bfd_follow_gnu_debugaltlink} +-@deftypefn {Function} char *bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir); +-Takes a BFD and searches it for a .gnu_debugaltlink section. If this +-section is found, it examines the section for the name of a file +-containing auxiliary debugging information. It then searches the +-filesystem for this file in a set of standard locations, including +-the directory tree rooted at @var{dir}, and if found returns the +-full filename. +- +-If @var{dir} is NULL, the search will take place starting at +-the current directory. +- +-Returns @code{NULL} on any errors or failure to locate the debug +-file, otherwise a pointer to a heap-allocated string +-containing the filename. The caller is responsible for +-freeing this string. +- +-@end deftypefn +-@findex bfd_create_gnu_debuglink_section +-@subsubsection @code{bfd_create_gnu_debuglink_section} +-@deftypefn {Function} struct bfd_section *bfd_create_gnu_debuglink_section (bfd *abfd, const char *filename); +-Takes a @var{BFD} and adds a .gnu_debuglink section to it. The +-section is sized to be big enough to contain a link to the specified +-@var{filename}. +- +-A pointer to the new section is returned if all is ok. Otherwise +-@code{NULL} is returned and bfd_error is set. +- +-@end deftypefn +-@findex bfd_fill_in_gnu_debuglink_section +-@subsubsection @code{bfd_fill_in_gnu_debuglink_section} +-@deftypefn {Function} bool bfd_fill_in_gnu_debuglink_section (bfd *abfd, struct bfd_section *sect, const char *filename); +-Takes a @var{BFD} and containing a .gnu_debuglink section @var{SECT} +-and fills in the contents of the section to contain a link to the +-specified @var{filename}. The filename should be absolute or +-relative to the current directory. +- +-@code{TRUE} is returned if all is ok. Otherwise @code{FALSE} is returned +-and bfd_error is set. +- +-@end deftypefn +-@findex bfd_follow_build_id_debuglink +-@subsubsection @code{bfd_follow_build_id_debuglink} +-@deftypefn {Function} char *bfd_follow_build_id_debuglink (bfd *abfd, const char *dir); +-Takes @var{abfd} and searches it for a .note.gnu.build-id section. +-If this section is found, it extracts the value of the NT_GNU_BUILD_ID +-note, which should be a hexadecimal value @var{NNNN+NN} (for +-32+ hex digits). It then searches the filesystem for a file named +-@var{.build-id/NN/NN+NN.debug} in a set of standard locations, +-including the directory tree rooted at @var{dir}. The filename +-of the first matching file to be found is returned. A matching +-file should contain a .note.gnu.build-id section with the same +-@var{NNNN+NN} note as @var{abfd}, although this check is currently +-not implemented. +- +-If @var{dir} is NULL, the search will take place starting at +-the current directory. +- +-Returns @code{NULL} on any errors or failure to locate the debug +-file, otherwise a pointer to a heap-allocated string +-containing the filename. The caller is responsible for +-freeing this string. +- +-@end deftypefn +-@findex bfd_set_filename +-@subsubsection @code{bfd_set_filename} +-@deftypefn {Function} const char *bfd_set_filename (bfd *abfd, const char *filename); +-Set the filename of @var{abfd}, copying the FILENAME parameter to +-bfd_alloc'd memory owned by @var{abfd}. Returns a pointer the +-newly allocated name, or NULL if the allocation failed. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/reloc.texi gdb-14.1-sw64/bfd/doc/reloc.texi +--- gdb-14.1-after-patch/bfd/doc/reloc.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/reloc.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,4727 +0,0 @@ +-@section Relocations +-BFD maintains relocations in much the same way it maintains +-symbols: they are left alone until required, then read in +-en-masse and translated into an internal form. A common +-routine @code{bfd_perform_relocation} acts upon the +-canonical form to do the fixup. +- +-Relocations are maintained on a per section basis, +-while symbols are maintained on a per BFD basis. +- +-All that a back end has to do to fit the BFD interface is to create +-a @code{struct reloc_cache_entry} for each relocation +-in a particular section, and fill in the right bits of the structures. +- +-@menu +-* typedef arelent:: +-* howto manager:: +-@end menu +- +- +-@node typedef arelent, howto manager, Relocations, Relocations +-@subsection typedef arelent +-This is the structure of a relocation entry: +- +- +-@example +-struct reloc_cache_entry +-@{ +- /* A pointer into the canonical table of pointers. */ +- struct bfd_symbol **sym_ptr_ptr; +- +- /* offset in section. */ +- bfd_size_type address; +- +- /* addend for relocation value. */ +- bfd_vma addend; +- +- /* Pointer to how to perform the required relocation. */ +- reloc_howto_type *howto; +- +-@}; +- +-@end example +-Here is a description of each of the fields within an @code{arelent}: +- +-@itemize @bullet +- +-@item +-@code{sym_ptr_ptr} +-@end itemize +-The symbol table pointer points to a pointer to the symbol +-associated with the relocation request. It is the pointer +-into the table returned by the back end's +-@code{canonicalize_symtab} action. @xref{Symbols}. The symbol is +-referenced through a pointer to a pointer so that tools like +-the linker can fix up all the symbols of the same name by +-modifying only one pointer. The relocation routine looks in +-the symbol and uses the base of the section the symbol is +-attached to and the value of the symbol as the initial +-relocation offset. If the symbol pointer is zero, then the +-section provided is looked up. +- +-@itemize @bullet +- +-@item +-@code{address} +-@end itemize +-The @code{address} field gives the offset in bytes from the base of +-the section data which owns the relocation record to the first +-byte of relocatable information. The actual data relocated +-will be relative to this point; for example, a relocation +-type which modifies the bottom two bytes of a four byte word +-would not touch the first byte pointed to in a big endian +-world. +- +-@itemize @bullet +- +-@item +-@code{addend} +-@end itemize +-The @code{addend} is a value provided by the back end to be added (!) +-to the relocation offset. Its interpretation is dependent upon +-the howto. For example, on the 68k the code: +- +-@example +- char foo[]; +- main() +- @{ +- return foo[0x12345678]; +- @} +-@end example +- +-Could be compiled into: +- +-@example +- linkw fp,#-4 +- moveb @@#12345678,d0 +- extbl d0 +- unlk fp +- rts +-@end example +- +-This could create a reloc pointing to @code{foo}, but leave the +-offset in the data, something like: +- +-@example +-RELOCATION RECORDS FOR [.text]: +-offset type value +-00000006 32 _foo +- +-00000000 4e56 fffc ; linkw fp,#-4 +-00000004 1039 1234 5678 ; moveb @@#12345678,d0 +-0000000a 49c0 ; extbl d0 +-0000000c 4e5e ; unlk fp +-0000000e 4e75 ; rts +-@end example +- +-Using coff and an 88k, some instructions don't have enough +-space in them to represent the full address range, and +-pointers have to be loaded in two parts. So you'd get something like: +- +-@example +- or.u r13,r0,hi16(_foo+0x12345678) +- ld.b r2,r13,lo16(_foo+0x12345678) +- jmp r1 +-@end example +- +-This should create two relocs, both pointing to @code{_foo}, and with +-0x12340000 in their addend field. The data would consist of: +- +-@example +-RELOCATION RECORDS FOR [.text]: +-offset type value +-00000002 HVRT16 _foo+0x12340000 +-00000006 LVRT16 _foo+0x12340000 +- +-00000000 5da05678 ; or.u r13,r0,0x5678 +-00000004 1c4d5678 ; ld.b r2,r13,0x5678 +-00000008 f400c001 ; jmp r1 +-@end example +- +-The relocation routine digs out the value from the data, adds +-it to the addend to get the original offset, and then adds the +-value of @code{_foo}. Note that all 32 bits have to be kept around +-somewhere, to cope with carry from bit 15 to bit 16. +- +-One further example is the sparc and the a.out format. The +-sparc has a similar problem to the 88k, in that some +-instructions don't have room for an entire offset, but on the +-sparc the parts are created in odd sized lumps. The designers of +-the a.out format chose to not use the data within the section +-for storing part of the offset; all the offset is kept within +-the reloc. Anything in the data should be ignored. +- +-@example +- save %sp,-112,%sp +- sethi %hi(_foo+0x12345678),%g2 +- ldsb [%g2+%lo(_foo+0x12345678)],%i0 +- ret +- restore +-@end example +- +-Both relocs contain a pointer to @code{foo}, and the offsets +-contain junk. +- +-@example +-RELOCATION RECORDS FOR [.text]: +-offset type value +-00000004 HI22 _foo+0x12345678 +-00000008 LO10 _foo+0x12345678 +- +-00000000 9de3bf90 ; save %sp,-112,%sp +-00000004 05000000 ; sethi %hi(_foo+0),%g2 +-00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0 +-0000000c 81c7e008 ; ret +-00000010 81e80000 ; restore +-@end example +- +-@itemize @bullet +- +-@item +-@code{howto} +-@end itemize +-The @code{howto} field can be imagined as a +-relocation instruction. It is a pointer to a structure which +-contains information on what to do with all of the other +-information in the reloc record and data section. A back end +-would normally have a relocation instruction set and turn +-relocations into pointers to the correct structure on input - +-but it would be possible to create each howto field on demand. +- +-@subsubsection @code{enum complain_overflow} +-Indicates what sort of overflow checking should be done when +-performing a relocation. +- +- +-@example +-enum complain_overflow +-@{ +- /* Do not complain on overflow. */ +- complain_overflow_dont, +- +- /* Complain if the value overflows when considered as a signed +- number one bit larger than the field. ie. A bitfield of N bits +- is allowed to represent -2**n to 2**n-1. */ +- complain_overflow_bitfield, +- +- /* Complain if the value overflows when considered as a signed +- number. */ +- complain_overflow_signed, +- +- /* Complain if the value overflows when considered as an +- unsigned number. */ +- complain_overflow_unsigned +-@}; +- +-@end example +-@subsubsection @code{reloc_howto_type} +-The @code{reloc_howto_type} is a structure which contains all the +-information that libbfd needs to know to tie up a back end's data. +- +- +-@example +-struct reloc_howto_struct +-@{ +- /* The type field has mainly a documentary use - the back end can +- do what it wants with it, though normally the back end's idea of +- an external reloc number is stored in this field. */ +- unsigned int type; +- +- /* The size of the item to be relocated in bytes. */ +- unsigned int size:4; +- +- /* The number of bits in the field to be relocated. This is used +- when doing overflow checking. */ +- unsigned int bitsize:7; +- +- /* The value the final relocation is shifted right by. This drops +- unwanted data from the relocation. */ +- unsigned int rightshift:6; +- +- /* The bit position of the reloc value in the destination. +- The relocated value is left shifted by this amount. */ +- unsigned int bitpos:6; +- +- /* What type of overflow error should be checked for when +- relocating. */ +- ENUM_BITFIELD (complain_overflow) complain_on_overflow:2; +- +- /* The relocation value should be negated before applying. */ +- unsigned int negate:1; +- +- /* The relocation is relative to the item being relocated. */ +- unsigned int pc_relative:1; +- +- /* Some formats record a relocation addend in the section contents +- rather than with the relocation. For ELF formats this is the +- distinction between USE_REL and USE_RELA (though the code checks +- for USE_REL == 1/0). The value of this field is TRUE if the +- addend is recorded with the section contents; when performing a +- partial link (ld -r) the section contents (the data) will be +- modified. The value of this field is FALSE if addends are +- recorded with the relocation (in arelent.addend); when performing +- a partial link the relocation will be modified. +- All relocations for all ELF USE_RELA targets should set this field +- to FALSE (values of TRUE should be looked on with suspicion). +- However, the converse is not true: not all relocations of all ELF +- USE_REL targets set this field to TRUE. Why this is so is peculiar +- to each particular target. For relocs that aren't used in partial +- links (e.g. GOT stuff) it doesn't matter what this is set to. */ +- unsigned int partial_inplace:1; +- +- /* When some formats create PC relative instructions, they leave +- the value of the pc of the place being relocated in the offset +- slot of the instruction, so that a PC relative relocation can +- be made just by adding in an ordinary offset (e.g., sun3 a.out). +- Some formats leave the displacement part of an instruction +- empty (e.g., ELF); this flag signals the fact. */ +- unsigned int pcrel_offset:1; +- +- /* Whether bfd_install_relocation should just install the addend, +- or should follow the practice of some older object formats and +- install a value including the symbol. */ +- unsigned int install_addend:1; +- +- /* src_mask selects the part of the instruction (or data) to be used +- in the relocation sum. If the target relocations don't have an +- addend in the reloc, eg. ELF USE_REL, src_mask will normally equal +- dst_mask to extract the addend from the section contents. If +- relocations do have an addend in the reloc, eg. ELF USE_RELA, this +- field should normally be zero. Non-zero values for ELF USE_RELA +- targets should be viewed with suspicion as normally the value in +- the dst_mask part of the section contents should be ignored. */ +- bfd_vma src_mask; +- +- /* dst_mask selects which parts of the instruction (or data) are +- replaced with a relocated value. */ +- bfd_vma dst_mask; +- +- /* If this field is non null, then the supplied function is +- called rather than the normal function. This allows really +- strange relocation methods to be accommodated. */ +- bfd_reloc_status_type (*special_function) +- (bfd *, arelent *, struct bfd_symbol *, void *, asection *, +- bfd *, char **); +- +- /* The textual name of the relocation type. */ +- const char *name; +-@}; +- +-@end example +-@findex The HOWTO Macro +-@subsubsection @code{The HOWTO Macro} +-The HOWTO macro fills in a reloc_howto_type (a typedef for +-const struct reloc_howto_struct). +-@example +-#define HOWTO_INSTALL_ADDEND 0 +-#define HOWTO_RSIZE(sz) ((sz) < 0 ? -(sz) : (sz)) +-#define HOWTO(type, right, size, bits, pcrel, left, ovf, func, name, \ +- inplace, src_mask, dst_mask, pcrel_off) \ +- @{ (unsigned) type, HOWTO_RSIZE (size), bits, right, left, ovf, \ +- size < 0, pcrel, inplace, pcrel_off, HOWTO_INSTALL_ADDEND, \ +- src_mask, dst_mask, func, name @} +-@end example +- +-This is used to fill in an empty howto entry in an array. +-@example +-#define EMPTY_HOWTO(C) \ +- HOWTO ((C), 0, 1, 0, false, 0, complain_overflow_dont, NULL, \ +- NULL, false, 0, 0, false) +- +-static inline unsigned int +-bfd_get_reloc_size (reloc_howto_type *howto) +-@{ +- return howto->size; +-@} +- +-@end example +- +-@findex arelent_chain +-@subsubsection @code{arelent_chain} +-How relocs are tied together in an @code{asection}: +-@example +-typedef struct relent_chain +-@{ +- arelent relent; +- struct relent_chain *next; +-@} +-arelent_chain; +- +-@end example +- +-@findex bfd_check_overflow +-@subsubsection @code{bfd_check_overflow} +-@deftypefn {Function} bfd_reloc_status_type bfd_check_overflow (enum complain_overflow how, unsigned int bitsize, unsigned int rightshift, unsigned int addrsize, bfd_vma relocation); +-Perform overflow checking on @var{relocation} which has +-@var{bitsize} significant bits and will be shifted right by +-@var{rightshift} bits, on a machine with addresses containing +-@var{addrsize} significant bits. The result is either of +-@code{bfd_reloc_ok} or @code{bfd_reloc_overflow}. +- +-@end deftypefn +-@findex bfd_reloc_offset_in_range +-@subsubsection @code{bfd_reloc_offset_in_range} +-@deftypefn {Function} bool bfd_reloc_offset_in_range (reloc_howto_type *howto, bfd *abfd, asection *section, bfd_size_type offset); +-Returns TRUE if the reloc described by @var{HOWTO} can be +-applied at @var{OFFSET} octets in @var{SECTION}. +- +-@end deftypefn +-@findex bfd_perform_relocation +-@subsubsection @code{bfd_perform_relocation} +-@deftypefn {Function} bfd_reloc_status_type bfd_perform_relocation (bfd *abfd, arelent *reloc_entry, void *data, asection *input_section, bfd *output_bfd, char **error_message); +-If @var{output_bfd} is supplied to this function, the +-generated image will be relocatable; the relocations are +-copied to the output file after they have been changed to +-reflect the new state of the world. There are two ways of +-reflecting the results of partial linkage in an output file: +-by modifying the output data in place, and by modifying the +-relocation record. Some native formats (e.g., basic a.out and +-basic coff) have no way of specifying an addend in the +-relocation type, so the addend has to go in the output data. +-This is no big deal since in these formats the output data +-slot will always be big enough for the addend. Complex reloc +-types with addends were invented to solve just this problem. +-The @var{error_message} argument is set to an error message if +-this return @code{bfd_reloc_dangerous}. +- +-@end deftypefn +-@findex bfd_install_relocation +-@subsubsection @code{bfd_install_relocation} +-@deftypefn {Function} bfd_reloc_status_type bfd_install_relocation (bfd *abfd, arelent *reloc_entry, void *data, bfd_vma data_start, asection *input_section, char **error_message); +-This looks remarkably like @code{bfd_perform_relocation}, except it +-does not expect that the section contents have been filled in. +-I.e., it's suitable for use when creating, rather than applying +-a relocation. +- +-For now, this function should be considered reserved for the +-assembler. +- +-@end deftypefn +- +-@node howto manager, , typedef arelent, Relocations +-@subsection The howto manager +-When an application wants to create a relocation, but doesn't +-know what the target machine might call it, it can find out by +-using this bit of code. +- +-@findex bfd_reloc_code_real_type +-@subsubsection @code{bfd_reloc_code_real_type} +-The insides of a reloc code. The idea is that, eventually, there +-will be one enumerator for every type of relocation we ever do. +-Pass one of these values to @code{bfd_reloc_type_lookup}, and it'll +-return a howto pointer. +- +-This does mean that the application must determine the correct +-enumerator value; you can't get a howto pointer from a random set +-of attributes. +- +-Here are the possible values for @code{enum bfd_reloc_code_real}: +- +-@deffn {} BFD_RELOC_64 +-@deffnx {} BFD_RELOC_32 +-@deffnx {} BFD_RELOC_26 +-@deffnx {} BFD_RELOC_24 +-@deffnx {} BFD_RELOC_16 +-@deffnx {} BFD_RELOC_14 +-@deffnx {} BFD_RELOC_8 +-Basic absolute relocations of N bits. +-@end deffn +-@deffn {} BFD_RELOC_64_PCREL +-@deffnx {} BFD_RELOC_32_PCREL +-@deffnx {} BFD_RELOC_24_PCREL +-@deffnx {} BFD_RELOC_16_PCREL +-@deffnx {} BFD_RELOC_12_PCREL +-@deffnx {} BFD_RELOC_8_PCREL +-PC-relative relocations. Sometimes these are relative to the address +-of the relocation itself; sometimes they are relative to the start of +-the section containing the relocation. It depends on the specific target. +-@end deffn +-@deffn {} BFD_RELOC_32_SECREL +-@deffnx {} BFD_RELOC_16_SECIDX +-Section relative relocations. Some targets need this for DWARF2. +-@end deffn +-@deffn {} BFD_RELOC_32_GOT_PCREL +-@deffnx {} BFD_RELOC_16_GOT_PCREL +-@deffnx {} BFD_RELOC_8_GOT_PCREL +-@deffnx {} BFD_RELOC_32_GOTOFF +-@deffnx {} BFD_RELOC_16_GOTOFF +-@deffnx {} BFD_RELOC_LO16_GOTOFF +-@deffnx {} BFD_RELOC_HI16_GOTOFF +-@deffnx {} BFD_RELOC_HI16_S_GOTOFF +-@deffnx {} BFD_RELOC_8_GOTOFF +-@deffnx {} BFD_RELOC_64_PLT_PCREL +-@deffnx {} BFD_RELOC_32_PLT_PCREL +-@deffnx {} BFD_RELOC_24_PLT_PCREL +-@deffnx {} BFD_RELOC_16_PLT_PCREL +-@deffnx {} BFD_RELOC_8_PLT_PCREL +-@deffnx {} BFD_RELOC_64_PLTOFF +-@deffnx {} BFD_RELOC_32_PLTOFF +-@deffnx {} BFD_RELOC_16_PLTOFF +-@deffnx {} BFD_RELOC_LO16_PLTOFF +-@deffnx {} BFD_RELOC_HI16_PLTOFF +-@deffnx {} BFD_RELOC_HI16_S_PLTOFF +-@deffnx {} BFD_RELOC_8_PLTOFF +-For ELF. +-@end deffn +-@deffn {} BFD_RELOC_SIZE32 +-@deffnx {} BFD_RELOC_SIZE64 +-Size relocations. +-@end deffn +-@deffn {} BFD_RELOC_68K_GLOB_DAT +-@deffnx {} BFD_RELOC_68K_JMP_SLOT +-@deffnx {} BFD_RELOC_68K_RELATIVE +-@deffnx {} BFD_RELOC_68K_TLS_GD32 +-@deffnx {} BFD_RELOC_68K_TLS_GD16 +-@deffnx {} BFD_RELOC_68K_TLS_GD8 +-@deffnx {} BFD_RELOC_68K_TLS_LDM32 +-@deffnx {} BFD_RELOC_68K_TLS_LDM16 +-@deffnx {} BFD_RELOC_68K_TLS_LDM8 +-@deffnx {} BFD_RELOC_68K_TLS_LDO32 +-@deffnx {} BFD_RELOC_68K_TLS_LDO16 +-@deffnx {} BFD_RELOC_68K_TLS_LDO8 +-@deffnx {} BFD_RELOC_68K_TLS_IE32 +-@deffnx {} BFD_RELOC_68K_TLS_IE16 +-@deffnx {} BFD_RELOC_68K_TLS_IE8 +-@deffnx {} BFD_RELOC_68K_TLS_LE32 +-@deffnx {} BFD_RELOC_68K_TLS_LE16 +-@deffnx {} BFD_RELOC_68K_TLS_LE8 +-Relocations used by 68K ELF. +-@end deffn +-@deffn {} BFD_RELOC_32_BASEREL +-@deffnx {} BFD_RELOC_16_BASEREL +-@deffnx {} BFD_RELOC_LO16_BASEREL +-@deffnx {} BFD_RELOC_HI16_BASEREL +-@deffnx {} BFD_RELOC_HI16_S_BASEREL +-@deffnx {} BFD_RELOC_8_BASEREL +-@deffnx {} BFD_RELOC_RVA +-Linkage-table relative. +-@end deffn +-@deffn {} BFD_RELOC_8_FFnn +-Absolute 8-bit relocation, but used to form an address like 0xFFnn. +-@end deffn +-@deffn {} BFD_RELOC_32_PCREL_S2 +-@deffnx {} BFD_RELOC_16_PCREL_S2 +-@deffnx {} BFD_RELOC_23_PCREL_S2 +-These PC-relative relocations are stored as word displacements -- +-i.e., byte displacements shifted right two bits. The 30-bit word +-displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the +-SPARC. (SPARC tools generally refer to this as <>.) The +-signed 16-bit displacement is used on the MIPS, and the 23-bit +-displacement is used on the Alpha. +-@end deffn +-@deffn {} BFD_RELOC_HI22 +-@deffnx {} BFD_RELOC_LO10 +-High 22 bits and low 10 bits of 32-bit value, placed into lower bits of +-the target word. These are used on the SPARC. +-@end deffn +-@deffn {} BFD_RELOC_GPREL16 +-@deffnx {} BFD_RELOC_GPREL32 +-For systems that allocate a Global Pointer register, these are +-displacements off that register. These relocation types are +-handled specially, because the value the register will have is +-decided relatively late. +-@end deffn +-@deffn {} BFD_RELOC_NONE +-@deffnx {} BFD_RELOC_SPARC_WDISP22 +-@deffnx {} BFD_RELOC_SPARC22 +-@deffnx {} BFD_RELOC_SPARC13 +-@deffnx {} BFD_RELOC_SPARC_GOT10 +-@deffnx {} BFD_RELOC_SPARC_GOT13 +-@deffnx {} BFD_RELOC_SPARC_GOT22 +-@deffnx {} BFD_RELOC_SPARC_PC10 +-@deffnx {} BFD_RELOC_SPARC_PC22 +-@deffnx {} BFD_RELOC_SPARC_WPLT30 +-@deffnx {} BFD_RELOC_SPARC_COPY +-@deffnx {} BFD_RELOC_SPARC_GLOB_DAT +-@deffnx {} BFD_RELOC_SPARC_JMP_SLOT +-@deffnx {} BFD_RELOC_SPARC_RELATIVE +-@deffnx {} BFD_RELOC_SPARC_UA16 +-@deffnx {} BFD_RELOC_SPARC_UA32 +-@deffnx {} BFD_RELOC_SPARC_UA64 +-@deffnx {} BFD_RELOC_SPARC_GOTDATA_HIX22 +-@deffnx {} BFD_RELOC_SPARC_GOTDATA_LOX10 +-@deffnx {} BFD_RELOC_SPARC_GOTDATA_OP_HIX22 +-@deffnx {} BFD_RELOC_SPARC_GOTDATA_OP_LOX10 +-@deffnx {} BFD_RELOC_SPARC_GOTDATA_OP +-@deffnx {} BFD_RELOC_SPARC_JMP_IREL +-@deffnx {} BFD_RELOC_SPARC_IRELATIVE +-SPARC ELF relocations. There is probably some overlap with other +-relocation types already defined. +-@end deffn +-@deffn {} BFD_RELOC_SPARC_BASE13 +-@deffnx {} BFD_RELOC_SPARC_BASE22 +-I think these are specific to SPARC a.out (e.g., Sun 4). +-@end deffn +-@deffn {} BFD_RELOC_SPARC_64 +-@deffnx {} BFD_RELOC_SPARC_10 +-@deffnx {} BFD_RELOC_SPARC_11 +-@deffnx {} BFD_RELOC_SPARC_OLO10 +-@deffnx {} BFD_RELOC_SPARC_HH22 +-@deffnx {} BFD_RELOC_SPARC_HM10 +-@deffnx {} BFD_RELOC_SPARC_LM22 +-@deffnx {} BFD_RELOC_SPARC_PC_HH22 +-@deffnx {} BFD_RELOC_SPARC_PC_HM10 +-@deffnx {} BFD_RELOC_SPARC_PC_LM22 +-@deffnx {} BFD_RELOC_SPARC_WDISP16 +-@deffnx {} BFD_RELOC_SPARC_WDISP19 +-@deffnx {} BFD_RELOC_SPARC_7 +-@deffnx {} BFD_RELOC_SPARC_6 +-@deffnx {} BFD_RELOC_SPARC_5 +-@deffnx {} BFD_RELOC_SPARC_DISP64 +-@deffnx {} BFD_RELOC_SPARC_PLT32 +-@deffnx {} BFD_RELOC_SPARC_PLT64 +-@deffnx {} BFD_RELOC_SPARC_HIX22 +-@deffnx {} BFD_RELOC_SPARC_LOX10 +-@deffnx {} BFD_RELOC_SPARC_H44 +-@deffnx {} BFD_RELOC_SPARC_M44 +-@deffnx {} BFD_RELOC_SPARC_L44 +-@deffnx {} BFD_RELOC_SPARC_REGISTER +-@deffnx {} BFD_RELOC_SPARC_H34 +-@deffnx {} BFD_RELOC_SPARC_SIZE32 +-@deffnx {} BFD_RELOC_SPARC_SIZE64 +-@deffnx {} BFD_RELOC_SPARC_WDISP10 +-SPARC64 relocations +-@end deffn +-@deffn {} BFD_RELOC_SPARC_REV32 +-SPARC little endian relocation +-@end deffn +-@deffn {} BFD_RELOC_SPARC_TLS_GD_HI22 +-@deffnx {} BFD_RELOC_SPARC_TLS_GD_LO10 +-@deffnx {} BFD_RELOC_SPARC_TLS_GD_ADD +-@deffnx {} BFD_RELOC_SPARC_TLS_GD_CALL +-@deffnx {} BFD_RELOC_SPARC_TLS_LDM_HI22 +-@deffnx {} BFD_RELOC_SPARC_TLS_LDM_LO10 +-@deffnx {} BFD_RELOC_SPARC_TLS_LDM_ADD +-@deffnx {} BFD_RELOC_SPARC_TLS_LDM_CALL +-@deffnx {} BFD_RELOC_SPARC_TLS_LDO_HIX22 +-@deffnx {} BFD_RELOC_SPARC_TLS_LDO_LOX10 +-@deffnx {} BFD_RELOC_SPARC_TLS_LDO_ADD +-@deffnx {} BFD_RELOC_SPARC_TLS_IE_HI22 +-@deffnx {} BFD_RELOC_SPARC_TLS_IE_LO10 +-@deffnx {} BFD_RELOC_SPARC_TLS_IE_LD +-@deffnx {} BFD_RELOC_SPARC_TLS_IE_LDX +-@deffnx {} BFD_RELOC_SPARC_TLS_IE_ADD +-@deffnx {} BFD_RELOC_SPARC_TLS_LE_HIX22 +-@deffnx {} BFD_RELOC_SPARC_TLS_LE_LOX10 +-@deffnx {} BFD_RELOC_SPARC_TLS_DTPMOD32 +-@deffnx {} BFD_RELOC_SPARC_TLS_DTPMOD64 +-@deffnx {} BFD_RELOC_SPARC_TLS_DTPOFF32 +-@deffnx {} BFD_RELOC_SPARC_TLS_DTPOFF64 +-@deffnx {} BFD_RELOC_SPARC_TLS_TPOFF32 +-@deffnx {} BFD_RELOC_SPARC_TLS_TPOFF64 +-SPARC TLS relocations +-@end deffn +-@deffn {} BFD_RELOC_SPU_IMM7 +-@deffnx {} BFD_RELOC_SPU_IMM8 +-@deffnx {} BFD_RELOC_SPU_IMM10 +-@deffnx {} BFD_RELOC_SPU_IMM10W +-@deffnx {} BFD_RELOC_SPU_IMM16 +-@deffnx {} BFD_RELOC_SPU_IMM16W +-@deffnx {} BFD_RELOC_SPU_IMM18 +-@deffnx {} BFD_RELOC_SPU_PCREL9a +-@deffnx {} BFD_RELOC_SPU_PCREL9b +-@deffnx {} BFD_RELOC_SPU_PCREL16 +-@deffnx {} BFD_RELOC_SPU_LO16 +-@deffnx {} BFD_RELOC_SPU_HI16 +-@deffnx {} BFD_RELOC_SPU_PPU32 +-@deffnx {} BFD_RELOC_SPU_PPU64 +-@deffnx {} BFD_RELOC_SPU_ADD_PIC +-SPU Relocations. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_GPDISP_HI16 +-Alpha ECOFF and ELF relocations. Some of these treat the symbol or +-"addend" in some special way. +-For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when +-writing; when reading, it will be the absolute section symbol. The +-addend is the displacement in bytes of the "lda" instruction from +-the "ldah" instruction (which is at the address of this reloc). +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_GPDISP_LO16 +-For GPDISP_LO16 ("ignore") relocations, the symbol is handled as +-with GPDISP_HI16 relocs. The addend is ignored when writing the +-relocations out, and is filled in with the file's GP value on +-reading, for convenience. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_GPDISP +-The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 +-relocation except that there is no accompanying GPDISP_LO16 +-relocation. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_LITERAL +-@deffnx {} BFD_RELOC_ALPHA_ELF_LITERAL +-@deffnx {} BFD_RELOC_ALPHA_LITUSE +-The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; +-the assembler turns it into a LDQ instruction to load the address of +-the symbol, and then fills in a register in the real instruction. +- +-The LITERAL reloc, at the LDQ instruction, refers to the .lita +-section symbol. The addend is ignored when writing, but is filled +-in with the file's GP value on reading, for convenience, as with the +-GPDISP_LO16 reloc. +- +-The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. +-It should refer to the symbol to be referenced, as with 16_GOTOFF, +-but it generates output not based on the position within the .got +-section, but relative to the GP value chosen for the file during the +-final link stage. +- +-The LITUSE reloc, on the instruction using the loaded address, gives +-information to the linker that it might be able to use to optimize +-away some literal section references. The symbol is ignored (read +-as the absolute section symbol), and the "addend" indicates the type +-of instruction using the register: +-1 - "memory" fmt insn +-2 - byte-manipulation (byte offset reg) +-3 - jsr (target of branch) +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_HINT +-The HINT relocation indicates a value that should be filled into the +-"hint" field of a jmp/jsr/ret instruction, for possible branch- +-prediction logic which may be provided on some processors. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_LINKAGE +-The LINKAGE relocation outputs a linkage pair in the object file, +-which is filled by the linker. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_CODEADDR +-The CODEADDR relocation outputs a STO_CA in the object file, +-which is filled by the linker. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_GPREL_HI16 +-@deffnx {} BFD_RELOC_ALPHA_GPREL_LO16 +-The GPREL_HI/LO relocations together form a 32-bit offset from the +-GP register. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_BRSGP +-Like BFD_RELOC_23_PCREL_S2, except that the source and target must +-share a common GP, and the target address is adjusted for +-STO_ALPHA_STD_GPLOAD. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_NOP +-The NOP relocation outputs a NOP if the longword displacement +-between two procedure entry points is < 2^21. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_BSR +-The BSR relocation outputs a BSR if the longword displacement +-between two procedure entry points is < 2^21. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_LDA +-The LDA relocation outputs a LDA if the longword displacement +-between two procedure entry points is < 2^16. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_BOH +-The BOH relocation outputs a BSR if the longword displacement +-between two procedure entry points is < 2^21, or else a hint. +-@end deffn +-@deffn {} BFD_RELOC_ALPHA_TLSGD +-@deffnx {} BFD_RELOC_ALPHA_TLSLDM +-@deffnx {} BFD_RELOC_ALPHA_DTPMOD64 +-@deffnx {} BFD_RELOC_ALPHA_GOTDTPREL16 +-@deffnx {} BFD_RELOC_ALPHA_DTPREL64 +-@deffnx {} BFD_RELOC_ALPHA_DTPREL_HI16 +-@deffnx {} BFD_RELOC_ALPHA_DTPREL_LO16 +-@deffnx {} BFD_RELOC_ALPHA_DTPREL16 +-@deffnx {} BFD_RELOC_ALPHA_GOTTPREL16 +-@deffnx {} BFD_RELOC_ALPHA_TPREL64 +-@deffnx {} BFD_RELOC_ALPHA_TPREL_HI16 +-@deffnx {} BFD_RELOC_ALPHA_TPREL_LO16 +-@deffnx {} BFD_RELOC_ALPHA_TPREL16 +-Alpha thread-local storage relocations. +-@end deffn +-@deffn {} BFD_RELOC_MIPS_JMP +-@deffnx {} BFD_RELOC_MICROMIPS_JMP +-The MIPS jump instruction. +-@end deffn +-@deffn {} BFD_RELOC_MIPS16_JMP +-The MIPS16 jump instruction. +-@end deffn +-@deffn {} BFD_RELOC_MIPS16_GPREL +-MIPS16 GP relative reloc. +-@end deffn +-@deffn {} BFD_RELOC_HI16 +-High 16 bits of 32-bit value; simple reloc. +-@end deffn +-@deffn {} BFD_RELOC_HI16_S +-High 16 bits of 32-bit value but the low 16 bits will be sign +-extended and added to form the final result. If the low 16 +-bits form a negative number, we need to add one to the high value +-to compensate for the borrow when the low bits are added. +-@end deffn +-@deffn {} BFD_RELOC_LO16 +-Low 16 bits. +-@end deffn +-@deffn {} BFD_RELOC_HI16_PCREL +-High 16 bits of 32-bit pc-relative value +-@end deffn +-@deffn {} BFD_RELOC_HI16_S_PCREL +-High 16 bits of 32-bit pc-relative value, adjusted +-@end deffn +-@deffn {} BFD_RELOC_LO16_PCREL +-Low 16 bits of pc-relative value +-@end deffn +-@deffn {} BFD_RELOC_MIPS16_GOT16 +-@deffnx {} BFD_RELOC_MIPS16_CALL16 +-Equivalent of BFD_RELOC_MIPS_*, but with the MIPS16 layout of +-16-bit immediate fields +-@end deffn +-@deffn {} BFD_RELOC_MIPS16_HI16 +-MIPS16 high 16 bits of 32-bit value. +-@end deffn +-@deffn {} BFD_RELOC_MIPS16_HI16_S +-MIPS16 high 16 bits of 32-bit value but the low 16 bits will be sign +-extended and added to form the final result. If the low 16 +-bits form a negative number, we need to add one to the high value +-to compensate for the borrow when the low bits are added. +-@end deffn +-@deffn {} BFD_RELOC_MIPS16_LO16 +-MIPS16 low 16 bits. +-@end deffn +-@deffn {} BFD_RELOC_MIPS16_TLS_GD +-@deffnx {} BFD_RELOC_MIPS16_TLS_LDM +-@deffnx {} BFD_RELOC_MIPS16_TLS_DTPREL_HI16 +-@deffnx {} BFD_RELOC_MIPS16_TLS_DTPREL_LO16 +-@deffnx {} BFD_RELOC_MIPS16_TLS_GOTTPREL +-@deffnx {} BFD_RELOC_MIPS16_TLS_TPREL_HI16 +-@deffnx {} BFD_RELOC_MIPS16_TLS_TPREL_LO16 +-MIPS16 TLS relocations +-@end deffn +-@deffn {} BFD_RELOC_MIPS_LITERAL +-@deffnx {} BFD_RELOC_MICROMIPS_LITERAL +-Relocation against a MIPS literal section. +-@end deffn +-@deffn {} BFD_RELOC_MICROMIPS_7_PCREL_S1 +-@deffnx {} BFD_RELOC_MICROMIPS_10_PCREL_S1 +-@deffnx {} BFD_RELOC_MICROMIPS_16_PCREL_S1 +-microMIPS PC-relative relocations. +-@end deffn +-@deffn {} BFD_RELOC_MIPS16_16_PCREL_S1 +-MIPS16 PC-relative relocation. +-@end deffn +-@deffn {} BFD_RELOC_MIPS_21_PCREL_S2 +-@deffnx {} BFD_RELOC_MIPS_26_PCREL_S2 +-@deffnx {} BFD_RELOC_MIPS_18_PCREL_S3 +-@deffnx {} BFD_RELOC_MIPS_19_PCREL_S2 +-MIPS PC-relative relocations. +-@end deffn +-@deffn {} BFD_RELOC_MICROMIPS_GPREL16 +-@deffnx {} BFD_RELOC_MICROMIPS_HI16 +-@deffnx {} BFD_RELOC_MICROMIPS_HI16_S +-@deffnx {} BFD_RELOC_MICROMIPS_LO16 +-microMIPS versions of generic BFD relocs. +-@end deffn +-@deffn {} BFD_RELOC_MIPS_GOT16 +-@deffnx {} BFD_RELOC_MICROMIPS_GOT16 +-@deffnx {} BFD_RELOC_MIPS_CALL16 +-@deffnx {} BFD_RELOC_MICROMIPS_CALL16 +-@deffnx {} BFD_RELOC_MIPS_GOT_HI16 +-@deffnx {} BFD_RELOC_MICROMIPS_GOT_HI16 +-@deffnx {} BFD_RELOC_MIPS_GOT_LO16 +-@deffnx {} BFD_RELOC_MICROMIPS_GOT_LO16 +-@deffnx {} BFD_RELOC_MIPS_CALL_HI16 +-@deffnx {} BFD_RELOC_MICROMIPS_CALL_HI16 +-@deffnx {} BFD_RELOC_MIPS_CALL_LO16 +-@deffnx {} BFD_RELOC_MICROMIPS_CALL_LO16 +-@deffnx {} BFD_RELOC_MIPS_SUB +-@deffnx {} BFD_RELOC_MICROMIPS_SUB +-@deffnx {} BFD_RELOC_MIPS_GOT_PAGE +-@deffnx {} BFD_RELOC_MICROMIPS_GOT_PAGE +-@deffnx {} BFD_RELOC_MIPS_GOT_OFST +-@deffnx {} BFD_RELOC_MICROMIPS_GOT_OFST +-@deffnx {} BFD_RELOC_MIPS_GOT_DISP +-@deffnx {} BFD_RELOC_MICROMIPS_GOT_DISP +-@deffnx {} BFD_RELOC_MIPS_SHIFT5 +-@deffnx {} BFD_RELOC_MIPS_SHIFT6 +-@deffnx {} BFD_RELOC_MIPS_INSERT_A +-@deffnx {} BFD_RELOC_MIPS_INSERT_B +-@deffnx {} BFD_RELOC_MIPS_DELETE +-@deffnx {} BFD_RELOC_MIPS_HIGHEST +-@deffnx {} BFD_RELOC_MICROMIPS_HIGHEST +-@deffnx {} BFD_RELOC_MIPS_HIGHER +-@deffnx {} BFD_RELOC_MICROMIPS_HIGHER +-@deffnx {} BFD_RELOC_MIPS_SCN_DISP +-@deffnx {} BFD_RELOC_MICROMIPS_SCN_DISP +-@deffnx {} BFD_RELOC_MIPS_16 +-@deffnx {} BFD_RELOC_MIPS_RELGOT +-@deffnx {} BFD_RELOC_MIPS_JALR +-@deffnx {} BFD_RELOC_MICROMIPS_JALR +-@deffnx {} BFD_RELOC_MIPS_TLS_DTPMOD32 +-@deffnx {} BFD_RELOC_MIPS_TLS_DTPREL32 +-@deffnx {} BFD_RELOC_MIPS_TLS_DTPMOD64 +-@deffnx {} BFD_RELOC_MIPS_TLS_DTPREL64 +-@deffnx {} BFD_RELOC_MIPS_TLS_GD +-@deffnx {} BFD_RELOC_MICROMIPS_TLS_GD +-@deffnx {} BFD_RELOC_MIPS_TLS_LDM +-@deffnx {} BFD_RELOC_MICROMIPS_TLS_LDM +-@deffnx {} BFD_RELOC_MIPS_TLS_DTPREL_HI16 +-@deffnx {} BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16 +-@deffnx {} BFD_RELOC_MIPS_TLS_DTPREL_LO16 +-@deffnx {} BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16 +-@deffnx {} BFD_RELOC_MIPS_TLS_GOTTPREL +-@deffnx {} BFD_RELOC_MICROMIPS_TLS_GOTTPREL +-@deffnx {} BFD_RELOC_MIPS_TLS_TPREL32 +-@deffnx {} BFD_RELOC_MIPS_TLS_TPREL64 +-@deffnx {} BFD_RELOC_MIPS_TLS_TPREL_HI16 +-@deffnx {} BFD_RELOC_MICROMIPS_TLS_TPREL_HI16 +-@deffnx {} BFD_RELOC_MIPS_TLS_TPREL_LO16 +-@deffnx {} BFD_RELOC_MICROMIPS_TLS_TPREL_LO16 +-@deffnx {} BFD_RELOC_MIPS_EH +-MIPS ELF relocations. +-@end deffn +-@deffn {} BFD_RELOC_MIPS_COPY +-@deffnx {} BFD_RELOC_MIPS_JUMP_SLOT +-MIPS ELF relocations (VxWorks and PLT extensions). +-@end deffn +-@deffn {} BFD_RELOC_MOXIE_10_PCREL +-Moxie ELF relocations. +-@end deffn +-@deffn {} BFD_RELOC_FT32_10 +-@deffnx {} BFD_RELOC_FT32_20 +-@deffnx {} BFD_RELOC_FT32_17 +-@deffnx {} BFD_RELOC_FT32_18 +-@deffnx {} BFD_RELOC_FT32_RELAX +-@deffnx {} BFD_RELOC_FT32_SC0 +-@deffnx {} BFD_RELOC_FT32_SC1 +-@deffnx {} BFD_RELOC_FT32_15 +-@deffnx {} BFD_RELOC_FT32_DIFF32 +-FT32 ELF relocations. +-@end deffn +-@deffn {} BFD_RELOC_FRV_LABEL16 +-@deffnx {} BFD_RELOC_FRV_LABEL24 +-@deffnx {} BFD_RELOC_FRV_LO16 +-@deffnx {} BFD_RELOC_FRV_HI16 +-@deffnx {} BFD_RELOC_FRV_GPREL12 +-@deffnx {} BFD_RELOC_FRV_GPRELU12 +-@deffnx {} BFD_RELOC_FRV_GPREL32 +-@deffnx {} BFD_RELOC_FRV_GPRELHI +-@deffnx {} BFD_RELOC_FRV_GPRELLO +-@deffnx {} BFD_RELOC_FRV_GOT12 +-@deffnx {} BFD_RELOC_FRV_GOTHI +-@deffnx {} BFD_RELOC_FRV_GOTLO +-@deffnx {} BFD_RELOC_FRV_FUNCDESC +-@deffnx {} BFD_RELOC_FRV_FUNCDESC_GOT12 +-@deffnx {} BFD_RELOC_FRV_FUNCDESC_GOTHI +-@deffnx {} BFD_RELOC_FRV_FUNCDESC_GOTLO +-@deffnx {} BFD_RELOC_FRV_FUNCDESC_VALUE +-@deffnx {} BFD_RELOC_FRV_FUNCDESC_GOTOFF12 +-@deffnx {} BFD_RELOC_FRV_FUNCDESC_GOTOFFHI +-@deffnx {} BFD_RELOC_FRV_FUNCDESC_GOTOFFLO +-@deffnx {} BFD_RELOC_FRV_GOTOFF12 +-@deffnx {} BFD_RELOC_FRV_GOTOFFHI +-@deffnx {} BFD_RELOC_FRV_GOTOFFLO +-@deffnx {} BFD_RELOC_FRV_GETTLSOFF +-@deffnx {} BFD_RELOC_FRV_TLSDESC_VALUE +-@deffnx {} BFD_RELOC_FRV_GOTTLSDESC12 +-@deffnx {} BFD_RELOC_FRV_GOTTLSDESCHI +-@deffnx {} BFD_RELOC_FRV_GOTTLSDESCLO +-@deffnx {} BFD_RELOC_FRV_TLSMOFF12 +-@deffnx {} BFD_RELOC_FRV_TLSMOFFHI +-@deffnx {} BFD_RELOC_FRV_TLSMOFFLO +-@deffnx {} BFD_RELOC_FRV_GOTTLSOFF12 +-@deffnx {} BFD_RELOC_FRV_GOTTLSOFFHI +-@deffnx {} BFD_RELOC_FRV_GOTTLSOFFLO +-@deffnx {} BFD_RELOC_FRV_TLSOFF +-@deffnx {} BFD_RELOC_FRV_TLSDESC_RELAX +-@deffnx {} BFD_RELOC_FRV_GETTLSOFF_RELAX +-@deffnx {} BFD_RELOC_FRV_TLSOFF_RELAX +-@deffnx {} BFD_RELOC_FRV_TLSMOFF +-Fujitsu Frv Relocations. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_GOTOFF24 +-This is a 24bit GOT-relative reloc for the mn10300. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_GOT32 +-This is a 32bit GOT-relative reloc for the mn10300, offset by two bytes +-in the instruction. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_GOT24 +-This is a 24bit GOT-relative reloc for the mn10300, offset by two bytes +-in the instruction. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_GOT16 +-This is a 16bit GOT-relative reloc for the mn10300, offset by two bytes +-in the instruction. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_COPY +-Copy symbol at runtime. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_GLOB_DAT +-Create GOT entry. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_JMP_SLOT +-Create PLT entry. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_RELATIVE +-Adjust by program base. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_SYM_DIFF +-Together with another reloc targeted at the same location, +-allows for a value that is the difference of two symbols +-in the same section. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_ALIGN +-The addend of this reloc is an alignment power that must +-be honoured at the offset's location, regardless of linker +-relaxation. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_TLS_GD +-@deffnx {} BFD_RELOC_MN10300_TLS_LD +-@deffnx {} BFD_RELOC_MN10300_TLS_LDO +-@deffnx {} BFD_RELOC_MN10300_TLS_GOTIE +-@deffnx {} BFD_RELOC_MN10300_TLS_IE +-@deffnx {} BFD_RELOC_MN10300_TLS_LE +-@deffnx {} BFD_RELOC_MN10300_TLS_DTPMOD +-@deffnx {} BFD_RELOC_MN10300_TLS_DTPOFF +-@deffnx {} BFD_RELOC_MN10300_TLS_TPOFF +-Various TLS-related relocations. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_32_PCREL +-This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the +-instruction. +-@end deffn +-@deffn {} BFD_RELOC_MN10300_16_PCREL +-This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the +-instruction. +-@end deffn +-@deffn {} BFD_RELOC_386_GOT32 +-@deffnx {} BFD_RELOC_386_PLT32 +-@deffnx {} BFD_RELOC_386_COPY +-@deffnx {} BFD_RELOC_386_GLOB_DAT +-@deffnx {} BFD_RELOC_386_JUMP_SLOT +-@deffnx {} BFD_RELOC_386_RELATIVE +-@deffnx {} BFD_RELOC_386_GOTOFF +-@deffnx {} BFD_RELOC_386_GOTPC +-@deffnx {} BFD_RELOC_386_TLS_TPOFF +-@deffnx {} BFD_RELOC_386_TLS_IE +-@deffnx {} BFD_RELOC_386_TLS_GOTIE +-@deffnx {} BFD_RELOC_386_TLS_LE +-@deffnx {} BFD_RELOC_386_TLS_GD +-@deffnx {} BFD_RELOC_386_TLS_LDM +-@deffnx {} BFD_RELOC_386_TLS_LDO_32 +-@deffnx {} BFD_RELOC_386_TLS_IE_32 +-@deffnx {} BFD_RELOC_386_TLS_LE_32 +-@deffnx {} BFD_RELOC_386_TLS_DTPMOD32 +-@deffnx {} BFD_RELOC_386_TLS_DTPOFF32 +-@deffnx {} BFD_RELOC_386_TLS_TPOFF32 +-@deffnx {} BFD_RELOC_386_TLS_GOTDESC +-@deffnx {} BFD_RELOC_386_TLS_DESC_CALL +-@deffnx {} BFD_RELOC_386_TLS_DESC +-@deffnx {} BFD_RELOC_386_IRELATIVE +-@deffnx {} BFD_RELOC_386_GOT32X +-i386/elf relocations +-@end deffn +-@deffn {} BFD_RELOC_X86_64_GOT32 +-@deffnx {} BFD_RELOC_X86_64_PLT32 +-@deffnx {} BFD_RELOC_X86_64_COPY +-@deffnx {} BFD_RELOC_X86_64_GLOB_DAT +-@deffnx {} BFD_RELOC_X86_64_JUMP_SLOT +-@deffnx {} BFD_RELOC_X86_64_RELATIVE +-@deffnx {} BFD_RELOC_X86_64_GOTPCREL +-@deffnx {} BFD_RELOC_X86_64_32S +-@deffnx {} BFD_RELOC_X86_64_DTPMOD64 +-@deffnx {} BFD_RELOC_X86_64_DTPOFF64 +-@deffnx {} BFD_RELOC_X86_64_TPOFF64 +-@deffnx {} BFD_RELOC_X86_64_TLSGD +-@deffnx {} BFD_RELOC_X86_64_TLSLD +-@deffnx {} BFD_RELOC_X86_64_DTPOFF32 +-@deffnx {} BFD_RELOC_X86_64_GOTTPOFF +-@deffnx {} BFD_RELOC_X86_64_TPOFF32 +-@deffnx {} BFD_RELOC_X86_64_GOTOFF64 +-@deffnx {} BFD_RELOC_X86_64_GOTPC32 +-@deffnx {} BFD_RELOC_X86_64_GOT64 +-@deffnx {} BFD_RELOC_X86_64_GOTPCREL64 +-@deffnx {} BFD_RELOC_X86_64_GOTPC64 +-@deffnx {} BFD_RELOC_X86_64_GOTPLT64 +-@deffnx {} BFD_RELOC_X86_64_PLTOFF64 +-@deffnx {} BFD_RELOC_X86_64_GOTPC32_TLSDESC +-@deffnx {} BFD_RELOC_X86_64_TLSDESC_CALL +-@deffnx {} BFD_RELOC_X86_64_TLSDESC +-@deffnx {} BFD_RELOC_X86_64_IRELATIVE +-@deffnx {} BFD_RELOC_X86_64_PC32_BND +-@deffnx {} BFD_RELOC_X86_64_PLT32_BND +-@deffnx {} BFD_RELOC_X86_64_GOTPCRELX +-@deffnx {} BFD_RELOC_X86_64_REX_GOTPCRELX +-x86-64/elf relocations +-@end deffn +-@deffn {} BFD_RELOC_NS32K_IMM_8 +-@deffnx {} BFD_RELOC_NS32K_IMM_16 +-@deffnx {} BFD_RELOC_NS32K_IMM_32 +-@deffnx {} BFD_RELOC_NS32K_IMM_8_PCREL +-@deffnx {} BFD_RELOC_NS32K_IMM_16_PCREL +-@deffnx {} BFD_RELOC_NS32K_IMM_32_PCREL +-@deffnx {} BFD_RELOC_NS32K_DISP_8 +-@deffnx {} BFD_RELOC_NS32K_DISP_16 +-@deffnx {} BFD_RELOC_NS32K_DISP_32 +-@deffnx {} BFD_RELOC_NS32K_DISP_8_PCREL +-@deffnx {} BFD_RELOC_NS32K_DISP_16_PCREL +-@deffnx {} BFD_RELOC_NS32K_DISP_32_PCREL +-ns32k relocations +-@end deffn +-@deffn {} BFD_RELOC_PDP11_DISP_8_PCREL +-@deffnx {} BFD_RELOC_PDP11_DISP_6_PCREL +-PDP11 relocations +-@end deffn +-@deffn {} BFD_RELOC_PJ_CODE_HI16 +-@deffnx {} BFD_RELOC_PJ_CODE_LO16 +-@deffnx {} BFD_RELOC_PJ_CODE_DIR16 +-@deffnx {} BFD_RELOC_PJ_CODE_DIR32 +-@deffnx {} BFD_RELOC_PJ_CODE_REL16 +-@deffnx {} BFD_RELOC_PJ_CODE_REL32 +-Picojava relocs. Not all of these appear in object files. +-@end deffn +-@deffn {} BFD_RELOC_PPC_B26 +-@deffnx {} BFD_RELOC_PPC_BA26 +-@deffnx {} BFD_RELOC_PPC_TOC16 +-@deffnx {} BFD_RELOC_PPC_TOC16_LO +-@deffnx {} BFD_RELOC_PPC_TOC16_HI +-@deffnx {} BFD_RELOC_PPC_B16 +-@deffnx {} BFD_RELOC_PPC_B16_BRTAKEN +-@deffnx {} BFD_RELOC_PPC_B16_BRNTAKEN +-@deffnx {} BFD_RELOC_PPC_BA16 +-@deffnx {} BFD_RELOC_PPC_BA16_BRTAKEN +-@deffnx {} BFD_RELOC_PPC_BA16_BRNTAKEN +-@deffnx {} BFD_RELOC_PPC_COPY +-@deffnx {} BFD_RELOC_PPC_GLOB_DAT +-@deffnx {} BFD_RELOC_PPC_JMP_SLOT +-@deffnx {} BFD_RELOC_PPC_RELATIVE +-@deffnx {} BFD_RELOC_PPC_LOCAL24PC +-@deffnx {} BFD_RELOC_PPC_EMB_NADDR32 +-@deffnx {} BFD_RELOC_PPC_EMB_NADDR16 +-@deffnx {} BFD_RELOC_PPC_EMB_NADDR16_LO +-@deffnx {} BFD_RELOC_PPC_EMB_NADDR16_HI +-@deffnx {} BFD_RELOC_PPC_EMB_NADDR16_HA +-@deffnx {} BFD_RELOC_PPC_EMB_SDAI16 +-@deffnx {} BFD_RELOC_PPC_EMB_SDA2I16 +-@deffnx {} BFD_RELOC_PPC_EMB_SDA2REL +-@deffnx {} BFD_RELOC_PPC_EMB_SDA21 +-@deffnx {} BFD_RELOC_PPC_EMB_MRKREF +-@deffnx {} BFD_RELOC_PPC_EMB_RELSEC16 +-@deffnx {} BFD_RELOC_PPC_EMB_RELST_LO +-@deffnx {} BFD_RELOC_PPC_EMB_RELST_HI +-@deffnx {} BFD_RELOC_PPC_EMB_RELST_HA +-@deffnx {} BFD_RELOC_PPC_EMB_BIT_FLD +-@deffnx {} BFD_RELOC_PPC_EMB_RELSDA +-@deffnx {} BFD_RELOC_PPC_VLE_REL8 +-@deffnx {} BFD_RELOC_PPC_VLE_REL15 +-@deffnx {} BFD_RELOC_PPC_VLE_REL24 +-@deffnx {} BFD_RELOC_PPC_VLE_LO16A +-@deffnx {} BFD_RELOC_PPC_VLE_LO16D +-@deffnx {} BFD_RELOC_PPC_VLE_HI16A +-@deffnx {} BFD_RELOC_PPC_VLE_HI16D +-@deffnx {} BFD_RELOC_PPC_VLE_HA16A +-@deffnx {} BFD_RELOC_PPC_VLE_HA16D +-@deffnx {} BFD_RELOC_PPC_VLE_SDA21 +-@deffnx {} BFD_RELOC_PPC_VLE_SDA21_LO +-@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_LO16A +-@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_LO16D +-@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_HI16A +-@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_HI16D +-@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_HA16A +-@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_HA16D +-@deffnx {} BFD_RELOC_PPC_16DX_HA +-@deffnx {} BFD_RELOC_PPC_REL16DX_HA +-@deffnx {} BFD_RELOC_PPC_NEG +-@deffnx {} BFD_RELOC_PPC64_HIGHER +-@deffnx {} BFD_RELOC_PPC64_HIGHER_S +-@deffnx {} BFD_RELOC_PPC64_HIGHEST +-@deffnx {} BFD_RELOC_PPC64_HIGHEST_S +-@deffnx {} BFD_RELOC_PPC64_TOC16_LO +-@deffnx {} BFD_RELOC_PPC64_TOC16_HI +-@deffnx {} BFD_RELOC_PPC64_TOC16_HA +-@deffnx {} BFD_RELOC_PPC64_TOC +-@deffnx {} BFD_RELOC_PPC64_PLTGOT16 +-@deffnx {} BFD_RELOC_PPC64_PLTGOT16_LO +-@deffnx {} BFD_RELOC_PPC64_PLTGOT16_HI +-@deffnx {} BFD_RELOC_PPC64_PLTGOT16_HA +-@deffnx {} BFD_RELOC_PPC64_ADDR16_DS +-@deffnx {} BFD_RELOC_PPC64_ADDR16_LO_DS +-@deffnx {} BFD_RELOC_PPC64_GOT16_DS +-@deffnx {} BFD_RELOC_PPC64_GOT16_LO_DS +-@deffnx {} BFD_RELOC_PPC64_PLT16_LO_DS +-@deffnx {} BFD_RELOC_PPC64_SECTOFF_DS +-@deffnx {} BFD_RELOC_PPC64_SECTOFF_LO_DS +-@deffnx {} BFD_RELOC_PPC64_TOC16_DS +-@deffnx {} BFD_RELOC_PPC64_TOC16_LO_DS +-@deffnx {} BFD_RELOC_PPC64_PLTGOT16_DS +-@deffnx {} BFD_RELOC_PPC64_PLTGOT16_LO_DS +-@deffnx {} BFD_RELOC_PPC64_ADDR16_HIGH +-@deffnx {} BFD_RELOC_PPC64_ADDR16_HIGHA +-@deffnx {} BFD_RELOC_PPC64_REL16_HIGH +-@deffnx {} BFD_RELOC_PPC64_REL16_HIGHA +-@deffnx {} BFD_RELOC_PPC64_REL16_HIGHER +-@deffnx {} BFD_RELOC_PPC64_REL16_HIGHERA +-@deffnx {} BFD_RELOC_PPC64_REL16_HIGHEST +-@deffnx {} BFD_RELOC_PPC64_REL16_HIGHESTA +-@deffnx {} BFD_RELOC_PPC64_ADDR64_LOCAL +-@deffnx {} BFD_RELOC_PPC64_ENTRY +-@deffnx {} BFD_RELOC_PPC64_REL24_NOTOC +-@deffnx {} BFD_RELOC_PPC64_REL24_P9NOTOC +-@deffnx {} BFD_RELOC_PPC64_D34 +-@deffnx {} BFD_RELOC_PPC64_D34_LO +-@deffnx {} BFD_RELOC_PPC64_D34_HI30 +-@deffnx {} BFD_RELOC_PPC64_D34_HA30 +-@deffnx {} BFD_RELOC_PPC64_PCREL34 +-@deffnx {} BFD_RELOC_PPC64_GOT_PCREL34 +-@deffnx {} BFD_RELOC_PPC64_PLT_PCREL34 +-@deffnx {} BFD_RELOC_PPC64_ADDR16_HIGHER34 +-@deffnx {} BFD_RELOC_PPC64_ADDR16_HIGHERA34 +-@deffnx {} BFD_RELOC_PPC64_ADDR16_HIGHEST34 +-@deffnx {} BFD_RELOC_PPC64_ADDR16_HIGHESTA34 +-@deffnx {} BFD_RELOC_PPC64_REL16_HIGHER34 +-@deffnx {} BFD_RELOC_PPC64_REL16_HIGHERA34 +-@deffnx {} BFD_RELOC_PPC64_REL16_HIGHEST34 +-@deffnx {} BFD_RELOC_PPC64_REL16_HIGHESTA34 +-@deffnx {} BFD_RELOC_PPC64_D28 +-@deffnx {} BFD_RELOC_PPC64_PCREL28 +-Power(rs6000) and PowerPC relocations. +-@end deffn +-@deffn {} BFD_RELOC_PPC_TLS +-@deffnx {} BFD_RELOC_PPC_TLSGD +-@deffnx {} BFD_RELOC_PPC_TLSLD +-@deffnx {} BFD_RELOC_PPC_TLSLE +-@deffnx {} BFD_RELOC_PPC_TLSIE +-@deffnx {} BFD_RELOC_PPC_TLSM +-@deffnx {} BFD_RELOC_PPC_TLSML +-@deffnx {} BFD_RELOC_PPC_DTPMOD +-@deffnx {} BFD_RELOC_PPC_TPREL16 +-@deffnx {} BFD_RELOC_PPC_TPREL16_LO +-@deffnx {} BFD_RELOC_PPC_TPREL16_HI +-@deffnx {} BFD_RELOC_PPC_TPREL16_HA +-@deffnx {} BFD_RELOC_PPC_TPREL +-@deffnx {} BFD_RELOC_PPC_DTPREL16 +-@deffnx {} BFD_RELOC_PPC_DTPREL16_LO +-@deffnx {} BFD_RELOC_PPC_DTPREL16_HI +-@deffnx {} BFD_RELOC_PPC_DTPREL16_HA +-@deffnx {} BFD_RELOC_PPC_DTPREL +-@deffnx {} BFD_RELOC_PPC_GOT_TLSGD16 +-@deffnx {} BFD_RELOC_PPC_GOT_TLSGD16_LO +-@deffnx {} BFD_RELOC_PPC_GOT_TLSGD16_HI +-@deffnx {} BFD_RELOC_PPC_GOT_TLSGD16_HA +-@deffnx {} BFD_RELOC_PPC_GOT_TLSLD16 +-@deffnx {} BFD_RELOC_PPC_GOT_TLSLD16_LO +-@deffnx {} BFD_RELOC_PPC_GOT_TLSLD16_HI +-@deffnx {} BFD_RELOC_PPC_GOT_TLSLD16_HA +-@deffnx {} BFD_RELOC_PPC_GOT_TPREL16 +-@deffnx {} BFD_RELOC_PPC_GOT_TPREL16_LO +-@deffnx {} BFD_RELOC_PPC_GOT_TPREL16_HI +-@deffnx {} BFD_RELOC_PPC_GOT_TPREL16_HA +-@deffnx {} BFD_RELOC_PPC_GOT_DTPREL16 +-@deffnx {} BFD_RELOC_PPC_GOT_DTPREL16_LO +-@deffnx {} BFD_RELOC_PPC_GOT_DTPREL16_HI +-@deffnx {} BFD_RELOC_PPC_GOT_DTPREL16_HA +-@deffnx {} BFD_RELOC_PPC64_TLSGD +-@deffnx {} BFD_RELOC_PPC64_TLSLD +-@deffnx {} BFD_RELOC_PPC64_TLSLE +-@deffnx {} BFD_RELOC_PPC64_TLSIE +-@deffnx {} BFD_RELOC_PPC64_TLSM +-@deffnx {} BFD_RELOC_PPC64_TLSML +-@deffnx {} BFD_RELOC_PPC64_TPREL16_DS +-@deffnx {} BFD_RELOC_PPC64_TPREL16_LO_DS +-@deffnx {} BFD_RELOC_PPC64_TPREL16_HIGH +-@deffnx {} BFD_RELOC_PPC64_TPREL16_HIGHA +-@deffnx {} BFD_RELOC_PPC64_TPREL16_HIGHER +-@deffnx {} BFD_RELOC_PPC64_TPREL16_HIGHERA +-@deffnx {} BFD_RELOC_PPC64_TPREL16_HIGHEST +-@deffnx {} BFD_RELOC_PPC64_TPREL16_HIGHESTA +-@deffnx {} BFD_RELOC_PPC64_DTPREL16_DS +-@deffnx {} BFD_RELOC_PPC64_DTPREL16_LO_DS +-@deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGH +-@deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGHA +-@deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGHER +-@deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGHERA +-@deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGHEST +-@deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGHESTA +-@deffnx {} BFD_RELOC_PPC64_TPREL34 +-@deffnx {} BFD_RELOC_PPC64_DTPREL34 +-@deffnx {} BFD_RELOC_PPC64_GOT_TLSGD_PCREL34 +-@deffnx {} BFD_RELOC_PPC64_GOT_TLSLD_PCREL34 +-@deffnx {} BFD_RELOC_PPC64_GOT_TPREL_PCREL34 +-@deffnx {} BFD_RELOC_PPC64_GOT_DTPREL_PCREL34 +-@deffnx {} BFD_RELOC_PPC64_TLS_PCREL +-PowerPC and PowerPC64 thread-local storage relocations. +-@end deffn +-@deffn {} BFD_RELOC_I370_D12 +-IBM 370/390 relocations +-@end deffn +-@deffn {} BFD_RELOC_CTOR +-The type of reloc used to build a constructor table - at the moment +-probably a 32 bit wide absolute relocation, but the target can choose. +-It generally does map to one of the other relocation types. +-@end deffn +-@deffn {} BFD_RELOC_ARM_PCREL_BRANCH +-ARM 26 bit pc-relative branch. The lowest two bits must be zero and are +-not stored in the instruction. +-@end deffn +-@deffn {} BFD_RELOC_ARM_PCREL_BLX +-ARM 26 bit pc-relative branch. The lowest bit must be zero and is +-not stored in the instruction. The 2nd lowest bit comes from a 1 bit +-field in the instruction. +-@end deffn +-@deffn {} BFD_RELOC_THUMB_PCREL_BLX +-Thumb 22 bit pc-relative branch. The lowest bit must be zero and is +-not stored in the instruction. The 2nd lowest bit comes from a 1 bit +-field in the instruction. +-@end deffn +-@deffn {} BFD_RELOC_ARM_PCREL_CALL +-ARM 26-bit pc-relative branch for an unconditional BL or BLX instruction. +-@end deffn +-@deffn {} BFD_RELOC_ARM_PCREL_JUMP +-ARM 26-bit pc-relative branch for B or conditional BL instruction. +-@end deffn +-@deffn {} BFD_RELOC_THUMB_PCREL_BRANCH5 +-ARM 5-bit pc-relative branch for Branch Future instructions. +-@end deffn +-@deffn {} BFD_RELOC_THUMB_PCREL_BFCSEL +-ARM 6-bit pc-relative branch for BFCSEL instruction. +-@end deffn +-@deffn {} BFD_RELOC_ARM_THUMB_BF17 +-ARM 17-bit pc-relative branch for Branch Future instructions. +-@end deffn +-@deffn {} BFD_RELOC_ARM_THUMB_BF13 +-ARM 13-bit pc-relative branch for BFCSEL instruction. +-@end deffn +-@deffn {} BFD_RELOC_ARM_THUMB_BF19 +-ARM 19-bit pc-relative branch for Branch Future Link instruction. +-@end deffn +-@deffn {} BFD_RELOC_ARM_THUMB_LOOP12 +-ARM 12-bit pc-relative branch for Low Overhead Loop instructions. +-@end deffn +-@deffn {} BFD_RELOC_THUMB_PCREL_BRANCH7 +-@deffnx {} BFD_RELOC_THUMB_PCREL_BRANCH9 +-@deffnx {} BFD_RELOC_THUMB_PCREL_BRANCH12 +-@deffnx {} BFD_RELOC_THUMB_PCREL_BRANCH20 +-@deffnx {} BFD_RELOC_THUMB_PCREL_BRANCH23 +-@deffnx {} BFD_RELOC_THUMB_PCREL_BRANCH25 +-Thumb 7-, 9-, 12-, 20-, 23-, and 25-bit pc-relative branches. +-The lowest bit must be zero and is not stored in the instruction. +-Note that the corresponding ELF R_ARM_THM_JUMPnn constant has an +-"nn" one smaller in all cases. Note further that BRANCH23 +-corresponds to R_ARM_THM_CALL. +-@end deffn +-@deffn {} BFD_RELOC_ARM_OFFSET_IMM +-12-bit immediate offset, used in ARM-format ldr and str instructions. +-@end deffn +-@deffn {} BFD_RELOC_ARM_THUMB_OFFSET +-5-bit immediate offset, used in Thumb-format ldr and str instructions. +-@end deffn +-@deffn {} BFD_RELOC_ARM_TARGET1 +-Pc-relative or absolute relocation depending on target. Used for +-entries in .init_array sections. +-@end deffn +-@deffn {} BFD_RELOC_ARM_ROSEGREL32 +-Read-only segment base relative address. +-@end deffn +-@deffn {} BFD_RELOC_ARM_SBREL32 +-Data segment base relative address. +-@end deffn +-@deffn {} BFD_RELOC_ARM_TARGET2 +-This reloc is used for references to RTTI data from exception handling +-tables. The actual definition depends on the target. It may be a +-pc-relative or some form of GOT-indirect relocation. +-@end deffn +-@deffn {} BFD_RELOC_ARM_PREL31 +-31-bit PC relative address. +-@end deffn +-@deffn {} BFD_RELOC_ARM_MOVW +-@deffnx {} BFD_RELOC_ARM_MOVT +-@deffnx {} BFD_RELOC_ARM_MOVW_PCREL +-@deffnx {} BFD_RELOC_ARM_MOVT_PCREL +-@deffnx {} BFD_RELOC_ARM_THUMB_MOVW +-@deffnx {} BFD_RELOC_ARM_THUMB_MOVT +-@deffnx {} BFD_RELOC_ARM_THUMB_MOVW_PCREL +-@deffnx {} BFD_RELOC_ARM_THUMB_MOVT_PCREL +-Low and High halfword relocations for MOVW and MOVT instructions. +-@end deffn +-@deffn {} BFD_RELOC_ARM_GOTFUNCDESC +-@deffnx {} BFD_RELOC_ARM_GOTOFFFUNCDESC +-@deffnx {} BFD_RELOC_ARM_FUNCDESC +-@deffnx {} BFD_RELOC_ARM_FUNCDESC_VALUE +-@deffnx {} BFD_RELOC_ARM_TLS_GD32_FDPIC +-@deffnx {} BFD_RELOC_ARM_TLS_LDM32_FDPIC +-@deffnx {} BFD_RELOC_ARM_TLS_IE32_FDPIC +-ARM FDPIC specific relocations. +-@end deffn +-@deffn {} BFD_RELOC_ARM_JUMP_SLOT +-@deffnx {} BFD_RELOC_ARM_GLOB_DAT +-@deffnx {} BFD_RELOC_ARM_GOT32 +-@deffnx {} BFD_RELOC_ARM_PLT32 +-@deffnx {} BFD_RELOC_ARM_RELATIVE +-@deffnx {} BFD_RELOC_ARM_GOTOFF +-@deffnx {} BFD_RELOC_ARM_GOTPC +-@deffnx {} BFD_RELOC_ARM_GOT_PREL +-Relocations for setting up GOTs and PLTs for shared libraries. +-@end deffn +-@deffn {} BFD_RELOC_ARM_TLS_GD32 +-@deffnx {} BFD_RELOC_ARM_TLS_LDO32 +-@deffnx {} BFD_RELOC_ARM_TLS_LDM32 +-@deffnx {} BFD_RELOC_ARM_TLS_DTPOFF32 +-@deffnx {} BFD_RELOC_ARM_TLS_DTPMOD32 +-@deffnx {} BFD_RELOC_ARM_TLS_TPOFF32 +-@deffnx {} BFD_RELOC_ARM_TLS_IE32 +-@deffnx {} BFD_RELOC_ARM_TLS_LE32 +-@deffnx {} BFD_RELOC_ARM_TLS_GOTDESC +-@deffnx {} BFD_RELOC_ARM_TLS_CALL +-@deffnx {} BFD_RELOC_ARM_THM_TLS_CALL +-@deffnx {} BFD_RELOC_ARM_TLS_DESCSEQ +-@deffnx {} BFD_RELOC_ARM_THM_TLS_DESCSEQ +-@deffnx {} BFD_RELOC_ARM_TLS_DESC +-ARM thread-local storage relocations. +-@end deffn +-@deffn {} BFD_RELOC_ARM_ALU_PC_G0_NC +-@deffnx {} BFD_RELOC_ARM_ALU_PC_G0 +-@deffnx {} BFD_RELOC_ARM_ALU_PC_G1_NC +-@deffnx {} BFD_RELOC_ARM_ALU_PC_G1 +-@deffnx {} BFD_RELOC_ARM_ALU_PC_G2 +-@deffnx {} BFD_RELOC_ARM_LDR_PC_G0 +-@deffnx {} BFD_RELOC_ARM_LDR_PC_G1 +-@deffnx {} BFD_RELOC_ARM_LDR_PC_G2 +-@deffnx {} BFD_RELOC_ARM_LDRS_PC_G0 +-@deffnx {} BFD_RELOC_ARM_LDRS_PC_G1 +-@deffnx {} BFD_RELOC_ARM_LDRS_PC_G2 +-@deffnx {} BFD_RELOC_ARM_LDC_PC_G0 +-@deffnx {} BFD_RELOC_ARM_LDC_PC_G1 +-@deffnx {} BFD_RELOC_ARM_LDC_PC_G2 +-@deffnx {} BFD_RELOC_ARM_ALU_SB_G0_NC +-@deffnx {} BFD_RELOC_ARM_ALU_SB_G0 +-@deffnx {} BFD_RELOC_ARM_ALU_SB_G1_NC +-@deffnx {} BFD_RELOC_ARM_ALU_SB_G1 +-@deffnx {} BFD_RELOC_ARM_ALU_SB_G2 +-@deffnx {} BFD_RELOC_ARM_LDR_SB_G0 +-@deffnx {} BFD_RELOC_ARM_LDR_SB_G1 +-@deffnx {} BFD_RELOC_ARM_LDR_SB_G2 +-@deffnx {} BFD_RELOC_ARM_LDRS_SB_G0 +-@deffnx {} BFD_RELOC_ARM_LDRS_SB_G1 +-@deffnx {} BFD_RELOC_ARM_LDRS_SB_G2 +-@deffnx {} BFD_RELOC_ARM_LDC_SB_G0 +-@deffnx {} BFD_RELOC_ARM_LDC_SB_G1 +-@deffnx {} BFD_RELOC_ARM_LDC_SB_G2 +-ARM group relocations. +-@end deffn +-@deffn {} BFD_RELOC_ARM_V4BX +-Annotation of BX instructions. +-@end deffn +-@deffn {} BFD_RELOC_ARM_IRELATIVE +-ARM support for STT_GNU_IFUNC. +-@end deffn +-@deffn {} BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC +-@deffnx {} BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC +-@deffnx {} BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC +-@deffnx {} BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC +-Thumb1 relocations to support execute-only code. +-@end deffn +-@deffn {} BFD_RELOC_ARM_IMMEDIATE +-@deffnx {} BFD_RELOC_ARM_ADRL_IMMEDIATE +-@deffnx {} BFD_RELOC_ARM_T32_IMMEDIATE +-@deffnx {} BFD_RELOC_ARM_T32_ADD_IMM +-@deffnx {} BFD_RELOC_ARM_T32_IMM12 +-@deffnx {} BFD_RELOC_ARM_T32_ADD_PC12 +-@deffnx {} BFD_RELOC_ARM_SHIFT_IMM +-@deffnx {} BFD_RELOC_ARM_SMC +-@deffnx {} BFD_RELOC_ARM_HVC +-@deffnx {} BFD_RELOC_ARM_SWI +-@deffnx {} BFD_RELOC_ARM_MULTI +-@deffnx {} BFD_RELOC_ARM_CP_OFF_IMM +-@deffnx {} BFD_RELOC_ARM_CP_OFF_IMM_S2 +-@deffnx {} BFD_RELOC_ARM_T32_CP_OFF_IMM +-@deffnx {} BFD_RELOC_ARM_T32_CP_OFF_IMM_S2 +-@deffnx {} BFD_RELOC_ARM_T32_VLDR_VSTR_OFF_IMM +-@deffnx {} BFD_RELOC_ARM_ADR_IMM +-@deffnx {} BFD_RELOC_ARM_LDR_IMM +-@deffnx {} BFD_RELOC_ARM_LITERAL +-@deffnx {} BFD_RELOC_ARM_IN_POOL +-@deffnx {} BFD_RELOC_ARM_OFFSET_IMM8 +-@deffnx {} BFD_RELOC_ARM_T32_OFFSET_U8 +-@deffnx {} BFD_RELOC_ARM_T32_OFFSET_IMM +-@deffnx {} BFD_RELOC_ARM_HWLITERAL +-@deffnx {} BFD_RELOC_ARM_THUMB_ADD +-@deffnx {} BFD_RELOC_ARM_THUMB_IMM +-@deffnx {} BFD_RELOC_ARM_THUMB_SHIFT +-These relocs are only used within the ARM assembler. They are not +-(at present) written to any object files. +-@end deffn +-@deffn {} BFD_RELOC_SH_PCDISP8BY2 +-@deffnx {} BFD_RELOC_SH_PCDISP12BY2 +-@deffnx {} BFD_RELOC_SH_IMM3 +-@deffnx {} BFD_RELOC_SH_IMM3U +-@deffnx {} BFD_RELOC_SH_DISP12 +-@deffnx {} BFD_RELOC_SH_DISP12BY2 +-@deffnx {} BFD_RELOC_SH_DISP12BY4 +-@deffnx {} BFD_RELOC_SH_DISP12BY8 +-@deffnx {} BFD_RELOC_SH_DISP20 +-@deffnx {} BFD_RELOC_SH_DISP20BY8 +-@deffnx {} BFD_RELOC_SH_IMM4 +-@deffnx {} BFD_RELOC_SH_IMM4BY2 +-@deffnx {} BFD_RELOC_SH_IMM4BY4 +-@deffnx {} BFD_RELOC_SH_IMM8 +-@deffnx {} BFD_RELOC_SH_IMM8BY2 +-@deffnx {} BFD_RELOC_SH_IMM8BY4 +-@deffnx {} BFD_RELOC_SH_PCRELIMM8BY2 +-@deffnx {} BFD_RELOC_SH_PCRELIMM8BY4 +-@deffnx {} BFD_RELOC_SH_SWITCH16 +-@deffnx {} BFD_RELOC_SH_SWITCH32 +-@deffnx {} BFD_RELOC_SH_USES +-@deffnx {} BFD_RELOC_SH_COUNT +-@deffnx {} BFD_RELOC_SH_ALIGN +-@deffnx {} BFD_RELOC_SH_CODE +-@deffnx {} BFD_RELOC_SH_DATA +-@deffnx {} BFD_RELOC_SH_LABEL +-@deffnx {} BFD_RELOC_SH_LOOP_START +-@deffnx {} BFD_RELOC_SH_LOOP_END +-@deffnx {} BFD_RELOC_SH_COPY +-@deffnx {} BFD_RELOC_SH_GLOB_DAT +-@deffnx {} BFD_RELOC_SH_JMP_SLOT +-@deffnx {} BFD_RELOC_SH_RELATIVE +-@deffnx {} BFD_RELOC_SH_GOTPC +-@deffnx {} BFD_RELOC_SH_GOT_LOW16 +-@deffnx {} BFD_RELOC_SH_GOT_MEDLOW16 +-@deffnx {} BFD_RELOC_SH_GOT_MEDHI16 +-@deffnx {} BFD_RELOC_SH_GOT_HI16 +-@deffnx {} BFD_RELOC_SH_GOTPLT_LOW16 +-@deffnx {} BFD_RELOC_SH_GOTPLT_MEDLOW16 +-@deffnx {} BFD_RELOC_SH_GOTPLT_MEDHI16 +-@deffnx {} BFD_RELOC_SH_GOTPLT_HI16 +-@deffnx {} BFD_RELOC_SH_PLT_LOW16 +-@deffnx {} BFD_RELOC_SH_PLT_MEDLOW16 +-@deffnx {} BFD_RELOC_SH_PLT_MEDHI16 +-@deffnx {} BFD_RELOC_SH_PLT_HI16 +-@deffnx {} BFD_RELOC_SH_GOTOFF_LOW16 +-@deffnx {} BFD_RELOC_SH_GOTOFF_MEDLOW16 +-@deffnx {} BFD_RELOC_SH_GOTOFF_MEDHI16 +-@deffnx {} BFD_RELOC_SH_GOTOFF_HI16 +-@deffnx {} BFD_RELOC_SH_GOTPC_LOW16 +-@deffnx {} BFD_RELOC_SH_GOTPC_MEDLOW16 +-@deffnx {} BFD_RELOC_SH_GOTPC_MEDHI16 +-@deffnx {} BFD_RELOC_SH_GOTPC_HI16 +-@deffnx {} BFD_RELOC_SH_COPY64 +-@deffnx {} BFD_RELOC_SH_GLOB_DAT64 +-@deffnx {} BFD_RELOC_SH_JMP_SLOT64 +-@deffnx {} BFD_RELOC_SH_RELATIVE64 +-@deffnx {} BFD_RELOC_SH_GOT10BY4 +-@deffnx {} BFD_RELOC_SH_GOT10BY8 +-@deffnx {} BFD_RELOC_SH_GOTPLT10BY4 +-@deffnx {} BFD_RELOC_SH_GOTPLT10BY8 +-@deffnx {} BFD_RELOC_SH_GOTPLT32 +-@deffnx {} BFD_RELOC_SH_SHMEDIA_CODE +-@deffnx {} BFD_RELOC_SH_IMMU5 +-@deffnx {} BFD_RELOC_SH_IMMS6 +-@deffnx {} BFD_RELOC_SH_IMMS6BY32 +-@deffnx {} BFD_RELOC_SH_IMMU6 +-@deffnx {} BFD_RELOC_SH_IMMS10 +-@deffnx {} BFD_RELOC_SH_IMMS10BY2 +-@deffnx {} BFD_RELOC_SH_IMMS10BY4 +-@deffnx {} BFD_RELOC_SH_IMMS10BY8 +-@deffnx {} BFD_RELOC_SH_IMMS16 +-@deffnx {} BFD_RELOC_SH_IMMU16 +-@deffnx {} BFD_RELOC_SH_IMM_LOW16 +-@deffnx {} BFD_RELOC_SH_IMM_LOW16_PCREL +-@deffnx {} BFD_RELOC_SH_IMM_MEDLOW16 +-@deffnx {} BFD_RELOC_SH_IMM_MEDLOW16_PCREL +-@deffnx {} BFD_RELOC_SH_IMM_MEDHI16 +-@deffnx {} BFD_RELOC_SH_IMM_MEDHI16_PCREL +-@deffnx {} BFD_RELOC_SH_IMM_HI16 +-@deffnx {} BFD_RELOC_SH_IMM_HI16_PCREL +-@deffnx {} BFD_RELOC_SH_PT_16 +-@deffnx {} BFD_RELOC_SH_TLS_GD_32 +-@deffnx {} BFD_RELOC_SH_TLS_LD_32 +-@deffnx {} BFD_RELOC_SH_TLS_LDO_32 +-@deffnx {} BFD_RELOC_SH_TLS_IE_32 +-@deffnx {} BFD_RELOC_SH_TLS_LE_32 +-@deffnx {} BFD_RELOC_SH_TLS_DTPMOD32 +-@deffnx {} BFD_RELOC_SH_TLS_DTPOFF32 +-@deffnx {} BFD_RELOC_SH_TLS_TPOFF32 +-@deffnx {} BFD_RELOC_SH_GOT20 +-@deffnx {} BFD_RELOC_SH_GOTOFF20 +-@deffnx {} BFD_RELOC_SH_GOTFUNCDESC +-@deffnx {} BFD_RELOC_SH_GOTFUNCDESC20 +-@deffnx {} BFD_RELOC_SH_GOTOFFFUNCDESC +-@deffnx {} BFD_RELOC_SH_GOTOFFFUNCDESC20 +-@deffnx {} BFD_RELOC_SH_FUNCDESC +-Renesas / SuperH SH relocs. Not all of these appear in object files. +-@end deffn +-@deffn {} BFD_RELOC_ARC_NONE +-@deffnx {} BFD_RELOC_ARC_8 +-@deffnx {} BFD_RELOC_ARC_16 +-@deffnx {} BFD_RELOC_ARC_24 +-@deffnx {} BFD_RELOC_ARC_32 +-@deffnx {} BFD_RELOC_ARC_N8 +-@deffnx {} BFD_RELOC_ARC_N16 +-@deffnx {} BFD_RELOC_ARC_N24 +-@deffnx {} BFD_RELOC_ARC_N32 +-@deffnx {} BFD_RELOC_ARC_SDA +-@deffnx {} BFD_RELOC_ARC_SECTOFF +-@deffnx {} BFD_RELOC_ARC_S21H_PCREL +-@deffnx {} BFD_RELOC_ARC_S21W_PCREL +-@deffnx {} BFD_RELOC_ARC_S25H_PCREL +-@deffnx {} BFD_RELOC_ARC_S25W_PCREL +-@deffnx {} BFD_RELOC_ARC_SDA32 +-@deffnx {} BFD_RELOC_ARC_SDA_LDST +-@deffnx {} BFD_RELOC_ARC_SDA_LDST1 +-@deffnx {} BFD_RELOC_ARC_SDA_LDST2 +-@deffnx {} BFD_RELOC_ARC_SDA16_LD +-@deffnx {} BFD_RELOC_ARC_SDA16_LD1 +-@deffnx {} BFD_RELOC_ARC_SDA16_LD2 +-@deffnx {} BFD_RELOC_ARC_S13_PCREL +-@deffnx {} BFD_RELOC_ARC_W +-@deffnx {} BFD_RELOC_ARC_32_ME +-@deffnx {} BFD_RELOC_ARC_32_ME_S +-@deffnx {} BFD_RELOC_ARC_N32_ME +-@deffnx {} BFD_RELOC_ARC_SECTOFF_ME +-@deffnx {} BFD_RELOC_ARC_SDA32_ME +-@deffnx {} BFD_RELOC_ARC_W_ME +-@deffnx {} BFD_RELOC_AC_SECTOFF_U8 +-@deffnx {} BFD_RELOC_AC_SECTOFF_U8_1 +-@deffnx {} BFD_RELOC_AC_SECTOFF_U8_2 +-@deffnx {} BFD_RELOC_AC_SECTOFF_S9 +-@deffnx {} BFD_RELOC_AC_SECTOFF_S9_1 +-@deffnx {} BFD_RELOC_AC_SECTOFF_S9_2 +-@deffnx {} BFD_RELOC_ARC_SECTOFF_ME_1 +-@deffnx {} BFD_RELOC_ARC_SECTOFF_ME_2 +-@deffnx {} BFD_RELOC_ARC_SECTOFF_1 +-@deffnx {} BFD_RELOC_ARC_SECTOFF_2 +-@deffnx {} BFD_RELOC_ARC_SDA_12 +-@deffnx {} BFD_RELOC_ARC_SDA16_ST2 +-@deffnx {} BFD_RELOC_ARC_32_PCREL +-@deffnx {} BFD_RELOC_ARC_PC32 +-@deffnx {} BFD_RELOC_ARC_GOT32 +-@deffnx {} BFD_RELOC_ARC_GOTPC32 +-@deffnx {} BFD_RELOC_ARC_PLT32 +-@deffnx {} BFD_RELOC_ARC_COPY +-@deffnx {} BFD_RELOC_ARC_GLOB_DAT +-@deffnx {} BFD_RELOC_ARC_JMP_SLOT +-@deffnx {} BFD_RELOC_ARC_RELATIVE +-@deffnx {} BFD_RELOC_ARC_GOTOFF +-@deffnx {} BFD_RELOC_ARC_GOTPC +-@deffnx {} BFD_RELOC_ARC_S21W_PCREL_PLT +-@deffnx {} BFD_RELOC_ARC_S25H_PCREL_PLT +-@deffnx {} BFD_RELOC_ARC_TLS_DTPMOD +-@deffnx {} BFD_RELOC_ARC_TLS_TPOFF +-@deffnx {} BFD_RELOC_ARC_TLS_GD_GOT +-@deffnx {} BFD_RELOC_ARC_TLS_GD_LD +-@deffnx {} BFD_RELOC_ARC_TLS_GD_CALL +-@deffnx {} BFD_RELOC_ARC_TLS_IE_GOT +-@deffnx {} BFD_RELOC_ARC_TLS_DTPOFF +-@deffnx {} BFD_RELOC_ARC_TLS_DTPOFF_S9 +-@deffnx {} BFD_RELOC_ARC_TLS_LE_S9 +-@deffnx {} BFD_RELOC_ARC_TLS_LE_32 +-@deffnx {} BFD_RELOC_ARC_S25W_PCREL_PLT +-@deffnx {} BFD_RELOC_ARC_S21H_PCREL_PLT +-@deffnx {} BFD_RELOC_ARC_NPS_CMEM16 +-@deffnx {} BFD_RELOC_ARC_JLI_SECTOFF +-ARC relocs. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_16_IMM +-ADI Blackfin 16 bit immediate absolute reloc. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_16_HIGH +-ADI Blackfin 16 bit immediate absolute reloc higher 16 bits. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_4_PCREL +-ADI Blackfin 'a' part of LSETUP. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_5_PCREL +-ADI Blackfin. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_16_LOW +-ADI Blackfin 16 bit immediate absolute reloc lower 16 bits. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_10_PCREL +-ADI Blackfin. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_11_PCREL +-ADI Blackfin 'b' part of LSETUP. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_12_PCREL_JUMP +-ADI Blackfin. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_12_PCREL_JUMP_S +-ADI Blackfin Short jump, pcrel. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_24_PCREL_CALL_X +-ADI Blackfin Call.x not implemented. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_24_PCREL_JUMP_L +-ADI Blackfin Long Jump pcrel. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_GOT17M4 +-@deffnx {} BFD_RELOC_BFIN_GOTHI +-@deffnx {} BFD_RELOC_BFIN_GOTLO +-@deffnx {} BFD_RELOC_BFIN_FUNCDESC +-@deffnx {} BFD_RELOC_BFIN_FUNCDESC_GOT17M4 +-@deffnx {} BFD_RELOC_BFIN_FUNCDESC_GOTHI +-@deffnx {} BFD_RELOC_BFIN_FUNCDESC_GOTLO +-@deffnx {} BFD_RELOC_BFIN_FUNCDESC_VALUE +-@deffnx {} BFD_RELOC_BFIN_FUNCDESC_GOTOFF17M4 +-@deffnx {} BFD_RELOC_BFIN_FUNCDESC_GOTOFFHI +-@deffnx {} BFD_RELOC_BFIN_FUNCDESC_GOTOFFLO +-@deffnx {} BFD_RELOC_BFIN_GOTOFF17M4 +-@deffnx {} BFD_RELOC_BFIN_GOTOFFHI +-@deffnx {} BFD_RELOC_BFIN_GOTOFFLO +-ADI Blackfin FD-PIC relocations. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_GOT +-ADI Blackfin GOT relocation. +-@end deffn +-@deffn {} BFD_RELOC_BFIN_PLTPC +-ADI Blackfin PLTPC relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_PUSH +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_CONST +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_ADD +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_SUB +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_MULT +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_DIV +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_MOD +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_LSHIFT +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_RSHIFT +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_AND +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_OR +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_XOR +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_LAND +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_LOR +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_LEN +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_NEG +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_COMP +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_PAGE +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_HWPAGE +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_ARELOC_BFIN_ADDR +-ADI Blackfin arithmetic relocation. +-@end deffn +-@deffn {} BFD_RELOC_D10V_10_PCREL_R +-Mitsubishi D10V relocs. +-This is a 10-bit reloc with the right 2 bits +-assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_D10V_10_PCREL_L +-Mitsubishi D10V relocs. +-This is a 10-bit reloc with the right 2 bits +-assumed to be 0. This is the same as the previous reloc +-except it is in the left container, i.e., +-shifted left 15 bits. +-@end deffn +-@deffn {} BFD_RELOC_D10V_18 +-This is an 18-bit reloc with the right 2 bits +-assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_D10V_18_PCREL +-This is an 18-bit reloc with the right 2 bits +-assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_D30V_6 +-Mitsubishi D30V relocs. +-This is a 6-bit absolute reloc. +-@end deffn +-@deffn {} BFD_RELOC_D30V_9_PCREL +-This is a 6-bit pc-relative reloc with +-the right 3 bits assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_D30V_9_PCREL_R +-This is a 6-bit pc-relative reloc with +-the right 3 bits assumed to be 0. Same +-as the previous reloc but on the right side +-of the container. +-@end deffn +-@deffn {} BFD_RELOC_D30V_15 +-This is a 12-bit absolute reloc with the +-right 3 bitsassumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_D30V_15_PCREL +-This is a 12-bit pc-relative reloc with +-the right 3 bits assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_D30V_15_PCREL_R +-This is a 12-bit pc-relative reloc with +-the right 3 bits assumed to be 0. Same +-as the previous reloc but on the right side +-of the container. +-@end deffn +-@deffn {} BFD_RELOC_D30V_21 +-This is an 18-bit absolute reloc with +-the right 3 bits assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_D30V_21_PCREL +-This is an 18-bit pc-relative reloc with +-the right 3 bits assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_D30V_21_PCREL_R +-This is an 18-bit pc-relative reloc with +-the right 3 bits assumed to be 0. Same +-as the previous reloc but on the right side +-of the container. +-@end deffn +-@deffn {} BFD_RELOC_D30V_32 +-This is a 32-bit absolute reloc. +-@end deffn +-@deffn {} BFD_RELOC_D30V_32_PCREL +-This is a 32-bit pc-relative reloc. +-@end deffn +-@deffn {} BFD_RELOC_DLX_HI16_S +-DLX relocs +-@end deffn +-@deffn {} BFD_RELOC_DLX_LO16 +-DLX relocs +-@end deffn +-@deffn {} BFD_RELOC_DLX_JMP26 +-DLX relocs +-@end deffn +-@deffn {} BFD_RELOC_M32C_HI8 +-@deffnx {} BFD_RELOC_M32C_RL_JUMP +-@deffnx {} BFD_RELOC_M32C_RL_1ADDR +-@deffnx {} BFD_RELOC_M32C_RL_2ADDR +-Renesas M16C/M32C Relocations. +-@end deffn +-@deffn {} BFD_RELOC_M32R_24 +-Renesas M32R (formerly Mitsubishi M32R) relocs. +-This is a 24 bit absolute address. +-@end deffn +-@deffn {} BFD_RELOC_M32R_10_PCREL +-This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_M32R_18_PCREL +-This is an 18-bit reloc with the right 2 bits assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_M32R_26_PCREL +-This is a 26-bit reloc with the right 2 bits assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_M32R_HI16_ULO +-This is a 16-bit reloc containing the high 16 bits of an address +-used when the lower 16 bits are treated as unsigned. +-@end deffn +-@deffn {} BFD_RELOC_M32R_HI16_SLO +-This is a 16-bit reloc containing the high 16 bits of an address +-used when the lower 16 bits are treated as signed. +-@end deffn +-@deffn {} BFD_RELOC_M32R_LO16 +-This is a 16-bit reloc containing the lower 16 bits of an address. +-@end deffn +-@deffn {} BFD_RELOC_M32R_SDA16 +-This is a 16-bit reloc containing the small data area offset for use in +-add3, load, and store instructions. +-@end deffn +-@deffn {} BFD_RELOC_M32R_GOT24 +-@deffnx {} BFD_RELOC_M32R_26_PLTREL +-@deffnx {} BFD_RELOC_M32R_COPY +-@deffnx {} BFD_RELOC_M32R_GLOB_DAT +-@deffnx {} BFD_RELOC_M32R_JMP_SLOT +-@deffnx {} BFD_RELOC_M32R_RELATIVE +-@deffnx {} BFD_RELOC_M32R_GOTOFF +-@deffnx {} BFD_RELOC_M32R_GOTOFF_HI_ULO +-@deffnx {} BFD_RELOC_M32R_GOTOFF_HI_SLO +-@deffnx {} BFD_RELOC_M32R_GOTOFF_LO +-@deffnx {} BFD_RELOC_M32R_GOTPC24 +-@deffnx {} BFD_RELOC_M32R_GOT16_HI_ULO +-@deffnx {} BFD_RELOC_M32R_GOT16_HI_SLO +-@deffnx {} BFD_RELOC_M32R_GOT16_LO +-@deffnx {} BFD_RELOC_M32R_GOTPC_HI_ULO +-@deffnx {} BFD_RELOC_M32R_GOTPC_HI_SLO +-@deffnx {} BFD_RELOC_M32R_GOTPC_LO +-For PIC. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_20 +-NDS32 relocs. +-This is a 20 bit absolute address. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_9_PCREL +-This is a 9-bit pc-relative reloc with the right 1 bit assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_WORD_9_PCREL +-This is a 9-bit pc-relative reloc with the right 1 bit assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_15_PCREL +-This is an 15-bit reloc with the right 1 bit assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_17_PCREL +-This is an 17-bit reloc with the right 1 bit assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_25_PCREL +-This is a 25-bit reloc with the right 1 bit assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_HI20 +-This is a 20-bit reloc containing the high 20 bits of an address +-used with the lower 12 bits +-@end deffn +-@deffn {} BFD_RELOC_NDS32_LO12S3 +-This is a 12-bit reloc containing the lower 12 bits of an address +-then shift right by 3. This is used with ldi,sdi... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_LO12S2 +-This is a 12-bit reloc containing the lower 12 bits of an address +-then shift left by 2. This is used with lwi,swi... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_LO12S1 +-This is a 12-bit reloc containing the lower 12 bits of an address +-then shift left by 1. This is used with lhi,shi... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_LO12S0 +-This is a 12-bit reloc containing the lower 12 bits of an address +-then shift left by 0. This is used with lbisbi... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_LO12S0_ORI +-This is a 12-bit reloc containing the lower 12 bits of an address +-then shift left by 0. This is only used with branch relaxations +-@end deffn +-@deffn {} BFD_RELOC_NDS32_SDA15S3 +-This is a 15-bit reloc containing the small data area 18-bit signed offset +-and shift left by 3 for use in ldi, sdi... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_SDA15S2 +-This is a 15-bit reloc containing the small data area 17-bit signed offset +-and shift left by 2 for use in lwi, swi... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_SDA15S1 +-This is a 15-bit reloc containing the small data area 16-bit signed offset +-and shift left by 1 for use in lhi, shi... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_SDA15S0 +-This is a 15-bit reloc containing the small data area 15-bit signed offset +-and shift left by 0 for use in lbi, sbi... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_SDA16S3 +-This is a 16-bit reloc containing the small data area 16-bit signed offset +-and shift left by 3 +-@end deffn +-@deffn {} BFD_RELOC_NDS32_SDA17S2 +-This is a 17-bit reloc containing the small data area 17-bit signed offset +-and shift left by 2 for use in lwi.gp, swi.gp... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_SDA18S1 +-This is a 18-bit reloc containing the small data area 18-bit signed offset +-and shift left by 1 for use in lhi.gp, shi.gp... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_SDA19S0 +-This is a 19-bit reloc containing the small data area 19-bit signed offset +-and shift left by 0 for use in lbi.gp, sbi.gp... +-@end deffn +-@deffn {} BFD_RELOC_NDS32_GOT20 +-@deffnx {} BFD_RELOC_NDS32_9_PLTREL +-@deffnx {} BFD_RELOC_NDS32_25_PLTREL +-@deffnx {} BFD_RELOC_NDS32_COPY +-@deffnx {} BFD_RELOC_NDS32_GLOB_DAT +-@deffnx {} BFD_RELOC_NDS32_JMP_SLOT +-@deffnx {} BFD_RELOC_NDS32_RELATIVE +-@deffnx {} BFD_RELOC_NDS32_GOTOFF +-@deffnx {} BFD_RELOC_NDS32_GOTOFF_HI20 +-@deffnx {} BFD_RELOC_NDS32_GOTOFF_LO12 +-@deffnx {} BFD_RELOC_NDS32_GOTPC20 +-@deffnx {} BFD_RELOC_NDS32_GOT_HI20 +-@deffnx {} BFD_RELOC_NDS32_GOT_LO12 +-@deffnx {} BFD_RELOC_NDS32_GOTPC_HI20 +-@deffnx {} BFD_RELOC_NDS32_GOTPC_LO12 +-for PIC +-@end deffn +-@deffn {} BFD_RELOC_NDS32_INSN16 +-@deffnx {} BFD_RELOC_NDS32_LABEL +-@deffnx {} BFD_RELOC_NDS32_LONGCALL1 +-@deffnx {} BFD_RELOC_NDS32_LONGCALL2 +-@deffnx {} BFD_RELOC_NDS32_LONGCALL3 +-@deffnx {} BFD_RELOC_NDS32_LONGJUMP1 +-@deffnx {} BFD_RELOC_NDS32_LONGJUMP2 +-@deffnx {} BFD_RELOC_NDS32_LONGJUMP3 +-@deffnx {} BFD_RELOC_NDS32_LOADSTORE +-@deffnx {} BFD_RELOC_NDS32_9_FIXED +-@deffnx {} BFD_RELOC_NDS32_15_FIXED +-@deffnx {} BFD_RELOC_NDS32_17_FIXED +-@deffnx {} BFD_RELOC_NDS32_25_FIXED +-@deffnx {} BFD_RELOC_NDS32_LONGCALL4 +-@deffnx {} BFD_RELOC_NDS32_LONGCALL5 +-@deffnx {} BFD_RELOC_NDS32_LONGCALL6 +-@deffnx {} BFD_RELOC_NDS32_LONGJUMP4 +-@deffnx {} BFD_RELOC_NDS32_LONGJUMP5 +-@deffnx {} BFD_RELOC_NDS32_LONGJUMP6 +-@deffnx {} BFD_RELOC_NDS32_LONGJUMP7 +-for relax +-@end deffn +-@deffn {} BFD_RELOC_NDS32_PLTREL_HI20 +-@deffnx {} BFD_RELOC_NDS32_PLTREL_LO12 +-@deffnx {} BFD_RELOC_NDS32_PLT_GOTREL_HI20 +-@deffnx {} BFD_RELOC_NDS32_PLT_GOTREL_LO12 +-for PIC +-@end deffn +-@deffn {} BFD_RELOC_NDS32_SDA12S2_DP +-@deffnx {} BFD_RELOC_NDS32_SDA12S2_SP +-@deffnx {} BFD_RELOC_NDS32_LO12S2_DP +-@deffnx {} BFD_RELOC_NDS32_LO12S2_SP +-for floating point +-@end deffn +-@deffn {} BFD_RELOC_NDS32_DWARF2_OP1 +-@deffnx {} BFD_RELOC_NDS32_DWARF2_OP2 +-@deffnx {} BFD_RELOC_NDS32_DWARF2_LEB +-for dwarf2 debug_line. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_UPDATE_TA +-for eliminate 16-bit instructions +-@end deffn +-@deffn {} BFD_RELOC_NDS32_PLT_GOTREL_LO20 +-@deffnx {} BFD_RELOC_NDS32_PLT_GOTREL_LO15 +-@deffnx {} BFD_RELOC_NDS32_PLT_GOTREL_LO19 +-@deffnx {} BFD_RELOC_NDS32_GOT_LO15 +-@deffnx {} BFD_RELOC_NDS32_GOT_LO19 +-@deffnx {} BFD_RELOC_NDS32_GOTOFF_LO15 +-@deffnx {} BFD_RELOC_NDS32_GOTOFF_LO19 +-@deffnx {} BFD_RELOC_NDS32_GOT15S2 +-@deffnx {} BFD_RELOC_NDS32_GOT17S2 +-for PIC object relaxation +-@end deffn +-@deffn {} BFD_RELOC_NDS32_5 +-NDS32 relocs. +-This is a 5 bit absolute address. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_10_UPCREL +-This is a 10-bit unsigned pc-relative reloc with the right 1 bit assumed to be 0. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_SDA_FP7U2_RELA +-If fp were omitted, fp can used as another gp. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_RELAX_ENTRY +-@deffnx {} BFD_RELOC_NDS32_GOT_SUFF +-@deffnx {} BFD_RELOC_NDS32_GOTOFF_SUFF +-@deffnx {} BFD_RELOC_NDS32_PLT_GOT_SUFF +-@deffnx {} BFD_RELOC_NDS32_MULCALL_SUFF +-@deffnx {} BFD_RELOC_NDS32_PTR +-@deffnx {} BFD_RELOC_NDS32_PTR_COUNT +-@deffnx {} BFD_RELOC_NDS32_PTR_RESOLVED +-@deffnx {} BFD_RELOC_NDS32_PLTBLOCK +-@deffnx {} BFD_RELOC_NDS32_RELAX_REGION_BEGIN +-@deffnx {} BFD_RELOC_NDS32_RELAX_REGION_END +-@deffnx {} BFD_RELOC_NDS32_MINUEND +-@deffnx {} BFD_RELOC_NDS32_SUBTRAHEND +-@deffnx {} BFD_RELOC_NDS32_DIFF8 +-@deffnx {} BFD_RELOC_NDS32_DIFF16 +-@deffnx {} BFD_RELOC_NDS32_DIFF32 +-@deffnx {} BFD_RELOC_NDS32_DIFF_ULEB128 +-@deffnx {} BFD_RELOC_NDS32_EMPTY +-relaxation relative relocation types +-@end deffn +-@deffn {} BFD_RELOC_NDS32_25_ABS +-This is a 25 bit absolute address. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_DATA +-@deffnx {} BFD_RELOC_NDS32_TRAN +-@deffnx {} BFD_RELOC_NDS32_17IFC_PCREL +-@deffnx {} BFD_RELOC_NDS32_10IFCU_PCREL +-For ex9 and ifc using. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_TPOFF +-@deffnx {} BFD_RELOC_NDS32_GOTTPOFF +-@deffnx {} BFD_RELOC_NDS32_TLS_LE_HI20 +-@deffnx {} BFD_RELOC_NDS32_TLS_LE_LO12 +-@deffnx {} BFD_RELOC_NDS32_TLS_LE_20 +-@deffnx {} BFD_RELOC_NDS32_TLS_LE_15S0 +-@deffnx {} BFD_RELOC_NDS32_TLS_LE_15S1 +-@deffnx {} BFD_RELOC_NDS32_TLS_LE_15S2 +-@deffnx {} BFD_RELOC_NDS32_TLS_LE_ADD +-@deffnx {} BFD_RELOC_NDS32_TLS_LE_LS +-@deffnx {} BFD_RELOC_NDS32_TLS_IE_HI20 +-@deffnx {} BFD_RELOC_NDS32_TLS_IE_LO12 +-@deffnx {} BFD_RELOC_NDS32_TLS_IE_LO12S2 +-@deffnx {} BFD_RELOC_NDS32_TLS_IEGP_HI20 +-@deffnx {} BFD_RELOC_NDS32_TLS_IEGP_LO12 +-@deffnx {} BFD_RELOC_NDS32_TLS_IEGP_LO12S2 +-@deffnx {} BFD_RELOC_NDS32_TLS_IEGP_LW +-@deffnx {} BFD_RELOC_NDS32_TLS_DESC +-@deffnx {} BFD_RELOC_NDS32_TLS_DESC_HI20 +-@deffnx {} BFD_RELOC_NDS32_TLS_DESC_LO12 +-@deffnx {} BFD_RELOC_NDS32_TLS_DESC_20 +-@deffnx {} BFD_RELOC_NDS32_TLS_DESC_SDA17S2 +-@deffnx {} BFD_RELOC_NDS32_TLS_DESC_ADD +-@deffnx {} BFD_RELOC_NDS32_TLS_DESC_FUNC +-@deffnx {} BFD_RELOC_NDS32_TLS_DESC_CALL +-@deffnx {} BFD_RELOC_NDS32_TLS_DESC_MEM +-@deffnx {} BFD_RELOC_NDS32_REMOVE +-@deffnx {} BFD_RELOC_NDS32_GROUP +-For TLS. +-@end deffn +-@deffn {} BFD_RELOC_NDS32_LSI +-For floating load store relaxation. +-@end deffn +-@deffn {} BFD_RELOC_V850_9_PCREL +-This is a 9-bit reloc +-@end deffn +-@deffn {} BFD_RELOC_V850_22_PCREL +-This is a 22-bit reloc +-@end deffn +-@deffn {} BFD_RELOC_V850_SDA_16_16_OFFSET +-This is a 16 bit offset from the short data area pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_SDA_15_16_OFFSET +-This is a 16 bit offset (of which only 15 bits are used) from the +-short data area pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_ZDA_16_16_OFFSET +-This is a 16 bit offset from the zero data area pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_ZDA_15_16_OFFSET +-This is a 16 bit offset (of which only 15 bits are used) from the +-zero data area pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_TDA_6_8_OFFSET +-This is an 8 bit offset (of which only 6 bits are used) from the +-tiny data area pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_TDA_7_8_OFFSET +-This is an 8bit offset (of which only 7 bits are used) from the tiny +-data area pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_TDA_7_7_OFFSET +-This is a 7 bit offset from the tiny data area pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_TDA_16_16_OFFSET +-This is a 16 bit offset from the tiny data area pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_TDA_4_5_OFFSET +-This is a 5 bit offset (of which only 4 bits are used) from the tiny +-data area pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_TDA_4_4_OFFSET +-This is a 4 bit offset from the tiny data area pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET +-This is a 16 bit offset from the short data area pointer, with the +-bits placed non-contiguously in the instruction. +-@end deffn +-@deffn {} BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET +-This is a 16 bit offset from the zero data area pointer, with the +-bits placed non-contiguously in the instruction. +-@end deffn +-@deffn {} BFD_RELOC_V850_CALLT_6_7_OFFSET +-This is a 6 bit offset from the call table base pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_CALLT_16_16_OFFSET +-This is a 16 bit offset from the call table base pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_LONGCALL +-Used for relaxing indirect function calls. +-@end deffn +-@deffn {} BFD_RELOC_V850_LONGJUMP +-Used for relaxing indirect jumps. +-@end deffn +-@deffn {} BFD_RELOC_V850_ALIGN +-Used to maintain alignment whilst relaxing. +-@end deffn +-@deffn {} BFD_RELOC_V850_LO16_SPLIT_OFFSET +-This is a variation of BFD_RELOC_LO16 that can be used in v850e ld.bu +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_V850_16_PCREL +-This is a 16-bit reloc. +-@end deffn +-@deffn {} BFD_RELOC_V850_17_PCREL +-This is a 17-bit reloc. +-@end deffn +-@deffn {} BFD_RELOC_V850_23 +-This is a 23-bit reloc. +-@end deffn +-@deffn {} BFD_RELOC_V850_32_PCREL +-This is a 32-bit reloc. +-@end deffn +-@deffn {} BFD_RELOC_V850_32_ABS +-This is a 32-bit reloc. +-@end deffn +-@deffn {} BFD_RELOC_V850_16_SPLIT_OFFSET +-This is a 16-bit reloc. +-@end deffn +-@deffn {} BFD_RELOC_V850_16_S1 +-This is a 16-bit reloc. +-@end deffn +-@deffn {} BFD_RELOC_V850_LO16_S1 +-Low 16 bits. 16 bit shifted by 1. +-@end deffn +-@deffn {} BFD_RELOC_V850_CALLT_15_16_OFFSET +-This is a 16 bit offset from the call table base pointer. +-@end deffn +-@deffn {} BFD_RELOC_V850_32_GOTPCREL +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_16_GOT +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_32_GOT +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_22_PLT_PCREL +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_32_PLT_PCREL +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_COPY +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_GLOB_DAT +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_JMP_SLOT +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_RELATIVE +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_16_GOTOFF +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_32_GOTOFF +-DSO relocations. +-@end deffn +-@deffn {} BFD_RELOC_V850_CODE +-start code. +-@end deffn +-@deffn {} BFD_RELOC_V850_DATA +-start data in text. +-@end deffn +-@deffn {} BFD_RELOC_TIC30_LDP +-This is a 8bit DP reloc for the tms320c30, where the most +-significant 8 bits of a 24 bit word are placed into the least +-significant 8 bits of the opcode. +-@end deffn +-@deffn {} BFD_RELOC_TIC54X_PARTLS7 +-This is a 7bit reloc for the tms320c54x, where the least +-significant 7 bits of a 16 bit word are placed into the least +-significant 7 bits of the opcode. +-@end deffn +-@deffn {} BFD_RELOC_TIC54X_PARTMS9 +-This is a 9bit DP reloc for the tms320c54x, where the most +-significant 9 bits of a 16 bit word are placed into the least +-significant 9 bits of the opcode. +-@end deffn +-@deffn {} BFD_RELOC_TIC54X_23 +-This is an extended address 23-bit reloc for the tms320c54x. +-@end deffn +-@deffn {} BFD_RELOC_TIC54X_16_OF_23 +-This is a 16-bit reloc for the tms320c54x, where the least +-significant 16 bits of a 23-bit extended address are placed into +-the opcode. +-@end deffn +-@deffn {} BFD_RELOC_TIC54X_MS7_OF_23 +-This is a reloc for the tms320c54x, where the most +-significant 7 bits of a 23-bit extended address are placed into +-the opcode. +-@end deffn +-@deffn {} BFD_RELOC_C6000_PCR_S21 +-@deffnx {} BFD_RELOC_C6000_PCR_S12 +-@deffnx {} BFD_RELOC_C6000_PCR_S10 +-@deffnx {} BFD_RELOC_C6000_PCR_S7 +-@deffnx {} BFD_RELOC_C6000_ABS_S16 +-@deffnx {} BFD_RELOC_C6000_ABS_L16 +-@deffnx {} BFD_RELOC_C6000_ABS_H16 +-@deffnx {} BFD_RELOC_C6000_SBR_U15_B +-@deffnx {} BFD_RELOC_C6000_SBR_U15_H +-@deffnx {} BFD_RELOC_C6000_SBR_U15_W +-@deffnx {} BFD_RELOC_C6000_SBR_S16 +-@deffnx {} BFD_RELOC_C6000_SBR_L16_B +-@deffnx {} BFD_RELOC_C6000_SBR_L16_H +-@deffnx {} BFD_RELOC_C6000_SBR_L16_W +-@deffnx {} BFD_RELOC_C6000_SBR_H16_B +-@deffnx {} BFD_RELOC_C6000_SBR_H16_H +-@deffnx {} BFD_RELOC_C6000_SBR_H16_W +-@deffnx {} BFD_RELOC_C6000_SBR_GOT_U15_W +-@deffnx {} BFD_RELOC_C6000_SBR_GOT_L16_W +-@deffnx {} BFD_RELOC_C6000_SBR_GOT_H16_W +-@deffnx {} BFD_RELOC_C6000_DSBT_INDEX +-@deffnx {} BFD_RELOC_C6000_PREL31 +-@deffnx {} BFD_RELOC_C6000_COPY +-@deffnx {} BFD_RELOC_C6000_JUMP_SLOT +-@deffnx {} BFD_RELOC_C6000_EHTYPE +-@deffnx {} BFD_RELOC_C6000_PCR_H16 +-@deffnx {} BFD_RELOC_C6000_PCR_L16 +-@deffnx {} BFD_RELOC_C6000_ALIGN +-@deffnx {} BFD_RELOC_C6000_FPHEAD +-@deffnx {} BFD_RELOC_C6000_NOCMP +-TMS320C6000 relocations. +-@end deffn +-@deffn {} BFD_RELOC_FR30_48 +-This is a 48 bit reloc for the FR30 that stores 32 bits. +-@end deffn +-@deffn {} BFD_RELOC_FR30_20 +-This is a 32 bit reloc for the FR30 that stores 20 bits split up into +-two sections. +-@end deffn +-@deffn {} BFD_RELOC_FR30_6_IN_4 +-This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in +-4 bits. +-@end deffn +-@deffn {} BFD_RELOC_FR30_8_IN_8 +-This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset +-into 8 bits. +-@end deffn +-@deffn {} BFD_RELOC_FR30_9_IN_8 +-This is a 16 bit reloc for the FR30 that stores a 9 bit short offset +-into 8 bits. +-@end deffn +-@deffn {} BFD_RELOC_FR30_10_IN_8 +-This is a 16 bit reloc for the FR30 that stores a 10 bit word offset +-into 8 bits. +-@end deffn +-@deffn {} BFD_RELOC_FR30_9_PCREL +-This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative +-short offset into 8 bits. +-@end deffn +-@deffn {} BFD_RELOC_FR30_12_PCREL +-This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative +-short offset into 11 bits. +-@end deffn +-@deffn {} BFD_RELOC_MCORE_PCREL_IMM8BY4 +-@deffnx {} BFD_RELOC_MCORE_PCREL_IMM11BY2 +-@deffnx {} BFD_RELOC_MCORE_PCREL_IMM4BY2 +-@deffnx {} BFD_RELOC_MCORE_PCREL_32 +-@deffnx {} BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2 +-@deffnx {} BFD_RELOC_MCORE_RVA +-Motorola Mcore relocations. +-@end deffn +-@deffn {} BFD_RELOC_MEP_8 +-@deffnx {} BFD_RELOC_MEP_16 +-@deffnx {} BFD_RELOC_MEP_32 +-@deffnx {} BFD_RELOC_MEP_PCREL8A2 +-@deffnx {} BFD_RELOC_MEP_PCREL12A2 +-@deffnx {} BFD_RELOC_MEP_PCREL17A2 +-@deffnx {} BFD_RELOC_MEP_PCREL24A2 +-@deffnx {} BFD_RELOC_MEP_PCABS24A2 +-@deffnx {} BFD_RELOC_MEP_LOW16 +-@deffnx {} BFD_RELOC_MEP_HI16U +-@deffnx {} BFD_RELOC_MEP_HI16S +-@deffnx {} BFD_RELOC_MEP_GPREL +-@deffnx {} BFD_RELOC_MEP_TPREL +-@deffnx {} BFD_RELOC_MEP_TPREL7 +-@deffnx {} BFD_RELOC_MEP_TPREL7A2 +-@deffnx {} BFD_RELOC_MEP_TPREL7A4 +-@deffnx {} BFD_RELOC_MEP_UIMM24 +-@deffnx {} BFD_RELOC_MEP_ADDR24A4 +-@deffnx {} BFD_RELOC_MEP_GNU_VTINHERIT +-@deffnx {} BFD_RELOC_MEP_GNU_VTENTRY +-Toshiba Media Processor Relocations. +-@end deffn +-@deffn {} BFD_RELOC_METAG_HIADDR16 +-@deffnx {} BFD_RELOC_METAG_LOADDR16 +-@deffnx {} BFD_RELOC_METAG_RELBRANCH +-@deffnx {} BFD_RELOC_METAG_GETSETOFF +-@deffnx {} BFD_RELOC_METAG_HIOG +-@deffnx {} BFD_RELOC_METAG_LOOG +-@deffnx {} BFD_RELOC_METAG_REL8 +-@deffnx {} BFD_RELOC_METAG_REL16 +-@deffnx {} BFD_RELOC_METAG_HI16_GOTOFF +-@deffnx {} BFD_RELOC_METAG_LO16_GOTOFF +-@deffnx {} BFD_RELOC_METAG_GETSET_GOTOFF +-@deffnx {} BFD_RELOC_METAG_GETSET_GOT +-@deffnx {} BFD_RELOC_METAG_HI16_GOTPC +-@deffnx {} BFD_RELOC_METAG_LO16_GOTPC +-@deffnx {} BFD_RELOC_METAG_HI16_PLT +-@deffnx {} BFD_RELOC_METAG_LO16_PLT +-@deffnx {} BFD_RELOC_METAG_RELBRANCH_PLT +-@deffnx {} BFD_RELOC_METAG_GOTOFF +-@deffnx {} BFD_RELOC_METAG_PLT +-@deffnx {} BFD_RELOC_METAG_COPY +-@deffnx {} BFD_RELOC_METAG_JMP_SLOT +-@deffnx {} BFD_RELOC_METAG_RELATIVE +-@deffnx {} BFD_RELOC_METAG_GLOB_DAT +-@deffnx {} BFD_RELOC_METAG_TLS_GD +-@deffnx {} BFD_RELOC_METAG_TLS_LDM +-@deffnx {} BFD_RELOC_METAG_TLS_LDO_HI16 +-@deffnx {} BFD_RELOC_METAG_TLS_LDO_LO16 +-@deffnx {} BFD_RELOC_METAG_TLS_LDO +-@deffnx {} BFD_RELOC_METAG_TLS_IE +-@deffnx {} BFD_RELOC_METAG_TLS_IENONPIC +-@deffnx {} BFD_RELOC_METAG_TLS_IENONPIC_HI16 +-@deffnx {} BFD_RELOC_METAG_TLS_IENONPIC_LO16 +-@deffnx {} BFD_RELOC_METAG_TLS_TPOFF +-@deffnx {} BFD_RELOC_METAG_TLS_DTPMOD +-@deffnx {} BFD_RELOC_METAG_TLS_DTPOFF +-@deffnx {} BFD_RELOC_METAG_TLS_LE +-@deffnx {} BFD_RELOC_METAG_TLS_LE_HI16 +-@deffnx {} BFD_RELOC_METAG_TLS_LE_LO16 +-Imagination Technologies Meta relocations. +-@end deffn +-@deffn {} BFD_RELOC_MMIX_GETA +-@deffnx {} BFD_RELOC_MMIX_GETA_1 +-@deffnx {} BFD_RELOC_MMIX_GETA_2 +-@deffnx {} BFD_RELOC_MMIX_GETA_3 +-These are relocations for the GETA instruction. +-@end deffn +-@deffn {} BFD_RELOC_MMIX_CBRANCH +-@deffnx {} BFD_RELOC_MMIX_CBRANCH_J +-@deffnx {} BFD_RELOC_MMIX_CBRANCH_1 +-@deffnx {} BFD_RELOC_MMIX_CBRANCH_2 +-@deffnx {} BFD_RELOC_MMIX_CBRANCH_3 +-These are relocations for a conditional branch instruction. +-@end deffn +-@deffn {} BFD_RELOC_MMIX_PUSHJ +-@deffnx {} BFD_RELOC_MMIX_PUSHJ_1 +-@deffnx {} BFD_RELOC_MMIX_PUSHJ_2 +-@deffnx {} BFD_RELOC_MMIX_PUSHJ_3 +-@deffnx {} BFD_RELOC_MMIX_PUSHJ_STUBBABLE +-These are relocations for the PUSHJ instruction. +-@end deffn +-@deffn {} BFD_RELOC_MMIX_JMP +-@deffnx {} BFD_RELOC_MMIX_JMP_1 +-@deffnx {} BFD_RELOC_MMIX_JMP_2 +-@deffnx {} BFD_RELOC_MMIX_JMP_3 +-These are relocations for the JMP instruction. +-@end deffn +-@deffn {} BFD_RELOC_MMIX_ADDR19 +-This is a relocation for a relative address as in a GETA instruction or +-a branch. +-@end deffn +-@deffn {} BFD_RELOC_MMIX_ADDR27 +-This is a relocation for a relative address as in a JMP instruction. +-@end deffn +-@deffn {} BFD_RELOC_MMIX_REG_OR_BYTE +-This is a relocation for an instruction field that may be a general +-register or a value 0..255. +-@end deffn +-@deffn {} BFD_RELOC_MMIX_REG +-This is a relocation for an instruction field that may be a general +-register. +-@end deffn +-@deffn {} BFD_RELOC_MMIX_BASE_PLUS_OFFSET +-This is a relocation for two instruction fields holding a register and +-an offset, the equivalent of the relocation. +-@end deffn +-@deffn {} BFD_RELOC_MMIX_LOCAL +-This relocation is an assertion that the expression is not allocated as +-a global register. It does not modify contents. +-@end deffn +-@deffn {} BFD_RELOC_AVR_7_PCREL +-This is a 16 bit reloc for the AVR that stores 8 bit pc relative +-short offset into 7 bits. +-@end deffn +-@deffn {} BFD_RELOC_AVR_13_PCREL +-This is a 16 bit reloc for the AVR that stores 13 bit pc relative +-short offset into 12 bits. +-@end deffn +-@deffn {} BFD_RELOC_AVR_16_PM +-This is a 16 bit reloc for the AVR that stores 17 bit value (usually +-program memory address) into 16 bits. +-@end deffn +-@deffn {} BFD_RELOC_AVR_LO8_LDI +-This is a 16 bit reloc for the AVR that stores 8 bit value (usually +-data memory address) into 8 bit immediate value of LDI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_HI8_LDI +-This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit +-of data memory address) into 8 bit immediate value of LDI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_HH8_LDI +-This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit +-of program memory address) into 8 bit immediate value of LDI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_MS8_LDI +-This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit +-of 32 bit value) into 8 bit immediate value of LDI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_LO8_LDI_NEG +-This is a 16 bit reloc for the AVR that stores negated 8 bit value +-(usually data memory address) into 8 bit immediate value of SUBI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_HI8_LDI_NEG +-This is a 16 bit reloc for the AVR that stores negated 8 bit value +-(high 8 bit of data memory address) into 8 bit immediate value of +-SUBI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_HH8_LDI_NEG +-This is a 16 bit reloc for the AVR that stores negated 8 bit value +-(most high 8 bit of program memory address) into 8 bit immediate value +-of LDI or SUBI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_MS8_LDI_NEG +-This is a 16 bit reloc for the AVR that stores negated 8 bit value (msb +-of 32 bit value) into 8 bit immediate value of LDI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_LO8_LDI_PM +-This is a 16 bit reloc for the AVR that stores 8 bit value (usually +-command address) into 8 bit immediate value of LDI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_LO8_LDI_GS +-This is a 16 bit reloc for the AVR that stores 8 bit value +-(command address) into 8 bit immediate value of LDI insn. If the address +-is beyond the 128k boundary, the linker inserts a jump stub for this reloc +-in the lower 128k. +-@end deffn +-@deffn {} BFD_RELOC_AVR_HI8_LDI_PM +-This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit +-of command address) into 8 bit immediate value of LDI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_HI8_LDI_GS +-This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit +-of command address) into 8 bit immediate value of LDI insn. If the address +-is beyond the 128k boundary, the linker inserts a jump stub for this reloc +-below 128k. +-@end deffn +-@deffn {} BFD_RELOC_AVR_HH8_LDI_PM +-This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit +-of command address) into 8 bit immediate value of LDI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_LO8_LDI_PM_NEG +-This is a 16 bit reloc for the AVR that stores negated 8 bit value +-(usually command address) into 8 bit immediate value of SUBI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_HI8_LDI_PM_NEG +-This is a 16 bit reloc for the AVR that stores negated 8 bit value +-(high 8 bit of 16 bit command address) into 8 bit immediate value +-of SUBI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_HH8_LDI_PM_NEG +-This is a 16 bit reloc for the AVR that stores negated 8 bit value +-(high 6 bit of 22 bit command address) into 8 bit immediate +-value of SUBI insn. +-@end deffn +-@deffn {} BFD_RELOC_AVR_CALL +-This is a 32 bit reloc for the AVR that stores 23 bit value +-into 22 bits. +-@end deffn +-@deffn {} BFD_RELOC_AVR_LDI +-This is a 16 bit reloc for the AVR that stores all needed bits +-for absolute addressing with ldi with overflow check to linktime +-@end deffn +-@deffn {} BFD_RELOC_AVR_6 +-This is a 6 bit reloc for the AVR that stores offset for ldd/std +-instructions +-@end deffn +-@deffn {} BFD_RELOC_AVR_6_ADIW +-This is a 6 bit reloc for the AVR that stores offset for adiw/sbiw +-instructions +-@end deffn +-@deffn {} BFD_RELOC_AVR_8_LO +-This is a 8 bit reloc for the AVR that stores bits 0..7 of a symbol +-in .byte lo8(symbol) +-@end deffn +-@deffn {} BFD_RELOC_AVR_8_HI +-This is a 8 bit reloc for the AVR that stores bits 8..15 of a symbol +-in .byte hi8(symbol) +-@end deffn +-@deffn {} BFD_RELOC_AVR_8_HLO +-This is a 8 bit reloc for the AVR that stores bits 16..23 of a symbol +-in .byte hlo8(symbol) +-@end deffn +-@deffn {} BFD_RELOC_AVR_DIFF8 +-@deffnx {} BFD_RELOC_AVR_DIFF16 +-@deffnx {} BFD_RELOC_AVR_DIFF32 +-AVR relocations to mark the difference of two local symbols. +-These are only needed to support linker relaxation and can be ignored +-when not relaxing. The field is set to the value of the difference +-assuming no relaxation. The relocation encodes the position of the +-second symbol so the linker can determine whether to adjust the field +-value. +-@end deffn +-@deffn {} BFD_RELOC_AVR_LDS_STS_16 +-This is a 7 bit reloc for the AVR that stores SRAM address for 16bit +-lds and sts instructions supported only tiny core. +-@end deffn +-@deffn {} BFD_RELOC_AVR_PORT6 +-This is a 6 bit reloc for the AVR that stores an I/O register +-number for the IN and OUT instructions +-@end deffn +-@deffn {} BFD_RELOC_AVR_PORT5 +-This is a 5 bit reloc for the AVR that stores an I/O register +-number for the SBIC, SBIS, SBI and CBI instructions +-@end deffn +-@deffn {} BFD_RELOC_RISCV_HI20 +-@deffnx {} BFD_RELOC_RISCV_PCREL_HI20 +-@deffnx {} BFD_RELOC_RISCV_PCREL_LO12_I +-@deffnx {} BFD_RELOC_RISCV_PCREL_LO12_S +-@deffnx {} BFD_RELOC_RISCV_LO12_I +-@deffnx {} BFD_RELOC_RISCV_LO12_S +-@deffnx {} BFD_RELOC_RISCV_GPREL12_I +-@deffnx {} BFD_RELOC_RISCV_GPREL12_S +-@deffnx {} BFD_RELOC_RISCV_TPREL_HI20 +-@deffnx {} BFD_RELOC_RISCV_TPREL_LO12_I +-@deffnx {} BFD_RELOC_RISCV_TPREL_LO12_S +-@deffnx {} BFD_RELOC_RISCV_TPREL_ADD +-@deffnx {} BFD_RELOC_RISCV_CALL +-@deffnx {} BFD_RELOC_RISCV_CALL_PLT +-@deffnx {} BFD_RELOC_RISCV_ADD8 +-@deffnx {} BFD_RELOC_RISCV_ADD16 +-@deffnx {} BFD_RELOC_RISCV_ADD32 +-@deffnx {} BFD_RELOC_RISCV_ADD64 +-@deffnx {} BFD_RELOC_RISCV_SUB8 +-@deffnx {} BFD_RELOC_RISCV_SUB16 +-@deffnx {} BFD_RELOC_RISCV_SUB32 +-@deffnx {} BFD_RELOC_RISCV_SUB64 +-@deffnx {} BFD_RELOC_RISCV_GOT_HI20 +-@deffnx {} BFD_RELOC_RISCV_TLS_GOT_HI20 +-@deffnx {} BFD_RELOC_RISCV_TLS_GD_HI20 +-@deffnx {} BFD_RELOC_RISCV_JMP +-@deffnx {} BFD_RELOC_RISCV_TLS_DTPMOD32 +-@deffnx {} BFD_RELOC_RISCV_TLS_DTPREL32 +-@deffnx {} BFD_RELOC_RISCV_TLS_DTPMOD64 +-@deffnx {} BFD_RELOC_RISCV_TLS_DTPREL64 +-@deffnx {} BFD_RELOC_RISCV_TLS_TPREL32 +-@deffnx {} BFD_RELOC_RISCV_TLS_TPREL64 +-@deffnx {} BFD_RELOC_RISCV_ALIGN +-@deffnx {} BFD_RELOC_RISCV_RVC_BRANCH +-@deffnx {} BFD_RELOC_RISCV_RVC_JUMP +-@deffnx {} BFD_RELOC_RISCV_RVC_LUI +-@deffnx {} BFD_RELOC_RISCV_GPREL_I +-@deffnx {} BFD_RELOC_RISCV_GPREL_S +-@deffnx {} BFD_RELOC_RISCV_TPREL_I +-@deffnx {} BFD_RELOC_RISCV_TPREL_S +-@deffnx {} BFD_RELOC_RISCV_RELAX +-@deffnx {} BFD_RELOC_RISCV_CFA +-@deffnx {} BFD_RELOC_RISCV_SUB6 +-@deffnx {} BFD_RELOC_RISCV_SET6 +-@deffnx {} BFD_RELOC_RISCV_SET8 +-@deffnx {} BFD_RELOC_RISCV_SET16 +-@deffnx {} BFD_RELOC_RISCV_SET32 +-@deffnx {} BFD_RELOC_RISCV_32_PCREL +-@deffnx {} BFD_RELOC_RISCV_SET_ULEB128 +-@deffnx {} BFD_RELOC_RISCV_SUB_ULEB128 +-RISC-V relocations. +-@end deffn +-@deffn {} BFD_RELOC_RL78_NEG8 +-@deffnx {} BFD_RELOC_RL78_NEG16 +-@deffnx {} BFD_RELOC_RL78_NEG24 +-@deffnx {} BFD_RELOC_RL78_NEG32 +-@deffnx {} BFD_RELOC_RL78_16_OP +-@deffnx {} BFD_RELOC_RL78_24_OP +-@deffnx {} BFD_RELOC_RL78_32_OP +-@deffnx {} BFD_RELOC_RL78_8U +-@deffnx {} BFD_RELOC_RL78_16U +-@deffnx {} BFD_RELOC_RL78_24U +-@deffnx {} BFD_RELOC_RL78_DIR3U_PCREL +-@deffnx {} BFD_RELOC_RL78_DIFF +-@deffnx {} BFD_RELOC_RL78_GPRELB +-@deffnx {} BFD_RELOC_RL78_GPRELW +-@deffnx {} BFD_RELOC_RL78_GPRELL +-@deffnx {} BFD_RELOC_RL78_SYM +-@deffnx {} BFD_RELOC_RL78_OP_SUBTRACT +-@deffnx {} BFD_RELOC_RL78_OP_NEG +-@deffnx {} BFD_RELOC_RL78_OP_AND +-@deffnx {} BFD_RELOC_RL78_OP_SHRA +-@deffnx {} BFD_RELOC_RL78_ABS8 +-@deffnx {} BFD_RELOC_RL78_ABS16 +-@deffnx {} BFD_RELOC_RL78_ABS16_REV +-@deffnx {} BFD_RELOC_RL78_ABS32 +-@deffnx {} BFD_RELOC_RL78_ABS32_REV +-@deffnx {} BFD_RELOC_RL78_ABS16U +-@deffnx {} BFD_RELOC_RL78_ABS16UW +-@deffnx {} BFD_RELOC_RL78_ABS16UL +-@deffnx {} BFD_RELOC_RL78_RELAX +-@deffnx {} BFD_RELOC_RL78_HI16 +-@deffnx {} BFD_RELOC_RL78_HI8 +-@deffnx {} BFD_RELOC_RL78_LO16 +-@deffnx {} BFD_RELOC_RL78_CODE +-@deffnx {} BFD_RELOC_RL78_SADDR +-Renesas RL78 Relocations. +-@end deffn +-@deffn {} BFD_RELOC_RX_NEG8 +-@deffnx {} BFD_RELOC_RX_NEG16 +-@deffnx {} BFD_RELOC_RX_NEG24 +-@deffnx {} BFD_RELOC_RX_NEG32 +-@deffnx {} BFD_RELOC_RX_16_OP +-@deffnx {} BFD_RELOC_RX_24_OP +-@deffnx {} BFD_RELOC_RX_32_OP +-@deffnx {} BFD_RELOC_RX_8U +-@deffnx {} BFD_RELOC_RX_16U +-@deffnx {} BFD_RELOC_RX_24U +-@deffnx {} BFD_RELOC_RX_DIR3U_PCREL +-@deffnx {} BFD_RELOC_RX_DIFF +-@deffnx {} BFD_RELOC_RX_GPRELB +-@deffnx {} BFD_RELOC_RX_GPRELW +-@deffnx {} BFD_RELOC_RX_GPRELL +-@deffnx {} BFD_RELOC_RX_SYM +-@deffnx {} BFD_RELOC_RX_OP_SUBTRACT +-@deffnx {} BFD_RELOC_RX_OP_NEG +-@deffnx {} BFD_RELOC_RX_ABS8 +-@deffnx {} BFD_RELOC_RX_ABS16 +-@deffnx {} BFD_RELOC_RX_ABS16_REV +-@deffnx {} BFD_RELOC_RX_ABS32 +-@deffnx {} BFD_RELOC_RX_ABS32_REV +-@deffnx {} BFD_RELOC_RX_ABS16U +-@deffnx {} BFD_RELOC_RX_ABS16UW +-@deffnx {} BFD_RELOC_RX_ABS16UL +-@deffnx {} BFD_RELOC_RX_RELAX +-Renesas RX Relocations. +-@end deffn +-@deffn {} BFD_RELOC_390_12 +-Direct 12 bit. +-@end deffn +-@deffn {} BFD_RELOC_390_GOT12 +-12 bit GOT offset. +-@end deffn +-@deffn {} BFD_RELOC_390_PLT32 +-32 bit PC relative PLT address. +-@end deffn +-@deffn {} BFD_RELOC_390_COPY +-Copy symbol at runtime. +-@end deffn +-@deffn {} BFD_RELOC_390_GLOB_DAT +-Create GOT entry. +-@end deffn +-@deffn {} BFD_RELOC_390_JMP_SLOT +-Create PLT entry. +-@end deffn +-@deffn {} BFD_RELOC_390_RELATIVE +-Adjust by program base. +-@end deffn +-@deffn {} BFD_RELOC_390_GOTPC +-32 bit PC relative offset to GOT. +-@end deffn +-@deffn {} BFD_RELOC_390_GOT16 +-16 bit GOT offset. +-@end deffn +-@deffn {} BFD_RELOC_390_PC12DBL +-PC relative 12 bit shifted by 1. +-@end deffn +-@deffn {} BFD_RELOC_390_PLT12DBL +-12 bit PC rel. PLT shifted by 1. +-@end deffn +-@deffn {} BFD_RELOC_390_PC16DBL +-PC relative 16 bit shifted by 1. +-@end deffn +-@deffn {} BFD_RELOC_390_PLT16DBL +-16 bit PC rel. PLT shifted by 1. +-@end deffn +-@deffn {} BFD_RELOC_390_PC24DBL +-PC relative 24 bit shifted by 1. +-@end deffn +-@deffn {} BFD_RELOC_390_PLT24DBL +-24 bit PC rel. PLT shifted by 1. +-@end deffn +-@deffn {} BFD_RELOC_390_PC32DBL +-PC relative 32 bit shifted by 1. +-@end deffn +-@deffn {} BFD_RELOC_390_PLT32DBL +-32 bit PC rel. PLT shifted by 1. +-@end deffn +-@deffn {} BFD_RELOC_390_GOTPCDBL +-32 bit PC rel. GOT shifted by 1. +-@end deffn +-@deffn {} BFD_RELOC_390_GOT64 +-64 bit GOT offset. +-@end deffn +-@deffn {} BFD_RELOC_390_PLT64 +-64 bit PC relative PLT address. +-@end deffn +-@deffn {} BFD_RELOC_390_GOTENT +-32 bit rel. offset to GOT entry. +-@end deffn +-@deffn {} BFD_RELOC_390_GOTOFF64 +-64 bit offset to GOT. +-@end deffn +-@deffn {} BFD_RELOC_390_GOTPLT12 +-12-bit offset to symbol-entry within GOT, with PLT handling. +-@end deffn +-@deffn {} BFD_RELOC_390_GOTPLT16 +-16-bit offset to symbol-entry within GOT, with PLT handling. +-@end deffn +-@deffn {} BFD_RELOC_390_GOTPLT32 +-32-bit offset to symbol-entry within GOT, with PLT handling. +-@end deffn +-@deffn {} BFD_RELOC_390_GOTPLT64 +-64-bit offset to symbol-entry within GOT, with PLT handling. +-@end deffn +-@deffn {} BFD_RELOC_390_GOTPLTENT +-32-bit rel. offset to symbol-entry within GOT, with PLT handling. +-@end deffn +-@deffn {} BFD_RELOC_390_PLTOFF16 +-16-bit rel. offset from the GOT to a PLT entry. +-@end deffn +-@deffn {} BFD_RELOC_390_PLTOFF32 +-32-bit rel. offset from the GOT to a PLT entry. +-@end deffn +-@deffn {} BFD_RELOC_390_PLTOFF64 +-64-bit rel. offset from the GOT to a PLT entry. +-@end deffn +-@deffn {} BFD_RELOC_390_TLS_LOAD +-@deffnx {} BFD_RELOC_390_TLS_GDCALL +-@deffnx {} BFD_RELOC_390_TLS_LDCALL +-@deffnx {} BFD_RELOC_390_TLS_GD32 +-@deffnx {} BFD_RELOC_390_TLS_GD64 +-@deffnx {} BFD_RELOC_390_TLS_GOTIE12 +-@deffnx {} BFD_RELOC_390_TLS_GOTIE32 +-@deffnx {} BFD_RELOC_390_TLS_GOTIE64 +-@deffnx {} BFD_RELOC_390_TLS_LDM32 +-@deffnx {} BFD_RELOC_390_TLS_LDM64 +-@deffnx {} BFD_RELOC_390_TLS_IE32 +-@deffnx {} BFD_RELOC_390_TLS_IE64 +-@deffnx {} BFD_RELOC_390_TLS_IEENT +-@deffnx {} BFD_RELOC_390_TLS_LE32 +-@deffnx {} BFD_RELOC_390_TLS_LE64 +-@deffnx {} BFD_RELOC_390_TLS_LDO32 +-@deffnx {} BFD_RELOC_390_TLS_LDO64 +-@deffnx {} BFD_RELOC_390_TLS_DTPMOD +-@deffnx {} BFD_RELOC_390_TLS_DTPOFF +-@deffnx {} BFD_RELOC_390_TLS_TPOFF +-s390 tls relocations. +-@end deffn +-@deffn {} BFD_RELOC_390_20 +-@deffnx {} BFD_RELOC_390_GOT20 +-@deffnx {} BFD_RELOC_390_GOTPLT20 +-@deffnx {} BFD_RELOC_390_TLS_GOTIE20 +-Long displacement extension. +-@end deffn +-@deffn {} BFD_RELOC_390_IRELATIVE +-STT_GNU_IFUNC relocation. +-@end deffn +-@deffn {} BFD_RELOC_SCORE_GPREL15 +-Score relocations +-Low 16 bit for load/store +-@end deffn +-@deffn {} BFD_RELOC_SCORE_DUMMY2 +-@deffnx {} BFD_RELOC_SCORE_JMP +-This is a 24-bit reloc with the right 1 bit assumed to be 0 +-@end deffn +-@deffn {} BFD_RELOC_SCORE_BRANCH +-This is a 19-bit reloc with the right 1 bit assumed to be 0 +-@end deffn +-@deffn {} BFD_RELOC_SCORE_IMM30 +-This is a 32-bit reloc for 48-bit instructions. +-@end deffn +-@deffn {} BFD_RELOC_SCORE_IMM32 +-This is a 32-bit reloc for 48-bit instructions. +-@end deffn +-@deffn {} BFD_RELOC_SCORE16_JMP +-This is a 11-bit reloc with the right 1 bit assumed to be 0 +-@end deffn +-@deffn {} BFD_RELOC_SCORE16_BRANCH +-This is a 8-bit reloc with the right 1 bit assumed to be 0 +-@end deffn +-@deffn {} BFD_RELOC_SCORE_BCMP +-This is a 9-bit reloc with the right 1 bit assumed to be 0 +-@end deffn +-@deffn {} BFD_RELOC_SCORE_GOT15 +-@deffnx {} BFD_RELOC_SCORE_GOT_LO16 +-@deffnx {} BFD_RELOC_SCORE_CALL15 +-@deffnx {} BFD_RELOC_SCORE_DUMMY_HI16 +-Undocumented Score relocs +-@end deffn +-@deffn {} BFD_RELOC_IP2K_FR9 +-Scenix IP2K - 9-bit register number / data address +-@end deffn +-@deffn {} BFD_RELOC_IP2K_BANK +-Scenix IP2K - 4-bit register/data bank number +-@end deffn +-@deffn {} BFD_RELOC_IP2K_ADDR16CJP +-Scenix IP2K - low 13 bits of instruction word address +-@end deffn +-@deffn {} BFD_RELOC_IP2K_PAGE3 +-Scenix IP2K - high 3 bits of instruction word address +-@end deffn +-@deffn {} BFD_RELOC_IP2K_LO8DATA +-@deffnx {} BFD_RELOC_IP2K_HI8DATA +-@deffnx {} BFD_RELOC_IP2K_EX8DATA +-Scenix IP2K - ext/low/high 8 bits of data address +-@end deffn +-@deffn {} BFD_RELOC_IP2K_LO8INSN +-@deffnx {} BFD_RELOC_IP2K_HI8INSN +-Scenix IP2K - low/high 8 bits of instruction word address +-@end deffn +-@deffn {} BFD_RELOC_IP2K_PC_SKIP +-Scenix IP2K - even/odd PC modifier to modify snb pcl.0 +-@end deffn +-@deffn {} BFD_RELOC_IP2K_TEXT +-Scenix IP2K - 16 bit word address in text section. +-@end deffn +-@deffn {} BFD_RELOC_IP2K_FR_OFFSET +-Scenix IP2K - 7-bit sp or dp offset +-@end deffn +-@deffn {} BFD_RELOC_VPE4KMATH_DATA +-@deffnx {} BFD_RELOC_VPE4KMATH_INSN +-Scenix VPE4K coprocessor - data/insn-space addressing +-@end deffn +-@deffn {} BFD_RELOC_VTABLE_INHERIT +-@deffnx {} BFD_RELOC_VTABLE_ENTRY +-These two relocations are used by the linker to determine which of +-the entries in a C++ virtual function table are actually used. When +-the --gc-sections option is given, the linker will zero out the entries +-that are not used, so that the code for those functions need not be +-included in the output. +- +-VTABLE_INHERIT is a zero-space relocation used to describe to the +-linker the inheritance tree of a C++ virtual function table. The +-relocation's symbol should be the parent class' vtable, and the +-relocation should be located at the child vtable. +- +-VTABLE_ENTRY is a zero-space relocation that describes the use of a +-virtual function table entry. The reloc's symbol should refer to the +-table of the class mentioned in the code. Off of that base, an offset +-describes the entry that is being used. For Rela hosts, this offset +-is stored in the reloc's addend. For Rel hosts, we are forced to put +-this offset in the reloc's section offset. +-@end deffn +-@deffn {} BFD_RELOC_IA64_IMM14 +-@deffnx {} BFD_RELOC_IA64_IMM22 +-@deffnx {} BFD_RELOC_IA64_IMM64 +-@deffnx {} BFD_RELOC_IA64_DIR32MSB +-@deffnx {} BFD_RELOC_IA64_DIR32LSB +-@deffnx {} BFD_RELOC_IA64_DIR64MSB +-@deffnx {} BFD_RELOC_IA64_DIR64LSB +-@deffnx {} BFD_RELOC_IA64_GPREL22 +-@deffnx {} BFD_RELOC_IA64_GPREL64I +-@deffnx {} BFD_RELOC_IA64_GPREL32MSB +-@deffnx {} BFD_RELOC_IA64_GPREL32LSB +-@deffnx {} BFD_RELOC_IA64_GPREL64MSB +-@deffnx {} BFD_RELOC_IA64_GPREL64LSB +-@deffnx {} BFD_RELOC_IA64_LTOFF22 +-@deffnx {} BFD_RELOC_IA64_LTOFF64I +-@deffnx {} BFD_RELOC_IA64_PLTOFF22 +-@deffnx {} BFD_RELOC_IA64_PLTOFF64I +-@deffnx {} BFD_RELOC_IA64_PLTOFF64MSB +-@deffnx {} BFD_RELOC_IA64_PLTOFF64LSB +-@deffnx {} BFD_RELOC_IA64_FPTR64I +-@deffnx {} BFD_RELOC_IA64_FPTR32MSB +-@deffnx {} BFD_RELOC_IA64_FPTR32LSB +-@deffnx {} BFD_RELOC_IA64_FPTR64MSB +-@deffnx {} BFD_RELOC_IA64_FPTR64LSB +-@deffnx {} BFD_RELOC_IA64_PCREL21B +-@deffnx {} BFD_RELOC_IA64_PCREL21BI +-@deffnx {} BFD_RELOC_IA64_PCREL21M +-@deffnx {} BFD_RELOC_IA64_PCREL21F +-@deffnx {} BFD_RELOC_IA64_PCREL22 +-@deffnx {} BFD_RELOC_IA64_PCREL60B +-@deffnx {} BFD_RELOC_IA64_PCREL64I +-@deffnx {} BFD_RELOC_IA64_PCREL32MSB +-@deffnx {} BFD_RELOC_IA64_PCREL32LSB +-@deffnx {} BFD_RELOC_IA64_PCREL64MSB +-@deffnx {} BFD_RELOC_IA64_PCREL64LSB +-@deffnx {} BFD_RELOC_IA64_LTOFF_FPTR22 +-@deffnx {} BFD_RELOC_IA64_LTOFF_FPTR64I +-@deffnx {} BFD_RELOC_IA64_LTOFF_FPTR32MSB +-@deffnx {} BFD_RELOC_IA64_LTOFF_FPTR32LSB +-@deffnx {} BFD_RELOC_IA64_LTOFF_FPTR64MSB +-@deffnx {} BFD_RELOC_IA64_LTOFF_FPTR64LSB +-@deffnx {} BFD_RELOC_IA64_SEGREL32MSB +-@deffnx {} BFD_RELOC_IA64_SEGREL32LSB +-@deffnx {} BFD_RELOC_IA64_SEGREL64MSB +-@deffnx {} BFD_RELOC_IA64_SEGREL64LSB +-@deffnx {} BFD_RELOC_IA64_SECREL32MSB +-@deffnx {} BFD_RELOC_IA64_SECREL32LSB +-@deffnx {} BFD_RELOC_IA64_SECREL64MSB +-@deffnx {} BFD_RELOC_IA64_SECREL64LSB +-@deffnx {} BFD_RELOC_IA64_REL32MSB +-@deffnx {} BFD_RELOC_IA64_REL32LSB +-@deffnx {} BFD_RELOC_IA64_REL64MSB +-@deffnx {} BFD_RELOC_IA64_REL64LSB +-@deffnx {} BFD_RELOC_IA64_LTV32MSB +-@deffnx {} BFD_RELOC_IA64_LTV32LSB +-@deffnx {} BFD_RELOC_IA64_LTV64MSB +-@deffnx {} BFD_RELOC_IA64_LTV64LSB +-@deffnx {} BFD_RELOC_IA64_IPLTMSB +-@deffnx {} BFD_RELOC_IA64_IPLTLSB +-@deffnx {} BFD_RELOC_IA64_COPY +-@deffnx {} BFD_RELOC_IA64_LTOFF22X +-@deffnx {} BFD_RELOC_IA64_LDXMOV +-@deffnx {} BFD_RELOC_IA64_TPREL14 +-@deffnx {} BFD_RELOC_IA64_TPREL22 +-@deffnx {} BFD_RELOC_IA64_TPREL64I +-@deffnx {} BFD_RELOC_IA64_TPREL64MSB +-@deffnx {} BFD_RELOC_IA64_TPREL64LSB +-@deffnx {} BFD_RELOC_IA64_LTOFF_TPREL22 +-@deffnx {} BFD_RELOC_IA64_DTPMOD64MSB +-@deffnx {} BFD_RELOC_IA64_DTPMOD64LSB +-@deffnx {} BFD_RELOC_IA64_LTOFF_DTPMOD22 +-@deffnx {} BFD_RELOC_IA64_DTPREL14 +-@deffnx {} BFD_RELOC_IA64_DTPREL22 +-@deffnx {} BFD_RELOC_IA64_DTPREL64I +-@deffnx {} BFD_RELOC_IA64_DTPREL32MSB +-@deffnx {} BFD_RELOC_IA64_DTPREL32LSB +-@deffnx {} BFD_RELOC_IA64_DTPREL64MSB +-@deffnx {} BFD_RELOC_IA64_DTPREL64LSB +-@deffnx {} BFD_RELOC_IA64_LTOFF_DTPREL22 +-Intel IA64 Relocations. +-@end deffn +-@deffn {} BFD_RELOC_M68HC11_HI8 +-Motorola 68HC11 reloc. +-This is the 8 bit high part of an absolute address. +-@end deffn +-@deffn {} BFD_RELOC_M68HC11_LO8 +-Motorola 68HC11 reloc. +-This is the 8 bit low part of an absolute address. +-@end deffn +-@deffn {} BFD_RELOC_M68HC11_3B +-Motorola 68HC11 reloc. +-This is the 3 bit of a value. +-@end deffn +-@deffn {} BFD_RELOC_M68HC11_RL_JUMP +-Motorola 68HC11 reloc. +-This reloc marks the beginning of a jump/call instruction. +-It is used for linker relaxation to correctly identify beginning +-of instruction and change some branches to use PC-relative +-addressing mode. +-@end deffn +-@deffn {} BFD_RELOC_M68HC11_RL_GROUP +-Motorola 68HC11 reloc. +-This reloc marks a group of several instructions that gcc generates +-and for which the linker relaxation pass can modify and/or remove +-some of them. +-@end deffn +-@deffn {} BFD_RELOC_M68HC11_LO16 +-Motorola 68HC11 reloc. +-This is the 16-bit lower part of an address. It is used for 'call' +-instruction to specify the symbol address without any special +-transformation (due to memory bank window). +-@end deffn +-@deffn {} BFD_RELOC_M68HC11_PAGE +-Motorola 68HC11 reloc. +-This is a 8-bit reloc that specifies the page number of an address. +-It is used by 'call' instruction to specify the page number of +-the symbol. +-@end deffn +-@deffn {} BFD_RELOC_M68HC11_24 +-Motorola 68HC11 reloc. +-This is a 24-bit reloc that represents the address with a 16-bit +-value and a 8-bit page number. The symbol address is transformed +-to follow the 16K memory bank of 68HC12 (seen as mapped in the window). +-@end deffn +-@deffn {} BFD_RELOC_M68HC12_5B +-Motorola 68HC12 reloc. +-This is the 5 bits of a value. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_RL_JUMP +-Freescale XGATE reloc. +-This reloc marks the beginning of a bra/jal instruction. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_RL_GROUP +-Freescale XGATE reloc. +-This reloc marks a group of several instructions that gcc generates +-and for which the linker relaxation pass can modify and/or remove +-some of them. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_LO16 +-Freescale XGATE reloc. +-This is the 16-bit lower part of an address. It is used for the '16-bit' +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_GPAGE +-Freescale XGATE reloc. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_24 +-Freescale XGATE reloc. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_PCREL_9 +-Freescale XGATE reloc. +-This is a 9-bit pc-relative reloc. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_PCREL_10 +-Freescale XGATE reloc. +-This is a 10-bit pc-relative reloc. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_IMM8_LO +-Freescale XGATE reloc. +-This is the 16-bit lower part of an address. It is used for the '16-bit' +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_IMM8_HI +-Freescale XGATE reloc. +-This is the 16-bit higher part of an address. It is used for the '16-bit' +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_IMM3 +-Freescale XGATE reloc. +-This is a 3-bit pc-relative reloc. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_IMM4 +-Freescale XGATE reloc. +-This is a 4-bit pc-relative reloc. +-@end deffn +-@deffn {} BFD_RELOC_XGATE_IMM5 +-Freescale XGATE reloc. +-This is a 5-bit pc-relative reloc. +-@end deffn +-@deffn {} BFD_RELOC_M68HC12_9B +-Motorola 68HC12 reloc. +-This is the 9 bits of a value. +-@end deffn +-@deffn {} BFD_RELOC_M68HC12_16B +-Motorola 68HC12 reloc. +-This is the 16 bits of a value. +-@end deffn +-@deffn {} BFD_RELOC_M68HC12_9_PCREL +-Motorola 68HC12/XGATE reloc. +-This is a PCREL9 branch. +-@end deffn +-@deffn {} BFD_RELOC_M68HC12_10_PCREL +-Motorola 68HC12/XGATE reloc. +-This is a PCREL10 branch. +-@end deffn +-@deffn {} BFD_RELOC_M68HC12_LO8XG +-Motorola 68HC12/XGATE reloc. +-This is the 8 bit low part of an absolute address and immediately precedes +-a matching HI8XG part. +-@end deffn +-@deffn {} BFD_RELOC_M68HC12_HI8XG +-Motorola 68HC12/XGATE reloc. +-This is the 8 bit high part of an absolute address and immediately follows +-a matching LO8XG part. +-@end deffn +-@deffn {} BFD_RELOC_S12Z_15_PCREL +-Freescale S12Z reloc. +-This is a 15 bit relative address. If the most significant bits are all zero +-then it may be truncated to 8 bits. +-@end deffn +-@deffn {} BFD_RELOC_CR16_NUM8 +-@deffnx {} BFD_RELOC_CR16_NUM16 +-@deffnx {} BFD_RELOC_CR16_NUM32 +-@deffnx {} BFD_RELOC_CR16_NUM32a +-@deffnx {} BFD_RELOC_CR16_REGREL0 +-@deffnx {} BFD_RELOC_CR16_REGREL4 +-@deffnx {} BFD_RELOC_CR16_REGREL4a +-@deffnx {} BFD_RELOC_CR16_REGREL14 +-@deffnx {} BFD_RELOC_CR16_REGREL14a +-@deffnx {} BFD_RELOC_CR16_REGREL16 +-@deffnx {} BFD_RELOC_CR16_REGREL20 +-@deffnx {} BFD_RELOC_CR16_REGREL20a +-@deffnx {} BFD_RELOC_CR16_ABS20 +-@deffnx {} BFD_RELOC_CR16_ABS24 +-@deffnx {} BFD_RELOC_CR16_IMM4 +-@deffnx {} BFD_RELOC_CR16_IMM8 +-@deffnx {} BFD_RELOC_CR16_IMM16 +-@deffnx {} BFD_RELOC_CR16_IMM20 +-@deffnx {} BFD_RELOC_CR16_IMM24 +-@deffnx {} BFD_RELOC_CR16_IMM32 +-@deffnx {} BFD_RELOC_CR16_IMM32a +-@deffnx {} BFD_RELOC_CR16_DISP4 +-@deffnx {} BFD_RELOC_CR16_DISP8 +-@deffnx {} BFD_RELOC_CR16_DISP16 +-@deffnx {} BFD_RELOC_CR16_DISP20 +-@deffnx {} BFD_RELOC_CR16_DISP24 +-@deffnx {} BFD_RELOC_CR16_DISP24a +-@deffnx {} BFD_RELOC_CR16_SWITCH8 +-@deffnx {} BFD_RELOC_CR16_SWITCH16 +-@deffnx {} BFD_RELOC_CR16_SWITCH32 +-@deffnx {} BFD_RELOC_CR16_GOT_REGREL20 +-@deffnx {} BFD_RELOC_CR16_GOTC_REGREL20 +-@deffnx {} BFD_RELOC_CR16_GLOB_DAT +-NS CR16 Relocations. +-@end deffn +-@deffn {} BFD_RELOC_CRX_REL4 +-@deffnx {} BFD_RELOC_CRX_REL8 +-@deffnx {} BFD_RELOC_CRX_REL8_CMP +-@deffnx {} BFD_RELOC_CRX_REL16 +-@deffnx {} BFD_RELOC_CRX_REL24 +-@deffnx {} BFD_RELOC_CRX_REL32 +-@deffnx {} BFD_RELOC_CRX_REGREL12 +-@deffnx {} BFD_RELOC_CRX_REGREL22 +-@deffnx {} BFD_RELOC_CRX_REGREL28 +-@deffnx {} BFD_RELOC_CRX_REGREL32 +-@deffnx {} BFD_RELOC_CRX_ABS16 +-@deffnx {} BFD_RELOC_CRX_ABS32 +-@deffnx {} BFD_RELOC_CRX_NUM8 +-@deffnx {} BFD_RELOC_CRX_NUM16 +-@deffnx {} BFD_RELOC_CRX_NUM32 +-@deffnx {} BFD_RELOC_CRX_IMM16 +-@deffnx {} BFD_RELOC_CRX_IMM32 +-@deffnx {} BFD_RELOC_CRX_SWITCH8 +-@deffnx {} BFD_RELOC_CRX_SWITCH16 +-@deffnx {} BFD_RELOC_CRX_SWITCH32 +-NS CRX Relocations. +-@end deffn +-@deffn {} BFD_RELOC_CRIS_BDISP8 +-@deffnx {} BFD_RELOC_CRIS_UNSIGNED_5 +-@deffnx {} BFD_RELOC_CRIS_SIGNED_6 +-@deffnx {} BFD_RELOC_CRIS_UNSIGNED_6 +-@deffnx {} BFD_RELOC_CRIS_SIGNED_8 +-@deffnx {} BFD_RELOC_CRIS_UNSIGNED_8 +-@deffnx {} BFD_RELOC_CRIS_SIGNED_16 +-@deffnx {} BFD_RELOC_CRIS_UNSIGNED_16 +-@deffnx {} BFD_RELOC_CRIS_LAPCQ_OFFSET +-@deffnx {} BFD_RELOC_CRIS_UNSIGNED_4 +-These relocs are only used within the CRIS assembler. They are not +-(at present) written to any object files. +-@end deffn +-@deffn {} BFD_RELOC_CRIS_COPY +-@deffnx {} BFD_RELOC_CRIS_GLOB_DAT +-@deffnx {} BFD_RELOC_CRIS_JUMP_SLOT +-@deffnx {} BFD_RELOC_CRIS_RELATIVE +-Relocs used in ELF shared libraries for CRIS. +-@end deffn +-@deffn {} BFD_RELOC_CRIS_32_GOT +-32-bit offset to symbol-entry within GOT. +-@end deffn +-@deffn {} BFD_RELOC_CRIS_16_GOT +-16-bit offset to symbol-entry within GOT. +-@end deffn +-@deffn {} BFD_RELOC_CRIS_32_GOTPLT +-32-bit offset to symbol-entry within GOT, with PLT handling. +-@end deffn +-@deffn {} BFD_RELOC_CRIS_16_GOTPLT +-16-bit offset to symbol-entry within GOT, with PLT handling. +-@end deffn +-@deffn {} BFD_RELOC_CRIS_32_GOTREL +-32-bit offset to symbol, relative to GOT. +-@end deffn +-@deffn {} BFD_RELOC_CRIS_32_PLT_GOTREL +-32-bit offset to symbol with PLT entry, relative to GOT. +-@end deffn +-@deffn {} BFD_RELOC_CRIS_32_PLT_PCREL +-32-bit offset to symbol with PLT entry, relative to this relocation. +-@end deffn +-@deffn {} BFD_RELOC_CRIS_32_GOT_GD +-@deffnx {} BFD_RELOC_CRIS_16_GOT_GD +-@deffnx {} BFD_RELOC_CRIS_32_GD +-@deffnx {} BFD_RELOC_CRIS_DTP +-@deffnx {} BFD_RELOC_CRIS_32_DTPREL +-@deffnx {} BFD_RELOC_CRIS_16_DTPREL +-@deffnx {} BFD_RELOC_CRIS_32_GOT_TPREL +-@deffnx {} BFD_RELOC_CRIS_16_GOT_TPREL +-@deffnx {} BFD_RELOC_CRIS_32_TPREL +-@deffnx {} BFD_RELOC_CRIS_16_TPREL +-@deffnx {} BFD_RELOC_CRIS_DTPMOD +-@deffnx {} BFD_RELOC_CRIS_32_IE +-Relocs used in TLS code for CRIS. +-@end deffn +-@deffn {} BFD_RELOC_OR1K_REL_26 +-@deffnx {} BFD_RELOC_OR1K_SLO16 +-@deffnx {} BFD_RELOC_OR1K_PCREL_PG21 +-@deffnx {} BFD_RELOC_OR1K_LO13 +-@deffnx {} BFD_RELOC_OR1K_SLO13 +-@deffnx {} BFD_RELOC_OR1K_GOTPC_HI16 +-@deffnx {} BFD_RELOC_OR1K_GOTPC_LO16 +-@deffnx {} BFD_RELOC_OR1K_GOT_AHI16 +-@deffnx {} BFD_RELOC_OR1K_GOT16 +-@deffnx {} BFD_RELOC_OR1K_GOT_PG21 +-@deffnx {} BFD_RELOC_OR1K_GOT_LO13 +-@deffnx {} BFD_RELOC_OR1K_PLT26 +-@deffnx {} BFD_RELOC_OR1K_PLTA26 +-@deffnx {} BFD_RELOC_OR1K_GOTOFF_SLO16 +-@deffnx {} BFD_RELOC_OR1K_COPY +-@deffnx {} BFD_RELOC_OR1K_GLOB_DAT +-@deffnx {} BFD_RELOC_OR1K_JMP_SLOT +-@deffnx {} BFD_RELOC_OR1K_RELATIVE +-@deffnx {} BFD_RELOC_OR1K_TLS_GD_HI16 +-@deffnx {} BFD_RELOC_OR1K_TLS_GD_LO16 +-@deffnx {} BFD_RELOC_OR1K_TLS_GD_PG21 +-@deffnx {} BFD_RELOC_OR1K_TLS_GD_LO13 +-@deffnx {} BFD_RELOC_OR1K_TLS_LDM_HI16 +-@deffnx {} BFD_RELOC_OR1K_TLS_LDM_LO16 +-@deffnx {} BFD_RELOC_OR1K_TLS_LDM_PG21 +-@deffnx {} BFD_RELOC_OR1K_TLS_LDM_LO13 +-@deffnx {} BFD_RELOC_OR1K_TLS_LDO_HI16 +-@deffnx {} BFD_RELOC_OR1K_TLS_LDO_LO16 +-@deffnx {} BFD_RELOC_OR1K_TLS_IE_HI16 +-@deffnx {} BFD_RELOC_OR1K_TLS_IE_AHI16 +-@deffnx {} BFD_RELOC_OR1K_TLS_IE_LO16 +-@deffnx {} BFD_RELOC_OR1K_TLS_IE_PG21 +-@deffnx {} BFD_RELOC_OR1K_TLS_IE_LO13 +-@deffnx {} BFD_RELOC_OR1K_TLS_LE_HI16 +-@deffnx {} BFD_RELOC_OR1K_TLS_LE_AHI16 +-@deffnx {} BFD_RELOC_OR1K_TLS_LE_LO16 +-@deffnx {} BFD_RELOC_OR1K_TLS_LE_SLO16 +-@deffnx {} BFD_RELOC_OR1K_TLS_TPOFF +-@deffnx {} BFD_RELOC_OR1K_TLS_DTPOFF +-@deffnx {} BFD_RELOC_OR1K_TLS_DTPMOD +-OpenRISC 1000 Relocations. +-@end deffn +-@deffn {} BFD_RELOC_H8_DIR16A8 +-@deffnx {} BFD_RELOC_H8_DIR16R8 +-@deffnx {} BFD_RELOC_H8_DIR24A8 +-@deffnx {} BFD_RELOC_H8_DIR24R8 +-@deffnx {} BFD_RELOC_H8_DIR32A16 +-@deffnx {} BFD_RELOC_H8_DISP32A16 +-H8 elf Relocations. +-@end deffn +-@deffn {} BFD_RELOC_XSTORMY16_REL_12 +-@deffnx {} BFD_RELOC_XSTORMY16_12 +-@deffnx {} BFD_RELOC_XSTORMY16_24 +-@deffnx {} BFD_RELOC_XSTORMY16_FPTR16 +-Sony Xstormy16 Relocations. +-@end deffn +-@deffn {} BFD_RELOC_RELC +-Self-describing complex relocations. +-@end deffn +-@deffn {} BFD_RELOC_VAX_GLOB_DAT +-@deffnx {} BFD_RELOC_VAX_JMP_SLOT +-@deffnx {} BFD_RELOC_VAX_RELATIVE +-Relocations used by VAX ELF. +-@end deffn +-@deffn {} BFD_RELOC_MT_PC16 +-Morpho MT - 16 bit immediate relocation. +-@end deffn +-@deffn {} BFD_RELOC_MT_HI16 +-Morpho MT - Hi 16 bits of an address. +-@end deffn +-@deffn {} BFD_RELOC_MT_LO16 +-Morpho MT - Low 16 bits of an address. +-@end deffn +-@deffn {} BFD_RELOC_MT_GNU_VTINHERIT +-Morpho MT - Used to tell the linker which vtable entries are used. +-@end deffn +-@deffn {} BFD_RELOC_MT_GNU_VTENTRY +-Morpho MT - Used to tell the linker which vtable entries are used. +-@end deffn +-@deffn {} BFD_RELOC_MT_PCINSN8 +-Morpho MT - 8 bit immediate relocation. +-@end deffn +-@deffn {} BFD_RELOC_MSP430_10_PCREL +-@deffnx {} BFD_RELOC_MSP430_16_PCREL +-@deffnx {} BFD_RELOC_MSP430_16 +-@deffnx {} BFD_RELOC_MSP430_16_PCREL_BYTE +-@deffnx {} BFD_RELOC_MSP430_16_BYTE +-@deffnx {} BFD_RELOC_MSP430_2X_PCREL +-@deffnx {} BFD_RELOC_MSP430_RL_PCREL +-@deffnx {} BFD_RELOC_MSP430_ABS8 +-@deffnx {} BFD_RELOC_MSP430X_PCR20_EXT_SRC +-@deffnx {} BFD_RELOC_MSP430X_PCR20_EXT_DST +-@deffnx {} BFD_RELOC_MSP430X_PCR20_EXT_ODST +-@deffnx {} BFD_RELOC_MSP430X_ABS20_EXT_SRC +-@deffnx {} BFD_RELOC_MSP430X_ABS20_EXT_DST +-@deffnx {} BFD_RELOC_MSP430X_ABS20_EXT_ODST +-@deffnx {} BFD_RELOC_MSP430X_ABS20_ADR_SRC +-@deffnx {} BFD_RELOC_MSP430X_ABS20_ADR_DST +-@deffnx {} BFD_RELOC_MSP430X_PCR16 +-@deffnx {} BFD_RELOC_MSP430X_PCR20_CALL +-@deffnx {} BFD_RELOC_MSP430X_ABS16 +-@deffnx {} BFD_RELOC_MSP430_ABS_HI16 +-@deffnx {} BFD_RELOC_MSP430_PREL31 +-@deffnx {} BFD_RELOC_MSP430_SYM_DIFF +-@deffnx {} BFD_RELOC_MSP430_SET_ULEB128 +-@deffnx {} BFD_RELOC_MSP430_SUB_ULEB128 +-msp430 specific relocation codes +-@end deffn +-@deffn {} BFD_RELOC_NIOS2_S16 +-@deffnx {} BFD_RELOC_NIOS2_U16 +-@deffnx {} BFD_RELOC_NIOS2_CALL26 +-@deffnx {} BFD_RELOC_NIOS2_IMM5 +-@deffnx {} BFD_RELOC_NIOS2_CACHE_OPX +-@deffnx {} BFD_RELOC_NIOS2_IMM6 +-@deffnx {} BFD_RELOC_NIOS2_IMM8 +-@deffnx {} BFD_RELOC_NIOS2_HI16 +-@deffnx {} BFD_RELOC_NIOS2_LO16 +-@deffnx {} BFD_RELOC_NIOS2_HIADJ16 +-@deffnx {} BFD_RELOC_NIOS2_GPREL +-@deffnx {} BFD_RELOC_NIOS2_UJMP +-@deffnx {} BFD_RELOC_NIOS2_CJMP +-@deffnx {} BFD_RELOC_NIOS2_CALLR +-@deffnx {} BFD_RELOC_NIOS2_ALIGN +-@deffnx {} BFD_RELOC_NIOS2_GOT16 +-@deffnx {} BFD_RELOC_NIOS2_CALL16 +-@deffnx {} BFD_RELOC_NIOS2_GOTOFF_LO +-@deffnx {} BFD_RELOC_NIOS2_GOTOFF_HA +-@deffnx {} BFD_RELOC_NIOS2_PCREL_LO +-@deffnx {} BFD_RELOC_NIOS2_PCREL_HA +-@deffnx {} BFD_RELOC_NIOS2_TLS_GD16 +-@deffnx {} BFD_RELOC_NIOS2_TLS_LDM16 +-@deffnx {} BFD_RELOC_NIOS2_TLS_LDO16 +-@deffnx {} BFD_RELOC_NIOS2_TLS_IE16 +-@deffnx {} BFD_RELOC_NIOS2_TLS_LE16 +-@deffnx {} BFD_RELOC_NIOS2_TLS_DTPMOD +-@deffnx {} BFD_RELOC_NIOS2_TLS_DTPREL +-@deffnx {} BFD_RELOC_NIOS2_TLS_TPREL +-@deffnx {} BFD_RELOC_NIOS2_COPY +-@deffnx {} BFD_RELOC_NIOS2_GLOB_DAT +-@deffnx {} BFD_RELOC_NIOS2_JUMP_SLOT +-@deffnx {} BFD_RELOC_NIOS2_RELATIVE +-@deffnx {} BFD_RELOC_NIOS2_GOTOFF +-@deffnx {} BFD_RELOC_NIOS2_CALL26_NOAT +-@deffnx {} BFD_RELOC_NIOS2_GOT_LO +-@deffnx {} BFD_RELOC_NIOS2_GOT_HA +-@deffnx {} BFD_RELOC_NIOS2_CALL_LO +-@deffnx {} BFD_RELOC_NIOS2_CALL_HA +-@deffnx {} BFD_RELOC_NIOS2_R2_S12 +-@deffnx {} BFD_RELOC_NIOS2_R2_I10_1_PCREL +-@deffnx {} BFD_RELOC_NIOS2_R2_T1I7_1_PCREL +-@deffnx {} BFD_RELOC_NIOS2_R2_T1I7_2 +-@deffnx {} BFD_RELOC_NIOS2_R2_T2I4 +-@deffnx {} BFD_RELOC_NIOS2_R2_T2I4_1 +-@deffnx {} BFD_RELOC_NIOS2_R2_T2I4_2 +-@deffnx {} BFD_RELOC_NIOS2_R2_X1I7_2 +-@deffnx {} BFD_RELOC_NIOS2_R2_X2L5 +-@deffnx {} BFD_RELOC_NIOS2_R2_F1I5_2 +-@deffnx {} BFD_RELOC_NIOS2_R2_L5I4X1 +-@deffnx {} BFD_RELOC_NIOS2_R2_T1X1I6 +-@deffnx {} BFD_RELOC_NIOS2_R2_T1X1I6_2 +-Relocations used by the Altera Nios II core. +-@end deffn +-@deffn {} BFD_RELOC_PRU_U16 +-PRU LDI 16-bit unsigned data-memory relocation. +-@end deffn +-@deffn {} BFD_RELOC_PRU_U16_PMEMIMM +-PRU LDI 16-bit unsigned instruction-memory relocation. +-@end deffn +-@deffn {} BFD_RELOC_PRU_LDI32 +-PRU relocation for two consecutive LDI load instructions that load a +-32 bit value into a register. If the higher bits are all zero, then +-the second instruction may be relaxed. +-@end deffn +-@deffn {} BFD_RELOC_PRU_S10_PCREL +-PRU QBBx 10-bit signed PC-relative relocation. +-@end deffn +-@deffn {} BFD_RELOC_PRU_U8_PCREL +-PRU 8-bit unsigned relocation used for the LOOP instruction. +-@end deffn +-@deffn {} BFD_RELOC_PRU_32_PMEM +-@deffnx {} BFD_RELOC_PRU_16_PMEM +-PRU Program Memory relocations. Used to convert from byte addressing to +-32-bit word addressing. +-@end deffn +-@deffn {} BFD_RELOC_PRU_GNU_DIFF8 +-@deffnx {} BFD_RELOC_PRU_GNU_DIFF16 +-@deffnx {} BFD_RELOC_PRU_GNU_DIFF32 +-@deffnx {} BFD_RELOC_PRU_GNU_DIFF16_PMEM +-@deffnx {} BFD_RELOC_PRU_GNU_DIFF32_PMEM +-PRU relocations to mark the difference of two local symbols. +-These are only needed to support linker relaxation and can be ignored +-when not relaxing. The field is set to the value of the difference +-assuming no relaxation. The relocation encodes the position of the +-second symbol so the linker can determine whether to adjust the field +-value. The PMEM variants encode the word difference, instead of byte +-difference between symbols. +-@end deffn +-@deffn {} BFD_RELOC_IQ2000_OFFSET_16 +-@deffnx {} BFD_RELOC_IQ2000_OFFSET_21 +-@deffnx {} BFD_RELOC_IQ2000_UHI16 +-IQ2000 Relocations. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_RTLD +-Special Xtensa relocation used only by PLT entries in ELF shared +-objects to indicate that the runtime linker should set the value +-to one of its own internal functions or data structures. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_GLOB_DAT +-@deffnx {} BFD_RELOC_XTENSA_JMP_SLOT +-@deffnx {} BFD_RELOC_XTENSA_RELATIVE +-Xtensa relocations for ELF shared objects. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_PLT +-Xtensa relocation used in ELF object files for symbols that may require +-PLT entries. Otherwise, this is just a generic 32-bit relocation. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_DIFF8 +-@deffnx {} BFD_RELOC_XTENSA_DIFF16 +-@deffnx {} BFD_RELOC_XTENSA_DIFF32 +-Xtensa relocations for backward compatibility. These have been replaced +-by BFD_RELOC_XTENSA_PDIFF and BFD_RELOC_XTENSA_NDIFF. +-Xtensa relocations to mark the difference of two local symbols. +-These are only needed to support linker relaxation and can be ignored +-when not relaxing. The field is set to the value of the difference +-assuming no relaxation. The relocation encodes the position of the +-first symbol so the linker can determine whether to adjust the field +-value. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_SLOT0_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT1_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT2_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT3_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT4_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT5_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT6_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT7_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT8_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT9_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT10_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT11_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT12_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT13_OP +-@deffnx {} BFD_RELOC_XTENSA_SLOT14_OP +-Generic Xtensa relocations for instruction operands. Only the slot +-number is encoded in the relocation. The relocation applies to the +-last PC-relative immediate operand, or if there are no PC-relative +-immediates, to the last immediate operand. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_SLOT0_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT1_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT2_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT3_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT4_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT5_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT6_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT7_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT8_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT9_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT10_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT11_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT12_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT13_ALT +-@deffnx {} BFD_RELOC_XTENSA_SLOT14_ALT +-Alternate Xtensa relocations. Only the slot is encoded in the +-relocation. The meaning of these relocations is opcode-specific. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_OP0 +-@deffnx {} BFD_RELOC_XTENSA_OP1 +-@deffnx {} BFD_RELOC_XTENSA_OP2 +-Xtensa relocations for backward compatibility. These have all been +-replaced by BFD_RELOC_XTENSA_SLOT0_OP. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_ASM_EXPAND +-Xtensa relocation to mark that the assembler expanded the +-instructions from an original target. The expansion size is +-encoded in the reloc size. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_ASM_SIMPLIFY +-Xtensa relocation to mark that the linker should simplify +-assembler-expanded instructions. This is commonly used +-internally by the linker after analysis of a +-BFD_RELOC_XTENSA_ASM_EXPAND. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_TLSDESC_FN +-@deffnx {} BFD_RELOC_XTENSA_TLSDESC_ARG +-@deffnx {} BFD_RELOC_XTENSA_TLS_DTPOFF +-@deffnx {} BFD_RELOC_XTENSA_TLS_TPOFF +-@deffnx {} BFD_RELOC_XTENSA_TLS_FUNC +-@deffnx {} BFD_RELOC_XTENSA_TLS_ARG +-@deffnx {} BFD_RELOC_XTENSA_TLS_CALL +-Xtensa TLS relocations. +-@end deffn +-@deffn {} BFD_RELOC_XTENSA_PDIFF8 +-@deffnx {} BFD_RELOC_XTENSA_PDIFF16 +-@deffnx {} BFD_RELOC_XTENSA_PDIFF32 +-@deffnx {} BFD_RELOC_XTENSA_NDIFF8 +-@deffnx {} BFD_RELOC_XTENSA_NDIFF16 +-@deffnx {} BFD_RELOC_XTENSA_NDIFF32 +-Xtensa relocations to mark the difference of two local symbols. +-These are only needed to support linker relaxation and can be ignored +-when not relaxing. The field is set to the value of the difference +-assuming no relaxation. The relocation encodes the position of the +-subtracted symbol so the linker can determine whether to adjust the field +-value. PDIFF relocations are used for positive differences, NDIFF +-relocations are used for negative differences. The difference value +-is treated as unsigned with these relocation types, giving full +-8/16 value ranges. +-@end deffn +-@deffn {} BFD_RELOC_Z80_DISP8 +-8 bit signed offset in (ix+d) or (iy+d). +-@end deffn +-@deffn {} BFD_RELOC_Z80_BYTE0 +-First 8 bits of multibyte (32, 24 or 16 bit) value. +-@end deffn +-@deffn {} BFD_RELOC_Z80_BYTE1 +-Second 8 bits of multibyte (32, 24 or 16 bit) value. +-@end deffn +-@deffn {} BFD_RELOC_Z80_BYTE2 +-Third 8 bits of multibyte (32 or 24 bit) value. +-@end deffn +-@deffn {} BFD_RELOC_Z80_BYTE3 +-Fourth 8 bits of multibyte (32 bit) value. +-@end deffn +-@deffn {} BFD_RELOC_Z80_WORD0 +-Lowest 16 bits of multibyte (32 or 24 bit) value. +-@end deffn +-@deffn {} BFD_RELOC_Z80_WORD1 +-Highest 16 bits of multibyte (32 or 24 bit) value. +-@end deffn +-@deffn {} BFD_RELOC_Z80_16_BE +-Like BFD_RELOC_16 but big-endian. +-@end deffn +-@deffn {} BFD_RELOC_Z8K_DISP7 +-DJNZ offset. +-@end deffn +-@deffn {} BFD_RELOC_Z8K_CALLR +-CALR offset. +-@end deffn +-@deffn {} BFD_RELOC_Z8K_IMM4L +-4 bit value. +-@end deffn +-@deffn {} BFD_RELOC_LM32_CALL +-@deffnx {} BFD_RELOC_LM32_BRANCH +-@deffnx {} BFD_RELOC_LM32_16_GOT +-@deffnx {} BFD_RELOC_LM32_GOTOFF_HI16 +-@deffnx {} BFD_RELOC_LM32_GOTOFF_LO16 +-@deffnx {} BFD_RELOC_LM32_COPY +-@deffnx {} BFD_RELOC_LM32_GLOB_DAT +-@deffnx {} BFD_RELOC_LM32_JMP_SLOT +-@deffnx {} BFD_RELOC_LM32_RELATIVE +-Lattice Mico32 relocations. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_SECTDIFF +-Difference between two section addreses. Must be followed by a +-BFD_RELOC_MACH_O_PAIR. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_LOCAL_SECTDIFF +-Like BFD_RELOC_MACH_O_SECTDIFF but with a local symbol. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_PAIR +-Pair of relocation. Contains the first symbol. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_SUBTRACTOR32 +-Symbol will be substracted. Must be followed by a BFD_RELOC_32. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_SUBTRACTOR64 +-Symbol will be substracted. Must be followed by a BFD_RELOC_64. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_X86_64_BRANCH32 +-@deffnx {} BFD_RELOC_MACH_O_X86_64_BRANCH8 +-PCREL relocations. They are marked as branch to create PLT entry if +-required. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_X86_64_GOT +-Used when referencing a GOT entry. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_X86_64_GOT_LOAD +-Used when loading a GOT entry with movq. It is specially marked so that +-the linker could optimize the movq to a leaq if possible. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_X86_64_PCREL32_1 +-Same as BFD_RELOC_32_PCREL but with an implicit -1 addend. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_X86_64_PCREL32_2 +-Same as BFD_RELOC_32_PCREL but with an implicit -2 addend. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_X86_64_PCREL32_4 +-Same as BFD_RELOC_32_PCREL but with an implicit -4 addend. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_X86_64_TLV +-Used when referencing a TLV entry. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_ARM64_ADDEND +-Addend for PAGE or PAGEOFF. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_ARM64_GOT_LOAD_PAGE21 +-Relative offset to page of GOT slot. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_ARM64_GOT_LOAD_PAGEOFF12 +-Relative offset within page of GOT slot. +-@end deffn +-@deffn {} BFD_RELOC_MACH_O_ARM64_POINTER_TO_GOT +-Address of a GOT entry. +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_32_LO +-This is a 32 bit reloc for the microblaze that stores the +-low 16 bits of a value +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_32_LO_PCREL +-This is a 32 bit pc-relative reloc for the microblaze that +-stores the low 16 bits of a value +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_32_ROSDA +-This is a 32 bit reloc for the microblaze that stores a +-value relative to the read-only small data area anchor +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_32_RWSDA +-This is a 32 bit reloc for the microblaze that stores a +-value relative to the read-write small data area anchor +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM +-This is a 32 bit reloc for the microblaze to handle +-expressions of the form "Symbol Op Symbol" +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_NONE +-This is a 64 bit reloc that stores the 32 bit pc relative +-value in two words (with an imm instruction). No relocation is +-done here - only used for relaxing +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_GOTPC +-This is a 64 bit reloc that stores the 32 bit pc relative +-value in two words (with an imm instruction). The relocation is +-PC-relative GOT offset +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_GOT +-This is a 64 bit reloc that stores the 32 bit pc relative +-value in two words (with an imm instruction). The relocation is +-GOT offset +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_PLT +-This is a 64 bit reloc that stores the 32 bit pc relative +-value in two words (with an imm instruction). The relocation is +-PC-relative offset into PLT +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_GOTOFF +-This is a 64 bit reloc that stores the 32 bit GOT relative +-value in two words (with an imm instruction). The relocation is +-relative offset from _GLOBAL_OFFSET_TABLE_ +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_32_GOTOFF +-This is a 32 bit reloc that stores the 32 bit GOT relative +-value in a word. The relocation is relative offset from +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_COPY +-This is used to tell the dynamic linker to copy the value out of +-the dynamic object into the runtime process image. +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_TLS +-Unused Reloc +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_TLSGD +-This is a 64 bit reloc that stores the 32 bit GOT relative value +-of the GOT TLS GD info entry in two words (with an imm instruction). The +-relocation is GOT offset. +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_TLSLD +-This is a 64 bit reloc that stores the 32 bit GOT relative value +-of the GOT TLS LD info entry in two words (with an imm instruction). The +-relocation is GOT offset. +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_32_TLSDTPMOD +-This is a 32 bit reloc that stores the Module ID to GOT(n). +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_32_TLSDTPREL +-This is a 32 bit reloc that stores TLS offset to GOT(n+1). +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_TLSDTPREL +-This is a 32 bit reloc for storing TLS offset to two words (uses imm +-instruction) +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL +-This is a 64 bit reloc that stores 32-bit thread pointer relative offset +-to two words (uses imm instruction). +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_TLSTPREL +-This is a 64 bit reloc that stores 32-bit thread pointer relative offset +-to two words (uses imm instruction). +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_TEXTPCREL +-This is a 64 bit reloc that stores the 32 bit pc relative +-value in two words (with an imm instruction). The relocation is +-PC-relative offset from start of TEXT. +-@end deffn +-@deffn {} BFD_RELOC_MICROBLAZE_64_TEXTREL +-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. +-@end deffn +-@deffn {} BFD_RELOC_KVX_RELOC_START +-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."; +-@end deffn +-@deffn {} BFD_RELOC_KVX_NONE +-KVX null relocation code. +-@end deffn +-@deffn {} BFD_RELOC_KVX_16 +-@deffnx {} BFD_RELOC_KVX_32 +-@deffnx {} BFD_RELOC_KVX_64 +-@deffnx {} BFD_RELOC_KVX_S16_PCREL +-@deffnx {} BFD_RELOC_KVX_PCREL17 +-@deffnx {} BFD_RELOC_KVX_PCREL27 +-@deffnx {} BFD_RELOC_KVX_32_PCREL +-@deffnx {} BFD_RELOC_KVX_S37_PCREL_LO10 +-@deffnx {} BFD_RELOC_KVX_S37_PCREL_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_PCREL_LO10 +-@deffnx {} BFD_RELOC_KVX_S43_PCREL_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_PCREL_EX6 +-@deffnx {} BFD_RELOC_KVX_S64_PCREL_LO10 +-@deffnx {} BFD_RELOC_KVX_S64_PCREL_UP27 +-@deffnx {} BFD_RELOC_KVX_S64_PCREL_EX27 +-@deffnx {} BFD_RELOC_KVX_64_PCREL +-@deffnx {} BFD_RELOC_KVX_S16 +-@deffnx {} BFD_RELOC_KVX_S32_LO5 +-@deffnx {} BFD_RELOC_KVX_S32_UP27 +-@deffnx {} BFD_RELOC_KVX_S37_LO10 +-@deffnx {} BFD_RELOC_KVX_S37_UP27 +-@deffnx {} BFD_RELOC_KVX_S37_GOTOFF_LO10 +-@deffnx {} BFD_RELOC_KVX_S37_GOTOFF_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_GOTOFF_LO10 +-@deffnx {} BFD_RELOC_KVX_S43_GOTOFF_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_GOTOFF_EX6 +-@deffnx {} BFD_RELOC_KVX_32_GOTOFF +-@deffnx {} BFD_RELOC_KVX_64_GOTOFF +-@deffnx {} BFD_RELOC_KVX_32_GOT +-@deffnx {} BFD_RELOC_KVX_S37_GOT_LO10 +-@deffnx {} BFD_RELOC_KVX_S37_GOT_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_GOT_LO10 +-@deffnx {} BFD_RELOC_KVX_S43_GOT_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_GOT_EX6 +-@deffnx {} BFD_RELOC_KVX_64_GOT +-@deffnx {} BFD_RELOC_KVX_GLOB_DAT +-@deffnx {} BFD_RELOC_KVX_COPY +-@deffnx {} BFD_RELOC_KVX_JMP_SLOT +-@deffnx {} BFD_RELOC_KVX_RELATIVE +-@deffnx {} BFD_RELOC_KVX_S43_LO10 +-@deffnx {} BFD_RELOC_KVX_S43_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_EX6 +-@deffnx {} BFD_RELOC_KVX_S64_LO10 +-@deffnx {} BFD_RELOC_KVX_S64_UP27 +-@deffnx {} BFD_RELOC_KVX_S64_EX27 +-@deffnx {} BFD_RELOC_KVX_S37_GOTADDR_LO10 +-@deffnx {} BFD_RELOC_KVX_S37_GOTADDR_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_GOTADDR_LO10 +-@deffnx {} BFD_RELOC_KVX_S43_GOTADDR_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_GOTADDR_EX6 +-@deffnx {} BFD_RELOC_KVX_S64_GOTADDR_LO10 +-@deffnx {} BFD_RELOC_KVX_S64_GOTADDR_UP27 +-@deffnx {} BFD_RELOC_KVX_S64_GOTADDR_EX27 +-@deffnx {} BFD_RELOC_KVX_64_DTPMOD +-@deffnx {} BFD_RELOC_KVX_64_DTPOFF +-@deffnx {} BFD_RELOC_KVX_S37_TLS_DTPOFF_LO10 +-@deffnx {} BFD_RELOC_KVX_S37_TLS_DTPOFF_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_DTPOFF_LO10 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_DTPOFF_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_DTPOFF_EX6 +-@deffnx {} BFD_RELOC_KVX_S37_TLS_GD_LO10 +-@deffnx {} BFD_RELOC_KVX_S37_TLS_GD_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_GD_LO10 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_GD_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_GD_EX6 +-@deffnx {} BFD_RELOC_KVX_S37_TLS_LD_LO10 +-@deffnx {} BFD_RELOC_KVX_S37_TLS_LD_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_LD_LO10 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_LD_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_LD_EX6 +-@deffnx {} BFD_RELOC_KVX_64_TPOFF +-@deffnx {} BFD_RELOC_KVX_S37_TLS_IE_LO10 +-@deffnx {} BFD_RELOC_KVX_S37_TLS_IE_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_IE_LO10 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_IE_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_IE_EX6 +-@deffnx {} BFD_RELOC_KVX_S37_TLS_LE_LO10 +-@deffnx {} BFD_RELOC_KVX_S37_TLS_LE_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_LE_LO10 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_LE_UP27 +-@deffnx {} BFD_RELOC_KVX_S43_TLS_LE_EX6 +-@deffnx {} BFD_RELOC_KVX_8 +-KVX Relocations. +-@end deffn +-@deffn {} BFD_RELOC_KVX_RELOC_END +-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. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_RELOC_START +-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 +-by these enumerators; make sure they are all synced. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_NULL +-Deprecated AArch64 null relocation code. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_NONE +-AArch64 null relocation code. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_64 +-@deffnx {} BFD_RELOC_AARCH64_32 +-@deffnx {} BFD_RELOC_AARCH64_16 +-Basic absolute relocations of N bits. These are equivalent to +-BFD_RELOC_N and they were added to assist the indexing of the howto +-table. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_64_PCREL +-@deffnx {} BFD_RELOC_AARCH64_32_PCREL +-@deffnx {} BFD_RELOC_AARCH64_16_PCREL +-PC-relative relocations. These are equivalent to BFD_RELOC_N_PCREL +-and they were added to assist the indexing of the howto table. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_G0 +-AArch64 MOV[NZK] instruction with most significant bits 0 to 15 +-of an unsigned address/value. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_G0_NC +-AArch64 MOV[NZK] instruction with less significant bits 0 to 15 of +-an address/value. No overflow checking. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_G1 +-AArch64 MOV[NZK] instruction with most significant bits 16 to 31 +-of an unsigned address/value. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_G1_NC +-AArch64 MOV[NZK] instruction with less significant bits 16 to 31 +-of an address/value. No overflow checking. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_G2 +-AArch64 MOV[NZK] instruction with most significant bits 32 to 47 +-of an unsigned address/value. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_G2_NC +-AArch64 MOV[NZK] instruction with less significant bits 32 to 47 +-of an address/value. No overflow checking. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_G3 +-AArch64 MOV[NZK] instruction with most signficant bits 48 to 64 +-of a signed or unsigned address/value. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_G0_S +-AArch64 MOV[NZ] instruction with most significant bits 0 to 15 +-of a signed value. Changes instruction to MOVZ or MOVN depending on the +-value's sign. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_G1_S +-AArch64 MOV[NZ] instruction with most significant bits 16 to 31 +-of a signed value. Changes instruction to MOVZ or MOVN depending on the +-value's sign. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_G2_S +-AArch64 MOV[NZ] instruction with most significant bits 32 to 47 +-of a signed value. Changes instruction to MOVZ or MOVN depending on the +-value's sign. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_PREL_G0 +-AArch64 MOV[NZ] instruction with most significant bits 0 to 15 +-of a signed value. Changes instruction to MOVZ or MOVN depending on the +-value's sign. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_PREL_G0_NC +-AArch64 MOV[NZ] instruction with most significant bits 0 to 15 +-of a signed value. Changes instruction to MOVZ or MOVN depending on the +-value's sign. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_PREL_G1 +-AArch64 MOVK instruction with most significant bits 16 to 31 +-of a signed value. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_PREL_G1_NC +-AArch64 MOVK instruction with most significant bits 16 to 31 +-of a signed value. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_PREL_G2 +-AArch64 MOVK instruction with most significant bits 32 to 47 +-of a signed value. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_PREL_G2_NC +-AArch64 MOVK instruction with most significant bits 32 to 47 +-of a signed value. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_PREL_G3 +-AArch64 MOVK instruction with most significant bits 47 to 63 +-of a signed value. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LD_LO19_PCREL +-AArch64 Load Literal instruction, holding a 19 bit pc-relative word +-offset. The lowest two bits must be zero and are not stored in the +-instruction, giving a 21 bit signed byte offset. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_ADR_LO21_PCREL +-AArch64 ADR instruction, holding a simple 21 bit pc-relative byte offset. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_ADR_HI21_PCREL +-AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page +-offset, giving a 4KB aligned page base address. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL +-AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page +-offset, giving a 4KB aligned page base address, but with no overflow +-checking. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_ADD_LO12 +-AArch64 ADD immediate instruction, holding bits 0 to 11 of the address. +-Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LDST8_LO12 +-AArch64 8-bit load/store instruction, holding bits 0 to 11 of the +-address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TSTBR14 +-AArch64 14 bit pc-relative test bit and branch. +-The lowest two bits must be zero and are not stored in the instruction, +-giving a 16 bit signed byte offset. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_BRANCH19 +-AArch64 19 bit pc-relative conditional branch and compare & branch. +-The lowest two bits must be zero and are not stored in the instruction, +-giving a 21 bit signed byte offset. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_JUMP26 +-AArch64 26 bit pc-relative unconditional branch. +-The lowest two bits must be zero and are not stored in the instruction, +-giving a 28 bit signed byte offset. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_CALL26 +-AArch64 26 bit pc-relative unconditional branch and link. +-The lowest two bits must be zero and are not stored in the instruction, +-giving a 28 bit signed byte offset. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LDST16_LO12 +-AArch64 16-bit load/store instruction, holding bits 0 to 11 of the +-address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LDST32_LO12 +-AArch64 32-bit load/store instruction, holding bits 0 to 11 of the +-address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LDST64_LO12 +-AArch64 64-bit load/store instruction, holding bits 0 to 11 of the +-address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LDST128_LO12 +-AArch64 128-bit load/store instruction, holding bits 0 to 11 of the +-address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_GOT_LD_PREL19 +-AArch64 Load Literal instruction, holding a 19 bit PC relative word +-offset of the global offset table entry for a symbol. The lowest two +-bits must be zero and are not stored in the instruction, giving a 21 +-bit signed byte offset. This relocation type requires signed overflow +-checking. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_ADR_GOT_PAGE +-Get to the page base of the global offset table entry for a symbol as +-part of an ADRP instruction using a 21 bit PC relative value.Used in +-conjunction with BFD_RELOC_AARCH64_LD64_GOT_LO12_NC. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LD64_GOT_LO12_NC +-Unsigned 12 bit byte offset for 64 bit load/store from the page of +-the GOT entry for this symbol. Used in conjunction with +-BFD_RELOC_AARCH64_ADR_GOT_PAGE. Valid in LP64 ABI only. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LD32_GOT_LO12_NC +-Unsigned 12 bit byte offset for 32 bit load/store from the page of +-the GOT entry for this symbol. Used in conjunction with +-BFD_RELOC_AARCH64_ADR_GOT_PAGE. Valid in ILP32 ABI only. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC +-Unsigned 16 bit byte offset for 64 bit load/store from the GOT entry +-for this symbol. Valid in LP64 ABI only. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_MOVW_GOTOFF_G1 +-Unsigned 16 bit byte higher offset for 64 bit load/store from the GOT entry +-for this symbol. Valid in LP64 ABI only. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LD64_GOTOFF_LO15 +-Unsigned 15 bit byte offset for 64 bit load/store from the page of +-the GOT entry for this symbol. Valid in LP64 ABI only. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14 +-Scaled 14 bit byte offset to the page base of the global offset table. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15 +-Scaled 15 bit byte offset to the page base of the global offset table. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21 +-Get to the page base of the global offset table entry for a symbols +-tls_index structure as part of an adrp instruction using a 21 bit PC +-relative value. Used in conjunction with +-BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSGD_ADR_PREL21 +-AArch64 TLS General Dynamic +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC +-Unsigned 12 bit byte offset to global offset table entry for a symbols +-tls_index structure. Used in conjunction with +-BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC +-AArch64 TLS General Dynamic relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSGD_MOVW_G1 +-AArch64 TLS General Dynamic relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 +-AArch64 TLS INITIAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC +-AArch64 TLS INITIAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC +-AArch64 TLS INITIAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19 +-AArch64 TLS INITIAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC +-AArch64 TLS INITIAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1 +-AArch64 TLS INITIAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12 +-bit[23:12] of byte offset to module TLS base address. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12 +-Unsigned 12 bit byte offset to module TLS base address. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC +-No overflow check version of BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC +-Unsigned 12 bit byte offset to global offset table entry for a symbols +-tls_index structure. Used in conjunction with +-BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21 +-GOT entry page address for AArch64 TLS Local Dynamic, used with ADRP +-instruction. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_ADR_PREL21 +-GOT entry address for AArch64 TLS Local Dynamic, used with ADR instruction. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12 +-bit[11:1] of byte offset to module TLS base address, encoded in ldst +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC +-Similar as BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12, but no overflow check. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12 +-bit[11:2] of byte offset to module TLS base address, encoded in ldst +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC +-Similar as BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12, but no overflow check. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12 +-bit[11:3] of byte offset to module TLS base address, encoded in ldst +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC +-Similar as BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12, but no overflow check. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12 +-bit[11:0] of byte offset to module TLS base address, encoded in ldst +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC +-Similar as BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12, but no overflow check. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0 +-bit[15:0] of byte offset to module TLS base address. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC +-No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0 +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1 +-bit[31:16] of byte offset to module TLS base address. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC +-No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1 +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2 +-bit[47:32] of byte offset to module TLS base address. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2 +-AArch64 TLS LOCAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1 +-AArch64 TLS LOCAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC +-AArch64 TLS LOCAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0 +-AArch64 TLS LOCAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC +-AArch64 TLS LOCAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12 +-AArch64 TLS LOCAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12 +-AArch64 TLS LOCAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC +-AArch64 TLS LOCAL EXEC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12 +-bit[11:1] of byte offset to module TLS base address, encoded in ldst +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC +-Similar as BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12, but no overflow check. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12 +-bit[11:2] of byte offset to module TLS base address, encoded in ldst +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC +-Similar as BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12, but no overflow check. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12 +-bit[11:3] of byte offset to module TLS base address, encoded in ldst +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC +-Similar as BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12, but no overflow check. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12 +-bit[11:0] of byte offset to module TLS base address, encoded in ldst +-instructions. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC +-Similar as BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12, but no overflow check. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_LD_PREL19 +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21 +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21 +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_LD64_LO12 +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_ADD_LO12 +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_OFF_G1 +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_LDR +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_ADD +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_CALL +-AArch64 TLS DESC relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_COPY +-AArch64 TLS relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_GLOB_DAT +-AArch64 TLS relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_JUMP_SLOT +-AArch64 TLS relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_RELATIVE +-AArch64 TLS relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLS_DTPMOD +-AArch64 TLS relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLS_DTPREL +-AArch64 TLS relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLS_TPREL +-AArch64 TLS relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC +-AArch64 TLS relocation. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_IRELATIVE +-AArch64 support for STT_GNU_IFUNC. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_RELOC_END +-AArch64 pseudo relocation code to mark the end of the AArch64 +-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 AArch64 assembler for the internal fixup or to select +-one of the above enumerators. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP +-AArch64 pseudo relocation code to be used internally by the AArch64 +-assembler and not (currently) written to any object files. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LDST_LO12 +-AArch64 unspecified load/store instruction, holding bits 0 to 11 of the +-address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12 +-AArch64 pseudo relocation code for TLS local dynamic mode. It's to be +-used internally by the AArch64 assembler and not (currently) written to +-any object files. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC +-Similar as BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, but no overflow check. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12 +-AArch64 pseudo relocation code for TLS local exec mode. It's to be +-used internally by the AArch64 assembler and not (currently) written to +-any object files. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC +-Similar as BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12, but no overflow check. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_LD_GOT_LO12_NC +-AArch64 pseudo relocation code to be used internally by the AArch64 +-assembler and not (currently) written to any object files. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC +-AArch64 pseudo relocation code to be used internally by the AArch64 +-assembler and not (currently) written to any object files. +-@end deffn +-@deffn {} BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC +-AArch64 pseudo relocation code to be used internally by the AArch64 +-assembler and not (currently) written to any object files. +-@end deffn +-@deffn {} BFD_RELOC_TILEPRO_COPY +-@deffnx {} BFD_RELOC_TILEPRO_GLOB_DAT +-@deffnx {} BFD_RELOC_TILEPRO_JMP_SLOT +-@deffnx {} BFD_RELOC_TILEPRO_RELATIVE +-@deffnx {} BFD_RELOC_TILEPRO_BROFF_X1 +-@deffnx {} BFD_RELOC_TILEPRO_JOFFLONG_X1 +-@deffnx {} BFD_RELOC_TILEPRO_JOFFLONG_X1_PLT +-@deffnx {} BFD_RELOC_TILEPRO_IMM8_X0 +-@deffnx {} BFD_RELOC_TILEPRO_IMM8_Y0 +-@deffnx {} BFD_RELOC_TILEPRO_IMM8_X1 +-@deffnx {} BFD_RELOC_TILEPRO_IMM8_Y1 +-@deffnx {} BFD_RELOC_TILEPRO_DEST_IMM8_X1 +-@deffnx {} BFD_RELOC_TILEPRO_MT_IMM15_X1 +-@deffnx {} BFD_RELOC_TILEPRO_MF_IMM15_X1 +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0 +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1 +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_LO +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_LO +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_HI +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_HI +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_HA +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_HA +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_PCREL +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_PCREL +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_LO_PCREL +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_LO_PCREL +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_HI_PCREL +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_HI_PCREL +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_HA_PCREL +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_HA_PCREL +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_GOT +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_GOT +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_GOT_LO +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_GOT_LO +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_GOT_HI +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_GOT_HI +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_GOT_HA +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_GOT_HA +-@deffnx {} BFD_RELOC_TILEPRO_MMSTART_X0 +-@deffnx {} BFD_RELOC_TILEPRO_MMEND_X0 +-@deffnx {} BFD_RELOC_TILEPRO_MMSTART_X1 +-@deffnx {} BFD_RELOC_TILEPRO_MMEND_X1 +-@deffnx {} BFD_RELOC_TILEPRO_SHAMT_X0 +-@deffnx {} BFD_RELOC_TILEPRO_SHAMT_X1 +-@deffnx {} BFD_RELOC_TILEPRO_SHAMT_Y0 +-@deffnx {} BFD_RELOC_TILEPRO_SHAMT_Y1 +-@deffnx {} BFD_RELOC_TILEPRO_TLS_GD_CALL +-@deffnx {} BFD_RELOC_TILEPRO_IMM8_X0_TLS_GD_ADD +-@deffnx {} BFD_RELOC_TILEPRO_IMM8_X1_TLS_GD_ADD +-@deffnx {} BFD_RELOC_TILEPRO_IMM8_Y0_TLS_GD_ADD +-@deffnx {} BFD_RELOC_TILEPRO_IMM8_Y1_TLS_GD_ADD +-@deffnx {} BFD_RELOC_TILEPRO_TLS_IE_LOAD +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_LO +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD_LO +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_HI +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD_HI +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_HA +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD_HA +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE_LO +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE_LO +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE_HI +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE_HI +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_IE_HA +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_IE_HA +-@deffnx {} BFD_RELOC_TILEPRO_TLS_DTPMOD32 +-@deffnx {} BFD_RELOC_TILEPRO_TLS_DTPOFF32 +-@deffnx {} BFD_RELOC_TILEPRO_TLS_TPOFF32 +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_LO +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_LO +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HI +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HI +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HA +-@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HA +-Tilera TILEPro Relocations. +-@end deffn +-@deffn {} BFD_RELOC_TILEGX_HW0 +-@deffnx {} BFD_RELOC_TILEGX_HW1 +-@deffnx {} BFD_RELOC_TILEGX_HW2 +-@deffnx {} BFD_RELOC_TILEGX_HW3 +-@deffnx {} BFD_RELOC_TILEGX_HW0_LAST +-@deffnx {} BFD_RELOC_TILEGX_HW1_LAST +-@deffnx {} BFD_RELOC_TILEGX_HW2_LAST +-@deffnx {} BFD_RELOC_TILEGX_COPY +-@deffnx {} BFD_RELOC_TILEGX_GLOB_DAT +-@deffnx {} BFD_RELOC_TILEGX_JMP_SLOT +-@deffnx {} BFD_RELOC_TILEGX_RELATIVE +-@deffnx {} BFD_RELOC_TILEGX_BROFF_X1 +-@deffnx {} BFD_RELOC_TILEGX_JUMPOFF_X1 +-@deffnx {} BFD_RELOC_TILEGX_JUMPOFF_X1_PLT +-@deffnx {} BFD_RELOC_TILEGX_IMM8_X0 +-@deffnx {} BFD_RELOC_TILEGX_IMM8_Y0 +-@deffnx {} BFD_RELOC_TILEGX_IMM8_X1 +-@deffnx {} BFD_RELOC_TILEGX_IMM8_Y1 +-@deffnx {} BFD_RELOC_TILEGX_DEST_IMM8_X1 +-@deffnx {} BFD_RELOC_TILEGX_MT_IMM14_X1 +-@deffnx {} BFD_RELOC_TILEGX_MF_IMM14_X1 +-@deffnx {} BFD_RELOC_TILEGX_MMSTART_X0 +-@deffnx {} BFD_RELOC_TILEGX_MMEND_X0 +-@deffnx {} BFD_RELOC_TILEGX_SHAMT_X0 +-@deffnx {} BFD_RELOC_TILEGX_SHAMT_X1 +-@deffnx {} BFD_RELOC_TILEGX_SHAMT_Y0 +-@deffnx {} BFD_RELOC_TILEGX_SHAMT_Y1 +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0 +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0 +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1 +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1 +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2 +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2 +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW3 +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW3 +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW3_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW3_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_GOT +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_GOT +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_GOT +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_GOT +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_GOT +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_GOT +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW3_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW3_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_GD +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_GD +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_LE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_LE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_LE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_LE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_LE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_LE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_GD +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_GD +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_GD +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_GD +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_IE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_IE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_IE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_IE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_IE +-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_IE +-@deffnx {} BFD_RELOC_TILEGX_TLS_DTPMOD64 +-@deffnx {} BFD_RELOC_TILEGX_TLS_DTPOFF64 +-@deffnx {} BFD_RELOC_TILEGX_TLS_TPOFF64 +-@deffnx {} BFD_RELOC_TILEGX_TLS_DTPMOD32 +-@deffnx {} BFD_RELOC_TILEGX_TLS_DTPOFF32 +-@deffnx {} BFD_RELOC_TILEGX_TLS_TPOFF32 +-@deffnx {} BFD_RELOC_TILEGX_TLS_GD_CALL +-@deffnx {} BFD_RELOC_TILEGX_IMM8_X0_TLS_GD_ADD +-@deffnx {} BFD_RELOC_TILEGX_IMM8_X1_TLS_GD_ADD +-@deffnx {} BFD_RELOC_TILEGX_IMM8_Y0_TLS_GD_ADD +-@deffnx {} BFD_RELOC_TILEGX_IMM8_Y1_TLS_GD_ADD +-@deffnx {} BFD_RELOC_TILEGX_TLS_IE_LOAD +-@deffnx {} BFD_RELOC_TILEGX_IMM8_X0_TLS_ADD +-@deffnx {} BFD_RELOC_TILEGX_IMM8_X1_TLS_ADD +-@deffnx {} BFD_RELOC_TILEGX_IMM8_Y0_TLS_ADD +-@deffnx {} BFD_RELOC_TILEGX_IMM8_Y1_TLS_ADD +-Tilera TILE-Gx Relocations. +-@end deffn +-@deffn {} BFD_RELOC_BPF_64 +-@deffnx {} BFD_RELOC_BPF_DISP32 +-@deffnx {} BFD_RELOC_BPF_DISPCALL32 +-@deffnx {} BFD_RELOC_BPF_DISP16 +-Linux eBPF relocations. +-@end deffn +-@deffn {} BFD_RELOC_EPIPHANY_SIMM8 +-Adapteva EPIPHANY - 8 bit signed pc-relative displacement +-@end deffn +-@deffn {} BFD_RELOC_EPIPHANY_SIMM24 +-Adapteva EPIPHANY - 24 bit signed pc-relative displacement +-@end deffn +-@deffn {} BFD_RELOC_EPIPHANY_HIGH +-Adapteva EPIPHANY - 16 most-significant bits of absolute address +-@end deffn +-@deffn {} BFD_RELOC_EPIPHANY_LOW +-Adapteva EPIPHANY - 16 least-significant bits of absolute address +-@end deffn +-@deffn {} BFD_RELOC_EPIPHANY_SIMM11 +-Adapteva EPIPHANY - 11 bit signed number - add/sub immediate +-@end deffn +-@deffn {} BFD_RELOC_EPIPHANY_IMM11 +-Adapteva EPIPHANY - 11 bit sign-magnitude number (ld/st displacement) +-@end deffn +-@deffn {} BFD_RELOC_EPIPHANY_IMM8 +-Adapteva EPIPHANY - 8 bit immediate for 16 bit mov instruction. +-@end deffn +-@deffn {} BFD_RELOC_VISIUM_HI16 +-@deffnx {} BFD_RELOC_VISIUM_LO16 +-@deffnx {} BFD_RELOC_VISIUM_IM16 +-@deffnx {} BFD_RELOC_VISIUM_REL16 +-@deffnx {} BFD_RELOC_VISIUM_HI16_PCREL +-@deffnx {} BFD_RELOC_VISIUM_LO16_PCREL +-@deffnx {} BFD_RELOC_VISIUM_IM16_PCREL +-Visium Relocations. +-@end deffn +-@deffn {} BFD_RELOC_WASM32_LEB128 +-@deffnx {} BFD_RELOC_WASM32_LEB128_GOT +-@deffnx {} BFD_RELOC_WASM32_LEB128_GOT_CODE +-@deffnx {} BFD_RELOC_WASM32_LEB128_PLT +-@deffnx {} BFD_RELOC_WASM32_PLT_INDEX +-@deffnx {} BFD_RELOC_WASM32_ABS32_CODE +-@deffnx {} BFD_RELOC_WASM32_COPY +-@deffnx {} BFD_RELOC_WASM32_CODE_POINTER +-@deffnx {} BFD_RELOC_WASM32_INDEX +-@deffnx {} BFD_RELOC_WASM32_PLT_SIG +-WebAssembly relocations. +-@end deffn +-@deffn {} BFD_RELOC_CKCORE_NONE +-@deffnx {} BFD_RELOC_CKCORE_ADDR32 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_IMM8BY4 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_IMM11BY2 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_IMM4BY2 +-@deffnx {} BFD_RELOC_CKCORE_PCREL32 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_JSR_IMM11BY2 +-@deffnx {} BFD_RELOC_CKCORE_GNU_VTINHERIT +-@deffnx {} BFD_RELOC_CKCORE_GNU_VTENTRY +-@deffnx {} BFD_RELOC_CKCORE_RELATIVE +-@deffnx {} BFD_RELOC_CKCORE_COPY +-@deffnx {} BFD_RELOC_CKCORE_GLOB_DAT +-@deffnx {} BFD_RELOC_CKCORE_JUMP_SLOT +-@deffnx {} BFD_RELOC_CKCORE_GOTOFF +-@deffnx {} BFD_RELOC_CKCORE_GOTPC +-@deffnx {} BFD_RELOC_CKCORE_GOT32 +-@deffnx {} BFD_RELOC_CKCORE_PLT32 +-@deffnx {} BFD_RELOC_CKCORE_ADDRGOT +-@deffnx {} BFD_RELOC_CKCORE_ADDRPLT +-@deffnx {} BFD_RELOC_CKCORE_PCREL_IMM26BY2 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_IMM16BY2 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_IMM16BY4 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_IMM10BY2 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_IMM10BY4 +-@deffnx {} BFD_RELOC_CKCORE_ADDR_HI16 +-@deffnx {} BFD_RELOC_CKCORE_ADDR_LO16 +-@deffnx {} BFD_RELOC_CKCORE_GOTPC_HI16 +-@deffnx {} BFD_RELOC_CKCORE_GOTPC_LO16 +-@deffnx {} BFD_RELOC_CKCORE_GOTOFF_HI16 +-@deffnx {} BFD_RELOC_CKCORE_GOTOFF_LO16 +-@deffnx {} BFD_RELOC_CKCORE_GOT12 +-@deffnx {} BFD_RELOC_CKCORE_GOT_HI16 +-@deffnx {} BFD_RELOC_CKCORE_GOT_LO16 +-@deffnx {} BFD_RELOC_CKCORE_PLT12 +-@deffnx {} BFD_RELOC_CKCORE_PLT_HI16 +-@deffnx {} BFD_RELOC_CKCORE_PLT_LO16 +-@deffnx {} BFD_RELOC_CKCORE_ADDRGOT_HI16 +-@deffnx {} BFD_RELOC_CKCORE_ADDRGOT_LO16 +-@deffnx {} BFD_RELOC_CKCORE_ADDRPLT_HI16 +-@deffnx {} BFD_RELOC_CKCORE_ADDRPLT_LO16 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_JSR_IMM26BY2 +-@deffnx {} BFD_RELOC_CKCORE_TOFFSET_LO16 +-@deffnx {} BFD_RELOC_CKCORE_DOFFSET_LO16 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_IMM18BY2 +-@deffnx {} BFD_RELOC_CKCORE_DOFFSET_IMM18 +-@deffnx {} BFD_RELOC_CKCORE_DOFFSET_IMM18BY2 +-@deffnx {} BFD_RELOC_CKCORE_DOFFSET_IMM18BY4 +-@deffnx {} BFD_RELOC_CKCORE_GOTOFF_IMM18 +-@deffnx {} BFD_RELOC_CKCORE_GOT_IMM18BY4 +-@deffnx {} BFD_RELOC_CKCORE_PLT_IMM18BY4 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_IMM7BY4 +-@deffnx {} BFD_RELOC_CKCORE_TLS_LE32 +-@deffnx {} BFD_RELOC_CKCORE_TLS_IE32 +-@deffnx {} BFD_RELOC_CKCORE_TLS_GD32 +-@deffnx {} BFD_RELOC_CKCORE_TLS_LDM32 +-@deffnx {} BFD_RELOC_CKCORE_TLS_LDO32 +-@deffnx {} BFD_RELOC_CKCORE_TLS_DTPMOD32 +-@deffnx {} BFD_RELOC_CKCORE_TLS_DTPOFF32 +-@deffnx {} BFD_RELOC_CKCORE_TLS_TPOFF32 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_FLRW_IMM8BY4 +-@deffnx {} BFD_RELOC_CKCORE_NOJSRI +-@deffnx {} BFD_RELOC_CKCORE_CALLGRAPH +-@deffnx {} BFD_RELOC_CKCORE_IRELATIVE +-@deffnx {} BFD_RELOC_CKCORE_PCREL_BLOOP_IMM4BY4 +-@deffnx {} BFD_RELOC_CKCORE_PCREL_BLOOP_IMM12BY4 +-C-SKY relocations. +-@end deffn +-@deffn {} BFD_RELOC_S12Z_OPR +-S12Z relocations. +-@end deffn +-@deffn {} BFD_RELOC_LARCH_TLS_DTPMOD32 +-@deffnx {} BFD_RELOC_LARCH_TLS_DTPREL32 +-@deffnx {} BFD_RELOC_LARCH_TLS_DTPMOD64 +-@deffnx {} BFD_RELOC_LARCH_TLS_DTPREL64 +-@deffnx {} BFD_RELOC_LARCH_TLS_TPREL32 +-@deffnx {} BFD_RELOC_LARCH_TLS_TPREL64 +-@deffnx {} BFD_RELOC_LARCH_MARK_LA +-@deffnx {} BFD_RELOC_LARCH_MARK_PCREL +-@deffnx {} BFD_RELOC_LARCH_SOP_PUSH_PCREL +-@deffnx {} BFD_RELOC_LARCH_SOP_PUSH_ABSOLUTE +-@deffnx {} BFD_RELOC_LARCH_SOP_PUSH_DUP +-@deffnx {} BFD_RELOC_LARCH_SOP_PUSH_GPREL +-@deffnx {} BFD_RELOC_LARCH_SOP_PUSH_TLS_TPREL +-@deffnx {} BFD_RELOC_LARCH_SOP_PUSH_TLS_GOT +-@deffnx {} BFD_RELOC_LARCH_SOP_PUSH_TLS_GD +-@deffnx {} BFD_RELOC_LARCH_SOP_PUSH_PLT_PCREL +-@deffnx {} BFD_RELOC_LARCH_SOP_ASSERT +-@deffnx {} BFD_RELOC_LARCH_SOP_NOT +-@deffnx {} BFD_RELOC_LARCH_SOP_SUB +-@deffnx {} BFD_RELOC_LARCH_SOP_SL +-@deffnx {} BFD_RELOC_LARCH_SOP_SR +-@deffnx {} BFD_RELOC_LARCH_SOP_ADD +-@deffnx {} BFD_RELOC_LARCH_SOP_AND +-@deffnx {} BFD_RELOC_LARCH_SOP_IF_ELSE +-@deffnx {} BFD_RELOC_LARCH_SOP_POP_32_S_10_5 +-@deffnx {} BFD_RELOC_LARCH_SOP_POP_32_U_10_12 +-@deffnx {} BFD_RELOC_LARCH_SOP_POP_32_S_10_12 +-@deffnx {} BFD_RELOC_LARCH_SOP_POP_32_S_10_16 +-@deffnx {} BFD_RELOC_LARCH_SOP_POP_32_S_10_16_S2 +-@deffnx {} BFD_RELOC_LARCH_SOP_POP_32_S_5_20 +-@deffnx {} BFD_RELOC_LARCH_SOP_POP_32_S_0_5_10_16_S2 +-@deffnx {} BFD_RELOC_LARCH_SOP_POP_32_S_0_10_10_16_S2 +-@deffnx {} BFD_RELOC_LARCH_SOP_POP_32_U +-@deffnx {} BFD_RELOC_LARCH_ADD8 +-@deffnx {} BFD_RELOC_LARCH_ADD16 +-@deffnx {} BFD_RELOC_LARCH_ADD24 +-@deffnx {} BFD_RELOC_LARCH_ADD32 +-@deffnx {} BFD_RELOC_LARCH_ADD64 +-@deffnx {} BFD_RELOC_LARCH_SUB8 +-@deffnx {} BFD_RELOC_LARCH_SUB16 +-@deffnx {} BFD_RELOC_LARCH_SUB24 +-@deffnx {} BFD_RELOC_LARCH_SUB32 +-@deffnx {} BFD_RELOC_LARCH_SUB64 +-@deffnx {} BFD_RELOC_LARCH_B16 +-@deffnx {} BFD_RELOC_LARCH_B21 +-@deffnx {} BFD_RELOC_LARCH_B26 +-@deffnx {} BFD_RELOC_LARCH_ABS_HI20 +-@deffnx {} BFD_RELOC_LARCH_ABS_LO12 +-@deffnx {} BFD_RELOC_LARCH_ABS64_LO20 +-@deffnx {} BFD_RELOC_LARCH_ABS64_HI12 +-@deffnx {} BFD_RELOC_LARCH_PCALA_HI20 +-@deffnx {} BFD_RELOC_LARCH_PCALA_LO12 +-@deffnx {} BFD_RELOC_LARCH_PCALA64_LO20 +-@deffnx {} BFD_RELOC_LARCH_PCALA64_HI12 +-@deffnx {} BFD_RELOC_LARCH_GOT_PC_HI20 +-@deffnx {} BFD_RELOC_LARCH_GOT_PC_LO12 +-@deffnx {} BFD_RELOC_LARCH_GOT64_PC_LO20 +-@deffnx {} BFD_RELOC_LARCH_GOT64_PC_HI12 +-@deffnx {} BFD_RELOC_LARCH_GOT_HI20 +-@deffnx {} BFD_RELOC_LARCH_GOT_LO12 +-@deffnx {} BFD_RELOC_LARCH_GOT64_LO20 +-@deffnx {} BFD_RELOC_LARCH_GOT64_HI12 +-@deffnx {} BFD_RELOC_LARCH_TLS_LE_HI20 +-@deffnx {} BFD_RELOC_LARCH_TLS_LE_LO12 +-@deffnx {} BFD_RELOC_LARCH_TLS_LE64_LO20 +-@deffnx {} BFD_RELOC_LARCH_TLS_LE64_HI12 +-@deffnx {} BFD_RELOC_LARCH_TLS_IE_PC_HI20 +-@deffnx {} BFD_RELOC_LARCH_TLS_IE_PC_LO12 +-@deffnx {} BFD_RELOC_LARCH_TLS_IE64_PC_LO20 +-@deffnx {} BFD_RELOC_LARCH_TLS_IE64_PC_HI12 +-@deffnx {} BFD_RELOC_LARCH_TLS_IE_HI20 +-@deffnx {} BFD_RELOC_LARCH_TLS_IE_LO12 +-@deffnx {} BFD_RELOC_LARCH_TLS_IE64_LO20 +-@deffnx {} BFD_RELOC_LARCH_TLS_IE64_HI12 +-@deffnx {} BFD_RELOC_LARCH_TLS_LD_PC_HI20 +-@deffnx {} BFD_RELOC_LARCH_TLS_LD_HI20 +-@deffnx {} BFD_RELOC_LARCH_TLS_GD_PC_HI20 +-@deffnx {} BFD_RELOC_LARCH_TLS_GD_HI20 +-@deffnx {} BFD_RELOC_LARCH_32_PCREL +-@deffnx {} BFD_RELOC_LARCH_RELAX +-@deffnx {} BFD_RELOC_LARCH_DELETE +-@deffnx {} BFD_RELOC_LARCH_ALIGN +-@deffnx {} BFD_RELOC_LARCH_PCREL20_S2 +-@deffnx {} BFD_RELOC_LARCH_CFA +-@deffnx {} BFD_RELOC_LARCH_ADD6 +-@deffnx {} BFD_RELOC_LARCH_SUB6 +-@deffnx {} BFD_RELOC_LARCH_ADD_ULEB128 +-@deffnx {} BFD_RELOC_LARCH_SUB_ULEB128 +-@deffnx {} BFD_RELOC_LARCH_64_PCREL +-LARCH relocations. +-@end deffn +- +-@example +-typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; +- +-@end example +-@findex bfd_reloc_type_lookup +-@subsubsection @code{bfd_reloc_type_lookup} +-@deftypefn {Function} reloc_howto_type *bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code); reloc_howto_type *bfd_reloc_name_lookup (bfd *abfd, const char *reloc_name); +-Return a pointer to a howto structure which, when +-invoked, will perform the relocation @var{code} on data from the +-architecture noted. +- +-@end deftypefn +-@findex bfd_default_reloc_type_lookup +-@subsubsection @code{bfd_default_reloc_type_lookup} +-@deftypefn {Function} reloc_howto_type *bfd_default_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code); +-Provides a default relocation lookup routine for any architecture. +- +-@end deftypefn +-@findex bfd_get_reloc_code_name +-@subsubsection @code{bfd_get_reloc_code_name} +-@deftypefn {Function} const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code); +-Provides a printable name for the supplied relocation code. +-Useful mainly for printing error messages. +- +-@end deftypefn +-@findex bfd_generic_relax_section +-@subsubsection @code{bfd_generic_relax_section} +-@deftypefn {Function} bool bfd_generic_relax_section (bfd *abfd, asection *section, struct bfd_link_info *, bool *); +-Provides default handling for relaxing for back ends which +-don't do relaxing. +- +-@end deftypefn +-@findex bfd_generic_gc_sections +-@subsubsection @code{bfd_generic_gc_sections} +-@deftypefn {Function} bool bfd_generic_gc_sections (bfd *, struct bfd_link_info *); +-Provides default handling for relaxing for back ends which +-don't do section gc -- i.e., does nothing. +- +-@end deftypefn +-@findex bfd_generic_lookup_section_flags +-@subsubsection @code{bfd_generic_lookup_section_flags} +-@deftypefn {Function} bool bfd_generic_lookup_section_flags (struct bfd_link_info *, struct flag_info *, asection *); +-Provides default handling for section flags lookup +--- i.e., does nothing. +-Returns FALSE if the section should be omitted, otherwise TRUE. +- +-@end deftypefn +-@findex bfd_generic_merge_sections +-@subsubsection @code{bfd_generic_merge_sections} +-@deftypefn {Function} bool bfd_generic_merge_sections (bfd *, struct bfd_link_info *); +-Provides default handling for SEC_MERGE section merging for back ends +-which don't have SEC_MERGE support -- i.e., does nothing. +- +-@end deftypefn +-@findex bfd_generic_get_relocated_section_contents +-@subsubsection @code{bfd_generic_get_relocated_section_contents} +-@deftypefn {Function} bfd_byte *bfd_generic_get_relocated_section_contents (bfd *abfd, struct bfd_link_info *link_info, struct bfd_link_order *link_order, bfd_byte *data, bool relocatable, asymbol **symbols); +-Provides default handling of relocation effort for back ends +-which can't be bothered to do it efficiently. +- +-@end deftypefn +-@findex _bfd_generic_set_reloc +-@subsubsection @code{_bfd_generic_set_reloc} +-@deftypefn {Function} void _bfd_generic_set_reloc (bfd *abfd, sec_ptr section, arelent **relptr, unsigned int count); +-Installs a new set of internal relocations in SECTION. +- +-@end deftypefn +-@findex _bfd_unrecognized_reloc +-@subsubsection @code{_bfd_unrecognized_reloc} +-@deftypefn {Function} bool _bfd_unrecognized_reloc (bfd * abfd, sec_ptr section, unsigned int r_type); +-Reports an unrecognized reloc. +-Written as a function in order to reduce code duplication. +-Returns FALSE so that it can be called from a return statement. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/section.texi gdb-14.1-sw64/bfd/doc/section.texi +--- gdb-14.1-after-patch/bfd/doc/section.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/section.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,826 +0,0 @@ +-@section Sections +-The raw data contained within a BFD is maintained through the +-section abstraction. A single BFD may have any number of +-sections. It keeps hold of them by pointing to the first; +-each one points to the next in the list. +- +-Sections are supported in BFD in @code{section.c}. +- +-@menu +-* Section Input:: +-* Section Output:: +-* typedef asection:: +-* section prototypes:: +-@end menu +- +-@node Section Input, Section Output, Sections, Sections +-@subsection Section input +-When a BFD is opened for reading, the section structures are +-created and attached to the BFD. +- +-Each section has a name which describes the section in the +-outside world---for example, @code{a.out} would contain at least +-three sections, called @code{.text}, @code{.data} and @code{.bss}. +- +-Names need not be unique; for example a COFF file may have several +-sections named @code{.data}. +- +-Sometimes a BFD will contain more than the ``natural'' number of +-sections. A back end may attach other sections containing +-constructor data, or an application may add a section (using +-@code{bfd_make_section}) to the sections attached to an already open +-BFD. For example, the linker creates an extra section +-@code{COMMON} for each input file's BFD to hold information about +-common storage. +- +-The raw data is not necessarily read in when +-the section descriptor is created. Some targets may leave the +-data in place until a @code{bfd_get_section_contents} call is +-made. Other back ends may read in all the data at once. For +-example, an S-record file has to be read once to determine the +-size of the data. +- +-@node Section Output, typedef asection, Section Input, Sections +-@subsection Section output +-To write a new object style BFD, the various sections to be +-written have to be created. They are attached to the BFD in +-the same way as input sections; data is written to the +-sections using @code{bfd_set_section_contents}. +- +-Any program that creates or combines sections (e.g., the assembler +-and linker) must use the @code{asection} fields @code{output_section} and +-@code{output_offset} to indicate the file sections to which each +-section must be written. (If the section is being created from +-scratch, @code{output_section} should probably point to the section +-itself and @code{output_offset} should probably be zero.) +- +-The data to be written comes from input sections attached +-(via @code{output_section} pointers) to +-the output sections. The output section structure can be +-considered a filter for the input section: the output section +-determines the vma of the output data and the name, but the +-input section determines the offset into the output section of +-the data to be written. +- +-E.g., to create a section "O", starting at 0x100, 0x123 long, +-containing two subsections, "A" at offset 0x0 (i.e., at vma +-0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the @code{asection} +-structures would look like: +- +-@example +- section name "A" +- output_offset 0x00 +- size 0x20 +- output_section -----------> section name "O" +- | vma 0x100 +- section name "B" | size 0x123 +- output_offset 0x20 | +- size 0x103 | +- output_section --------| +-@end example +- +-@subsection Link orders +-The data within a section is stored in a @dfn{link_order}. +-These are much like the fixups in @code{gas}. The link_order +-abstraction allows a section to grow and shrink within itself. +- +-A link_order knows how big it is, and which is the next +-link_order and where the raw data for it is; it also points to +-a list of relocations which apply to it. +- +-The link_order is used by the linker to perform relaxing on +-final code. The compiler creates code which is as big as +-necessary to make it work without relaxing, and the user can +-select whether to relax. Sometimes relaxing takes a lot of +-time. The linker runs around the relocations to see if any +-are attached to data which can be shrunk, if so it does it on +-a link_order by link_order basis. +- +- +-@node typedef asection, section prototypes, Section Output, Sections +-@subsection typedef asection +-Here is the section structure: +- +- +-@example +-typedef struct bfd_section +-@{ +- /* The name of the section; the name isn't a copy, the pointer is +- the same as that passed to bfd_make_section. */ +- const char *name; +- +- /* The next section in the list belonging to the BFD, or NULL. */ +- struct bfd_section *next; +- +- /* The previous section in the list belonging to the BFD, or NULL. */ +- struct bfd_section *prev; +- +- /* A unique sequence number. */ +- unsigned int id; +- +- /* A unique section number which can be used by assembler to +- distinguish different sections with the same section name. */ +- unsigned int section_id; +- +- /* Which section in the bfd; 0..n-1 as sections are created in a bfd. */ +- unsigned int index; +- +- /* The field flags contains attributes of the section. Some +- flags are read in from the object file, and some are +- synthesized from other information. */ +- flagword flags; +- +-#define SEC_NO_FLAGS 0x0 +- +- /* Tells the OS to allocate space for this section when loading. +- This is clear for a section containing debug information only. */ +-#define SEC_ALLOC 0x1 +- +- /* Tells the OS to load the section from the file when loading. +- This is clear for a .bss section. */ +-#define SEC_LOAD 0x2 +- +- /* The section contains data still to be relocated, so there is +- some relocation information too. */ +-#define SEC_RELOC 0x4 +- +- /* A signal to the OS that the section contains read only data. */ +-#define SEC_READONLY 0x8 +- +- /* The section contains code only. */ +-#define SEC_CODE 0x10 +- +- /* The section contains data only. */ +-#define SEC_DATA 0x20 +- +- /* The section will reside in ROM. */ +-#define SEC_ROM 0x40 +- +- /* The section contains constructor information. This section +- type is used by the linker to create lists of constructors and +- destructors used by @code{g++}. When a back end sees a symbol +- which should be used in a constructor list, it creates a new +- section for the type of name (e.g., @code{__CTOR_LIST__}), attaches +- the symbol to it, and builds a relocation. To build the lists +- of constructors, all the linker has to do is catenate all the +- sections called @code{__CTOR_LIST__} and relocate the data +- contained within - exactly the operations it would peform on +- standard data. */ +-#define SEC_CONSTRUCTOR 0x80 +- +- /* The section has contents - a data section could be +- @code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}; a debug section could be +- @code{SEC_HAS_CONTENTS} */ +-#define SEC_HAS_CONTENTS 0x100 +- +- /* An instruction to the linker to not output the section +- even if it has information which would normally be written. */ +-#define SEC_NEVER_LOAD 0x200 +- +- /* The section contains thread local data. */ +-#define SEC_THREAD_LOCAL 0x400 +- +- /* The section's size is fixed. Generic linker code will not +- recalculate it and it is up to whoever has set this flag to +- get the size right. */ +-#define SEC_FIXED_SIZE 0x800 +- +- /* The section contains common symbols (symbols may be defined +- multiple times, the value of a symbol is the amount of +- space it requires, and the largest symbol value is the one +- used). Most targets have exactly one of these (which we +- translate to bfd_com_section_ptr), but ECOFF has two. */ +-#define SEC_IS_COMMON 0x1000 +- +- /* The section contains only debugging information. For +- example, this is set for ELF .debug and .stab sections. +- strip tests this flag to see if a section can be +- discarded. */ +-#define SEC_DEBUGGING 0x2000 +- +- /* The contents of this section are held in memory pointed to +- by the contents field. This is checked by bfd_get_section_contents, +- and the data is retrieved from memory if appropriate. */ +-#define SEC_IN_MEMORY 0x4000 +- +- /* The contents of this section are to be excluded by the +- linker for executable and shared objects unless those +- objects are to be further relocated. */ +-#define SEC_EXCLUDE 0x8000 +- +- /* The contents of this section are to be sorted based on the sum of +- the symbol and addend values specified by the associated relocation +- entries. Entries without associated relocation entries will be +- appended to the end of the section in an unspecified order. */ +-#define SEC_SORT_ENTRIES 0x10000 +- +- /* When linking, duplicate sections of the same name should be +- discarded, rather than being combined into a single section as +- is usually done. This is similar to how common symbols are +- handled. See SEC_LINK_DUPLICATES below. */ +-#define SEC_LINK_ONCE 0x20000 +- +- /* If SEC_LINK_ONCE is set, this bitfield describes how the linker +- should handle duplicate sections. */ +-#define SEC_LINK_DUPLICATES 0xc0000 +- +- /* This value for SEC_LINK_DUPLICATES means that duplicate +- sections with the same name should simply be discarded. */ +-#define SEC_LINK_DUPLICATES_DISCARD 0x0 +- +- /* This value for SEC_LINK_DUPLICATES means that the linker +- should warn if there are any duplicate sections, although +- it should still only link one copy. */ +-#define SEC_LINK_DUPLICATES_ONE_ONLY 0x40000 +- +- /* This value for SEC_LINK_DUPLICATES means that the linker +- should warn if any duplicate sections are a different size. */ +-#define SEC_LINK_DUPLICATES_SAME_SIZE 0x80000 +- +- /* This value for SEC_LINK_DUPLICATES means that the linker +- should warn if any duplicate sections contain different +- contents. */ +-#define SEC_LINK_DUPLICATES_SAME_CONTENTS \ +- (SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE) +- +- /* This section was created by the linker as part of dynamic +- relocation or other arcane processing. It is skipped when +- going through the first-pass output, trusting that someone +- else up the line will take care of it later. */ +-#define SEC_LINKER_CREATED 0x100000 +- +- /* This section contains a section ID to distinguish different +- sections with the same section name. */ +-#define SEC_ASSEMBLER_SECTION_ID 0x100000 +- +- /* This section should not be subject to garbage collection. +- Also set to inform the linker that this section should not be +- listed in the link map as discarded. */ +-#define SEC_KEEP 0x200000 +- +- /* This section contains "short" data, and should be placed +- "near" the GP. */ +-#define SEC_SMALL_DATA 0x400000 +- +- /* Attempt to merge identical entities in the section. +- Entity size is given in the entsize field. */ +-#define SEC_MERGE 0x800000 +- +- /* If given with SEC_MERGE, entities to merge are zero terminated +- strings where entsize specifies character size instead of fixed +- size entries. */ +-#define SEC_STRINGS 0x1000000 +- +- /* This section contains data about section groups. */ +-#define SEC_GROUP 0x2000000 +- +- /* The section is a COFF shared library section. This flag is +- only for the linker. If this type of section appears in +- the input file, the linker must copy it to the output file +- without changing the vma or size. FIXME: Although this +- was originally intended to be general, it really is COFF +- specific (and the flag was renamed to indicate this). It +- might be cleaner to have some more general mechanism to +- allow the back end to control what the linker does with +- sections. */ +-#define SEC_COFF_SHARED_LIBRARY 0x4000000 +- +- /* This input section should be copied to output in reverse order +- as an array of pointers. This is for ELF linker internal use +- only. */ +-#define SEC_ELF_REVERSE_COPY 0x4000000 +- +- /* This section contains data which may be shared with other +- executables or shared objects. This is for COFF only. */ +-#define SEC_COFF_SHARED 0x8000000 +- +- /* Indicate that section has the purecode flag set. */ +-#define SEC_ELF_PURECODE 0x8000000 +- +- /* When a section with this flag is being linked, then if the size of +- the input section is less than a page, it should not cross a page +- boundary. If the size of the input section is one page or more, +- it should be aligned on a page boundary. This is for TI +- TMS320C54X only. */ +-#define SEC_TIC54X_BLOCK 0x10000000 +- +- /* This section has the SHF_X86_64_LARGE flag. This is ELF x86-64 only. */ +-#define SEC_ELF_LARGE 0x10000000 +- +- /* Conditionally link this section; do not link if there are no +- references found to any symbol in the section. This is for TI +- TMS320C54X only. */ +-#define SEC_TIC54X_CLINK 0x20000000 +- +- /* This section contains vliw code. This is for Toshiba MeP only. */ +-#define SEC_MEP_VLIW 0x20000000 +- +- /* All symbols, sizes and relocations in this section are octets +- instead of bytes. Required for DWARF debug sections as DWARF +- information is organized in octets, not bytes. */ +-#define SEC_ELF_OCTETS 0x40000000 +- +- /* Indicate that section has the no read flag set. This happens +- when memory read flag isn't set. */ +-#define SEC_COFF_NOREAD 0x40000000 +- +- /* End of section flags. */ +- +- /* Some internal packed boolean fields. */ +- +- /* See the vma field. */ +- unsigned int user_set_vma : 1; +- +- /* A mark flag used by some of the linker backends. */ +- unsigned int linker_mark : 1; +- +- /* Another mark flag used by some of the linker backends. Set for +- output sections that have an input section. */ +- unsigned int linker_has_input : 1; +- +- /* Mark flag used by some linker backends for garbage collection. */ +- unsigned int gc_mark : 1; +- +- /* Section compression status. */ +- unsigned int compress_status : 2; +-#define COMPRESS_SECTION_NONE 0 +-#define COMPRESS_SECTION_DONE 1 +-#define DECOMPRESS_SECTION_ZLIB 2 +-#define DECOMPRESS_SECTION_ZSTD 3 +- +- /* The following flags are used by the ELF linker. */ +- +- /* Mark sections which have been allocated to segments. */ +- unsigned int segment_mark : 1; +- +- /* Type of sec_info information. */ +- unsigned int sec_info_type:3; +-#define SEC_INFO_TYPE_NONE 0 +-#define SEC_INFO_TYPE_STABS 1 +-#define SEC_INFO_TYPE_MERGE 2 +-#define SEC_INFO_TYPE_EH_FRAME 3 +-#define SEC_INFO_TYPE_JUST_SYMS 4 +-#define SEC_INFO_TYPE_TARGET 5 +-#define SEC_INFO_TYPE_EH_FRAME_ENTRY 6 +-#define SEC_INFO_TYPE_SFRAME 7 +- +- /* Nonzero if this section uses RELA relocations, rather than REL. */ +- unsigned int use_rela_p:1; +- +- /* Bits used by various backends. The generic code doesn't touch +- these fields. */ +- +- unsigned int sec_flg0:1; +- unsigned int sec_flg1:1; +- unsigned int sec_flg2:1; +- unsigned int sec_flg3:1; +- unsigned int sec_flg4:1; +- unsigned int sec_flg5:1; +- +- /* End of internal packed boolean fields. */ +- +- /* The virtual memory address of the section - where it will be +- at run time. The symbols are relocated against this. The +- user_set_vma flag is maintained by bfd; if it's not set, the +- backend can assign addresses (for example, in @code{a.out}, where +- the default address for @code{.data} is dependent on the specific +- target and various flags). */ +- bfd_vma vma; +- +- /* The load address of the section - where it would be in a +- rom image; really only used for writing section header +- information. */ +- bfd_vma lma; +- +- /* The size of the section in *octets*, as it will be output. +- Contains a value even if the section has no contents (e.g., the +- size of @code{.bss}). */ +- bfd_size_type size; +- +- /* For input sections, the original size on disk of the section, in +- octets. This field should be set for any section whose size is +- changed by linker relaxation. It is required for sections where +- the linker relaxation scheme doesn't cache altered section and +- reloc contents (stabs, eh_frame, SEC_MERGE, some coff relaxing +- targets), and thus the original size needs to be kept to read the +- section multiple times. For output sections, rawsize holds the +- section size calculated on a previous linker relaxation pass. */ +- bfd_size_type rawsize; +- +- /* The compressed size of the section in octets. */ +- bfd_size_type compressed_size; +- +- /* If this section is going to be output, then this value is the +- offset in *bytes* into the output section of the first byte in the +- input section (byte ==> smallest addressable unit on the +- target). In most cases, if this was going to start at the +- 100th octet (8-bit quantity) in the output section, this value +- would be 100. However, if the target byte size is 16 bits +- (bfd_octets_per_byte is "2"), this value would be 50. */ +- bfd_vma output_offset; +- +- /* The output section through which to map on output. */ +- struct bfd_section *output_section; +- +- /* If an input section, a pointer to a vector of relocation +- records for the data in this section. */ +- struct reloc_cache_entry *relocation; +- +- /* If an output section, a pointer to a vector of pointers to +- relocation records for the data in this section. */ +- struct reloc_cache_entry **orelocation; +- +- /* The number of relocation records in one of the above. */ +- unsigned reloc_count; +- +- /* The alignment requirement of the section, as an exponent of 2 - +- e.g., 3 aligns to 2^3 (or 8). */ +- unsigned int alignment_power; +- +- /* Information below is back end specific - and not always used +- or updated. */ +- +- /* File position of section data. */ +- file_ptr filepos; +- +- /* File position of relocation info. */ +- file_ptr rel_filepos; +- +- /* File position of line data. */ +- file_ptr line_filepos; +- +- /* Pointer to data for applications. */ +- void *userdata; +- +- /* If the SEC_IN_MEMORY flag is set, this points to the actual +- contents. */ +- bfd_byte *contents; +- +- /* Attached line number information. */ +- alent *lineno; +- +- /* Number of line number records. */ +- unsigned int lineno_count; +- +- /* Entity size for merging purposes. */ +- unsigned int entsize; +- +- /* Points to the kept section if this section is a link-once section, +- and is discarded. */ +- struct bfd_section *kept_section; +- +- /* When a section is being output, this value changes as more +- linenumbers are written out. */ +- file_ptr moving_line_filepos; +- +- /* What the section number is in the target world. */ +- int target_index; +- +- void *used_by_bfd; +- +- /* If this is a constructor section then here is a list of the +- relocations created to relocate items within it. */ +- struct relent_chain *constructor_chain; +- +- /* The BFD which owns the section. */ +- bfd *owner; +- +- /* A symbol which points at this section only. */ +- struct bfd_symbol *symbol; +- struct bfd_symbol **symbol_ptr_ptr; +- +- /* Early in the link process, map_head and map_tail are used to build +- a list of input sections attached to an output section. Later, +- output sections use these fields for a list of bfd_link_order +- structs. The linked_to_symbol_name field is for ELF assembler +- internal use. */ +- union @{ +- struct bfd_link_order *link_order; +- struct bfd_section *s; +- const char *linked_to_symbol_name; +- @} map_head, map_tail; +- +- /* Points to the output section this section is already assigned to, +- if any. This is used when support for non-contiguous memory +- regions is enabled. */ +- struct bfd_section *already_assigned; +- +- /* Explicitly specified section type, if non-zero. */ +- unsigned int type; +- +-@} asection; +- +-@end example +- +-@node section prototypes, , typedef asection, Sections +-@subsection Section prototypes +-These are the functions exported by the section handling part of BFD. +- +-@findex bfd_section_list_clear +-@subsubsection @code{bfd_section_list_clear} +-@deftypefn {Function} void bfd_section_list_clear (bfd *); +-Clears the section list, and also resets the section count and +-hash table entries. +- +-@end deftypefn +-@findex bfd_get_section_by_name +-@subsubsection @code{bfd_get_section_by_name} +-@deftypefn {Function} asection *bfd_get_section_by_name (bfd *abfd, const char *name); +-Return the most recently created section attached to @var{abfd} +-named @var{name}. Return NULL if no such section exists. +- +-@end deftypefn +-@findex bfd_get_next_section_by_name +-@subsubsection @code{bfd_get_next_section_by_name} +-@deftypefn {Function} asection *bfd_get_next_section_by_name (bfd *ibfd, asection *sec); +-Given @var{sec} is a section returned by @code{bfd_get_section_by_name}, +-return the next most recently created section attached to the same +-BFD with the same name, or if no such section exists in the same BFD and +-IBFD is non-NULL, the next section with the same name in any input +-BFD following IBFD. Return NULL on finding no section. +- +-@end deftypefn +-@findex bfd_get_linker_section +-@subsubsection @code{bfd_get_linker_section} +-@deftypefn {Function} asection *bfd_get_linker_section (bfd *abfd, const char *name); +-Return the linker created section attached to @var{abfd} +-named @var{name}. Return NULL if no such section exists. +- +-@end deftypefn +-@findex bfd_get_section_by_name_if +-@subsubsection @code{bfd_get_section_by_name_if} +-@deftypefn {Function} asection *bfd_get_section_by_name_if (bfd *abfd, const char *name, bool (*func) (bfd *abfd, asection *sect, void *obj), void *obj); +-Call the provided function @var{func} for each section +-attached to the BFD @var{abfd} whose name matches @var{name}, +-passing @var{obj} as an argument. The function will be called +-as if by +- +-@example +- func (abfd, the_section, obj); +-@end example +- +-It returns the first section for which @var{func} returns true, +-otherwise @code{NULL}. +- +-@end deftypefn +-@findex bfd_get_unique_section_name +-@subsubsection @code{bfd_get_unique_section_name} +-@deftypefn {Function} char *bfd_get_unique_section_name (bfd *abfd, const char *templat, int *count); +-Invent a section name that is unique in @var{abfd} by tacking +-a dot and a digit suffix onto the original @var{templat}. If +-@var{count} is non-NULL, then it specifies the first number +-tried as a suffix to generate a unique name. The value +-pointed to by @var{count} will be incremented in this case. +- +-@end deftypefn +-@findex bfd_make_section_old_way +-@subsubsection @code{bfd_make_section_old_way} +-@deftypefn {Function} asection *bfd_make_section_old_way (bfd *abfd, const char *name); +-Create a new empty section called @var{name} +-and attach it to the end of the chain of sections for the +-BFD @var{abfd}. An attempt to create a section with a name which +-is already in use returns its pointer without changing the +-section chain. +- +-It has the funny name since this is the way it used to be +-before it was rewritten.... +- +-Possible errors are: +-@itemize @bullet +- +-@item +-@code{bfd_error_invalid_operation} - +-If output has already started for this BFD. +-@item +-@code{bfd_error_no_memory} - +-If memory allocation fails. +-@end itemize +- +-@end deftypefn +-@findex bfd_make_section_anyway_with_flags +-@subsubsection @code{bfd_make_section_anyway_with_flags} +-@deftypefn {Function} asection *bfd_make_section_anyway_with_flags (bfd *abfd, const char *name, flagword flags); +-Create a new empty section called @var{name} and attach it to the end of +-the chain of sections for @var{abfd}. Create a new section even if there +-is already a section with that name. Also set the attributes of the +-new section to the value @var{flags}. +- +-Return @code{NULL} and set @code{bfd_error} on error; possible errors are: +-@itemize @bullet +- +-@item +-@code{bfd_error_invalid_operation} - If output has already started for @var{abfd}. +-@item +-@code{bfd_error_no_memory} - If memory allocation fails. +-@end itemize +- +-@end deftypefn +-@findex bfd_make_section_anyway +-@subsubsection @code{bfd_make_section_anyway} +-@deftypefn {Function} asection *bfd_make_section_anyway (bfd *abfd, const char *name); +-Create a new empty section called @var{name} and attach it to the end of +-the chain of sections for @var{abfd}. Create a new section even if there +-is already a section with that name. +- +-Return @code{NULL} and set @code{bfd_error} on error; possible errors are: +-@itemize @bullet +- +-@item +-@code{bfd_error_invalid_operation} - If output has already started for @var{abfd}. +-@item +-@code{bfd_error_no_memory} - If memory allocation fails. +-@end itemize +- +-@end deftypefn +-@findex bfd_make_section_with_flags +-@subsubsection @code{bfd_make_section_with_flags} +-@deftypefn {Function} asection *bfd_make_section_with_flags (bfd *, const char *name, flagword flags); +-Like @code{bfd_make_section_anyway}, but return @code{NULL} (without calling +-bfd_set_error ()) without changing the section chain if there is already a +-section named @var{name}. Also set the attributes of the new section to +-the value @var{flags}. If there is an error, return @code{NULL} and set +-@code{bfd_error}. +- +-@end deftypefn +-@findex bfd_make_section +-@subsubsection @code{bfd_make_section} +-@deftypefn {Function} asection *bfd_make_section (bfd *, const char *name); +-Like @code{bfd_make_section_anyway}, but return @code{NULL} (without calling +-bfd_set_error ()) without changing the section chain if there is already a +-section named @var{name}. If there is an error, return @code{NULL} and set +-@code{bfd_error}. +- +-@end deftypefn +-@findex bfd_set_section_flags +-@subsubsection @code{bfd_set_section_flags} +-@deftypefn {Function} bool bfd_set_section_flags (asection *sec, flagword flags); +-Set the attributes of the section @var{sec} to the value @var{flags}. +-Return @code{TRUE} on success, @code{FALSE} on error. Possible error +-returns are: +- +-@itemize @bullet +- +-@item +-@code{bfd_error_invalid_operation} - +-The section cannot have one or more of the attributes +-requested. For example, a .bss section in @code{a.out} may not +-have the @code{SEC_HAS_CONTENTS} field set. +-@end itemize +- +-@end deftypefn +-@findex bfd_rename_section +-@subsubsection @code{bfd_rename_section} +-@deftypefn {Function} void bfd_rename_section (asection *sec, const char *newname); +-Rename section @var{sec} to @var{newname}. +- +-@end deftypefn +-@findex bfd_map_over_sections +-@subsubsection @code{bfd_map_over_sections} +-@deftypefn {Function} void bfd_map_over_sections (bfd *abfd, void (*func) (bfd *abfd, asection *sect, void *obj), void *obj); +-Call the provided function @var{func} for each section +-attached to the BFD @var{abfd}, passing @var{obj} as an +-argument. The function will be called as if by +- +-@example +- func (abfd, the_section, obj); +-@end example +- +-This is the preferred method for iterating over sections; an +-alternative would be to use a loop: +- +-@example +- asection *p; +- for (p = abfd->sections; p != NULL; p = p->next) +- func (abfd, p, ...) +-@end example +- +-@end deftypefn +-@findex bfd_sections_find_if +-@subsubsection @code{bfd_sections_find_if} +-@deftypefn {Function} asection *bfd_sections_find_if (bfd *abfd, bool (*operation) (bfd *abfd, asection *sect, void *obj), void *obj); +-Call the provided function @var{operation} for each section +-attached to the BFD @var{abfd}, passing @var{obj} as an +-argument. The function will be called as if by +- +-@example +- operation (abfd, the_section, obj); +-@end example +- +-It returns the first section for which @var{operation} returns true. +- +-@end deftypefn +-@findex bfd_set_section_size +-@subsubsection @code{bfd_set_section_size} +-@deftypefn {Function} bool bfd_set_section_size (asection *sec, bfd_size_type val); +-Set @var{sec} to the size @var{val}. If the operation is +-ok, then @code{TRUE} is returned, else @code{FALSE}. +- +-Possible error returns: +-@itemize @bullet +- +-@item +-@code{bfd_error_invalid_operation} - +-Writing has started to the BFD, so setting the size is invalid. +-@end itemize +- +-@end deftypefn +-@findex bfd_set_section_contents +-@subsubsection @code{bfd_set_section_contents} +-@deftypefn {Function} bool bfd_set_section_contents (bfd *abfd, asection *section, const void *data, file_ptr offset, bfd_size_type count); +-Sets the contents of the section @var{section} in BFD +-@var{abfd} to the data starting in memory at @var{location}. +-The data is written to the output section starting at offset +-@var{offset} for @var{count} octets. +- +-Normally @code{TRUE} is returned, but @code{FALSE} is returned if +-there was an error. Possible error returns are: +-@itemize @bullet +- +-@item +-@code{bfd_error_no_contents} - +-The output section does not have the @code{SEC_HAS_CONTENTS} +-attribute, so nothing can be written to it. +-@item +-@code{bfd_error_bad_value} - +-The section is unable to contain all of the data. +-@item +-@code{bfd_error_invalid_operation} - +-The BFD is not writeable. +-@item +-and some more too. +-@end itemize +-This routine is front end to the back end function +-@code{_bfd_set_section_contents}. +- +-@end deftypefn +-@findex bfd_get_section_contents +-@subsubsection @code{bfd_get_section_contents} +-@deftypefn {Function} bool bfd_get_section_contents (bfd *abfd, asection *section, void *location, file_ptr offset, bfd_size_type count); +-Read data from @var{section} in BFD @var{abfd} +-into memory starting at @var{location}. The data is read at an +-offset of @var{offset} from the start of the input section, +-and is read for @var{count} bytes. +- +-If the contents of a constructor with the @code{SEC_CONSTRUCTOR} +-flag set are requested or if the section does not have the +-@code{SEC_HAS_CONTENTS} flag set, then the @var{location} is filled +-with zeroes. If no errors occur, @code{TRUE} is returned, else +-@code{FALSE}. +- +-@end deftypefn +-@findex bfd_malloc_and_get_section +-@subsubsection @code{bfd_malloc_and_get_section} +-@deftypefn {Function} bool bfd_malloc_and_get_section (bfd *abfd, asection *section, bfd_byte **buf); +-Read all data from @var{section} in BFD @var{abfd} +-into a buffer, *@var{buf}, malloc'd by this function. +-Return @code{true} on success, @code{false} on failure in which +-case *@var{buf} will be NULL. +- +-@end deftypefn +-@findex bfd_copy_private_section_data +-@subsubsection @code{bfd_copy_private_section_data} +-@deftypefn {Function} bool bfd_copy_private_section_data (bfd *ibfd, asection *isec, bfd *obfd, asection *osec); +-Copy private section information from @var{isec} in the BFD +-@var{ibfd} to the section @var{osec} in the BFD @var{obfd}. +-Return @code{TRUE} on success, @code{FALSE} on error. Possible error +-returns are: +- +-@itemize @bullet +- +-@item +-@code{bfd_error_no_memory} - +-Not enough memory exists to create private data for @var{osec}. +-@end itemize +-@example +-#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ +- BFD_SEND (obfd, _bfd_copy_private_section_data, \ +- (ibfd, isection, obfd, osection)) +-@end example +- +-@end deftypefn +-@findex bfd_generic_is_group_section +-@subsubsection @code{bfd_generic_is_group_section} +-@deftypefn {Function} bool bfd_generic_is_group_section (bfd *, const asection *sec); +-Returns TRUE if @var{sec} is a member of a group. +- +-@end deftypefn +-@findex bfd_generic_group_name +-@subsubsection @code{bfd_generic_group_name} +-@deftypefn {Function} const char *bfd_generic_group_name (bfd *, const asection *sec); +-Returns group name if @var{sec} is a member of a group. +- +-@end deftypefn +-@findex bfd_generic_discard_group +-@subsubsection @code{bfd_generic_discard_group} +-@deftypefn {Function} bool bfd_generic_discard_group (bfd *abfd, asection *group); +-Remove all members of @var{group} from the output. +- +-@end deftypefn +-@findex _bfd_section_size_insane +-@subsubsection @code{_bfd_section_size_insane} +-@deftypefn {Function} bool _bfd_section_size_insane (bfd *abfd, asection *sec); +-Returns true if the given section has a size that indicates +-it cannot be read from file. Return false if the size is OK +-or* this function can't say one way or the other. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/syms.texi gdb-14.1-sw64/bfd/doc/syms.texi +--- gdb-14.1-after-patch/bfd/doc/syms.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/syms.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,446 +0,0 @@ +-@section Symbols +-BFD tries to maintain as much symbol information as it can when +-it moves information from file to file. BFD passes information +-to applications though the @code{asymbol} structure. When the +-application requests the symbol table, BFD reads the table in +-the native form and translates parts of it into the internal +-format. To maintain more than the information passed to +-applications, some targets keep some information ``behind the +-scenes'' in a structure only the particular back end knows +-about. For example, the coff back end keeps the original +-symbol table structure as well as the canonical structure when +-a BFD is read in. On output, the coff back end can reconstruct +-the output symbol table so that no information is lost, even +-information unique to coff which BFD doesn't know or +-understand. If a coff symbol table were read, but were written +-through an a.out back end, all the coff specific information +-would be lost. The symbol table of a BFD +-is not necessarily read in until a canonicalize request is +-made. Then the BFD back end fills in a table provided by the +-application with pointers to the canonical information. To +-output symbols, the application provides BFD with a table of +-pointers to pointers to @code{asymbol}s. This allows applications +-like the linker to output a symbol as it was read, since the ``behind +-the scenes'' information will be still available. +-@menu +-* Reading Symbols:: +-* Writing Symbols:: +-* Mini Symbols:: +-* typedef asymbol:: +-* symbol handling functions:: +-@end menu +- +-@node Reading Symbols, Writing Symbols, Symbols, Symbols +-@subsection Reading symbols +-There are two stages to reading a symbol table from a BFD: +-allocating storage, and the actual reading process. This is an +-excerpt from an application which reads the symbol table: +- +-@example +- long storage_needed; +- asymbol **symbol_table; +- long number_of_symbols; +- long i; +- +- storage_needed = bfd_get_symtab_upper_bound (abfd); +- +- if (storage_needed < 0) +- FAIL +- +- if (storage_needed == 0) +- return; +- +- symbol_table = xmalloc (storage_needed); +- ... +- number_of_symbols = +- bfd_canonicalize_symtab (abfd, symbol_table); +- +- if (number_of_symbols < 0) +- FAIL +- +- for (i = 0; i < number_of_symbols; i++) +- process_symbol (symbol_table[i]); +-@end example +- +-All storage for the symbols themselves is in an objalloc +-connected to the BFD; it is freed when the BFD is closed. +- +-@node Writing Symbols, Mini Symbols, Reading Symbols, Symbols +-@subsection Writing symbols +-Writing of a symbol table is automatic when a BFD open for +-writing is closed. The application attaches a vector of +-pointers to pointers to symbols to the BFD being written, and +-fills in the symbol count. The close and cleanup code reads +-through the table provided and performs all the necessary +-operations. The BFD output code must always be provided with an +-``owned'' symbol: one which has come from another BFD, or one +-which has been created using @code{bfd_make_empty_symbol}. Here is an +-example showing the creation of a symbol table with only one element: +- +-@example +- #include "sysdep.h" +- #include "bfd.h" +- int main (void) +- @{ +- bfd *abfd; +- asymbol *ptrs[2]; +- asymbol *new; +- +- abfd = bfd_openw ("foo","a.out-sunos-big"); +- bfd_set_format (abfd, bfd_object); +- new = bfd_make_empty_symbol (abfd); +- new->name = "dummy_symbol"; +- new->section = bfd_make_section_old_way (abfd, ".text"); +- new->flags = BSF_GLOBAL; +- new->value = 0x12345; +- +- ptrs[0] = new; +- ptrs[1] = 0; +- +- bfd_set_symtab (abfd, ptrs, 1); +- bfd_close (abfd); +- return 0; +- @} +- +- ./makesym +- nm foo +- 00012345 A dummy_symbol +-@end example +- +-Many formats cannot represent arbitrary symbol information; for +-instance, the @code{a.out} object format does not allow an +-arbitrary number of sections. A symbol pointing to a section +-which is not one of @code{.text}, @code{.data} or @code{.bss} cannot +-be described. +- +-@node Mini Symbols, typedef asymbol, Writing Symbols, Symbols +-@subsection Mini Symbols +-Mini symbols provide read-only access to the symbol table. +-They use less memory space, but require more time to access. +-They can be useful for tools like nm or objdump, which may +-have to handle symbol tables of extremely large executables. +- +-The @code{bfd_read_minisymbols} function will read the symbols +-into memory in an internal form. It will return a @code{void *} +-pointer to a block of memory, a symbol count, and the size of +-each symbol. The pointer is allocated using @code{malloc}, and +-should be freed by the caller when it is no longer needed. +- +-The function @code{bfd_minisymbol_to_symbol} will take a pointer +-to a minisymbol, and a pointer to a structure returned by +-@code{bfd_make_empty_symbol}, and return a @code{asymbol} structure. +-The return value may or may not be the same as the value from +-@code{bfd_make_empty_symbol} which was passed in. +- +- +-@node typedef asymbol, symbol handling functions, Mini Symbols, Symbols +-@subsection typedef asymbol +-An @code{asymbol} has the form: +- +- +-@example +-typedef struct bfd_symbol +-@{ +- /* A pointer to the BFD which owns the symbol. This information +- is necessary so that a back end can work out what additional +- information (invisible to the application writer) is carried +- with the symbol. +- +- This field is *almost* redundant, since you can use section->owner +- instead, except that some symbols point to the global sections +- bfd_@{abs,com,und@}_section. This could be fixed by making +- these globals be per-bfd (or per-target-flavor). FIXME. */ +- struct bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */ +- +- /* The text of the symbol. The name is left alone, and not copied; the +- application may not alter it. */ +- const char *name; +- +- /* The value of the symbol. This really should be a union of a +- numeric value with a pointer, since some flags indicate that +- a pointer to another symbol is stored here. */ +- symvalue value; +- +- /* Attributes of a symbol. */ +-#define BSF_NO_FLAGS 0 +- +- /* The symbol has local scope; @code{static} in @code{C}. The value +- is the offset into the section of the data. */ +-#define BSF_LOCAL (1 << 0) +- +- /* The symbol has global scope; initialized data in @code{C}. The +- value is the offset into the section of the data. */ +-#define BSF_GLOBAL (1 << 1) +- +- /* The symbol has global scope and is exported. The value is +- the offset into the section of the data. */ +-#define BSF_EXPORT BSF_GLOBAL /* No real difference. */ +- +- /* A normal C symbol would be one of: +- @code{BSF_LOCAL}, @code{BSF_UNDEFINED} or @code{BSF_GLOBAL}. */ +- +- /* The symbol is a debugging record. The value has an arbitrary +- meaning, unless BSF_DEBUGGING_RELOC is also set. */ +-#define BSF_DEBUGGING (1 << 2) +- +- /* The symbol denotes a function entry point. Used in ELF, +- perhaps others someday. */ +-#define BSF_FUNCTION (1 << 3) +- +- /* Used by the linker. */ +-#define BSF_KEEP (1 << 5) +- +- /* An ELF common symbol. */ +-#define BSF_ELF_COMMON (1 << 6) +- +- /* A weak global symbol, overridable without warnings by +- a regular global symbol of the same name. */ +-#define BSF_WEAK (1 << 7) +- +- /* This symbol was created to point to a section, e.g. ELF's +- STT_SECTION symbols. */ +-#define BSF_SECTION_SYM (1 << 8) +- +- /* The symbol used to be a common symbol, but now it is +- allocated. */ +-#define BSF_OLD_COMMON (1 << 9) +- +- /* In some files the type of a symbol sometimes alters its +- location in an output file - ie in coff a @code{ISFCN} symbol +- which is also @code{C_EXT} symbol appears where it was +- declared and not at the end of a section. This bit is set +- by the target BFD part to convey this information. */ +-#define BSF_NOT_AT_END (1 << 10) +- +- /* Signal that the symbol is the label of constructor section. */ +-#define BSF_CONSTRUCTOR (1 << 11) +- +- /* Signal that the symbol is a warning symbol. The name is a +- warning. The name of the next symbol is the one to warn about; +- if a reference is made to a symbol with the same name as the next +- symbol, a warning is issued by the linker. */ +-#define BSF_WARNING (1 << 12) +- +- /* Signal that the symbol is indirect. This symbol is an indirect +- pointer to the symbol with the same name as the next symbol. */ +-#define BSF_INDIRECT (1 << 13) +- +- /* BSF_FILE marks symbols that contain a file name. This is used +- for ELF STT_FILE symbols. */ +-#define BSF_FILE (1 << 14) +- +- /* Symbol is from dynamic linking information. */ +-#define BSF_DYNAMIC (1 << 15) +- +- /* The symbol denotes a data object. Used in ELF, and perhaps +- others someday. */ +-#define BSF_OBJECT (1 << 16) +- +- /* This symbol is a debugging symbol. The value is the offset +- into the section of the data. BSF_DEBUGGING should be set +- as well. */ +-#define BSF_DEBUGGING_RELOC (1 << 17) +- +- /* This symbol is thread local. Used in ELF. */ +-#define BSF_THREAD_LOCAL (1 << 18) +- +- /* This symbol represents a complex relocation expression, +- with the expression tree serialized in the symbol name. */ +-#define BSF_RELC (1 << 19) +- +- /* This symbol represents a signed complex relocation expression, +- with the expression tree serialized in the symbol name. */ +-#define BSF_SRELC (1 << 20) +- +- /* This symbol was created by bfd_get_synthetic_symtab. */ +-#define BSF_SYNTHETIC (1 << 21) +- +- /* This symbol is an indirect code object. Unrelated to BSF_INDIRECT. +- The dynamic linker will compute the value of this symbol by +- calling the function that it points to. BSF_FUNCTION must +- also be also set. */ +-#define BSF_GNU_INDIRECT_FUNCTION (1 << 22) +- /* This symbol is a globally unique data object. The dynamic linker +- will make sure that in the entire process there is just one symbol +- with this name and type in use. BSF_OBJECT must also be set. */ +-#define BSF_GNU_UNIQUE (1 << 23) +- +- /* This section symbol should be included in the symbol table. */ +-#define BSF_SECTION_SYM_USED (1 << 24) +- +- flagword flags; +- +- /* A pointer to the section to which this symbol is +- relative. This will always be non NULL, there are special +- sections for undefined and absolute symbols. */ +- struct bfd_section *section; +- +- /* Back end special data. */ +- union +- @{ +- void *p; +- bfd_vma i; +- @} +- udata; +-@} +-asymbol; +- +-@end example +- +-@node symbol handling functions, , typedef asymbol, Symbols +-@subsection Symbol handling functions +- +- +-@findex bfd_get_symtab_upper_bound +-@subsubsection @code{bfd_get_symtab_upper_bound} +-Return the number of bytes required to store a vector of pointers +-to @code{asymbols} for all the symbols in the BFD @var{abfd}, +-including a terminal NULL pointer. If there are no symbols in +-the BFD, then return 0. If an error occurs, return -1. +-@example +-#define bfd_get_symtab_upper_bound(abfd) \ +- BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) +- +-@end example +- +-@findex bfd_is_local_label +-@subsubsection @code{bfd_is_local_label} +-@deftypefn {Function} bool bfd_is_local_label (bfd *abfd, asymbol *sym); +-Return TRUE if the given symbol @var{sym} in the BFD @var{abfd} is +-a compiler generated local label, else return FALSE. +- +-@end deftypefn +-@findex bfd_is_local_label_name +-@subsubsection @code{bfd_is_local_label_name} +-@deftypefn {Function} bool bfd_is_local_label_name (bfd *abfd, const char *name); +-Return TRUE if a symbol with the name @var{name} in the BFD +-@var{abfd} is a compiler generated local label, else return +-FALSE. This just checks whether the name has the form of a +-local label. +-@example +-#define bfd_is_local_label_name(abfd, name) \ +- BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) +- +-@end example +- +-@end deftypefn +-@findex bfd_is_target_special_symbol +-@subsubsection @code{bfd_is_target_special_symbol} +-@deftypefn {Function} bool bfd_is_target_special_symbol (bfd *abfd, asymbol *sym); +-Return TRUE iff a symbol @var{sym} in the BFD @var{abfd} is something +-special to the particular target represented by the BFD. Such symbols +-should normally not be mentioned to the user. +-@example +-#define bfd_is_target_special_symbol(abfd, sym) \ +- BFD_SEND (abfd, _bfd_is_target_special_symbol, (abfd, sym)) +- +-@end example +- +-@end deftypefn +-@findex bfd_canonicalize_symtab +-@subsubsection @code{bfd_canonicalize_symtab} +-Read the symbols from the BFD @var{abfd}, and fills in +-the vector @var{location} with pointers to the symbols and +-a trailing NULL. +-Return the actual number of symbol pointers, not +-including the NULL. +-@example +-#define bfd_canonicalize_symtab(abfd, location) \ +- BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location)) +- +-@end example +- +-@findex bfd_set_symtab +-@subsubsection @code{bfd_set_symtab} +-@deftypefn {Function} bool bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count); +-Arrange that when the output BFD @var{abfd} is closed, +-the table @var{location} of @var{count} pointers to symbols +-will be written. +- +-@end deftypefn +-@findex bfd_print_symbol_vandf +-@subsubsection @code{bfd_print_symbol_vandf} +-@deftypefn {Function} void bfd_print_symbol_vandf (bfd *abfd, void *file, asymbol *symbol); +-Print the value and flags of the @var{symbol} supplied to the +-stream @var{file}. +- +-@end deftypefn +-@findex bfd_make_empty_symbol +-@subsubsection @code{bfd_make_empty_symbol} +-Create a new @code{asymbol} structure for the BFD @var{abfd} +-and return a pointer to it. +- +-This routine is necessary because each back end has private +-information surrounding the @code{asymbol}. Building your own +-@code{asymbol} and pointing to it will not create the private +-information, and will cause problems later on. +-@example +-#define bfd_make_empty_symbol(abfd) \ +- BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) +- +-@end example +- +-@findex _bfd_generic_make_empty_symbol +-@subsubsection @code{_bfd_generic_make_empty_symbol} +-@deftypefn {Function} asymbol *_bfd_generic_make_empty_symbol (bfd *); +-Create a new @code{asymbol} structure for the BFD @var{abfd} +-and return a pointer to it. Used by core file routines, +-binary back-end and anywhere else where no private info +-is needed. +- +-@end deftypefn +-@findex bfd_make_debug_symbol +-@subsubsection @code{bfd_make_debug_symbol} +-Create a new @code{asymbol} structure for the BFD @var{abfd}, +-to be used as a debugging symbol. +-@example +-#define bfd_make_debug_symbol(abfd) \ +- BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd)) +- +-@end example +- +-@findex bfd_decode_symclass +-@subsubsection @code{bfd_decode_symclass} +-@deftypefn {Function} int bfd_decode_symclass (asymbol *symbol); +-Return a character corresponding to the symbol +-class of @var{symbol}, or '?' for an unknown class. +- +-@end deftypefn +-@findex bfd_is_undefined_symclass +-@subsubsection @code{bfd_is_undefined_symclass} +-@deftypefn {Function} bool bfd_is_undefined_symclass (int symclass); +-Returns non-zero if the class symbol returned by +-bfd_decode_symclass represents an undefined symbol. +-Returns zero otherwise. +- +-@end deftypefn +-@findex bfd_symbol_info +-@subsubsection @code{bfd_symbol_info} +-@deftypefn {Function} void bfd_symbol_info (asymbol *symbol, symbol_info *ret); +-Fill in the basic info about symbol that nm needs. +-Additional info may be added by the back-ends after +-calling this function. +- +-@end deftypefn +-@findex bfd_copy_private_symbol_data +-@subsubsection @code{bfd_copy_private_symbol_data} +-@deftypefn {Function} bool bfd_copy_private_symbol_data (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym); +-Copy private symbol information from @var{isym} in the BFD +-@var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}. +-Return @code{TRUE} on success, @code{FALSE} on error. Possible error +-returns are: +- +-@itemize @bullet +- +-@item +-@code{bfd_error_no_memory} - +-Not enough memory exists to create private data for @var{osec}. +-@end itemize +-@example +-#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \ +- BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ +- (ibfd, isymbol, obfd, osymbol)) +- +-@end example +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/doc/targets.texi gdb-14.1-sw64/bfd/doc/targets.texi +--- gdb-14.1-after-patch/bfd/doc/targets.texi 2023-12-03 13:25:15.000000000 +0800 ++++ gdb-14.1-sw64/bfd/doc/targets.texi 1970-01-01 08:00:00.000000000 +0800 +@@ -1,691 +0,0 @@ +-@section Targets +- +- +-Each port of BFD to a different machine requires the creation +-of a target back end. All the back end provides to the root +-part of BFD is a structure containing pointers to functions +-which perform certain low level operations on files. BFD +-translates the applications's requests through a pointer into +-calls to the back end routines. +- +-When a file is opened with @code{bfd_openr}, its format and +-target are unknown. BFD uses various mechanisms to determine +-how to interpret the file. The operations performed are: +- +-@itemize @bullet +- +-@item +-Create a BFD by calling the internal routine +-@code{_bfd_new_bfd}, then call @code{bfd_find_target} with the +-target string supplied to @code{bfd_openr} and the new BFD pointer. +- +-@item +-If a null target string was provided to @code{bfd_find_target}, +-look up the environment variable @code{GNUTARGET} and use +-that as the target string. +- +-@item +-If the target string is still @code{NULL}, or the target string is +-@code{default}, then use the first item in the target vector +-as the target type, and set @code{target_defaulted} in the BFD to +-cause @code{bfd_check_format} to loop through all the targets. +-@xref{bfd_target}. @xref{Formats}. +- +-@item +-Otherwise, inspect the elements in the target vector +-one by one, until a match on target name is found. When found, +-use it. +- +-@item +-Otherwise return the error @code{bfd_error_invalid_target} to +-@code{bfd_openr}. +- +-@item +-@code{bfd_openr} attempts to open the file using +-@code{bfd_open_file}, and returns the BFD. +-@end itemize +-Once the BFD has been opened and the target selected, the file +-format may be determined. This is done by calling +-@code{bfd_check_format} on the BFD with a suggested format. +-If @code{target_defaulted} has been set, each possible target +-type is tried to see if it recognizes the specified format. +-@code{bfd_check_format} returns @code{TRUE} when the caller guesses right. +-@menu +-* bfd_target:: +-@end menu +- +-@node bfd_target, , Targets, Targets +- +-@subsection bfd_target +- +- +-This structure contains everything that BFD knows about a +-target. It includes things like its byte order, name, and which +-routines to call to do various operations. +- +-Every BFD points to a target structure with its @code{xvec} +-member. +- +-The macros below are used to dispatch to functions through the +-@code{bfd_target} vector. They are used in a number of macros further +-down in @file{bfd.h}, and are also used when calling various +-routines by hand inside the BFD implementation. The @var{arglist} +-argument must be parenthesized; it contains all the arguments +-to the called function. +- +-They make the documentation (more) unpleasant to read, so if +-someone wants to fix this and not break the above, please do. +-@example +-#define BFD_SEND(bfd, message, arglist) \ +- ((*((bfd)->xvec->message)) arglist) +- +-#ifdef DEBUG_BFD_SEND +-#undef BFD_SEND +-#define BFD_SEND(bfd, message, arglist) \ +- (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ +- ((*((bfd)->xvec->message)) arglist) : \ +- (bfd_assert (__FILE__,__LINE__), NULL)) +-#endif +-@end example +-For operations which index on the BFD format: +-@example +-#define BFD_SEND_FMT(bfd, message, arglist) \ +- (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) +- +-#ifdef DEBUG_BFD_SEND +-#undef BFD_SEND_FMT +-#define BFD_SEND_FMT(bfd, message, arglist) \ +- (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ +- (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \ +- (bfd_assert (__FILE__,__LINE__), NULL)) +-#endif +- +-/* Defined to TRUE if unused section symbol should be kept. */ +-#ifndef TARGET_KEEP_UNUSED_SECTION_SYMBOLS +-#define TARGET_KEEP_UNUSED_SECTION_SYMBOLS true +-#endif +- +-@end example +-This is the structure which defines the type of BFD this is. The +-@code{xvec} member of the struct @code{bfd} itself points here. Each +-module that implements access to a different target under BFD, +-defines one of these. +- +-FIXME, these names should be rationalised with the names of +-the entry points which call them. Too bad we can't have one +-macro to define them both! +- +- +-@example +-typedef struct bfd_target +-@{ +- /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc. */ +- const char *name; +- +- /* The "flavour" of a back end is a general indication about +- the contents of a file. */ +- enum bfd_flavour flavour; +- +- /* The order of bytes within the data area of a file. */ +- enum bfd_endian byteorder; +- +- /* The order of bytes within the header parts of a file. */ +- enum bfd_endian header_byteorder; +- +- /* A mask of all the flags which an executable may have set - +- from the set @code{BFD_NO_FLAGS}, @code{HAS_RELOC}, ...@code{D_PAGED}. */ +- flagword object_flags; +- +- /* A mask of all the flags which a section may have set - from +- the set @code{SEC_NO_FLAGS}, @code{SEC_ALLOC}, ...@code{SET_NEVER_LOAD}. */ +- flagword section_flags; +- +- /* The character normally found at the front of a symbol. +- (if any), perhaps `_'. */ +- char symbol_leading_char; +- +- /* The pad character for file names within an archive header. */ +- char ar_pad_char; +- +- /* The maximum number of characters in an archive header. */ +- unsigned char ar_max_namelen; +- +- /* How well this target matches, used to select between various +- possible targets when more than one target matches. */ +- unsigned char match_priority; +- +- /* TRUE if unused section symbols should be kept. */ +- bool keep_unused_section_symbols; +- +- /* Entries for byte swapping for data. These are different from the +- other entry points, since they don't take a BFD as the first argument. +- Certain other handlers could do the same. */ +- uint64_t (*bfd_getx64) (const void *); +- int64_t (*bfd_getx_signed_64) (const void *); +- void (*bfd_putx64) (uint64_t, void *); +- bfd_vma (*bfd_getx32) (const void *); +- bfd_signed_vma (*bfd_getx_signed_32) (const void *); +- void (*bfd_putx32) (bfd_vma, void *); +- bfd_vma (*bfd_getx16) (const void *); +- bfd_signed_vma (*bfd_getx_signed_16) (const void *); +- void (*bfd_putx16) (bfd_vma, void *); +- +- /* Byte swapping for the headers. */ +- uint64_t (*bfd_h_getx64) (const void *); +- int64_t (*bfd_h_getx_signed_64) (const void *); +- void (*bfd_h_putx64) (uint64_t, void *); +- bfd_vma (*bfd_h_getx32) (const void *); +- bfd_signed_vma (*bfd_h_getx_signed_32) (const void *); +- void (*bfd_h_putx32) (bfd_vma, void *); +- bfd_vma (*bfd_h_getx16) (const void *); +- bfd_signed_vma (*bfd_h_getx_signed_16) (const void *); +- void (*bfd_h_putx16) (bfd_vma, void *); +- +- /* Format dependent routines: these are vectors of entry points +- within the target vector structure, one for each format to check. */ +- +- /* Check the format of a file being read. Return a @code{bfd_cleanup} on +- success or zero on failure. */ +- bfd_cleanup (*_bfd_check_format[bfd_type_end]) (bfd *); +- +- /* Set the format of a file being written. */ +- bool (*_bfd_set_format[bfd_type_end]) (bfd *); +- +- /* Write cached information into a file being written, at @code{bfd_close}. */ +- bool (*_bfd_write_contents[bfd_type_end]) (bfd *); +- +-@end example +-The general target vector. These vectors are initialized using the +-BFD_JUMP_TABLE macros. +-@example +- /* Generic entry points. */ +-#define BFD_JUMP_TABLE_GENERIC(NAME) \ +- NAME##_close_and_cleanup, \ +- NAME##_bfd_free_cached_info, \ +- NAME##_new_section_hook, \ +- NAME##_get_section_contents, \ +- NAME##_get_section_contents_in_window +- +- /* Called when the BFD is being closed to do any necessary cleanup. */ +- bool (*_close_and_cleanup) (bfd *); +- /* Ask the BFD to free all cached information. */ +- bool (*_bfd_free_cached_info) (bfd *); +- /* Called when a new section is created. */ +- bool (*_new_section_hook) (bfd *, sec_ptr); +- /* Read the contents of a section. */ +- bool (*_bfd_get_section_contents) (bfd *, sec_ptr, void *, file_ptr, +- bfd_size_type); +- bool (*_bfd_get_section_contents_in_window) (bfd *, sec_ptr, bfd_window *, +- file_ptr, bfd_size_type); +- +- /* Entry points to copy private data. */ +-#define BFD_JUMP_TABLE_COPY(NAME) \ +- NAME##_bfd_copy_private_bfd_data, \ +- NAME##_bfd_merge_private_bfd_data, \ +- _bfd_generic_init_private_section_data, \ +- NAME##_bfd_copy_private_section_data, \ +- NAME##_bfd_copy_private_symbol_data, \ +- NAME##_bfd_copy_private_header_data, \ +- NAME##_bfd_set_private_flags, \ +- NAME##_bfd_print_private_bfd_data +- +- /* Called to copy BFD general private data from one object file +- to another. */ +- bool (*_bfd_copy_private_bfd_data) (bfd *, bfd *); +- /* Called to merge BFD general private data from one object file +- to a common output file when linking. */ +- bool (*_bfd_merge_private_bfd_data) (bfd *, struct bfd_link_info *); +- /* Called to initialize BFD private section data from one object file +- to another. */ +-#define bfd_init_private_section_data(ibfd, isec, obfd, osec, link_info) \ +- BFD_SEND (obfd, _bfd_init_private_section_data, \ +- (ibfd, isec, obfd, osec, link_info)) +- bool (*_bfd_init_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr, +- struct bfd_link_info *); +- /* Called to copy BFD private section data from one object file +- to another. */ +- bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr); +- /* Called to copy BFD private symbol data from one symbol +- to another. */ +- bool (*_bfd_copy_private_symbol_data) (bfd *, asymbol *, +- bfd *, asymbol *); +- /* Called to copy BFD private header data from one object file +- to another. */ +- bool (*_bfd_copy_private_header_data) (bfd *, bfd *); +- /* Called to set private backend flags. */ +- bool (*_bfd_set_private_flags) (bfd *, flagword); +- +- /* Called to print private BFD data. */ +- bool (*_bfd_print_private_bfd_data) (bfd *, void *); +- +- /* Core file entry points. */ +-#define BFD_JUMP_TABLE_CORE(NAME) \ +- NAME##_core_file_failing_command, \ +- NAME##_core_file_failing_signal, \ +- NAME##_core_file_matches_executable_p, \ +- NAME##_core_file_pid +- +- char *(*_core_file_failing_command) (bfd *); +- int (*_core_file_failing_signal) (bfd *); +- bool (*_core_file_matches_executable_p) (bfd *, bfd *); +- int (*_core_file_pid) (bfd *); +- +- /* Archive entry points. */ +-#define BFD_JUMP_TABLE_ARCHIVE(NAME) \ +- NAME##_slurp_armap, \ +- NAME##_slurp_extended_name_table, \ +- NAME##_construct_extended_name_table, \ +- NAME##_truncate_arname, \ +- NAME##_write_armap, \ +- NAME##_read_ar_hdr, \ +- NAME##_write_ar_hdr, \ +- NAME##_openr_next_archived_file, \ +- NAME##_get_elt_at_index, \ +- NAME##_generic_stat_arch_elt, \ +- NAME##_update_armap_timestamp +- +- bool (*_bfd_slurp_armap) (bfd *); +- bool (*_bfd_slurp_extended_name_table) (bfd *); +- bool (*_bfd_construct_extended_name_table) (bfd *, char **, +- bfd_size_type *, +- const char **); +- void (*_bfd_truncate_arname) (bfd *, const char *, char *); +- bool (*write_armap) (bfd *, unsigned, struct orl *, unsigned, int); +- void *(*_bfd_read_ar_hdr_fn) (bfd *); +- bool (*_bfd_write_ar_hdr_fn) (bfd *, bfd *); +- bfd *(*openr_next_archived_file) (bfd *, bfd *); +-#define bfd_get_elt_at_index(b,i) \ +- BFD_SEND (b, _bfd_get_elt_at_index, (b,i)) +- bfd *(*_bfd_get_elt_at_index) (bfd *, symindex); +- int (*_bfd_stat_arch_elt) (bfd *, struct stat *); +- bool (*_bfd_update_armap_timestamp) (bfd *); +- +- /* Entry points used for symbols. */ +-#define BFD_JUMP_TABLE_SYMBOLS(NAME) \ +- NAME##_get_symtab_upper_bound, \ +- NAME##_canonicalize_symtab, \ +- NAME##_make_empty_symbol, \ +- NAME##_print_symbol, \ +- NAME##_get_symbol_info, \ +- NAME##_get_symbol_version_string, \ +- NAME##_bfd_is_local_label_name, \ +- NAME##_bfd_is_target_special_symbol, \ +- NAME##_get_lineno, \ +- NAME##_find_nearest_line, \ +- NAME##_find_nearest_line_with_alt, \ +- NAME##_find_line, \ +- NAME##_find_inliner_info, \ +- NAME##_bfd_make_debug_symbol, \ +- NAME##_read_minisymbols, \ +- NAME##_minisymbol_to_symbol +- +- long (*_bfd_get_symtab_upper_bound) (bfd *); +- long (*_bfd_canonicalize_symtab) (bfd *, struct bfd_symbol **); +- struct bfd_symbol * +- (*_bfd_make_empty_symbol) (bfd *); +- void (*_bfd_print_symbol) (bfd *, void *, struct bfd_symbol *, +- bfd_print_symbol_type); +-#define bfd_print_symbol(b,p,s,e) \ +- BFD_SEND (b, _bfd_print_symbol, (b,p,s,e)) +- void (*_bfd_get_symbol_info) (bfd *, struct bfd_symbol *, symbol_info *); +-#define bfd_get_symbol_info(b,p,e) \ +- BFD_SEND (b, _bfd_get_symbol_info, (b,p,e)) +- const char * +- (*_bfd_get_symbol_version_string) (bfd *, struct bfd_symbol *, +- bool, bool *); +-#define bfd_get_symbol_version_string(b,s,p,h) \ +- BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,p,h)) +- bool (*_bfd_is_local_label_name) (bfd *, const char *); +- bool (*_bfd_is_target_special_symbol) (bfd *, asymbol *); +- alent * +- (*_get_lineno) (bfd *, struct bfd_symbol *); +- bool (*_bfd_find_nearest_line) (bfd *, struct bfd_symbol **, +- struct bfd_section *, bfd_vma, +- const char **, const char **, +- unsigned int *, unsigned int *); +- bool (*_bfd_find_nearest_line_with_alt) (bfd *, const char *, +- struct bfd_symbol **, +- struct bfd_section *, bfd_vma, +- const char **, const char **, +- unsigned int *, unsigned int *); +- bool (*_bfd_find_line) (bfd *, struct bfd_symbol **, +- struct bfd_symbol *, const char **, +- unsigned int *); +- bool (*_bfd_find_inliner_info) +- (bfd *, const char **, const char **, unsigned int *); +- /* Back-door to allow format-aware applications to create debug symbols +- while using BFD for everything else. Currently used by the assembler +- when creating COFF files. */ +- asymbol * +- (*_bfd_make_debug_symbol) (bfd *); +-#define bfd_read_minisymbols(b, d, m, s) \ +- BFD_SEND (b, _read_minisymbols, (b, d, m, s)) +- long (*_read_minisymbols) (bfd *, bool, void **, unsigned int *); +-#define bfd_minisymbol_to_symbol(b, d, m, f) \ +- BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f)) +- asymbol * +- (*_minisymbol_to_symbol) (bfd *, bool, const void *, asymbol *); +- +- /* Routines for relocs. */ +-#define BFD_JUMP_TABLE_RELOCS(NAME) \ +- NAME##_get_reloc_upper_bound, \ +- NAME##_canonicalize_reloc, \ +- NAME##_set_reloc, \ +- NAME##_bfd_reloc_type_lookup, \ +- NAME##_bfd_reloc_name_lookup +- +- long (*_get_reloc_upper_bound) (bfd *, sec_ptr); +- long (*_bfd_canonicalize_reloc) (bfd *, sec_ptr, arelent **, +- struct bfd_symbol **); +- void (*_bfd_set_reloc) (bfd *, sec_ptr, arelent **, unsigned int); +- /* See documentation on reloc types. */ +- reloc_howto_type * +- (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type); +- reloc_howto_type * +- (*reloc_name_lookup) (bfd *, const char *); +- +- /* Routines used when writing an object file. */ +-#define BFD_JUMP_TABLE_WRITE(NAME) \ +- NAME##_set_arch_mach, \ +- NAME##_set_section_contents +- +- bool (*_bfd_set_arch_mach) (bfd *, enum bfd_architecture, +- unsigned long); +- bool (*_bfd_set_section_contents) (bfd *, sec_ptr, const void *, +- file_ptr, bfd_size_type); +- +- /* Routines used by the linker. */ +-#define BFD_JUMP_TABLE_LINK(NAME) \ +- NAME##_sizeof_headers, \ +- NAME##_bfd_get_relocated_section_contents, \ +- NAME##_bfd_relax_section, \ +- NAME##_bfd_link_hash_table_create, \ +- NAME##_bfd_link_add_symbols, \ +- NAME##_bfd_link_just_syms, \ +- NAME##_bfd_copy_link_hash_symbol_type, \ +- NAME##_bfd_final_link, \ +- NAME##_bfd_link_split_section, \ +- NAME##_bfd_link_check_relocs, \ +- NAME##_bfd_gc_sections, \ +- NAME##_bfd_lookup_section_flags, \ +- NAME##_bfd_merge_sections, \ +- NAME##_bfd_is_group_section, \ +- NAME##_bfd_group_name, \ +- NAME##_bfd_discard_group, \ +- NAME##_section_already_linked, \ +- NAME##_bfd_define_common_symbol, \ +- NAME##_bfd_link_hide_symbol, \ +- NAME##_bfd_define_start_stop +- +- int (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *); +- bfd_byte * +- (*_bfd_get_relocated_section_contents) (bfd *, +- struct bfd_link_info *, +- struct bfd_link_order *, +- bfd_byte *, bool, +- struct bfd_symbol **); +- +- bool (*_bfd_relax_section) (bfd *, struct bfd_section *, +- struct bfd_link_info *, bool *); +- +- /* Create a hash table for the linker. Different backends store +- different information in this table. */ +- struct bfd_link_hash_table * +- (*_bfd_link_hash_table_create) (bfd *); +- +- /* Add symbols from this object file into the hash table. */ +- bool (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *); +- +- /* Indicate that we are only retrieving symbol values from this section. */ +- void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *); +- +- /* Copy the symbol type and other attributes for a linker script +- assignment of one symbol to another. */ +-#define bfd_copy_link_hash_symbol_type(b, t, f) \ +- BFD_SEND (b, _bfd_copy_link_hash_symbol_type, (b, t, f)) +- void (*_bfd_copy_link_hash_symbol_type) (bfd *, +- struct bfd_link_hash_entry *, +- struct bfd_link_hash_entry *); +- +- /* Do a link based on the link_order structures attached to each +- section of the BFD. */ +- bool (*_bfd_final_link) (bfd *, struct bfd_link_info *); +- +- /* Should this section be split up into smaller pieces during linking. */ +- bool (*_bfd_link_split_section) (bfd *, struct bfd_section *); +- +- /* Check the relocations in the bfd for validity. */ +- bool (* _bfd_link_check_relocs)(bfd *, struct bfd_link_info *); +- +- /* Remove sections that are not referenced from the output. */ +- bool (*_bfd_gc_sections) (bfd *, struct bfd_link_info *); +- +- /* Sets the bitmask of allowed and disallowed section flags. */ +- bool (*_bfd_lookup_section_flags) (struct bfd_link_info *, +- struct flag_info *, asection *); +- +- /* Attempt to merge SEC_MERGE sections. */ +- bool (*_bfd_merge_sections) (bfd *, struct bfd_link_info *); +- +- /* Is this section a member of a group? */ +- bool (*_bfd_is_group_section) (bfd *, const struct bfd_section *); +- +- /* The group name, if section is a member of a group. */ +- const char *(*_bfd_group_name) (bfd *, const struct bfd_section *); +- +- /* Discard members of a group. */ +- bool (*_bfd_discard_group) (bfd *, struct bfd_section *); +- +- /* Check if SEC has been already linked during a reloceatable or +- final link. */ +- bool (*_section_already_linked) (bfd *, asection *, +- struct bfd_link_info *); +- +- /* Define a common symbol. */ +- bool (*_bfd_define_common_symbol) (bfd *, struct bfd_link_info *, +- struct bfd_link_hash_entry *); +- +- /* Hide a symbol. */ +- void (*_bfd_link_hide_symbol) (bfd *, struct bfd_link_info *, +- struct bfd_link_hash_entry *); +- +- /* Define a __start, __stop, .startof. or .sizeof. symbol. */ +- struct bfd_link_hash_entry * +- (*_bfd_define_start_stop) (struct bfd_link_info *, const char *, +- asection *); +- +- /* Routines to handle dynamic symbols and relocs. */ +-#define BFD_JUMP_TABLE_DYNAMIC(NAME) \ +- NAME##_get_dynamic_symtab_upper_bound, \ +- NAME##_canonicalize_dynamic_symtab, \ +- NAME##_get_synthetic_symtab, \ +- NAME##_get_dynamic_reloc_upper_bound, \ +- NAME##_canonicalize_dynamic_reloc +- +- /* Get the amount of memory required to hold the dynamic symbols. */ +- long (*_bfd_get_dynamic_symtab_upper_bound) (bfd *); +- /* Read in the dynamic symbols. */ +- long (*_bfd_canonicalize_dynamic_symtab) (bfd *, struct bfd_symbol **); +- /* Create synthetized symbols. */ +- long (*_bfd_get_synthetic_symtab) (bfd *, long, struct bfd_symbol **, +- long, struct bfd_symbol **, +- struct bfd_symbol **); +- /* Get the amount of memory required to hold the dynamic relocs. */ +- long (*_bfd_get_dynamic_reloc_upper_bound) (bfd *); +- /* Read in the dynamic relocs. */ +- long (*_bfd_canonicalize_dynamic_reloc) (bfd *, arelent **, +- struct bfd_symbol **); +- +-@end example +-A pointer to an alternative bfd_target in case the current one is not +-satisfactory. This can happen when the target cpu supports both big +-and little endian code, and target chosen by the linker has the wrong +-endianness. The function open_output() in ld/ldlang.c uses this field +-to find an alternative output format that is suitable. +-@example +- /* Opposite endian version of this target. */ +- const struct bfd_target *alternative_target; +- +- /* Data for use by back-end routines, which isn't +- generic enough to belong in this structure. */ +- const void *backend_data; +- +-@} bfd_target; +- +-static inline const char * +-bfd_get_target (const bfd *abfd) +-@{ +- return abfd->xvec->name; +-@} +- +-static inline enum bfd_flavour +-bfd_get_flavour (const bfd *abfd) +-@{ +- return abfd->xvec->flavour; +-@} +- +-static inline flagword +-bfd_applicable_file_flags (const bfd *abfd) +-@{ +- return abfd->xvec->object_flags; +-@} +- +-static inline bool +-bfd_family_coff (const bfd *abfd) +-@{ +- return (bfd_get_flavour (abfd) == bfd_target_coff_flavour +- || bfd_get_flavour (abfd) == bfd_target_xcoff_flavour); +-@} +- +-static inline bool +-bfd_big_endian (const bfd *abfd) +-@{ +- return abfd->xvec->byteorder == BFD_ENDIAN_BIG; +-@} +-static inline bool +-bfd_little_endian (const bfd *abfd) +-@{ +- return abfd->xvec->byteorder == BFD_ENDIAN_LITTLE; +-@} +- +-static inline bool +-bfd_header_big_endian (const bfd *abfd) +-@{ +- return abfd->xvec->header_byteorder == BFD_ENDIAN_BIG; +-@} +- +-static inline bool +-bfd_header_little_endian (const bfd *abfd) +-@{ +- return abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE; +-@} +- +-static inline flagword +-bfd_applicable_section_flags (const bfd *abfd) +-@{ +- return abfd->xvec->section_flags; +-@} +- +-static inline char +-bfd_get_symbol_leading_char (const bfd *abfd) +-@{ +- return abfd->xvec->symbol_leading_char; +-@} +- +-static inline enum bfd_flavour +-bfd_asymbol_flavour (const asymbol *sy) +-@{ +- if ((sy->flags & BSF_SYNTHETIC) != 0) +- return bfd_target_unknown_flavour; +- return sy->the_bfd->xvec->flavour; +-@} +- +-static inline bool +-bfd_keep_unused_section_symbols (const bfd *abfd) +-@{ +- return abfd->xvec->keep_unused_section_symbols; +-@} +- +-@end example +-@findex _bfd_per_xvec_warn +-@subsubsection @code{_bfd_per_xvec_warn} +-@deftypefn {Function} struct per_xvec_message **_bfd_per_xvec_warn (const bfd_target *, size_t); +-Return a location for the given target xvec to use for +-warnings specific to that target. If TARG is NULL, returns +-the array of per_xvec_message pointers, otherwise if ALLOC is +-zero, returns a pointer to a pointer to the list of messages +-for TARG, otherwise (both TARG and ALLOC non-zero), allocates +-a new per_xvec_message with space for a string of ALLOC +-bytes and returns a pointer to a pointer to it. May return a +-pointer to a NULL pointer on allocation failure. +- +-@end deftypefn +-@findex bfd_set_default_target +-@subsubsection @code{bfd_set_default_target} +-@deftypefn {Function} bool bfd_set_default_target (const char *name); +-Set the default target vector to use when recognizing a BFD. +-This takes the name of the target, which may be a BFD target +-name or a configuration triplet. +- +-@end deftypefn +-@findex bfd_find_target +-@subsubsection @code{bfd_find_target} +-@deftypefn {Function} const bfd_target *bfd_find_target (const char *target_name, bfd *abfd); +-Return a pointer to the transfer vector for the object target +-named @var{target_name}. If @var{target_name} is @code{NULL}, +-choose the one in the environment variable @code{GNUTARGET}; if +-that is null or not defined, then choose the first entry in the +-target list. Passing in the string "default" or setting the +-environment variable to "default" will cause the first entry in +-the target list to be returned, and "target_defaulted" will be +-set in the BFD if @var{abfd} isn't @code{NULL}. This causes +-@code{bfd_check_format} to loop over all the targets to find the +-one that matches the file being read. +- +-@end deftypefn +-@findex bfd_get_target_info +-@subsubsection @code{bfd_get_target_info} +-@deftypefn {Function} const bfd_target *bfd_get_target_info (const char *target_name, bfd *abfd, bool *is_bigendian, int *underscoring, const char **def_target_arch); +-Return a pointer to the transfer vector for the object target +-named @var{target_name}. If @var{target_name} is @code{NULL}, +-choose the one in the environment variable @code{GNUTARGET}; if +-that is null or not defined, then choose the first entry in the +-target list. Passing in the string "default" or setting the +-environment variable to "default" will cause the first entry in +-the target list to be returned, and "target_defaulted" will be +-set in the BFD if @var{abfd} isn't @code{NULL}. This causes +-@code{bfd_check_format} to loop over all the targets to find the +-one that matches the file being read. +-If @var{is_bigendian} is not @code{NULL}, then set this value to target's +-endian mode. True for big-endian, FALSE for little-endian or for +-invalid target. +-If @var{underscoring} is not @code{NULL}, then set this value to target's +-underscoring mode. Zero for none-underscoring, -1 for invalid target, +-else the value of target vector's symbol underscoring. +-If @var{def_target_arch} is not @code{NULL}, then set it to the architecture +-string specified by the target_name. +- +-@end deftypefn +-@findex bfd_target_list +-@subsubsection @code{bfd_target_list} +-@deftypefn {Function} const char ** bfd_target_list (void); +-Return a freshly malloced NULL-terminated +-vector of the names of all the valid BFD targets. Do not +-modify the names. +- +-@end deftypefn +-@findex bfd_iterate_over_targets +-@subsubsection @code{bfd_iterate_over_targets} +-@deftypefn {Function} const bfd_target *bfd_iterate_over_targets (int (*func) (const bfd_target *, void *), void *data); +-Call @var{func} for each target in the list of BFD target +-vectors, passing @var{data} to @var{func}. Stop iterating if +-@var{func} returns a non-zero result, and return that target +-vector. Return NULL if @var{func} always returns zero. +- +-@end deftypefn +-@findex bfd_flavour_name +-@subsubsection @code{bfd_flavour_name} +-@deftypefn {Function} const char *bfd_flavour_name (enum bfd_flavour flavour); +-Return the string form of @var{flavour}. +- +-@end deftypefn +diff -Naur gdb-14.1-after-patch/bfd/ecoff.c gdb-14.1-sw64/bfd/ecoff.c +--- gdb-14.1-after-patch/bfd/ecoff.c 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/bfd/ecoff.c 2025-03-03 10:59:12.970000000 +0800 +@@ -222,6 +222,11 @@ + mach = 0; + break; + ++ case SW64_MAGIC: ++ arch = bfd_arch_sw64; ++ mach = 0; ++ break; ++ + default: + arch = bfd_arch_obscure; + mach = 0; +@@ -275,6 +280,9 @@ + case bfd_arch_alpha: + return ALPHA_MAGIC; + ++ case bfd_arch_sw64: ++ return SW64_MAGIC; ++ + default: + abort (); + return 0; +diff -Naur gdb-14.1-after-patch/bfd/elf64-sw64.c gdb-14.1-sw64/bfd/elf64-sw64.c +--- gdb-14.1-after-patch/bfd/elf64-sw64.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/bfd/elf64-sw64.c 2025-03-03 10:59:12.990000000 +0800 +@@ -0,0 +1,5531 @@ ++/* SW64 specific support for 64-bit ELF ++ Copyright (C) 1996-2023 Free Software Foundation, Inc. ++ Contributed by Richard Henderson . ++ ++ 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; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++ MA 02110-1301, USA. */ ++ ++ ++/* We need a published ABI spec for this. Until one comes out, don't ++ assume this'll remain unchanged forever. */ ++ ++#include "sysdep.h" ++#include "bfd.h" ++#include "libbfd.h" ++#include "elf-bfd.h" ++#include "ecoff-bfd.h" ++ ++#include "elf/sw64.h" ++ ++#define SW64ECOFF ++ ++#define NO_COFF_RELOCS ++#define NO_COFF_SYMBOLS ++#define NO_COFF_LINENOS ++ ++/* Get the ECOFF swapping routines. Needed for the debug information. */ ++#include "coff/internal.h" ++#include "coff/sym.h" ++#include "coff/symconst.h" ++#include "coff/ecoff.h" ++#include "coff/sw64.h" ++#include "aout/ar.h" ++#include "libcoff.h" ++#include "libecoff.h" ++#define ECOFF_64 ++#include "ecoffswap.h" ++ ++ ++/* Instruction data for plt generation and relaxation. */ ++ ++#define OP_LDA 0x08U ++#define OP_LDAH 0x09U ++#define OP_LDQ 0x29U ++#define OP_BR 0x30U ++#define OP_BSR 0x34U ++ ++#define INSN_LDA (OP_LDA << 26) ++#define INSN_LDAH (OP_LDAH << 26) ++#define INSN_LDQ (OP_LDQ << 26) ++#define INSN_BR (OP_BR << 26) ++ ++#define INSN_ADDQ 0x40000400 ++#define INSN_RDUNIQ 0x0000009e ++#define INSN_SUBQ 0x40000520 ++#define INSN_S4SUBQ 0x40000560 ++#define INSN_UNOP 0x2ffe0000 ++ ++#define INSN_JSR 0x68004000 ++#define INSN_JMP 0x68000000 ++#define INSN_JSR_MASK 0xfc00c000 ++ ++#define INSN_A(I,A) (I | ((unsigned) A << 21)) ++#define INSN_AB(I,A,B) (INSN_A (I, A) | (B << 16)) ++#define INSN_ABC(I,A,B,C) (INSN_A (I, A) | (B << 16) | C) ++#define INSN_ABO(I,A,B,O) (INSN_A (I, A) | (B << 16) | ((O) & 0xffff)) ++#define INSN_AD(I,A,D) (INSN_A (I, A) | (((D) >> 2) & 0x1fffff)) ++ ++/* PLT/GOT Stuff */ ++ ++/* Set by ld emulation. Putting this into the link_info or hash structure ++ is simply working too hard. */ ++#ifdef USE_SECUREPLT ++bool elf64_sw64_use_secureplt = true; ++#else ++bool elf64_sw64_use_secureplt = false; ++#endif ++ ++#define OLD_PLT_HEADER_SIZE 32 ++#define OLD_PLT_ENTRY_SIZE 12 ++#define NEW_PLT_HEADER_SIZE 36 ++#define NEW_PLT_ENTRY_SIZE 4 ++ ++#define PLT_HEADER_SIZE \ ++ (elf64_sw64_use_secureplt ? NEW_PLT_HEADER_SIZE : OLD_PLT_HEADER_SIZE) ++#define PLT_ENTRY_SIZE \ ++ (elf64_sw64_use_secureplt ? NEW_PLT_ENTRY_SIZE : OLD_PLT_ENTRY_SIZE) ++ ++#define MAX_GOT_SIZE (64*1024) ++ ++#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so" ++ ++ ++/* Used to implement multiple .got subsections. */ ++struct sw64_elf_got_entry ++{ ++ struct sw64_elf_got_entry *next; ++ ++ /* Which .got subsection? */ ++ bfd *gotobj; ++ ++ /* The addend in effect for this entry. */ ++ bfd_vma addend; ++ ++ /* The .got offset for this entry. */ ++ int got_offset; ++ ++ /* The .plt offset for this entry. */ ++ int plt_offset; ++ ++ /* How many references to this entry? */ ++ int use_count; ++ ++ /* The relocation type of this entry. */ ++ unsigned char reloc_type; ++ ++ /* How a LITERAL is used. */ ++ unsigned char flags; ++ ++ /* Have we initialized the dynamic relocation for this entry? */ ++ unsigned char reloc_done; ++ ++ /* Have we adjusted this entry for SEC_MERGE? */ ++ unsigned char reloc_xlated; ++}; ++ ++struct sw64_elf_reloc_entry ++{ ++ struct sw64_elf_reloc_entry *next; ++ ++ /* Which .reloc section? */ ++ asection *srel; ++ ++ /* Which section this relocation is against? */ ++ asection *sec; ++ ++ /* How many did we find? */ ++ unsigned long count; ++ ++ /* What kind of relocation? */ ++ unsigned int rtype; ++}; ++ ++struct sw64_elf_link_hash_entry ++{ ++ struct elf_link_hash_entry root; ++ ++ /* External symbol information. */ ++ EXTR esym; ++ ++ /* Cumulative flags for all the .got entries. */ ++ int flags; ++ ++ /* Contexts in which a literal was referenced. */ ++#define SW64_ELF_LINK_HASH_LU_ADDR 0x01 ++#define SW64_ELF_LINK_HASH_LU_MEM 0x02 ++#define SW64_ELF_LINK_HASH_LU_BYTE 0x04 ++#define SW64_ELF_LINK_HASH_LU_JSR 0x08 ++#define SW64_ELF_LINK_HASH_LU_TLSGD 0x10 ++#define SW64_ELF_LINK_HASH_LU_TLSLDM 0x20 ++#define SW64_ELF_LINK_HASH_LU_JSRDIRECT 0x40 ++#define SW64_ELF_LINK_HASH_LU_PLT 0x38 ++#define SW64_ELF_LINK_HASH_TLS_IE 0x80 ++ ++ /* Used to implement multiple .got subsections. */ ++ struct sw64_elf_got_entry *got_entries; ++ ++ /* Used to count non-got, non-plt relocations for delayed sizing ++ of relocation sections. */ ++ struct sw64_elf_reloc_entry *reloc_entries; ++}; ++ ++/* SW64 ELF linker hash table. */ ++ ++struct sw64_elf_link_hash_table ++{ ++ struct elf_link_hash_table root; ++ ++ /* The head of a list of .got subsections linked through ++ sw64_elf_tdata(abfd)->got_link_next. */ ++ bfd *got_list; ++ ++ /* The most recent relax pass that we've seen. The GOTs ++ should be regenerated if this doesn't match. */ ++ int relax_trip; ++}; ++ ++/* Look up an entry in a SW64 ELF linker hash table. */ ++ ++#define sw64_elf_link_hash_lookup(table, string, create, copy, follow) \ ++ ((struct sw64_elf_link_hash_entry *) \ ++ elf_link_hash_lookup (&(table)->root, (string), (create), \ ++ (copy), (follow))) ++ ++/* Traverse a SW64 ELF linker hash table. */ ++ ++#define sw64_elf_link_hash_traverse(table, func, info) \ ++ (elf_link_hash_traverse \ ++ (&(table)->root, \ ++ (bool (*) (struct elf_link_hash_entry *, void *)) (func), \ ++ (info))) ++ ++/* Get the SW64 ELF linker hash table from a link_info structure. */ ++ ++#define sw64_elf_hash_table(p) \ ++ ((is_elf_hash_table ((p)->hash) \ ++ && elf_hash_table_id (elf_hash_table (p)) == SW64_ELF_DATA) \ ++ ? (struct sw64_elf_link_hash_table *) (p)->hash : NULL) ++ ++/* Get the object's symbols as our own entry type. */ ++ ++#define sw64_elf_sym_hashes(abfd) \ ++ ((struct sw64_elf_link_hash_entry **)elf_sym_hashes(abfd)) ++ ++/* Should we do dynamic things to this symbol? This differs from the ++ generic version in that we never need to consider function pointer ++ equality wrt PLT entries -- we don't create a PLT entry if a symbol's ++ address is ever taken. */ ++ ++static inline bool ++sw64_elf_dynamic_symbol_p (struct elf_link_hash_entry *h, ++ struct bfd_link_info *info) ++{ ++ return _bfd_elf_dynamic_symbol_p (h, info, 0); ++} ++ ++/* Create an entry in a SW64 ELF linker hash table. */ ++ ++static struct bfd_hash_entry * ++elf64_sw64_link_hash_newfunc (struct bfd_hash_entry *entry, ++ struct bfd_hash_table *table, ++ const char *string) ++{ ++ struct sw64_elf_link_hash_entry *ret = ++ (struct sw64_elf_link_hash_entry *) entry; ++ ++ /* Allocate the structure if it has not already been allocated by a ++ subclass. */ ++ if (ret == (struct sw64_elf_link_hash_entry *) NULL) ++ ret = ((struct sw64_elf_link_hash_entry *) ++ bfd_hash_allocate (table, ++ sizeof (struct sw64_elf_link_hash_entry))); ++ if (ret == (struct sw64_elf_link_hash_entry *) NULL) ++ return (struct bfd_hash_entry *) ret; ++ ++ /* Call the allocation method of the superclass. */ ++ ret = ((struct sw64_elf_link_hash_entry *) ++ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, ++ table, string)); ++ if (ret != (struct sw64_elf_link_hash_entry *) NULL) ++ { ++ /* Set local fields. */ ++ memset (&ret->esym, 0, sizeof (EXTR)); ++ /* We use -2 as a marker to indicate that the information has ++ not been set. -1 means there is no associated ifd. */ ++ ret->esym.ifd = -2; ++ ret->flags = 0; ++ ret->got_entries = NULL; ++ ret->reloc_entries = NULL; ++ } ++ ++ return (struct bfd_hash_entry *) ret; ++} ++ ++/* Create a SW64 ELF linker hash table. */ ++ ++static struct bfd_link_hash_table * ++elf64_sw64_bfd_link_hash_table_create (bfd *abfd) ++{ ++ struct sw64_elf_link_hash_table *ret; ++ size_t amt = sizeof (struct sw64_elf_link_hash_table); ++ ++ ret = (struct sw64_elf_link_hash_table *) bfd_zmalloc (amt); ++ if (ret == (struct sw64_elf_link_hash_table *) NULL) ++ return NULL; ++ ++ if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, ++ elf64_sw64_link_hash_newfunc, ++ sizeof (struct sw64_elf_link_hash_entry), ++ SW64_ELF_DATA)) ++ { ++ free (ret); ++ return NULL; ++ } ++ ++ return &ret->root.root; ++} ++ ++/* SW64 ELF follows MIPS ELF in using a special find_nearest_line ++ routine in order to handle the ECOFF debugging information. */ ++ ++struct sw64_elf_find_line ++{ ++ struct ecoff_debug_info d; ++ struct ecoff_find_line i; ++}; ++ ++/* We have some private fields hanging off of the elf_tdata structure. */ ++ ++struct sw64_elf_obj_tdata ++{ ++ struct elf_obj_tdata root; ++ ++ /* For every input file, these are the got entries for that object's ++ local symbols. */ ++ struct sw64_elf_got_entry ** local_got_entries; ++ ++ /* For every input file, this is the object that owns the got that ++ this input file uses. */ ++ bfd *gotobj; ++ ++ /* For every got, this is a linked list through the objects using this got */ ++ bfd *in_got_link_next; ++ ++ /* For every got, this is a link to the next got subsegment. */ ++ bfd *got_link_next; ++ ++ /* For every got, this is the section. */ ++ asection *got; ++ ++ /* For every got, this is it's total number of words. */ ++ int total_got_size; ++ ++ /* For every got, this is the sum of the number of words required ++ to hold all of the member object's local got. */ ++ int local_got_size; ++ ++ /* Used by elf64_sw64_find_nearest_line entry point. */ ++ struct sw64_elf_find_line *find_line_info; ++ ++}; ++ ++#define sw64_elf_tdata(abfd) \ ++ ((struct sw64_elf_obj_tdata *) (abfd)->tdata.any) ++ ++#define is_sw64_elf(bfd) \ ++ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \ ++ && elf_tdata (bfd) != NULL \ ++ && elf_object_id (bfd) == SW64_ELF_DATA) ++ ++static bool ++elf64_sw64_mkobject (bfd *abfd) ++{ ++ return bfd_elf_allocate_object (abfd, sizeof (struct sw64_elf_obj_tdata), ++ SW64_ELF_DATA); ++} ++ ++static bool ++elf64_sw64_object_p (bfd *abfd) ++{ ++ /* Set the right machine number for an SW64 ELF file. */ ++ return bfd_default_set_arch_mach (abfd, bfd_arch_sw64, 0); ++} ++ ++/* A relocation function which doesn't do anything. */ ++ ++static bfd_reloc_status_type ++elf64_sw64_reloc_nil (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc, ++ asymbol *sym ATTRIBUTE_UNUSED, ++ void * data ATTRIBUTE_UNUSED, asection *sec, ++ bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED) ++{ ++ if (output_bfd) ++ reloc->address += sec->output_offset; ++ return bfd_reloc_ok; ++} ++ ++/* A relocation function used for an unsupported reloc. */ ++ ++static bfd_reloc_status_type ++elf64_sw64_reloc_bad (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc, ++ asymbol *sym ATTRIBUTE_UNUSED, ++ void * data ATTRIBUTE_UNUSED, asection *sec, ++ bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED) ++{ ++ if (output_bfd) ++ reloc->address += sec->output_offset; ++ return bfd_reloc_notsupported; ++} ++ ++/* Do the work of the GPDISP relocation. */ ++ ++static bfd_reloc_status_type ++elf64_sw64_do_reloc_gpdisp (bfd *abfd, bfd_vma gpdisp, bfd_byte *p_ldah, ++ bfd_byte *p_lda) ++{ ++ bfd_reloc_status_type ret = bfd_reloc_ok; ++ bfd_vma addend; ++ unsigned long i_ldah, i_lda; ++ ++ i_ldah = bfd_get_32 (abfd, p_ldah); ++ i_lda = bfd_get_32 (abfd, p_lda); ++ ++ /* Complain if the instructions are not correct. */ ++ if (((i_ldah >> 26) & 0x3f) != 0x09 ++ || ((i_lda >> 26) & 0x3f) != 0x08) ++ ret = bfd_reloc_dangerous; ++ ++ /* Extract the user-supplied offset, mirroring the sign extensions ++ that the instructions perform. */ ++ addend = ((i_ldah & 0xffff) << 16) | (i_lda & 0xffff); ++ addend = (addend ^ 0x80008000) - 0x80008000; ++ ++ gpdisp += addend; ++ ++ if ((bfd_signed_vma) gpdisp < -(bfd_signed_vma) 0x80000000 ++ || (bfd_signed_vma) gpdisp >= (bfd_signed_vma) 0x7fff8000) ++ ret = bfd_reloc_overflow; ++ ++ /* compensate for the sign extension again. */ ++ i_ldah = ((i_ldah & 0xffff0000) ++ | (((gpdisp >> 16) + ((gpdisp >> 15) & 1)) & 0xffff)); ++ i_lda = (i_lda & 0xffff0000) | (gpdisp & 0xffff); ++ ++ bfd_put_32 (abfd, (bfd_vma) i_ldah, p_ldah); ++ bfd_put_32 (abfd, (bfd_vma) i_lda, p_lda); ++ ++ return ret; ++} ++ ++/* The special function for the GPDISP reloc. */ ++ ++static bfd_reloc_status_type ++elf64_sw64_reloc_gpdisp (bfd *abfd, arelent *reloc_entry, ++ asymbol *sym ATTRIBUTE_UNUSED, void * data, ++ asection *input_section, bfd *output_bfd, ++ char **err_msg) ++{ ++ bfd_reloc_status_type ret; ++ bfd_vma gp, relocation; ++ bfd_vma high_address; ++ bfd_byte *p_ldah, *p_lda; ++ ++ /* Don't do anything if we're not doing a final link. */ ++ if (output_bfd) ++ { ++ reloc_entry->address += input_section->output_offset; ++ return bfd_reloc_ok; ++ } ++ ++ high_address = bfd_get_section_limit (abfd, input_section); ++ if (reloc_entry->address > high_address ++ || reloc_entry->address + reloc_entry->addend > high_address) ++ return bfd_reloc_outofrange; ++ ++ /* The gp used in the portion of the output object to which this ++ input object belongs is cached on the input bfd. */ ++ gp = _bfd_get_gp_value (abfd); ++ ++ relocation = (input_section->output_section->vma ++ + input_section->output_offset ++ + reloc_entry->address); ++ ++ p_ldah = (bfd_byte *) data + reloc_entry->address; ++ p_lda = p_ldah + reloc_entry->addend; ++ ++ ret = elf64_sw64_do_reloc_gpdisp (abfd, gp - relocation, p_ldah, p_lda); ++ ++ /* Complain if the instructions are not correct. */ ++ if (ret == bfd_reloc_dangerous) ++ *err_msg = _("GPDISP relocation did not find ldah and lda instructions"); ++ ++ return ret; ++} ++ ++/* In case we're on a 32-bit machine, construct a 64-bit "-1" value ++ from smaller values. Start with zero, widen, *then* decrement. */ ++#define MINUS_ONE (((bfd_vma)0) - 1) ++ ++ ++#define SKIP_HOWTO(N) \ ++ HOWTO(N, 0, 0, 0, 0, 0, complain_overflow_dont, elf64_sw64_reloc_bad, 0, 0, 0, 0, 0) ++ ++static reloc_howto_type elf64_sw64_howto_table[] = ++{ ++ HOWTO (R_SW64_NONE, /* type */ ++ 0, /* rightshift */ ++ 0, /* size */ ++ 0, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ elf64_sw64_reloc_nil, /* special_function */ ++ "NONE", /* name */ ++ false, /* partial_inplace */ ++ 0, /* src_mask */ ++ 0, /* dst_mask */ ++ true), /* pcrel_offset */ ++ ++ /* A 32 bit reference to a symbol. */ ++ HOWTO (R_SW64_REFLONG, /* type */ ++ 0, /* rightshift */ ++ 4, /* size */ ++ 32, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_bitfield, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "REFLONG", /* name */ ++ false, /* partial_inplace */ ++ 0xffffffff, /* src_mask */ ++ 0xffffffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A 64 bit reference to a symbol. */ ++ HOWTO (R_SW64_REFQUAD, /* type */ ++ 0, /* rightshift */ ++ 8, /* size */ ++ 64, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_bitfield, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "REFQUAD", /* name */ ++ false, /* partial_inplace */ ++ MINUS_ONE, /* src_mask */ ++ MINUS_ONE, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A 32 bit GP relative offset. This is just like REFLONG except ++ that when the value is used the value of the gp register will be ++ added in. */ ++ HOWTO (R_SW64_GPREL32, /* type */ ++ 0, /* rightshift */ ++ 4, /* size */ ++ 32, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_bitfield, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "GPREL32", /* name */ ++ false, /* partial_inplace */ ++ 0xffffffff, /* src_mask */ ++ 0xffffffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Used for an instruction that refers to memory off the GP register. */ ++ HOWTO (R_SW64_LITERAL, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "ELF_LITERAL", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* This reloc only appears immediately following an ELF_LITERAL reloc. ++ It identifies a use of the literal. The symbol index is special: ++ 1 means the literal address is in the base register of a memory ++ format instruction; 2 means the literal address is in the byte ++ offset register of a byte-manipulation instruction; 3 means the ++ literal address is in the target register of a jsr instruction. ++ This does not actually do any relocation. */ ++ HOWTO (R_SW64_LITUSE, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 32, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ elf64_sw64_reloc_nil, /* special_function */ ++ "LITUSE", /* name */ ++ false, /* partial_inplace */ ++ 0, /* src_mask */ ++ 0, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Load the gp register. This is always used for a ldah instruction ++ which loads the upper 16 bits of the gp register. The symbol ++ index of the GPDISP instruction is an offset in bytes to the lda ++ instruction that loads the lower 16 bits. The value to use for ++ the relocation is the difference between the GP value and the ++ current location; the load will always be done against a register ++ holding the current address. ++ ++ NOTE: Unlike ECOFF, partial in-place relocation is not done. If ++ any offset is present in the instructions, it is an offset from ++ the register to the ldah instruction. This lets us avoid any ++ stupid hackery like inventing a gp value to do partial relocation ++ against. Also unlike ECOFF, we do the whole relocation off of ++ the GPDISP rather than a GPDISP_HI16/GPDISP_LO16 pair. An odd, ++ space consuming bit, that, since all the information was present ++ in the GPDISP_HI16 reloc. */ ++ HOWTO (R_SW64_GPDISP, /* type */ ++ 16, /* rightshift */ ++ 4, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ elf64_sw64_reloc_gpdisp, /* special_function */ ++ "GPDISP", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ true), /* pcrel_offset */ ++ ++ /* A 21 bit branch. */ ++ HOWTO (R_SW64_BRADDR, /* type */ ++ 2, /* rightshift */ ++ 4, /* size */ ++ 21, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "BRADDR", /* name */ ++ false, /* partial_inplace */ ++ 0x1fffff, /* src_mask */ ++ 0x1fffff, /* dst_mask */ ++ true), /* pcrel_offset */ ++ ++ /* A hint for a jump to a register. */ ++ HOWTO (R_SW64_HINT, /* type */ ++ 2, /* rightshift */ ++ 2, /* size */ ++ 14, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "HINT", /* name */ ++ false, /* partial_inplace */ ++ 0x3fff, /* src_mask */ ++ 0x3fff, /* dst_mask */ ++ true), /* pcrel_offset */ ++ ++ /* 16 bit PC relative offset. */ ++ HOWTO (R_SW64_SREL16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "SREL16", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ true), /* pcrel_offset */ ++ ++ /* 32 bit PC relative offset. */ ++ HOWTO (R_SW64_SREL32, /* type */ ++ 0, /* rightshift */ ++ 4, /* size */ ++ 32, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "SREL32", /* name */ ++ false, /* partial_inplace */ ++ 0xffffffff, /* src_mask */ ++ 0xffffffff, /* dst_mask */ ++ true), /* pcrel_offset */ ++ ++ /* A 64 bit PC relative offset. */ ++ HOWTO (R_SW64_SREL64, /* type */ ++ 0, /* rightshift */ ++ 8, /* size */ ++ 64, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "SREL64", /* name */ ++ false, /* partial_inplace */ ++ MINUS_ONE, /* src_mask */ ++ MINUS_ONE, /* dst_mask */ ++ true), /* pcrel_offset */ ++ ++ /* Skip 12 - 16; deprecated ECOFF relocs. */ ++ SKIP_HOWTO (12), ++ SKIP_HOWTO (13), ++ SKIP_HOWTO (14), ++ SKIP_HOWTO (15), ++ SKIP_HOWTO (16), ++ ++ /* The high 16 bits of the displacement from GP to the target. */ ++ HOWTO (R_SW64_GPRELHIGH, ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "GPRELHIGH", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* The low 16 bits of the displacement from GP to the target. */ ++ HOWTO (R_SW64_GPRELLOW, ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "GPRELLOW", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A 16-bit displacement from the GP to the target. */ ++ HOWTO (R_SW64_GPREL16, ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "GPREL16", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Skip 20 - 23; deprecated ECOFF relocs. */ ++ SKIP_HOWTO (20), ++ SKIP_HOWTO (21), ++ SKIP_HOWTO (22), ++ SKIP_HOWTO (23), ++ ++ /* Misc ELF relocations. */ ++ ++ /* A dynamic relocation to copy the target into our .dynbss section. */ ++ /* Not generated, as all SW64 objects use PIC, so it is not needed. It ++ is present because every other ELF has one, but should not be used ++ because .dynbss is an ugly thing. */ ++ HOWTO (R_SW64_COPY, ++ 0, ++ 0, ++ 0, ++ false, ++ 0, ++ complain_overflow_dont, ++ bfd_elf_generic_reloc, ++ "COPY", ++ false, ++ 0, ++ 0, ++ true), ++ ++ /* A dynamic relocation for a .got entry. */ ++ HOWTO (R_SW64_GLOB_DAT, ++ 0, ++ 0, ++ 0, ++ false, ++ 0, ++ complain_overflow_dont, ++ bfd_elf_generic_reloc, ++ "GLOB_DAT", ++ false, ++ 0, ++ 0, ++ true), ++ ++ /* A dynamic relocation for a .plt entry. */ ++ HOWTO (R_SW64_JMP_SLOT, ++ 0, ++ 0, ++ 0, ++ false, ++ 0, ++ complain_overflow_dont, ++ bfd_elf_generic_reloc, ++ "JMP_SLOT", ++ false, ++ 0, ++ 0, ++ true), ++ ++ /* A dynamic relocation to add the base of the DSO to a 64-bit field. */ ++ HOWTO (R_SW64_RELATIVE, ++ 0, ++ 0, ++ 0, ++ false, ++ 0, ++ complain_overflow_dont, ++ bfd_elf_generic_reloc, ++ "RELATIVE", ++ false, ++ 0, ++ 0, ++ true), ++ ++ /* A 21 bit branch that adjusts for gp loads. */ ++ HOWTO (R_SW64_BRSGP, /* type */ ++ 2, /* rightshift */ ++ 4, /* size */ ++ 21, /* bitsize */ ++ true, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "BRSGP", /* name */ ++ false, /* partial_inplace */ ++ 0x1fffff, /* src_mask */ ++ 0x1fffff, /* dst_mask */ ++ true), /* pcrel_offset */ ++ ++ /* Creates a tls_index for the symbol in the got. */ ++ HOWTO (R_SW64_TLSGD, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "TLSGD", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Creates a tls_index for the (current) module in the got. */ ++ HOWTO (R_SW64_TLSLDM, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "TLSLDM", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A dynamic relocation for a DTP module entry. */ ++ HOWTO (R_SW64_DTPMOD64, /* type */ ++ 0, /* rightshift */ ++ 8, /* size */ ++ 64, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_bitfield, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "DTPMOD64", /* name */ ++ false, /* partial_inplace */ ++ MINUS_ONE, /* src_mask */ ++ MINUS_ONE, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Creates a 64-bit offset in the got for the displacement ++ from DTP to the target. */ ++ HOWTO (R_SW64_GOTDTPREL, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "GOTDTPREL", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A dynamic relocation for a displacement from DTP to the target. */ ++ HOWTO (R_SW64_DTPREL64, /* type */ ++ 0, /* rightshift */ ++ 8, /* size */ ++ 64, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_bitfield, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "DTPREL64", /* name */ ++ false, /* partial_inplace */ ++ MINUS_ONE, /* src_mask */ ++ MINUS_ONE, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* The high 16 bits of the displacement from DTP to the target. */ ++ HOWTO (R_SW64_DTPRELHI, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "DTPRELHI", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* The low 16 bits of the displacement from DTP to the target. */ ++ HOWTO (R_SW64_DTPRELLO, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "DTPRELLO", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A 16-bit displacement from DTP to the target. */ ++ HOWTO (R_SW64_DTPREL16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "DTPREL16", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* Creates a 64-bit offset in the got for the displacement ++ from TP to the target. */ ++ HOWTO (R_SW64_GOTTPREL, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "GOTTPREL", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A dynamic relocation for a displacement from TP to the target. */ ++ HOWTO (R_SW64_TPREL64, /* type */ ++ 0, /* rightshift */ ++ 8, /* size */ ++ 64, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_bitfield, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "TPREL64", /* name */ ++ false, /* partial_inplace */ ++ MINUS_ONE, /* src_mask */ ++ MINUS_ONE, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* The high 16 bits of the displacement from TP to the target. */ ++ HOWTO (R_SW64_TPRELHI, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "TPRELHI", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* The low 16 bits of the displacement from TP to the target. */ ++ HOWTO (R_SW64_TPRELLO, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_dont, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "TPRELLO", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++ ++ /* A 16-bit displacement from TP to the target. */ ++ HOWTO (R_SW64_TPREL16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size */ ++ 16, /* bitsize */ ++ false, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ bfd_elf_generic_reloc, /* special_function */ ++ "TPREL16", /* name */ ++ false, /* partial_inplace */ ++ 0xffff, /* src_mask */ ++ 0xffff, /* dst_mask */ ++ false), /* pcrel_offset */ ++}; ++ ++/* A mapping from BFD reloc types to SW64 ELF reloc types. */ ++ ++struct elf_reloc_map ++{ ++ bfd_reloc_code_real_type bfd_reloc_val; ++ int elf_reloc_val; ++}; ++ ++static const struct elf_reloc_map elf64_sw64_reloc_map[] = ++{ ++ {BFD_RELOC_NONE, R_SW64_NONE}, ++ {BFD_RELOC_32, R_SW64_REFLONG}, ++ {BFD_RELOC_64, R_SW64_REFQUAD}, ++ {BFD_RELOC_CTOR, R_SW64_REFQUAD}, ++ {BFD_RELOC_GPREL32, R_SW64_GPREL32}, ++ {BFD_RELOC_SW64_ELF_LITERAL, R_SW64_LITERAL}, ++ {BFD_RELOC_SW64_LITUSE, R_SW64_LITUSE}, ++ {BFD_RELOC_SW64_GPDISP, R_SW64_GPDISP}, ++ {BFD_RELOC_23_PCREL_S2, R_SW64_BRADDR}, ++ {BFD_RELOC_SW64_HINT, R_SW64_HINT}, ++ {BFD_RELOC_16_PCREL, R_SW64_SREL16}, ++ {BFD_RELOC_32_PCREL, R_SW64_SREL32}, ++ {BFD_RELOC_64_PCREL, R_SW64_SREL64}, ++ {BFD_RELOC_SW64_GPREL_HI16, R_SW64_GPRELHIGH}, ++ {BFD_RELOC_SW64_GPREL_LO16, R_SW64_GPRELLOW}, ++ {BFD_RELOC_GPREL16, R_SW64_GPREL16}, ++ {BFD_RELOC_SW64_BRSGP, R_SW64_BRSGP}, ++ {BFD_RELOC_SW64_TLSGD, R_SW64_TLSGD}, ++ {BFD_RELOC_SW64_TLSLDM, R_SW64_TLSLDM}, ++ {BFD_RELOC_SW64_DTPMOD64, R_SW64_DTPMOD64}, ++ {BFD_RELOC_SW64_GOTDTPREL16, R_SW64_GOTDTPREL}, ++ {BFD_RELOC_SW64_DTPREL64, R_SW64_DTPREL64}, ++ {BFD_RELOC_SW64_DTPREL_HI16, R_SW64_DTPRELHI}, ++ {BFD_RELOC_SW64_DTPREL_LO16, R_SW64_DTPRELLO}, ++ {BFD_RELOC_SW64_DTPREL16, R_SW64_DTPREL16}, ++ {BFD_RELOC_SW64_GOTTPREL16, R_SW64_GOTTPREL}, ++ {BFD_RELOC_SW64_TPREL64, R_SW64_TPREL64}, ++ {BFD_RELOC_SW64_TPREL_HI16, R_SW64_TPRELHI}, ++ {BFD_RELOC_SW64_TPREL_LO16, R_SW64_TPRELLO}, ++ {BFD_RELOC_SW64_TPREL16, R_SW64_TPREL16}, ++}; ++ ++/* Given a BFD reloc type, return a HOWTO structure. */ ++ ++static reloc_howto_type * ++elf64_sw64_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, ++ bfd_reloc_code_real_type code) ++{ ++ const struct elf_reloc_map *i, *e; ++ i = e = elf64_sw64_reloc_map; ++ e += sizeof (elf64_sw64_reloc_map) / sizeof (struct elf_reloc_map); ++ for (; i != e; ++i) ++ { ++ if (i->bfd_reloc_val == code) ++ return &elf64_sw64_howto_table[i->elf_reloc_val]; ++ } ++ return 0; ++} ++ ++static reloc_howto_type * ++elf64_sw64_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, ++ const char *r_name) ++{ ++ unsigned int i; ++ ++ for (i = 0; ++ i < (sizeof (elf64_sw64_howto_table) ++ / sizeof (elf64_sw64_howto_table[0])); ++ i++) ++ if (elf64_sw64_howto_table[i].name != NULL ++ && strcasecmp (elf64_sw64_howto_table[i].name, r_name) == 0) ++ return &elf64_sw64_howto_table[i]; ++ ++ return NULL; ++} ++ ++/* Given an SW64 ELF reloc type, fill in an arelent structure. */ ++ ++static bool ++elf64_sw64_info_to_howto (bfd *abfd, arelent *cache_ptr, ++ Elf_Internal_Rela *dst) ++{ ++ unsigned r_type = ELF64_R_TYPE(dst->r_info); ++ ++ if (r_type >= R_SW64_max) ++ { ++ /* xgettext:c-format */ ++ _bfd_error_handler (_("%pB: unsupported relocation type %#x"), ++ abfd, r_type); ++ bfd_set_error (bfd_error_bad_value); ++ return false; ++ } ++ cache_ptr->howto = &elf64_sw64_howto_table[r_type]; ++ return true; ++} ++ ++/* These two relocations create a two-word entry in the got. */ ++#define sw64_got_entry_size(r_type) \ ++ (r_type == R_SW64_TLSGD || r_type == R_SW64_TLSLDM ? 16 : 8) ++ ++/* This is PT_TLS segment p_vaddr. */ ++#define sw64_get_dtprel_base(info) \ ++ (elf_hash_table (info)->tls_sec->vma) ++ ++/* Main program TLS (whose template starts at PT_TLS p_vaddr) ++ is assigned offset round(16, PT_TLS p_align). */ ++#define sw64_get_tprel_base(info) \ ++ (elf_hash_table (info)->tls_sec->vma \ ++ - align_power ((bfd_vma) 16, \ ++ elf_hash_table (info)->tls_sec->alignment_power)) ++ ++/* Handle an SW64 specific section when reading an object file. This ++ is called when bfd_section_from_shdr finds a section with an unknown ++ type. */ ++ ++static bool ++elf64_sw64_section_from_shdr (bfd *abfd, ++ Elf_Internal_Shdr *hdr, ++ const char *name, ++ int shindex) ++{ ++ asection *newsect; ++ ++ /* There ought to be a place to keep ELF backend specific flags, but ++ at the moment there isn't one. We just keep track of the ++ sections by their name, instead. Fortunately, the ABI gives ++ suggested names for all the MIPS specific sections, so we will ++ probably get away with this. */ ++ switch (hdr->sh_type) ++ { ++ case SHT_SW64_DEBUG: ++ if (strcmp (name, ".mdebug") != 0) ++ return false; ++ break; ++ default: ++ return false; ++ } ++ ++ if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) ++ return false; ++ newsect = hdr->bfd_section; ++ ++ if (hdr->sh_type == SHT_SW64_DEBUG) ++ { ++ if (!bfd_set_section_flags (newsect, ++ bfd_section_flags (newsect) | SEC_DEBUGGING)) ++ return false; ++ } ++ ++ return true; ++} ++ ++/* Convert SW64 specific section flags to bfd internal section flags. */ ++ ++static bool ++elf64_sw64_section_flags (const Elf_Internal_Shdr *hdr) ++{ ++ if (hdr->sh_flags & SHF_SW64_GPREL) ++ hdr->bfd_section->flags |= SEC_SMALL_DATA; ++ ++ return true; ++} ++ ++/* Set the correct type for an SW64 ELF section. We do this by the ++ section name, which is a hack, but ought to work. */ ++ ++static bool ++elf64_sw64_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec) ++{ ++ register const char *name; ++ ++ name = bfd_section_name (sec); ++ ++ if (strcmp (name, ".mdebug") == 0) ++ { ++ hdr->sh_type = SHT_SW64_DEBUG; ++ /* In a shared object on Irix 5.3, the .mdebug section has an ++ entsize of 0. FIXME: Does this matter? */ ++ if ((abfd->flags & DYNAMIC) != 0 ) ++ hdr->sh_entsize = 0; ++ else ++ hdr->sh_entsize = 1; ++ } ++ else if ((sec->flags & SEC_SMALL_DATA) ++ || strcmp (name, ".sdata") == 0 ++ || strcmp (name, ".sbss") == 0 ++ || strcmp (name, ".lit4") == 0 ++ || strcmp (name, ".lit8") == 0) ++ hdr->sh_flags |= SHF_SW64_GPREL; ++ ++ return true; ++} ++ ++/* Hook called by the linker routine which adds symbols from an object ++ file. We use it to put .comm items in .sbss, and not .bss. */ ++ ++static bool ++elf64_sw64_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, ++ Elf_Internal_Sym *sym, ++ const char **namep ATTRIBUTE_UNUSED, ++ flagword *flagsp ATTRIBUTE_UNUSED, ++ asection **secp, bfd_vma *valp) ++{ ++ if (sym->st_shndx == SHN_COMMON ++ && !bfd_link_relocatable (info) ++ && sym->st_size <= elf_gp_size (abfd)) ++ { ++ /* Common symbols less than or equal to -G nn bytes are ++ automatically put into .sbss. */ ++ ++ asection *scomm = bfd_get_section_by_name (abfd, ".scommon"); ++ ++ if (scomm == NULL) ++ { ++ scomm = bfd_make_section_with_flags (abfd, ".scommon", ++ (SEC_ALLOC ++ | SEC_IS_COMMON ++ | SEC_SMALL_DATA ++ | SEC_LINKER_CREATED)); ++ if (scomm == NULL) ++ return false; ++ } ++ ++ *secp = scomm; ++ *valp = sym->st_size; ++ } ++ ++ return true; ++} ++ ++/* Create the .got section. */ ++ ++static bool ++elf64_sw64_create_got_section (bfd *abfd, ++ struct bfd_link_info *info ATTRIBUTE_UNUSED) ++{ ++ flagword flags; ++ asection *s; ++ ++ if (! is_sw64_elf (abfd)) ++ return false; ++ ++ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY ++ | SEC_LINKER_CREATED); ++ s = bfd_make_section_anyway_with_flags (abfd, ".got", flags); ++ if (s == NULL ++ || !bfd_set_section_alignment (s, 3)) ++ return false; ++ ++ sw64_elf_tdata (abfd)->got = s; ++ ++ /* Make sure the object's gotobj is set to itself so that we default ++ to every object with its own .got. We'll merge .gots later once ++ we've collected each object's info. */ ++ sw64_elf_tdata (abfd)->gotobj = abfd; ++ ++ return true; ++} ++ ++/* Create all the dynamic sections. */ ++ ++static bool ++elf64_sw64_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) ++{ ++ asection *s; ++ flagword flags; ++ struct elf_link_hash_entry *h; ++ ++ if (! is_sw64_elf (abfd)) ++ return false; ++ ++ /* We need to create .plt, .rela.plt, .got, and .rela.got sections. */ ++ ++ flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY ++ | SEC_LINKER_CREATED ++ | (elf64_sw64_use_secureplt ? SEC_READONLY : 0)); ++ s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags); ++ elf_hash_table (info)->splt = s; ++ if (s == NULL || ! bfd_set_section_alignment (s, 4)) ++ return false; ++ ++ /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the ++ .plt section. */ ++ h = _bfd_elf_define_linkage_sym (abfd, info, s, ++ "_PROCEDURE_LINKAGE_TABLE_"); ++ elf_hash_table (info)->hplt = h; ++ if (h == NULL) ++ return false; ++ ++ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY ++ | SEC_LINKER_CREATED | SEC_READONLY); ++ s = bfd_make_section_anyway_with_flags (abfd, ".rela.plt", flags); ++ elf_hash_table (info)->srelplt = s; ++ if (s == NULL || ! bfd_set_section_alignment (s, 3)) ++ return false; ++ ++ if (elf64_sw64_use_secureplt) ++ { ++ flags = SEC_ALLOC | SEC_LINKER_CREATED; ++ s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags); ++ elf_hash_table (info)->sgotplt = s; ++ if (s == NULL || ! bfd_set_section_alignment (s, 3)) ++ return false; ++ } ++ ++ /* We may or may not have created a .got section for this object, but ++ we definitely havn't done the rest of the work. */ ++ ++ if (sw64_elf_tdata(abfd)->gotobj == NULL) ++ { ++ if (!elf64_sw64_create_got_section (abfd, info)) ++ return false; ++ } ++ ++ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY ++ | SEC_LINKER_CREATED | SEC_READONLY); ++ s = bfd_make_section_anyway_with_flags (abfd, ".rela.got", flags); ++ elf_hash_table (info)->srelgot = s; ++ if (s == NULL ++ || !bfd_set_section_alignment (s, 3)) ++ return false; ++ ++ /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the ++ dynobj's .got section. We don't do this in the linker script ++ because we don't want to define the symbol if we are not creating ++ a global offset table. */ ++ h = _bfd_elf_define_linkage_sym (abfd, info, sw64_elf_tdata(abfd)->got, ++ "_GLOBAL_OFFSET_TABLE_"); ++ elf_hash_table (info)->hgot = h; ++ if (h == NULL) ++ return false; ++ ++ return true; ++} ++ ++/* Read ECOFF debugging information from a .mdebug section into a ++ ecoff_debug_info structure. */ ++ ++static bool ++elf64_sw64_read_ecoff_info (bfd *abfd, asection *section, ++ struct ecoff_debug_info *debug) ++{ ++ HDRR *symhdr; ++ const struct ecoff_debug_swap *swap; ++ char *ext_hdr = NULL; ++ ++ swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap; ++ memset (debug, 0, sizeof (*debug)); ++ ++ ext_hdr = (char *) bfd_malloc (swap->external_hdr_size); ++ if (ext_hdr == NULL && swap->external_hdr_size != 0) ++ goto error_return; ++ ++ if (! bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0, ++ swap->external_hdr_size)) ++ goto error_return; ++ ++ symhdr = &debug->symbolic_header; ++ (*swap->swap_hdr_in) (abfd, ext_hdr, symhdr); ++ ++ /* The symbolic header contains absolute file offsets and sizes to ++ read. */ ++#define READ(ptr, offset, count, size, type) \ ++ do \ ++ { \ ++ size_t amt; \ ++ debug->ptr = NULL; \ ++ if (symhdr->count == 0) \ ++ break; \ ++ if (_bfd_mul_overflow (size, symhdr->count, &amt)) \ ++ { \ ++ bfd_set_error (bfd_error_file_too_big); \ ++ goto error_return; \ ++ } \ ++ if (bfd_seek (abfd, symhdr->offset, SEEK_SET) != 0) \ ++ goto error_return; \ ++ debug->ptr = (type) _bfd_malloc_and_read (abfd, amt, amt); \ ++ if (debug->ptr == NULL) \ ++ goto error_return; \ ++ } while (0) ++ ++ READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *); ++ READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, void *); ++ READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, void *); ++ READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, void *); ++ READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, void *); ++ READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext), ++ union aux_ext *); ++ READ (ss, cbSsOffset, issMax, sizeof (char), char *); ++ READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *); ++ READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, void *); ++ READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, void *); ++ READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, void *); ++#undef READ ++ ++ debug->fdr = NULL; ++ ++ return true; ++ ++ error_return: ++ free (ext_hdr); ++ _bfd_ecoff_free_ecoff_debug_info (debug); ++ return false; ++} ++ ++/* SW64 ELF local labels start with '$'. */ ++ ++static bool ++elf64_sw64_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name) ++{ ++ return name[0] == '$'; ++} ++ ++static bool ++elf64_sw64_find_nearest_line (bfd *abfd, asymbol **symbols, ++ asection *section, bfd_vma offset, ++ const char **filename_ptr, ++ const char **functionname_ptr, ++ unsigned int *line_ptr, ++ unsigned int *discriminator_ptr) ++{ ++ asection *msec; ++ ++ if (_bfd_dwarf2_find_nearest_line (abfd, symbols, NULL, section, offset, ++ filename_ptr, functionname_ptr, ++ line_ptr, discriminator_ptr, ++ dwarf_debug_sections, ++ &elf_tdata (abfd)->dwarf2_find_line_info) ++ == 1) ++ return true; ++ ++ msec = bfd_get_section_by_name (abfd, ".mdebug"); ++ if (msec != NULL) ++ { ++ flagword origflags; ++ struct sw64_elf_find_line *fi; ++ const struct ecoff_debug_swap * const swap = ++ get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap; ++ ++ /* If we are called during a link, sw64_elf_final_link may have ++ cleared the SEC_HAS_CONTENTS field. We force it back on here ++ if appropriate (which it normally will be). */ ++ origflags = msec->flags; ++ if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS) ++ msec->flags |= SEC_HAS_CONTENTS; ++ ++ fi = sw64_elf_tdata (abfd)->find_line_info; ++ if (fi == NULL) ++ { ++ bfd_size_type external_fdr_size; ++ char *fraw_src; ++ char *fraw_end; ++ struct fdr *fdr_ptr; ++ bfd_size_type amt = sizeof (struct sw64_elf_find_line); ++ ++ fi = (struct sw64_elf_find_line *) bfd_zalloc (abfd, amt); ++ if (fi == NULL) ++ { ++ msec->flags = origflags; ++ return false; ++ } ++ ++ if (!elf64_sw64_read_ecoff_info (abfd, msec, &fi->d)) ++ { ++ msec->flags = origflags; ++ return false; ++ } ++ ++ /* Swap in the FDR information. */ ++ amt = fi->d.symbolic_header.ifdMax * sizeof (struct fdr); ++ fi->d.fdr = (struct fdr *) bfd_alloc (abfd, amt); ++ if (fi->d.fdr == NULL) ++ { ++ msec->flags = origflags; ++ return false; ++ } ++ external_fdr_size = swap->external_fdr_size; ++ fdr_ptr = fi->d.fdr; ++ fraw_src = (char *) fi->d.external_fdr; ++ fraw_end = (fraw_src ++ + fi->d.symbolic_header.ifdMax * external_fdr_size); ++ for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++) ++ (*swap->swap_fdr_in) (abfd, fraw_src, fdr_ptr); ++ ++ sw64_elf_tdata (abfd)->find_line_info = fi; ++ } ++ ++ if (_bfd_ecoff_locate_line (abfd, section, offset, &fi->d, swap, ++ &fi->i, filename_ptr, functionname_ptr, ++ line_ptr)) ++ { ++ msec->flags = origflags; ++ return true; ++ } ++ ++ msec->flags = origflags; ++ } ++ ++ /* Fall back on the generic ELF find_nearest_line routine. */ ++ ++ return _bfd_elf_find_nearest_line (abfd, symbols, section, offset, ++ filename_ptr, functionname_ptr, ++ line_ptr, discriminator_ptr); ++} ++ ++/* Structure used to pass information to sw64_elf_output_extsym. */ ++ ++struct extsym_info ++{ ++ bfd *abfd; ++ struct bfd_link_info *info; ++ struct ecoff_debug_info *debug; ++ const struct ecoff_debug_swap *swap; ++ bool failed; ++}; ++ ++static bool ++elf64_sw64_output_extsym (struct elf_link_hash_entry *x, void * data) ++{ ++ struct sw64_elf_link_hash_entry *h = (struct sw64_elf_link_hash_entry *) x; ++ struct extsym_info *einfo = (struct extsym_info *) data; ++ bool strip; ++ asection *sec, *output_section; ++ ++ if (h->root.indx == -2) ++ strip = false; ++ else if ((h->root.def_dynamic ++ || h->root.ref_dynamic ++ || h->root.root.type == bfd_link_hash_new) ++ && !h->root.def_regular ++ && !h->root.ref_regular) ++ strip = true; ++ else if (einfo->info->strip == strip_all ++ || (einfo->info->strip == strip_some ++ && bfd_hash_lookup (einfo->info->keep_hash, ++ h->root.root.root.string, ++ false, false) == NULL)) ++ strip = true; ++ else ++ strip = false; ++ ++ if (strip) ++ return true; ++ ++ if (h->esym.ifd == -2) ++ { ++ h->esym.jmptbl = 0; ++ h->esym.cobol_main = 0; ++ h->esym.weakext = 0; ++ h->esym.reserved = 0; ++ h->esym.ifd = ifdNil; ++ h->esym.asym.value = 0; ++ h->esym.asym.st = stGlobal; ++ ++ if (h->root.root.type != bfd_link_hash_defined ++ && h->root.root.type != bfd_link_hash_defweak) ++ h->esym.asym.sc = scAbs; ++ else ++ { ++ const char *name; ++ ++ sec = h->root.root.u.def.section; ++ output_section = sec->output_section; ++ ++ /* When making a shared library and symbol h is the one from ++ the another shared library, OUTPUT_SECTION may be null. */ ++ if (output_section == NULL) ++ h->esym.asym.sc = scUndefined; ++ else ++ { ++ name = bfd_section_name (output_section); ++ ++ if (strcmp (name, ".text") == 0) ++ h->esym.asym.sc = scText; ++ else if (strcmp (name, ".data") == 0) ++ h->esym.asym.sc = scData; ++ else if (strcmp (name, ".sdata") == 0) ++ h->esym.asym.sc = scSData; ++ else if (strcmp (name, ".rodata") == 0 ++ || strcmp (name, ".rdata") == 0) ++ h->esym.asym.sc = scRData; ++ else if (strcmp (name, ".bss") == 0) ++ h->esym.asym.sc = scBss; ++ else if (strcmp (name, ".sbss") == 0) ++ h->esym.asym.sc = scSBss; ++ else if (strcmp (name, ".init") == 0) ++ h->esym.asym.sc = scInit; ++ else if (strcmp (name, ".fini") == 0) ++ h->esym.asym.sc = scFini; ++ else ++ h->esym.asym.sc = scAbs; ++ } ++ } ++ ++ h->esym.asym.reserved = 0; ++ h->esym.asym.index = indexNil; ++ } ++ ++ if (h->root.root.type == bfd_link_hash_common) ++ h->esym.asym.value = h->root.root.u.c.size; ++ else if (h->root.root.type == bfd_link_hash_defined ++ || h->root.root.type == bfd_link_hash_defweak) ++ { ++ if (h->esym.asym.sc == scCommon) ++ h->esym.asym.sc = scBss; ++ else if (h->esym.asym.sc == scSCommon) ++ h->esym.asym.sc = scSBss; ++ ++ sec = h->root.root.u.def.section; ++ output_section = sec->output_section; ++ if (output_section != NULL) ++ h->esym.asym.value = (h->root.root.u.def.value ++ + sec->output_offset ++ + output_section->vma); ++ else ++ h->esym.asym.value = 0; ++ } ++ ++ if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap, ++ h->root.root.root.string, ++ &h->esym)) ++ { ++ einfo->failed = true; ++ return false; ++ } ++ ++ return true; ++} ++ ++/* Search for and possibly create a got entry. */ ++ ++static struct sw64_elf_got_entry * ++get_got_entry (bfd *abfd, struct sw64_elf_link_hash_entry *h, ++ unsigned long r_type, unsigned long r_symndx, ++ bfd_vma r_addend) ++{ ++ struct sw64_elf_got_entry *gotent; ++ struct sw64_elf_got_entry **slot; ++ ++ if (h) ++ slot = &h->got_entries; ++ else ++ { ++ /* This is a local .got entry -- record for merge. */ ++ ++ struct sw64_elf_got_entry **local_got_entries; ++ ++ local_got_entries = sw64_elf_tdata(abfd)->local_got_entries; ++ if (!local_got_entries) ++ { ++ bfd_size_type size; ++ Elf_Internal_Shdr *symtab_hdr; ++ ++ symtab_hdr = &elf_tdata(abfd)->symtab_hdr; ++ size = symtab_hdr->sh_info; ++ size *= sizeof (struct sw64_elf_got_entry *); ++ ++ local_got_entries ++ = (struct sw64_elf_got_entry **) bfd_zalloc (abfd, size); ++ if (!local_got_entries) ++ return NULL; ++ ++ sw64_elf_tdata (abfd)->local_got_entries = local_got_entries; ++ } ++ ++ slot = &local_got_entries[r_symndx]; ++ } ++ ++ for (gotent = *slot; gotent ; gotent = gotent->next) ++ if (gotent->gotobj == abfd ++ && gotent->reloc_type == r_type ++ && gotent->addend == r_addend) ++ break; ++ ++ if (!gotent) ++ { ++ int entry_size; ++ size_t amt; ++ ++ amt = sizeof (struct sw64_elf_got_entry); ++ gotent = (struct sw64_elf_got_entry *) bfd_alloc (abfd, amt); ++ if (!gotent) ++ return NULL; ++ ++ gotent->gotobj = abfd; ++ gotent->addend = r_addend; ++ gotent->got_offset = -1; ++ gotent->plt_offset = -1; ++ gotent->use_count = 1; ++ gotent->reloc_type = r_type; ++ gotent->reloc_done = 0; ++ gotent->reloc_xlated = 0; ++ ++ gotent->next = *slot; ++ *slot = gotent; ++ ++ entry_size = sw64_got_entry_size (r_type); ++ sw64_elf_tdata (abfd)->total_got_size += entry_size; ++ if (!h) ++ sw64_elf_tdata(abfd)->local_got_size += entry_size; ++ } ++ else ++ gotent->use_count += 1; ++ ++ return gotent; ++} ++ ++static bool ++elf64_sw64_want_plt (struct sw64_elf_link_hash_entry *ah) ++{ ++ return ((ah->root.type == STT_FUNC ++ || ah->root.root.type == bfd_link_hash_undefweak ++ || ah->root.root.type == bfd_link_hash_undefined) ++ && (ah->flags & SW64_ELF_LINK_HASH_LU_PLT) != 0 ++ && (ah->flags & ~SW64_ELF_LINK_HASH_LU_PLT) == 0); ++} ++ ++/* Whether to sort relocs output by ld -r or ld --emit-relocs, by r_offset. ++ Don't do so for code sections. We want to keep ordering of LITERAL/LITUSE ++ as is. On the other hand, elf-eh-frame.c processing requires .eh_frame ++ relocs to be sorted. */ ++ ++static bool ++elf64_sw64_sort_relocs_p (asection *sec) ++{ ++ return (sec->flags & SEC_CODE) == 0; ++} ++ ++ ++/* Handle dynamic relocations when doing an SW64 ELF link. */ ++ ++static bool ++elf64_sw64_check_relocs (bfd *abfd, struct bfd_link_info *info, ++ asection *sec, const Elf_Internal_Rela *relocs) ++{ ++ bfd *dynobj; ++ asection *sreloc; ++ Elf_Internal_Shdr *symtab_hdr; ++ struct sw64_elf_link_hash_entry **sym_hashes; ++ const Elf_Internal_Rela *rel, *relend; ++ ++ if (bfd_link_relocatable (info)) ++ return true; ++ ++ BFD_ASSERT (is_sw64_elf (abfd)); ++ ++ dynobj = elf_hash_table (info)->dynobj; ++ if (dynobj == NULL) ++ elf_hash_table (info)->dynobj = dynobj = abfd; ++ ++ sreloc = NULL; ++ symtab_hdr = &elf_symtab_hdr (abfd); ++ sym_hashes = sw64_elf_sym_hashes (abfd); ++ ++ relend = relocs + sec->reloc_count; ++ for (rel = relocs; rel < relend; ++rel) ++ { ++ enum { ++ NEED_GOT = 1, ++ NEED_GOT_ENTRY = 2, ++ NEED_DYNREL = 4 ++ }; ++ ++ unsigned long r_symndx, r_type; ++ struct sw64_elf_link_hash_entry *h; ++ unsigned int gotent_flags; ++ bool maybe_dynamic; ++ unsigned int need; ++ bfd_vma addend; ++ ++ r_symndx = ELF64_R_SYM (rel->r_info); ++ if (r_symndx < symtab_hdr->sh_info) ++ h = NULL; ++ else ++ { ++ h = sym_hashes[r_symndx - symtab_hdr->sh_info]; ++ ++ while (h->root.root.type == bfd_link_hash_indirect ++ || h->root.root.type == bfd_link_hash_warning) ++ h = (struct sw64_elf_link_hash_entry *)h->root.root.u.i.link; ++ ++ /* PR15323, ref flags aren't set for references in the same ++ object. */ ++ h->root.ref_regular = 1; ++ } ++ ++ /* We can only get preliminary data on whether a symbol is ++ locally or externally defined, as not all of the input files ++ have yet been processed. Do something with what we know, as ++ this may help reduce memory usage and processing time later. */ ++ maybe_dynamic = false; ++ if (h && ((bfd_link_pic (info) ++ && (!info->symbolic ++ || info->unresolved_syms_in_shared_libs == RM_IGNORE)) ++ || !h->root.def_regular ++ || h->root.root.type == bfd_link_hash_defweak)) ++ maybe_dynamic = true; ++ ++ need = 0; ++ gotent_flags = 0; ++ r_type = ELF64_R_TYPE (rel->r_info); ++ addend = rel->r_addend; ++ ++ switch (r_type) ++ { ++ case R_SW64_LITERAL: ++ need = NEED_GOT | NEED_GOT_ENTRY; ++ ++ /* Remember how this literal is used from its LITUSEs. ++ This will be important when it comes to decide if we can ++ create a .plt entry for a function symbol. */ ++ while (++rel < relend && ELF64_R_TYPE (rel->r_info) == R_SW64_LITUSE) ++ if (rel->r_addend >= 1 && rel->r_addend <= 6) ++ gotent_flags |= 1 << rel->r_addend; ++ --rel; ++ ++ /* No LITUSEs -- presumably the address is used somehow. */ ++ if (gotent_flags == 0) ++ gotent_flags = SW64_ELF_LINK_HASH_LU_ADDR; ++ break; ++ ++ case R_SW64_GPDISP: ++ case R_SW64_GPREL16: ++ case R_SW64_GPREL32: ++ case R_SW64_GPRELHIGH: ++ case R_SW64_GPRELLOW: ++ case R_SW64_BRSGP: ++ need = NEED_GOT; ++ break; ++ ++ case R_SW64_REFLONG: ++ case R_SW64_REFQUAD: ++ if (bfd_link_pic (info) || maybe_dynamic) ++ need = NEED_DYNREL; ++ break; ++ ++ case R_SW64_TLSLDM: ++ /* The symbol for a TLSLDM reloc is ignored. Collapse the ++ reloc to the STN_UNDEF (0) symbol so that they all match. */ ++ r_symndx = STN_UNDEF; ++ h = 0; ++ maybe_dynamic = false; ++ /* FALLTHRU */ ++ ++ case R_SW64_TLSGD: ++ case R_SW64_GOTDTPREL: ++ need = NEED_GOT | NEED_GOT_ENTRY; ++ break; ++ ++ case R_SW64_GOTTPREL: ++ need = NEED_GOT | NEED_GOT_ENTRY; ++ gotent_flags = SW64_ELF_LINK_HASH_TLS_IE; ++ if (bfd_link_pic (info)) ++ info->flags |= DF_STATIC_TLS; ++ break; ++ ++ case R_SW64_TPREL64: ++ if (bfd_link_dll (info)) ++ { ++ info->flags |= DF_STATIC_TLS; ++ need = NEED_DYNREL; ++ } ++ else if (maybe_dynamic) ++ need = NEED_DYNREL; ++ break; ++ } ++ ++ if (need & NEED_GOT) ++ { ++ if (sw64_elf_tdata(abfd)->gotobj == NULL) ++ { ++ if (!elf64_sw64_create_got_section (abfd, info)) ++ return false; ++ } ++ } ++ ++ if (need & NEED_GOT_ENTRY) ++ { ++ struct sw64_elf_got_entry *gotent; ++ ++ gotent = get_got_entry (abfd, h, r_type, r_symndx, addend); ++ if (!gotent) ++ return false; ++ ++ if (gotent_flags) ++ { ++ gotent->flags |= gotent_flags; ++ if (h) ++ { ++ gotent_flags |= h->flags; ++ h->flags = gotent_flags; ++ ++ /* Make a guess as to whether a .plt entry is needed. */ ++ /* ??? It appears that we won't make it into ++ adjust_dynamic_symbol for symbols that remain ++ totally undefined. Copying this check here means ++ we can create a plt entry for them too. */ ++ h->root.needs_plt ++ = (maybe_dynamic && elf64_sw64_want_plt (h)); ++ } ++ } ++ } ++ ++ if (need & NEED_DYNREL) ++ { ++ /* We need to create the section here now whether we eventually ++ use it or not so that it gets mapped to an output section by ++ the linker. If not used, we'll kill it in size_dynamic_sections. */ ++ if (sreloc == NULL) ++ { ++ sreloc = _bfd_elf_make_dynamic_reloc_section ++ (sec, dynobj, 3, abfd, /*rela?*/ true); ++ ++ if (sreloc == NULL) ++ return false; ++ } ++ ++ if (h) ++ { ++ /* Since we havn't seen all of the input symbols yet, we ++ don't know whether we'll actually need a dynamic relocation ++ entry for this reloc. So make a record of it. Once we ++ find out if this thing needs dynamic relocation we'll ++ expand the relocation sections by the appropriate amount. */ ++ ++ struct sw64_elf_reloc_entry *rent; ++ ++ for (rent = h->reloc_entries; rent; rent = rent->next) ++ if (rent->rtype == r_type && rent->srel == sreloc) ++ break; ++ ++ if (!rent) ++ { ++ size_t amt = sizeof (struct sw64_elf_reloc_entry); ++ rent = (struct sw64_elf_reloc_entry *) bfd_alloc (abfd, amt); ++ if (!rent) ++ return false; ++ ++ rent->srel = sreloc; ++ rent->sec = sec; ++ rent->rtype = r_type; ++ rent->count = 1; ++ ++ rent->next = h->reloc_entries; ++ h->reloc_entries = rent; ++ } ++ else ++ rent->count++; ++ } ++ else if (bfd_link_pic (info)) ++ { ++ /* If this is a shared library, and the section is to be ++ loaded into memory, we need a RELATIVE reloc. */ ++ sreloc->size += sizeof (Elf64_External_Rela); ++ if (sec->flags & SEC_READONLY) ++ { ++ info->flags |= DF_TEXTREL; ++ info->callbacks->minfo ++ (_("%pB: dynamic relocation against a local symbol in " ++ "read-only section `%pA'\n"), ++ sec->owner, sec); ++ } ++ } ++ } ++ } ++ ++ return true; ++} ++ ++/* Return the section that should be marked against GC for a given ++ relocation. */ ++ ++static asection * ++elf64_sw64_gc_mark_hook (asection *sec, struct bfd_link_info *info, ++ Elf_Internal_Rela *rel, ++ struct elf_link_hash_entry *h, Elf_Internal_Sym *sym) ++{ ++ /* These relocations don't really reference a symbol. Instead we store ++ extra data in their addend slot. Ignore the symbol. */ ++ switch (ELF64_R_TYPE (rel->r_info)) ++ { ++ case R_SW64_LITUSE: ++ case R_SW64_GPDISP: ++ case R_SW64_HINT: ++ return NULL; ++ } ++ ++ return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); ++} ++ ++/* Adjust a symbol defined by a dynamic object and referenced by a ++ regular object. The current definition is in some section of the ++ dynamic object, but we're not including those sections. We have to ++ change the definition to something the rest of the link can ++ understand. */ ++ ++static bool ++elf64_sw64_adjust_dynamic_symbol (struct bfd_link_info *info, ++ struct elf_link_hash_entry *h) ++{ ++ bfd *dynobj; ++ asection *s; ++ struct sw64_elf_link_hash_entry *ah; ++ ++ dynobj = elf_hash_table(info)->dynobj; ++ ah = (struct sw64_elf_link_hash_entry *)h; ++ ++ /* Now that we've seen all of the input symbols, finalize our decision ++ about whether this symbol should get a .plt entry. Irritatingly, it ++ is common for folk to leave undefined symbols in shared libraries, ++ and they still expect lazy binding; accept undefined symbols in lieu ++ of STT_FUNC. */ ++ if (sw64_elf_dynamic_symbol_p (h, info) && elf64_sw64_want_plt (ah)) ++ { ++ h->needs_plt = true; ++ ++ s = elf_hash_table(info)->splt; ++ if (!s && !elf64_sw64_create_dynamic_sections (dynobj, info)) ++ return false; ++ ++ /* We need one plt entry per got subsection. Delay allocation of ++ the actual plt entries until size_plt_section, called from ++ size_dynamic_sections or during relaxation. */ ++ ++ return true; ++ } ++ else ++ h->needs_plt = false; ++ ++ /* If this is a weak symbol, and there is a real definition, the ++ processor independent code will have arranged for us to see the ++ real definition first, and we can just use the same value. */ ++ if (h->is_weakalias) ++ { ++ struct elf_link_hash_entry *def = weakdef (h); ++ BFD_ASSERT (def->root.type == bfd_link_hash_defined); ++ h->root.u.def.section = def->root.u.def.section; ++ h->root.u.def.value = def->root.u.def.value; ++ return true; ++ } ++ ++ /* This is a reference to a symbol defined by a dynamic object which ++ is not a function. The SW64, since it uses .got entries for all ++ symbols even in regular objects, does not need the hackery of a ++ .dynbss section and COPY dynamic relocations. */ ++ ++ return true; ++} ++ ++/* Record STO_SW64_NOPV and STO_SW64_STD_GPLOAD. */ ++ ++static void ++elf64_sw64_merge_symbol_attribute (struct elf_link_hash_entry *h, ++ unsigned int st_other, ++ bool definition, ++ bool dynamic) ++{ ++ if (!dynamic && definition) ++ h->other = ((h->other & ELF_ST_VISIBILITY (-1)) ++ | (st_other & ~ELF_ST_VISIBILITY (-1))); ++} ++ ++/* Symbol versioning can create new symbols, and make our old symbols ++ indirect to the new ones. Consolidate the got and reloc information ++ in these situations. */ ++ ++static void ++elf64_sw64_copy_indirect_symbol (struct bfd_link_info *info, ++ struct elf_link_hash_entry *dir, ++ struct elf_link_hash_entry *ind) ++{ ++ struct sw64_elf_link_hash_entry *hi ++ = (struct sw64_elf_link_hash_entry *) ind; ++ struct sw64_elf_link_hash_entry *hs ++ = (struct sw64_elf_link_hash_entry *) dir; ++ ++ /* Do the merging in the superclass. */ ++ _bfd_elf_link_hash_copy_indirect(info, dir, ind); ++ ++ /* Merge the flags. Whee. */ ++ hs->flags |= hi->flags; ++ ++ /* ??? It's unclear to me what's really supposed to happen when ++ "merging" defweak and defined symbols, given that we don't ++ actually throw away the defweak. This more-or-less copies ++ the logic related to got and plt entries in the superclass. */ ++ if (ind->root.type != bfd_link_hash_indirect) ++ return; ++ ++ /* Merge the .got entries. Cannibalize the old symbol's list in ++ doing so, since we don't need it anymore. */ ++ ++ if (hs->got_entries == NULL) ++ hs->got_entries = hi->got_entries; ++ else ++ { ++ struct sw64_elf_got_entry *gi, *gs, *gin, *gsh; ++ ++ gsh = hs->got_entries; ++ for (gi = hi->got_entries; gi ; gi = gin) ++ { ++ gin = gi->next; ++ for (gs = gsh; gs ; gs = gs->next) ++ if (gi->gotobj == gs->gotobj ++ && gi->reloc_type == gs->reloc_type ++ && gi->addend == gs->addend) ++ { ++ gs->use_count += gi->use_count; ++ goto got_found; ++ } ++ gi->next = hs->got_entries; ++ hs->got_entries = gi; ++ got_found:; ++ } ++ } ++ hi->got_entries = NULL; ++ ++ /* And similar for the reloc entries. */ ++ ++ if (hs->reloc_entries == NULL) ++ hs->reloc_entries = hi->reloc_entries; ++ else ++ { ++ struct sw64_elf_reloc_entry *ri, *rs, *rin, *rsh; ++ ++ rsh = hs->reloc_entries; ++ for (ri = hi->reloc_entries; ri ; ri = rin) ++ { ++ rin = ri->next; ++ for (rs = rsh; rs ; rs = rs->next) ++ if (ri->rtype == rs->rtype && ri->srel == rs->srel) ++ { ++ rs->count += ri->count; ++ goto found_reloc; ++ } ++ ri->next = hs->reloc_entries; ++ hs->reloc_entries = ri; ++ found_reloc:; ++ } ++ } ++ hi->reloc_entries = NULL; ++} ++ ++/* Is it possible to merge two object file's .got tables? */ ++ ++static bool ++elf64_sw64_can_merge_gots (bfd *a, bfd *b) ++{ ++ int total = sw64_elf_tdata (a)->total_got_size; ++ bfd *bsub; ++ ++ /* Trivial quick fallout test. */ ++ if (total + sw64_elf_tdata (b)->total_got_size <= MAX_GOT_SIZE) ++ return true; ++ ++ /* By their nature, local .got entries cannot be merged. */ ++ if ((total += sw64_elf_tdata (b)->local_got_size) > MAX_GOT_SIZE) ++ return false; ++ ++ /* Failing the common trivial comparison, we must effectively ++ perform the merge. Not actually performing the merge means that ++ we don't have to store undo information in case we fail. */ ++ for (bsub = b; bsub ; bsub = sw64_elf_tdata (bsub)->in_got_link_next) ++ { ++ struct sw64_elf_link_hash_entry **hashes = sw64_elf_sym_hashes (bsub); ++ Elf_Internal_Shdr *symtab_hdr = &elf_tdata (bsub)->symtab_hdr; ++ int i, n; ++ ++ n = NUM_SHDR_ENTRIES (symtab_hdr) - symtab_hdr->sh_info; ++ for (i = 0; i < n; ++i) ++ { ++ struct sw64_elf_got_entry *ae, *be; ++ struct sw64_elf_link_hash_entry *h; ++ ++ h = hashes[i]; ++ while (h->root.root.type == bfd_link_hash_indirect ++ || h->root.root.type == bfd_link_hash_warning) ++ h = (struct sw64_elf_link_hash_entry *)h->root.root.u.i.link; ++ ++ for (be = h->got_entries; be ; be = be->next) ++ { ++ if (be->use_count == 0) ++ continue; ++ if (be->gotobj != b) ++ continue; ++ ++ for (ae = h->got_entries; ae ; ae = ae->next) ++ if (ae->gotobj == a ++ && ae->reloc_type == be->reloc_type ++ && ae->addend == be->addend) ++ goto global_found; ++ ++ total += sw64_got_entry_size (be->reloc_type); ++ if (total > MAX_GOT_SIZE) ++ return false; ++ global_found:; ++ } ++ } ++ } ++ ++ return true; ++} ++ ++/* Actually merge two .got tables. */ ++ ++static void ++elf64_sw64_merge_gots (bfd *a, bfd *b) ++{ ++ int total = sw64_elf_tdata (a)->total_got_size; ++ bfd *bsub; ++ ++ /* Remember local expansion. */ ++ { ++ int e = sw64_elf_tdata (b)->local_got_size; ++ total += e; ++ sw64_elf_tdata (a)->local_got_size += e; ++ } ++ ++ for (bsub = b; bsub ; bsub = sw64_elf_tdata (bsub)->in_got_link_next) ++ { ++ struct sw64_elf_got_entry **local_got_entries; ++ struct sw64_elf_link_hash_entry **hashes; ++ Elf_Internal_Shdr *symtab_hdr; ++ int i, n; ++ ++ /* Let the local .got entries know they are part of a new subsegment. */ ++ local_got_entries = sw64_elf_tdata (bsub)->local_got_entries; ++ if (local_got_entries) ++ { ++ n = elf_tdata (bsub)->symtab_hdr.sh_info; ++ for (i = 0; i < n; ++i) ++ { ++ struct sw64_elf_got_entry *ent; ++ for (ent = local_got_entries[i]; ent; ent = ent->next) ++ ent->gotobj = a; ++ } ++ } ++ ++ /* Merge the global .got entries. */ ++ hashes = sw64_elf_sym_hashes (bsub); ++ symtab_hdr = &elf_tdata (bsub)->symtab_hdr; ++ ++ n = NUM_SHDR_ENTRIES (symtab_hdr) - symtab_hdr->sh_info; ++ for (i = 0; i < n; ++i) ++ { ++ struct sw64_elf_got_entry *ae, *be, **pbe, **start; ++ struct sw64_elf_link_hash_entry *h; ++ ++ h = hashes[i]; ++ while (h->root.root.type == bfd_link_hash_indirect ++ || h->root.root.type == bfd_link_hash_warning) ++ h = (struct sw64_elf_link_hash_entry *)h->root.root.u.i.link; ++ ++ pbe = start = &h->got_entries; ++ while ((be = *pbe) != NULL) ++ { ++ if (be->use_count == 0) ++ { ++ *pbe = be->next; ++ memset (be, 0xa5, sizeof (*be)); ++ goto kill; ++ } ++ if (be->gotobj != b) ++ goto next; ++ ++ for (ae = *start; ae ; ae = ae->next) ++ if (ae->gotobj == a ++ && ae->reloc_type == be->reloc_type ++ && ae->addend == be->addend) ++ { ++ ae->flags |= be->flags; ++ ae->use_count += be->use_count; ++ *pbe = be->next; ++ memset (be, 0xa5, sizeof (*be)); ++ goto kill; ++ } ++ be->gotobj = a; ++ total += sw64_got_entry_size (be->reloc_type); ++ ++ next:; ++ pbe = &be->next; ++ kill:; ++ } ++ } ++ ++ sw64_elf_tdata (bsub)->gotobj = a; ++ } ++ sw64_elf_tdata (a)->total_got_size = total; ++ ++ /* Merge the two in_got chains. */ ++ { ++ bfd *next; ++ ++ bsub = a; ++ while ((next = sw64_elf_tdata (bsub)->in_got_link_next) != NULL) ++ bsub = next; ++ ++ sw64_elf_tdata (bsub)->in_got_link_next = b; ++ } ++} ++ ++/* Calculate the offsets for the got entries. */ ++ ++static bool ++elf64_sw64_calc_got_offsets_for_symbol (struct sw64_elf_link_hash_entry *h, ++ void * arg ATTRIBUTE_UNUSED) ++{ ++ struct sw64_elf_got_entry *gotent; ++ ++ for (gotent = h->got_entries; gotent; gotent = gotent->next) ++ if (gotent->use_count > 0) ++ { ++ struct sw64_elf_obj_tdata *td; ++ bfd_size_type *plge; ++ ++ td = sw64_elf_tdata (gotent->gotobj); ++ plge = &td->got->size; ++ gotent->got_offset = *plge; ++ *plge += sw64_got_entry_size (gotent->reloc_type); ++ } ++ ++ return true; ++} ++ ++static void ++elf64_sw64_calc_got_offsets (struct bfd_link_info *info) ++{ ++ bfd *i, *got_list; ++ struct sw64_elf_link_hash_table * htab; ++ ++ htab = sw64_elf_hash_table (info); ++ if (htab == NULL) ++ return; ++ got_list = htab->got_list; ++ ++ /* First, zero out the .got sizes, as we may be recalculating the ++ .got after optimizing it. */ ++ for (i = got_list; i ; i = sw64_elf_tdata(i)->got_link_next) ++ sw64_elf_tdata(i)->got->size = 0; ++ ++ /* Next, fill in the offsets for all the global entries. */ ++ sw64_elf_link_hash_traverse (htab, ++ elf64_sw64_calc_got_offsets_for_symbol, ++ NULL); ++ ++ /* Finally, fill in the offsets for the local entries. */ ++ for (i = got_list; i ; i = sw64_elf_tdata(i)->got_link_next) ++ { ++ bfd_size_type got_offset = sw64_elf_tdata(i)->got->size; ++ bfd *j; ++ ++ for (j = i; j ; j = sw64_elf_tdata(j)->in_got_link_next) ++ { ++ struct sw64_elf_got_entry **local_got_entries, *gotent; ++ int k, n; ++ ++ local_got_entries = sw64_elf_tdata(j)->local_got_entries; ++ if (!local_got_entries) ++ continue; ++ ++ for (k = 0, n = elf_tdata(j)->symtab_hdr.sh_info; k < n; ++k) ++ for (gotent = local_got_entries[k]; gotent; gotent = gotent->next) ++ if (gotent->use_count > 0) ++ { ++ gotent->got_offset = got_offset; ++ got_offset += sw64_got_entry_size (gotent->reloc_type); ++ } ++ } ++ ++ sw64_elf_tdata(i)->got->size = got_offset; ++ } ++} ++ ++/* Constructs the gots. */ ++ ++static bool ++elf64_sw64_size_got_sections (struct bfd_link_info *info, ++ bool may_merge) ++{ ++ bfd *i, *got_list, *cur_got_obj = NULL; ++ struct sw64_elf_link_hash_table * htab; ++ ++ htab = sw64_elf_hash_table (info); ++ if (htab == NULL) ++ return false; ++ got_list = htab->got_list; ++ ++ /* On the first time through, pretend we have an existing got list ++ consisting of all of the input files. */ ++ if (got_list == NULL) ++ { ++ for (i = info->input_bfds; i ; i = i->link.next) ++ { ++ bfd *this_got; ++ ++ if (! is_sw64_elf (i)) ++ continue; ++ ++ this_got = sw64_elf_tdata (i)->gotobj; ++ if (this_got == NULL) ++ continue; ++ ++ /* We are assuming no merging has yet occurred. */ ++ BFD_ASSERT (this_got == i); ++ ++ if (sw64_elf_tdata (this_got)->total_got_size > MAX_GOT_SIZE) ++ { ++ /* Yikes! A single object file has too many entries. */ ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: .got subsegment exceeds 64K (size %d)"), ++ i, sw64_elf_tdata (this_got)->total_got_size); ++ return false; ++ } ++ ++ if (got_list == NULL) ++ got_list = this_got; ++ else ++ sw64_elf_tdata(cur_got_obj)->got_link_next = this_got; ++ cur_got_obj = this_got; ++ } ++ ++ /* Strange degenerate case of no got references. */ ++ if (got_list == NULL) ++ return true; ++ ++ htab->got_list = got_list; ++ } ++ ++ cur_got_obj = got_list; ++ if (cur_got_obj == NULL) ++ return false; ++ ++ if (may_merge) ++ { ++ i = sw64_elf_tdata(cur_got_obj)->got_link_next; ++ while (i != NULL) ++ { ++ if (elf64_sw64_can_merge_gots (cur_got_obj, i)) ++ { ++ elf64_sw64_merge_gots (cur_got_obj, i); ++ ++ sw64_elf_tdata(i)->got->size = 0; ++ i = sw64_elf_tdata(i)->got_link_next; ++ sw64_elf_tdata(cur_got_obj)->got_link_next = i; ++ } ++ else ++ { ++ cur_got_obj = i; ++ i = sw64_elf_tdata(i)->got_link_next; ++ } ++ } ++ } ++ ++ /* Once the gots have been merged, fill in the got offsets for ++ everything therein. */ ++ elf64_sw64_calc_got_offsets (info); ++ ++ return true; ++} ++ ++static bool ++elf64_sw64_size_plt_section_1 (struct sw64_elf_link_hash_entry *h, ++ void * data) ++{ ++ asection *splt = (asection *) data; ++ struct sw64_elf_got_entry *gotent; ++ bool saw_one = false; ++ ++ /* If we didn't need an entry before, we still don't. */ ++ if (!h->root.needs_plt) ++ return true; ++ ++ /* For each LITERAL got entry still in use, allocate a plt entry. */ ++ for (gotent = h->got_entries; gotent ; gotent = gotent->next) ++ if (gotent->reloc_type == R_SW64_LITERAL ++ && gotent->use_count > 0) ++ { ++ if (splt->size == 0) ++ splt->size = PLT_HEADER_SIZE; ++ gotent->plt_offset = splt->size; ++ splt->size += PLT_ENTRY_SIZE; ++ saw_one = true; ++ } ++ ++ /* If there weren't any, there's no longer a need for the PLT entry. */ ++ if (!saw_one) ++ h->root.needs_plt = false; ++ ++ return true; ++} ++ ++/* Called from relax_section to rebuild the PLT in light of potential changes ++ in the function's status. */ ++ ++static void ++elf64_sw64_size_plt_section (struct bfd_link_info *info) ++{ ++ asection *splt, *spltrel, *sgotplt; ++ unsigned long entries; ++ struct sw64_elf_link_hash_table * htab; ++ ++ htab = sw64_elf_hash_table (info); ++ if (htab == NULL) ++ return; ++ ++ splt = elf_hash_table(info)->splt; ++ if (splt == NULL) ++ return; ++ ++ splt->size = 0; ++ ++ sw64_elf_link_hash_traverse (htab, ++ elf64_sw64_size_plt_section_1, splt); ++ ++ /* Every plt entry requires a JMP_SLOT relocation. */ ++ spltrel = elf_hash_table(info)->srelplt; ++ entries = 0; ++ if (splt->size) ++ { ++ if (elf64_sw64_use_secureplt) ++ entries = (splt->size - NEW_PLT_HEADER_SIZE) / NEW_PLT_ENTRY_SIZE; ++ else ++ entries = (splt->size - OLD_PLT_HEADER_SIZE) / OLD_PLT_ENTRY_SIZE; ++ } ++ spltrel->size = entries * sizeof (Elf64_External_Rela); ++ ++ /* When using the secureplt, we need two words somewhere in the data ++ segment for the dynamic linker to tell us where to go. This is the ++ entire contents of the .got.plt section. */ ++ if (elf64_sw64_use_secureplt) ++ { ++ sgotplt = elf_hash_table(info)->sgotplt; ++ sgotplt->size = entries ? 16 : 0; ++ } ++} ++ ++static bool ++elf64_sw64_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, ++ struct bfd_link_info *info) ++{ ++ bfd *i; ++ struct sw64_elf_link_hash_table * htab; ++ ++ if (bfd_link_relocatable (info)) ++ return true; ++ ++ htab = sw64_elf_hash_table (info); ++ if (htab == NULL) ++ return false; ++ ++ if (!elf64_sw64_size_got_sections (info, true)) ++ return false; ++ ++ /* Allocate space for all of the .got subsections. */ ++ i = htab->got_list; ++ for ( ; i ; i = sw64_elf_tdata(i)->got_link_next) ++ { ++ asection *s = sw64_elf_tdata(i)->got; ++ if (s->size > 0) ++ { ++ s->contents = (bfd_byte *) bfd_zalloc (i, s->size); ++ if (s->contents == NULL) ++ return false; ++ } ++ } ++ ++ return true; ++} ++ ++/* The number of dynamic relocations required by a static relocation. */ ++ ++static int ++sw64_dynamic_entries_for_reloc (int r_type, int dynamic, int shared, int pie) ++{ ++ switch (r_type) ++ { ++ /* May appear in GOT entries. */ ++ case R_SW64_TLSGD: ++ return (dynamic ? 2 : shared ? 1 : 0); ++ case R_SW64_TLSLDM: ++ return shared; ++ case R_SW64_LITERAL: ++ return dynamic || shared; ++ case R_SW64_GOTTPREL: ++ return dynamic || (shared && !pie); ++ case R_SW64_GOTDTPREL: ++ return dynamic; ++ ++ /* May appear in data sections. */ ++ case R_SW64_REFLONG: ++ case R_SW64_REFQUAD: ++ return dynamic || shared; ++ case R_SW64_TPREL64: ++ return dynamic || (shared && !pie); ++ ++ /* Everything else is illegal. We'll issue an error during ++ relocate_section. */ ++ default: ++ return 0; ++ } ++} ++ ++/* Work out the sizes of the dynamic relocation entries. */ ++ ++static bool ++elf64_sw64_calc_dynrel_sizes (struct sw64_elf_link_hash_entry *h, ++ struct bfd_link_info *info) ++{ ++ bool dynamic; ++ struct sw64_elf_reloc_entry *relent; ++ unsigned long entries; ++ ++ /* If the symbol was defined as a common symbol in a regular object ++ file, and there was no definition in any dynamic object, then the ++ linker will have allocated space for the symbol in a common ++ section but the ELF_LINK_HASH_DEF_REGULAR flag will not have been ++ set. This is done for dynamic symbols in ++ elf_adjust_dynamic_symbol but this is not done for non-dynamic ++ symbols, somehow. */ ++ if (!h->root.def_regular ++ && h->root.ref_regular ++ && !h->root.def_dynamic ++ && (h->root.root.type == bfd_link_hash_defined ++ || h->root.root.type == bfd_link_hash_defweak) ++ && !(h->root.root.u.def.section->owner->flags & DYNAMIC)) ++ h->root.def_regular = 1; ++ ++ /* If the symbol is dynamic, we'll need all the relocations in their ++ natural form. If this is a shared object, and it has been forced ++ local, we'll need the same number of RELATIVE relocations. */ ++ dynamic = sw64_elf_dynamic_symbol_p (&h->root, info); ++ ++ /* If the symbol is a hidden undefined weak, then we never have any ++ relocations. Avoid the loop which may want to add RELATIVE relocs ++ based on bfd_link_pic (info). */ ++ if (h->root.root.type == bfd_link_hash_undefweak && !dynamic) ++ return true; ++ ++ for (relent = h->reloc_entries; relent; relent = relent->next) ++ { ++ entries = sw64_dynamic_entries_for_reloc (relent->rtype, dynamic, ++ bfd_link_pic (info), ++ bfd_link_pie (info)); ++ if (entries) ++ { ++ asection *sec = relent->sec; ++ relent->srel->size += ++ entries * sizeof (Elf64_External_Rela) * relent->count; ++ if ((sec->flags & SEC_READONLY) != 0) ++ { ++ info->flags |= DT_TEXTREL; ++ info->callbacks->minfo ++ (_("%pB: dynamic relocation against `%pT' in " ++ "read-only section `%pA'\n"), ++ sec->owner, h->root.root.root.string, sec); ++ } ++ } ++ } ++ ++ return true; ++} ++ ++/* Subroutine of elf64_sw64_size_rela_got_section for doing the ++ global symbols. */ ++ ++static bool ++elf64_sw64_size_rela_got_1 (struct sw64_elf_link_hash_entry *h, ++ struct bfd_link_info *info) ++{ ++ bool dynamic; ++ struct sw64_elf_got_entry *gotent; ++ unsigned long entries; ++ ++ /* If we're using a plt for this symbol, then all of its relocations ++ for its got entries go into .rela.plt. */ ++ if (h->root.needs_plt) ++ return true; ++ ++ /* If the symbol is dynamic, we'll need all the relocations in their ++ natural form. If this is a shared object, and it has been forced ++ local, we'll need the same number of RELATIVE relocations. */ ++ dynamic = sw64_elf_dynamic_symbol_p (&h->root, info); ++ ++ /* If the symbol is a hidden undefined weak, then we never have any ++ relocations. Avoid the loop which may want to add RELATIVE relocs ++ based on bfd_link_pic (info). */ ++ if (h->root.root.type == bfd_link_hash_undefweak && !dynamic) ++ return true; ++ ++ entries = 0; ++ for (gotent = h->got_entries; gotent ; gotent = gotent->next) ++ if (gotent->use_count > 0) ++ entries += sw64_dynamic_entries_for_reloc (gotent->reloc_type, dynamic, ++ bfd_link_pic (info), ++ bfd_link_pie (info)); ++ ++ if (entries > 0) ++ { ++ asection *srel = elf_hash_table(info)->srelgot; ++ BFD_ASSERT (srel != NULL); ++ srel->size += sizeof (Elf64_External_Rela) * entries; ++ } ++ ++ return true; ++} ++ ++/* Set the sizes of the dynamic relocation sections. */ ++ ++static void ++elf64_sw64_size_rela_got_section (struct bfd_link_info *info) ++{ ++ unsigned long entries; ++ bfd *i; ++ asection *srel; ++ struct sw64_elf_link_hash_table * htab; ++ ++ htab = sw64_elf_hash_table (info); ++ if (htab == NULL) ++ return; ++ ++ /* Shared libraries often require RELATIVE relocs, and some relocs ++ require attention for the main application as well. */ ++ ++ entries = 0; ++ for (i = htab->got_list; ++ i ; i = sw64_elf_tdata(i)->got_link_next) ++ { ++ bfd *j; ++ ++ for (j = i; j ; j = sw64_elf_tdata(j)->in_got_link_next) ++ { ++ struct sw64_elf_got_entry **local_got_entries, *gotent; ++ int k, n; ++ ++ local_got_entries = sw64_elf_tdata(j)->local_got_entries; ++ if (!local_got_entries) ++ continue; ++ ++ for (k = 0, n = elf_tdata(j)->symtab_hdr.sh_info; k < n; ++k) ++ for (gotent = local_got_entries[k]; ++ gotent ; gotent = gotent->next) ++ if (gotent->use_count > 0) ++ entries += (sw64_dynamic_entries_for_reloc ++ (gotent->reloc_type, 0, bfd_link_pic (info), ++ bfd_link_pie (info))); ++ } ++ } ++ ++ srel = elf_hash_table(info)->srelgot; ++ if (!srel) ++ { ++ BFD_ASSERT (entries == 0); ++ return; ++ } ++ srel->size = sizeof (Elf64_External_Rela) * entries; ++ ++ /* Now do the non-local symbols. */ ++ sw64_elf_link_hash_traverse (htab, ++ elf64_sw64_size_rela_got_1, info); ++} ++ ++/* Set the sizes of the dynamic sections. */ ++ ++static bool ++elf64_sw64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, ++ struct bfd_link_info *info) ++{ ++ bfd *dynobj; ++ asection *s; ++ bool relplt, relocs; ++ struct sw64_elf_link_hash_table * htab; ++ ++ htab = sw64_elf_hash_table (info); ++ if (htab == NULL) ++ return false; ++ ++ dynobj = elf_hash_table(info)->dynobj; ++ BFD_ASSERT(dynobj != NULL); ++ ++ if (elf_hash_table (info)->dynamic_sections_created) ++ { ++ /* Set the contents of the .interp section to the interpreter. */ ++ if (bfd_link_executable (info) && !info->nointerp) ++ { ++ s = bfd_get_linker_section (dynobj, ".interp"); ++ BFD_ASSERT (s != NULL); ++ s->size = sizeof ELF_DYNAMIC_INTERPRETER; ++ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; ++ } ++ ++ /* Now that we've seen all of the input files, we can decide which ++ symbols need dynamic relocation entries and which don't. We've ++ collected information in check_relocs that we can now apply to ++ size the dynamic relocation sections. */ ++ sw64_elf_link_hash_traverse (htab, ++ elf64_sw64_calc_dynrel_sizes, info); ++ ++ elf64_sw64_size_rela_got_section (info); ++ elf64_sw64_size_plt_section (info); ++ } ++ /* else we're not dynamic and by definition we don't need such things. */ ++ ++ /* The check_relocs and adjust_dynamic_symbol entry points have ++ determined the sizes of the various dynamic sections. Allocate ++ memory for them. */ ++ relplt = false; ++ relocs = false; ++ for (s = dynobj->sections; s != NULL; s = s->next) ++ { ++ const char *name; ++ ++ if (!(s->flags & SEC_LINKER_CREATED)) ++ continue; ++ ++ /* It's OK to base decisions on the section name, because none ++ of the dynobj section names depend upon the input files. */ ++ name = bfd_section_name (s); ++ ++ if (startswith (name, ".rela")) ++ { ++ if (s->size != 0) ++ { ++ if (strcmp (name, ".rela.plt") == 0) ++ relplt = true; ++ else ++ relocs = true; ++ ++ /* We use the reloc_count field as a counter if we need ++ to copy relocs into the output file. */ ++ s->reloc_count = 0; ++ } ++ } ++ else if (! startswith (name, ".got") ++ && strcmp (name, ".plt") != 0 ++ && strcmp (name, ".dynbss") != 0) ++ { ++ /* It's not one of our dynamic sections, so don't allocate space. */ ++ continue; ++ } ++ ++ if (s->size == 0) ++ { ++ /* If we don't need this section, strip it from the output file. ++ This is to handle .rela.bss and .rela.plt. We must create it ++ in create_dynamic_sections, because it must be created before ++ the linker maps input sections to output sections. The ++ linker does that before adjust_dynamic_symbol is called, and ++ it is that function which decides whether anything needs to ++ go into these sections. */ ++ if (!startswith (name, ".got")) ++ s->flags |= SEC_EXCLUDE; ++ } ++ else if ((s->flags & SEC_HAS_CONTENTS) != 0) ++ { ++ /* Allocate memory for the section contents. */ ++ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); ++ if (s->contents == NULL) ++ return false; ++ } ++ } ++ ++ if (elf_hash_table (info)->dynamic_sections_created) ++ { ++ /* Add some entries to the .dynamic section. We fill in the ++ values later, in elf64_sw64_finish_dynamic_sections, but we ++ must add the entries now so that we get the correct size for ++ the .dynamic section. The DT_DEBUG entry is filled in by the ++ dynamic linker and used by the debugger. */ ++#define add_dynamic_entry(TAG, VAL) \ ++ _bfd_elf_add_dynamic_entry (info, TAG, VAL) ++ ++ if (!_bfd_elf_add_dynamic_tags (output_bfd, info, ++ relocs || relplt)) ++ return false; ++ ++ if (relplt ++ && elf64_sw64_use_secureplt ++ && !add_dynamic_entry (DT_SW64_PLTRO, 1)) ++ return false; ++ } ++#undef add_dynamic_entry ++ ++ return true; ++} ++ ++/* These functions do relaxation for SW64 ELF. ++ ++ Currently I'm only handling what I can do with existing compiler ++ and assembler support, which means no instructions are removed, ++ though some may be nopped. At this time GCC does not emit enough ++ information to do all of the relaxing that is possible. It will ++ take some not small amount of work for that to happen. ++ ++ There are a couple of interesting papers that I once read on this ++ subject, that I cannot find references to at the moment, that ++ related to SW64 in particular. They are by David Wall, then of ++ DEC WRL. */ ++ ++struct sw64_relax_info ++{ ++ bfd *abfd; ++ asection *sec; ++ bfd_byte *contents; ++ Elf_Internal_Shdr *symtab_hdr; ++ Elf_Internal_Rela *relocs, *relend; ++ struct bfd_link_info *link_info; ++ bfd_vma gp; ++ bfd *gotobj; ++ asection *tsec; ++ struct sw64_elf_link_hash_entry *h; ++ struct sw64_elf_got_entry **first_gotent; ++ struct sw64_elf_got_entry *gotent; ++ bool changed_contents; ++ bool changed_relocs; ++ unsigned char other; ++}; ++ ++static Elf_Internal_Rela * ++elf64_sw64_find_reloc_at_ofs (Elf_Internal_Rela *rel, ++ Elf_Internal_Rela *relend, ++ bfd_vma offset, int type) ++{ ++ while (rel < relend) ++ { ++ if (rel->r_offset == offset ++ && ELF64_R_TYPE (rel->r_info) == (unsigned int) type) ++ return rel; ++ ++rel; ++ } ++ return NULL; ++} ++ ++static bool ++elf64_sw64_relax_got_load (struct sw64_relax_info *info, bfd_vma symval, ++ Elf_Internal_Rela *irel, unsigned long r_type) ++{ ++ unsigned int insn; ++ bfd_signed_vma disp; ++ ++ /* Get the instruction. */ ++ insn = bfd_get_32 (info->abfd, info->contents + irel->r_offset); ++ ++ if (insn >> 26 != OP_LDQ) ++ { ++ reloc_howto_type *howto = elf64_sw64_howto_table + r_type; ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: %pA+%#" PRIx64 ": warning: " ++ "%s relocation against unexpected insn"), ++ info->abfd, info->sec, (uint64_t) irel->r_offset, howto->name); ++ return true; ++ } ++ ++ /* Can't relax dynamic symbols. */ ++ if (info->h != NULL ++ && sw64_elf_dynamic_symbol_p (&info->h->root, info->link_info)) ++ return true; ++ ++ /* Can't use local-exec relocations in shared libraries. */ ++ if (r_type == R_SW64_GOTTPREL ++ && bfd_link_dll (info->link_info)) ++ return true; ++ ++ if (r_type == R_SW64_LITERAL) ++ { ++ /* Look for nice constant addresses. This includes the not-uncommon ++ special case of 0 for undefweak symbols. */ ++ if ((info->h && info->h->root.root.type == bfd_link_hash_undefweak) ++ || (!bfd_link_pic (info->link_info) ++ && (symval >= (bfd_vma)-0x8000 || symval < 0x8000))) ++ { ++ disp = 0; ++ insn = (OP_LDA << 26) | (insn & (31 << 21)) | (31 << 16); ++ insn |= (symval & 0xffff); ++ r_type = R_SW64_NONE; ++ } ++ else ++ { ++ /* We may only create GPREL relocs during the second pass. */ ++ if (info->link_info->relax_pass == 0) ++ return true; ++ ++ disp = symval - info->gp; ++ insn = (OP_LDA << 26) | (insn & 0x03ff0000); ++ r_type = R_SW64_GPREL16; ++ } ++ } ++ else ++ { ++ bfd_vma dtp_base, tp_base; ++ ++ BFD_ASSERT (elf_hash_table (info->link_info)->tls_sec != NULL); ++ dtp_base = sw64_get_dtprel_base (info->link_info); ++ tp_base = sw64_get_tprel_base (info->link_info); ++ disp = symval - (r_type == R_SW64_GOTDTPREL ? dtp_base : tp_base); ++ ++ insn = (OP_LDA << 26) | (insn & (31 << 21)) | (31 << 16); ++ ++ switch (r_type) ++ { ++ case R_SW64_GOTDTPREL: ++ r_type = R_SW64_DTPREL16; ++ break; ++ case R_SW64_GOTTPREL: ++ r_type = R_SW64_TPREL16; ++ break; ++ default: ++ BFD_ASSERT (0); ++ return false; ++ } ++ } ++ ++ if (disp < -0x8000 || disp >= 0x8000) ++ return true; ++ ++ bfd_put_32 (info->abfd, (bfd_vma) insn, info->contents + irel->r_offset); ++ info->changed_contents = true; ++ ++ /* Reduce the use count on this got entry by one, possibly ++ eliminating it. */ ++ if (--info->gotent->use_count == 0) ++ { ++ int sz = sw64_got_entry_size (r_type); ++ sw64_elf_tdata (info->gotobj)->total_got_size -= sz; ++ if (!info->h) ++ sw64_elf_tdata (info->gotobj)->local_got_size -= sz; ++ } ++ ++ /* Smash the existing GOT relocation for its 16-bit immediate pair. */ ++ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), r_type); ++ info->changed_relocs = true; ++ ++ /* ??? Search forward through this basic block looking for insns ++ that use the target register. Stop after an insn modifying the ++ register is seen, or after a branch or call. ++ ++ Any such memory load insn may be substituted by a load directly ++ off the GP. This allows the memory load insn to be issued before ++ the calculated GP register would otherwise be ready. ++ ++ Any such jsr insn can be replaced by a bsr if it is in range. ++ ++ This would mean that we'd have to _add_ relocations, the pain of ++ which gives one pause. */ ++ ++ return true; ++} ++ ++static bfd_vma ++elf64_sw64_relax_opt_call (struct sw64_relax_info *info, bfd_vma symval) ++{ ++ /* If the function has the same gp, and we can identify that the ++ function does not use its function pointer, we can eliminate the ++ address load. */ ++ ++ /* If the symbol is marked NOPV, we are being told the function never ++ needs its procedure value. */ ++ if ((info->other & STO_SW64_STD_GPLOAD) == STO_SW64_NOPV) ++ return symval; ++ ++ /* If the symbol is marked STD_GP, we are being told the function does ++ a normal ldgp in the first two words. */ ++ else if ((info->other & STO_SW64_STD_GPLOAD) == STO_SW64_STD_GPLOAD) ++ ; ++ ++ /* Otherwise, we may be able to identify a GP load in the first two ++ words, which we can then skip. */ ++ else ++ { ++ Elf_Internal_Rela *tsec_relocs, *tsec_relend, *tsec_free, *gpdisp; ++ bfd_vma ofs; ++ ++ /* Load the relocations from the section that the target symbol is in. */ ++ if (info->sec == info->tsec) ++ { ++ tsec_relocs = info->relocs; ++ tsec_relend = info->relend; ++ tsec_free = NULL; ++ } ++ else ++ { ++ tsec_relocs = (_bfd_elf_link_read_relocs ++ (info->abfd, info->tsec, NULL, ++ (Elf_Internal_Rela *) NULL, ++ info->link_info->keep_memory)); ++ if (tsec_relocs == NULL) ++ return 0; ++ tsec_relend = tsec_relocs + info->tsec->reloc_count; ++ tsec_free = (elf_section_data (info->tsec)->relocs == tsec_relocs ++ ? NULL ++ : tsec_relocs); ++ } ++ ++ /* Recover the symbol's offset within the section. */ ++ ofs = (symval - info->tsec->output_section->vma ++ - info->tsec->output_offset); ++ ++ /* Look for a GPDISP reloc. */ ++ gpdisp = (elf64_sw64_find_reloc_at_ofs ++ (tsec_relocs, tsec_relend, ofs, R_SW64_GPDISP)); ++ ++ if (!gpdisp || gpdisp->r_addend != 4) ++ { ++ free (tsec_free); ++ return 0; ++ } ++ free (tsec_free); ++ } ++ ++ /* We've now determined that we can skip an initial gp load. Verify ++ that the call and the target use the same gp. */ ++ if (info->link_info->output_bfd->xvec != info->tsec->owner->xvec ++ || info->gotobj != sw64_elf_tdata (info->tsec->owner)->gotobj) ++ return 0; ++ ++ return symval + 8; ++} ++ ++static bool ++elf64_sw64_relax_with_lituse (struct sw64_relax_info *info, ++ bfd_vma symval, Elf_Internal_Rela *irel) ++{ ++ Elf_Internal_Rela *urel, *erel, *irelend = info->relend; ++ int flags; ++ bfd_signed_vma disp; ++ bool fits16; ++ bool fits32; ++ bool lit_reused = false; ++ bool all_optimized = true; ++ bool changed_contents; ++ bool changed_relocs; ++ bfd_byte *contents = info->contents; ++ bfd *abfd = info->abfd; ++ bfd_vma sec_output_vma; ++ unsigned int lit_insn; ++ int relax_pass; ++ ++ lit_insn = bfd_get_32 (abfd, contents + irel->r_offset); ++ if (lit_insn >> 26 != OP_LDQ) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: %pA+%#" PRIx64 ": warning: " ++ "%s relocation against unexpected insn"), ++ abfd, info->sec, (uint64_t) irel->r_offset, "LITERAL"); ++ return true; ++ } ++ ++ /* Can't relax dynamic symbols. */ ++ if (info->h != NULL ++ && sw64_elf_dynamic_symbol_p (&info->h->root, info->link_info)) ++ return true; ++ ++ changed_contents = info->changed_contents; ++ changed_relocs = info->changed_relocs; ++ sec_output_vma = info->sec->output_section->vma + info->sec->output_offset; ++ relax_pass = info->link_info->relax_pass; ++ ++ /* Summarize how this particular LITERAL is used. */ ++ for (erel = irel+1, flags = 0; erel < irelend; ++erel) ++ { ++ if (ELF64_R_TYPE (erel->r_info) != R_SW64_LITUSE) ++ break; ++ if (erel->r_addend <= 6) ++ flags |= 1 << erel->r_addend; ++ } ++ ++ /* A little preparation for the loop... */ ++ disp = symval - info->gp; ++ ++ for (urel = irel+1; urel < erel; ++urel) ++ { ++ bfd_vma urel_r_offset = urel->r_offset; ++ unsigned int insn; ++ int insn_disp; ++ bfd_signed_vma xdisp; ++ Elf_Internal_Rela nrel; ++ ++ insn = bfd_get_32 (abfd, contents + urel_r_offset); ++ ++ switch (urel->r_addend) ++ { ++ case LITUSE_SW64_ADDR: ++ default: ++ /* This type is really just a placeholder to note that all ++ uses cannot be optimized, but to still allow some. */ ++ all_optimized = false; ++ break; ++ ++ case LITUSE_SW64_BASE: ++ /* We may only create GPREL relocs during the second pass. */ ++ if (relax_pass == 0) ++ { ++ all_optimized = false; ++ break; ++ } ++ ++ /* We can always optimize 16-bit displacements. */ ++ ++ /* Extract the displacement from the instruction, sign-extending ++ it if necessary, then test whether it is within 16 or 32 bits ++ displacement from GP. */ ++ insn_disp = ((insn & 0xffff) ^ 0x8000) - 0x8000; ++ ++ xdisp = disp + insn_disp; ++ fits16 = (xdisp >= - (bfd_signed_vma) 0x8000 && xdisp < 0x8000); ++ fits32 = (xdisp >= - (bfd_signed_vma) 0x80000000 ++ && xdisp < 0x7fff8000); ++ ++ if (fits16) ++ { ++ /* Take the op code and dest from this insn, take the base ++ register from the literal insn. Leave the offset alone. */ ++ insn = (insn & 0xffe0ffff) | (lit_insn & 0x001f0000); ++ bfd_put_32 (abfd, (bfd_vma) insn, contents + urel_r_offset); ++ changed_contents = true; ++ ++ nrel = *urel; ++ nrel.r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), ++ R_SW64_GPREL16); ++ nrel.r_addend = irel->r_addend; ++ ++ /* As we adjust, move the reloc to the end so that we don't ++ break the LITERAL+LITUSE chain. */ ++ if (urel < --erel) ++ *urel-- = *erel; ++ *erel = nrel; ++ changed_relocs = true; ++ } ++ ++ /* If all mem+byte, we can optimize 32-bit mem displacements. */ ++ else if (fits32 && !(flags & ~6)) ++ { ++ /* FIXME: sanity check that lit insn Ra is mem insn Rb. */ ++ ++ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), ++ R_SW64_GPRELHIGH); ++ lit_insn = (OP_LDAH << 26) | (lit_insn & 0x03ff0000); ++ bfd_put_32 (abfd, (bfd_vma) lit_insn, contents + irel->r_offset); ++ lit_reused = true; ++ changed_contents = true; ++ ++ /* Since all relocs must be optimized, don't bother swapping ++ this relocation to the end. */ ++ urel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), ++ R_SW64_GPRELLOW); ++ urel->r_addend = irel->r_addend; ++ changed_relocs = true; ++ } ++ else ++ all_optimized = false; ++ break; ++ ++ case LITUSE_SW64_BYTOFF: ++ /* We can always optimize byte instructions. */ ++ ++ /* FIXME: sanity check the insn for byte op. Check that the ++ literal dest reg is indeed Rb in the byte insn. */ ++ ++ insn &= ~ (unsigned) 0x001ff000; ++ insn |= ((symval & 7) << 13) | 0x1000; ++ bfd_put_32 (abfd, (bfd_vma) insn, contents + urel_r_offset); ++ changed_contents = true; ++ ++ nrel = *urel; ++ nrel.r_info = ELF64_R_INFO (0, R_SW64_NONE); ++ nrel.r_addend = 0; ++ ++ /* As we adjust, move the reloc to the end so that we don't ++ break the LITERAL+LITUSE chain. */ ++ if (urel < --erel) ++ *urel-- = *erel; ++ *erel = nrel; ++ changed_relocs = true; ++ break; ++ ++ case LITUSE_SW64_JSR: ++ case LITUSE_SW64_TLSGD: ++ case LITUSE_SW64_TLSLDM: ++ case LITUSE_SW64_JSRDIRECT: ++ { ++ bfd_vma optdest, org; ++ bfd_signed_vma odisp; ++ ++ /* For undefined weak symbols, we're mostly interested in getting ++ rid of the got entry whenever possible, so optimize this to a ++ use of the zero register. */ ++ if (info->h && info->h->root.root.type == bfd_link_hash_undefweak) ++ { ++ insn |= 31 << 16; ++ bfd_put_32 (abfd, (bfd_vma) insn, contents + urel_r_offset); ++ ++ changed_contents = true; ++ break; ++ } ++ ++ /* If not zero, place to jump without needing pv. */ ++ optdest = elf64_sw64_relax_opt_call (info, symval); ++ org = sec_output_vma + urel_r_offset + 4; ++ odisp = (optdest ? optdest : symval) - org; ++ ++ if (odisp >= -0x400000 && odisp < 0x400000) ++ { ++ Elf_Internal_Rela *xrel; ++ ++ /* Preserve branch prediction call stack when possible. */ ++ if ((insn & INSN_JSR_MASK) == INSN_JSR) ++ insn = (OP_BSR << 26) | (insn & 0x03e00000); ++ else ++ insn = (OP_BR << 26) | (insn & 0x03e00000); ++ bfd_put_32 (abfd, (bfd_vma) insn, contents + urel_r_offset); ++ changed_contents = true; ++ ++ nrel = *urel; ++ nrel.r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), ++ R_SW64_BRADDR); ++ nrel.r_addend = irel->r_addend; ++ ++ if (optdest) ++ nrel.r_addend += optdest - symval; ++ else ++ all_optimized = false; ++ ++ /* Kill any HINT reloc that might exist for this insn. */ ++ xrel = (elf64_sw64_find_reloc_at_ofs ++ (info->relocs, info->relend, urel_r_offset, ++ R_SW64_HINT)); ++ if (xrel) ++ xrel->r_info = ELF64_R_INFO (0, R_SW64_NONE); ++ ++ /* As we adjust, move the reloc to the end so that we don't ++ break the LITERAL+LITUSE chain. */ ++ if (urel < --erel) ++ *urel-- = *erel; ++ *erel = nrel; ++ ++ info->changed_relocs = true; ++ } ++ else ++ all_optimized = false; ++ ++ /* Even if the target is not in range for a direct branch, ++ if we share a GP, we can eliminate the gp reload. */ ++ if (optdest) ++ { ++ Elf_Internal_Rela *gpdisp ++ = (elf64_sw64_find_reloc_at_ofs ++ (info->relocs, irelend, urel_r_offset + 4, ++ R_SW64_GPDISP)); ++ if (gpdisp) ++ { ++ bfd_byte *p_ldah = contents + gpdisp->r_offset; ++ bfd_byte *p_lda = p_ldah + gpdisp->r_addend; ++ unsigned int ldah = bfd_get_32 (abfd, p_ldah); ++ unsigned int lda = bfd_get_32 (abfd, p_lda); ++ ++ /* Verify that the instruction is "ldah $29,0($26)". ++ Consider a function that ends in a noreturn call, ++ and that the next function begins with an ldgp, ++ and that by accident there is no padding between. ++ In that case the insn would use $27 as the base. */ ++ if (ldah == 0x27ba0000 && lda == 0x23bd0000) ++ { ++ bfd_put_32 (abfd, (bfd_vma) INSN_UNOP, p_ldah); ++ bfd_put_32 (abfd, (bfd_vma) INSN_UNOP, p_lda); ++ ++ gpdisp->r_info = ELF64_R_INFO (0, R_SW64_NONE); ++ changed_contents = true; ++ changed_relocs = true; ++ } ++ } ++ } ++ } ++ break; ++ } ++ } ++ ++ /* If we reused the literal instruction, we must have optimized all. */ ++ BFD_ASSERT(!lit_reused || all_optimized); ++ ++ /* If all cases were optimized, we can reduce the use count on this ++ got entry by one, possibly eliminating it. */ ++ if (all_optimized) ++ { ++ if (--info->gotent->use_count == 0) ++ { ++ int sz = sw64_got_entry_size (R_SW64_LITERAL); ++ sw64_elf_tdata (info->gotobj)->total_got_size -= sz; ++ if (!info->h) ++ sw64_elf_tdata (info->gotobj)->local_got_size -= sz; ++ } ++ ++ /* If the literal instruction is no longer needed (it may have been ++ reused. We can eliminate it. */ ++ /* ??? For now, I don't want to deal with compacting the section, ++ so just nop it out. */ ++ if (!lit_reused) ++ { ++ irel->r_info = ELF64_R_INFO (0, R_SW64_NONE); ++ changed_relocs = true; ++ ++ bfd_put_32 (abfd, (bfd_vma) INSN_UNOP, contents + irel->r_offset); ++ changed_contents = true; ++ } ++ } ++ ++ info->changed_contents = changed_contents; ++ info->changed_relocs = changed_relocs; ++ ++ if (all_optimized || relax_pass == 0) ++ return true; ++ return elf64_sw64_relax_got_load (info, symval, irel, R_SW64_LITERAL); ++} ++ ++static bool ++elf64_sw64_relax_tls_get_addr (struct sw64_relax_info *info, bfd_vma symval, ++ Elf_Internal_Rela *irel, bool is_gd) ++{ ++ bfd_byte *pos[5]; ++ unsigned int insn, tlsgd_reg; ++ Elf_Internal_Rela *gpdisp, *hint; ++ bool dynamic, use_gottprel; ++ unsigned long new_symndx; ++ ++ dynamic = (info->h != NULL ++ && sw64_elf_dynamic_symbol_p (&info->h->root, info->link_info)); ++ ++ /* If a TLS symbol is accessed using IE at least once, there is no point ++ to use dynamic model for it. */ ++ if (is_gd && info->h && (info->h->flags & SW64_ELF_LINK_HASH_TLS_IE)) ++ ; ++ ++ /* If the symbol is local, and we've already committed to DF_STATIC_TLS, ++ then we might as well relax to IE. */ ++ else if (bfd_link_pic (info->link_info) && !dynamic ++ && (info->link_info->flags & DF_STATIC_TLS)) ++ ; ++ ++ /* Otherwise we must be building an executable to do anything. */ ++ else if (bfd_link_pic (info->link_info)) ++ return true; ++ ++ /* The TLSGD/TLSLDM relocation must be followed by a LITERAL and ++ the matching LITUSE_TLS relocations. */ ++ if (irel + 2 >= info->relend) ++ return true; ++ if (ELF64_R_TYPE (irel[1].r_info) != R_SW64_LITERAL ++ || ELF64_R_TYPE (irel[2].r_info) != R_SW64_LITUSE ++ || irel[2].r_addend != (is_gd ? LITUSE_SW64_TLSGD : LITUSE_SW64_TLSLDM)) ++ return true; ++ ++ /* There must be a GPDISP relocation positioned immediately after the ++ LITUSE relocation. */ ++ gpdisp = elf64_sw64_find_reloc_at_ofs (info->relocs, info->relend, ++ irel[2].r_offset + 4, R_SW64_GPDISP); ++ if (!gpdisp) ++ return true; ++ ++ pos[0] = info->contents + irel[0].r_offset; ++ pos[1] = info->contents + irel[1].r_offset; ++ pos[2] = info->contents + irel[2].r_offset; ++ pos[3] = info->contents + gpdisp->r_offset; ++ pos[4] = pos[3] + gpdisp->r_addend; ++ ++ /* Beware of the compiler hoisting part of the sequence out a loop ++ and adjusting the destination register for the TLSGD insn. If this ++ happens, there will be a move into $16 before the JSR insn, so only ++ transformations of the first insn pair should use this register. */ ++ tlsgd_reg = bfd_get_32 (info->abfd, pos[0]); ++ tlsgd_reg = (tlsgd_reg >> 21) & 31; ++ ++ /* Generally, the positions are not allowed to be out of order, lest the ++ modified insn sequence have different register lifetimes. We can make ++ an exception when pos 1 is adjacent to pos 0. */ ++ if (pos[1] + 4 == pos[0]) ++ { ++ bfd_byte *tmp = pos[0]; ++ pos[0] = pos[1]; ++ pos[1] = tmp; ++ } ++ if (pos[1] >= pos[2] || pos[2] >= pos[3]) ++ return true; ++ ++ /* Reduce the use count on the LITERAL relocation. Do this before we ++ smash the symndx when we adjust the relocations below. */ ++ { ++ struct sw64_elf_got_entry *lit_gotent; ++ struct sw64_elf_link_hash_entry *lit_h; ++ unsigned long indx; ++ ++ BFD_ASSERT (ELF64_R_SYM (irel[1].r_info) >= info->symtab_hdr->sh_info); ++ indx = ELF64_R_SYM (irel[1].r_info) - info->symtab_hdr->sh_info; ++ lit_h = sw64_elf_sym_hashes (info->abfd)[indx]; ++ ++ while (lit_h->root.root.type == bfd_link_hash_indirect ++ || lit_h->root.root.type == bfd_link_hash_warning) ++ lit_h = (struct sw64_elf_link_hash_entry *) lit_h->root.root.u.i.link; ++ ++ for (lit_gotent = lit_h->got_entries; lit_gotent ; ++ lit_gotent = lit_gotent->next) ++ if (lit_gotent->gotobj == info->gotobj ++ && lit_gotent->reloc_type == R_SW64_LITERAL ++ && lit_gotent->addend == irel[1].r_addend) ++ break; ++ BFD_ASSERT (lit_gotent); ++ ++ if (--lit_gotent->use_count == 0) ++ { ++ int sz = sw64_got_entry_size (R_SW64_LITERAL); ++ sw64_elf_tdata (info->gotobj)->total_got_size -= sz; ++ } ++ } ++ ++ /* Change ++ ++ lda $16,x($gp) !tlsgd!1 ++ ldq $27,__tls_get_addr($gp) !literal!1 ++ jsr $26,($27),__tls_get_addr !lituse_tlsgd!1 ++ ldah $29,0($26) !gpdisp!2 ++ lda $29,0($29) !gpdisp!2 ++ to ++ ldq $16,x($gp) !gottprel ++ unop ++ call_pal rduniq ++ addq $16,$0,$0 ++ unop ++ or the first pair to ++ lda $16,x($gp) !tprel ++ unop ++ or ++ ldah $16,x($gp) !tprelhi ++ lda $16,x($16) !tprello ++ ++ as appropriate. */ ++ ++ use_gottprel = false; ++ new_symndx = is_gd ? ELF64_R_SYM (irel->r_info) : STN_UNDEF; ++ ++ /* Some compilers warn about a Boolean-looking expression being ++ used in a switch. The explicit cast silences them. */ ++ switch ((int) (!dynamic && !bfd_link_pic (info->link_info))) ++ { ++ case 1: ++ { ++ bfd_vma tp_base; ++ bfd_signed_vma disp; ++ ++ BFD_ASSERT (elf_hash_table (info->link_info)->tls_sec != NULL); ++ tp_base = sw64_get_tprel_base (info->link_info); ++ disp = symval - tp_base; ++ ++ if (disp >= -0x8000 && disp < 0x8000) ++ { ++ insn = (OP_LDA << 26) | (tlsgd_reg << 21) | (31 << 16); ++ bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]); ++ bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[1]); ++ ++ irel[0].r_offset = pos[0] - info->contents; ++ irel[0].r_info = ELF64_R_INFO (new_symndx, R_SW64_TPREL16); ++ irel[1].r_info = ELF64_R_INFO (0, R_SW64_NONE); ++ break; ++ } ++ else if (disp >= -(bfd_signed_vma) 0x80000000 ++ && disp < (bfd_signed_vma) 0x7fff8000 ++ && pos[0] + 4 == pos[1]) ++ { ++ insn = (OP_LDAH << 26) | (tlsgd_reg << 21) | (31 << 16); ++ bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]); ++ insn = (OP_LDA << 26) | (tlsgd_reg << 21) | (tlsgd_reg << 16); ++ bfd_put_32 (info->abfd, (bfd_vma) insn, pos[1]); ++ ++ irel[0].r_offset = pos[0] - info->contents; ++ irel[0].r_info = ELF64_R_INFO (new_symndx, R_SW64_TPRELHI); ++ irel[1].r_offset = pos[1] - info->contents; ++ irel[1].r_info = ELF64_R_INFO (new_symndx, R_SW64_TPRELLO); ++ break; ++ } ++ } ++ /* FALLTHRU */ ++ ++ default: ++ use_gottprel = true; ++ ++ insn = (OP_LDQ << 26) | (tlsgd_reg << 21) | (29 << 16); ++ bfd_put_32 (info->abfd, (bfd_vma) insn, pos[0]); ++ bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[1]); ++ ++ irel[0].r_offset = pos[0] - info->contents; ++ irel[0].r_info = ELF64_R_INFO (new_symndx, R_SW64_GOTTPREL); ++ irel[1].r_info = ELF64_R_INFO (0, R_SW64_NONE); ++ break; ++ } ++ ++ bfd_put_32 (info->abfd, (bfd_vma) INSN_RDUNIQ, pos[2]); ++ ++ insn = INSN_ADDQ | (16 << 21) | (0 << 16) | (0 << 0); ++ bfd_put_32 (info->abfd, (bfd_vma) insn, pos[3]); ++ ++ bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, pos[4]); ++ ++ irel[2].r_info = ELF64_R_INFO (0, R_SW64_NONE); ++ gpdisp->r_info = ELF64_R_INFO (0, R_SW64_NONE); ++ ++ hint = elf64_sw64_find_reloc_at_ofs (info->relocs, info->relend, ++ irel[2].r_offset, R_SW64_HINT); ++ if (hint) ++ hint->r_info = ELF64_R_INFO (0, R_SW64_NONE); ++ ++ info->changed_contents = true; ++ info->changed_relocs = true; ++ ++ /* Reduce the use count on the TLSGD/TLSLDM relocation. */ ++ if (--info->gotent->use_count == 0) ++ { ++ int sz = sw64_got_entry_size (info->gotent->reloc_type); ++ sw64_elf_tdata (info->gotobj)->total_got_size -= sz; ++ if (!info->h) ++ sw64_elf_tdata (info->gotobj)->local_got_size -= sz; ++ } ++ ++ /* If we've switched to a GOTTPREL relocation, increment the reference ++ count on that got entry. */ ++ if (use_gottprel) ++ { ++ struct sw64_elf_got_entry *tprel_gotent; ++ ++ for (tprel_gotent = *info->first_gotent; tprel_gotent ; ++ tprel_gotent = tprel_gotent->next) ++ if (tprel_gotent->gotobj == info->gotobj ++ && tprel_gotent->reloc_type == R_SW64_GOTTPREL ++ && tprel_gotent->addend == irel->r_addend) ++ break; ++ if (tprel_gotent) ++ tprel_gotent->use_count++; ++ else ++ { ++ if (info->gotent->use_count == 0) ++ tprel_gotent = info->gotent; ++ else ++ { ++ tprel_gotent = (struct sw64_elf_got_entry *) ++ bfd_alloc (info->abfd, sizeof (struct sw64_elf_got_entry)); ++ if (!tprel_gotent) ++ return false; ++ ++ tprel_gotent->next = *info->first_gotent; ++ *info->first_gotent = tprel_gotent; ++ ++ tprel_gotent->gotobj = info->gotobj; ++ tprel_gotent->addend = irel->r_addend; ++ tprel_gotent->got_offset = -1; ++ tprel_gotent->reloc_done = 0; ++ tprel_gotent->reloc_xlated = 0; ++ } ++ ++ tprel_gotent->use_count = 1; ++ tprel_gotent->reloc_type = R_SW64_GOTTPREL; ++ } ++ } ++ ++ return true; ++} ++ ++static bool ++elf64_sw64_relax_section (bfd *abfd, asection *sec, ++ struct bfd_link_info *link_info, bool *again) ++{ ++ Elf_Internal_Shdr *symtab_hdr; ++ Elf_Internal_Rela *internal_relocs; ++ Elf_Internal_Rela *irel, *irelend; ++ Elf_Internal_Sym *isymbuf = NULL; ++ struct sw64_elf_got_entry **local_got_entries; ++ struct sw64_relax_info info; ++ struct sw64_elf_link_hash_table * htab; ++ int relax_pass; ++ ++ htab = sw64_elf_hash_table (link_info); ++ if (htab == NULL) ++ return false; ++ ++ /* There's nothing to change, yet. */ ++ *again = false; ++ ++ if (bfd_link_relocatable (link_info) ++ || ((sec->flags & (SEC_CODE | SEC_RELOC | SEC_ALLOC | SEC_HAS_CONTENTS)) ++ != (SEC_CODE | SEC_RELOC | SEC_ALLOC | SEC_HAS_CONTENTS)) ++ || sec->reloc_count == 0) ++ return true; ++ ++ BFD_ASSERT (is_sw64_elf (abfd)); ++ relax_pass = link_info->relax_pass; ++ ++ /* Make sure our GOT and PLT tables are up-to-date. */ ++ if (htab->relax_trip != link_info->relax_trip) ++ { ++ htab->relax_trip = link_info->relax_trip; ++ ++ /* This should never fail after the initial round, since the only error ++ is GOT overflow, and relaxation only shrinks the table. However, we ++ may only merge got sections during the first pass. If we merge ++ sections after we've created GPREL relocs, the GP for the merged ++ section backs up which may put the relocs out of range. */ ++ if (!elf64_sw64_size_got_sections (link_info, relax_pass == 0)) ++ abort (); ++ if (elf_hash_table (link_info)->dynamic_sections_created) ++ { ++ elf64_sw64_size_plt_section (link_info); ++ elf64_sw64_size_rela_got_section (link_info); ++ } ++ } ++ ++ symtab_hdr = &elf_symtab_hdr (abfd); ++ local_got_entries = sw64_elf_tdata(abfd)->local_got_entries; ++ ++ /* Load the relocations for this section. */ ++ internal_relocs = (_bfd_elf_link_read_relocs ++ (abfd, sec, NULL, (Elf_Internal_Rela *) NULL, ++ link_info->keep_memory)); ++ if (internal_relocs == NULL) ++ return false; ++ ++ memset(&info, 0, sizeof (info)); ++ info.abfd = abfd; ++ info.sec = sec; ++ info.link_info = link_info; ++ info.symtab_hdr = symtab_hdr; ++ info.relocs = internal_relocs; ++ info.relend = irelend = internal_relocs + sec->reloc_count; ++ ++ /* Find the GP for this object. Do not store the result back via ++ _bfd_set_gp_value, since this could change again before final. */ ++ info.gotobj = sw64_elf_tdata (abfd)->gotobj; ++ if (info.gotobj) ++ { ++ asection *sgot = sw64_elf_tdata (info.gotobj)->got; ++ info.gp = (sgot->output_section->vma ++ + sgot->output_offset ++ + 0x8000); ++ } ++ ++ /* Get the section contents. */ ++ if (elf_section_data (sec)->this_hdr.contents != NULL) ++ info.contents = elf_section_data (sec)->this_hdr.contents; ++ else ++ { ++ if (!bfd_malloc_and_get_section (abfd, sec, &info.contents)) ++ goto error_return; ++ } ++ ++ for (irel = internal_relocs; irel < irelend; irel++) ++ { ++ bfd_vma symval; ++ struct sw64_elf_got_entry *gotent; ++ unsigned long r_type = ELF64_R_TYPE (irel->r_info); ++ unsigned long r_symndx = ELF64_R_SYM (irel->r_info); ++ ++ /* Early exit for unhandled or unrelaxable relocations. */ ++ if (r_type != R_SW64_LITERAL) ++ { ++ /* We complete everything except LITERAL in the first pass. */ ++ if (relax_pass != 0) ++ continue; ++ if (r_type == R_SW64_TLSLDM) ++ { ++ /* The symbol for a TLSLDM reloc is ignored. Collapse the ++ reloc to the STN_UNDEF (0) symbol so that they all match. */ ++ r_symndx = STN_UNDEF; ++ } ++ else if (r_type != R_SW64_GOTDTPREL ++ && r_type != R_SW64_GOTTPREL ++ && r_type != R_SW64_TLSGD) ++ continue; ++ } ++ ++ /* Get the value of the symbol referred to by the reloc. */ ++ if (r_symndx < symtab_hdr->sh_info) ++ { ++ /* A local symbol. */ ++ Elf_Internal_Sym *isym; ++ ++ /* Read this BFD's local symbols. */ ++ if (isymbuf == NULL) ++ { ++ isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents; ++ if (isymbuf == NULL) ++ isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr, ++ symtab_hdr->sh_info, 0, ++ NULL, NULL, NULL); ++ if (isymbuf == NULL) ++ goto error_return; ++ } ++ ++ isym = isymbuf + r_symndx; ++ ++ /* Given the symbol for a TLSLDM reloc is ignored, this also ++ means forcing the symbol value to the tp base. */ ++ if (r_type == R_SW64_TLSLDM) ++ { ++ info.tsec = bfd_abs_section_ptr; ++ symval = sw64_get_tprel_base (info.link_info); ++ } ++ else ++ { ++ symval = isym->st_value; ++ if (isym->st_shndx == SHN_UNDEF) ++ continue; ++ else if (isym->st_shndx == SHN_ABS) ++ info.tsec = bfd_abs_section_ptr; ++ else if (isym->st_shndx == SHN_COMMON) ++ info.tsec = bfd_com_section_ptr; ++ else ++ info.tsec = bfd_section_from_elf_index (abfd, isym->st_shndx); ++ } ++ ++ info.h = NULL; ++ info.other = isym->st_other; ++ if (local_got_entries) ++ info.first_gotent = &local_got_entries[r_symndx]; ++ else ++ { ++ info.first_gotent = &info.gotent; ++ info.gotent = NULL; ++ } ++ } ++ else ++ { ++ unsigned long indx; ++ struct sw64_elf_link_hash_entry *h; ++ ++ indx = r_symndx - symtab_hdr->sh_info; ++ h = sw64_elf_sym_hashes (abfd)[indx]; ++ BFD_ASSERT (h != NULL); ++ ++ while (h->root.root.type == bfd_link_hash_indirect ++ || h->root.root.type == bfd_link_hash_warning) ++ h = (struct sw64_elf_link_hash_entry *)h->root.root.u.i.link; ++ ++ /* If the symbol is undefined, we can't do anything with it. */ ++ if (h->root.root.type == bfd_link_hash_undefined) ++ continue; ++ ++ /* If the symbol isn't defined in the current module, ++ again we can't do anything. */ ++ if (h->root.root.type == bfd_link_hash_undefweak) ++ { ++ info.tsec = bfd_abs_section_ptr; ++ symval = 0; ++ } ++ else if (!h->root.def_regular) ++ { ++ /* Except for TLSGD relocs, which can sometimes be ++ relaxed to GOTTPREL relocs. */ ++ if (r_type != R_SW64_TLSGD) ++ continue; ++ info.tsec = bfd_abs_section_ptr; ++ symval = 0; ++ } ++ else ++ { ++ info.tsec = h->root.root.u.def.section; ++ symval = h->root.root.u.def.value; ++ } ++ ++ info.h = h; ++ info.other = h->root.other; ++ info.first_gotent = &h->got_entries; ++ } ++ ++ /* Search for the got entry to be used by this relocation. */ ++ for (gotent = *info.first_gotent; gotent ; gotent = gotent->next) ++ if (gotent->gotobj == info.gotobj ++ && gotent->reloc_type == r_type ++ && gotent->addend == irel->r_addend) ++ break; ++ info.gotent = gotent; ++ ++ symval += info.tsec->output_section->vma + info.tsec->output_offset; ++ symval += irel->r_addend; ++ ++ switch (r_type) ++ { ++ case R_SW64_LITERAL: ++ BFD_ASSERT(info.gotent != NULL); ++ ++ /* If there exist LITUSE relocations immediately following, this ++ opens up all sorts of interesting optimizations, because we ++ now know every location that this address load is used. */ ++ if (irel+1 < irelend ++ && ELF64_R_TYPE (irel[1].r_info) == R_SW64_LITUSE) ++ { ++ if (!elf64_sw64_relax_with_lituse (&info, symval, irel)) ++ goto error_return; ++ } ++ else ++ { ++ if (!elf64_sw64_relax_got_load (&info, symval, irel, r_type)) ++ goto error_return; ++ } ++ break; ++ ++ case R_SW64_GOTDTPREL: ++ case R_SW64_GOTTPREL: ++ BFD_ASSERT(info.gotent != NULL); ++ if (!elf64_sw64_relax_got_load (&info, symval, irel, r_type)) ++ goto error_return; ++ break; ++ ++ case R_SW64_TLSGD: ++ case R_SW64_TLSLDM: ++ BFD_ASSERT(info.gotent != NULL); ++ if (!elf64_sw64_relax_tls_get_addr (&info, symval, irel, ++ r_type == R_SW64_TLSGD)) ++ goto error_return; ++ break; ++ } ++ } ++ ++ if (isymbuf != NULL ++ && symtab_hdr->contents != (unsigned char *) isymbuf) ++ { ++ if (!link_info->keep_memory) ++ free (isymbuf); ++ else ++ { ++ /* Cache the symbols for elf_link_input_bfd. */ ++ symtab_hdr->contents = (unsigned char *) isymbuf; ++ } ++ } ++ ++ if (info.contents != NULL ++ && elf_section_data (sec)->this_hdr.contents != info.contents) ++ { ++ if (!info.changed_contents && !link_info->keep_memory) ++ free (info.contents); ++ else ++ { ++ /* Cache the section contents for elf_link_input_bfd. */ ++ elf_section_data (sec)->this_hdr.contents = info.contents; ++ } ++ } ++ ++ if (elf_section_data (sec)->relocs != internal_relocs) ++ { ++ if (!info.changed_relocs) ++ free (internal_relocs); ++ else ++ elf_section_data (sec)->relocs = internal_relocs; ++ } ++ ++ *again = info.changed_contents || info.changed_relocs; ++ ++ return true; ++ ++ error_return: ++ if (symtab_hdr->contents != (unsigned char *) isymbuf) ++ free (isymbuf); ++ if (elf_section_data (sec)->this_hdr.contents != info.contents) ++ free (info.contents); ++ if (elf_section_data (sec)->relocs != internal_relocs) ++ free (internal_relocs); ++ return false; ++} ++ ++/* Emit a dynamic relocation for (DYNINDX, RTYPE, ADDEND) at (SEC, OFFSET) ++ into the next available slot in SREL. */ ++ ++static void ++elf64_sw64_emit_dynrel (bfd *abfd, struct bfd_link_info *info, ++ asection *sec, asection *srel, bfd_vma offset, ++ long dynindx, long rtype, bfd_vma addend) ++{ ++ Elf_Internal_Rela outrel; ++ bfd_byte *loc; ++ ++ BFD_ASSERT (srel != NULL); ++ ++ outrel.r_info = ELF64_R_INFO (dynindx, rtype); ++ outrel.r_addend = addend; ++ ++ offset = _bfd_elf_section_offset (abfd, info, sec, offset); ++ if ((offset | 1) != (bfd_vma) -1) ++ outrel.r_offset = sec->output_section->vma + sec->output_offset + offset; ++ else ++ memset (&outrel, 0, sizeof (outrel)); ++ ++ loc = srel->contents; ++ loc += srel->reloc_count++ * sizeof (Elf64_External_Rela); ++ bfd_elf64_swap_reloca_out (abfd, &outrel, loc); ++ BFD_ASSERT (sizeof (Elf64_External_Rela) * srel->reloc_count <= srel->size); ++} ++ ++/* Relocate an SW64 ELF section for a relocatable link. ++ ++ We don't have to change anything unless the reloc is against a section ++ symbol, in which case we have to adjust according to where the section ++ symbol winds up in the output section. */ ++ ++static int ++elf64_sw64_relocate_section_r (bfd *output_bfd ATTRIBUTE_UNUSED, ++ struct bfd_link_info *info ATTRIBUTE_UNUSED, ++ bfd *input_bfd, asection *input_section, ++ bfd_byte *contents ATTRIBUTE_UNUSED, ++ Elf_Internal_Rela *relocs, ++ Elf_Internal_Sym *local_syms, ++ asection **local_sections) ++{ ++ unsigned long symtab_hdr_sh_info; ++ Elf_Internal_Rela *rel; ++ Elf_Internal_Rela *relend; ++ struct elf_link_hash_entry **sym_hashes; ++ bool ret_val = true; ++ ++ symtab_hdr_sh_info = elf_symtab_hdr (input_bfd).sh_info; ++ sym_hashes = elf_sym_hashes (input_bfd); ++ ++ relend = relocs + input_section->reloc_count; ++ for (rel = relocs; rel < relend; rel++) ++ { ++ unsigned long r_symndx; ++ Elf_Internal_Sym *sym; ++ asection *sec; ++ unsigned long r_type; ++ ++ r_type = ELF64_R_TYPE (rel->r_info); ++ if (r_type >= R_SW64_max) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: unsupported relocation type %#x"), ++ input_bfd, (int) r_type); ++ bfd_set_error (bfd_error_bad_value); ++ ret_val = false; ++ continue; ++ } ++ ++ /* The symbol associated with GPDISP and LITUSE is ++ immaterial. Only the addend is significant. */ ++ if (r_type == R_SW64_GPDISP || r_type == R_SW64_LITUSE) ++ continue; ++ ++ r_symndx = ELF64_R_SYM (rel->r_info); ++ if (r_symndx < symtab_hdr_sh_info) ++ { ++ sym = local_syms + r_symndx; ++ sec = local_sections[r_symndx]; ++ } ++ else ++ { ++ struct elf_link_hash_entry *h; ++ ++ h = sym_hashes[r_symndx - symtab_hdr_sh_info]; ++ ++ while (h->root.type == bfd_link_hash_indirect ++ || h->root.type == bfd_link_hash_warning) ++ h = (struct elf_link_hash_entry *) h->root.u.i.link; ++ ++ if (h->root.type != bfd_link_hash_defined ++ && h->root.type != bfd_link_hash_defweak) ++ continue; ++ ++ sym = NULL; ++ sec = h->root.u.def.section; ++ } ++ ++ if (sec != NULL && discarded_section (sec)) ++ RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, ++ rel, 1, relend, ++ elf64_sw64_howto_table + r_type, 0, ++ contents); ++ ++ if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION) ++ rel->r_addend += sec->output_offset; ++ } ++ ++ return ret_val; ++} ++ ++/* Relocate an SW64 ELF section. */ ++ ++static int ++elf64_sw64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, ++ bfd *input_bfd, asection *input_section, ++ bfd_byte *contents, Elf_Internal_Rela *relocs, ++ Elf_Internal_Sym *local_syms, ++ asection **local_sections) ++{ ++ Elf_Internal_Shdr *symtab_hdr; ++ Elf_Internal_Rela *rel; ++ Elf_Internal_Rela *relend; ++ asection *sgot, *srel, *srelgot; ++ bfd *dynobj, *gotobj; ++ bfd_vma gp, tp_base, dtp_base; ++ struct sw64_elf_got_entry **local_got_entries; ++ bool ret_val; ++ ++ BFD_ASSERT (is_sw64_elf (input_bfd)); ++ ++ /* Handle relocatable links with a smaller loop. */ ++ if (bfd_link_relocatable (info)) ++ return elf64_sw64_relocate_section_r (output_bfd, info, input_bfd, ++ input_section, contents, relocs, ++ local_syms, local_sections); ++ ++ /* This is a final link. */ ++ ++ ret_val = true; ++ ++ symtab_hdr = &elf_symtab_hdr (input_bfd); ++ ++ dynobj = elf_hash_table (info)->dynobj; ++ srelgot = elf_hash_table (info)->srelgot; ++ ++ if (input_section->flags & SEC_ALLOC) ++ { ++ const char *section_name; ++ section_name = (bfd_elf_string_from_elf_section ++ (input_bfd, elf_elfheader(input_bfd)->e_shstrndx, ++ _bfd_elf_single_rel_hdr (input_section)->sh_name)); ++ BFD_ASSERT(section_name != NULL); ++ srel = bfd_get_linker_section (dynobj, section_name); ++ } ++ else ++ srel = NULL; ++ ++ /* Find the gp value for this input bfd. */ ++ gotobj = sw64_elf_tdata (input_bfd)->gotobj; ++ if (gotobj) ++ { ++ sgot = sw64_elf_tdata (gotobj)->got; ++ gp = _bfd_get_gp_value (gotobj); ++ if (gp == 0) ++ { ++ gp = (sgot->output_section->vma ++ + sgot->output_offset ++ + 0x8000); ++ _bfd_set_gp_value (gotobj, gp); ++ } ++ } ++ else ++ { ++ sgot = NULL; ++ gp = 0; ++ } ++ ++ local_got_entries = sw64_elf_tdata(input_bfd)->local_got_entries; ++ ++ if (elf_hash_table (info)->tls_sec != NULL) ++ { ++ dtp_base = sw64_get_dtprel_base (info); ++ tp_base = sw64_get_tprel_base (info); ++ } ++ else ++ dtp_base = tp_base = 0; ++ ++ relend = relocs + input_section->reloc_count; ++ for (rel = relocs; rel < relend; rel++) ++ { ++ struct sw64_elf_link_hash_entry *h = NULL; ++ struct sw64_elf_got_entry *gotent; ++ bfd_reloc_status_type r; ++ reloc_howto_type *howto; ++ unsigned long r_symndx; ++ Elf_Internal_Sym *sym = NULL; ++ asection *sec = NULL; ++ bfd_vma value; ++ bfd_vma addend; ++ bool dynamic_symbol_p; ++ bool unresolved_reloc = false; ++ bool undef_weak_ref = false; ++ unsigned long r_type; ++ ++ r_type = ELF64_R_TYPE(rel->r_info); ++ if (r_type >= R_SW64_max) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: unsupported relocation type %#x"), ++ input_bfd, (int) r_type); ++ bfd_set_error (bfd_error_bad_value); ++ ret_val = false; ++ continue; ++ } ++ ++ howto = elf64_sw64_howto_table + r_type; ++ r_symndx = ELF64_R_SYM(rel->r_info); ++ ++ /* The symbol for a TLSLDM reloc is ignored. Collapse the ++ reloc to the STN_UNDEF (0) symbol so that they all match. */ ++ if (r_type == R_SW64_TLSLDM) ++ r_symndx = STN_UNDEF; ++ ++ if (r_symndx < symtab_hdr->sh_info) ++ { ++ asection *msec; ++ sym = local_syms + r_symndx; ++ sec = local_sections[r_symndx]; ++ msec = sec; ++ value = _bfd_elf_rela_local_sym (output_bfd, sym, &msec, rel); ++ ++ /* If this is a tp-relative relocation against sym STN_UNDEF (0), ++ this is hackery from relax_section. Force the value to ++ be the tls module base. */ ++ if (r_symndx == STN_UNDEF ++ && (r_type == R_SW64_TLSLDM ++ || r_type == R_SW64_GOTTPREL ++ || r_type == R_SW64_TPREL64 ++ || r_type == R_SW64_TPRELHI ++ || r_type == R_SW64_TPRELLO ++ || r_type == R_SW64_TPREL16)) ++ value = dtp_base; ++ ++ if (local_got_entries) ++ gotent = local_got_entries[r_symndx]; ++ else ++ gotent = NULL; ++ ++ /* Need to adjust local GOT entries' addends for SEC_MERGE ++ unless it has been done already. */ ++ if ((sec->flags & SEC_MERGE) ++ && ELF_ST_TYPE (sym->st_info) == STT_SECTION ++ && sec->sec_info_type == SEC_INFO_TYPE_MERGE ++ && gotent ++ && !gotent->reloc_xlated) ++ { ++ struct sw64_elf_got_entry *ent; ++ ++ for (ent = gotent; ent; ent = ent->next) ++ { ++ ent->reloc_xlated = 1; ++ if (ent->use_count == 0) ++ continue; ++ msec = sec; ++ ent->addend = ++ _bfd_merged_section_offset (output_bfd, &msec, ++ elf_section_data (sec)-> ++ sec_info, ++ sym->st_value + ent->addend); ++ ent->addend -= sym->st_value; ++ ent->addend += msec->output_section->vma ++ + msec->output_offset ++ - sec->output_section->vma ++ - sec->output_offset; ++ } ++ } ++ ++ dynamic_symbol_p = false; ++ } ++ else ++ { ++ bool warned, ignored; ++ struct elf_link_hash_entry *hh; ++ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd); ++ ++ RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, ++ r_symndx, symtab_hdr, sym_hashes, ++ hh, sec, value, ++ unresolved_reloc, warned, ignored); ++ ++ if (warned) ++ continue; ++ ++ if (value == 0 ++ && ! unresolved_reloc ++ && hh->root.type == bfd_link_hash_undefweak) ++ undef_weak_ref = true; ++ ++ h = (struct sw64_elf_link_hash_entry *) hh; ++ dynamic_symbol_p = sw64_elf_dynamic_symbol_p (&h->root, info); ++ gotent = h->got_entries; ++ } ++ ++ if (sec != NULL && discarded_section (sec)) ++ RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, ++ rel, 1, relend, howto, 0, contents); ++ ++ addend = rel->r_addend; ++ value += addend; ++ ++ /* Search for the proper got entry. */ ++ for (; gotent ; gotent = gotent->next) ++ if (gotent->gotobj == gotobj ++ && gotent->reloc_type == r_type ++ && gotent->addend == addend) ++ break; ++ ++ switch (r_type) ++ { ++ case R_SW64_GPDISP: ++ { ++ bfd_byte *p_ldah, *p_lda; ++ ++ BFD_ASSERT(gp != 0); ++ ++ value = (input_section->output_section->vma ++ + input_section->output_offset ++ + rel->r_offset); ++ ++ p_ldah = contents + rel->r_offset; ++ p_lda = p_ldah + rel->r_addend; ++ ++ r = elf64_sw64_do_reloc_gpdisp (input_bfd, gp - value, ++ p_ldah, p_lda); ++ } ++ break; ++ ++ case R_SW64_LITERAL: ++ BFD_ASSERT(sgot != NULL); ++ BFD_ASSERT(gp != 0); ++ BFD_ASSERT(gotent != NULL); ++ BFD_ASSERT(gotent->use_count >= 1); ++ ++ if (!gotent->reloc_done) ++ { ++ gotent->reloc_done = 1; ++ ++ bfd_put_64 (output_bfd, value, ++ sgot->contents + gotent->got_offset); ++ ++ /* If the symbol has been forced local, output a ++ RELATIVE reloc, otherwise it will be handled in ++ finish_dynamic_symbol. */ ++ if (bfd_link_pic (info) ++ && !dynamic_symbol_p ++ && !undef_weak_ref) ++ elf64_sw64_emit_dynrel (output_bfd, info, sgot, srelgot, ++ gotent->got_offset, 0, ++ R_SW64_RELATIVE, value); ++ } ++ ++ value = (sgot->output_section->vma ++ + sgot->output_offset ++ + gotent->got_offset); ++ value -= gp; ++ goto default_reloc; ++ ++ case R_SW64_GPREL32: ++ case R_SW64_GPREL16: ++ case R_SW64_GPRELLOW: ++ if (dynamic_symbol_p) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: gp-relative relocation against dynamic symbol %s"), ++ input_bfd, h->root.root.root.string); ++ ret_val = false; ++ } ++ BFD_ASSERT(gp != 0); ++ value -= gp; ++ goto default_reloc; ++ ++ case R_SW64_GPRELHIGH: ++ if (dynamic_symbol_p) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: gp-relative relocation against dynamic symbol %s"), ++ input_bfd, h->root.root.root.string); ++ ret_val = false; ++ } ++ BFD_ASSERT(gp != 0); ++ value -= gp; ++ value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1); ++ goto default_reloc; ++ ++ case R_SW64_HINT: ++ /* A call to a dynamic symbol is definitely out of range of ++ the 16-bit displacement. Don't bother writing anything. */ ++ if (dynamic_symbol_p) ++ { ++ r = bfd_reloc_ok; ++ break; ++ } ++ /* The regular PC-relative stuff measures from the start of ++ the instruction rather than the end. */ ++ value -= 4; ++ goto default_reloc; ++ ++ case R_SW64_BRADDR: ++ if (dynamic_symbol_p) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: pc-relative relocation against dynamic symbol %s"), ++ input_bfd, h->root.root.root.string); ++ ret_val = false; ++ } ++ /* The regular PC-relative stuff measures from the start of ++ the instruction rather than the end. */ ++ value -= 4; ++ goto default_reloc; ++ ++ case R_SW64_BRSGP: ++ { ++ int other; ++ const char *name; ++ ++ /* The regular PC-relative stuff measures from the start of ++ the instruction rather than the end. */ ++ value -= 4; ++ ++ /* The source and destination gp must be the same. Note that ++ the source will always have an assigned gp, since we forced ++ one in check_relocs, but that the destination may not, as ++ it might not have had any relocations at all. Also take ++ care not to crash if H is an undefined symbol. */ ++ if (h != NULL && sec != NULL ++ && sw64_elf_tdata (sec->owner)->gotobj ++ && gotobj != sw64_elf_tdata (sec->owner)->gotobj) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: change in gp: BRSGP %s"), ++ input_bfd, h->root.root.root.string); ++ ret_val = false; ++ } ++ ++ /* The symbol should be marked either NOPV or STD_GPLOAD. */ ++ if (h != NULL) ++ other = h->root.other; ++ else ++ other = sym->st_other; ++ switch (other & STO_SW64_STD_GPLOAD) ++ { ++ case STO_SW64_NOPV: ++ break; ++ case STO_SW64_STD_GPLOAD: ++ value += 8; ++ break; ++ default: ++ if (h != NULL) ++ name = h->root.root.root.string; ++ else ++ { ++ name = (bfd_elf_string_from_elf_section ++ (input_bfd, symtab_hdr->sh_link, sym->st_name)); ++ if (name == NULL) ++ name = _(""); ++ else if (name[0] == 0) ++ name = bfd_section_name (sec); ++ } ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: !samegp reloc against symbol without .prologue: %s"), ++ input_bfd, name); ++ ret_val = false; ++ break; ++ } ++ ++ goto default_reloc; ++ } ++ ++ case R_SW64_REFLONG: ++ case R_SW64_REFQUAD: ++ case R_SW64_DTPREL64: ++ case R_SW64_TPREL64: ++ { ++ long dynindx, dyntype = r_type; ++ bfd_vma dynaddend; ++ ++ /* Careful here to remember RELATIVE relocations for global ++ variables for symbolic shared objects. */ ++ ++ if (dynamic_symbol_p) ++ { ++ BFD_ASSERT(h->root.dynindx != -1); ++ dynindx = h->root.dynindx; ++ dynaddend = addend; ++ addend = 0, value = 0; ++ } ++ else if (r_type == R_SW64_DTPREL64) ++ { ++ BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL); ++ value -= dtp_base; ++ goto default_reloc; ++ } ++ else if (r_type == R_SW64_TPREL64) ++ { ++ BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL); ++ if (!bfd_link_dll (info)) ++ { ++ value -= tp_base; ++ goto default_reloc; ++ } ++ dynindx = 0; ++ dynaddend = value - dtp_base; ++ } ++ else if (bfd_link_pic (info) ++ && r_symndx != STN_UNDEF ++ && (input_section->flags & SEC_ALLOC) ++ && !undef_weak_ref ++ && !(unresolved_reloc ++ && (_bfd_elf_section_offset (output_bfd, info, ++ input_section, ++ rel->r_offset) ++ == (bfd_vma) -1))) ++ { ++ if (r_type == R_SW64_REFLONG) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: unhandled dynamic relocation against %s"), ++ input_bfd, ++ h->root.root.root.string); ++ ret_val = false; ++ } ++ dynindx = 0; ++ dyntype = R_SW64_RELATIVE; ++ dynaddend = value; ++ } ++ else ++ goto default_reloc; ++ ++ if (input_section->flags & SEC_ALLOC) ++ elf64_sw64_emit_dynrel (output_bfd, info, input_section, ++ srel, rel->r_offset, dynindx, ++ dyntype, dynaddend); ++ } ++ goto default_reloc; ++ ++ case R_SW64_SREL16: ++ case R_SW64_SREL32: ++ case R_SW64_SREL64: ++ if (dynamic_symbol_p) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: pc-relative relocation against dynamic symbol %s"), ++ input_bfd, h->root.root.root.string); ++ ret_val = false; ++ } ++ else if (bfd_link_pic (info) ++ && undef_weak_ref) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: pc-relative relocation against undefined weak symbol %s"), ++ input_bfd, h->root.root.root.string); ++ ret_val = false; ++ } ++ ++ ++ /* ??? .eh_frame references to discarded sections will be smashed ++ to relocations against SHN_UNDEF. The .eh_frame format allows ++ NULL to be encoded as 0 in any format, so this works here. */ ++ if (r_symndx == STN_UNDEF ++ || (unresolved_reloc ++ && _bfd_elf_section_offset (output_bfd, info, ++ input_section, ++ rel->r_offset) == (bfd_vma) -1)) ++ howto = (elf64_sw64_howto_table ++ + (r_type - R_SW64_SREL32 + R_SW64_REFLONG)); ++ goto default_reloc; ++ ++ case R_SW64_TLSLDM: ++ /* Ignore the symbol for the relocation. The result is always ++ the current module. */ ++ dynamic_symbol_p = 0; ++ /* FALLTHRU */ ++ ++ case R_SW64_TLSGD: ++ if (!gotent->reloc_done) ++ { ++ gotent->reloc_done = 1; ++ ++ /* Note that the module index for the main program is 1. */ ++ bfd_put_64 (output_bfd, ++ !bfd_link_pic (info) && !dynamic_symbol_p, ++ sgot->contents + gotent->got_offset); ++ ++ /* If the symbol has been forced local, output a ++ DTPMOD64 reloc, otherwise it will be handled in ++ finish_dynamic_symbol. */ ++ if (bfd_link_pic (info) && !dynamic_symbol_p) ++ elf64_sw64_emit_dynrel (output_bfd, info, sgot, srelgot, ++ gotent->got_offset, 0, ++ R_SW64_DTPMOD64, 0); ++ ++ if (dynamic_symbol_p || r_type == R_SW64_TLSLDM) ++ value = 0; ++ else ++ { ++ BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL); ++ value -= dtp_base; ++ } ++ bfd_put_64 (output_bfd, value, ++ sgot->contents + gotent->got_offset + 8); ++ } ++ ++ value = (sgot->output_section->vma ++ + sgot->output_offset ++ + gotent->got_offset); ++ value -= gp; ++ goto default_reloc; ++ ++ case R_SW64_DTPRELHI: ++ case R_SW64_DTPRELLO: ++ case R_SW64_DTPREL16: ++ if (dynamic_symbol_p) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: dtp-relative relocation against dynamic symbol %s"), ++ input_bfd, h->root.root.root.string); ++ ret_val = false; ++ } ++ BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL); ++ value -= dtp_base; ++ if (r_type == R_SW64_DTPRELHI) ++ value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1); ++ goto default_reloc; ++ ++ case R_SW64_TPRELHI: ++ case R_SW64_TPRELLO: ++ case R_SW64_TPREL16: ++ if (bfd_link_dll (info)) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: TLS local exec code cannot be linked into shared objects"), ++ input_bfd); ++ ret_val = false; ++ } ++ else if (dynamic_symbol_p) ++ { ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%pB: tp-relative relocation against dynamic symbol %s"), ++ input_bfd, h->root.root.root.string); ++ ret_val = false; ++ } ++ BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL); ++ value -= tp_base; ++ if (r_type == R_SW64_TPRELHI) ++ value = ((bfd_signed_vma) value >> 16) + ((value >> 15) & 1); ++ goto default_reloc; ++ ++ case R_SW64_GOTDTPREL: ++ case R_SW64_GOTTPREL: ++ BFD_ASSERT(sgot != NULL); ++ BFD_ASSERT(gp != 0); ++ BFD_ASSERT(gotent != NULL); ++ BFD_ASSERT(gotent->use_count >= 1); ++ ++ if (!gotent->reloc_done) ++ { ++ gotent->reloc_done = 1; ++ ++ if (dynamic_symbol_p) ++ value = 0; ++ else ++ { ++ BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL); ++ if (r_type == R_SW64_GOTDTPREL) ++ value -= dtp_base; ++ else if (bfd_link_executable (info)) ++ value -= tp_base; ++ else ++ { ++ elf64_sw64_emit_dynrel (output_bfd, info, sgot, srelgot, ++ gotent->got_offset, 0, ++ R_SW64_TPREL64, ++ value - dtp_base); ++ value = 0; ++ } ++ } ++ bfd_put_64 (output_bfd, value, ++ sgot->contents + gotent->got_offset); ++ } ++ ++ value = (sgot->output_section->vma ++ + sgot->output_offset ++ + gotent->got_offset); ++ value -= gp; ++ goto default_reloc; ++ ++ default: ++ default_reloc: ++ r = _bfd_final_link_relocate (howto, input_bfd, input_section, ++ contents, rel->r_offset, value, 0); ++ break; ++ } ++ ++ switch (r) ++ { ++ case bfd_reloc_ok: ++ break; ++ ++ case bfd_reloc_overflow: ++ { ++ const char *name; ++ ++ /* Don't warn if the overflow is due to pc relative reloc ++ against discarded section. Section optimization code should ++ handle it. */ ++ ++ if (r_symndx < symtab_hdr->sh_info ++ && sec != NULL && howto->pc_relative ++ && discarded_section (sec)) ++ break; ++ ++ if (h != NULL) ++ name = NULL; ++ else ++ { ++ name = (bfd_elf_string_from_elf_section ++ (input_bfd, symtab_hdr->sh_link, sym->st_name)); ++ if (name == NULL) ++ return false; ++ if (*name == '\0') ++ name = bfd_section_name (sec); ++ } ++ (*info->callbacks->reloc_overflow) ++ (info, (h ? &h->root.root : NULL), name, howto->name, ++ (bfd_vma) 0, input_bfd, input_section, rel->r_offset); ++ } ++ break; ++ ++ default: ++ case bfd_reloc_outofrange: ++ abort (); ++ } ++ } ++ ++ return ret_val; ++} ++ ++/* Finish up dynamic symbol handling. We set the contents of various ++ dynamic sections here. */ ++ ++static bool ++elf64_sw64_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, ++ struct elf_link_hash_entry *h, ++ Elf_Internal_Sym *sym) ++{ ++ struct sw64_elf_link_hash_entry *ah = (struct sw64_elf_link_hash_entry *)h; ++ ++ if (h->needs_plt) ++ { ++ /* Fill in the .plt entry for this symbol. */ ++ asection *splt, *sgot, *srel; ++ Elf_Internal_Rela outrel; ++ bfd_byte *loc; ++ bfd_vma got_addr, plt_addr; ++ bfd_vma plt_index; ++ struct sw64_elf_got_entry *gotent; ++ ++ BFD_ASSERT (h->dynindx != -1); ++ ++ splt = elf_hash_table (info)->splt; ++ BFD_ASSERT (splt != NULL); ++ srel = elf_hash_table (info)->srelplt; ++ BFD_ASSERT (srel != NULL); ++ ++ for (gotent = ah->got_entries; gotent ; gotent = gotent->next) ++ if (gotent->reloc_type == R_SW64_LITERAL ++ && gotent->use_count > 0) ++ { ++ unsigned int insn; ++ int disp; ++ ++ sgot = sw64_elf_tdata (gotent->gotobj)->got; ++ BFD_ASSERT (sgot != NULL); ++ ++ BFD_ASSERT (gotent->got_offset != -1); ++ BFD_ASSERT (gotent->plt_offset != -1); ++ ++ got_addr = (sgot->output_section->vma ++ + sgot->output_offset ++ + gotent->got_offset); ++ plt_addr = (splt->output_section->vma ++ + splt->output_offset ++ + gotent->plt_offset); ++ ++ plt_index = (gotent->plt_offset-PLT_HEADER_SIZE) / PLT_ENTRY_SIZE; ++ ++ /* Fill in the entry in the procedure linkage table. */ ++ if (elf64_sw64_use_secureplt) ++ { ++ disp = (PLT_HEADER_SIZE - 4) - (gotent->plt_offset + 4); ++ insn = INSN_AD (INSN_BR, 31, disp); ++ bfd_put_32 (output_bfd, insn, ++ splt->contents + gotent->plt_offset); ++ ++ plt_index = ((gotent->plt_offset - NEW_PLT_HEADER_SIZE) ++ / NEW_PLT_ENTRY_SIZE); ++ } ++ else ++ { ++ disp = -(gotent->plt_offset + 4); ++ insn = INSN_AD (INSN_BR, 28, disp); ++ bfd_put_32 (output_bfd, insn, ++ splt->contents + gotent->plt_offset); ++ bfd_put_32 (output_bfd, INSN_UNOP, ++ splt->contents + gotent->plt_offset + 4); ++ bfd_put_32 (output_bfd, INSN_UNOP, ++ splt->contents + gotent->plt_offset + 8); ++ ++ plt_index = ((gotent->plt_offset - OLD_PLT_HEADER_SIZE) ++ / OLD_PLT_ENTRY_SIZE); ++ } ++ ++ /* Fill in the entry in the .rela.plt section. */ ++ outrel.r_offset = got_addr; ++ outrel.r_info = ELF64_R_INFO(h->dynindx, R_SW64_JMP_SLOT); ++ outrel.r_addend = 0; ++ ++ loc = srel->contents + plt_index * sizeof (Elf64_External_Rela); ++ bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); ++ ++ /* Fill in the entry in the .got. */ ++ bfd_put_64 (output_bfd, plt_addr, ++ sgot->contents + gotent->got_offset); ++ } ++ } ++ else if (sw64_elf_dynamic_symbol_p (h, info)) ++ { ++ /* Fill in the dynamic relocations for this symbol's .got entries. */ ++ asection *srel; ++ struct sw64_elf_got_entry *gotent; ++ ++ srel = elf_hash_table (info)->srelgot; ++ BFD_ASSERT (srel != NULL); ++ ++ for (gotent = ((struct sw64_elf_link_hash_entry *) h)->got_entries; ++ gotent != NULL; ++ gotent = gotent->next) ++ { ++ asection *sgot; ++ long r_type; ++ ++ if (gotent->use_count == 0) ++ continue; ++ ++ sgot = sw64_elf_tdata (gotent->gotobj)->got; ++ ++ r_type = gotent->reloc_type; ++ switch (r_type) ++ { ++ case R_SW64_LITERAL: ++ r_type = R_SW64_GLOB_DAT; ++ break; ++ case R_SW64_TLSGD: ++ r_type = R_SW64_DTPMOD64; ++ break; ++ case R_SW64_GOTDTPREL: ++ r_type = R_SW64_DTPREL64; ++ break; ++ case R_SW64_GOTTPREL: ++ r_type = R_SW64_TPREL64; ++ break; ++ case R_SW64_TLSLDM: ++ default: ++ abort (); ++ } ++ ++ elf64_sw64_emit_dynrel (output_bfd, info, sgot, srel, ++ gotent->got_offset, h->dynindx, ++ r_type, gotent->addend); ++ ++ if (gotent->reloc_type == R_SW64_TLSGD) ++ elf64_sw64_emit_dynrel (output_bfd, info, sgot, srel, ++ gotent->got_offset + 8, h->dynindx, ++ R_SW64_DTPREL64, gotent->addend); ++ } ++ } ++ ++ /* Mark some specially defined symbols as absolute. */ ++ if (h == elf_hash_table (info)->hdynamic ++ || h == elf_hash_table (info)->hgot ++ || h == elf_hash_table (info)->hplt) ++ sym->st_shndx = SHN_ABS; ++ ++ return true; ++} ++ ++/* Finish up the dynamic sections. */ ++ ++static bool ++elf64_sw64_finish_dynamic_sections (bfd *output_bfd, ++ struct bfd_link_info *info) ++{ ++ bfd *dynobj; ++ asection *sdyn; ++ ++ dynobj = elf_hash_table (info)->dynobj; ++ sdyn = bfd_get_linker_section (dynobj, ".dynamic"); ++ ++ if (elf_hash_table (info)->dynamic_sections_created) ++ { ++ asection *splt, *sgotplt, *srelaplt; ++ Elf64_External_Dyn *dyncon, *dynconend; ++ bfd_vma plt_vma, gotplt_vma; ++ ++ splt = elf_hash_table (info)->splt; ++ srelaplt = elf_hash_table (info)->srelplt; ++ BFD_ASSERT (splt != NULL && sdyn != NULL); ++ ++ plt_vma = splt->output_section->vma + splt->output_offset; ++ ++ gotplt_vma = 0; ++ if (elf64_sw64_use_secureplt) ++ { ++ sgotplt = elf_hash_table (info)->sgotplt; ++ BFD_ASSERT (sgotplt != NULL); ++ if (sgotplt->size > 0) ++ gotplt_vma = sgotplt->output_section->vma + sgotplt->output_offset; ++ } ++ ++ dyncon = (Elf64_External_Dyn *) sdyn->contents; ++ dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); ++ for (; dyncon < dynconend; dyncon++) ++ { ++ Elf_Internal_Dyn dyn; ++ ++ bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn); ++ ++ switch (dyn.d_tag) ++ { ++ case DT_PLTGOT: ++ dyn.d_un.d_ptr ++ = elf64_sw64_use_secureplt ? gotplt_vma : plt_vma; ++ break; ++ case DT_PLTRELSZ: ++ dyn.d_un.d_val = srelaplt ? srelaplt->size : 0; ++ break; ++ case DT_JMPREL: ++ dyn.d_un.d_ptr = srelaplt ? (srelaplt->output_section->vma ++ + srelaplt->output_offset) : 0; ++ break; ++ } ++ ++ bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); ++ } ++ ++ /* Initialize the plt header. */ ++ if (splt->size > 0) ++ { ++ unsigned int insn; ++ int ofs; ++ ++ if (elf64_sw64_use_secureplt) ++ { ++ ofs = gotplt_vma - (plt_vma + PLT_HEADER_SIZE); ++ ++ insn = INSN_ABC (INSN_SUBQ, 27, 28, 25); ++ bfd_put_32 (output_bfd, insn, splt->contents); ++ ++ insn = INSN_ABO (INSN_LDAH, 28, 28, (ofs + 0x8000) >> 16); ++ bfd_put_32 (output_bfd, insn, splt->contents + 4); ++ ++ insn = INSN_ABC (INSN_S4SUBQ, 25, 25, 25); ++ bfd_put_32 (output_bfd, insn, splt->contents + 8); ++ ++ insn = INSN_ABO (INSN_LDA, 28, 28, ofs); ++ bfd_put_32 (output_bfd, insn, splt->contents + 12); ++ ++ insn = INSN_ABO (INSN_LDQ, 27, 28, 0); ++ bfd_put_32 (output_bfd, insn, splt->contents + 16); ++ ++ insn = INSN_ABC (INSN_ADDQ, 25, 25, 25); ++ bfd_put_32 (output_bfd, insn, splt->contents + 20); ++ ++ insn = INSN_ABO (INSN_LDQ, 28, 28, 8); ++ bfd_put_32 (output_bfd, insn, splt->contents + 24); ++ ++ insn = INSN_AB (INSN_JMP, 31, 27); ++ bfd_put_32 (output_bfd, insn, splt->contents + 28); ++ ++ insn = INSN_AD (INSN_BR, 28, -PLT_HEADER_SIZE); ++ bfd_put_32 (output_bfd, insn, splt->contents + 32); ++ } ++ else ++ { ++ insn = INSN_AD (INSN_BR, 27, 0); /* br $27, .+4 */ ++ bfd_put_32 (output_bfd, insn, splt->contents); ++ ++ insn = INSN_ABO (INSN_LDQ, 27, 27, 12); ++ bfd_put_32 (output_bfd, insn, splt->contents + 4); ++ ++ insn = INSN_UNOP; ++ bfd_put_32 (output_bfd, insn, splt->contents + 8); ++ ++ insn = INSN_AB (INSN_JMP, 27, 27); ++ bfd_put_32 (output_bfd, insn, splt->contents + 12); ++ ++ /* The next two words will be filled in by ld.so. */ ++ bfd_put_64 (output_bfd, 0, splt->contents + 16); ++ bfd_put_64 (output_bfd, 0, splt->contents + 24); ++ } ++ ++ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 0; ++ } ++ } ++ ++ return true; ++} ++ ++/* We need to use a special link routine to handle the .mdebug section. ++ We need to merge all instances of these sections together, not write ++ them all out sequentially. */ ++ ++static bool ++elf64_sw64_final_link (bfd *abfd, struct bfd_link_info *info) ++{ ++ asection *o; ++ struct bfd_link_order *p; ++ asection *mdebug_sec; ++ struct ecoff_debug_info debug; ++ const struct ecoff_debug_swap *swap ++ = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap; ++ HDRR *symhdr = &debug.symbolic_header; ++ void * mdebug_handle = NULL; ++ struct sw64_elf_link_hash_table * htab; ++ ++ htab = sw64_elf_hash_table (info); ++ if (htab == NULL) ++ return false; ++ ++ /* Go through the sections and collect the mdebug information. */ ++ mdebug_sec = NULL; ++ for (o = abfd->sections; o != (asection *) NULL; o = o->next) ++ { ++ if (strcmp (o->name, ".mdebug") == 0) ++ { ++ struct extsym_info einfo; ++ ++ /* We have found the .mdebug section in the output file. ++ Look through all the link_orders comprising it and merge ++ the information together. */ ++ symhdr->magic = swap->sym_magic; ++ /* FIXME: What should the version stamp be? */ ++ symhdr->vstamp = 0; ++ symhdr->ilineMax = 0; ++ symhdr->cbLine = 0; ++ symhdr->idnMax = 0; ++ symhdr->ipdMax = 0; ++ symhdr->isymMax = 0; ++ symhdr->ioptMax = 0; ++ symhdr->iauxMax = 0; ++ symhdr->issMax = 0; ++ symhdr->issExtMax = 0; ++ symhdr->ifdMax = 0; ++ symhdr->crfd = 0; ++ symhdr->iextMax = 0; ++ ++ /* We accumulate the debugging information itself in the ++ debug_info structure. */ ++ debug.line = NULL; ++ debug.external_dnr = NULL; ++ debug.external_pdr = NULL; ++ debug.external_sym = NULL; ++ debug.external_opt = NULL; ++ debug.external_aux = NULL; ++ debug.ss = NULL; ++ debug.ssext = debug.ssext_end = NULL; ++ debug.external_fdr = NULL; ++ debug.external_rfd = NULL; ++ debug.external_ext = debug.external_ext_end = NULL; ++ ++ mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info); ++ if (mdebug_handle == NULL) ++ return false; ++ ++ if (1) ++ { ++ asection *s; ++ EXTR esym; ++ bfd_vma last = 0; ++ unsigned int i; ++ static const char * const name[] = ++ { ++ ".text", ".init", ".fini", ".data", ++ ".rodata", ".sdata", ".sbss", ".bss" ++ }; ++ static const int sc[] = { scText, scInit, scFini, scData, ++ scRData, scSData, scSBss, scBss }; ++ ++ esym.jmptbl = 0; ++ esym.cobol_main = 0; ++ esym.weakext = 0; ++ esym.reserved = 0; ++ esym.ifd = ifdNil; ++ esym.asym.iss = issNil; ++ esym.asym.st = stLocal; ++ esym.asym.reserved = 0; ++ esym.asym.index = indexNil; ++ for (i = 0; i < 8; i++) ++ { ++ esym.asym.sc = sc[i]; ++ s = bfd_get_section_by_name (abfd, name[i]); ++ if (s != NULL) ++ { ++ esym.asym.value = s->vma; ++ last = s->vma + s->size; ++ } ++ else ++ esym.asym.value = last; ++ ++ if (! bfd_ecoff_debug_one_external (abfd, &debug, swap, ++ name[i], &esym)) ++ return false; ++ } ++ } ++ ++ for (p = o->map_head.link_order; ++ p != (struct bfd_link_order *) NULL; ++ p = p->next) ++ { ++ asection *input_section; ++ bfd *input_bfd; ++ const struct ecoff_debug_swap *input_swap; ++ struct ecoff_debug_info input_debug; ++ char *eraw_src; ++ char *eraw_end; ++ ++ if (p->type != bfd_indirect_link_order) ++ { ++ if (p->type == bfd_data_link_order) ++ continue; ++ abort (); ++ } ++ ++ input_section = p->u.indirect.section; ++ input_bfd = input_section->owner; ++ ++ if (! is_sw64_elf (input_bfd)) ++ /* I don't know what a non SW64 ELF bfd would be ++ doing with a .mdebug section, but I don't really ++ want to deal with it. */ ++ continue; ++ ++ input_swap = (get_elf_backend_data (input_bfd) ++ ->elf_backend_ecoff_debug_swap); ++ ++ BFD_ASSERT (p->size == input_section->size); ++ ++ /* The ECOFF linking code expects that we have already ++ read in the debugging information and set up an ++ ecoff_debug_info structure, so we do that now. */ ++ if (!elf64_sw64_read_ecoff_info (input_bfd, input_section, ++ &input_debug)) ++ return false; ++ ++ if (! (bfd_ecoff_debug_accumulate ++ (mdebug_handle, abfd, &debug, swap, input_bfd, ++ &input_debug, input_swap, info))) ++ return false; ++ ++ /* Loop through the external symbols. For each one with ++ interesting information, try to find the symbol in ++ the linker global hash table and save the information ++ for the output external symbols. */ ++ eraw_src = (char *) input_debug.external_ext; ++ eraw_end = (eraw_src ++ + (input_debug.symbolic_header.iextMax ++ * input_swap->external_ext_size)); ++ for (; ++ eraw_src < eraw_end; ++ eraw_src += input_swap->external_ext_size) ++ { ++ EXTR ext; ++ const char *name; ++ struct sw64_elf_link_hash_entry *h; ++ ++ (*input_swap->swap_ext_in) (input_bfd, eraw_src, &ext); ++ if (ext.asym.sc == scNil ++ || ext.asym.sc == scUndefined ++ || ext.asym.sc == scSUndefined) ++ continue; ++ ++ name = input_debug.ssext + ext.asym.iss; ++ h = sw64_elf_link_hash_lookup (htab, name, false, false, true); ++ if (h == NULL || h->esym.ifd != -2) ++ continue; ++ ++ if (ext.ifd != -1) ++ { ++ BFD_ASSERT (ext.ifd ++ < input_debug.symbolic_header.ifdMax); ++ ext.ifd = input_debug.ifdmap[ext.ifd]; ++ } ++ ++ h->esym = ext; ++ } ++ ++ /* Free up the information we just read. */ ++ free (input_debug.line); ++ free (input_debug.external_dnr); ++ free (input_debug.external_pdr); ++ free (input_debug.external_sym); ++ free (input_debug.external_opt); ++ free (input_debug.external_aux); ++ free (input_debug.ss); ++ free (input_debug.ssext); ++ free (input_debug.external_fdr); ++ free (input_debug.external_rfd); ++ free (input_debug.external_ext); ++ ++ /* Hack: reset the SEC_HAS_CONTENTS flag so that ++ elf_link_input_bfd ignores this section. */ ++ input_section->flags &=~ SEC_HAS_CONTENTS; ++ } ++ ++ /* Build the external symbol information. */ ++ einfo.abfd = abfd; ++ einfo.info = info; ++ einfo.debug = &debug; ++ einfo.swap = swap; ++ einfo.failed = false; ++ elf_link_hash_traverse (elf_hash_table (info), ++ elf64_sw64_output_extsym, ++ &einfo); ++ if (einfo.failed) ++ return false; ++ ++ /* Set the size of the .mdebug section. */ ++ o->size = bfd_ecoff_debug_size (abfd, &debug, swap); ++ ++ /* Skip this section later on (I don't think this currently ++ matters, but someday it might). */ ++ o->map_head.link_order = (struct bfd_link_order *) NULL; ++ ++ mdebug_sec = o; ++ } ++ } ++ ++ /* Invoke the regular ELF backend linker to do all the work. */ ++ if (! bfd_elf_final_link (abfd, info)) ++ return false; ++ ++ /* Now write out the computed sections. */ ++ ++ /* The .got subsections... */ ++ { ++ bfd *i, *dynobj = elf_hash_table(info)->dynobj; ++ for (i = htab->got_list; ++ i != NULL; ++ i = sw64_elf_tdata(i)->got_link_next) ++ { ++ asection *sgot; ++ ++ /* elf_bfd_final_link already did everything in dynobj. */ ++ if (i == dynobj) ++ continue; ++ ++ sgot = sw64_elf_tdata(i)->got; ++ if (! bfd_set_section_contents (abfd, sgot->output_section, ++ sgot->contents, ++ (file_ptr) sgot->output_offset, ++ sgot->size)) ++ return false; ++ } ++ } ++ ++ if (mdebug_sec != (asection *) NULL) ++ { ++ BFD_ASSERT (abfd->output_has_begun); ++ if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug, ++ swap, info, ++ mdebug_sec->filepos)) ++ return false; ++ ++ bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info); ++ } ++ ++ return true; ++} ++ ++static enum elf_reloc_type_class ++elf64_sw64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED, ++ const asection *rel_sec ATTRIBUTE_UNUSED, ++ const Elf_Internal_Rela *rela) ++{ ++ switch ((int) ELF64_R_TYPE (rela->r_info)) ++ { ++ case R_SW64_RELATIVE: ++ return reloc_class_relative; ++ case R_SW64_JMP_SLOT: ++ return reloc_class_plt; ++ case R_SW64_COPY: ++ return reloc_class_copy; ++ default: ++ return reloc_class_normal; ++ } ++} ++ ++static const struct bfd_elf_special_section elf64_sw64_special_sections[] = ++{ ++ { STRING_COMMA_LEN (".sbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_SW64_GPREL }, ++ { STRING_COMMA_LEN (".sdata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_SW64_GPREL }, ++ { NULL, 0, 0, 0, 0 } ++}; ++ ++/* ECOFF swapping routines. These are used when dealing with the ++ .mdebug section, which is in the ECOFF debugging format. Copied ++ from elf32-mips.c. */ ++static const struct ecoff_debug_swap ++elf64_sw64_ecoff_debug_swap = ++{ ++ /* Symbol table magic number. */ ++ magicSym2, ++ /* Alignment of debugging information. E.g., 4. */ ++ 8, ++ /* Sizes of external symbolic information. */ ++ sizeof (struct hdr_ext), ++ sizeof (struct dnr_ext), ++ sizeof (struct pdr_ext), ++ sizeof (struct sym_ext), ++ sizeof (struct opt_ext), ++ sizeof (struct fdr_ext), ++ sizeof (struct rfd_ext), ++ sizeof (struct ext_ext), ++ /* Functions to swap in external symbolic data. */ ++ ecoff_swap_hdr_in, ++ ecoff_swap_dnr_in, ++ ecoff_swap_pdr_in, ++ ecoff_swap_sym_in, ++ ecoff_swap_opt_in, ++ ecoff_swap_fdr_in, ++ ecoff_swap_rfd_in, ++ ecoff_swap_ext_in, ++ _bfd_ecoff_swap_tir_in, ++ _bfd_ecoff_swap_rndx_in, ++ /* Functions to swap out external symbolic data. */ ++ ecoff_swap_hdr_out, ++ ecoff_swap_dnr_out, ++ ecoff_swap_pdr_out, ++ ecoff_swap_sym_out, ++ ecoff_swap_opt_out, ++ ecoff_swap_fdr_out, ++ ecoff_swap_rfd_out, ++ ecoff_swap_ext_out, ++ _bfd_ecoff_swap_tir_out, ++ _bfd_ecoff_swap_rndx_out, ++ /* Function to read in symbolic data. */ ++ elf64_sw64_read_ecoff_info ++}; ++ ++/* Use a non-standard hash bucket size of 8. */ ++ ++static const struct elf_size_info sw64_elf_size_info = ++{ ++ sizeof (Elf64_External_Ehdr), ++ sizeof (Elf64_External_Phdr), ++ sizeof (Elf64_External_Shdr), ++ sizeof (Elf64_External_Rel), ++ sizeof (Elf64_External_Rela), ++ sizeof (Elf64_External_Sym), ++ sizeof (Elf64_External_Dyn), ++ sizeof (Elf_External_Note), ++ 8, ++ 1, ++ 64, 3, ++ ELFCLASS64, EV_CURRENT, ++ bfd_elf64_write_out_phdrs, ++ bfd_elf64_write_shdrs_and_ehdr, ++ bfd_elf64_checksum_contents, ++ bfd_elf64_write_relocs, ++ bfd_elf64_swap_symbol_in, ++ bfd_elf64_swap_symbol_out, ++ bfd_elf64_slurp_reloc_table, ++ bfd_elf64_slurp_symbol_table, ++ bfd_elf64_swap_dyn_in, ++ bfd_elf64_swap_dyn_out, ++ bfd_elf64_swap_reloc_in, ++ bfd_elf64_swap_reloc_out, ++ bfd_elf64_swap_reloca_in, ++ bfd_elf64_swap_reloca_out ++}; ++ ++#define TARGET_LITTLE_SYM sw64_elf64_vec ++#define TARGET_LITTLE_NAME "elf64-sw64" ++#define ELF_ARCH bfd_arch_sw64 ++#define ELF_TARGET_ID SW64_ELF_DATA ++#define ELF_MACHINE_CODE EM_SW64 ++#define ELF_MAXPAGESIZE 0x10000 ++#define ELF_COMMONPAGESIZE 0x2000 ++ ++#define bfd_elf64_bfd_link_hash_table_create \ ++ elf64_sw64_bfd_link_hash_table_create ++ ++#define bfd_elf64_bfd_reloc_type_lookup \ ++ elf64_sw64_bfd_reloc_type_lookup ++#define bfd_elf64_bfd_reloc_name_lookup \ ++ elf64_sw64_bfd_reloc_name_lookup ++#define elf_info_to_howto \ ++ elf64_sw64_info_to_howto ++ ++#define bfd_elf64_mkobject \ ++ elf64_sw64_mkobject ++#define elf_backend_object_p \ ++ elf64_sw64_object_p ++ ++#define elf_backend_section_from_shdr \ ++ elf64_sw64_section_from_shdr ++#define elf_backend_section_flags \ ++ elf64_sw64_section_flags ++#define elf_backend_fake_sections \ ++ elf64_sw64_fake_sections ++ ++#define bfd_elf64_bfd_is_local_label_name \ ++ elf64_sw64_is_local_label_name ++#define bfd_elf64_find_nearest_line \ ++ elf64_sw64_find_nearest_line ++#define bfd_elf64_bfd_relax_section \ ++ elf64_sw64_relax_section ++ ++#define elf_backend_add_symbol_hook \ ++ elf64_sw64_add_symbol_hook ++#define elf_backend_relocs_compatible \ ++ _bfd_elf_relocs_compatible ++#define elf_backend_sort_relocs_p \ ++ elf64_sw64_sort_relocs_p ++#define elf_backend_check_relocs \ ++ elf64_sw64_check_relocs ++#define elf_backend_create_dynamic_sections \ ++ elf64_sw64_create_dynamic_sections ++#define elf_backend_adjust_dynamic_symbol \ ++ elf64_sw64_adjust_dynamic_symbol ++#define elf_backend_merge_symbol_attribute \ ++ elf64_sw64_merge_symbol_attribute ++#define elf_backend_copy_indirect_symbol \ ++ elf64_sw64_copy_indirect_symbol ++#define elf_backend_always_size_sections \ ++ elf64_sw64_always_size_sections ++#define elf_backend_size_dynamic_sections \ ++ elf64_sw64_size_dynamic_sections ++#define elf_backend_omit_section_dynsym \ ++ _bfd_elf_omit_section_dynsym_all ++#define elf_backend_relocate_section \ ++ elf64_sw64_relocate_section ++#define elf_backend_finish_dynamic_symbol \ ++ elf64_sw64_finish_dynamic_symbol ++#define elf_backend_finish_dynamic_sections \ ++ elf64_sw64_finish_dynamic_sections ++#define bfd_elf64_bfd_final_link \ ++ elf64_sw64_final_link ++#define elf_backend_reloc_type_class \ ++ elf64_sw64_reloc_type_class ++ ++#define elf_backend_can_gc_sections 1 ++#define elf_backend_gc_mark_hook elf64_sw64_gc_mark_hook ++ ++#define elf_backend_ecoff_debug_swap \ ++ &elf64_sw64_ecoff_debug_swap ++ ++#define elf_backend_size_info \ ++ sw64_elf_size_info ++ ++#define elf_backend_special_sections \ ++ elf64_sw64_special_sections ++ ++#define elf_backend_strip_zero_sized_dynamic_sections \ ++ _bfd_elf_strip_zero_sized_dynamic_sections ++ ++/* A few constants that determine how the .plt section is set up. */ ++#define elf_backend_want_got_plt 0 ++#define elf_backend_plt_readonly 0 ++#define elf_backend_want_plt_sym 1 ++#define elf_backend_got_header_size 0 ++#define elf_backend_dtrel_excludes_plt 1 ++ ++#include "elf64-target.h" ++ ++/* FreeBSD support. */ ++ ++#undef TARGET_LITTLE_SYM ++#define TARGET_LITTLE_SYM sw64_elf64_fbsd_vec ++#undef TARGET_LITTLE_NAME ++#define TARGET_LITTLE_NAME "elf64-sw64-freebsd" ++#undef ELF_OSABI ++#define ELF_OSABI ELFOSABI_FREEBSD ++ ++/* The kernel recognizes executables as valid only if they carry a ++ "FreeBSD" label in the ELF header. So we put this label on all ++ executables and (for simplicity) also all other object files. */ ++ ++static bool ++elf64_sw64_fbsd_init_file_header (bfd *abfd, struct bfd_link_info *info) ++{ ++ Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form. */ ++ ++ if (!_bfd_elf_init_file_header (abfd, info)) ++ return false; ++ ++ i_ehdrp = elf_elfheader (abfd); ++ ++ /* Put an ABI label supported by FreeBSD >= 4.1. */ ++ i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi; ++#ifdef OLD_FREEBSD_ABI_LABEL ++ /* The ABI label supported by FreeBSD <= 4.0 is quite nonstandard. */ ++ memcpy (&i_ehdrp->e_ident[EI_ABIVERSION], "FreeBSD", 8); ++#endif ++ return true; ++} ++ ++#undef elf_backend_init_file_header ++#define elf_backend_init_file_header \ ++ elf64_sw64_fbsd_init_file_header ++ ++#undef elf64_bed ++#define elf64_bed elf64_sw64_fbsd_bed ++ ++#include "elf64-target.h" +diff -Naur gdb-14.1-after-patch/bfd/elf-bfd.h gdb-14.1-sw64/bfd/elf-bfd.h +--- gdb-14.1-after-patch/bfd/elf-bfd.h 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/bfd/elf-bfd.h 2025-03-03 10:59:12.970000000 +0800 +@@ -533,6 +533,7 @@ + { + AARCH64_ELF_DATA = 1, + ALPHA_ELF_DATA, ++ SW64_ELF_DATA, + AMDGCN_ELF_DATA, + ARC_ELF_DATA, + ARM_ELF_DATA, +diff -Naur gdb-14.1-after-patch/bfd/libbfd.h gdb-14.1-sw64/bfd/libbfd.h +--- gdb-14.1-after-patch/bfd/libbfd.h 2025-03-03 09:43:44.100000000 +0800 ++++ gdb-14.1-sw64/bfd/libbfd.h 2025-03-03 10:59:13.020000000 +0800 +@@ -1237,6 +1237,35 @@ + "BFD_RELOC_ALPHA_TPREL_HI16", + "BFD_RELOC_ALPHA_TPREL_LO16", + "BFD_RELOC_ALPHA_TPREL16", ++ "BFD_RELOC_SW64_GPDISP_HI16", ++ "BFD_RELOC_SW64_GPDISP_LO16", ++ "BFD_RELOC_SW64_GPDISP", ++ "BFD_RELOC_SW64_LITERAL", ++ "BFD_RELOC_SW64_ELF_LITERAL", ++ "BFD_RELOC_SW64_LITUSE", ++ "BFD_RELOC_SW64_HINT", ++ "BFD_RELOC_SW64_LINKAGE", ++ "BFD_RELOC_SW64_CODEADDR", ++ "BFD_RELOC_SW64_GPREL_HI16", ++ "BFD_RELOC_SW64_GPREL_LO16", ++ "BFD_RELOC_SW64_BRSGP", ++ "BFD_RELOC_SW64_NOP", ++ "BFD_RELOC_SW64_BSR", ++ "BFD_RELOC_SW64_LDA", ++ "BFD_RELOC_SW64_BOH", ++ "BFD_RELOC_SW64_TLSGD", ++ "BFD_RELOC_SW64_TLSLDM", ++ "BFD_RELOC_SW64_DTPMOD64", ++ "BFD_RELOC_SW64_GOTDTPREL16", ++ "BFD_RELOC_SW64_DTPREL64", ++ "BFD_RELOC_SW64_DTPREL_HI16", ++ "BFD_RELOC_SW64_DTPREL_LO16", ++ "BFD_RELOC_SW64_DTPREL16", ++ "BFD_RELOC_SW64_GOTTPREL16", ++ "BFD_RELOC_SW64_TPREL64", ++ "BFD_RELOC_SW64_TPREL_HI16", ++ "BFD_RELOC_SW64_TPREL_LO16", ++ "BFD_RELOC_SW64_TPREL16", + "BFD_RELOC_MIPS_JMP", + "BFD_RELOC_MICROMIPS_JMP", + "BFD_RELOC_MIPS16_JMP", +diff -Naur gdb-14.1-after-patch/bfd/Makefile.am gdb-14.1-sw64/bfd/Makefile.am +--- gdb-14.1-after-patch/bfd/Makefile.am 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/bfd/Makefile.am 2025-03-03 10:59:12.950000000 +0800 +@@ -96,6 +96,7 @@ + # with the decls and initializer in archures.c. + ALL_MACHINES = \ + cpu-aarch64.lo \ ++ cpu-sw64.lo \ + cpu-alpha.lo \ + cpu-amdgcn.lo \ + cpu-arc.lo \ +@@ -180,6 +181,7 @@ + + ALL_MACHINES_CFILES = \ + cpu-aarch64.c \ ++ cpu-sw64.c \ + cpu-alpha.c \ + cpu-amdgcn.c \ + cpu-arc.c \ +@@ -552,6 +554,7 @@ + elf32-riscv.lo \ + elf32-score.lo \ + elf32-score7.lo \ ++ elf64-sw64.lo \ + elf64-aarch64.lo \ + elf64-alpha.lo \ + elf64-amdgcn.lo \ +@@ -686,7 +689,7 @@ + $(OPTIONAL_BACKENDS_CFILES) + + BUILD_CFILES = \ +- elf32-aarch64.c elf64-aarch64.c \ ++ elf32-aarch64.c elf64-aarch64.c elf64-sw64.c \ + elf32-kvx.c elf64-kvx.c \ + elf32-ia64.c elf64-ia64.c \ + elf32-loongarch.c elf64-loongarch.c \ +@@ -700,7 +703,7 @@ + SOURCE_HFILES = \ + aout-target.h aoutx.h arc-got.h arc-plt.h \ + coff-arm.h coff-bfd.h coffcode.h coffswap.h \ +- cpu-aarch64.h cpu-arm.h cpu-h8300.h cpu-m68k.h cpu-riscv.h \ ++ cpu-aarch64.h cpu-arm.h cpu-h8300.h cpu-m68k.h cpu-riscv.h cpu-sw64.h \ + ecoff-bfd.h ecoffswap.h \ + elf32-arm.h elf32-avr.h elf32-bfin.h elf32-cr16.h elf32-csky.h \ + elf32-dlx.h elf32-hppa.h elf32-m68hc1x.h elf32-m68k.h \ +diff -Naur gdb-14.1-after-patch/bfd/Makefile.in gdb-14.1-sw64/bfd/Makefile.in +--- gdb-14.1-after-patch/bfd/Makefile.in 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/bfd/Makefile.in 2025-03-03 10:59:12.950000000 +0800 +@@ -551,6 +551,7 @@ + # with the decls and initializer in archures.c. + ALL_MACHINES = \ + cpu-aarch64.lo \ ++ cpu-sw64.lo \ + cpu-alpha.lo \ + cpu-amdgcn.lo \ + cpu-arc.lo \ +@@ -635,6 +636,7 @@ + + ALL_MACHINES_CFILES = \ + cpu-aarch64.c \ ++ cpu-sw64.c \ + cpu-alpha.c \ + cpu-amdgcn.c \ + cpu-arc.c \ +@@ -998,6 +1000,7 @@ + BFD64_BACKENDS = \ + aix5ppc-core.lo \ + aout64.lo \ ++ coff-sw64.lo \ + coff-alpha.lo \ + coff-x86_64.lo \ + coff64-rs6000.lo \ +@@ -1010,6 +1013,7 @@ + elf32-score.lo \ + elf32-score7.lo \ + elf64-aarch64.lo \ ++ elf64-sw64.lo \ + elf64-alpha.lo \ + elf64-amdgcn.lo \ + elf64-bpf.lo \ +@@ -1055,6 +1059,7 @@ + BFD64_BACKENDS_CFILES = \ + aix5ppc-core.c \ + aout64.c \ ++ coff-sw64.c \ + coff-alpha.c \ + coff-x86_64.c \ + coff64-rs6000.c \ +@@ -1142,7 +1147,7 @@ + $(OPTIONAL_BACKENDS_CFILES) + + BUILD_CFILES = \ +- elf32-aarch64.c elf64-aarch64.c \ ++ elf32-aarch64.c elf64-aarch64.c elf64-sw64.c \ + elf32-kvx.c elf64-kvx.c \ + elf32-ia64.c elf64-ia64.c \ + elf32-loongarch.c elf64-loongarch.c \ +@@ -1153,7 +1158,7 @@ + SOURCE_HFILES = \ + aout-target.h aoutx.h arc-got.h arc-plt.h \ + coff-arm.h coff-bfd.h coffcode.h coffswap.h \ +- cpu-aarch64.h cpu-arm.h cpu-h8300.h cpu-m68k.h cpu-riscv.h \ ++ cpu-aarch64.h cpu-arm.h cpu-h8300.h cpu-m68k.h cpu-riscv.h cpu-sw64.h\ + ecoff-bfd.h ecoffswap.h \ + elf32-arm.h elf32-avr.h elf32-bfin.h elf32-cr16.h elf32-csky.h \ + elf32-dlx.h elf32-hppa.h elf32-m68hc1x.h elf32-m68k.h \ +@@ -1445,6 +1450,7 @@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cf-i386lynx.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cisco-core.Plo@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-sw64.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-alpha.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-bfd.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-go32.Plo@am__quote@ +@@ -1465,6 +1471,7 @@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/corefile.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-aarch64.Plo@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-sw64.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-alpha.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-amdgcn.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-arc.Plo@am__quote@ +@@ -1631,6 +1638,7 @@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-z80.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-aarch64.Plo@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-sw64.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-alpha.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-amdgcn.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-bpf.Plo@am__quote@ +diff -Naur gdb-14.1-after-patch/bfd/targets.c gdb-14.1-sw64/bfd/targets.c +--- gdb-14.1-after-patch/bfd/targets.c 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/bfd/targets.c 2025-03-03 10:59:13.020000000 +0800 +@@ -685,6 +685,8 @@ + extern const bfd_target aarch64_mach_o_vec; + extern const bfd_target aarch64_pei_le_vec; + extern const bfd_target aarch64_pe_le_vec; ++extern const bfd_target sw64_ecoff_le_vec; ++extern const bfd_target sw64_elf64_vec; + extern const bfd_target alpha_ecoff_le_vec; + extern const bfd_target alpha_elf64_vec; + extern const bfd_target alpha_elf64_fbsd_vec; +@@ -1006,6 +1008,8 @@ + #endif + + #ifdef BFD64 ++ &sw64_ecoff_le_vec, ++ &sw64_elf64_vec, + &alpha_ecoff_le_vec, + &alpha_elf64_vec, + &alpha_elf64_fbsd_vec, +diff -Naur gdb-14.1-after-patch/config.guess gdb-14.1-sw64/config.guess +--- gdb-14.1-after-patch/config.guess 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/config.guess 2025-03-03 10:59:13.020000000 +0800 +@@ -1158,6 +1158,9 @@ + sparc:Linux:*:* | sparc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; ++ sw_64:Linux:*:*) ++ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ++ ;; + tile*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; +diff -Naur gdb-14.1-after-patch/config.sub gdb-14.1-sw64/config.sub +--- gdb-14.1-after-patch/config.sub 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/config.sub 2025-03-03 10:59:13.020000000 +0800 +@@ -1130,6 +1130,9 @@ + arm64-* | aarch64le-*) + cpu=aarch64 + ;; ++ sw_64-*) ++ cpu=sw64 ++ ;; + + # Recognize the canonical CPU Types that limit and/or modify the + # company names they are paired with. +@@ -1269,6 +1272,7 @@ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ ++ | sw64 \ + | tahoe \ + | thumbv7* \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ +diff -Naur gdb-14.1-after-patch/configure.ac gdb-14.1-sw64/configure.ac +--- gdb-14.1-after-patch/configure.ac 2023-12-03 13:25:53.000000000 +0800 ++++ gdb-14.1-sw64/configure.ac 2025-03-03 10:59:13.030000000 +0800 +@@ -363,7 +363,7 @@ + # Check for target supported by gold. + case "${target}" in + i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-* \ +- | aarch64*-*-* | tilegx*-*-* | mips*-*-* | s390*-*-* | loongarch*-*-*) ++ | aarch64*-*-* | tilegx*-*-* | mips*-*-* | s390*-*-* | loongarch*-*-* | sw64*-*-*) + configdirs="$configdirs gold" + if test x${ENABLE_GOLD} = xdefault; then + default_ld=gold +@@ -927,6 +927,9 @@ + sparc*-*-*) + libgloss_dir=sparc + ;; ++ sw64*-*-*) ++ libgloss_dir=sw64 ++ ;; + esac + + # Disable newlib and libgloss for various target OSes. +@@ -1301,6 +1304,8 @@ + loongarch*-*-*) + noconfigdirs="$noconfigdirs gprof" + ;; ++ sw64*-*-linux*) ++ ;; + esac + + # If we aren't building newlib, then don't build libgloss, since libgloss +diff -Naur gdb-14.1-after-patch/gdb/arch/sw64.c gdb-14.1-sw64/gdb/arch/sw64.c +--- gdb-14.1-after-patch/gdb/arch/sw64.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/arch/sw64.c 2025-03-03 10:59:13.070000000 +0800 +@@ -0,0 +1,104 @@ ++/* Copyright (C) 2022-2023 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include "gdbsupport/common-defs.h" ++#include "sw64.h" ++#include ++#include ++ ++/* Target description features. */ ++ ++#include "../features/sw64/cpu.c" ++#include "../features/sw64/fpu.c" ++ ++#ifndef GDBSERVER ++#define STATIC_IN_GDB static ++#else ++#define STATIC_IN_GDB ++#endif ++ ++STATIC_IN_GDB target_desc_up ++sw64_create_target_description (const struct sw64_gdbarch_features features) ++{ ++ /* Now we should create a new target description. */ ++ target_desc_up tdesc = allocate_target_description (); ++ ++ std::string arch_name = "sw64"; ++ ++ if (features.xlen == 4) ++ arch_name.append ("32"); ++ else if (features.xlen == 8) ++ arch_name.append ("64"); ++ ++ if (features.fputype == SINGLE_FLOAT) ++ arch_name.append ("f"); ++ else if (features.fputype == DOUBLE_FLOAT) ++ arch_name.append ("d"); ++ ++ set_tdesc_architecture (tdesc.get (), arch_name.c_str ()); ++ ++ long regnum = 0; ++ ++ /* For now we only support creating 32-bit or 64-bit x-registers. */ ++ if (features.xlen == 8) ++ regnum = create_feature_sw64_base64 (tdesc.get (), regnum); ++ ++ /* For now we only support creating single float and double float. */ ++ regnum = create_feature_sw64_fpu (tdesc.get (), regnum); ++ ++ return tdesc; ++} ++ ++#ifndef GDBSERVER ++ ++/* Wrapper used by std::unordered_map to generate hash for feature set. */ ++struct sw64_gdbarch_features_hasher ++{ ++ std::size_t ++ operator() (const sw64_gdbarch_features &features) const noexcept ++ { ++ return features.hash (); ++ } ++}; ++ ++/* Cache of previously seen target descriptions, indexed by the feature set ++ that created them. */ ++static std::unordered_map sw64_tdesc_cache; ++ ++const target_desc * ++sw64_lookup_target_description (const struct sw64_gdbarch_features features) ++{ ++ /* Lookup in the cache. If we find it then return the pointer out of ++ the target_desc_up (which is a unique_ptr). This is safe as the ++ sw64_tdesc_cache will exist until GDB exits. */ ++ const auto it = sw64_tdesc_cache.find (features); ++ if (it != sw64_tdesc_cache.end ()) ++ return it->second.get (); ++ ++ target_desc_up tdesc (sw64_create_target_description (features)); ++ ++ /* Add to the cache, and return a pointer borrowed from the ++ target_desc_up. This is safe as the cache (and the pointers ++ contained within it) are not deleted until GDB exits. */ ++ target_desc *ptr = tdesc.get (); ++ sw64_tdesc_cache.emplace (features, std::move (tdesc)); ++ return ptr; ++} ++ ++#endif /* !GDBSERVER */ +diff -Naur gdb-14.1-after-patch/gdb/arch/sw64.h gdb-14.1-sw64/gdb/arch/sw64.h +--- gdb-14.1-after-patch/gdb/arch/sw64.h 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/arch/sw64.h 2025-03-03 10:59:13.070000000 +0800 +@@ -0,0 +1,118 @@ ++/* Common target-dependent functionality for LoongArch ++ ++ Copyright (C) 2022-2023 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#ifndef ARCH_LOONGARCH_H ++#define ARCH_LOONGARCH_H ++ ++#include "gdbsupport/tdesc.h" ++ ++/* Register numbers of various important registers. */ ++enum sw64_regnum ++{ ++ LOONGARCH_RA_REGNUM = 1, /* Return Address. */ ++ LOONGARCH_SP_REGNUM = 3, /* Stack Pointer. */ ++ LOONGARCH_A0_REGNUM = 4, /* First Argument/Return Value. */ ++ LOONGARCH_A7_REGNUM = 11, /* Seventh Argument/Syscall Number. */ ++ LOONGARCH_FP_REGNUM = 22, /* Frame Pointer. */ ++ LOONGARCH_ORIG_A0_REGNUM = 32, /* Syscall's original arg0. */ ++ LOONGARCH_PC_REGNUM = 33, /* Program Counter. */ ++ LOONGARCH_BADV_REGNUM = 34, /* Bad Vaddr for Addressing Exception. */ ++ LOONGARCH_LINUX_NUM_GREGSET = 45, /* 32 GPR, ORIG_A0, PC, BADV, RESERVED 10. */ ++ LOONGARCH_ARG_REGNUM = 8, /* r4-r11: general-purpose argument registers. ++ f0-f7: floating-point argument registers. */ ++ LOONGARCH_FIRST_FP_REGNUM = LOONGARCH_LINUX_NUM_GREGSET, ++ LOONGARCH_LINUX_NUM_FPREGSET = 32, ++ LOONGARCH_FIRST_FCC_REGNUM = LOONGARCH_FIRST_FP_REGNUM + LOONGARCH_LINUX_NUM_FPREGSET, ++ LOONGARCH_LINUX_NUM_FCC = 8, ++ LOONGARCH_FCSR_REGNUM = LOONGARCH_FIRST_FCC_REGNUM + LOONGARCH_LINUX_NUM_FCC, ++}; ++ ++enum sw64_fputype ++{ ++ SINGLE_FLOAT = 1, ++ DOUBLE_FLOAT = 2, ++}; ++ ++/* The set of LoongArch architectural features that we track that impact how ++ we configure the actual gdbarch instance. We hold one of these in the ++ gdbarch_tdep structure, and use it to distinguish between different ++ LoongArch gdbarch instances. ++ ++ The information in here ideally comes from the target description, ++ however, if the target doesn't provide a target description then we will ++ create a default target description by first populating one of these ++ based on what we know about the binary being executed, and using that to ++ drive default target description creation. */ ++ ++struct sw64_gdbarch_features ++{ ++ /* The size of the x-registers in bytes. This is either 4 (sw6432) ++ or 8 (sw6464). No other value is valid. Initialise to the invalid ++ 0 value so we can spot if one of these is used uninitialised. */ ++ int xlen = 0; ++ ++ /* The type of floating-point. This is either 1 (single float) or 2 ++ (double float). No other value is valid. Initialise to the invalid ++ 0 value so we can spot if one of these is used uninitialised. */ ++ int fputype = 0; ++ ++ /* Equality operator. */ ++ bool operator== (const struct sw64_gdbarch_features &rhs) const ++ { ++ return (xlen == rhs.xlen); ++ } ++ ++ /* Inequality operator. */ ++ bool operator!= (const struct sw64_gdbarch_features &rhs) const ++ { ++ return !((*this) == rhs); ++ } ++ ++ /* Used by std::unordered_map to hash feature sets. */ ++ std::size_t hash () const noexcept ++ { ++ std::size_t val = (xlen & 0x1f) << 5; ++ return val; ++ } ++}; ++ ++#ifdef GDBSERVER ++ ++/* Create and return a target description that is compatible with FEATURES. ++ This is only used directly from the gdbserver where the created target ++ description is modified after it is return. */ ++ ++target_desc_up sw64_create_target_description ++ (const struct sw64_gdbarch_features features); ++ ++#else ++ ++/* Lookup an already existing target description matching FEATURES, or ++ create a new target description if this is the first time we have seen ++ FEATURES. For the same FEATURES the same target_desc is always ++ returned. This is important when trying to lookup gdbarch objects as ++ GDBARCH_LIST_LOOKUP_BY_INFO performs a pointer comparison on target ++ descriptions to find candidate gdbarch objects. */ ++ ++const target_desc *sw64_lookup_target_description ++ (const struct sw64_gdbarch_features features); ++ ++#endif /* GDBSERVER */ ++ ++#endif /* ARCH_LOONGARCH_H */ +diff -Naur gdb-14.1-after-patch/gdb/configure.host gdb-14.1-sw64/gdb/configure.host +--- gdb-14.1-after-patch/gdb/configure.host 2023-02-02 12:45:52.000000000 +0800 ++++ gdb-14.1-sw64/gdb/configure.host 2025-03-03 10:59:13.080000000 +0800 +@@ -65,6 +65,7 @@ + sparcv9 | sparc64) gdb_host_cpu=sparc ;; + s390*) gdb_host_cpu=s390 ;; + sh*) gdb_host_cpu=sh ;; ++sw64*) gdb_host_cpu=sw64 ;; + tilegx*) gdb_host_cpu=tilegx ;; + x86_64*) gdb_host_cpu=i386 ;; + m32r*) gdb_host_cpu=m32r ;; +@@ -168,6 +169,8 @@ + gdb_host=sol2 + ;; + ++sw64*-linux*) gdb_host=linux ;; ++ + tilegx-*-linux*) gdb_host=linux ;; + + vax-*-netbsd* | vax-*-knetbsd*-gnu) +diff -Naur gdb-14.1-after-patch/gdb/configure.nat gdb-14.1-sw64/gdb/configure.nat +--- gdb-14.1-after-patch/gdb/configure.nat 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/gdb/configure.nat 2025-03-03 10:59:13.080000000 +0800 +@@ -304,6 +304,11 @@ + # Host: GNU/Linux SPARC + NATDEPFILES="${NATDEPFILES} sparc-nat.o sparc-linux-nat.o" + ;; ++ sw64) ++ # Host: SW64, running GNU/Linux. ++ NATDEPFILES="${NATDEPFILES} sw64-linux-nat.o linux-nat-trad.o \ ++ nat/sw64-linux-watch.o" ++ ;; + tilegx) + # Host: Tilera TILE-Gx running GNU/Linux. + NATDEPFILES="${NATDEPFILES} tilegx-linux-nat.o" +diff -Naur gdb-14.1-after-patch/gdb/configure.tgt gdb-14.1-sw64/gdb/configure.tgt +--- gdb-14.1-after-patch/gdb/configure.tgt 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/gdb/configure.tgt 2025-03-03 10:59:13.080000000 +0800 +@@ -108,6 +108,11 @@ + cpu_obs="riscv-tdep.o riscv-none-tdep.o arch/riscv.o \ + ravenscar-thread.o riscv-ravenscar-thread.o";; + ++sw64*-*-*) ++ # Target: SW64 ++ cpu_obs="sw64-tdep.o arch/sw64.o" ++ ;; ++ + x86_64-*-*) + cpu_obs="${i386_tobjs} ${amd64_tobjs}";; + +@@ -539,6 +544,12 @@ + linux-tdep.o linux-record.o symfile-mem.o" + ;; + ++sw64*-*-linux*) ++ # Target: SW64 running Linux ++ gdb_target_obs="sw64-linux-tdep.o glibc-tdep.o \ ++ linux-tdep.o solib-svr4.o linux-record.o" ++ ;; ++ + riscv*-*-freebsd*) + # Target: FreeBSD/riscv + gdb_target_obs="riscv-fbsd-tdep.o" +diff -Naur gdb-14.1-after-patch/gdb/data-directory/Makefile.in gdb-14.1-sw64/gdb/data-directory/Makefile.in +--- gdb-14.1-after-patch/gdb/data-directory/Makefile.in 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/gdb/data-directory/Makefile.in 2025-03-03 10:59:13.090000000 +0800 +@@ -58,6 +58,7 @@ + mips-o32-linux.xml \ + ppc-linux.xml \ + ppc64-linux.xml \ ++ sw64-linux.xml \ + s390-linux.xml \ + s390x-linux.xml \ + sparc-linux.xml \ +diff -Naur gdb-14.1-after-patch/gdb/features/sw64/cpu.c gdb-14.1-sw64/gdb/features/sw64/cpu.c +--- gdb-14.1-after-patch/gdb/features/sw64/cpu.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64/cpu.c 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,48 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: base64.xml */ ++ ++#include "gdbsupport/tdesc.h" ++ ++static int ++create_feature_sw64_base64 (struct target_desc *result, long regnum) ++{ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.sw64.base"); ++ tdesc_create_reg (feature, "r0", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r1", regnum++, 1, "general", 64, "code_ptr"); ++ tdesc_create_reg (feature, "r2", regnum++, 1, "general", 64, "data_ptr"); ++ tdesc_create_reg (feature, "r3", regnum++, 1, "general", 64, "data_ptr"); ++ tdesc_create_reg (feature, "r4", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r5", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r6", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r7", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r8", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r9", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r10", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r11", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r12", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r13", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r14", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r15", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r16", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r17", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r18", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r19", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r20", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r21", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r22", regnum++, 1, "general", 64, "data_ptr"); ++ tdesc_create_reg (feature, "r23", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r24", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r25", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r26", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r27", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r28", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r29", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r30", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "r31", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "orig_a0", regnum++, 1, "general", 64, "uint64"); ++ tdesc_create_reg (feature, "pc", regnum++, 1, "general", 64, "code_ptr"); ++ tdesc_create_reg (feature, "badv", regnum++, 1, "general", 64, "code_ptr"); ++ return regnum; ++} +diff -Naur gdb-14.1-after-patch/gdb/features/sw64/cpu.xml gdb-14.1-sw64/gdb/features/sw64/cpu.xml +--- gdb-14.1-after-patch/gdb/features/sw64/cpu.xml 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64/cpu.xml 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,45 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff -Naur gdb-14.1-after-patch/gdb/features/sw64/fpu.c gdb-14.1-sw64/gdb/features/sw64/fpu.c +--- gdb-14.1-after-patch/gdb/features/sw64/fpu.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64/fpu.c 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,62 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: fpu.xml */ ++ ++#include "gdbsupport/tdesc.h" ++ ++static int ++create_feature_sw64_fpu (struct target_desc *result, long regnum) ++{ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.sw64.fpu"); ++ tdesc_type_with_fields *type_with_fields; ++ type_with_fields = tdesc_create_union (feature, "fputype"); ++ tdesc_type *field_type; ++ field_type = tdesc_named_type (feature, "ieee_single"); ++ tdesc_add_field (type_with_fields, "f", field_type); ++ field_type = tdesc_named_type (feature, "ieee_double"); ++ tdesc_add_field (type_with_fields, "d", field_type); ++ ++ tdesc_create_reg (feature, "f0", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f1", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f2", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f3", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f4", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f5", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f6", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f7", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f8", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f9", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f10", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f11", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f12", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f13", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f14", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f15", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f16", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f17", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f18", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f19", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f20", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f21", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f22", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f23", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f24", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f25", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f26", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f27", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f28", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f29", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f30", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "f31", regnum++, 1, "float", 64, "fputype"); ++ tdesc_create_reg (feature, "fcc0", regnum++, 1, "float", 8, "uint8"); ++ tdesc_create_reg (feature, "fcc1", regnum++, 1, "float", 8, "uint8"); ++ tdesc_create_reg (feature, "fcc2", regnum++, 1, "float", 8, "uint8"); ++ tdesc_create_reg (feature, "fcc3", regnum++, 1, "float", 8, "uint8"); ++ tdesc_create_reg (feature, "fcc4", regnum++, 1, "float", 8, "uint8"); ++ tdesc_create_reg (feature, "fcc5", regnum++, 1, "float", 8, "uint8"); ++ tdesc_create_reg (feature, "fcc6", regnum++, 1, "float", 8, "uint8"); ++ tdesc_create_reg (feature, "fcc7", regnum++, 1, "float", 8, "uint8"); ++ tdesc_create_reg (feature, "fcsr", regnum++, 1, "float", 32, "uint32"); ++ return regnum; ++} +diff -Naur gdb-14.1-after-patch/gdb/features/sw64/fpu.xml gdb-14.1-sw64/gdb/features/sw64/fpu.xml +--- gdb-14.1-after-patch/gdb/features/sw64/fpu.xml 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64/fpu.xml 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,57 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff -Naur gdb-14.1-after-patch/gdb/features/sw64-cpu.c gdb-14.1-sw64/gdb/features/sw64-cpu.c +--- gdb-14.1-after-patch/gdb/features/sw64-cpu.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64-cpu.c 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,47 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: sw64-cpu.xml */ ++ ++#include "gdbsupport/tdesc.h" ++ ++static int ++create_feature_sw64_cpu (struct target_desc *result, long regnum) ++{ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.sw64.cpu"); ++ tdesc_create_reg (feature, "r0", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r1", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r2", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r3", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r4", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r5", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r6", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r7", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r8", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r9", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r10", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r11", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r12", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r13", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r14", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "fp", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r16", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r17", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r18", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r19", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r20", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r21", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r22", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r23", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r24", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r25", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ra", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r27", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r28", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r29", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "sp", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r31", regnum++, 1, NULL, 64, "int"); ++ regnum = 64; ++ tdesc_create_reg (feature, "pc", regnum++, 1, NULL, 64, "int"); ++ return regnum; ++} +diff -Naur gdb-14.1-after-patch/gdb/features/sw64-cpu.xml gdb-14.1-sw64/gdb/features/sw64-cpu.xml +--- gdb-14.1-after-patch/gdb/features/sw64-cpu.xml 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64-cpu.xml 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,44 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff -Naur gdb-14.1-after-patch/gdb/features/sw64-efu.c gdb-14.1-sw64/gdb/features/sw64-efu.c +--- gdb-14.1-after-patch/gdb/features/sw64-efu.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64-efu.c 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,110 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: sw64-efu.xml */ ++ ++#include "gdbsupport/tdesc.h" ++ ++static int ++create_feature_sw64_efu (struct target_desc *result, long regnum) ++{ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.sw64.efu"); ++ regnum = 67; ++ tdesc_create_reg (feature, "ef0", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef1", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef2", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef3", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef4", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef5", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef6", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef7", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef8", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef9", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef10", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef11", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef12", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef13", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef14", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef15", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef16", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef17", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef18", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef19", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef20", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef21", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef22", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef23", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef24", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef25", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef26", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef27", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef28", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef29", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef30", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef31", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef0", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef1", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef2", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef3", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef4", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef5", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef6", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef7", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef8", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef9", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef10", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef11", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef12", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef13", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef14", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef15", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef16", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef17", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef18", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef19", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef20", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef21", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef22", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef23", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef24", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef25", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef26", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef27", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef28", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef29", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef30", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef31", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef0", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef1", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef2", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef3", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef4", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef5", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef6", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef7", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef8", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef9", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef10", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef11", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef12", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef13", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef14", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef15", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef16", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef17", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef18", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef19", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef20", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef21", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef22", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef23", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef24", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef25", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef26", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef27", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef28", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef29", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef30", regnum++, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ef31", regnum++, 1, NULL, 64, "int"); ++ return regnum; ++} +diff -Naur gdb-14.1-after-patch/gdb/features/sw64-efu.xml gdb-14.1-sw64/gdb/features/sw64-efu.xml +--- gdb-14.1-after-patch/gdb/features/sw64-efu.xml 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64-efu.xml 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,106 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff -Naur gdb-14.1-after-patch/gdb/features/sw64-fpu.c gdb-14.1-sw64/gdb/features/sw64-fpu.c +--- gdb-14.1-after-patch/gdb/features/sw64-fpu.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64-fpu.c 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,46 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: sw64-fpu.xml */ ++ ++#include "gdbsupport/tdesc.h" ++ ++static int ++create_feature_sw64_fpu (struct target_desc *result, long regnum) ++{ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.sw64.fpu"); ++ regnum = 32; ++ tdesc_create_reg (feature, "f0", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f1", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f2", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f3", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f4", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f5", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f6", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f7", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f8", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f9", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f10", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f11", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f12", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f13", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f14", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f15", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f16", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f17", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f18", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f19", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f20", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f21", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f22", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f23", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f24", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f25", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f26", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f27", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f28", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f29", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f30", regnum++, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "fcsr", regnum++, 1, "float", 64, "int"); ++ return regnum; ++} +diff -Naur gdb-14.1-after-patch/gdb/features/sw64-fpu.xml gdb-14.1-sw64/gdb/features/sw64-fpu.xml +--- gdb-14.1-after-patch/gdb/features/sw64-fpu.xml 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64-fpu.xml 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,42 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff -Naur gdb-14.1-after-patch/gdb/features/sw64-linux.c gdb-14.1-sw64/gdb/features/sw64-linux.c +--- gdb-14.1-after-patch/gdb/features/sw64-linux.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64-linux.c 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,129 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: sw64-linux.xml */ ++ ++#include "defs.h" ++#include "osabi.h" ++#include "target-descriptions.h" ++ ++const struct target_desc *tdesc_sw64_linux; ++static void ++initialize_tdesc_sw64_linux (void) ++{ ++ target_desc_up result = allocate_target_description (); ++ set_tdesc_architecture (result.get (), bfd_scan_arch ("sw64")); ++ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result.get (), "org.gnu.gdb.sw64.cpu"); ++ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r3", 3, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r4", 4, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r5", 5, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r6", 6, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r7", 7, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r8", 8, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r9", 9, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r10", 10, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r11", 11, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r12", 12, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r13", 13, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r14", 14, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "fp", 15, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r16", 16, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r17", 17, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r18", 18, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r19", 19, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r20", 20, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r21", 21, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r22", 22, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r23", 23, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r24", 24, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r25", 25, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "ra", 26, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r27", 27, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r28", 28, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r29", 29, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "sp", 30, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "r31", 31, 1, NULL, 64, "int"); ++ tdesc_create_reg (feature, "pc", 64, 1, NULL, 64, "int"); ++ ++ feature = tdesc_create_feature (result.get (), "org.gnu.gdb.sw64.fpu"); ++ tdesc_create_reg (feature, "f0", 32, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f1", 33, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f2", 34, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f3", 35, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f4", 36, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f5", 37, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f6", 38, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f7", 39, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f8", 40, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f9", 41, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f10", 42, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f11", 43, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f12", 44, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f13", 45, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f14", 46, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f15", 47, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f16", 48, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f17", 49, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f18", 50, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f19", 51, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f20", 52, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f21", 53, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f22", 54, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f23", 55, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f24", 56, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f25", 57, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f26", 58, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f27", 59, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f28", 60, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f29", 61, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "f30", 62, 1, NULL, 64, "ieee_double"); ++ tdesc_create_reg (feature, "fcsr", 63, 1, "float", 64, "int"); ++ ++ feature = tdesc_create_feature (result.get (), "org.gnu.gdb.sw64.vec"); ++ tdesc_create_reg (feature, "V0", 167, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V1", 168, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V2", 169, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V3", 170, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V4", 171, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V5", 172, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V6", 173, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V7", 174, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V8", 175, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V9", 176, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V10", 177, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V11", 178, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V12", 179, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V13", 180, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V14", 181, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V15", 182, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V16", 183, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V17", 184, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V18", 185, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V19", 186, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V20", 187, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V21", 188, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V22", 189, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V23", 190, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V24", 191, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V25", 192, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V26", 193, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V27", 194, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V28", 195, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V29", 196, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V30", 197, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V31", 198, 1, NULL, 512, "int"); ++ ++ feature = tdesc_create_feature (result.get (), "org.gnu.gdb.sw64.linux"); ++ tdesc_create_reg (feature, "", 65, 1, "system", 64, "int"); ++ tdesc_create_reg (feature, "unique", 66, 1, "system", 64, "int"); ++ tdesc_create_reg (feature, "da_match", 163, 1, "system", 64, "int"); ++ tdesc_create_reg (feature, "da_mask", 164, 1, "system", 64, "int"); ++ tdesc_create_reg (feature, "dv_match", 165, 1, "system", 64, "int"); ++ tdesc_create_reg (feature, "dv_mask", 166, 1, "system", 64, "int"); ++ ++ tdesc_sw64_linux = result.release (); ++} +diff -Naur gdb-14.1-after-patch/gdb/features/sw64-linux.xml gdb-14.1-sw64/gdb/features/sw64-linux.xml +--- gdb-14.1-after-patch/gdb/features/sw64-linux.xml 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64-linux.xml 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,18 @@ ++ ++ ++ ++ ++ ++ sw64 ++ ++ ++ ++ ++ ++ ++ ++ +diff -Naur gdb-14.1-after-patch/gdb/features/sw64-vec.c gdb-14.1-sw64/gdb/features/sw64-vec.c +--- gdb-14.1-after-patch/gdb/features/sw64-vec.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64-vec.c 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,46 @@ ++/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: ++ Original: sw64-vec.xml */ ++ ++#include "gdbsupport/tdesc.h" ++ ++static int ++create_feature_sw64_vec (struct target_desc *result, long regnum) ++{ ++ struct tdesc_feature *feature; ++ ++ feature = tdesc_create_feature (result, "org.gnu.gdb.sw64.vec"); ++ regnum = 167; ++ tdesc_create_reg (feature, "V0", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V1", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V2", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V3", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V4", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V5", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V6", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V7", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V8", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V9", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V10", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V11", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V12", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V13", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V14", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V15", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V16", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V17", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V18", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V19", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V20", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V21", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V22", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V23", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V24", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V25", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V26", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V27", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V28", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V29", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V30", regnum++, 1, NULL, 512, "int"); ++ tdesc_create_reg (feature, "V31", regnum++, 1, NULL, 512, "int"); ++ return regnum; ++} +diff -Naur gdb-14.1-after-patch/gdb/features/sw64-vec.xml gdb-14.1-sw64/gdb/features/sw64-vec.xml +--- gdb-14.1-after-patch/gdb/features/sw64-vec.xml 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/features/sw64-vec.xml 2025-03-03 10:59:13.130000000 +0800 +@@ -0,0 +1,43 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff -Naur gdb-14.1-after-patch/gdb/linux-nat.c gdb-14.1-sw64/gdb/linux-nat.c +--- gdb-14.1-after-patch/gdb/linux-nat.c 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/gdb/linux-nat.c 2025-03-03 10:59:13.150000000 +0800 +@@ -237,7 +237,11 @@ + static struct lwp_info *add_lwp (ptid_t ptid); + static void purge_lwp_list (int pid); + static void delete_lwp (ptid_t ptid); ++#ifdef __sw_64__ ++struct lwp_info *find_lwp_pid (ptid_t ptid); ++#else + static struct lwp_info *find_lwp_pid (ptid_t ptid); ++#endif + + static int lwp_status_pending_p (struct lwp_info *lp); + +@@ -840,7 +844,11 @@ + /* Return a pointer to the structure describing the LWP corresponding + to PID. If no corresponding LWP could be found, return NULL. */ + ++#ifdef __sw_64__ ++struct lwp_info * ++#else + static struct lwp_info * ++#endif + find_lwp_pid (ptid_t ptid) + { + int lwp; +diff -Naur gdb-14.1-after-patch/gdb/Makefile.in gdb-14.1-sw64/gdb/Makefile.in +--- gdb-14.1-after-patch/gdb/Makefile.in 2025-03-03 09:43:44.070000000 +0800 ++++ gdb-14.1-sw64/gdb/Makefile.in 2025-03-03 10:59:13.660000000 +0800 +@@ -737,6 +737,8 @@ + ia64-vms-tdep.o \ + loongarch-linux-tdep.o \ + loongarch-tdep.o \ ++ sw64-linux-tdep.o \ ++ sw64-tdep.o \ + mips-fbsd-tdep.o \ + mips-linux-tdep.o \ + mips-netbsd-tdep.o \ +@@ -1394,6 +1396,7 @@ + linux-tdep.h \ + location.h \ + loongarch-tdep.h \ ++ sw64-tdep.h \ + m2-lang.h \ + m32r-tdep.h \ + m68k-tdep.h \ +@@ -1745,6 +1748,9 @@ + loongarch-linux-nat.c \ + loongarch-linux-tdep.c \ + loongarch-tdep.c \ ++ sw64-linux-nat.c \ ++ sw64-linux-tdep.c \ ++ sw64-tdep.c \ + m32r-linux-nat.c \ + m32r-linux-tdep.c \ + m32r-tdep.c \ +diff -Naur gdb-14.1-after-patch/gdb/Makefile.in.orig gdb-14.1-sw64/gdb/Makefile.in.orig +--- gdb-14.1-after-patch/gdb/Makefile.in.orig 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/Makefile.in.orig 2025-03-03 10:59:13.060000000 +0800 +@@ -0,0 +1,2667 @@ ++# Copyright (C) 1989-2023 Free Software Foundation, Inc. ++ ++# This file is part of GDB. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# Please keep lists in this file sorted alphabetically, with one item per line. ++# Here are the general guidelines for ordering files and directories: ++# ++# - Files come before directories. ++# - The extensions are not taken into account when comparing filenames, except ++# if the filenames are otherwise equal. ++# - A filename that is a prefix of another one comes before. ++# - Underscores and dashes are treated equally, and come before alphanumeric ++# characters. ++# ++# For example: ++# ++# SOME_FILES = \ ++# foo.c \ ++# foo.h \ ++# foo-bar.c \ ++# foobar.c \ ++# foo/bar.c ++ ++prefix = @prefix@ ++exec_prefix = @exec_prefix@ ++ ++host_alias = @host_alias@ ++target_alias = @target_alias@ ++program_transform_name = @program_transform_name@ ++bindir = @bindir@ ++libdir = @libdir@ ++tooldir = $(libdir)/$(target_alias) ++ ++datadir = @datadir@ ++localedir = @localedir@ ++mandir = @mandir@ ++man1dir = $(mandir)/man1 ++man2dir = $(mandir)/man2 ++man3dir = $(mandir)/man3 ++man4dir = $(mandir)/man4 ++man5dir = $(mandir)/man5 ++man6dir = $(mandir)/man6 ++man7dir = $(mandir)/man7 ++man8dir = $(mandir)/man8 ++man9dir = $(mandir)/man9 ++infodir = @infodir@ ++datarootdir = @datarootdir@ ++docdir = @docdir@ ++htmldir = @htmldir@ ++pdfdir = @pdfdir@ ++includedir = @includedir@ ++ ++install_sh = @install_sh@ ++ ++# This can be referenced by `LIBINTL' as computed by ++# ZW_GNU_GETTEXT_SISTER_DIR. ++top_builddir = . ++ ++SHELL = @SHELL@ ++EXEEXT = @EXEEXT@ ++ ++AWK = @AWK@ ++LN_S = @LN_S@ ++ ++INSTALL = @INSTALL@ ++INSTALL_PROGRAM = @INSTALL_PROGRAM@ ++INSTALL_SCRIPT = @INSTALL_SCRIPT@ ++INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ ++INSTALL_DATA = @INSTALL_DATA@ ++ ++DESTDIR = ++ ++AR = @AR@ ++AR_FLAGS = qv ++RANLIB = @RANLIB@ ++DLLTOOL = @DLLTOOL@ ++WINDRES = @WINDRES@ ++MIG = @MIG@ ++STRIP = @STRIP@ ++ ++XGETTEXT = @XGETTEXT@ ++GMSGFMT = @GMSGFMT@ ++MSGMERGE = msgmerge ++ ++PACKAGE = @PACKAGE@ ++CATALOGS = @CATALOGS@ ++ ++CC = @CC@ ++CXX = @CXX@ ++CXX_DIALECT = @CXX_DIALECT@ ++ ++# Dependency tracking information. ++DEPMODE = @CCDEPMODE@ ++DEPDIR = @DEPDIR@ ++depcomp = $(SHELL) $(srcdir)/../depcomp ++ ++# Directory containing source files. ++srcdir = @srcdir@ ++VPATH = @srcdir@ ++top_srcdir = @top_srcdir@ ++ ++include $(srcdir)/silent-rules.mk ++ ++# Note that these are overridden by GNU make-specific code below if ++# GNU make is used. The overrides implement dependency tracking. ++COMPILE.pre = $(CXX) -x c++ $(CXX_DIALECT) ++COMPILE.post = -c -o $@ ++POSTCOMPILE = @true ++ ++# CXXFLAGS is at the very end on purpose, so that user-supplied flags can ++# override internal flags. ++COMPILE = $(ECHO_CXX) $(COMPILE.pre) $(INTERNAL_CFLAGS) $(CXXFLAGS) \ ++ $(COMPILE.post) ++ ++YACC = @YACC@ ++ ++# This is used to rebuild ada-lex.c from ada-lex.l. If the program is ++# not defined, but ada-lex.c is present, compilation will continue, ++# possibly with a warning. ++FLEX = flex ++ ++YLWRAP = $(srcdir)/../ylwrap ++ ++# where to find makeinfo, preferably one designed for texinfo-2 ++MAKEINFO = @MAKEINFO@ ++MAKEINFOFLAGS = @MAKEINFOFLAGS@ ++MAKEINFO_EXTRA_FLAGS = @MAKEINFO_EXTRA_FLAGS@ ++MAKEINFO_CMD = $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFO_EXTRA_FLAGS) ++ ++MAKEHTML = $(MAKEINFO_CMD) --html ++MAKEHTMLFLAGS = ++ ++LIBTOOL = @LIBTOOL@ ++ ++# Set this up with gcc if you have gnu ld and the loader will print out ++# line numbers for undefined references. ++#CC_LD = g++ -static ++CC_LD = $(LIBTOOL) $(SILENT_FLAG) --mode=link $(CXX) $(CXX_DIALECT) ++ ++# Where is our "include" directory? Typically $(srcdir)/../include. ++# This is essentially the header file directory for the library ++# routines in libiberty. ++INCLUDE_DIR = $(srcdir)/../include ++INCLUDE_CFLAGS = -I$(INCLUDE_DIR) ++ ++# Where is the "-liberty" library? Typically in ../libiberty. ++LIBIBERTY = ../libiberty/libiberty.a ++ ++# Where is the CTF library? Typically in ../libctf. ++LIBCTF = @LIBCTF@ ++CTF_DEPS = @CTF_DEPS@ ++ ++# Where is the BFD library? Typically in ../bfd. ++BFD_DIR = ../bfd ++BFD = $(BFD_DIR)/libbfd.la ++BFD_SRC = $(srcdir)/$(BFD_DIR) ++BFD_CFLAGS = -I$(BFD_DIR) -I$(BFD_SRC) ++ ++# This is where we get zlib from. zlibdir is -L../zlib and zlibinc is ++# -I../zlib, unless we were configured with --with-system-zlib, in which ++# case both are empty. ++ZLIB = @zlibdir@ -lz ++ZLIBINC = @zlibinc@ ++ ++ZSTD_CFLAGS = @ZSTD_CFLAGS@ ++ZSTD_LIBS = @ZSTD_LIBS@ ++ ++# Where is the decnumber library? Typically in ../libdecnumber. ++LIBDECNUMBER_DIR = ../libdecnumber ++LIBDECNUMBER = $(LIBDECNUMBER_DIR)/libdecnumber.a ++LIBDECNUMBER_SRC = $(srcdir)/$(LIBDECNUMBER_DIR) ++LIBDECNUMBER_CFLAGS = -I$(LIBDECNUMBER_DIR) -I$(LIBDECNUMBER_SRC) ++ ++# Where is the READLINE library? Typically in ../readline/readline. ++READLINE_DIR = ../readline/readline ++READLINE_SRC = $(srcdir)/$(READLINE_DIR) ++READLINE = @READLINE@ ++READLINE_DEPS = @READLINE_DEPS@ ++READLINE_CFLAGS = @READLINE_CFLAGS@ ++ ++# Where is expat? This will be empty if expat was not available. ++LIBEXPAT = @LIBEXPAT@ ++ ++# Where is lzma? This will be empty if lzma was not available. ++LIBLZMA = @LIBLZMA@ ++ ++# Where is libbabeltrace? This will be empty if libbabeltrace was not ++# available. ++LIBBABELTRACE = @LIBBABELTRACE@ ++ ++# Where is libxxhash? This will be empty if libxxhash was not ++# available. ++LIBXXHASH = @LIBXXHASH@ ++ ++# Where is libipt? This will be empty if libipt was not available. ++LIBIPT = @LIBIPT@ ++ ++# How to find GMP and MPFR ++GMPLIBS = @GMPLIBS@ ++GMPINC = @GMPINC@ ++ ++# GNU source highlight library. ++SRCHIGH_LIBS = @SRCHIGH_LIBS@ ++SRCHIGH_CFLAGS = @SRCHIGH_CFLAGS@ ++ ++WARN_CFLAGS = @WARN_CFLAGS@ ++WERROR_CFLAGS = @WERROR_CFLAGS@ ++GDB_WARN_CFLAGS = $(WARN_CFLAGS) ++GDB_WERROR_CFLAGS = $(WERROR_CFLAGS) ++ ++PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ ++PTHREAD_LIBS = @PTHREAD_LIBS@ ++ ++DEBUGINFOD_CFLAGS = @DEBUGINFOD_CFLAGS@ ++DEBUGINFOD_LIBS = @DEBUGINFOD_LIBS@ ++ ++AMD_DBGAPI_CFLAGS = @AMD_DBGAPI_CFLAGS@ ++AMD_DBGAPI_LIBS = @AMD_DBGAPI_LIBS@ ++ ++RDYNAMIC = @RDYNAMIC@ ++ ++# Where is the INTL library? Typically in ../intl. ++INTL = @LIBINTL@ ++INTL_DEPS = @LIBINTL_DEP@ ++INTL_CFLAGS = @INCINTL@ ++ ++# Where is the ICONV library? This will be empty if in libc or not available. ++LIBICONV = @LIBICONV@ ++ ++# Did the user give us a --with-gdb-datadir option? ++GDB_DATADIR = @GDB_DATADIR@ ++ ++# Code signing. ++CODESIGN = codesign ++CODESIGN_CERT = @CODESIGN_CERT@ ++ ++# Flags to pass to gdb when invoked with "make run". ++GDBFLAGS = ++ ++# Helper code from gnulib. ++GNULIB_PARENT_DIR = .. ++include $(GNULIB_PARENT_DIR)/gnulib/Makefile.gnulib.inc ++ ++# For libbacktrace. ++LIBBACKTRACE_INC=@LIBBACKTRACE_INC@ ++LIBBACKTRACE_LIB=@LIBBACKTRACE_LIB@ ++ ++SUPPORT = ../gdbsupport ++LIBSUPPORT = $(SUPPORT)/libgdbsupport.a ++INCSUPPORT = -I$(srcdir)/.. -I.. ++ ++# ++# CLI sub directory definitons ++# ++SUBDIR_CLI_SRCS = \ ++ cli/cli-cmds.c \ ++ cli/cli-decode.c \ ++ cli/cli-dump.c \ ++ cli/cli-interp.c \ ++ cli/cli-logging.c \ ++ cli/cli-option.c \ ++ cli/cli-script.c \ ++ cli/cli-setshow.c \ ++ cli/cli-style.c \ ++ cli/cli-utils.c ++ ++SUBDIR_CLI_OBS = $(patsubst %.c,%.o,$(SUBDIR_CLI_SRCS)) ++ ++# ++# MI sub directory definitons ++# ++SUBDIR_MI_SRCS = \ ++ mi/mi-cmd-break.c \ ++ mi/mi-cmd-catch.c \ ++ mi/mi-cmd-disas.c \ ++ mi/mi-cmd-env.c \ ++ mi/mi-cmd-file.c \ ++ mi/mi-cmd-info.c \ ++ mi/mi-cmd-stack.c \ ++ mi/mi-cmd-target.c \ ++ mi/mi-cmd-var.c \ ++ mi/mi-cmds.c \ ++ mi/mi-common.c \ ++ mi/mi-console.c \ ++ mi/mi-getopt.c \ ++ mi/mi-interp.c \ ++ mi/mi-main.c \ ++ mi/mi-out.c \ ++ mi/mi-parse.c \ ++ mi/mi-symbol-cmds.c ++ ++SUBDIR_MI_OBS = $(patsubst %.c,%.o,$(SUBDIR_MI_SRCS)) ++ ++# ++# TUI sub directory definitions ++# ++SUBDIR_TUI_SRCS = \ ++ tui/tui.c \ ++ tui/tui-command.c \ ++ tui/tui-data.c \ ++ tui/tui-disasm.c \ ++ tui/tui-file.c \ ++ tui/tui-hooks.c \ ++ tui/tui-interp.c \ ++ tui/tui-io.c \ ++ tui/tui-layout.c \ ++ tui/tui-location.c \ ++ tui/tui-out.c \ ++ tui/tui-regs.c \ ++ tui/tui-source.c \ ++ tui/tui-stack.c \ ++ tui/tui-win.c \ ++ tui/tui-wingeneral.c \ ++ tui/tui-winsource.c ++ ++SUBDIR_TUI_OBS = $(patsubst %.c,%.o,$(SUBDIR_TUI_SRCS)) ++ ++SUBDIR_TUI_DEPS = ++SUBDIR_TUI_LDFLAGS = ++SUBDIR_TUI_CFLAGS = -DTUI=1 ++ ++# ++# GCC Compile support sub-directory definitions ++# ++SUBDIR_GCC_COMPILE_SRCS = \ ++ compile/compile.c \ ++ compile/compile-c-support.c \ ++ compile/compile-c-symbols.c \ ++ compile/compile-c-types.c \ ++ compile/compile-cplus-symbols.c \ ++ compile/compile-cplus-types.c \ ++ compile/compile-loc2c.c \ ++ compile/compile-object-load.c \ ++ compile/compile-object-run.c ++ ++SUBDIR_GCC_COMPILE_OBS = $(patsubst %.c,%.o,$(filter %.c,$(SUBDIR_GCC_COMPILE_SRCS))) ++ ++# ++# Guile sub directory definitons for guile support. ++# ++SUBDIR_GUILE_SRCS = \ ++ guile/guile.c \ ++ guile/scm-arch.c \ ++ guile/scm-auto-load.c \ ++ guile/scm-block.c \ ++ guile/scm-breakpoint.c \ ++ guile/scm-cmd.c \ ++ guile/scm-disasm.c \ ++ guile/scm-exception.c \ ++ guile/scm-frame.c \ ++ guile/scm-gsmob.c \ ++ guile/scm-iterator.c \ ++ guile/scm-lazy-string.c \ ++ guile/scm-math.c \ ++ guile/scm-objfile.c \ ++ guile/scm-param.c \ ++ guile/scm-ports.c \ ++ guile/scm-pretty-print.c \ ++ guile/scm-progspace.c \ ++ guile/scm-safe-call.c \ ++ guile/scm-string.c \ ++ guile/scm-symbol.c \ ++ guile/scm-symtab.c \ ++ guile/scm-type.c \ ++ guile/scm-utils.c \ ++ guile/scm-value.c ++ ++SUBDIR_GUILE_OBS = $(patsubst %.c,%.o,$(SUBDIR_GUILE_SRCS)) ++ ++SUBDIR_GUILE_DEPS = ++SUBDIR_GUILE_LDFLAGS = ++SUBDIR_GUILE_CFLAGS = ++ ++# ++# python sub directory definitons ++# ++SUBDIR_PYTHON_SRCS = \ ++ python/py-arch.c \ ++ python/py-auto-load.c \ ++ python/py-block.c \ ++ python/py-bpevent.c \ ++ python/py-breakpoint.c \ ++ python/py-cmd.c \ ++ python/py-connection.c \ ++ python/py-continueevent.c \ ++ python/py-dap.c \ ++ python/py-disasm.c \ ++ python/py-event.c \ ++ python/py-evtregistry.c \ ++ python/py-evts.c \ ++ python/py-exitedevent.c \ ++ python/py-finishbreakpoint.c \ ++ python/py-frame.c \ ++ python/py-framefilter.c \ ++ python/py-function.c \ ++ python/py-gdb-readline.c \ ++ python/py-inferior.c \ ++ python/py-infevents.c \ ++ python/py-infthread.c \ ++ python/py-instruction.c \ ++ python/py-lazy-string.c \ ++ python/py-linetable.c \ ++ python/py-membuf.c \ ++ python/py-mi.c \ ++ python/py-micmd.c \ ++ python/py-newobjfileevent.c \ ++ python/py-objfile.c \ ++ python/py-param.c \ ++ python/py-prettyprint.c \ ++ python/py-progspace.c \ ++ python/py-record.c \ ++ python/py-record-btrace.c \ ++ python/py-record-full.c \ ++ python/py-registers.c \ ++ python/py-signalevent.c \ ++ python/py-stopevent.c \ ++ python/py-symbol.c \ ++ python/py-symtab.c \ ++ python/py-threadevent.c \ ++ python/py-tui.c \ ++ python/py-type.c \ ++ python/py-unwind.c \ ++ python/py-utils.c \ ++ python/py-value.c \ ++ python/py-varobj.c \ ++ python/py-xmethods.c \ ++ python/python.c ++ ++SUBDIR_PYTHON_OBS = $(patsubst %.c,%.o,$(SUBDIR_PYTHON_SRCS)) ++ ++SUBDIR_PYTHON_DEPS = ++SUBDIR_PYTHON_LDFLAGS = ++SUBDIR_PYTHON_CFLAGS = ++ ++SELFTESTS_SRCS = \ ++ disasm-selftests.c \ ++ gdbarch-selftests.c \ ++ selftest-arch.c \ ++ unittests/array-view-selftests.c \ ++ unittests/child-path-selftests.c \ ++ unittests/cli-utils-selftests.c \ ++ unittests/command-def-selftests.c \ ++ unittests/common-utils-selftests.c \ ++ unittests/copy_bitwise-selftests.c \ ++ unittests/enum-flags-selftests.c \ ++ unittests/environ-selftests.c \ ++ unittests/filtered_iterator-selftests.c \ ++ unittests/format_pieces-selftests.c \ ++ unittests/frame_info_ptr-selftests.c \ ++ unittests/function-view-selftests.c \ ++ unittests/gdb_tilde_expand-selftests.c \ ++ unittests/gmp-utils-selftests.c \ ++ unittests/intrusive_list-selftests.c \ ++ unittests/lookup_name_info-selftests.c \ ++ unittests/memory-map-selftests.c \ ++ unittests/memrange-selftests.c \ ++ unittests/offset-type-selftests.c \ ++ unittests/observable-selftests.c \ ++ unittests/optional-selftests.c \ ++ unittests/packed-selftests.c \ ++ unittests/parallel-for-selftests.c \ ++ unittests/parse-connection-spec-selftests.c \ ++ unittests/path-join-selftests.c \ ++ unittests/ptid-selftests.c \ ++ unittests/main-thread-selftests.c \ ++ unittests/mkdir-recursive-selftests.c \ ++ unittests/rsp-low-selftests.c \ ++ unittests/scoped_fd-selftests.c \ ++ unittests/scoped_ignore_signal-selftests.c \ ++ unittests/scoped_mmap-selftests.c \ ++ unittests/scoped_restore-selftests.c \ ++ unittests/search-memory-selftests.c \ ++ unittests/string_view-selftests.c \ ++ unittests/style-selftests.c \ ++ unittests/tracepoint-selftests.c \ ++ unittests/tui-selftests.c \ ++ unittests/ui-file-selftests.c \ ++ unittests/unique_xmalloc_ptr_char.c \ ++ unittests/unpack-selftests.c \ ++ unittests/utils-selftests.c \ ++ unittests/vec-utils-selftests.c \ ++ unittests/xml-utils-selftests.c ++ ++SELFTESTS_OBS = $(patsubst %.c,%.o,$(SELFTESTS_SRCS)) ++ ++SUBDIR_TARGET_SRCS = target/target.c target/waitstatus.c ++SUBDIR_TARGET_OBS = $(patsubst %.c,%.o,$(SUBDIR_TARGET_SRCS)) ++ ++ ++# Opcodes currently live in one of two places. Either they are in the ++# opcode library, typically ../opcodes, or they are in a header file ++# in INCLUDE_DIR. ++# Where is the "-lopcodes" library, with (some of) the opcode tables and ++# disassemblers? ++OPCODES_DIR = ../opcodes ++OPCODES_SRC = $(srcdir)/$(OPCODES_DIR) ++OPCODES = $(OPCODES_DIR)/libopcodes.la ++# Where are the other opcode tables which only have header file ++# versions? ++OP_INCLUDE = $(INCLUDE_DIR)/opcode ++# See TOP_CFLAGS as well. ++OPCODES_CFLAGS = -I$(OP_INCLUDE) ++ ++# Allow includes like "opcodes/mumble.h". ++TOP_CFLAGS = -I$(top_srcdir)/.. ++ ++# The simulator is usually nonexistent; targets that include one ++# should set this to list all the .o or .a files to be linked in. ++SIM = @SIM@ ++ ++WIN32LIBS = @WIN32LIBS@ ++ ++# Tcl et al cflags and libraries ++TCL = @TCL_LIBRARY@ ++TCL_CFLAGS = @TCL_INCLUDE@ ++GDBTKLIBS = @GDBTKLIBS@ ++# Extra flags that the GDBTK files need: ++GDBTK_CFLAGS = @GDBTK_CFLAGS@ ++ ++TK = @TK_LIBRARY@ ++TK_CFLAGS = @TK_INCLUDE@ ++ ++X11_CFLAGS = @TK_XINCLUDES@ ++X11_LDFLAGS = ++X11_LIBS = ++ ++WIN32LDAPP = @WIN32LDAPP@ ++ ++LIBGUI = @LIBGUI@ ++GUI_CFLAGS_X = @GUI_CFLAGS_X@ ++IDE_CFLAGS = $(GUI_CFLAGS_X) $(IDE_CFLAGS_X) ++ ++ALL_TCL_CFLAGS = $(TCL_CFLAGS) $(TK_CFLAGS) ++ ++# The version of gdbtk we're building. This should be kept ++# in sync with GDBTK_VERSION and friends in gdbtk.h. ++GDBTK_VERSION = 1.0 ++GDBTK_LIBRARY = $(datadir)/insight$(GDBTK_VERSION) ++ ++# Gdbtk requires an absolute path to the source directory or ++# the testsuite won't run properly. ++GDBTK_SRC_DIR = @GDBTK_SRC_DIR@ ++ ++SUBDIR_GDBTK_OBS = \ ++ gdbtk.o \ ++ gdbtk-bp.o \ ++ gdbtk-cmds.o \ ++ gdbtk-hooks.o \ ++ gdbtk-interp.o \ ++ gdbtk-register.o \ ++ gdbtk-stack.o \ ++ gdbtk-varobj.o \ ++ gdbtk-wrapper.o ++ ++SUBDIR_GDBTK_SRCS = \ ++ gdbtk/generic/gdbtk.c \ ++ gdbtk/generic/gdbtk-bp.c \ ++ gdbtk/generic/gdbtk-cmds.c \ ++ gdbtk/generic/gdbtk-hooks.c \ ++ gdbtk/generic/gdbtk-interp.c \ ++ gdbtk/generic/gdbtk-main.c \ ++ gdbtk/generic/gdbtk-register.c \ ++ gdbtk/generic/gdbtk-stack.c \ ++ gdbtk/generic/gdbtk-varobj.c \ ++ gdbtk/generic/gdbtk-wrapper.c ++ ++SUBDIR_GDBTK_DEPS = $(LIBGUI) $(TCL_DEPS) $(TK_DEPS) ++SUBDIR_GDBTK_LDFLAGS = ++SUBDIR_GDBTK_CFLAGS = -DGDBTK ++ ++CONFIG_OBS = @CONFIG_OBS@ ++CONFIG_SRCS = @CONFIG_SRCS@ ++CONFIG_DEPS = @CONFIG_DEPS@ ++CONFIG_LDFLAGS = @CONFIG_LDFLAGS@ ++ENABLE_CFLAGS = @ENABLE_CFLAGS@ ++CONFIG_ALL = @CONFIG_ALL@ ++CONFIG_CLEAN = @CONFIG_CLEAN@ ++CONFIG_INSTALL = @CONFIG_INSTALL@ ++CONFIG_UNINSTALL = @CONFIG_UNINSTALL@ ++HAVE_NATIVE_GCORE_TARGET = @HAVE_NATIVE_GCORE_TARGET@ ++ ++CONFIG_SRC_SUBDIR = arch cli dwarf2 mi compile tui unittests guile python \ ++ target nat ++CONFIG_DEP_SUBDIR = $(addsuffix /$(DEPDIR),$(CONFIG_SRC_SUBDIR)) ++ ++# -I. for config files. ++# -I$(srcdir) for gdb internal headers. ++# -I$(srcdir)/config for more generic config files. ++ ++# It is also possible that you will need to add -I/usr/include/sys if ++# your system doesn't have fcntl.h in /usr/include (which is where it ++# should be according to Posix). ++DEFS = @DEFS@ ++GDB_CFLAGS = -I. -I$(srcdir) -I$(srcdir)/config \ ++ -DLOCALEDIR="\"$(localedir)\"" $(DEFS) ++ ++# MH_CFLAGS, if defined, has host-dependent CFLAGS from the config directory. ++GLOBAL_CFLAGS = $(MH_CFLAGS) ++ ++PROFILE_CFLAGS = @PROFILE_CFLAGS@ ++ ++# These are specifically reserved for setting from the command line ++# when running make. I.E.: "make CFLAGS=-Wmissing-prototypes". ++CFLAGS = @CFLAGS@ ++CXXFLAGS = @CXXFLAGS@ ++CPPFLAGS = @CPPFLAGS@ ++ ++# Set by configure, for e.g. expat. Python installations are such that ++# C headers are included using their basename (for example, we #include ++# rather than, say, ). Since the file names ++# are sometimes a little generic, we think that the risk of collision ++# with other header files is high. If that happens, we try to mitigate ++# a bit the consequences by putting the Python includes last in the list. ++INTERNAL_CPPFLAGS = $(CPPFLAGS) @GUILE_CPPFLAGS@ @PYTHON_CPPFLAGS@ \ ++ @LARGEFILE_CPPFLAGS@ ++ ++# INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros. ++INTERNAL_CFLAGS_BASE = \ ++ $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \ ++ $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(BFD_CFLAGS) $(INCLUDE_CFLAGS) \ ++ $(READLINE_CFLAGS) $(ZLIBINC) $(ZSTD_CFLAGS) $(LIBDECNUMBER_CFLAGS) \ ++ $(INTL_CFLAGS) $(INCGNU) $(INCSUPPORT) $(LIBBACKTRACE_INC) \ ++ $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS) $(SRCHIGH_CFLAGS) \ ++ $(TOP_CFLAGS) $(PTHREAD_CFLAGS) $(DEBUGINFOD_CFLAGS) $(GMPINC) \ ++ $(AMD_DBGAPI_CFLAGS) ++INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS) ++INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS) ++ ++# LDFLAGS is specifically reserved for setting from the command line ++# when running make. ++LDFLAGS = @LDFLAGS@ ++ ++# Profiling options need to go here to work. ++# I think it's perfectly reasonable for a user to set -pg in CFLAGS ++# and have it work; that's why CFLAGS is here. ++# PROFILE_CFLAGS is _not_ included, however, because we use monstartup. ++INTERNAL_LDFLAGS = \ ++ $(CXXFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) \ ++ $(LDFLAGS) $(CONFIG_LDFLAGS) $(PTHREAD_CFLAGS) ++ ++# Libraries and corresponding dependencies for compiling gdb. ++# XM_CLIBS, defined in *config files, have host-dependent libs. ++# LIBIBERTY appears twice on purpose. ++CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) $(ZSTD_LIBS) \ ++ $(LIBSUPPORT) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \ ++ $(XM_CLIBS) $(GDBTKLIBS) $(LIBBACKTRACE_LIB) \ ++ @LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ $(AMD_DBGAPI_LIBS) \ ++ $(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \ ++ $(WIN32LIBS) $(LIBGNU) $(LIBGNU_EXTRA_LIBS) $(LIBICONV) \ ++ $(GMPLIBS) $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) \ ++ $(DEBUGINFOD_LIBS) $(LIBBABELTRACE_LIB) ++CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \ ++ $(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) \ ++ $(LIBSUPPORT) ++ ++DIST = gdb ++ ++RUNTEST = runtest ++RUNTESTFLAGS = ++ ++# XML files to build in to GDB. ++XMLFILES = \ ++ $(srcdir)/features/btrace.dtd \ ++ $(srcdir)/features/btrace-conf.dtd \ ++ $(srcdir)/features/gdb-target.dtd \ ++ $(srcdir)/features/library-list.dtd \ ++ $(srcdir)/features/library-list-aix.dtd \ ++ $(srcdir)/features/library-list-svr4.dtd \ ++ $(srcdir)/features/osdata.dtd \ ++ $(srcdir)/features/threads.dtd \ ++ $(srcdir)/features/traceframe-info.dtd \ ++ $(srcdir)/features/xinclude.dtd ++ ++# Build the ser-*.o files the host supports. This includes ser-unix.o ++# for any system that supports a POSIX interface to the serial port. ++# See configure.ac. ++SER_HARDWIRE = @SER_HARDWIRE@ ++ ++# This is remote-sim.o if a simulator is to be linked in. ++SIM_OBS = @SIM_OBS@ ++ ++# Target-dependent object files. ++TARGET_OBS = @TARGET_OBS@ ++ ++# All target-dependent object files that require the amd-dbgapi ++# target to be available (used with --enable-targets=all). ++ALL_AMD_DBGAPI_TARGET_OBS = \ ++ amdgpu-tdep.o \ ++ solib-rocm.o ++ ++# All target-dependent objects files that require 64-bit CORE_ADDR ++# (used with --enable-targets=all --enable-64-bit-bfd). ++ALL_64_TARGET_OBS = \ ++ aarch64-fbsd-tdep.o \ ++ aarch64-linux-tdep.o \ ++ aarch64-newlib-tdep.o \ ++ aarch64-ravenscar-thread.o \ ++ aarch64-tdep.o \ ++ alpha-bsd-tdep.o \ ++ alpha-linux-tdep.o \ ++ alpha-mdebug-tdep.o \ ++ alpha-netbsd-tdep.o \ ++ alpha-obsd-tdep.o \ ++ alpha-tdep.o \ ++ amd64-darwin-tdep.o \ ++ amd64-dicos-tdep.o \ ++ amd64-fbsd-tdep.o \ ++ amd64-linux-tdep.o \ ++ amd64-netbsd-tdep.o \ ++ amd64-obsd-tdep.o \ ++ amd64-ravenscar-thread.o \ ++ amd64-sol2-tdep.o \ ++ amd64-tdep.o \ ++ amd64-windows-tdep.o \ ++ arch/aarch64.o \ ++ arch/aarch64-insn.o \ ++ arch/aarch64-mte-linux.o \ ++ arch/aarch64-scalable-linux.o \ ++ arch/amd64.o \ ++ arch/riscv.o \ ++ bpf-tdep.o \ ++ ia64-linux-tdep.o \ ++ ia64-tdep.o \ ++ ia64-vms-tdep.o \ ++ loongarch-linux-tdep.o \ ++ loongarch-tdep.o \ ++ sw64-linux-tdep.o \ ++ sw64-tdep.o \ ++ mips-fbsd-tdep.o \ ++ mips-linux-tdep.o \ ++ mips-netbsd-tdep.o \ ++ mips-sde-tdep.o \ ++ mips-tdep.o \ ++ mips64-obsd-tdep.o \ ++ riscv-fbsd-tdep.o \ ++ riscv-linux-tdep.o \ ++ riscv-none-tdep.o \ ++ riscv-ravenscar-thread.o \ ++ riscv-tdep.o \ ++ sparc64-fbsd-tdep.o \ ++ sparc64-linux-tdep.o \ ++ sparc64-netbsd-tdep.o \ ++ sparc64-obsd-tdep.o \ ++ sparc64-sol2-tdep.o \ ++ sparc64-tdep.o \ ++ tilegx-linux-tdep.o \ ++ tilegx-tdep.o ++ ++ ++# All other target-dependent objects files (used with --enable-targets=all). ++ALL_TARGET_OBS = \ ++ aarch32-tdep.o \ ++ arc-linux-tdep.o \ ++ arc-newlib-tdep.o \ ++ arc-tdep.o \ ++ arch/aarch32.o \ ++ arch/arc.o \ ++ arch/arm.o \ ++ arch/arm-get-next-pcs.o \ ++ arch/arm-linux.o \ ++ arch/i386.o \ ++ arch/loongarch.o \ ++ arch/ppc-linux-common.o \ ++ arm-bsd-tdep.o \ ++ arm-fbsd-tdep.o \ ++ arm-linux-tdep.o \ ++ arm-netbsd-tdep.o \ ++ arm-none-tdep.o \ ++ arm-obsd-tdep.o \ ++ arm-pikeos-tdep.o \ ++ arm-tdep.o \ ++ arm-wince-tdep.o \ ++ avr-tdep.o \ ++ bfin-linux-tdep.o \ ++ bfin-tdep.o \ ++ bsd-uthread.o \ ++ cris-linux-tdep.o \ ++ cris-tdep.o \ ++ csky-linux-tdep.o \ ++ csky-tdep.o \ ++ dicos-tdep.o \ ++ fbsd-tdep.o \ ++ frv-linux-tdep.o \ ++ frv-tdep.o \ ++ ft32-tdep.o \ ++ glibc-tdep.o \ ++ h8300-tdep.o \ ++ hppa-bsd-tdep.o \ ++ hppa-linux-tdep.o \ ++ hppa-netbsd-tdep.o \ ++ hppa-obsd-tdep.o \ ++ hppa-tdep.o \ ++ i386-bsd-tdep.o \ ++ i386-darwin-tdep.o \ ++ i386-dicos-tdep.o \ ++ i386-fbsd-tdep.o \ ++ i386-gnu-tdep.o \ ++ i386-go32-tdep.o \ ++ i386-linux-tdep.o \ ++ i386-netbsd-tdep.o \ ++ i386-nto-tdep.o \ ++ i386-obsd-tdep.o \ ++ i386-sol2-tdep.o \ ++ i386-tdep.o \ ++ i386-windows-tdep.o \ ++ i387-tdep.o \ ++ iq2000-tdep.o \ ++ linux-record.o \ ++ linux-tdep.o \ ++ lm32-tdep.o \ ++ m32c-tdep.o \ ++ m32r-linux-tdep.o \ ++ m32r-tdep.o \ ++ m68hc11-tdep.o \ ++ m68k-bsd-tdep.o \ ++ m68k-linux-tdep.o \ ++ m68k-tdep.o \ ++ mep-tdep.o \ ++ microblaze-linux-tdep.o \ ++ microblaze-tdep.o \ ++ mn10300-linux-tdep.o \ ++ mn10300-tdep.o \ ++ moxie-tdep.o \ ++ msp430-tdep.o \ ++ netbsd-tdep.o \ ++ nds32-tdep.o \ ++ nios2-linux-tdep.o \ ++ nios2-tdep.o \ ++ nto-tdep.o \ ++ obsd-tdep.o \ ++ or1k-linux-tdep.o \ ++ or1k-tdep.o \ ++ ppc-fbsd-tdep.o \ ++ ppc-linux-tdep.o \ ++ ppc-netbsd-tdep.o \ ++ ppc-obsd-tdep.o \ ++ ppc-ravenscar-thread.o \ ++ ppc-sysv-tdep.o \ ++ ppc64-tdep.o \ ++ ravenscar-thread.o \ ++ rl78-tdep.o \ ++ rs6000-aix-tdep.o \ ++ rs6000-lynx178-tdep.o \ ++ rs6000-tdep.o \ ++ rx-tdep.o \ ++ s12z-tdep.o \ ++ s390-linux-tdep.o \ ++ s390-tdep.o \ ++ sh-linux-tdep.o \ ++ sh-netbsd-tdep.o \ ++ sh-tdep.o \ ++ sol2-tdep.o \ ++ solib-aix.o \ ++ solib-darwin.o \ ++ solib-dsbt.o \ ++ solib-frv.o \ ++ solib-svr4.o \ ++ sparc-linux-tdep.o \ ++ sparc-netbsd-tdep.o \ ++ sparc-obsd-tdep.o \ ++ sparc-ravenscar-thread.o \ ++ sparc-sol2-tdep.o \ ++ sparc-tdep.o \ ++ symfile-mem.o \ ++ tic6x-linux-tdep.o \ ++ tic6x-tdep.o \ ++ v850-tdep.o \ ++ vax-netbsd-tdep.o \ ++ vax-tdep.o \ ++ windows-tdep.o \ ++ x86-tdep.o \ ++ xcoffread.o \ ++ xstormy16-tdep.o \ ++ xtensa-config.o \ ++ xtensa-linux-tdep.o \ ++ xtensa-tdep.o \ ++ z80-tdep.o ++ ++# The following native-target dependent variables are defined on ++# configure.nat. ++NAT_FILE = @NAT_FILE@ ++NATDEPFILES = @NATDEPFILES@ ++NAT_CDEPS = @NAT_CDEPS@ ++LOADLIBES = @LOADLIBES@ ++MH_CFLAGS = @MH_CFLAGS@ ++XM_CLIBS = @XM_CLIBS@ ++NAT_GENERATED_FILES = @NAT_GENERATED_FILES@ ++NM_H = @NM_H@ ++HAVE_NATIVE_GCORE_HOST = @HAVE_NATIVE_GCORE_HOST@ ++ ++# Native-target dependent makefile fragment comes in here. ++@nat_makefile_frag@ ++ ++# End of native-target dependent variables. ++ ++FLAGS_TO_PASS = \ ++ "prefix=$(prefix)" \ ++ "exec_prefix=$(exec_prefix)" \ ++ "infodir=$(infodir)" \ ++ "datarootdir=$(datarootdir)" \ ++ "docdir=$(docdir)" \ ++ "htmldir=$(htmldir)" \ ++ "pdfdir=$(pdfdir)" \ ++ "libdir=$(libdir)" \ ++ "mandir=$(mandir)" \ ++ "datadir=$(datadir)" \ ++ "includedir=$(includedir)" \ ++ "against=$(against)" \ ++ "DESTDIR=$(DESTDIR)" \ ++ "AR=$(AR)" \ ++ "AR_FLAGS=$(AR_FLAGS)" \ ++ "CC=$(CC)" \ ++ "CFLAGS=$(CFLAGS)" \ ++ "CXX=$(CXX)" \ ++ "CXX_DIALECT=$(CXX_DIALECT)" \ ++ "CXXFLAGS=$(CXXFLAGS)" \ ++ "DLLTOOL=$(DLLTOOL)" \ ++ "LDFLAGS=$(LDFLAGS)" \ ++ "RANLIB=$(RANLIB)" \ ++ "MAKEINFO=$(MAKEINFO)" \ ++ "MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \ ++ "MAKEINFO_EXTRA_FLAGS=$(MAKEINFO_EXTRA_FLAGS)" \ ++ "MAKEHTML=$(MAKEHTML)" \ ++ "MAKEHTMLFLAGS=$(MAKEHTMLFLAGS)" \ ++ "INSTALL=$(INSTALL)" \ ++ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ ++ "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \ ++ "INSTALL_DATA=$(INSTALL_DATA)" \ ++ "RUNTEST=$(RUNTEST)" \ ++ "RUNTESTFLAGS=$(RUNTESTFLAGS)" ++ ++# Flags that we pass when building the testsuite. ++ ++# empty for native, $(target_alias)/ for cross ++target_subdir = @target_subdir@ ++ ++CC_FOR_TARGET = ` \ ++ if [ -f $${rootme}/../gcc/xgcc ] ; then \ ++ if [ -f $${rootme}/../$(target_subdir)newlib/Makefile ] ; then \ ++ echo $${rootme}/../gcc/xgcc -B$${rootme}/../gcc/ -idirafter $${rootme}/$(target_subdir)newlib/targ-include -idirafter $${rootsrc}/../$(target_subdir)newlib/libc/include -nostdinc -B$${rootme}/../$(target_subdir)newlib/; \ ++ else \ ++ echo $${rootme}/../gcc/xgcc -B$${rootme}/../gcc/; \ ++ fi; \ ++ else \ ++ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ ++ echo $(CC); \ ++ else \ ++ t='$(program_transform_name)'; echo gcc | sed -e '' $$t; \ ++ fi; \ ++ fi` ++ ++CXX_FOR_TARGET = ` \ ++ if [ -f $${rootme}/../gcc/xg++ ] ; then \ ++ if [ -f $${rootme}/../$(target_subdir)newlib/Makefile ] ; then \ ++ echo $${rootme}/../gcc/xg++ -B$${rootme}/../gcc/ -idirafter $${rootme}/$(target_subdir)newlib/targ-include -idirafter $${rootsrc}/../$(target_subdir)newlib/libc/include -nostdinc -B$${rootme}/../$(target_subdir)newlib/; \ ++ else \ ++ echo $${rootme}/../gcc/xg++ -B$${rootme}/../gcc/; \ ++ fi; \ ++ else \ ++ if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ ++ echo $(CXX); \ ++ else \ ++ t='$(program_transform_name)'; echo g++ | sed -e '' $$t; \ ++ fi; \ ++ fi` ++ ++# The use of $$(x_FOR_TARGET) reduces the command line length by not ++# duplicating the lengthy definition. ++TARGET_FLAGS_TO_PASS = \ ++ "prefix=$(prefix)" \ ++ "exec_prefix=$(exec_prefix)" \ ++ "against=$(against)" \ ++ 'CC=$$(CC_FOR_TARGET)' \ ++ "CC_FOR_TARGET=$(CC_FOR_TARGET)" \ ++ "CFLAGS=$(CFLAGS)" \ ++ 'CXX=$$(CXX_FOR_TARGET)' \ ++ "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \ ++ "CXXFLAGS=$(CXXFLAGS)" \ ++ "INSTALL=$(INSTALL)" \ ++ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ ++ "INSTALL_DATA=$(INSTALL_DATA)" \ ++ "MAKEINFO=$(MAKEINFO)" \ ++ "MAKEHTML=$(MAKEHTML)" \ ++ "RUNTEST=$(RUNTEST)" \ ++ "RUNTESTFLAGS=$(RUNTESTFLAGS)" \ ++ "FORCE_PARALLEL=$(FORCE_PARALLEL)" \ ++ "TESTS=$(TESTS)" ++ ++# All source files that go into linking GDB. ++ ++# Files that should wind up in SFILES and whose corresponding .o ++# should be in COMMON_OBS. ++COMMON_SFILES = \ ++ ada-lang.c \ ++ ada-tasks.c \ ++ ada-typeprint.c \ ++ ada-valprint.c \ ++ ada-varobj.c \ ++ addrmap.c \ ++ agent.c \ ++ alloc.c \ ++ annotate.c \ ++ arch-utils.c \ ++ async-event.c \ ++ auto-load.c \ ++ auxv.c \ ++ ax-gdb.c \ ++ ax-general.c \ ++ bcache.c \ ++ bfd-target.c \ ++ block.c \ ++ blockframe.c \ ++ break-catch-exec.c \ ++ break-catch-fork.c \ ++ break-catch-load.c \ ++ break-catch-sig.c \ ++ break-catch-syscall.c \ ++ break-catch-throw.c \ ++ breakpoint.c \ ++ bt-utils.c \ ++ btrace.c \ ++ build-id.c \ ++ buildsym-legacy.c \ ++ buildsym.c \ ++ c-lang.c \ ++ c-typeprint.c \ ++ c-valprint.c \ ++ c-varobj.c \ ++ charset.c \ ++ cli-out.c \ ++ coff-pe-read.c \ ++ coffread.c \ ++ complaints.c \ ++ completer.c \ ++ copying.c \ ++ corefile.c \ ++ corelow.c \ ++ cp-abi.c \ ++ cp-namespace.c \ ++ cp-support.c \ ++ cp-valprint.c \ ++ ctfread.c \ ++ d-lang.c \ ++ d-namespace.c \ ++ d-valprint.c \ ++ dbxread.c \ ++ dcache.c \ ++ debug.c \ ++ debuginfod-support.c \ ++ dictionary.c \ ++ disasm.c \ ++ displaced-stepping.c \ ++ dummy-frame.c \ ++ dwarf2/abbrev.c \ ++ dwarf2/abbrev-cache.c \ ++ dwarf2/ada-imported.c \ ++ dwarf2/attribute.c \ ++ dwarf2/comp-unit-head.c \ ++ dwarf2/cooked-index.c \ ++ dwarf2/cu.c \ ++ dwarf2/die.c \ ++ dwarf2/dwz.c \ ++ dwarf2/expr.c \ ++ dwarf2/frame-tailcall.c \ ++ dwarf2/frame.c \ ++ dwarf2/index-cache.c \ ++ dwarf2/index-common.c \ ++ dwarf2/index-write.c \ ++ dwarf2/leb.c \ ++ dwarf2/line-header.c \ ++ dwarf2/loc.c \ ++ dwarf2/macro.c \ ++ dwarf2/read.c \ ++ dwarf2/read-debug-names.c \ ++ dwarf2/read-gdb-index.c \ ++ dwarf2/section.c \ ++ dwarf2/stringify.c \ ++ eval.c \ ++ event-top.c \ ++ exceptions.c \ ++ exec.c \ ++ expprint.c \ ++ extension.c \ ++ f-lang.c \ ++ f-typeprint.c \ ++ f-valprint.c \ ++ filename-seen-cache.c \ ++ filesystem.c \ ++ findcmd.c \ ++ findvar.c \ ++ frame.c \ ++ frame-base.c \ ++ frame-unwind.c \ ++ gcore.c \ ++ gdb-demangle.c \ ++ gdb_bfd.c \ ++ gdbtypes.c \ ++ gmp-utils.c \ ++ gnu-v2-abi.c \ ++ gnu-v3-abi.c \ ++ go-lang.c \ ++ go-typeprint.c \ ++ go-valprint.c \ ++ inf-child.c \ ++ inf-loop.c \ ++ infcall.c \ ++ infcmd.c \ ++ inferior.c \ ++ inflow.c \ ++ infrun.c \ ++ inline-frame.c \ ++ interps.c \ ++ jit.c \ ++ language.c \ ++ linespec.c \ ++ location.c \ ++ m2-lang.c \ ++ m2-typeprint.c \ ++ m2-valprint.c \ ++ macrocmd.c \ ++ macroexp.c \ ++ macroscope.c \ ++ macrotab.c \ ++ main.c \ ++ maint.c \ ++ maint-test-options.c \ ++ maint-test-settings.c \ ++ mdebugread.c \ ++ mem-break.c \ ++ memattr.c \ ++ memory-map.c \ ++ memrange.c \ ++ memtag.c \ ++ minidebug.c \ ++ minsyms.c \ ++ mipsread.c \ ++ namespace.c \ ++ objc-lang.c \ ++ objfiles.c \ ++ observable.c \ ++ opencl-lang.c \ ++ osabi.c \ ++ osdata.c \ ++ p-lang.c \ ++ p-typeprint.c \ ++ p-valprint.c \ ++ parse.c \ ++ printcmd.c \ ++ probe.c \ ++ process-stratum-target.c \ ++ producer.c \ ++ progspace.c \ ++ progspace-and-thread.c \ ++ prologue-value.c \ ++ psymtab.c \ ++ record.c \ ++ record-btrace.c \ ++ record-full.c \ ++ regcache.c \ ++ regcache-dump.c \ ++ reggroups.c \ ++ remote.c \ ++ remote-fileio.c \ ++ remote-notif.c \ ++ reverse.c \ ++ run-on-main-thread.c \ ++ rust-lang.c \ ++ rust-parse.c \ ++ sentinel-frame.c \ ++ ser-event.c \ ++ serial.c \ ++ skip.c \ ++ solib.c \ ++ solib-target.c \ ++ source.c \ ++ source-cache.c \ ++ split-name.c \ ++ stabsread.c \ ++ stack.c \ ++ std-regs.c \ ++ symfile.c \ ++ symfile-debug.c \ ++ symmisc.c \ ++ symtab.c \ ++ target.c \ ++ target-connection.c \ ++ target-dcache.c \ ++ target-descriptions.c \ ++ target-memory.c \ ++ test-target.c \ ++ thread.c \ ++ thread-iter.c \ ++ tid-parse.c \ ++ top.c \ ++ tracectf.c \ ++ tracefile.c \ ++ tracefile-tfile.c \ ++ tracepoint.c \ ++ trad-frame.c \ ++ tramp-frame.c \ ++ target-float.c \ ++ type-stack.c \ ++ typeprint.c \ ++ ui.c \ ++ ui-file.c \ ++ ui-out.c \ ++ ui-style.c \ ++ user-regs.c \ ++ utils.c \ ++ valarith.c \ ++ valops.c \ ++ valprint.c \ ++ value.c \ ++ varobj.c \ ++ xml-support.c \ ++ xml-syscall.c \ ++ xml-tdesc.c ++ ++# Links made at configuration time should not be specified here, since ++# SFILES is used in building the distribution archive. ++SFILES = \ ++ ada-exp.y \ ++ arch/i386.c \ ++ c-exp.y \ ++ cp-name-parser.y \ ++ d-exp.y \ ++ dtrace-probe.c \ ++ elf-none-tdep.c \ ++ elfread.c \ ++ f-exp.y \ ++ gcore-elf.c \ ++ gdb.c \ ++ go-exp.y \ ++ m2-exp.y \ ++ p-exp.y \ ++ proc-service.list \ ++ ser-base.c \ ++ ser-unix.c \ ++ sol-thread.c \ ++ stap-probe.c \ ++ stub-termcap.c \ ++ symfile-mem.c \ ++ ui-file.h \ ++ $(SUBDIR_CLI_SRCS) \ ++ $(SUBDIR_MI_SRCS) \ ++ $(SUBDIR_TARGET_SRCS) \ ++ $(COMMON_SFILES) \ ++ $(SUBDIR_GCC_COMPILE_SRCS) ++ ++# Header files that need to have srcdir added. Note that in the cases ++# where we use a macro like $(gdbcmd_h), things are carefully arranged ++# so that each .h file is listed exactly once (M-x tags-search works ++# wrong if TAGS has files twice). Because this is tricky to get ++# right, it is probably easiest just to list .h files here directly. ++ ++HFILES_NO_SRCDIR = \ ++ aarch32-tdep.h \ ++ aarch64-ravenscar-thread.h \ ++ aarch64-tdep.h \ ++ ada-lang.h \ ++ addrmap.h \ ++ alpha-bsd-tdep.h \ ++ alpha-tdep.h \ ++ amd-dbgapi-target.h \ ++ amd64-darwin-tdep.h \ ++ amd64-linux-tdep.h \ ++ amd64-nat.h \ ++ amd64-ravenscar-thread.h \ ++ amd64-tdep.h \ ++ amdgpu-tdep.h \ ++ annotate.h \ ++ arc-tdep.h \ ++ arch-utils.h \ ++ arm-linux-tdep.h \ ++ arm-netbsd-tdep.h \ ++ arm-tdep.h \ ++ async-event.h \ ++ auto-load.h \ ++ auxv.h \ ++ ax.h \ ++ ax-gdb.h \ ++ bcache.h \ ++ bfd-target.h \ ++ bfin-tdep.h \ ++ block.h \ ++ breakpoint.h \ ++ bsd-kvm.h \ ++ bsd-uthread.h \ ++ bt-utils.h \ ++ build-id.h \ ++ buildsym-legacy.h \ ++ buildsym.h \ ++ c-lang.h \ ++ charset.h \ ++ charset-list.h \ ++ cli-out.h \ ++ coff-pe-read.h \ ++ command.h \ ++ complaints.h \ ++ completer.h \ ++ cp-abi.h \ ++ cp-support.h \ ++ csky-tdep.h \ ++ d-lang.h \ ++ darwin-nat.h \ ++ dcache.h \ ++ defs.h \ ++ dicos-tdep.h \ ++ dictionary.h \ ++ disasm-flags.h \ ++ disasm.h \ ++ dummy-frame.h \ ++ dwarf2/cooked-index.h \ ++ dwarf2/cu.h \ ++ dwarf2/frame-tailcall.h \ ++ dwarf2/frame.h \ ++ dwarf2/expr.h \ ++ dwarf2/index-cache.h \ ++ dwarf2/index-common.h \ ++ dwarf2/loc.h \ ++ dwarf2/read.h \ ++ dwarf2/read-debug-names.h \ ++ dwarf2/read-gdb-index.h \ ++ event-top.h \ ++ exceptions.h \ ++ exec.h \ ++ expression.h \ ++ extension.h \ ++ extension-priv.h \ ++ f-array-walker.h \ ++ f-lang.h \ ++ fbsd-nat.h \ ++ fbsd-tdep.h \ ++ filesystem.h \ ++ frame.h \ ++ frame-base.h \ ++ frame-unwind.h \ ++ frv-tdep.h \ ++ ft32-tdep.h \ ++ gcore-elf.h \ ++ gcore.h \ ++ gdb_bfd.h \ ++ gdb_curses.h \ ++ gdb_expat.h \ ++ gdb_proc_service.h \ ++ gdb-stabs.h \ ++ gdb_vfork.h \ ++ gdb_wchar.h \ ++ gdbarch.h \ ++ gdbcmd.h \ ++ gdbcore.h \ ++ gdbthread.h \ ++ gdbtypes.h \ ++ glibc-tdep.h \ ++ gmp-utils.h \ ++ gnu-nat.h \ ++ go-lang.h \ ++ gregset.h \ ++ hppa-bsd-tdep.h \ ++ hppa-linux-offsets.h \ ++ hppa-tdep.h \ ++ i386-bsd-nat.h \ ++ i386-darwin-tdep.h \ ++ i386-linux-nat.h \ ++ i386-linux-tdep.h \ ++ i386-tdep.h \ ++ i387-tdep.h \ ++ ia64-libunwind-tdep.h \ ++ ia64-tdep.h \ ++ inf-child.h \ ++ inf-loop.h \ ++ inf-ptrace.h \ ++ infcall.h \ ++ inferior.h \ ++ inline-frame.h \ ++ interps.h \ ++ jit.h \ ++ language.h \ ++ linespec.h \ ++ linux-fork.h \ ++ linux-nat.h \ ++ linux-record.h \ ++ linux-tdep.h \ ++ location.h \ ++ loongarch-tdep.h \ ++ sw64-tdep.h \ ++ m2-lang.h \ ++ m32r-tdep.h \ ++ m68k-tdep.h \ ++ macroexp.h \ ++ macroscope.h \ ++ macrotab.h \ ++ main.h \ ++ mdebugread.h \ ++ memattr.h \ ++ memory-map.h \ ++ memrange.h \ ++ microblaze-tdep.h \ ++ mips-linux-tdep.h \ ++ mips-netbsd-tdep.h \ ++ mips-tdep.h \ ++ mn10300-tdep.h \ ++ moxie-tdep.h \ ++ netbsd-nat.h \ ++ netbsd-tdep.h \ ++ nds32-tdep.h \ ++ nios2-tdep.h \ ++ elf-none-tdep.h \ ++ nto-tdep.h \ ++ objc-lang.h \ ++ objfiles.h \ ++ obsd-nat.h \ ++ obsd-tdep.h \ ++ or1k-linux-tdep.h \ ++ osabi.h \ ++ osdata.h \ ++ p-lang.h \ ++ parser-defs.h \ ++ ppc-fbsd-tdep.h \ ++ ppc-linux-tdep.h \ ++ ppc-netbsd-tdep.h \ ++ ppc-obsd-tdep.h \ ++ ppc-ravenscar-thread.h \ ++ ppc-tdep.h \ ++ ppc64-tdep.h \ ++ probe.h \ ++ proc-utils.h \ ++ procfs.h \ ++ progspace.h \ ++ progspace-and-thread.h \ ++ prologue-value.h \ ++ psymtab.h \ ++ ravenscar-thread.h \ ++ record.h \ ++ record-full.h \ ++ regcache.h \ ++ reggroups.h \ ++ regset.h \ ++ remote.h \ ++ remote-fileio.h \ ++ remote-notif.h \ ++ riscv-fbsd-tdep.h \ ++ riscv-ravenscar-thread.h \ ++ riscv-tdep.h \ ++ rs6000-aix-tdep.h \ ++ run-on-main-thread.h \ ++ s390-linux-tdep.h \ ++ s390-tdep.h \ ++ selftest-arch.h \ ++ sentinel-frame.h \ ++ ser-base.h \ ++ ser-event.h \ ++ ser-tcp.h \ ++ ser-unix.h \ ++ serial.h \ ++ sh-tdep.h \ ++ sim-regno.h \ ++ skip.h \ ++ sol2-tdep.h \ ++ solib.h \ ++ solib-aix.h \ ++ solib-darwin.h \ ++ solib-svr4.h \ ++ solib-target.h \ ++ solist.h \ ++ source.h \ ++ source-cache.h \ ++ sparc-nat.h \ ++ sparc-ravenscar-thread.h \ ++ sparc-tdep.h \ ++ sparc64-tdep.h \ ++ split-name.h \ ++ stabsread.h \ ++ stack.h \ ++ stap-probe.h \ ++ symfile.h \ ++ symtab.h \ ++ target.h \ ++ target-dcache.h \ ++ target-descriptions.h \ ++ terminal.h \ ++ tid-parse.h \ ++ top.h \ ++ tracectf.h \ ++ tracefile.h \ ++ tracepoint.h \ ++ trad-frame.h \ ++ target-float.h \ ++ tramp-frame.h \ ++ type-stack.h \ ++ typeprint.h \ ++ ui.h \ ++ ui-file.h \ ++ ui-out.h \ ++ ui-style.h \ ++ user-regs.h \ ++ utils.h \ ++ valprint.h \ ++ value.h \ ++ varobj.h \ ++ varobj-iter.h \ ++ vax-tdep.h \ ++ windows-nat.h \ ++ windows-tdep.h \ ++ x86-bsd-nat.h \ ++ x86-linux-nat.h \ ++ x86-nat.h \ ++ xcoffread.h \ ++ xml-builtin.h \ ++ xml-support.h \ ++ xml-syscall.h \ ++ xml-tdesc.h \ ++ xtensa-tdep.h \ ++ arch/aarch32.h \ ++ arch/aarch64.h \ ++ arch/aarch64-insn.h \ ++ arch/aarch64-mte-linux.h \ ++ arch/aarch64-scalable-linux.h \ ++ arch/arc.h \ ++ arch/arm.h \ ++ arch/i386.h \ ++ arch/loongarch.h \ ++ arch/ppc-linux-common.h \ ++ arch/ppc-linux-tdesc.h \ ++ arch/riscv.h \ ++ cli/cli-cmds.h \ ++ cli/cli-decode.h \ ++ cli/cli-script.h \ ++ cli/cli-setshow.h \ ++ cli/cli-style.h \ ++ cli/cli-utils.h \ ++ compile/compile.h \ ++ compile/compile-c.h \ ++ compile/compile-cplus.h \ ++ compile/compile-internal.h \ ++ compile/compile-object-load.h \ ++ compile/compile-object-run.h \ ++ compile/gcc-c-plugin.h \ ++ compile/gcc-cp-plugin.h \ ++ config/nm-linux.h \ ++ config/nm-nto.h \ ++ config/djgpp/langinfo.h \ ++ config/djgpp/nl_types.h \ ++ config/i386/nm-i386gnu.h \ ++ config/sparc/nm-sol2.h \ ++ mi/mi-cmds.h \ ++ mi/mi-common.h \ ++ mi/mi-console.h \ ++ mi/mi-getopt.h \ ++ mi/mi-main.h \ ++ mi/mi-out.h \ ++ mi/mi-parse.h \ ++ nat/aarch64-linux.h \ ++ nat/aarch64-linux-hw-point.h \ ++ nat/aarch64-mte-linux-ptrace.h \ ++ nat/aarch64-scalable-linux-ptrace.h \ ++ nat/aarch64-scalable-linux-sigcontext.h \ ++ nat/amd64-linux-siginfo.h \ ++ nat/gdb_ptrace.h \ ++ nat/gdb_thread_db.h \ ++ nat/fork-inferior.h \ ++ nat/linux-btrace.h \ ++ nat/linux-namespaces.h \ ++ nat/linux-nat.h \ ++ nat/linux-osdata.h \ ++ nat/linux-personality.h \ ++ nat/linux-ptrace.h \ ++ nat/linux-waitpid.h \ ++ nat/mips-linux-watch.h \ ++ nat/ppc-linux.h \ ++ nat/x86-cpuid.h \ ++ nat/x86-dregs.h \ ++ nat/x86-gcc-cpuid.h \ ++ nat/x86-linux.h \ ++ nat/x86-linux-dregs.h \ ++ python/py-event.h \ ++ python/py-events.h \ ++ python/py-stopevent.h \ ++ python/python.h \ ++ python/python-internal.h \ ++ regformats/regdef.h \ ++ target/resume.h \ ++ target/target.h \ ++ target/wait.h \ ++ target/waitstatus.h \ ++ tui/tui.h \ ++ tui/tui-command.h \ ++ tui/tui-data.h \ ++ tui/tui-disasm.h \ ++ tui/tui-file.h \ ++ tui/tui-hooks.h \ ++ tui/tui-io.h \ ++ tui/tui-layout.h \ ++ tui/tui-location.h \ ++ tui/tui-out.h \ ++ tui/tui-regs.h \ ++ tui/tui-source.h \ ++ tui/tui-stack.h \ ++ tui/tui-win.h \ ++ tui/tui-wingeneral.h \ ++ tui/tui-winsource.h \ ++ x86-tdep.h ++ ++# Header files that already have srcdir in them, or which are in objdir. ++ ++HFILES_WITH_SRCDIR = \ ++ ../bfd/bfd.h \ ++ jit-reader.h ++ ++# {X,T,NAT}DEPFILES are something of a pain in that it's hard to ++# default their values the way we do for SER_HARDWIRE; in the future ++# maybe much of the stuff now in {X,T,NAT}DEPFILES will go into other ++# variables analogous to SER_HARDWIRE which get defaulted in this ++# Makefile.in ++ ++DEPFILES = $(TARGET_OBS) $(SER_HARDWIRE) $(NATDEPFILES) $(SIM_OBS) ++ ++ALLDEPFILES = \ ++ arch/aarch32.c \ ++ arch/aarch64.c \ ++ arch/aarch64-insn.c \ ++ arch/aarch64-mte-linux.c \ ++ arch/aarch64-scalable-linux.c \ ++ arch/amd64.c \ ++ arch/arc.c \ ++ arch/arm.c \ ++ arch/arm-get-next-pcs.c \ ++ arch/arm-linux.c \ ++ arch/i386.c \ ++ arch/loongarch.c \ ++ arch/ppc-linux-common.c \ ++ arch/riscv.c \ ++ arch/tic6x.c \ ++ aarch32-tdep.c \ ++ aarch64-fbsd-nat.c \ ++ aarch64-fbsd-tdep.c \ ++ aarch64-linux-nat.c \ ++ aarch64-linux-tdep.c \ ++ aarch64-newlib-tdep.c \ ++ aarch64-ravenscar-thread.c \ ++ aarch64-tdep.c \ ++ aix-thread.c \ ++ alpha-bsd-nat.c \ ++ alpha-bsd-tdep.c \ ++ alpha-linux-nat.c \ ++ alpha-linux-tdep.c \ ++ alpha-mdebug-tdep.c \ ++ alpha-netbsd-tdep.c \ ++ alpha-obsd-tdep.c \ ++ alpha-tdep.c \ ++ amd-dbgapi-target.c \ ++ amd64-bsd-nat.c \ ++ amd64-darwin-tdep.c \ ++ amd64-dicos-tdep.c \ ++ amd64-fbsd-nat.c \ ++ amd64-fbsd-tdep.c \ ++ amd64-linux-nat.c \ ++ amd64-linux-tdep.c \ ++ amd64-nat.c \ ++ amd64-netbsd-nat.c \ ++ amd64-netbsd-tdep.c \ ++ amd64-obsd-nat.c \ ++ amd64-obsd-tdep.c \ ++ amd64-ravenscar-thread.c \ ++ amd64-sol2-tdep.c \ ++ amd64-tdep.c \ ++ amdgpu-tdep.c \ ++ arc-linux-nat.c \ ++ arc-tdep.c \ ++ arm-bsd-tdep.c \ ++ arm-fbsd-nat.c \ ++ arm-fbsd-tdep.c \ ++ arm-linux-nat.c \ ++ arm-linux-tdep.c \ ++ arm-netbsd-nat.c \ ++ arm-netbsd-tdep.c \ ++ arm-none-tdep.c \ ++ arm-obsd-tdep.c \ ++ arm-tdep.c \ ++ avr-tdep.c \ ++ bfin-linux-tdep.c \ ++ bfin-tdep.c \ ++ bpf-tdep.c \ ++ bsd-kvm.c \ ++ bsd-uthread.c \ ++ csky-linux-tdep.c \ ++ csky-tdep.c \ ++ darwin-nat.c \ ++ dicos-tdep.c \ ++ fbsd-nat.c \ ++ fbsd-tdep.c \ ++ fork-child.c \ ++ ft32-tdep.c \ ++ glibc-tdep.c \ ++ go32-nat.c \ ++ h8300-tdep.c \ ++ hppa-bsd-tdep.c \ ++ hppa-linux-nat.c \ ++ hppa-linux-tdep.c \ ++ hppa-netbsd-nat.c \ ++ hppa-netbsd-tdep.c \ ++ hppa-obsd-nat.c \ ++ hppa-obsd-tdep.c \ ++ hppa-tdep.c \ ++ i386-bsd-nat.c \ ++ i386-bsd-tdep.c \ ++ i386-darwin-nat.c \ ++ i386-darwin-tdep.c \ ++ i386-dicos-tdep.c \ ++ i386-fbsd-nat.c \ ++ i386-fbsd-tdep.c \ ++ i386-gnu-nat.c \ ++ i386-gnu-tdep.c \ ++ i386-linux-nat.c \ ++ i386-linux-tdep.c \ ++ i386-netbsd-nat.c \ ++ i386-netbsd-tdep.c \ ++ i386-obsd-nat.c \ ++ i386-obsd-tdep.c \ ++ i386-sol2-nat.c \ ++ i386-sol2-tdep.c \ ++ i386-tdep.c \ ++ i386-windows-tdep.c \ ++ i387-tdep.c \ ++ ia64-libunwind-tdep.c \ ++ ia64-linux-nat.c \ ++ ia64-linux-tdep.c \ ++ ia64-tdep.c \ ++ ia64-vms-tdep.c \ ++ inf-ptrace.c \ ++ linux-fork.c \ ++ linux-record.c \ ++ linux-tdep.c \ ++ lm32-tdep.c \ ++ loongarch-linux-nat.c \ ++ loongarch-linux-tdep.c \ ++ loongarch-tdep.c \ ++ sw64-linux-nat.c \ ++ sw64-linux-tdep.c \ ++ sw64-tdep.c \ ++ m32r-linux-nat.c \ ++ m32r-linux-tdep.c \ ++ m32r-tdep.c \ ++ m68hc11-tdep.c \ ++ m68k-bsd-nat.c \ ++ m68k-bsd-tdep.c \ ++ m68k-linux-nat.c \ ++ m68k-linux-tdep.c \ ++ m68k-tdep.c \ ++ microblaze-linux-tdep.c \ ++ microblaze-tdep.c \ ++ mingw-hdep.c \ ++ mips-fbsd-nat.c \ ++ mips-fbsd-tdep.c \ ++ mips-linux-nat.c \ ++ mips-linux-tdep.c \ ++ mips-netbsd-nat.c \ ++ mips-netbsd-tdep.c \ ++ mips-sde-tdep.c \ ++ mips-tdep.c \ ++ mips64-obsd-nat.c \ ++ mips64-obsd-tdep.c \ ++ msp430-tdep.c \ ++ netbsd-nat.c \ ++ netbsd-tdep.c \ ++ nds32-tdep.c \ ++ nios2-linux-tdep.c \ ++ nios2-tdep.c \ ++ obsd-nat.c \ ++ obsd-tdep.c \ ++ or1k-linux-nat.c \ ++ posix-hdep.c \ ++ ppc-fbsd-nat.c \ ++ ppc-fbsd-tdep.c \ ++ ppc-linux-nat.c \ ++ ppc-linux-tdep.c \ ++ ppc-netbsd-nat.c \ ++ ppc-netbsd-tdep.c \ ++ ppc-obsd-nat.c \ ++ ppc-obsd-tdep.c \ ++ ppc-ravenscar-thread.c \ ++ ppc-sysv-tdep.c \ ++ ppc64-tdep.c \ ++ procfs.c \ ++ ravenscar-thread.c \ ++ remote-sim.c \ ++ riscv-fbsd-nat.c \ ++ riscv-fbsd-tdep.c \ ++ riscv-linux-nat.c \ ++ riscv-linux-tdep.c \ ++ riscv-none-tdep.c \ ++ riscv-ravenscar-thread.c \ ++ riscv-tdep.c \ ++ rl78-tdep.c \ ++ rs6000-aix-nat.c \ ++ rs6000-lynx178-tdep.c \ ++ rs6000-tdep.c \ ++ rx-tdep.c \ ++ s390-linux-nat.c \ ++ s390-linux-tdep.c \ ++ s390-tdep.c \ ++ ser-go32.c \ ++ ser-mingw.c \ ++ ser-pipe.c \ ++ ser-tcp.c \ ++ ser-uds.c \ ++ sh-netbsd-nat.c \ ++ sh-netbsd-tdep.c \ ++ sh-tdep.c \ ++ sol2-tdep.c \ ++ solib-aix.c \ ++ solib-rocm.c \ ++ solib-svr4.c \ ++ sparc-linux-nat.c \ ++ sparc-linux-tdep.c \ ++ sparc-nat.c \ ++ sparc-netbsd-nat.c \ ++ sparc-netbsd-tdep.c \ ++ sparc-obsd-tdep.c \ ++ sparc-ravenscar-thread.c \ ++ sparc-sol2-nat.c \ ++ sparc-sol2-tdep.c \ ++ sparc-tdep.c \ ++ sparc64-fbsd-nat.c \ ++ sparc64-fbsd-tdep.c \ ++ sparc64-linux-nat.c \ ++ sparc64-linux-tdep.c \ ++ sparc64-nat.c \ ++ sparc64-netbsd-nat.c \ ++ sparc64-netbsd-tdep.c \ ++ sparc64-obsd-nat.c \ ++ sparc64-obsd-tdep.c \ ++ sparc64-sol2-tdep.c \ ++ sparc64-tdep.c \ ++ tilegx-linux-nat.c \ ++ tilegx-linux-tdep.c \ ++ tilegx-tdep.c \ ++ v850-tdep.c \ ++ vax-bsd-nat.c \ ++ vax-netbsd-tdep.c \ ++ vax-tdep.c \ ++ windows-nat.c \ ++ windows-tdep.c \ ++ x86-nat.c \ ++ x86-tdep.c \ ++ xcoffread.c \ ++ xstormy16-tdep.c \ ++ xtensa-config.c \ ++ xtensa-linux-nat.c \ ++ xtensa-linux-tdep.c \ ++ xtensa-tdep.c \ ++ xtensa-xtregs.c ++ ++# Don't include YYFILES (*.c) because we already include *.y in SFILES, ++# and it's more useful to see it in the .y file. ++TAGFILES_NO_SRCDIR = $(SFILES) $(HFILES_NO_SRCDIR) $(ALLDEPFILES) \ ++ $(CONFIG_SRCS) ++TAGFILES_WITH_SRCDIR = $(HFILES_WITH_SRCDIR) ++ ++COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ ++ mi/mi-common.o \ ++ version.o \ ++ xml-builtin.o \ ++ $(patsubst %.c,%.o,$(COMMON_SFILES)) \ ++ $(SUBDIR_CLI_OBS) \ ++ $(SUBDIR_MI_OBS) \ ++ $(SUBDIR_TARGET_OBS) \ ++ $(SUBDIR_GCC_COMPILE_OBS) ++ ++SUBDIRS = doc @subdirs@ data-directory ++CLEANDIRS = $(SUBDIRS) ++ ++# List of subdirectories in the build tree that must exist. ++# This is used to force build failures in existing trees when ++# a new directory is added. ++# The format here is for the `case' shell command. ++REQUIRED_SUBDIRS = doc | testsuite | data-directory ++ ++# Parser intermediate files. ++YYFILES = \ ++ ada-exp.c \ ++ ada-lex.c \ ++ c-exp.c \ ++ cp-name-parser.c \ ++ d-exp.c \ ++ f-exp.c \ ++ go-exp.c \ ++ m2-exp.c \ ++ p-exp.c ++ ++# ada-lex.c is included by another file, so it shouldn't wind up as a ++# .o itself. ++YYOBJ = $(filter-out ada-lex.o,$(patsubst %.c,%.o,$(YYFILES))) ++ ++# Things which need to be built when making a distribution. ++ ++DISTSTUFF = $(YYFILES) ++ ++ ++# All generated files which can be included by another file. ++generated_files = \ ++ ada-lex.c \ ++ config.h \ ++ jit-reader.h \ ++ $(NAT_GENERATED_FILES) \ ++ $(NM_H) ++ ++# Flags needed to compile Python code ++PYTHON_CFLAGS = @PYTHON_CFLAGS@ ++ ++all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb ++ @$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=$(SUBDIRS)" subdir_do ++ ++# Rule for compiling .c files in the top-level gdb directory. ++# The order-only dependencies ensure that we create the build subdirectories. ++%.o: %.c | $(CONFIG_DEP_SUBDIR) ++ $(COMPILE) $< ++ $(POSTCOMPILE) ++ ++$(CONFIG_DEP_SUBDIR): ++ $(SHELL) $(srcdir)/../mkinstalldirs $@ ++ ++# Python files need special flags. ++python/%.o: INTERNAL_CFLAGS += $(PYTHON_CFLAGS) ++ ++# Rules for compiling .c files in the various source subdirectories. ++%.o: $(srcdir)/gdbtk/generic/%.c ++ $(COMPILE) $(all_gdbtk_cflags) $< ++ $(POSTCOMPILE) ++ ++installcheck: ++ ++# The check target can not use subdir_do, because subdir_do does not ++# use TARGET_FLAGS_TO_PASS. ++check: force ++ @if [ -f testsuite/Makefile ]; then \ ++ rootme=`pwd`; export rootme; \ ++ rootsrc=`cd $(srcdir); pwd`; export rootsrc; \ ++ cd testsuite; \ ++ $(MAKE) $(TARGET_FLAGS_TO_PASS) check; \ ++ else true; fi ++ ++check-perf: force ++ @if [ -f testsuite/Makefile ]; then \ ++ rootme=`pwd`; export rootme; \ ++ rootsrc=`cd $(srcdir); pwd`; export rootsrc; \ ++ cd testsuite; \ ++ $(MAKE) $(TARGET_FLAGS_TO_PASS) check-perf; \ ++ else true; fi ++ ++check-read1 check-readmore: force ++ @if [ -f testsuite/Makefile ]; then \ ++ rootme=`pwd`; export rootme; \ ++ rootsrc=`cd $(srcdir); pwd`; export rootsrc; \ ++ cd testsuite; \ ++ $(MAKE) $(TARGET_FLAGS_TO_PASS) $@; \ ++ else true; fi ++ ++check-parallel: force ++ @if [ -f testsuite/Makefile ]; then \ ++ rootme=`pwd`; export rootme; \ ++ rootsrc=`cd $(srcdir); pwd`; export rootsrc; \ ++ cd testsuite; \ ++ $(MAKE) $(TARGET_FLAGS_TO_PASS) check-parallel; \ ++ else true; fi ++ ++# The idea is to parallelize testing of multilibs, for example: ++# make -j3 check//sh-hms-sim/{-m1,-m2,-m3,-m3e,-m4}/{,-nofpu} ++# will run 3 concurrent sessions of check, eventually testing all 10 ++# combinations. GNU make is required for the % pattern to work, as is ++# a shell that expands alternations within braces. If GNU make is not ++# used, this rule will harmlessly fail to match. Used FORCE_PARALLEL to ++# prevent serialized checking due to the passed RUNTESTFLAGS. ++# FIXME: use config.status --config not --version, when available. ++check//%: force ++ @if [ -f testsuite/config.status ]; then \ ++ rootme=`pwd`; export rootme; \ ++ rootsrc=`cd $(srcdir); pwd`; export rootsrc; \ ++ target=`echo "$@" | sed 's,//.*,,'`; \ ++ variant=`echo "$@" | sed 's,^[^/]*//,,'`; \ ++ vardots=`echo "$$variant" | sed 's,/,.,g'`; \ ++ testdir=testsuite.$$vardots; \ ++ if [ ! -f $$testdir/Makefile ] && [ -f testsuite/config.status ]; then \ ++ configargs=`cd testsuite && ./config.status --version | \ ++ sed -n -e 's,"$$,,' -e 's,^ *with options ",,p'`; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs $$testdir && \ ++ (cd $$testdir && \ ++ eval $(SHELL) "\"\$$rootsrc/testsuite/configure\" $$configargs" \ ++ "\"--srcdir=\$$rootsrc/testsuite\"" \ ++ ); \ ++ else :; fi && cd $$testdir && \ ++ $(MAKE) $(TARGET_FLAGS_TO_PASS) \ ++ RUNTESTFLAGS="--target_board=$$variant $(RUNTESTFLAGS)" \ ++ FORCE_PARALLEL=$(if $(FORCE_PARALLEL),1,$(if $(RUNTESTFLAGS),,1)) \ ++ "$$target"; \ ++ else true; fi ++ ++# The set of headers checked by 'check-headers' by default. ++CHECK_HEADERS = $(HFILES_NO_SRCDIR) ++ ++# Try to compile each header in isolation, thus ensuring headers are ++# self-contained. ++# ++# Defaults to checking all $HFILES_NO_SRCDIR headers. ++# ++# Do: ++# ++# make check-headers CHECK_HEADERS="header.h list.h" ++# ++# to check specific headers. ++# ++check-headers: ++ @echo Checking headers. ++ for i in $(CHECK_HEADERS) ; do \ ++ $(CXX) $(CXX_DIALECT) -x c++-header -c -fsyntax-only \ ++ $(INTERNAL_CFLAGS) $(CXXFLAGS) -include defs.h $(srcdir)/$$i ; \ ++ done ++.PHONY: check-headers ++ ++info install-info clean-info dvi pdf install-pdf html install-html: force ++ @$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do ++ ++# Traditionally "install" depends on "all". But it may be useful ++# not to; for example, if the user has made some trivial change to a ++# source file and doesn't care about rebuilding or just wants to save the ++# time it takes for make to check that all is up to date. ++# install-only is intended to address that need. ++install: all ++ @$(MAKE) $(FLAGS_TO_PASS) install-only ++ ++install-only: $(CONFIG_INSTALL) ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo gdb | sed -e "$$t"` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=gdb ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \ ++ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) \ ++ gdb$(EXEEXT) \ ++ $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(includedir)/gdb ; \ ++ $(INSTALL_DATA) jit-reader.h $(DESTDIR)$(includedir)/gdb/jit-reader.h ++ if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" != x; \ ++ then \ ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo gcore | sed -e "$$t"` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=gcore ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) ; \ ++ $(INSTALL_SCRIPT) gcore \ ++ $(DESTDIR)$(bindir)/$$transformed_name; \ ++ fi ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo gdb-add-index | sed -e "$$t"` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=gdb-add-index ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ $(INSTALL_SCRIPT) $(srcdir)/contrib/gdb-add-index.sh \ ++ $(DESTDIR)$(bindir)/$$transformed_name ++ @$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do ++ ++install-strip: ++ $(MAKE) $(FLAGS_TO_PASS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ ++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ ++ `test -z '$(STRIP)' || \ ++ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install-only ++ ++install-guile: ++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/guile/gdb ++ ++install-python: ++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb ++ ++uninstall: force $(CONFIG_UNINSTALL) ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo gdb | sed -e $$t` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=gdb ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ++ rm -f $(DESTDIR)$(includedir)/gdb/jit-reader.h ++ if test "x$(HAVE_NATIVE_GCORE_TARGET)$(HAVE_NATIVE_GCORE_HOST)" != x; \ ++ then \ ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo gcore | sed -e "$$t"` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=gcore ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ rm -f $(DESTDIR)$(bindir)/$$transformed_name; \ ++ fi ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo gdb-add-index | sed -e "$$t"` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=gdb-add-index ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ rm -f $(DESTDIR)$(bindir)/$$transformed_name ++ @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do ++ ++# The C++ name parser can be built standalone for testing. ++test-cp-name-parser.o: cp-name-parser.c ++ $(COMPILE) -DTEST_CPNAMES cp-name-parser.c ++ $(POSTCOMPILE) ++ ++test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY) ++ $(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) \ ++ -o test-cp-name-parser$(EXEEXT) test-cp-name-parser.o \ ++ $(LIBIBERTY) ++ ++# We do this by grepping through sources. If that turns out to be too slow, ++# maybe we could just require every .o file to have an initialization routine ++# of a given name (top.o -> _initialize_top, etc.). ++# ++# Note that the set of files with init functions might change, or the names ++# of the functions might change, so this files needs to depend on all the ++# source files that will be linked into gdb. However, due to the way ++# this Makefile has generally been written, we do this indirectly, by ++# computing the list of source files from the list of object files. ++ ++INIT_FILES_FILTER_OUT = \ ++ cp-name-parser.o \ ++ init.o \ ++ version.o \ ++ xml-builtin.o \ ++ %_S.o \ ++ %_U.o ++ ++INIT_FILES = \ ++ $(patsubst %.o,%.c, \ ++ $(patsubst %-exp.o,%-exp.y, \ ++ $(filter-out $(INIT_FILES_FILTER_OUT), $(COMMON_OBS)))) ++ ++init.c: stamp-init; @true ++stamp-init: $(INIT_FILES) config.status $(srcdir)/make-init-c ++ $(ECHO_INIT_C) ++ $(SILENCE) $(srcdir)/make-init-c $(addprefix $(srcdir)/,$(INIT_FILES)) > init.c-tmp ++ $(SILENCE) $(SHELL) $(srcdir)/../move-if-change init.c-tmp init.c ++ $(SILENCE) echo stamp > stamp-init ++ ++.PRECIOUS: init.c ++ ++# Create a library of the gdb object files and build GDB by linking ++# against that. ++# ++# init.o is very important. It pulls in the rest of GDB. ++LIBGDB_OBS = $(sort $(COMMON_OBS)) init.o ++libgdb.a: $(LIBGDB_OBS) ++ -rm -f libgdb.a ++ $(AR) q libgdb.a $(LIBGDB_OBS) ++ $(RANLIB) libgdb.a ++ ++# Removing the old gdb first works better if it is running, at least on SunOS. ++gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(CDEPS) $(TDEPLIBS) ++ $(SILENCE) rm -f gdb$(EXEEXT) ++ $(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \ ++ -o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \ ++ $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES) ++ifneq ($(CODESIGN_CERT),) ++ $(ECHO_SIGN) $(CODESIGN) -s $(CODESIGN_CERT) gdb$(EXEEXT) ++endif ++ ++# This is useful when debugging GDB, because some Unix's don't let you run GDB ++# on itself without copying the executable. So "make gdb1" will make ++# gdb and put a copy in gdb1, and you can run it with "gdb gdb1". ++# Removing gdb1 before the copy is the right thing if gdb1 is open ++# in another process. ++gdb1$(EXEEXT): gdb$(EXEEXT) ++ rm -f gdb1$(EXEEXT) ++ cp gdb$(EXEEXT) gdb1$(EXEEXT) ++ ++# Put the proper machine-specific files first, so M-. on a machine ++# specific routine gets the one for the correct machine. (FIXME: those ++# files go in twice; we should be removing them from the main list). ++ ++# TAGS depends on all the files that go into it so you can rebuild TAGS ++# with `make TAGS' and not have to say `rm TAGS' first. ++ ++GDB_NM_FILE = @GDB_NM_FILE@ ++TAGS: $(TAGFILES_NO_SRCDIR) $(TAGFILES_WITH_SRCDIR) ++ @echo Making TAGS ++ etags `(test -n "$(GDB_NM_FILE)" && echo "$(srcdir)/$(GDB_NM_FILE)")` \ ++ `(for i in $(DEPFILES) $(TAGFILES_NO_SRCDIR); do \ ++ echo $(srcdir)/$$i ; \ ++ done ; for i in $(TAGFILES_WITH_SRCDIR); do \ ++ echo $$i ; \ ++ done) | sed -e 's/\.o$$/\.c/'` \ ++ `find $(srcdir)/config -name '*.h' -print` ++ ++tags: TAGS ++ ++clean mostlyclean: $(CONFIG_CLEAN) ++ @$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do ++ rm -f *.o *.a *~ init.c-tmp init.l-tmp version.c-tmp ++ rm -f init.c stamp-init version.c stamp-version ++ rm -f gdb$(EXEEXT) core make.log ++ rm -f gdb[0-9]$(EXEEXT) ++ rm -f test-cp-name-parser$(EXEEXT) ++ rm -f xml-builtin.c stamp-xml ++ rm -f $(DEPDIR)/* ++ for i in $(CONFIG_SRC_SUBDIR); do \ ++ rm -f $$i/*.o; \ ++ rm -f $$i/$(DEPDIR)/*; \ ++ done ++ ++# This used to depend on c-exp.c m2-exp.c TAGS ++# I believe this is wrong; the makefile standards for distclean just ++# describe removing files; the only sort of "re-create a distribution" ++# functionality described is if the distributed files are unmodified. ++distclean: clean ++ @$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(CLEANDIRS)" subdir_do ++ rm -f nm.h config.status config.h stamp-h b jit-reader.h gcore stamp-nmh ++ rm -f gdb-gdb.py gdb-gdb.gdb ++ rm -f y.output yacc.acts yacc.tmp y.tab.h ++ rm -f config.log config.cache ++ rm -f config.lt libtool ++ rm -f Makefile ++ rm -rf $(DEPDIR) ++ for i in $(CONFIG_SRC_SUBDIR); do \ ++ if test -d $$i/$(DEPDIR); then rmdir $$i/$(DEPDIR); fi \ ++ done ++ ++maintainer-clean: local-maintainer-clean do-maintainer-clean distclean ++realclean: maintainer-clean ++ ++local-maintainer-clean: ++ @echo "This command is intended for maintainers to use;" ++ @echo "it deletes files that may require special tools to rebuild." ++ rm -f c-exp.c \ ++ cp-name-parser.c \ ++ ada-lex.c ada-exp.c \ ++ d-exp.c f-exp.c go-exp.c m2-exp.c p-exp.c ++ rm -f TAGS ++ rm -f $(YYFILES) ++ rm -f nm.h config.status ++ ++do-maintainer-clean: ++ @$(MAKE) $(FLAGS_TO_PASS) DO=maintainer-clean "DODIRS=$(CLEANDIRS)" \ ++ subdir_do ++ ++diststuff: $(DISTSTUFF) $(PACKAGE).pot $(CATALOGS) ++ cd doc; $(MAKE) $(MFLAGS) diststuff ++ ++subdir_do: force ++ @for i in $(DODIRS); do \ ++ case $$i in \ ++ $(REQUIRED_SUBDIRS)) \ ++ if [ ! -f ./$$i/Makefile ] ; then \ ++ echo "Missing $$i/Makefile" >&2 ; \ ++ exit 1 ; \ ++ fi ;; \ ++ esac ; \ ++ if [ -f ./$$i/Makefile ] ; then \ ++ if (cd ./$$i; \ ++ $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \ ++ else exit 1 ; fi ; \ ++ else true ; fi ; \ ++ done ++ ++Makefile: Makefile.in config.status ++ $(SHELL) config.status $@ ++ ++.PHONY: run ++run: Makefile ++ ./gdb$(EXEEXT) --data-directory=`pwd`/data-directory $(GDBFLAGS) ++ ++jit-reader.h: $(srcdir)/jit-reader.in ++ $(SHELL) config.status $@ ++ ++gcore: $(srcdir)/gcore.in ++ $(SHELL) config.status $@ ++ ++gdb-gdb.py: $(srcdir)/gdb-gdb.py.in ++ $(SHELL) config.status $@ ++ ++gdb-gdb.gdb: $(srcdir)/gdb-gdb.gdb.in ++ $(SHELL) config.status $@ ++ ++config.h: stamp-h ; @true ++stamp-h: $(srcdir)/config.in config.status ++ $(SHELL) config.status config.h ++ ++nm.h: stamp-nmh ; @true ++stamp-nmh: config.status ++ $(SHELL) config.status nm.h ++ ++config.status: $(srcdir)/configure configure.nat configure.tgt configure.host ../bfd/development.sh ++ $(SHELL) config.status --recheck ++ ++ACLOCAL = aclocal ++ACLOCAL_AMFLAGS = -I ../config ++ ++# Keep these in sync with the includes in acinclude.m4. ++aclocal_m4_deps = \ ++ configure.ac \ ++ acx_configure_dir.m4 \ ++ transform.m4 \ ++ ../bfd/bfd.m4 \ ++ ../config/acinclude.m4 \ ++ ../config/enable.m4 \ ++ ../config/plugins.m4 \ ++ ../config/lead-dot.m4 \ ++ ../config/override.m4 \ ++ ../config/largefile.m4 \ ++ ../config/gettext-sister.m4 \ ++ ../config/lib-ld.m4 \ ++ ../config/lib-prefix.m4 \ ++ ../config/lib-link.m4 \ ++ ../config/acx.m4 \ ++ ../config/tcl.m4 \ ++ ../config/depstand.m4 \ ++ ../config/lcmessage.m4 \ ++ ../config/codeset.m4 \ ++ ../config/zlib.m4 \ ++ ../config/zstd.m4 \ ++ ../config/ax_pthread.m4 ++ ++$(srcdir)/aclocal.m4: @MAINTAINER_MODE_TRUE@ $(aclocal_m4_deps) ++ cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) ++ ++AUTOCONF = autoconf ++configure_deps = $(srcdir)/configure.ac $(srcdir)/aclocal.m4 ++$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(configure_deps) ++ cd $(srcdir) && $(AUTOCONF) ++ ++AUTOHEADER = autoheader ++$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@ $(configure_deps) ++ cd $(srcdir) && $(AUTOHEADER) ++ rm -f stamp-h ++ touch $@ ++ ++# automatic rebuilding in automake-generated Makefiles requires ++# this rule in the toplevel Makefile, which, with GNU make, causes ++# the desired updates through the implicit regeneration of the Makefile ++# and all of its prerequisites. ++am--refresh: ++ @: ++ ++force: ++ ++# Documentation! ++# GDB QUICK REFERENCE (TeX dvi file, CM fonts) ++doc/refcard.dvi: ++ cd doc; $(MAKE) refcard.dvi $(FLAGS_TO_PASS) ++ ++# GDB QUICK REFERENCE (PostScript output, common PS fonts) ++doc/refcard.ps: ++ cd doc; $(MAKE) refcard.ps $(FLAGS_TO_PASS) ++ ++# GDB MANUAL: TeX dvi file ++doc/gdb.dvi: ++ cd doc; $(MAKE) gdb.dvi $(FLAGS_TO_PASS) ++ ++# GDB MANUAL: info file ++doc/gdb.info: ++ cd doc; $(MAKE) gdb.info $(FLAGS_TO_PASS) ++ ++# Make copying.c from COPYING ++$(srcdir)/copying.c: @MAINTAINER_MODE_TRUE@ $(srcdir)/../COPYING3 $(srcdir)/copying.awk ++ awk -f $(srcdir)/copying.awk \ ++ < $(srcdir)/../COPYING3 > $(srcdir)/copying.tmp ++ mv $(srcdir)/copying.tmp $(srcdir)/copying.c ++ ++version.c: stamp-version; @true ++# Note that the obvious names for the temp file are taken by ++# create-version.sh. ++stamp-version: Makefile version.in $(srcdir)/../bfd/version.h $(srcdir)/../gdbsupport/create-version.sh ++ $(ECHO_GEN) $(SHELL) $(srcdir)/../gdbsupport/create-version.sh $(srcdir) \ ++ $(host_alias) $(target_alias) version-t.t ++ @$(SHELL) $(srcdir)/../move-if-change version-t.t version.c ++ @echo stamp > stamp-version ++ ++ ++gdb.cxref: $(SFILES) ++ cxref -I. $(SFILES) >gdb.cxref ++ ++force_update: ++ ++# GNU Make has an annoying habit of putting *all* the Makefile variables ++# into the environment, unless you include this target as a circumvention. ++# Rumor is that this will be fixed (and this target can be removed) ++# in GNU Make 4.0. ++.NOEXPORT: ++ ++# GNU Make 3.63 has a different problem: it keeps tacking command line ++# overrides onto the definition of $(MAKE). This variable setting ++# will remove them. ++MAKEOVERRIDES = ++ ++# Some files need explicit build rules (due to -Werror problems) or due ++# to sub-directory fun 'n' games. ++ ++# ada-exp.c can appear in srcdir, for releases; or in ., for ++# development builds. ++ADA_EXP_C = `if test -f ada-exp.c; then echo ada-exp.c; else echo $(srcdir)/ada-exp.c; fi` ++ ++ada-exp.o: ada-exp.c ++ $(COMPILE) $(ADA_EXP_C) ++ $(POSTCOMPILE) ++ ++# Message files. Based on code in gcc/Makefile.in. ++ ++# Rules for generating translated message descriptions. Disabled by ++# autoconf if the tools are not available. ++ ++.PHONY: all-po install-po uninstall-po clean-po update-po $(PACKAGE).pot ++ ++all-po: $(CATALOGS) ++ ++# This notation should be acceptable to all Make implementations used ++# by people who are interested in updating .po files. ++update-po: $(CATALOGS:.gmo=.pox) ++ ++# N.B. We do not attempt to copy these into $(srcdir). The snapshot ++# script does that. ++%.gmo: %.po ++ -test -d po || mkdir po ++ $(GMSGFMT) --statistics -o $@ $< ++ ++# The new .po has to be gone over by hand, so we deposit it into ++# build/po with a different extension. If build/po/$(PACKAGE).pot ++# exists, use it (it was just created), else use the one in srcdir. ++%.pox: %.po ++ -test -d po || mkdir po ++ $(MSGMERGE) $< `if test -f po/$(PACKAGE).pot; \ ++ then echo po/$(PACKAGE).pot; \ ++ else echo $(srcdir)/po/$(PACKAGE).pot; fi` -o $@ ++ ++# This rule has to look for .gmo modules in both srcdir and the cwd, ++# and has to check that we actually have a catalog for each language, ++# in case they weren't built or included with the distribution. ++install-po: ++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(datadir) ++ cats="$(CATALOGS)"; for cat in $$cats; do \ ++ lang=`basename $$cat | sed 's/\.gmo$$//'`; \ ++ if [ -f $$cat ]; then :; \ ++ elif [ -f $(srcdir)/$$cat ]; then cat=$(srcdir)/$$cat; \ ++ else continue; \ ++ fi; \ ++ dir=$(localedir)/$$lang/LC_MESSAGES; \ ++ echo $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$$dir; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$$dir || exit 1; \ ++ echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE).mo; \ ++ $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE).mo; \ ++ done ++uninstall-po: ++ cats="$(CATALOGS)"; for cat in $$cats; do \ ++ lang=`basename $$cat | sed 's/\.gmo$$//'`; \ ++ if [ -f $$cat ]; then :; \ ++ elif [ -f $(srcdir)/$$cat ]; then cat=$(srcdir)/$$cat; \ ++ else continue; \ ++ fi; \ ++ dir=$(localedir)/$$lang/LC_MESSAGES; \ ++ rm -f $(DESTDIR)$$dir/$(PACKAGE).mo; \ ++ done ++# Delete po/*.gmo only if we are not building in the source directory. ++clean-po: ++ -if [ ! -f Makefile.in ]; then rm -f po/*.gmo; fi ++ ++# Rule for regenerating the message template (gdb.pot). Instead of ++# forcing everyone to edit POTFILES.in, which proved impractical, this ++# rule has no dependencies and always regenerates gdb.pot. This is ++# relatively harmless since the .po files do not directly depend on ++# it. The .pot file is left in the build directory. Since GDB's ++# Makefile lacks a cannonical list of sources (missing xm, tm and nm ++# files) force this rule. ++$(PACKAGE).pot: po/$(PACKAGE).pot ++po/$(PACKAGE).pot: force ++ -test -d po || mkdir po ++ sh -e $(srcdir)/po/gdbtext $(XGETTEXT) $(PACKAGE) . $(srcdir) ++ ++ ++# ++# YACC/LEX dependencies ++# ++# LANG-exp.c is generated in objdir from LANG-exp.y if it doesn't ++# exist in srcdir, then compiled in objdir to LANG-exp.o. If we ++# said LANG-exp.c rather than ./c-exp.c some makes would ++# sometimes re-write it into $(srcdir)/c-exp.c. Remove bogus ++# decls for malloc/realloc/free which conflict with everything else. ++# Strictly speaking c-exp.c should therefore depend on ++# Makefile.in, but that was a pretty big annoyance. ++ ++%.c: %.y ++ $(ECHO_YACC) $(SHELL) $(YLWRAP) $< y.tab.c $@.tmp -- \ ++ $(YACC) $(YFLAGS) || (rm -f $@.tmp; false) ++ @sed -e '/extern.*malloc/d' \ ++ -e '/extern.*realloc/d' \ ++ -e '/extern.*free/d' \ ++ -e '/include.*malloc.h/d' \ ++ -e 's/\([^x]\)malloc/\1xmalloc/g' \ ++ -e 's/\([^x]\)realloc/\1xrealloc/g' \ ++ -e 's/\([ \t;,(]\)free\([ \t]*[&(),]\)/\1xfree\2/g' \ ++ -e 's/\([ \t;,(]\)free$$/\1xfree/g' \ ++ -e '/^#line.*y.tab.c/d' \ ++ -e 's/YY_NULL/YY_NULLPTR/g' \ ++ -e "s/YYSTYPE/$(subst -,_,$*)_YYSTYPE/g" \ ++ -e "s/yyalloc/$(subst -,_,$*)_yyalloc/g" \ ++ -e "s/yysymbol_kind_t/$(subst -,_,$*)_yysymbol_kind_t/g" \ ++ < $@.tmp > $@.new && \ ++ rm -f $@.tmp && \ ++ mv $@.new $@ ++%.c: %.l ++ $(ECHO_LEX) $(FLEX) -t $< > $@.tmp || (rm -f $@.tmp; false) ++ @sed -e '/extern.*malloc/d' \ ++ -e '/extern.*realloc/d' \ ++ -e '/extern.*free/d' \ ++ -e '/include.*malloc.h/d' \ ++ -e 's/\([^x]\)malloc/\1xmalloc/g' \ ++ -e 's/\([^x]\)realloc/\1xrealloc/g' \ ++ -e 's/\([ \t;,(]\)free\([ \t]*[&(),]\)/\1xfree\2/g' \ ++ -e 's/\([ \t;,(]\)free$$/\1xfree/g' \ ++ -e 's/yy_flex_xrealloc/yyxrealloc/g' \ ++ < $@.tmp > $@.new && \ ++ rm -f $@.tmp && \ ++ mv $@.new $@ ++ ++# XML rules ++ ++xml-builtin.c: stamp-xml; @true ++stamp-xml: $(srcdir)/features/feature_to_c.sh Makefile $(XMLFILES) ++ $(SILENCE) rm -f xml-builtin.tmp ++ $(ECHO_GEN_XML_BUILTIN) AWK="$(AWK)" \ ++ $(SHELL) $(srcdir)/features/feature_to_c.sh \ ++ xml-builtin.tmp $(XMLFILES) ++ $(SILENCE) $(SHELL) $(srcdir)/../move-if-change xml-builtin.tmp xml-builtin.c ++ $(SILENCE) echo stamp > stamp-xml ++ ++.PRECIOUS: xml-builtin.c ++ ++# ++# GDBTK sub-directory ++# ++ ++all-gdbtk: insight$(EXEEXT) ++ ++install-gdbtk: ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo insight | sed -e $$t` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=insight ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir); \ ++ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) \ ++ insight$(EXEEXT) \ ++ $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs \ ++ $(DESTDIR)$(GDBTK_LIBRARY) ; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs \ ++ $(DESTDIR)$(libdir)/insight$(GDBTK_VERSION) ; \ ++ $(INSTALL_DATA) $(srcdir)/gdbtk/plugins/plugins.tcl \ ++ $(DESTDIR)$(libdir)/insight$(GDBTK_VERSION)/plugins.tcl ; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs \ ++ $(DESTDIR)$(GDBTK_LIBRARY)/images \ ++ $(DESTDIR)$(GDBTK_LIBRARY)/images2 ; \ ++ $(SHELL) $(srcdir)/../mkinstalldirs \ ++ $(DESTDIR)$(GDBTK_LIBRARY)/help \ ++ $(DESTDIR)$(GDBTK_LIBRARY)/help/images \ ++ $(DESTDIR)$(GDBTK_LIBRARY)/help/trace ; \ ++ cd $(srcdir)/gdbtk/library ; \ ++ for i in *.tcl *.itcl *.ith *.itb images/*.gif images2/*.gif images/icons.txt images2/icons.txt tclIndex help/*.html help/trace/*.html help/trace/index.toc help/images/*.gif help/images/*.png; \ ++ do \ ++ $(INSTALL_DATA) $$i $(DESTDIR)$(GDBTK_LIBRARY)/$$i ; \ ++ done ; ++ ++uninstall-gdbtk: ++ transformed_name=`t='$(program_transform_name)'; \ ++ echo insight | sed -e $$t` ; \ ++ if test "x$$transformed_name" = x; then \ ++ transformed_name=insight ; \ ++ else \ ++ true ; \ ++ fi ; \ ++ rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \ ++ rm -rf $(DESTDIR)$(GDBTK_LIBRARY) ++ ++clean-gdbtk: ++ rm -f insight$(EXEEXT) ++ ++# Removing the old gdb first works better if it is running, at least on SunOS. ++insight$(EXEEXT): gdbtk-main.o libgdb.a $(CDEPS) $(TDEPLIBS) ++ rm -f insight$(EXEEXT) ++ $(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \ ++ -o insight$(EXEEXT) gdbtk-main.o libgdb.a \ ++ $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES) ++ ++gdbres.o: $(srcdir)/gdbtk/gdb.rc $(srcdir)/gdbtk/gdbtool.ico ++ $(WINDRES) --include $(srcdir)/gdbtk $(srcdir)/gdbtk/gdb.rc gdbres.o ++ ++all_gdbtk_cflags = $(IDE_CFLAGS) $(ITCL_CFLAGS) \ ++ $(ITK_CFLAGS) $(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS) \ ++ $(GDBTK_CFLAGS) \ ++ -DGDBTK_LIBRARY=\"$(GDBTK_LIBRARY)\" \ ++ -DSRC_DIR=\"$(GDBTK_SRC_DIR)\" ++ ++# ++# Dependency tracking. ++# ++ ++ifeq ($(DEPMODE),depmode=gcc3) ++# Note that we put the dependencies into a .Tpo file, then move them ++# into place if the compile succeeds. We need this because gcc does ++# not atomically write the dependency output file. ++override COMPILE.post = -c -o $@ -MT $@ -MMD -MP \ ++ -MF $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo ++override POSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(basename $(@F)).Tpo \ ++ $(@D)/$(DEPDIR)/$(basename $(@F)).Po ++else ++override COMPILE.pre = source='$<' object='$@' libtool=no \ ++ DEPDIR=$(DEPDIR) $(DEPMODE) $(depcomp) \ ++ $(CXX) -x c++ $(CXX_DIALECT) ++# depcomp handles atomicity for us, so we don't need a postcompile ++# step. ++override POSTCOMPILE = ++endif ++ ++# A list of all the objects we might care about in this build, for ++# dependency tracking. ++all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o \ ++ test-cp-name-parser.o ++ ++# All the .deps files to include. ++all_deps_files = $(foreach dep,$(patsubst %.o,%.Po,$(all_object_files)),\ ++ $(dir $(dep))/$(DEPDIR)/$(notdir $(dep))) ++ ++# Ensure that generated files are created early. Use order-only ++# dependencies if available. They require GNU make 3.80 or newer, ++# and the .VARIABLES variable was introduced at the same time. ++ifdef .VARIABLES ++$(all_object_files): | $(generated_files) ++else ++$(all_object_files) : $(generated_files) ++endif ++ ++# Dependencies. ++-include $(all_deps_files) ++ ++# Disable implicit make rules. ++include $(srcdir)/disable-implicit-rules.mk ++ ++### end of the gdb Makefile.in. +diff -Naur gdb-14.1-after-patch/gdb/nat/sw64-linux-watch.c gdb-14.1-sw64/gdb/nat/sw64-linux-watch.c +--- gdb-14.1-after-patch/gdb/nat/sw64-linux-watch.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/nat/sw64-linux-watch.c 2025-03-03 10:59:13.160000000 +0800 +@@ -0,0 +1,182 @@ ++/* Copyright (C) 2009-2023 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include "gdbsupport/common-defs.h" ++#include "nat/gdb_ptrace.h" ++#include "sw64-linux-watch.h" ++ ++#ifdef GDBSERVER ++extern int debug_threads; ++#define debug(format, ... ) do { \ ++ if (debug_threads) {\ ++ fprintf(stdout, "%s,%d:%s:", __FILE__, __LINE__,__func__); \ ++ fprintf(stdout, format, ##__VA_ARGS__); \ ++ fprintf(stdout, "\n"); \ ++ fflush(stdout); \ ++ } \ ++ } while (0) ++extern int delete_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind); ++#else ++extern int debug_infrun; ++#define debug(format, ... ) do { \ ++ if (debug_infrun){ \ ++ fprintf(stdout, "%s,%d:%s:", __FILE__, __LINE__,__func__); \ ++ fprintf(stdout, format, ##__VA_ARGS__); \ ++ fprintf(stdout, "\n"); \ ++ fflush(stdout); \ ++ } \ ++ } while (0) ++#endif ++ ++int read_debug_register (pid_t pid, int regno, long *val) ++{ ++ int ret = 0; ++ errno = 0; ++ //printf("%s: pid = %d, regno = %d *val = %d\n", __FUNCTION__, pid, regno, *val); ++ if (SPE_LWP(pid)) ++ ret = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3) regno, val); ++ else ++ *val = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3) regno, 0); ++ //printf("%s: ret = %d, *val = %d\n", __FUNCTION__, ret, *val); ++ if ( ret < 0 || errno != 0) ++ { ++ warning("lwp %x write $%d failed \n", pid, regno); ++ return 0; ++ } ++ return 1; ++} ++ ++int store_debug_register (pid_t pid, int regno, long val) ++{ ++ int ret; ++ errno = 0; ++ //printf("%s: pid = %d, regno = %d val = %d\n", __FUNCTION__, pid, regno, val); ++ //debug("store tid %x CSR %d, val = %#lx", pid, regno, val); ++ ret = ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3) regno, val); ++ //printf("%s: ret = %d\n", __FUNCTION__, ret); ++ if ( ret < 0 || errno != 0) ++ { ++ warning("lwp %x write $%d failed \n", pid, regno); ++ return 0; ++ } ++ return 1; ++} ++ ++int is_power_of_2 (int val) ++{ ++ int i, onecount; ++ ++ onecount = 0; ++ for (i = 0; i < 8 * sizeof (val); i++) ++ if (val & (1 << i)) ++ onecount++; ++ ++ return onecount <= 1; ++} ++ ++int sw64_read_insn(pid_t pid, ulong pc) ++{ ++ int insn; ++ long tmp, data; ++ ++ tmp = pc & ~0x7; ++ data = ptrace(PTRACE_PEEKTEXT, pid, tmp, 0); ++ if ( pc & 0x7) ++ insn = (int)(data>>32); ++ else ++ insn = (int)data; ++ return insn; ++} ++ ++int sw64_linux_try_one_watch (pid_t lwpid, struct arch_lwp_info *info, ++ enum sw64_hw_bp_type wpt_type, long addr, int len) ++{ ++ long data; ++ int found = 0; ++ struct pt_watch_regs *wpt = info->wpt; ++ ++ if (!addr || !is_power_of_2 (len)) ++ return 0; ++ if ( wpt_type == sw64_vstore) ++ { ++ debug("insert master wp %lx, dv_match len = %d", (long)addr, len); ++ ++ info->value_address = addr; //saved ++ wpt[1].match = ptrace(PTRACE_PEEKDATA, lwpid, addr, 0); //dv_match ++ wpt[1].mask = (len &0x8)?0xffffffffffffffffUL:0xffffffffUL; //dv_mask ++ wpt[1].match &= wpt[1].mask; ++ wpt[1].valid = 1; ++ ++ if (wpt[0].valid) ++ { ++ data = wpt[0].match & ((1L<<53)-1); ++ ++ wpt[0].match = sw64_write; ++ wpt->match <<= 53; ++ wpt->match |= data; ++ /* wpt->mask not changed */ ++ } ++ } ++ else ++ { ++ debug("insert master wp %lx, da_match len = %d", (long)addr, len); ++ wpt->match = wpt_type&0x3; ++ wpt->match <<= 53; ++ wpt->match |= addr & ((1L<<53)-1); ++ data = len -1; ++ wpt->mask = ~data & ((1L<<53)-1); ++ wpt->valid = 1; ++ } ++ ++ found = 1; ++ ++ if (!found) ++ error("hardware wpt resource empty\n"); ++ return 1; ++} ++ ++ ++int sw64_linux_del_one_watch (pid_t lwpid, struct arch_lwp_info *info, ++ enum sw64_hw_bp_type wpt_type, long addr, int len) ++{ ++ int deleted_one = 0; ++ long match; ++ struct pt_watch_regs *wpt = info->wpt; ++ ++ if ( wpt_type == sw64_vstore ) ++ { ++ wpt[1].valid = 0; ++ wpt[0].valid = 0; ++ // debug("to remove master wp %#lx, dv_match", (long)addr); ++ info->value_address = 0L; //clr the saved ++ return 1; ++ } ++ match = wpt_type&0x3; ++ match <<= 53; ++ match |= addr&((1L<<53)-1); ++ ++ if ( wpt->valid && (match == wpt->match )) ++ { ++ wpt->match &= ~(0x3L<<53); ++ wpt->valid = 0; ++ // deleted_one ++; ++ // debug("to remove master wp %#lx, da_match", (long)addr); ++ return 1; ++ } ++ ++ return deleted_one>0; ++} +diff -Naur gdb-14.1-after-patch/gdb/nat/sw64-linux-watch.h gdb-14.1-sw64/gdb/nat/sw64-linux-watch.h +--- gdb-14.1-after-patch/gdb/nat/sw64-linux-watch.h 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/nat/sw64-linux-watch.h 2025-03-03 10:59:13.160000000 +0800 +@@ -0,0 +1,121 @@ ++/* Copyright (C) 2009-2023 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#ifndef NAT_SW64_LINUX_WATCH_H ++#define NAT_SW64_LINUX_WATCH_H ++ ++#include ++#include "gdbsupport/break-common.h" ++ ++#if 0 ++extern int debug_infrun; ++#define debug(format, ... ) do { \ ++ if (debug_infrun){ \ ++ fprintf(stdout, "%s,%d:%s:", __FILE__, __LINE__,__func__); \ ++ fprintf(stdout, format, ##__VA_ARGS__); \ ++ fprintf(stdout, "\n"); \ ++ fflush(stdout); \ ++ } \ ++ } while (0) ++#endif ++ ++#define SPE_LWP(pid) (pid & (1 << 31)) ++ ++enum { ++ REG_R0 = 0, ++ REG_SP = 30, ++ REG_F0 = 32, ++ REG_FPCR = 63, ++ REG_PC = 64, ++ UNIQUE_ADDR =65, ++ REG_V0F1 = 67, ++ SPE_V0 = 70, ++ REG_V0F2 = 99, ++ REG_V0F3 = 131, ++ M_DA_MATCH = 163, ++ M_DA_MASK = 164, ++ M_DV_MATCH = 165, ++ M_DV_MASK = 166, ++ M_DC_CTL = 167, ++#ifdef SW8A ++ M_MATCH_CTL = 167, ++#endif ++// Liu Hanxu: refer to linux-stable-sw/arch/sw64/include/uapi/asm/ptrace.h ++}; ++ ++enum sw64_hw_bp_type ++{ ++ sw64_none = 0, /* not match, or Execute HW breakpoint */ ++ sw64_read = 1, /* Read HW watchpoint */ ++ sw64_write = 2, /* Common HW watchpoint */ ++ sw64_access = 3, /* Access HW watchpoint */ ++ sw64_vstore = 4, ++}; ++ ++/* A value of zero in a watchlo indicates that it is available. */ ++ ++struct pt_watch_regs ++{ ++ uint64_t match; ++ uint64_t mask; ++ int valid; ++} __attribute__ ((aligned (8))); ++ ++ ++/* Per-thread arch-specific data we want to keep. */ ++#define MAX_DA_MATECH 2 ++struct arch_lwp_info ++{ ++ /* Non-zero if our copy differs from what's recorded in the thread. */ ++ int watch_registers_changed; ++ int watch_matched; ++ ++ struct pt_watch_regs wpt[MAX_DA_MATECH]; ++ ++ /* Cached stopped data address. */ ++ CORE_ADDR stopped_data_address; ++ CORE_ADDR value_address; ++ /* tls cs */ ++ long ebxio_def0; ++}; ++ ++ ++/* We keep list of all watchpoints we should install and calculate the ++ watch register values each time the list changes. This allows for ++ easy sharing of watch registers for more than one watchpoint. */ ++ ++struct sw64_watchpoint ++{ ++ CORE_ADDR addr; ++ int len; ++ enum target_hw_bp_type type; ++ struct sw64_watchpoint *next; ++}; ++ ++int is_power_of_2 (int val); ++ ++int sw64_linux_try_one_watch (pid_t , struct arch_lwp_info *, enum sw64_hw_bp_type , long , int ); ++ ++int sw64_linux_del_one_watch (pid_t , struct arch_lwp_info *, enum sw64_hw_bp_type , long , int ); ++ ++int read_debug_register (pid_t pid, int regno, long *val); ++ ++int store_debug_register (pid_t pid, int regno, long val); ++ ++int sw64_read_insn (pid_t pid, ulong pc); ++ ++#endif /* NAT_SW64_LINUX_WATCH_H */ +diff -Naur gdb-14.1-after-patch/gdb/regformats/sw64-linux.dat gdb-14.1-sw64/gdb/regformats/sw64-linux.dat +--- gdb-14.1-after-patch/gdb/regformats/sw64-linux.dat 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/regformats/sw64-linux.dat 2025-03-03 10:59:13.190000000 +0800 +@@ -0,0 +1,168 @@ ++# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro: ++# Generated from: sw64-linux.xml ++name:sw64_linux ++xmltarget:sw64-linux.xml ++expedite: ++64:r0 ++64:r1 ++64:r2 ++64:r3 ++64:r4 ++64:r5 ++64:r6 ++64:r7 ++64:r8 ++64:r9 ++64:r10 ++64:r11 ++64:r12 ++64:r13 ++64:r14 ++64:fp ++64:r16 ++64:r17 ++64:r18 ++64:r19 ++64:r20 ++64:r21 ++64:r22 ++64:r23 ++64:r24 ++64:r25 ++64:ra ++64:r27 ++64:r28 ++64:r29 ++64:sp ++64:r31 ++64:f0 ++64:f1 ++64:f2 ++64:f3 ++64:f4 ++64:f5 ++64:f6 ++64:f7 ++64:f8 ++64:f9 ++64:f10 ++64:f11 ++64:f12 ++64:f13 ++64:f14 ++64:f15 ++64:f16 ++64:f17 ++64:f18 ++64:f19 ++64:f20 ++64:f21 ++64:f22 ++64:f23 ++64:f24 ++64:f25 ++64:f26 ++64:f27 ++64:f28 ++64:f29 ++64:f30 ++64:fcsr ++64:pc ++64: ++64:unique ++64:ef0 ++64:ef1 ++64:ef2 ++64:ef3 ++64:ef4 ++64:ef5 ++64:ef6 ++64:ef7 ++64:ef8 ++64:ef9 ++64:ef10 ++64:ef11 ++64:ef12 ++64:ef13 ++64:ef14 ++64:ef15 ++64:ef16 ++64:ef17 ++64:ef18 ++64:ef19 ++64:ef20 ++64:ef21 ++64:ef22 ++64:ef23 ++64:ef24 ++64:ef25 ++64:ef26 ++64:ef27 ++64:ef28 ++64:ef29 ++64:ef30 ++64:ef31 ++64:ef0 ++64:ef1 ++64:ef2 ++64:ef3 ++64:ef4 ++64:ef5 ++64:ef6 ++64:ef7 ++64:ef8 ++64:ef9 ++64:ef10 ++64:ef11 ++64:ef12 ++64:ef13 ++64:ef14 ++64:ef15 ++64:ef16 ++64:ef17 ++64:ef18 ++64:ef19 ++64:ef20 ++64:ef21 ++64:ef22 ++64:ef23 ++64:ef24 ++64:ef25 ++64:ef26 ++64:ef27 ++64:ef28 ++64:ef29 ++64:ef30 ++64:ef31 ++64:ef0 ++64:ef1 ++64:ef2 ++64:ef3 ++64:ef4 ++64:ef5 ++64:ef6 ++64:ef7 ++64:ef8 ++64:ef9 ++64:ef10 ++64:ef11 ++64:ef12 ++64:ef13 ++64:ef14 ++64:ef15 ++64:ef16 ++64:ef17 ++64:ef18 ++64:ef19 ++64:ef20 ++64:ef21 ++64:ef22 ++64:ef23 ++64:ef24 ++64:ef25 ++64:ef26 ++64:ef27 ++64:ef28 ++64:ef29 ++64:ef30 ++64:ef31 +diff -Naur gdb-14.1-after-patch/gdb/sw64-linux-nat.c gdb-14.1-sw64/gdb/sw64-linux-nat.c +--- gdb-14.1-after-patch/gdb/sw64-linux-nat.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/sw64-linux-nat.c 2025-03-03 10:59:13.210000000 +0800 +@@ -0,0 +1,466 @@ ++/* Low level SW64 GNU/Linux interface, for GDB when running native. ++ Copyright (C) 2005-2023 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include "defs.h" ++#include "target.h" ++#include "regcache.h" ++#include "linux-nat-trad.h" ++ ++#include "sw64-tdep.h" ++#include "gdbarch.h" ++ ++#include "nat/gdb_ptrace.h" ++#include ++ ++#include ++#include "gregset.h" ++ ++#include "nat/sw64-linux-watch.h" ++#include "sw64-linux-tdep.h" ++#include "inferior.h" // defs of inferior_ptid ++#include "nat/linux-ptrace.h" // defs of TRAP_HWBKPT ++#include "linux-nat.h" // defs of lwp_info ++ ++/* The address of UNIQUE for ptrace. */ ++#define SW64_UNIQUE_PTRACE_ADDR 65 ++ ++#ifndef LHX20240711 ++static void sw64_linux_new_thread (struct lwp_info *lwp); ++ ++/* Function to call when a thread is being deleted. */ ++void sw64_linux_delete_thread (struct arch_lwp_info *arch_lwp); ++ ++//void sw64_linux_prepare_to_resume (struct lwp_info *lwp); ++ ++extern struct lwp_info *find_lwp_pid (ptid_t); ++ ++enum sw64_hw_bp_type sw64_hw_bp_type_from_target_hw_bp_type (enum target_hw_bp_type); ++#endif ++ ++class sw64_linux_nat_target final : public linux_nat_trad_target ++{ ++#ifndef LHX20240710 ++public: ++ void close () override; ++ ++ // LHX: Support for hardware watchpoint ++ int can_use_hw_breakpoint (enum bptype, int, int) override; ++ ++ int remove_watchpoint (CORE_ADDR, int, enum target_hw_bp_type, ++ struct expression *) override; ++ ++ int insert_watchpoint (CORE_ADDR, int, enum target_hw_bp_type, ++ struct expression *) override; ++ ++ bool stopped_by_watchpoint () override; ++ ++ bool stopped_data_address (CORE_ADDR *) override; ++ ++ // LHX: Not implemented. ++ //int region_ok_for_hw_watchpoint (CORE_ADDR, int) override; ++ ++ /* LHX: Used for watch registers. */ ++ void low_new_thread (struct lwp_info *lp) override ++ { sw64_linux_new_thread (lp); } ++ ++ void low_delete_thread (struct arch_lwp_info *lp) override ++ { sw64_linux_delete_thread (lp); } ++ ++ void low_prepare_to_resume (struct lwp_info *lp) override; ++ //{ sw64_linux_prepare_to_resume (lp); } ++#endif ++ ++ const struct target_desc *read_description () override; ++ ++protected: ++ /* Override linux_nat_trad_target methods. */ ++ CORE_ADDR register_u_offset (struct gdbarch *gdbarch, ++ int regno, int store_p) override; ++}; ++ ++static sw64_linux_nat_target the_sw64_linux_nat_target; ++ ++/* See the comment in m68k-tdep.c regarding the utility of these ++ functions. */ ++ ++void ++supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp) ++{ ++ const long *regp = (const long *)gregsetp; ++ ++ /* PC is in slot 32, UNIQUE is in slot 33. */ ++ sw64_supply_int_regs (regcache, -1, regp, regp + 31, regp + 32); ++} ++ ++void ++fill_gregset (const struct regcache *regcache, ++ gdb_gregset_t *gregsetp, int regno) ++{ ++ long *regp = (long *)gregsetp; ++ ++ /* PC is in slot 32, UNIQUE is in slot 33. */ ++ sw64_fill_int_regs (regcache, regno, regp, regp + 31, regp + 32); ++} ++ ++/* Now we do the same thing for floating-point registers. ++ Again, see the comments in m68k-tdep.c. */ ++ ++void ++supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp) ++{ ++ const long *regp = (const long *)fpregsetp; ++ ++ /* FPCR is in slot 32. */ ++ sw64_supply_fp_regs (regcache, -1, regp, regp + 31); ++} ++ ++void ++fill_fpregset (const struct regcache *regcache, ++ gdb_fpregset_t *fpregsetp, int regno) ++{ ++ long *regp = (long *)fpregsetp; ++ ++ /* FPCR is in slot 32. */ ++ sw64_fill_fp_regs (regcache, regno, regp, regp + 31); ++} ++ ++CORE_ADDR ++sw64_linux_nat_target::register_u_offset (struct gdbarch *gdbarch, ++ int regno, int store_p) ++{ ++ if (regno == gdbarch_pc_regnum (gdbarch)) ++ return SW64_PC_REGNUM; ++ if (regno == SW64_UNIQUE_REGNUM) ++ return SW64_UNIQUE_PTRACE_ADDR; ++ if (regno < gdbarch_fp0_regnum (gdbarch)) ++ return GPR_BASE + regno; ++ else ++ return FPR_BASE + regno - gdbarch_fp0_regnum (gdbarch); ++} ++ ++const struct target_desc * ++sw64_linux_nat_target::read_description () ++{ ++ return tdesc_sw64_linux; ++} ++ ++#ifndef LHX20240710 ++/* Target to_can_use_hw_breakpoint implementation. Return 1 if we can ++ handle the specified watch type. */ ++ ++int ++sw64_linux_nat_target::can_use_hw_breakpoint (enum bptype type, ++ int cnt, int ot) ++{ ++ if (type == bp_hardware_breakpoint && ++ cnt > 2 ) ++ return -1; ++ return 1; ++} ++ ++/* Target to_stopped_by_watchpoint implementation. Return 1 if ++ stopped by watchpoint. The watchhi R and W bits indicate the watch ++ register triggered. */ ++ ++bool ++sw64_linux_nat_target::stopped_by_watchpoint () ++{ ++ pid_t lwpid = inferior_ptid.lwp ();//ptid_get_lwp(inferior_ptid); ++ struct lwp_info *lwp = find_lwp_pid (inferior_ptid); ++ siginfo_t siginfo; ++ ++ gdb_assert (lwp != NULL); ++ ++ if (SPE_LWP(lwpid)) ++ { ++ //debug("keep going after slave-wp, can\'t ptrace."); ++ return true; ++ } ++ ++ /* Retrieve siginfo. */ ++ errno = 0; ++ ptrace (PTRACE_GETSIGINFO, lwpid, 0, &siginfo); ++ if (errno != 0) ++ { ++ warning("%s:%d GETSIGINFO return %d\n", __FILE__, __LINE__, errno); ++ return false; ++ } ++ //debug("si_code=%#x si_signo=%d si_errno = %x pc=%#lx, data_address %#lx", ++ //siginfo.si_code, siginfo.si_signo,siginfo.si_errno,(long)siginfo.si_value.sival_ptr, (long)siginfo.si_addr); ++ /* This must be a hardware breakpoint. */ ++ if (siginfo.si_signo != SIGTRAP ++ || (siginfo.si_code & 0xffff) != TRAP_HWBKPT) ++ return false; ++ ++ /* siginfo should return the accessed data address, not pc */ ++ switch (siginfo.si_errno){ ++ case 1: //si_errno[0]: ++ case 5: ++ case 7: //si_errno[2]: ++ lwp->arch_private->stopped_data_address ++ = (CORE_ADDR) (uintptr_t) (lwp->arch_private->wpt->match & ((1L<<53)-1)); ++ lwp->arch_private->watch_matched = 1; ++ break; ++ case 2: //si_errno[`] ++ lwp->arch_private->stopped_data_address ++ = (CORE_ADDR) (uintptr_t) (lwp->arch_private->value_address); // get the saved ++ lwp->arch_private->watch_matched = 1; ++ break; ++ default: ++ ;; ++ } ++ return true; ++} ++ ++/* Target to_stopped_data_address implementation. Set the address ++ where the watch triggered (if known). Return 1 if the address was ++ known. */ ++ ++bool ++sw64_linux_nat_target::stopped_data_address (CORE_ADDR *paddr) ++{ ++ struct lwp_info *lwp = find_lwp_pid (inferior_ptid); ++ ++ gdb_assert (lwp != NULL); ++ gdb_assert (lwp->arch_private != NULL); ++ if (lwp->arch_private->watch_matched) ++ *paddr = lwp->arch_private->stopped_data_address; ++ return lwp->arch_private->watch_matched; ++} ++ ++#if 0 // lhx: This function is not implemented. ++/* Target to_region_ok_for_hw_watchpoint implementation. Return 1 if ++ the specified region can be covered by the watch registers. */ ++ ++int ++sw64_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len) ++{ ++ /* Can not set watchpoints for zero or negative lengths. */ ++ if (len <= 0) ++ return 0; ++ ++ /* The current ptrace interface can only handle watchpoints that are a ++ * power of 2. */ ++ if ((len & (len - 1)) != 0) ++ return 0; ++ ++ /* All tests passed so we must be able to set a watchpoint. */ ++ return 1; ++} ++#endif ++ ++enum sw64_hw_bp_type ++sw64_hw_bp_type_from_target_hw_bp_type (enum target_hw_bp_type raw_type) ++{ ++ switch (raw_type) ++ { ++ case hw_execute: ++ /* permit r/w */ ++ return sw64_none; ++ case hw_write: ++ return sw64_write; ++ case hw_read: ++ return sw64_read; ++ case hw_access: ++ return sw64_access; ++ case hw_vstore: ++ return sw64_vstore; ++ default: ++ error ( "bad raw breakpoint type %d", (int) raw_type); ++ } ++} ++ ++/* Handle thread creation. We need to copy the breakpoints and watchpoints ++ * in the parent thread to the child thread. */ ++ ++static void ++sw64_linux_new_thread (struct lwp_info *lp) ++{ ++ struct arch_lwp_info *info = XCNEW (struct arch_lwp_info); ++ ++ /* Mark that all the hardware breakpoint/watchpoint register pairs ++ * for this thread need to be initialized. */ ++ ++ lp->arch_private = info; ++} ++ ++void ++sw64_linux_delete_thread (struct arch_lwp_info *arch_lwp) ++{ ++ xfree (arch_lwp); ++} ++ ++/* Target to_insert_watchpoint implementation. Try to insert a new ++ watch. Return zero on success. */ ++ ++int ++sw64_linux_nat_target::insert_watchpoint (CORE_ADDR addr, int len, ++ enum target_hw_bp_type type, ++ struct expression *cond) ++{ ++ enum sw64_hw_bp_type watch_type; ++ struct lwp_info *lp = find_lwp_pid(inferior_ptid); ++ struct arch_lwp_info *priv; ++ ++ //debug("%s insert wpt at %#lx type %d", target_pid_to_str(inferior_ptid), ++ // addr, type); ++ if ( !lp->arch_private ) ++ sw64_linux_new_thread(lp); ++ priv = lp->arch_private; ++ ++ watch_type = sw64_hw_bp_type_from_target_hw_bp_type(type); ++ ++ if (sw64_linux_try_one_watch(inferior_ptid.lwp (),/*ptid_get_lwp(inferior_ptid),*/ priv, ++ watch_type,addr,len)) ++ { ++ priv->watch_registers_changed =1; ++ return 0; ++ } ++ return -1; ++} ++ ++/* Target to_remove_watchpoint implementation. Try to remove a watch. ++ Return zero on success. */ ++ ++int ++sw64_linux_nat_target::remove_watchpoint (CORE_ADDR addr, int len, ++ enum target_hw_bp_type type, ++ struct expression *cond) ++{ ++ enum sw64_hw_bp_type watch_type; ++ struct lwp_info *lp = find_lwp_pid(inferior_ptid); ++ pid_t lwp = inferior_ptid.lwp ();/*ptid_get_lwp (inferior_ptid);*/ ++ struct arch_lwp_info *priv = lp->arch_private; ++ ++ watch_type = sw64_hw_bp_type_from_target_hw_bp_type(type); ++ if (sw64_linux_del_one_watch(lwp, priv, watch_type,addr,len)) ++ { ++ priv->watch_registers_changed =1; ++ return 0; ++ } ++ return -1; ++} ++ ++/* Target to_close implementation. Free any watches and call the ++ super implementation. */ ++ ++void ++sw64_linux_nat_target::close () ++{ ++ linux_nat_trad_target::close (); ++} ++ ++/* Called when resuming a thread. ++ The hardware debug registers are updated when there is any change. */ ++ ++void ++sw64_linux_nat_target::low_prepare_to_resume (struct lwp_info *lwp) ++{ ++ int lwpid, i; ++ struct arch_lwp_info *priv = lwp->arch_private; ++ ++ //ptid_t ptid = ptid_of_lwp (lwp); ++ lwpid = lwp->ptid.lwp();//ptid_get_pid (ptid); ++ /* priv's NULL means this is the main thread still going through the shell, ++ * or, no watchpoint has been set yet. In that case, there's ++ * nothing to do. */ ++ if ( priv && priv->watch_registers_changed) ++ { ++ /* Only update the watch registers if we have set or unset a ++ watchpoint already. */ ++ /* when detach, all of priv->....valid should be zero */ ++ if ( priv->wpt[1].valid ) ++ { ++ // debug("write master dv_match %#lx, mask %#lx", priv->wpt[1].match, priv->wpt[1].mask); ++ store_debug_register (lwpid, M_DV_MATCH, priv->wpt[1].match); ++ store_debug_register (lwpid, M_DV_MASK, priv->wpt[1].mask); ++ } ++ if ( priv->wpt[0].valid ) ++ { ++ // debug("write master da_match %#lx, mask %#lx", priv->wpt->match, priv->wpt->mask); ++ store_debug_register (lwpid, M_DA_MATCH, priv->wpt->match); ++ store_debug_register (lwpid, M_DA_MASK, priv->wpt->mask); ++ } ++ ++ i = (priv->wpt[1].valid<<1) | priv->wpt[0].valid; ++ ++ // setting dv_ctl ++ /* ++ *pcb->match_ctl: ++ * [0] DA_MATCH ++ * [1] DV_MATCH ++ * [2] DAV_MATCH ++ * [3] IA_MATCH ++ * [4] IV_MATCH ++ * [5] IDA_MATCH ++ * [8:9] match_ctl_mode ++ * [0:0]: not match ++ * [0:1]: match when read addr ++ * [1:0]: match when write addr ++ * [1:1]: match when read & write addr ++ * ++ * #define DA_MATCH 0x1 ++ * #define DV_MATCH 0x2 ++ * #define DAV_MATCH 0x4 ++ * #define IA_MATCH 0x8 ++ * #define IV_MATCH 0x10 ++ * #define IDA_MATCH 0x20 ++ */ ++ ++ switch (i) ++ { ++ //da_match ++ case 0: ++ case 1: ++ //store_debug_register (lwpid, M_DV_MATCH+2, 0L); ++#ifdef SW8A ++ store_debug_register (lwpid, M_MATCH_CTL, 0x301); ++#endif ++ break; ++ //dv_match ++ case 2: ++ store_debug_register (lwpid, M_DC_CTL, 1); ++#ifdef SW8A ++ store_debug_register (lwpid, M_MATCH_CTL, 0x302); ++#endif ++ break; ++ //dva_match ++ case 3: ++ store_debug_register (lwpid, M_DC_CTL, 3); ++#ifdef SW8A ++ store_debug_register (lwpid, M_MATCH_CTL, 0x304); ++#endif ++ break; ++ default: ++ ;; ++ } ++ ++ priv->watch_registers_changed = 0; ++ priv->watch_matched = 0; ++ } ++} ++#endif ++ ++void _initialize_sw64_linux_nat (); ++ ++void ++_initialize_sw64_linux_nat () ++{ ++ linux_target = &the_sw64_linux_nat_target; ++ add_inf_child_target (&the_sw64_linux_nat_target); ++} +diff -Naur gdb-14.1-after-patch/gdb/sw64-linux-tdep.c gdb-14.1-sw64/gdb/sw64-linux-tdep.c +--- gdb-14.1-after-patch/gdb/sw64-linux-tdep.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/sw64-linux-tdep.c 2025-03-03 10:59:13.660000000 +0800 +@@ -0,0 +1,1434 @@ ++/* Target-dependent code for GNU/Linux on SW64. ++ Copyright (C) 2002-2023 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include "defs.h" ++#include "frame.h" ++#include "osabi.h" ++#include "solib-svr4.h" ++#include "symtab.h" ++#include "regset.h" ++#include "regcache.h" ++#include "linux-tdep.h" ++#include "sw64-tdep.h" ++#include "gdbarch.h" ++ ++#include "features/sw64-linux.c" ++ ++#ifndef LHX20240711_catch ++#include "xml-syscall.h" ++#endif ++ ++#ifndef LHX20240716_record ++#include "glibc-tdep.h" ++#include "sw64-linux-tdep.h" ++#include "tramp-frame.h" ++#include "trad-frame.h" ++#include "target/target.h" ++ ++#include "stap-probe.h" ++#include "parser-defs.h" ++#include "user-regs.h" ++#include ++ ++#include "record-full.h" ++#include "linux-record.h" ++#endif ++ ++/* This enum represents the signals' numbers on the SW64 ++ architecture. It just contains the signal definitions which are ++ different from the generic implementation. ++ ++ It is derived from the file , ++ from the Linux kernel tree. */ ++ ++enum ++ { ++ /* SIGABRT is the same as in the generic implementation, but is ++ defined here because SIGIOT depends on it. */ ++ SW64_LINUX_SIGABRT = 6, ++ SW64_LINUX_SIGEMT = 7, ++ SW64_LINUX_SIGBUS = 10, ++ SW64_LINUX_SIGSYS = 12, ++ SW64_LINUX_SIGURG = 16, ++ SW64_LINUX_SIGSTOP = 17, ++ SW64_LINUX_SIGTSTP = 18, ++ SW64_LINUX_SIGCONT = 19, ++ SW64_LINUX_SIGCHLD = 20, ++ SW64_LINUX_SIGIO = 23, ++ SW64_LINUX_SIGINFO = 29, ++ SW64_LINUX_SIGUSR1 = 30, ++ SW64_LINUX_SIGUSR2 = 31, ++ SW64_LINUX_SIGPOLL = SW64_LINUX_SIGIO, ++ SW64_LINUX_SIGPWR = SW64_LINUX_SIGINFO, ++ SW64_LINUX_SIGIOT = SW64_LINUX_SIGABRT, ++ }; ++ ++/* Under GNU/Linux, signal handler invocations can be identified by ++ the designated code sequence that is used to return from a signal ++ handler. In particular, the return address of a signal handler ++ points to a sequence that copies $sp to $16, loads $0 with the ++ appropriate syscall number, and finally enters the kernel. ++ ++ This is somewhat complicated in that: ++ (1) the expansion of the "mov" assembler macro has changed over ++ time, from "bis src,src,dst" to "bis zero,src,dst", ++ (2) the kernel has changed from using "addq" to "lda" to load the ++ syscall number, ++ (3) there is a "normal" sigreturn and an "rt" sigreturn which ++ has a different stack layout. */ ++ ++static long ++sw64_linux_sigtramp_offset_1 (struct gdbarch *gdbarch, CORE_ADDR pc) ++{ ++ switch (sw64_read_insn (gdbarch, pc)) ++ { ++ case 0x47de0410: /* bis $30,$30,$16 */ ++ case 0x43fe0750: /* bis $31,$30,$16 */ ++ return 0; ++ ++ case 0x43ecf400: /* addq $31,103,$0 */ ++#if 0 ++ case 0x201f0067: /* lda $0,103($31) */ ++ case 0x201f015f: /* lda $0,351($31) */ ++#else ++ case 0xf81f0067U: ++ case 0xf81f015fU: ++#endif ++ return 4; ++ ++ case 0x02000083: /* call_pal callsys */ ++ return 8; ++ ++ default: ++ return -1; ++ } ++} ++ ++static LONGEST ++sw64_linux_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc) ++{ ++ long i, off; ++ ++ if (pc & 3) ++ return -1; ++ ++ /* Guess where we might be in the sequence. */ ++ off = sw64_linux_sigtramp_offset_1 (gdbarch, pc); ++ if (off < 0) ++ return -1; ++ ++ /* Verify that the other two insns of the sequence are as we expect. */ ++ pc -= off; ++ for (i = 0; i < 12; i += 4) ++ { ++ if (i == off) ++ continue; ++ if (sw64_linux_sigtramp_offset_1 (gdbarch, pc + i) != i) ++ return -1; ++ } ++ ++ return off; ++} ++ ++static int ++sw64_linux_pc_in_sigtramp (struct gdbarch *gdbarch, ++ CORE_ADDR pc, const char *func_name) ++{ ++ return sw64_linux_sigtramp_offset (gdbarch, pc) >= 0; ++} ++ ++static CORE_ADDR ++sw64_linux_sigcontext_addr (frame_info_ptr this_frame) ++{ ++ struct gdbarch *gdbarch = get_frame_arch (this_frame); ++ CORE_ADDR pc; ++ ULONGEST sp; ++ long off; ++ ++ pc = get_frame_pc (this_frame); ++ sp = get_frame_register_unsigned (this_frame, SW64_SP_REGNUM); ++ ++ off = sw64_linux_sigtramp_offset (gdbarch, pc); ++ gdb_assert (off >= 0); ++ ++ /* __NR_rt_sigreturn has a couple of structures on the stack. This is: ++ ++ struct rt_sigframe { ++ struct siginfo info; ++ struct ucontext uc; ++ }; ++ ++ offsetof (struct rt_sigframe, uc.uc_mcontext); */ ++ ++ if (sw64_read_insn (gdbarch, pc - off + 4) == 0xf81f015fU) ++ return sp + 176; ++ ++ /* __NR_sigreturn has the sigcontext structure at the top of the stack. */ ++ return sp; ++} ++ ++/* Supply register REGNUM from the buffer specified by GREGS and LEN ++ in the general-purpose register set REGSET to register cache ++ REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ ++ ++static void ++sw64_linux_supply_gregset (const struct regset *regset, ++ struct regcache *regcache, ++ int regnum, const void *gregs, size_t len) ++{ ++ const gdb_byte *regs = (const gdb_byte *) gregs; ++ ++ gdb_assert (len >= 32 * 8); ++ sw64_supply_int_regs (regcache, regnum, regs, regs + 31 * 8, ++ len >= 33 * 8 ? regs + 32 * 8 : NULL); ++} ++ ++/* Collect register REGNUM from the register cache REGCACHE and store ++ it in the buffer specified by GREGS and LEN as described by the ++ general-purpose register set REGSET. If REGNUM is -1, do this for ++ all registers in REGSET. */ ++ ++static void ++sw64_linux_collect_gregset (const struct regset *regset, ++ const struct regcache *regcache, ++ int regnum, void *gregs, size_t len) ++{ ++ gdb_byte *regs = (gdb_byte *) gregs; ++ ++ gdb_assert (len >= 32 * 8); ++ sw64_fill_int_regs (regcache, regnum, regs, regs + 31 * 8, ++ len >= 33 * 8 ? regs + 32 * 8 : NULL); ++} ++ ++/* Supply register REGNUM from the buffer specified by FPREGS and LEN ++ in the floating-point register set REGSET to register cache ++ REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ ++ ++static void ++sw64_linux_supply_fpregset (const struct regset *regset, ++ struct regcache *regcache, ++ int regnum, const void *fpregs, size_t len) ++{ ++ const gdb_byte *regs = (const gdb_byte *) fpregs; ++ ++ gdb_assert (len >= 32 * 8); ++ sw64_supply_fp_regs (regcache, regnum, regs, regs + 31 * 8); ++} ++ ++/* Collect register REGNUM from the register cache REGCACHE and store ++ it in the buffer specified by FPREGS and LEN as described by the ++ general-purpose register set REGSET. If REGNUM is -1, do this for ++ all registers in REGSET. */ ++ ++static void ++sw64_linux_collect_fpregset (const struct regset *regset, ++ const struct regcache *regcache, ++ int regnum, void *fpregs, size_t len) ++{ ++ gdb_byte *regs = (gdb_byte *) fpregs; ++ ++ gdb_assert (len >= 32 * 8); ++ sw64_fill_fp_regs (regcache, regnum, regs, regs + 31 * 8); ++} ++ ++static const struct regset sw64_linux_gregset = ++{ ++ NULL, ++ sw64_linux_supply_gregset, sw64_linux_collect_gregset ++}; ++ ++static const struct regset sw64_linux_fpregset = ++{ ++ NULL, ++ sw64_linux_supply_fpregset, sw64_linux_collect_fpregset ++}; ++ ++/* Iterate over core file register note sections. */ ++ ++static void ++sw64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, ++ iterate_over_regset_sections_cb *cb, ++ void *cb_data, ++ const struct regcache *regcache) ++{ ++ cb (".reg", SW64_LINUX_SIZEOF_GREGSET, SW64_LINUX_SIZEOF_GREGSET, &sw64_linux_gregset, NULL, cb_data); ++ cb (".reg2", SW64_LINUX_SIZEOF_FPREGSET, SW64_LINUX_SIZEOF_FPREGSET, &sw64_linux_fpregset, NULL, cb_data); ++} ++ ++/* Implementation of `gdbarch_gdb_signal_from_target', as defined in ++ gdbarch.h. */ ++ ++static enum gdb_signal ++sw64_linux_gdb_signal_from_target (struct gdbarch *gdbarch, ++ int signal) ++{ ++ switch (signal) ++ { ++ case SW64_LINUX_SIGEMT: ++ return GDB_SIGNAL_EMT; ++ ++ case SW64_LINUX_SIGBUS: ++ return GDB_SIGNAL_BUS; ++ ++ case SW64_LINUX_SIGSYS: ++ return GDB_SIGNAL_SYS; ++ ++ case SW64_LINUX_SIGURG: ++ return GDB_SIGNAL_URG; ++ ++ case SW64_LINUX_SIGSTOP: ++ return GDB_SIGNAL_STOP; ++ ++ case SW64_LINUX_SIGTSTP: ++ return GDB_SIGNAL_TSTP; ++ ++ case SW64_LINUX_SIGCONT: ++ return GDB_SIGNAL_CONT; ++ ++ case SW64_LINUX_SIGCHLD: ++ return GDB_SIGNAL_CHLD; ++ ++ /* No way to differentiate between SIGIO and SIGPOLL. ++ Therefore, we just handle the first one. */ ++ case SW64_LINUX_SIGIO: ++ return GDB_SIGNAL_IO; ++ ++ /* No way to differentiate between SIGINFO and SIGPWR. ++ Therefore, we just handle the first one. */ ++ case SW64_LINUX_SIGINFO: ++ return GDB_SIGNAL_INFO; ++ ++ case SW64_LINUX_SIGUSR1: ++ return GDB_SIGNAL_USR1; ++ ++ case SW64_LINUX_SIGUSR2: ++ return GDB_SIGNAL_USR2; ++ } ++ ++ return linux_gdb_signal_from_target (gdbarch, signal); ++} ++ ++/* Implementation of `gdbarch_gdb_signal_to_target', as defined in ++ gdbarch.h. */ ++ ++static int ++sw64_linux_gdb_signal_to_target (struct gdbarch *gdbarch, ++ enum gdb_signal signal) ++{ ++ switch (signal) ++ { ++ case GDB_SIGNAL_EMT: ++ return SW64_LINUX_SIGEMT; ++ ++ case GDB_SIGNAL_BUS: ++ return SW64_LINUX_SIGBUS; ++ ++ case GDB_SIGNAL_SYS: ++ return SW64_LINUX_SIGSYS; ++ ++ case GDB_SIGNAL_URG: ++ return SW64_LINUX_SIGURG; ++ ++ case GDB_SIGNAL_STOP: ++ return SW64_LINUX_SIGSTOP; ++ ++ case GDB_SIGNAL_TSTP: ++ return SW64_LINUX_SIGTSTP; ++ ++ case GDB_SIGNAL_CONT: ++ return SW64_LINUX_SIGCONT; ++ ++ case GDB_SIGNAL_CHLD: ++ return SW64_LINUX_SIGCHLD; ++ ++ case GDB_SIGNAL_IO: ++ return SW64_LINUX_SIGIO; ++ ++ case GDB_SIGNAL_INFO: ++ return SW64_LINUX_SIGINFO; ++ ++ case GDB_SIGNAL_USR1: ++ return SW64_LINUX_SIGUSR1; ++ ++ case GDB_SIGNAL_USR2: ++ return SW64_LINUX_SIGUSR2; ++ ++ case GDB_SIGNAL_POLL: ++ return SW64_LINUX_SIGPOLL; ++ ++ case GDB_SIGNAL_PWR: ++ return SW64_LINUX_SIGPWR; ++ } ++ ++ return linux_gdb_signal_to_target (gdbarch, signal); ++} ++ ++#ifndef LHX20240711_catch ++/* Return the current system call's number present in the ++ v0 register. When the function fails, it returns -1. */ ++ ++static LONGEST ++sw64_linux_get_syscall_number (struct gdbarch *gdbarch, ++ thread_info *thread) ++{ ++ struct regcache *regcache = get_thread_regcache (thread); ++ //sw64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ++ int regsize = register_size (gdbarch, SW64_V0_REGNUM); ++ /* The content of a register */ ++ gdb_byte buf[8]; ++ /* The result */ ++ LONGEST ret; ++ ++ gdb_assert (regsize <= sizeof (buf)); ++ ++ /* Getting the system call number from the register. ++ syscall number is in v0 or $0. */ ++ regcache->cooked_read (SW64_V0_REGNUM, buf); ++ ++ ret = extract_signed_integer (buf, regsize, byte_order); ++ ++ return ret; ++} ++#endif ++ ++#ifndef LHX20240716_record ++/* Initialize linux_record_tdep if not initialized yet. ++ WORDSIZE is 4 or 8 for 32- or 64-bit PowerPC Linux respectively. ++ Sizes of data structures are initialized accordingly. */ ++ ++static void ++sw64_init_linux_record_tdep (struct linux_record_tdep *record_tdep, ++ int wordsize) ++ ++{ ++ /* Simply return if it had been initialized. */ ++ if (record_tdep->size_pointer != 0) ++ return; ++ ++ /* These values are the size of the type that will be used in a system ++ call. They are obtained from Linux Kernel source. */ ++ ++ if (wordsize == 8) ++ { ++ record_tdep->size_pointer = 8; ++ record_tdep->size__old_kernel_stat = 32; ++ record_tdep->size_tms = 32; ++ record_tdep->size_loff_t = 8; ++ record_tdep->size_flock = 32; ++ record_tdep->size_oldold_utsname = 45; ++ record_tdep->size_ustat = 32; ++ record_tdep->size_old_sigaction = 32; ++ record_tdep->size_old_sigset_t = 8; ++ record_tdep->size_rlimit = 16; ++ record_tdep->size_rusage = 144; ++ record_tdep->size_timeval = 16; ++ record_tdep->size_timezone = 8; ++ record_tdep->size_old_gid_t = 4; ++ record_tdep->size_old_uid_t = 4; ++ record_tdep->size_fd_set = 128; ++ record_tdep->size_old_dirent = 280; ++ record_tdep->size_statfs = 120; ++ record_tdep->size_statfs64 = 120; ++ record_tdep->size_sockaddr = 16; ++ record_tdep->size_int = 4; ++ record_tdep->size_long = 8; ++ record_tdep->size_ulong = 8; ++ record_tdep->size_msghdr = 56; ++ record_tdep->size_itimerval = 32; ++ record_tdep->size_stat = 144; ++ record_tdep->size_old_utsname = 325; ++ record_tdep->size_sysinfo = 112; ++ record_tdep->size_msqid_ds = 120; ++ record_tdep->size_shmid_ds = 112; ++ record_tdep->size_new_utsname = 390; ++ record_tdep->size_timex = 208; ++ record_tdep->size_mem_dqinfo = 24; ++ record_tdep->size_if_dqblk = 72; ++ record_tdep->size_fs_quota_stat = 80; ++ record_tdep->size_timespec = 16; ++ record_tdep->size_pollfd = 8; ++ record_tdep->size_NFS_FHSIZE = 32; ++ record_tdep->size_knfsd_fh = 132; ++ record_tdep->size_TASK_COMM_LEN = 16; ++ record_tdep->size_sigaction = 32; ++ record_tdep->size_sigset_t = 8; ++ record_tdep->size_siginfo_t = 128; ++ record_tdep->size_cap_user_data_t = 8; ++ record_tdep->size_stack_t = 24; ++ record_tdep->size_off_t = 8; ++ record_tdep->size_stat64 = 104; ++ record_tdep->size_gid_t = 4; ++ record_tdep->size_uid_t = 4; ++ record_tdep->size_PAGE_SIZE = 0x10000; /* 64KB */ ++ record_tdep->size_flock64 = 32; ++ record_tdep->size_io_event = 32; ++ record_tdep->size_iocb = 64; ++ record_tdep->size_epoll_event = 16; ++ record_tdep->size_itimerspec = 32; ++ record_tdep->size_mq_attr = 64; ++ record_tdep->size_termios = 44; ++ record_tdep->size_pid_t = 4; ++ record_tdep->size_winsize = 8; ++ record_tdep->size_serial_struct = 72; ++ record_tdep->size_serial_icounter_struct = 80; ++ record_tdep->size_size_t = 8; ++ record_tdep->size_iovec = 16; ++ record_tdep->size_time_t = 8; ++ } ++ else if (wordsize == 4) ++ { ++ record_tdep->size_pointer = 4; ++ record_tdep->size__old_kernel_stat = 32; ++ record_tdep->size_tms = 16; ++ record_tdep->size_loff_t = 8; ++ record_tdep->size_flock = 16; ++ record_tdep->size_oldold_utsname = 45; ++ record_tdep->size_ustat = 20; ++ record_tdep->size_old_sigaction = 16; ++ record_tdep->size_old_sigset_t = 4; ++ record_tdep->size_rlimit = 8; ++ record_tdep->size_rusage = 72; ++ record_tdep->size_timeval = 8; ++ record_tdep->size_timezone = 8; ++ record_tdep->size_old_gid_t = 4; ++ record_tdep->size_old_uid_t = 4; ++ record_tdep->size_fd_set = 128; ++ record_tdep->size_old_dirent = 268; ++ record_tdep->size_statfs = 64; ++ record_tdep->size_statfs64 = 88; ++ record_tdep->size_sockaddr = 16; ++ record_tdep->size_int = 4; ++ record_tdep->size_long = 4; ++ record_tdep->size_ulong = 4; ++ record_tdep->size_msghdr = 28; ++ record_tdep->size_itimerval = 16; ++ record_tdep->size_stat = 88; ++ record_tdep->size_old_utsname = 325; ++ record_tdep->size_sysinfo = 64; ++ record_tdep->size_msqid_ds = 68; ++ record_tdep->size_shmid_ds = 60; ++ record_tdep->size_new_utsname = 390; ++ record_tdep->size_timex = 128; ++ record_tdep->size_mem_dqinfo = 24; ++ record_tdep->size_if_dqblk = 72; ++ record_tdep->size_fs_quota_stat = 80; ++ record_tdep->size_timespec = 8; ++ record_tdep->size_pollfd = 8; ++ record_tdep->size_NFS_FHSIZE = 32; ++ record_tdep->size_knfsd_fh = 132; ++ record_tdep->size_TASK_COMM_LEN = 16; ++ record_tdep->size_sigaction = 20; ++ record_tdep->size_sigset_t = 8; ++ record_tdep->size_siginfo_t = 128; ++ record_tdep->size_cap_user_data_t = 4; ++ record_tdep->size_stack_t = 12; ++ record_tdep->size_off_t = 4; ++ record_tdep->size_stat64 = 104; ++ record_tdep->size_gid_t = 4; ++ record_tdep->size_uid_t = 4; ++ record_tdep->size_PAGE_SIZE = 0x10000; /* 64KB */ ++ record_tdep->size_flock64 = 32; ++ record_tdep->size_io_event = 32; ++ record_tdep->size_iocb = 64; ++ record_tdep->size_epoll_event = 16; ++ record_tdep->size_itimerspec = 16; ++ record_tdep->size_mq_attr = 32; ++ record_tdep->size_termios = 44; ++ record_tdep->size_pid_t = 4; ++ record_tdep->size_winsize = 8; ++ record_tdep->size_serial_struct = 60; ++ record_tdep->size_serial_icounter_struct = 80; ++ record_tdep->size_size_t = 4; ++ record_tdep->size_iovec = 8; ++ record_tdep->size_time_t = 4; ++ } ++ else ++ internal_error (_("unexpected wordsize")); ++ ++ /* These values are the second argument of system call "sys_fcntl" ++ and "sys_fcntl64". They are obtained from Linux Kernel source. */ ++ record_tdep->fcntl_F_GETLK = 5; ++ record_tdep->fcntl_F_GETLK64 = 12; ++ record_tdep->fcntl_F_SETLK64 = 13; ++ record_tdep->fcntl_F_SETLKW64 = 14; ++ ++ record_tdep->arg1 = SW64_A0_REGNUM + 0; ++ record_tdep->arg2 = SW64_A0_REGNUM + 1; ++ record_tdep->arg3 = SW64_A0_REGNUM + 2; ++ record_tdep->arg4 = SW64_A0_REGNUM + 3; ++ record_tdep->arg5 = SW64_A0_REGNUM + 4; ++ record_tdep->arg6 = SW64_A0_REGNUM + 5; ++ ++ /* These values are the second argument of system call "sys_ioctl". ++ They are obtained from Linux Kernel source. ++ See arch/powerpc/include/uapi/asm/ioctls.h. */ ++ record_tdep->ioctl_TCGETS = 0x403c7413;//402c7413 ++ record_tdep->ioctl_TCSETS = 0x802c7414;//802c7414 ++ record_tdep->ioctl_TCSETSW = 0x802c7415;//802c7415 ++ record_tdep->ioctl_TCSETSF = 0x802c7416;//802c7416 ++ record_tdep->ioctl_TCGETA = 0x40127417;//40127417 ++ record_tdep->ioctl_TCSETA = 0x80127418;//80127418 ++ record_tdep->ioctl_TCSETAW = 0x80127419;//80127419 ++ record_tdep->ioctl_TCSETAF = 0x8012741c;//8012741c ++ record_tdep->ioctl_TCSBRK = 0x2000741d;//2000741d ++ record_tdep->ioctl_TCXONC = 0x2000741e;//2000741e ++ record_tdep->ioctl_TCFLSH = 0x2000741f;//2000741f ++ record_tdep->ioctl_TIOCEXCL = 0x540c;// ++ record_tdep->ioctl_TIOCNXCL = 0x540d;// ++ record_tdep->ioctl_TIOCSCTTY = 0x540e;// ++ record_tdep->ioctl_TIOCGPGRP = 0x40047477;//40047477 ++ record_tdep->ioctl_TIOCSPGRP = 0x80047476;//80047476 ++ record_tdep->ioctl_TIOCOUTQ = 0x40047473;//40047473 ++ record_tdep->ioctl_TIOCSTI = 0x5412;//5412 ++ record_tdep->ioctl_TIOCGWINSZ = 0x40087468;//40087468 ++ record_tdep->ioctl_TIOCSWINSZ = 0x80087467;//80087467 ++ record_tdep->ioctl_TIOCMGET = 0x5415;// ++ record_tdep->ioctl_TIOCMBIS = 0x5416;// ++ record_tdep->ioctl_TIOCMBIC = 0x5417;// ++ record_tdep->ioctl_TIOCMSET = 0x5418;// ++ record_tdep->ioctl_TIOCGSOFTCAR = 0x5419;// ++ record_tdep->ioctl_TIOCSSOFTCAR = 0x541a;// ++ record_tdep->ioctl_FIONREAD = 0x4004667f;//4004667f ++ record_tdep->ioctl_TIOCINQ = 0x4004667f;//4004667f ++ record_tdep->ioctl_TIOCLINUX = 0x541c;// ++ record_tdep->ioctl_TIOCCONS = 0x541d;// ++ record_tdep->ioctl_TIOCGSERIAL = 0x541e;// ++ record_tdep->ioctl_TIOCSSERIAL = 0x541f;// ++ record_tdep->ioctl_TIOCPKT = 0x5420;// ++ record_tdep->ioctl_FIONBIO = 0x8004667e;//8004667e ++ record_tdep->ioctl_TIOCNOTTY = 0x5422;// ++ record_tdep->ioctl_TIOCSETD = 0x5423;// ++ record_tdep->ioctl_TIOCGETD = 0x5424;// ++ record_tdep->ioctl_TCSBRKP = 0x5425;// ++ record_tdep->ioctl_TIOCSBRK = 0x5427; ++ record_tdep->ioctl_TIOCCBRK = 0x5428; ++ record_tdep->ioctl_TIOCGSID = 0x5429; ++ record_tdep->ioctl_TIOCGPTN = 0x40045430;//40045430 ++ record_tdep->ioctl_TIOCSPTLCK = 0x80045431;//80045431 ++ record_tdep->ioctl_FIONCLEX = 0x20006602;//20006602 ++ record_tdep->ioctl_FIOCLEX = 0x20006601;//20006601 ++ record_tdep->ioctl_FIOASYNC = 0x8004667d;//8004667d ++ record_tdep->ioctl_TIOCSERCONFIG = 0x5453;// ++ record_tdep->ioctl_TIOCSERGWILD = 0x5454; ++ record_tdep->ioctl_TIOCSERSWILD = 0x5455; ++ record_tdep->ioctl_TIOCGLCKTRMIOS = 0x5456; ++ record_tdep->ioctl_TIOCSLCKTRMIOS = 0x5457; ++ record_tdep->ioctl_TIOCSERGSTRUCT = 0x5458; ++ record_tdep->ioctl_TIOCSERGETLSR = 0x5459; ++ record_tdep->ioctl_TIOCSERGETMULTI = 0x545a; ++ record_tdep->ioctl_TIOCSERSETMULTI = 0x545b; ++ record_tdep->ioctl_TIOCMIWAIT = 0x545c; ++ record_tdep->ioctl_TIOCGICOUNT = 0x545d; ++ record_tdep->ioctl_FIOQSIZE = 0x40086680;// ++} ++ ++/* sw64 process record-replay constructs: syscall, signal etc. */ ++ ++struct linux_record_tdep sw64_linux_record_tdep; ++ ++/* Enum that defines the sw64 linux specific syscall identifiers used for ++ process record/replay. */ ++enum sw64_syscall { ++ ++sw64_sys_exit =1, ++sw64_sys_fork =2, ++sw64_sys_read =3, ++sw64_sys_write =4, ++sw64_sys_close =6, ++//sw64_sys_wait4 =7, ++sw64_sys_link =9, ++sw64_sys_unlink =10, ++sw64_sys_chdir =12, ++sw64_sys_fchdir =13, ++sw64_sys_mknod =14, ++sw64_sys_chmod =15, ++sw64_sys_chown =16, ++sw64_sys_brk =17, ++sw64_sys_lseek =19, ++sw64_sys_getxpid =20,//getxpid ++sw64_sys_mount =21, ++sw64_sys_umount2 =22, ++sw64_sys_setuid =23, ++sw64_sys_getxuid =24,//getxuid ++sw64_sys_ptrace =26, ++sw64_sys_access =33, ++sw64_sys_sync =36, ++sw64_sys_kill =37, ++sw64_sys_setpgid =39, ++sw64_sys_dup =41, ++sw64_sys_pipe =42, ++sw64_sys_set_program_attributes =43, ++sw64_sys_open =45, ++sw64_sys_getxgid =47,//getxgid ++sw64_sys_sigprocmask =48, ++sw64_sys_acct =51, ++sw64_sys_sigpending =52, ++sw64_sys_ioctl =54, ++sw64_sys_symlink =57, ++sw64_sys_readlink =58, ++sw64_sys_execve =59, ++sw64_sys_umask =60, ++sw64_sys_chroot =61, ++sw64_sys_getpgrp =63, ++sw64_sys_getpagesize =64, ++sw64_sys_vfork =66, ++sw64_sys_stat =67, ++sw64_sys_lstat =68, ++sw64_sys_mmap =71, ++sw64_sys_munmap =73, ++sw64_sys_mprotect =74, ++sw64_sys_madvise =75, ++sw64_sys_vhangup =76, ++sw64_sys_getgroups =79, ++sw64_sys_setgroups =80, ++sw64_sys_setpgrp =82, ++sw64_sys_setitimer =83, ++sw64_sys_getitimer =86, ++sw64_sys_gethostname =87, ++sw64_sys_sethostname =88, ++sw64_sys_getdtablesize =89, ++sw64_sys_dup2 =90, ++sw64_sys_fstat =91, ++sw64_sys_fcntl =92, ++sw64_sys_select =93, ++sw64_sys_poll =94, ++sw64_sys_fsync =95, ++sw64_sys_setpriority =96, ++sw64_sys_socket =97, ++sw64_sys_connect =98, ++sw64_sys_accept =99, ++sw64_sys_getpriority =100, ++sw64_sys_send =101, ++sw64_sys_recv =102, ++sw64_sys_sigreturn =103, ++sw64_sys_bind =104, ++sw64_sys_setsockopt =105, ++sw64_sys_listen =106, ++sw64_sys_sigsuspend =111, ++sw64_sysi_sigstack =112, ++sw64_sys_recvmsg =113, ++sw64_sys_sendmsg =114, ++sw64_sys_gettimeofday =116, ++//sw64_sys_getrusage =117, ++sw64_sys_osf_getrusage =117, ++sw64_sys_getsockopt =118, ++sw64_sys_socketcall =119, ++sw64_sys_readv =120, ++sw64_sys_writev =121, ++sw64_sys_settimeofday =122, ++sw64_sys_fchown =123, ++sw64_sys_fchmod =124, ++sw64_sys_recvfrom =125, ++sw64_sys_setreuid =126, ++sw64_sys_setregid =127, ++sw64_sys_rename =128, ++sw64_sys_truncate =129, ++sw64_sys_ftruncate =130, ++sw64_sys_flock =131, ++sw64_sys_setgid =132, ++sw64_sys_sendto =133, ++sw64_sys_shutdown =134, ++sw64_sys_socketpair =135, ++sw64_sys_mkdir =136, ++sw64_sys_rmdir =137, ++sw64_sys_utimes =138, ++sw64_sys_getpeername =141, ++sw64_sys_getrlimit =144, ++sw64_sys_setrlimit =145, ++sw64_sys_setsid =147, ++sw64_sys_quotactl =148, ++sw64_sys_getsockname =150, ++sw64_sys_sigaction =156, ++sw64_sys_getdirentries =159, ++sw64_sys_statfs =160, ++sw64_sys_fstatfs =161, ++sw64_sys_getdomainname =165, ++sw64_sys_setdomainname =166, ++sw64_sys_bpf =170, ++sw64_sys_userfaultfd =171, ++sw64_sys_membarrier =172, ++sw64_sys_mlock2 =173, ++sw64_sys_getpid =174,//REPITATION ++sw64_sys_getppid =175, ++sw64_sys_getuid =176,//REPITATION ++sw64_sys_geteuid =177, ++sw64_sys_getgid =178,//REPITATION ++sw64_sys_getegid =179, ++sw64_sys_swapon =199, ++sw64_sys_msgctl =200, ++sw64_sys_msgget =201, ++sw64_sys_msgrcv =202, ++sw64_sys_msgsnd =203, ++sw64_sys_semctl =204, ++sw64_sys_semget =205, ++sw64_sys_semop =206, ++sw64_sys_utsname =207, ++sw64_sys_lchown =208, ++sw64_sys_shmat =209, ++sw64_sys_shmctl =210, ++sw64_sys_shmdt =211, ++sw64_sys_shmget =212, ++sw64_sys_msync =217, ++sw64_sysi_stat =224, ++sw64_sys_statfs64 =227, ++sw64_sys_fstatfs64 =230, ++sw64_sys_getpgid =233, ++sw64_sys_getsid =234, ++sw64_sys_sigaltstack =235, ++//sw64_sys_osf_sysinfo =241,// ++sw64_sys_proplist_syscall =244, ++sw64_sys_usleep_thread =251, ++sw64_sys_sysfs =254, ++sw64_sys_getsysinfo =256, ++sw64_sys_setsysinfo =257, ++sw64_sys_bdflush =300, ++sw64_sys_sethae =301, ++sw64_sys_old_adjtimex =303, ++sw64_sys_swapoff =304, ++sw64_sys_getdents =305, ++sw64_sys_create_module =306, ++sw64_sys_init_module =307, ++sw64_sys_delete_module =308, ++sw64_sys_get_kernel_syms =309, ++sw64_sys_syslog =310, ++sw64_sys_reboot =311, ++sw64_sys_clone =312, ++sw64_sys_uselib =313, ++sw64_sys_mlock =314, ++sw64_sys_munlock =315, ++sw64_sys_mlockall =316, ++sw64_sys_munlockall =317, ++sw64_sys_sysinfo =318, ++sw64_sys_sysctl =319, ++sw64_sys_oldumount =321, ++sw64_sys_times =323, ++sw64_sys_personality =324, ++sw64_sys_setfsuid =325, ++sw64_sys_setfsgid =326, ++sw64_sys_ustat =327, ++sw64_sys_sched_setparam =330, ++sw64_sys_sched_getparam =331, ++sw64_sys_sched_setscheduler =332, ++sw64_sys_sched_getscheduler =333, ++sw64_sys_sched_yield =334, ++sw64_sys_sched_get_priority_max =335, ++sw64_sys_sched_get_priority_min =336, ++sw64_sys_sched_rr_get_interval =337, ++sw64_sys_afs_syscall =338, ++sw64_sys_uname =339, ++sw64_sys_nanosleep =340, ++sw64_sys_mremap =341, ++sw64_sys_nfsservctl =342, ++sw64_sys_setresuid =343, ++sw64_sys_getresuid =344, ++sw64_sys_pciconfig_read =345, ++sw64_sys_pciconfig_write =346, ++sw64_sys_query_module =347, ++sw64_sys_prctl =348, ++sw64_sys_pread64 =349, ++sw64_sys_pwrite64 =350, ++sw64_sys_rt_sigreturn =351, ++sw64_sys_rt_sigaction =352, ++sw64_sys_rt_sigprocmask =353, ++sw64_sys_rt_sigpending =354, ++sw64_sys_rt_sigtimedwait =355, ++sw64_sys_rt_sigqueueinfo =356, ++sw64_sys_rt_sigsuspend =357, ++sw64_sys_getrusage =364, ++sw64_sys_wait4 =365, ++sw64_sys_adjtimex =366, ++sw64_sys_getcwd =367, ++sw64_sys_capget =368, ++sw64_sys_capset =369, ++sw64_sys_sendfile =370, ++sw64_sys_setresgid =371, ++sw64_sys_getresgid =372, ++sw64_sys_dipc =373, ++sw64_sys_pivot_root =374, ++sw64_sys_mincore =375, ++sw64_sys_pciconfig_iobase =376, ++sw64_sys_getdents64 =377, ++sw64_sys_gettid =378, ++sw64_sys_readahead =379, ++sw64_sys_tkill =381, ++sw64_sys_setxattr =382, ++sw64_sys_lsetxattr =383, ++sw64_sys_fsetxattr =384, ++sw64_sys_getxattr =385, ++sw64_sys_lgetxattr =386, ++sw64_sys_fgetxattr =387, ++sw64_sys_listxattr =388, ++sw64_sys_llistxattr =389, ++sw64_sys_flistxattr =390, ++sw64_sys_removexattr =391, ++sw64_sys_lremovexattr =392, ++sw64_sys_fremovexattr =393, ++sw64_sys_futex =394, ++sw64_sys_sched_setaffinity =395, ++sw64_sys_sched_getaffinity =396, ++sw64_sys_tuxcall =397, ++sw64_sys_io_setup =398, ++sw64_sys_io_destroy =399, ++sw64_sys_io_getevents =400, ++sw64_sys_io_submit =401, ++sw64_sys_io_cancel =402, ++sw64_sys_io_pgetevents =403, ++sw64_sys_rseq =404, ++sw64_sys_exit_group =405, ++sw64_sys_lookup_dcookie =406, ++sw64_sys_epoll_create =407, ++sw64_sys_epoll_ctl =408, ++sw64_sys_epoll_wait =409, ++sw64_sys_remap_file_pages =410, ++sw64_sys_set_tid_address =411, ++sw64_sys_restart_syscall =412, ++sw64_sys_fadvise64 =413, ++sw64_sys_timer_create =414, ++sw64_sys_timer_settime =415, ++sw64_sys_timer_gettime =416, ++sw64_sys_timer_getoverrun =417, ++sw64_sys_timer_delete =418, ++sw64_sys_clock_settime =419, ++sw64_sys_clock_gettime =420, ++sw64_sys_clock_getres =421, ++sw64_sys_clock_nanosleep =422, ++sw64_sys_semtimedop =423, ++sw64_sys_tgkill =424, ++sw64_sys_stat64 =425, ++sw64_sys_lstat64 =426, ++sw64_sys_fstat64 =427, ++sw64_sys_vserver =428, ++sw64_sys_mbind =429, ++sw64_sys_get_mempolicy =430, ++sw64_sys_set_mempolicy =431, ++sw64_sys_mq_open =432, ++sw64_sys_mq_unlink =433, ++sw64_sys_mq_timedsend =434, ++sw64_sys_mq_timedreceive =435, ++sw64_sys_mq_notify =436, ++sw64_sys_mq_getsetattr =437, ++sw64_sys_waitid =438, ++sw64_sys_add_key =439, ++sw64_sys_request_key =440, ++sw64_sys_keyctl =441, ++sw64_sys_ioprio_set =442, ++sw64_sys_ioprio_get =443, ++sw64_sys_inotify_init =444, ++sw64_sys_inotify_add_watch =445, ++sw64_sys_inotify_rm_watch =446, ++sw64_sys_fdatasync =447, ++sw64_sys_kexec_load =448, ++sw64_sys_migrate_pages =449, ++sw64_sys_openat =450, ++sw64_sys_mkdirat =451, ++sw64_sys_mknodat =452, ++sw64_sys_fchownat =453, ++sw64_sys_futimesat =454, ++sw64_sys_fstatat64 =455, ++sw64_sys_unlinkat =456, ++sw64_sys_renameat =457, ++sw64_sys_linkat =458, ++sw64_sys_symlinkat =459, ++sw64_sys_readlinkat =460, ++sw64_sys_fchmodat =461, ++sw64_sys_faccessat =462, ++sw64_sys_pselect6 =463, ++sw64_sys_ppoll =464, ++sw64_sys_unshare =465, ++sw64_sys_set_robust_list =466, ++sw64_sys_get_robust_list =467, ++sw64_sys_splice =468, ++sw64_sys_sync_file_range =469, ++sw64_sys_tee =470, ++sw64_sys_vmsplice =471, ++sw64_sys_move_pages =472, ++sw64_sys_getcpu =473, ++sw64_sys_epoll_pwait =474, ++sw64_sys_utimensat =475, ++sw64_sys_signalfd =476, ++sw64_sys_timerfd =477, ++sw64_sys_eventfd =478, ++sw64_sys_recvmmsg =479, ++sw64_sys_fallocate =480, ++sw64_sys_timerfd_create =481, ++sw64_sys_timerfd_settime =482, ++sw64_sys_timerfd_gettime =483, ++sw64_sys_signalfd4 =484, ++sw64_sys_eventfd2 =485, ++sw64_sys_epoll_create1 =486, ++sw64_sys_dup3 =487, ++sw64_sys_pipe2 =488, ++sw64_sys_inotify_init1 =489, ++sw64_sys_preadv =490, ++sw64_sys_pwritev =491, ++sw64_sys_rt_tgsigqueueinfo =492, ++sw64_sys_perf_event_open =493, ++sw64_sys_fanotify_init =494, ++sw64_sys_fanotify_mark =495, ++sw64_sys_prlimit64 =496, ++sw64_sys_name_to_handle_at =497, ++sw64_sys_open_by_handle_at =498, ++sw64_sys_clock_adjtime =499, ++sw64_sys_syncfs =500, ++sw64_sys_setns =501, ++sw64_sys_accept4 =502, ++sw64_sys_sendmmsg =503, ++sw64_sys_process_vm_readv =504, ++sw64_sys_process_vm_writev =505, ++sw64_sys_kcmp =506, ++sw64_sys_finit_module =507, ++sw64_sys_sched_setattr =508, ++sw64_sys_sched_getattr =509, ++sw64_sys_renameat2 =510, ++sw64_sys_getrandom =511, ++sw64_sys_memfd_create =512, ++sw64_sys_execveat =513, ++sw64_sys_seccomp =514, ++sw64_sys_copy_file_range =515, ++sw64_sys_preadv2 =516, ++sw64_sys_pwritev2 =517, ++sw64_sys_statx =518, ++}; ++ ++/* sw64_canonicalize_syscall maps syscall ids from the native AArch64 ++ linux set of syscall ids into a canonical set of syscall ids used by ++ process record. */ ++ ++static enum gdb_syscall ++sw64_canonicalize_syscall (enum sw64_syscall syscall_number) ++{ ++#define SYSCALL_MAP(SYSCALL) case sw64_sys_##SYSCALL: \ ++ return gdb_sys_##SYSCALL ++ ++#define UNSUPPORTED_SYSCALL_MAP(SYSCALL) case sw64_sys_##SYSCALL: \ ++ return gdb_sys_no_syscall ++ ++ switch (syscall_number) ++ { ++ //sw syscall ++ //UNSUPPORTED_SYSCALL_MAP(SYSCALL) (execveat); ++ //UNSUPPORTED_SYSCALL_MAP (userfaultfd); ++ //UNSUPPORTED_SYSCALL_MAP (mlock2); ++ //UNSUPPORTED_SYSCALL_MAP (copy_file_range); ++ //UNSUPPORTED_SYSCALL_MAP (preadv2); ++ //UNSUPPORTED_SYSCALL_MAP (pwritev2); ++ //UNSUPPORTED_SYSCALL_MAP (renameat2); ++ //UNSUPPORTED_SYSCALL_MAP (seccomp); ++ //UNSUPPORTED_SYSCALL_MAP (getrandom); ++ //UNSUPPORTED_SYSCALL_MAP (memfd_create); ++ //UNSUPPORTED_SYSCALL_MAP (bpf); ++ //UNSUPPORTED_SYSCALL_MAP(syscalls); ++ ++ SYSCALL_MAP (open); ++ SYSCALL_MAP (fstatat64); ++ SYSCALL_MAP (io_setup); ++ SYSCALL_MAP (io_destroy); ++ SYSCALL_MAP (io_submit); ++ SYSCALL_MAP (io_cancel); ++ SYSCALL_MAP (io_getevents); ++ ++ SYSCALL_MAP (setxattr); ++ SYSCALL_MAP (lsetxattr); ++ SYSCALL_MAP (fsetxattr); ++ SYSCALL_MAP (getxattr); ++ SYSCALL_MAP (lgetxattr); ++ SYSCALL_MAP (fgetxattr); ++ SYSCALL_MAP (listxattr); ++ SYSCALL_MAP (llistxattr); ++ SYSCALL_MAP (flistxattr); ++ SYSCALL_MAP (removexattr); ++ SYSCALL_MAP (lremovexattr); ++ SYSCALL_MAP (fremovexattr); ++ SYSCALL_MAP (getcwd); ++ SYSCALL_MAP (lookup_dcookie); ++ SYSCALL_MAP (eventfd2); ++ SYSCALL_MAP (epoll_create1); ++ SYSCALL_MAP (epoll_ctl); ++ SYSCALL_MAP (epoll_pwait); ++ SYSCALL_MAP (dup); ++ SYSCALL_MAP (dup3); ++ SYSCALL_MAP (fcntl); ++ SYSCALL_MAP (inotify_init1); ++ SYSCALL_MAP (inotify_add_watch); ++ SYSCALL_MAP (inotify_rm_watch); ++ SYSCALL_MAP (ioctl); ++ SYSCALL_MAP (ioprio_set); ++ SYSCALL_MAP (ioprio_get); ++ SYSCALL_MAP (flock); ++ SYSCALL_MAP (mknodat); ++ SYSCALL_MAP (mkdirat); ++ SYSCALL_MAP (unlinkat); ++ SYSCALL_MAP (symlinkat); ++ SYSCALL_MAP (linkat); ++ SYSCALL_MAP (renameat); ++ UNSUPPORTED_SYSCALL_MAP (umount2); ++ SYSCALL_MAP (mount); ++ SYSCALL_MAP (pivot_root); ++ SYSCALL_MAP (nfsservctl); ++ SYSCALL_MAP (statfs); ++ SYSCALL_MAP (truncate); ++ SYSCALL_MAP (ftruncate); ++ SYSCALL_MAP (fallocate); ++ SYSCALL_MAP (faccessat); ++ SYSCALL_MAP (fchdir); ++ SYSCALL_MAP (chroot); ++ SYSCALL_MAP (fchmod); ++ SYSCALL_MAP (fchmodat); ++ SYSCALL_MAP (fchownat); ++ SYSCALL_MAP (fchown); ++ SYSCALL_MAP (openat); ++ SYSCALL_MAP (close); ++ SYSCALL_MAP (vhangup); ++ SYSCALL_MAP (pipe); ++ SYSCALL_MAP (pipe2); ++ SYSCALL_MAP (quotactl); ++ SYSCALL_MAP (getdents64); ++ SYSCALL_MAP (lseek); ++ SYSCALL_MAP (read); ++ SYSCALL_MAP (write); ++ SYSCALL_MAP (readv); ++ SYSCALL_MAP (writev); ++ SYSCALL_MAP (pread64); ++ SYSCALL_MAP (pwrite64); ++ UNSUPPORTED_SYSCALL_MAP (preadv); ++ UNSUPPORTED_SYSCALL_MAP (pwritev); ++ SYSCALL_MAP (sendfile); ++ SYSCALL_MAP (pselect6); ++ SYSCALL_MAP (ppoll); ++ UNSUPPORTED_SYSCALL_MAP (signalfd4); ++ SYSCALL_MAP (vmsplice); ++ SYSCALL_MAP (splice); ++ SYSCALL_MAP (tee); ++ SYSCALL_MAP (readlinkat); ++ //SYSCALL_MAP (newfstatat); ++ ++ SYSCALL_MAP (fstat); ++ SYSCALL_MAP (sync); ++ SYSCALL_MAP (fsync); ++ SYSCALL_MAP (fdatasync); ++ SYSCALL_MAP (sync_file_range); ++ UNSUPPORTED_SYSCALL_MAP (timerfd_create); ++ UNSUPPORTED_SYSCALL_MAP (timerfd_settime); ++ UNSUPPORTED_SYSCALL_MAP (timerfd_gettime); ++ UNSUPPORTED_SYSCALL_MAP (utimensat); ++ SYSCALL_MAP (acct); ++ SYSCALL_MAP (capget); ++ SYSCALL_MAP (capset); ++ SYSCALL_MAP (personality); ++ SYSCALL_MAP (exit); ++ SYSCALL_MAP (exit_group); ++ SYSCALL_MAP (waitid); ++ SYSCALL_MAP (set_tid_address); ++ SYSCALL_MAP (unshare); ++ SYSCALL_MAP (futex); ++ SYSCALL_MAP (set_robust_list); ++ SYSCALL_MAP (get_robust_list); ++ SYSCALL_MAP (nanosleep); ++ ++ SYSCALL_MAP (getitimer); ++ SYSCALL_MAP (setitimer); ++ SYSCALL_MAP (kexec_load); ++ SYSCALL_MAP (init_module); ++ SYSCALL_MAP (delete_module); ++ SYSCALL_MAP (timer_create); ++ SYSCALL_MAP (timer_settime); ++ SYSCALL_MAP (timer_gettime); ++ SYSCALL_MAP (timer_getoverrun); ++ SYSCALL_MAP (timer_delete); ++ SYSCALL_MAP (clock_settime); ++ SYSCALL_MAP (clock_gettime); ++ SYSCALL_MAP (clock_getres); ++ SYSCALL_MAP (clock_nanosleep); ++ SYSCALL_MAP (syslog); ++ SYSCALL_MAP (ptrace); ++ SYSCALL_MAP (sched_setparam); ++ SYSCALL_MAP (sched_setscheduler); ++ SYSCALL_MAP (sched_getscheduler); ++ SYSCALL_MAP (sched_getparam); ++ SYSCALL_MAP (sched_setaffinity); ++ SYSCALL_MAP (sched_getaffinity); ++ SYSCALL_MAP (sched_yield); ++ SYSCALL_MAP (sched_get_priority_max); ++ SYSCALL_MAP (sched_get_priority_min); ++ SYSCALL_MAP (sched_rr_get_interval); ++ SYSCALL_MAP (kill); ++ SYSCALL_MAP (tkill); ++ SYSCALL_MAP (tgkill); ++ SYSCALL_MAP (sigaltstack); ++ SYSCALL_MAP (rt_sigsuspend); ++ SYSCALL_MAP (rt_sigaction); ++ SYSCALL_MAP (sigprocmask); ++ SYSCALL_MAP (rt_sigprocmask); ++ SYSCALL_MAP (rt_sigpending); ++ SYSCALL_MAP (rt_sigtimedwait); ++ SYSCALL_MAP (rt_sigqueueinfo); ++ SYSCALL_MAP (sigreturn); ++ SYSCALL_MAP (rt_sigreturn); ++ SYSCALL_MAP (setpriority); ++ SYSCALL_MAP (getpriority); ++ SYSCALL_MAP (reboot); ++ SYSCALL_MAP (setregid); ++ SYSCALL_MAP (setgid); ++ SYSCALL_MAP (setreuid); ++ SYSCALL_MAP (setuid); ++ SYSCALL_MAP (setresuid); ++ SYSCALL_MAP (getresuid); ++ SYSCALL_MAP (setresgid); ++ SYSCALL_MAP (getresgid); ++ SYSCALL_MAP (setfsuid); ++ SYSCALL_MAP (setfsgid); ++ SYSCALL_MAP (times); ++ SYSCALL_MAP (setpgid); ++ SYSCALL_MAP (getpgid); ++ SYSCALL_MAP (getsid); ++ SYSCALL_MAP (setsid); ++ SYSCALL_MAP (getgroups); ++ SYSCALL_MAP (setgroups); ++ SYSCALL_MAP (uname); ++ SYSCALL_MAP (sethostname); ++ SYSCALL_MAP (setdomainname); ++ SYSCALL_MAP (getrlimit); ++ SYSCALL_MAP (setrlimit); ++ SYSCALL_MAP (getrusage); ++ SYSCALL_MAP (umask); ++ SYSCALL_MAP (prctl); ++ SYSCALL_MAP (getcpu); ++ SYSCALL_MAP (gettimeofday); ++ SYSCALL_MAP (settimeofday); ++ SYSCALL_MAP (adjtimex); ++ SYSCALL_MAP (getpid); ++ SYSCALL_MAP (getppid); ++ SYSCALL_MAP (getuid); ++ SYSCALL_MAP (geteuid); ++ SYSCALL_MAP (getgid); ++ SYSCALL_MAP (getegid); ++ SYSCALL_MAP (gettid); ++ SYSCALL_MAP (sysinfo); ++ SYSCALL_MAP (mq_open); ++ SYSCALL_MAP (mq_unlink); ++ SYSCALL_MAP (mq_timedsend); ++ SYSCALL_MAP (mq_timedreceive); ++ SYSCALL_MAP (mq_notify); ++ SYSCALL_MAP (mq_getsetattr); ++ SYSCALL_MAP (msgget); ++ SYSCALL_MAP (msgctl); ++ SYSCALL_MAP (msgrcv); ++ SYSCALL_MAP (msgsnd); ++ SYSCALL_MAP (semget); ++ SYSCALL_MAP (semctl); ++ SYSCALL_MAP (semtimedop); ++ SYSCALL_MAP (semop); ++ SYSCALL_MAP (shmget); ++ SYSCALL_MAP (shmctl); ++ SYSCALL_MAP (shmat); ++ SYSCALL_MAP (shmdt); ++ SYSCALL_MAP (socket); ++ SYSCALL_MAP (socketpair); ++ SYSCALL_MAP (bind); ++ SYSCALL_MAP (listen); ++ SYSCALL_MAP (accept); ++ SYSCALL_MAP (connect); ++ SYSCALL_MAP (getsockname); ++ SYSCALL_MAP (getpeername); ++ SYSCALL_MAP (sendto); ++ SYSCALL_MAP (recvfrom); ++ SYSCALL_MAP (setsockopt); ++ SYSCALL_MAP (getsockopt); ++ SYSCALL_MAP (shutdown); ++ SYSCALL_MAP (sendmsg); ++ SYSCALL_MAP (recvmsg); ++ SYSCALL_MAP (readahead); ++ SYSCALL_MAP (brk); ++ SYSCALL_MAP (munmap); ++ SYSCALL_MAP (mremap); ++ SYSCALL_MAP (add_key); ++ SYSCALL_MAP (request_key); ++ SYSCALL_MAP (keyctl); ++ SYSCALL_MAP (clone); ++ SYSCALL_MAP (execve); ++ ++ case sw64_sys_mmap: ++ return gdb_sys_mmap2; ++ ++ SYSCALL_MAP (fadvise64); ++ SYSCALL_MAP (swapon); ++ SYSCALL_MAP (swapoff); ++ SYSCALL_MAP (mprotect); ++ SYSCALL_MAP (msync); ++ SYSCALL_MAP (mlock); ++ SYSCALL_MAP (munlock); ++ SYSCALL_MAP (mlockall); ++ SYSCALL_MAP (munlockall); ++ SYSCALL_MAP (mincore); ++ SYSCALL_MAP (madvise); ++ SYSCALL_MAP (remap_file_pages); ++ SYSCALL_MAP (mbind); ++ SYSCALL_MAP (get_mempolicy); ++ SYSCALL_MAP (set_mempolicy); ++ SYSCALL_MAP (migrate_pages); ++ SYSCALL_MAP (move_pages); ++ UNSUPPORTED_SYSCALL_MAP (rt_tgsigqueueinfo); ++ UNSUPPORTED_SYSCALL_MAP (perf_event_open); ++ UNSUPPORTED_SYSCALL_MAP (accept4); ++ UNSUPPORTED_SYSCALL_MAP (recvmmsg); ++ ++ SYSCALL_MAP (wait4); ++ ++ UNSUPPORTED_SYSCALL_MAP (prlimit64); ++ UNSUPPORTED_SYSCALL_MAP (fanotify_init); ++ UNSUPPORTED_SYSCALL_MAP (fanotify_mark); ++ UNSUPPORTED_SYSCALL_MAP (name_to_handle_at); ++ UNSUPPORTED_SYSCALL_MAP (open_by_handle_at); ++ UNSUPPORTED_SYSCALL_MAP (clock_adjtime); ++ UNSUPPORTED_SYSCALL_MAP (syncfs); ++ UNSUPPORTED_SYSCALL_MAP (setns); ++ UNSUPPORTED_SYSCALL_MAP (sendmmsg); ++ UNSUPPORTED_SYSCALL_MAP (process_vm_readv); ++ UNSUPPORTED_SYSCALL_MAP (process_vm_writev); ++ UNSUPPORTED_SYSCALL_MAP (kcmp); ++ UNSUPPORTED_SYSCALL_MAP (finit_module); ++ UNSUPPORTED_SYSCALL_MAP (sched_setattr); ++ UNSUPPORTED_SYSCALL_MAP (sched_getattr); ++ default: ++ return gdb_sys_no_syscall; ++ } ++} ++ ++/* Record all registers but PC register for process-record. */ ++ ++static int ++sw64_all_but_pc_registers_record (struct regcache *regcache) ++{ ++ int i; ++ ++ for (i = SW64_A0_REGNUM; i < SW64_PC_REGNUM; i++) ++ if (record_full_arch_list_add_reg (regcache, i)) ++ return -1; ++ ++ if (record_full_arch_list_add_reg (regcache, SW64_CSR_REGNUM)) ++ return -1; ++ ++ return 0; ++} ++ ++/* Handler for sw64 system call instruction recording. */ ++ ++static int ++sw64_linux_syscall_record (struct regcache *regcache) ++{ ++ int ret = 0; ++ enum gdb_syscall syscall_gdb; ++ ULONGEST svc_number; ++ regcache_raw_read_unsigned (regcache, SW64_V0_REGNUM, &svc_number);//_ASM_ get regbuf ++ syscall_gdb = ++ sw64_canonicalize_syscall ((enum sw64_syscall) svc_number); ++ ++ if (syscall_gdb < 0) ++ { ++ printf_unfiltered (_("Process record and replay target doesn't " ++ "support syscall number %s\n"), ++ plongest (svc_number)); ++ return -1; ++ } ++ ++ if (syscall_gdb == gdb_sys_sigreturn ++ || syscall_gdb == gdb_sys_rt_sigreturn) ++ { ++ if (sw64_all_but_pc_registers_record (regcache)) ++ return -1; ++ return 0; ++ } ++ ++ ret = record_linux_system_call (syscall_gdb, regcache, &sw64_linux_record_tdep); ++ ++ if (ret != 0) ++ return ret; ++ ++ /* Record the return value of the system call. */ ++ if (record_full_arch_list_add_reg (regcache, SW64_V0_REGNUM)) ++ return -1; ++ ++ return 0; ++} ++#endif ++ ++static void ++sw64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) ++{ ++ linux_init_abi (info, gdbarch, 0); ++ ++ /* Hook into the DWARF CFI frame unwinder. */ ++ sw64_dwarf2_init_abi (info, gdbarch); ++ ++ /* Hook into the MDEBUG frame unwinder. */ ++ //sw64_mdebug_init_abi (info, gdbarch); ++ ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ tdep->dynamic_sigtramp_offset = sw64_linux_sigtramp_offset; ++ tdep->sigcontext_addr = sw64_linux_sigcontext_addr; ++ tdep->pc_in_sigtramp = sw64_linux_pc_in_sigtramp; ++ tdep->jb_pc = 2; ++ tdep->jb_elt_size = 8; ++ ++ set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); ++ ++ set_solib_svr4_fetch_link_map_offsets ++ (gdbarch, linux_lp64_fetch_link_map_offsets); ++ ++ /* Enable TLS support. */ ++ set_gdbarch_fetch_tls_load_module_address (gdbarch, ++ svr4_fetch_objfile_link_map); ++ ++ set_gdbarch_iterate_over_regset_sections ++ (gdbarch, sw64_linux_iterate_over_regset_sections); ++ ++ set_gdbarch_gdb_signal_from_target (gdbarch, ++ sw64_linux_gdb_signal_from_target); ++ set_gdbarch_gdb_signal_to_target (gdbarch, ++ sw64_linux_gdb_signal_to_target); ++ ++#ifndef LHX20240711_catch ++ /* Support catch syscall */ ++ set_xml_syscall_file_name (gdbarch, "syscalls/sw64-linux.xml"); ++ /* Get the syscall number from the arch's register. */ ++ set_gdbarch_get_syscall_number (gdbarch, sw64_linux_get_syscall_number); ++#endif ++ ++#ifndef LHX20240716_record ++ /* Reversible debugging, process record. */ ++ set_gdbarch_process_record (gdbarch, sw64_process_record); ++ /* Syscall record. */ ++ tdep->sw64_syscall_record = sw64_linux_syscall_record; ++ /* Displaced stepping. */ ++ //set_gdbarch_displaced_step_location (gdbarch, ++ // linux_displaced_step_location); ++ sw64_init_linux_record_tdep (&sw64_linux_record_tdep, 8); ++#endif ++} ++ ++void _initialize_sw64_linux_tdep (); ++void ++_initialize_sw64_linux_tdep () ++{ ++ gdbarch_register_osabi (bfd_arch_sw64, 0, GDB_OSABI_LINUX, ++ sw64_linux_init_abi); ++ ++ /* Initialize the standard target descriptions. */ ++ initialize_tdesc_sw64_linux (); ++} +diff -Naur gdb-14.1-after-patch/gdb/sw64-linux-tdep.h gdb-14.1-sw64/gdb/sw64-linux-tdep.h +--- gdb-14.1-after-patch/gdb/sw64-linux-tdep.h 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/sw64-linux-tdep.h 2025-03-03 10:59:13.210000000 +0800 +@@ -0,0 +1,45 @@ ++/* GNU/Linux on SW64 target support, prototypes. ++ ++ Copyright (C) 2012-2020 Free Software Foundation, Inc. ++ Contributed by ARM Ltd. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#ifndef SW64_LINUX_TDEP_H ++#define SW64_LINUX_TDEP_H ++ ++#include "regset.h" ++ ++/* The definitions of following two value come from sw64 kernel. ++ * linux-stable-sw/arch/sw_64/include/asm/elf.h: ++ * #define ELF_NGREG 33 ++ * #define ELF_NFPREG 32 ++ * It can also be found in header file /usr/include/sys/procfs.h ++ * */ ++#define SW64_LINUX_SIZEOF_GREGSET (33 * SW64_REGISTER_SIZE) ++ ++/* Refer to linux-stable-sw/arch/sw_64/kernel/process.c ++ * When fill in the fpu structure for a core dump, ++ * fp size in 4.19 is 32*8=256, but in 5.10 is 32*8*4=1024. ++ * kernel-4.19 (dump_elf_task_fp): memcpy(dest, sw->fp, 32 * 8); ++ * kernel-5.10 (dump_fpu): memcpy(fpu, ¤t->thread.fpstate, sizeof(*fpu)); ++ */ ++#define SW64_LINUX_SIZEOF_FPREGSET (32 * 4 * SW64_REGISTER_SIZE) ++ ++/* Target descriptions. */ ++extern const struct target_desc *tdesc_sw64_linux; ++ ++#endif /* SW64_LINUX_TDEP_H */ +diff -Naur gdb-14.1-after-patch/gdb/sw64-tdep.c gdb-14.1-sw64/gdb/sw64-tdep.c +--- gdb-14.1-after-patch/gdb/sw64-tdep.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/sw64-tdep.c 2025-03-03 10:59:13.660000000 +0800 +@@ -0,0 +1,2721 @@ ++/* Target-dependent code for the SW64 architecture, for GDB, the GNU Debugger. ++ ++ Copyright (C) 1993-2023 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include "defs.h" ++#include "frame.h" ++#include "frame-unwind.h" ++#include "frame-base.h" ++#include "dwarf2/frame.h" ++#include "inferior.h" ++#include "symtab.h" ++#include "value.h" ++#include "gdbcmd.h" ++#include "gdbcore.h" ++#include "dis-asm.h" ++#include "symfile.h" ++#include "objfiles.h" ++#include "linespec.h" ++#include "regcache.h" ++#include "reggroups.h" ++#include "arch-utils.h" ++#include "osabi.h" ++#include "block.h" ++#include "infcall.h" ++#include "trad-frame.h" ++ ++#include "elf-bfd.h" ++ ++#include "sw64-tdep.h" ++#include ++ ++#ifndef LHX20240716_record ++#include "record.h" ++#include "record-full.h" ++#endif ++ ++#ifndef LHX20240716_record ++#define submask(x) ((1L << ((x) + 1)) - 1) ++#define bits(obj,st,fn) (((obj) >> (st)) & submask ((fn) - (st))) ++#define bit(obj,st) (((obj) >> (st)) & 1) ++#define rigg(obj,st) ((obj) >> (st)) ++#endif ++ ++/* Instruction decoding. The notations for registers, immediates and ++ opcodes are the same as the one used in Compaq's SW64 architecture ++ handbook. */ ++ ++#define INSN_OPCODE(insn) ((insn & 0xfc000000) >> 26) ++#define INSN_FUNC(insn) ((insn & 0xf000) >> 12) ++ ++/* Memory instruction format */ ++#define MEM_RA(insn) ((insn & 0x03e00000) >> 21) ++#define MEM_RB(insn) ((insn & 0x001f0000) >> 16) ++#define MEM_DISP(insn) \ ++ (((insn & 0x8000) == 0) ? (insn & 0xffff) : -((-insn) & 0xffff)) ++ ++static const int lda_opcode = 0x3e; ++static const int stq_opcode = 0x2b; ++ ++/* Branch instruction format */ ++#define BR_RA(insn) MEM_RA(insn) ++ ++static const int br_opcode = 0x04; ++static const int bne_opcode = 0x31; ++ ++/* Operate instruction format */ ++#define OPR_FUNCTION(insn) ((insn & 0xfe0) >> 5) ++#define OPR_HAS_IMMEDIATE(insn) ((insn & 0x1000) == 0x1000) ++#define OPR_RA(insn) MEM_RA(insn) ++#define OPR_RC(insn) ((insn & 0x1f)) ++#define OPR_LIT(insn) ((insn & 0x1fe000) >> 13) ++ ++ ++static const int subq_opcode = 0x10; ++static const int subq_function = 0x09; ++ ++ ++/* Return the name of the REGNO register. ++ ++ An empty name corresponds to a register number that used to ++ be used for a virtual register. That virtual register has ++ been removed, but the index is still reserved to maintain ++ compatibility with existing remote sw64 targets. */ ++ ++static const char * ++sw64_register_name (struct gdbarch *gdbarch, int regno) ++{ ++ static const char * const register_names[] = ++ { ++#ifndef LHX20240710 ++ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", ++ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "fp", ++ "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", ++ "r24", "r25", "ra", "r27", "r28", "r29", "sp", "r31", ++#else ++ "v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6", ++ "t7", "s0", "s1", "s2", "s3", "s4", "s5", "fp", ++ "a0", "a1", "a2", "a3", "a4", "a5", "t8", "t9", ++ "t10", "t11", "ra", "t12", "at", "gp", "sp", "zero", ++#endif ++ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", ++ "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", ++ "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", ++ "f24", "f25", "f26", "f27", "f28", "f29", "f30", "fpcr", ++ "pc", "", "unique", /* num = 67 */ ++ ++ "ef0", "ef", "ef", "ef", "ef", "ef", "ef", "ef", ++ "ef1", "ef", "ef", "ef", "ef", "ef", "ef", "ef", ++ "ef2", "ef", "ef", "ef", "ef", "ef", "ef", "ef", ++ "ef3", "ef", "ef", "ef", "ef", "ef", "ef", "ef", /* ef0 */ ++ "ef4", "ef", "ef", "ef", "ef", "ef", "ef", "ef", ++ "ef5", "ef", "ef", "ef", "ef", "ef", "ef", "ef", ++ "ef6", "ef", "ef", "ef", "ef", "ef", "ef", "ef", ++ "ef7", "ef", "ef", "ef", "ef", "ef", "ef", "ef", /* ef1 */ ++ "ef8", "ef", "ef", "ef", "ef", "ef", "ef", "ef", ++ "ef9", "ef", "ef", "ef", "ef", "ef", "ef", "ef", ++ "ef10", "ef", "ef", "ef", "ef", "ef", "ef", "ef", ++ "ef11", "ef", "ef", "ef", "ef", "ef", "ef", "ef", /* ef2 */ /* num = 163 */ ++ ++ "", "", "", "", /*"DA_MATCH", "DA_MASK", "DV__MATCH", "DV_MASK",*/ /* num = 167 */ ++ ++ "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7", ++ "V8", "V9", "V10", "V11", "V12", "V13", "V14", "V15", ++ "V16", "V17", "V18", "V19", "V20", "V21", "V22", "V23", ++ "V24", "V25", "V26", "V27", "V28", "V29", "V30", "V31" /* num = 199 */ ++ }; ++ ++ gdb_static_assert (SW64_NUM_REGS + NVEC_REGS == ARRAY_SIZE (register_names)); ++ ++ if ((regno < 0) || (regno >= ARRAY_SIZE(register_names))) ++ return NULL; ++ ++ return register_names[regno]; ++} ++ ++static int ++sw64_cannot_fetch_register (struct gdbarch *gdbarch, int regno) ++{ ++ return (strlen (sw64_register_name (gdbarch, regno)) == 0); ++} ++ ++static int ++sw64_cannot_store_register (struct gdbarch *gdbarch, int regno) ++{ ++ return (regno == SW64_ZERO_REGNUM ++ || strlen (sw64_register_name (gdbarch, regno)) == 0); ++} ++ ++#ifndef LHX20240710 ++/* Construct vector type for ext registers. */ ++static struct type * ++sw64_vec_type (struct gdbarch *gdbarch) ++{ ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ ++ if (!tdep->sw64_vec_type) ++ { ++ struct type *t, *elem; ++ ++ t = arch_composite_type(gdbarch, "__gdb_builtin_type_vec256", TYPE_CODE_UNION); ++ ++ elem = builtin_type (gdbarch)->builtin_long_long; ++ append_composite_type_field (t, "v4_int64", init_vector_type (elem, 4)); ++ ++ elem = builtin_type (gdbarch)->builtin_double; ++ append_composite_type_field (t, "v4_double", init_vector_type (elem, 4)); ++ ++ t->set_is_vector (true); ++ t->set_name ("builtin_type_vec256"); ++ tdep->sw64_vec_type = t; ++ } ++ ++ return tdep->sw64_vec_type; ++} ++#endif ++ ++static struct type * ++sw64_register_type (struct gdbarch *gdbarch, int regno) ++{ ++ if (regno == SW64_SP_REGNUM || regno == SW64_GP_REGNUM) ++ return builtin_type (gdbarch)->builtin_data_ptr; ++ if (regno == SW64_PC_REGNUM) ++ return builtin_type (gdbarch)->builtin_func_ptr; ++ ++ /* Don't need to worry about little vs big endian until ++ some jerk tries to port to sw64-unicosmk. */ ++ if (regno >= SW64_FP0_REGNUM && regno < SW64_FP0_REGNUM + 31) ++ return builtin_type (gdbarch)->builtin_double; ++ ++#ifndef LHX20240710 ++ if (regno >= SW64_VEC0_REGNUM && regno < SW64_VEC0_REGNUM + 31 ) ++ return sw64_vec_type(gdbarch); ++ ++ if (regno >= 67 && regno < 163) ++ return builtin_type (gdbarch)->builtin_double; ++#endif ++ ++ return builtin_type (gdbarch)->builtin_int64; ++} ++ ++/* Is REGNUM a member of REGGROUP? */ ++ ++static int ++sw64_register_reggroup_p (struct gdbarch *gdbarch, int regnum, ++ const struct reggroup *group) ++{ ++ /* Filter out any registers eliminated, but whose regnum is ++ reserved for backward compatibility, e.g. the vfp. */ ++ if (*gdbarch_register_name (gdbarch, regnum) == '\0') ++ return 0; ++ ++ if (group == all_reggroup) ++ return 1; ++ ++ /* Zero should not be saved or restored. Technically it is a general ++ register (just as $f31 would be a float if we represented it), but ++ there's no point displaying it during "info regs", so leave it out ++ of all groups except for "all". */ ++ if (regnum == SW64_ZERO_REGNUM) ++ return 0; ++ ++ /* All other registers are saved and restored. */ ++ if (group == save_reggroup || group == restore_reggroup) ++ return 1; ++ ++ /* All other groups are non-overlapping. */ ++ ++ /* Since this is really a PALcode memory slot... */ ++ if (regnum == SW64_UNIQUE_REGNUM) ++ return group == system_reggroup; ++ ++ /* Force the FPCR to be considered part of the floating point state. */ ++ if (regnum == SW64_FPCR_REGNUM) ++ return group == float_reggroup; ++ ++ if (regnum >= SW64_FP0_REGNUM && regnum < SW64_FP0_REGNUM + 31) ++ return group == float_reggroup; ++ ++#ifndef LHX20240710 ++ if (regnum >= SW64_VEC0_REGNUM && regnum < SW64_VEC0_REGNUM + 31) ++ return group == vector_reggroup; ++ ++ if (regnum < SW64_ZERO_REGNUM ) ++ return group == general_reggroup; ++ else ++ return 0; ++#endif ++} ++ ++#ifndef LHX20240710 ++static enum register_status ++sw64_vec_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, ++ int regnum, gdb_byte *buf) ++{ ++ //printf("[sw64_vec_register_read] REG: read $V%d\n", regnum); ++ int i, fpnum; ++ enum register_status status; ++ gdb_byte fp_buf[SW64_REGISTER_SIZE]; ++ if (regnum >= SW64_VEC0_REGNUM && regnum < SW64_VEC0_REGNUM + 31) ++ { ++ fpnum = regnum - SW64_VEC0_REGNUM + SW64_FP0_REGNUM; ++ status = regcache->raw_read(fpnum, fp_buf); ++ if (status != REG_VALID) ++ return status; ++ memcpy (buf + 24, fp_buf, SW64_REGISTER_SIZE); ++ fpnum = regnum - SW64_VEC0_REGNUM + SW64_V0F3_REGNUM; ++ for (i = 0; i < 3; i++, fpnum -= 32) { ++ status = regcache->raw_read(fpnum, fp_buf); ++ if (status != REG_VALID) ++ return status; ++ memcpy (buf + (i << 3), fp_buf, SW64_REGISTER_SIZE); ++ } ++ } ++ return REG_VALID; ++} ++ ++static void ++sw64_vec_register_write (struct gdbarch *gdbarch, struct regcache *regcache, ++ int regnum, const gdb_byte *buf) ++{ ++ //printf("[sw64_vec_register_write] REG: write $V%d\n", regnum); ++ if (regnum >= SW64_VEC0_REGNUM && regnum < SW64_VEC0_REGNUM + 31) { ++ int i, fpnum; ++ ++ fpnum = regnum - SW64_VEC0_REGNUM + SW64_FP0_REGNUM; ++ regcache->raw_write (fpnum, buf+24); ++ ++ fpnum = regnum - SW64_VEC0_REGNUM + SW64_V0F3_REGNUM; ++ for (i = 0; i < 3; i++, fpnum -= 32 ) { ++ regcache->raw_write (fpnum, buf + (i << 3)); ++ } ++ } ++} ++#endif ++ ++/* Read an instruction from memory at PC, looking through breakpoints. */ ++/* n is power of 2, over 0 */ ++#if 0 ++unsigned int* ++sw64_read_insns (struct gdbarch *gdbarch, CORE_ADDR pc, int n) ++{ ++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ++ ++ /* alloc from stack frame, freed on return */ ++ gdb_byte *buf = (gdb_byte *)XALLOCAVEC(int, n); ++ unsigned int *ibuf = XCNEWVEC(unsigned int, n); ++ gdb_byte *p; ++ int res, i; ++ ++ res = target_read_memory (pc, buf, sizeof (int)*n); ++ if (res != 0) ++ memory_error (TARGET_XFER_E_IO, pc); ++ ++ n >>= 1; ++ for (i = 0, p = buf; i < n; i += 2) ++ { ++ extract_long_unsigned_integer(p, sizeof(long), byte_order, (long *)&ibuf[i]); ++ p += sizeof(long); ++ } ++ return ibuf; ++} ++#endif ++ ++/* The following represents exactly the conversion performed by ++ the LDS instruction. This applies to both single-precision ++ floating point and 32-bit integers. */ ++ ++static void ++sw64_lds (struct gdbarch *gdbarch, void *out, const void *in) ++{ ++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ++ ULONGEST mem ++ = extract_unsigned_integer ((const gdb_byte *) in, 4, byte_order); ++ ULONGEST frac = (mem >> 0) & 0x7fffff; ++ ULONGEST sign = (mem >> 31) & 1; ++ ULONGEST exp_msb = (mem >> 30) & 1; ++ ULONGEST exp_low = (mem >> 23) & 0x7f; ++ ULONGEST exp, reg; ++ ++ exp = (exp_msb << 10) | exp_low; ++ if (exp_msb) ++ { ++ if (exp_low == 0x7f) ++ exp = 0x7ff; ++ } ++ else ++ { ++ if (exp_low != 0x00) ++ exp |= 0x380; ++ } ++ ++ reg = (sign << 63) | (exp << 52) | (frac << 29); ++ store_unsigned_integer ((gdb_byte *) out, 8, byte_order, reg); ++} ++ ++/* Similarly, this represents exactly the conversion performed by ++ the STS instruction. */ ++ ++static void ++sw64_sts (struct gdbarch *gdbarch, void *out, const void *in) ++{ ++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ++ ULONGEST reg, mem; ++ ++ reg = extract_unsigned_integer ((const gdb_byte *) in, 8, byte_order); ++ mem = ((reg >> 32) & 0xc0000000) | ((reg >> 29) & 0x3fffffff); ++ store_unsigned_integer ((gdb_byte *) out, 4, byte_order, mem); ++} ++ ++/* The sw64 needs a conversion between register and memory format if the ++ register is a floating point register and memory format is float, as the ++ register format must be double or memory format is an integer with 4 ++ bytes, as the representation of integers in floating point ++ registers is different. */ ++ ++static int ++sw64_convert_register_p (struct gdbarch *gdbarch, int regno, ++ struct type *type) ++{ ++ return (regno >= SW64_FP0_REGNUM && regno < SW64_FP0_REGNUM + 31 ++ && type->length () == 4); ++} ++ ++static int ++sw64_register_to_value (frame_info_ptr frame, int regnum, ++ struct type *valtype, gdb_byte *out, ++ int *optimizedp, int *unavailablep) ++{ ++ struct gdbarch *gdbarch = get_frame_arch (frame); ++ struct value *value = get_frame_register_value (frame, regnum); ++ ++ gdb_assert (value != NULL); ++ *optimizedp = value->optimized_out (); ++ *unavailablep = !value->entirely_available (); ++ ++ if (*optimizedp || *unavailablep) ++ { ++ release_value (value); ++ return 0; ++ } ++ ++ /* Convert to VALTYPE. */ ++ ++ gdb_assert (valtype->length () == 4); ++ sw64_sts (gdbarch, out, value->contents_all ().data ()); ++ ++ release_value (value); ++ return 1; ++} ++ ++static void ++sw64_value_to_register (frame_info_ptr frame, int regnum, ++ struct type *valtype, const gdb_byte *in) ++{ ++ gdb_byte out[SW64_REGISTER_SIZE]; ++ ++ gdb_assert (valtype->length () == 4); ++ gdb_assert (register_size (get_frame_arch (frame), regnum) ++ <= SW64_REGISTER_SIZE); ++ sw64_lds (get_frame_arch (frame), out, in); ++ ++ put_frame_register (frame, regnum, out); ++} ++ ++ ++/* The sw64 passes the first six arguments in the registers, the rest on ++ the stack. The register arguments are stored in ARG_REG_BUFFER, and ++ then moved into the register file; this simplifies the passing of a ++ large struct which extends from the registers to the stack, plus avoids ++ three ptrace invocations per word. ++ ++ We don't bother tracking which register values should go in integer ++ regs or fp regs; we load the same values into both. ++ ++ If the called function is returning a structure, the address of the ++ structure to be returned is passed as a hidden first argument. */ ++ ++static CORE_ADDR ++sw64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, ++ struct regcache *regcache, CORE_ADDR bp_addr, ++ int nargs, struct value **args, CORE_ADDR sp, ++ function_call_return_method return_method, ++ CORE_ADDR struct_addr) ++{ ++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ++ int i; ++ int accumulate_size = (return_method == return_method_struct) ? 8 : 0; ++ struct sw64_arg ++ { ++ const gdb_byte *contents; ++ int len; ++ int offset; ++ }; ++ struct sw64_arg *sw64_args = XALLOCAVEC (struct sw64_arg, nargs); ++ struct sw64_arg *m_arg; ++ gdb_byte arg_reg_buffer[SW64_REGISTER_SIZE * SW64_NUM_ARG_REGS]; ++ int required_arg_regs; ++ CORE_ADDR func_addr = find_function_addr (function, NULL); ++ ++ /* The ABI places the address of the called function in T12. */ ++ regcache_cooked_write_signed (regcache, SW64_T12_REGNUM, func_addr); ++ ++ /* Set the return address register to point to the entry point ++ of the program, where a breakpoint lies in wait. */ ++ regcache_cooked_write_signed (regcache, SW64_RA_REGNUM, bp_addr); ++ ++ /* Lay out the arguments in memory. */ ++ for (i = 0, m_arg = sw64_args; i < nargs; i++, m_arg++) ++ { ++ struct value *arg = args[i]; ++ struct type *arg_type = check_typedef (arg->type ()); ++ ++ /* Cast argument to long if necessary as the compiler does it too. */ ++ switch (arg_type->code ()) ++ { ++ case TYPE_CODE_INT: ++ case TYPE_CODE_BOOL: ++ case TYPE_CODE_CHAR: ++ case TYPE_CODE_RANGE: ++ case TYPE_CODE_ENUM: ++ if (arg_type->length () == 4) ++ { ++ /* 32-bit values must be sign-extended to 64 bits ++ even if the base data type is unsigned. */ ++ arg_type = builtin_type (gdbarch)->builtin_int32; ++ arg = value_cast (arg_type, arg); ++ } ++ if (arg_type->length () < SW64_REGISTER_SIZE) ++ { ++ arg_type = builtin_type (gdbarch)->builtin_int64; ++ arg = value_cast (arg_type, arg); ++ } ++ break; ++ ++ case TYPE_CODE_FLT: ++ /* "float" arguments loaded in registers must be passed in ++ register format, aka "double". */ ++ if (accumulate_size < sizeof (arg_reg_buffer) ++ && arg_type->length () == 4) ++ { ++ arg_type = builtin_type (gdbarch)->builtin_double; ++ arg = value_cast (arg_type, arg); ++ } ++ /* Tru64 5.1 has a 128-bit long double, and passes this by ++ invisible reference. No one else uses this data type. */ ++ else if (arg_type->length () == 16) ++ { ++ /* Allocate aligned storage. */ ++ sp = (sp & -16) - 16; ++ ++ /* Write the real data into the stack. */ ++ write_memory (sp, arg->contents ().data (), 16); ++ ++ /* Construct the indirection. */ ++ arg_type = lookup_pointer_type (arg_type); ++ arg = value_from_pointer (arg_type, sp); ++ } ++ break; ++ ++ case TYPE_CODE_COMPLEX: ++ /* ??? The ABI says that complex values are passed as two ++ separate scalar values. This distinction only matters ++ for complex float. However, GCC does not implement this. */ ++ ++ /* Tru64 5.1 has a 128-bit long double, and passes this by ++ invisible reference. */ ++ if (arg_type->length () == 32) ++ { ++ /* Allocate aligned storage. */ ++ sp = (sp & -16) - 16; ++ ++ /* Write the real data into the stack. */ ++ write_memory (sp, arg->contents ().data (), 32); ++ ++ /* Construct the indirection. */ ++ arg_type = lookup_pointer_type (arg_type); ++ arg = value_from_pointer (arg_type, sp); ++ } ++ break; ++ ++ default: ++ break; ++ } ++ m_arg->len = arg_type->length (); ++ m_arg->offset = accumulate_size; ++ accumulate_size = (accumulate_size + m_arg->len + 7) & ~7; ++ m_arg->contents = arg->contents ().data (); ++ } ++ ++ /* Determine required argument register loads, loading an argument register ++ is expensive as it uses three ptrace calls. */ ++ required_arg_regs = accumulate_size / 8; ++ if (required_arg_regs > SW64_NUM_ARG_REGS) ++ required_arg_regs = SW64_NUM_ARG_REGS; ++ ++ /* Make room for the arguments on the stack. */ ++ if (accumulate_size < sizeof(arg_reg_buffer)) ++ accumulate_size = 0; ++ else ++ accumulate_size -= sizeof(arg_reg_buffer); ++ sp -= accumulate_size; ++ ++ /* Keep sp aligned to a multiple of 16 as the ABI requires. */ ++ sp &= ~15; ++ ++ /* `Push' arguments on the stack. */ ++ for (i = nargs; m_arg--, --i >= 0;) ++ { ++ const gdb_byte *contents = m_arg->contents; ++ int offset = m_arg->offset; ++ int len = m_arg->len; ++ ++ /* Copy the bytes destined for registers into arg_reg_buffer. */ ++ if (offset < sizeof(arg_reg_buffer)) ++ { ++ if (offset + len <= sizeof(arg_reg_buffer)) ++ { ++ memcpy (arg_reg_buffer + offset, contents, len); ++ continue; ++ } ++ else ++ { ++ int tlen = sizeof(arg_reg_buffer) - offset; ++ memcpy (arg_reg_buffer + offset, contents, tlen); ++ offset += tlen; ++ contents += tlen; ++ len -= tlen; ++ } ++ } ++ ++ /* Everything else goes to the stack. */ ++ write_memory (sp + offset - sizeof(arg_reg_buffer), contents, len); ++ } ++ if (return_method == return_method_struct) ++ store_unsigned_integer (arg_reg_buffer, SW64_REGISTER_SIZE, ++ byte_order, struct_addr); ++ ++ /* Load the argument registers. */ ++ for (i = 0; i < required_arg_regs; i++) ++ { ++ regcache->cooked_write (SW64_A0_REGNUM + i, ++ arg_reg_buffer + i * SW64_REGISTER_SIZE); ++ regcache->cooked_write (SW64_FPA0_REGNUM + i, ++ arg_reg_buffer + i * SW64_REGISTER_SIZE); ++ } ++ ++ /* Finally, update the stack pointer. */ ++ regcache_cooked_write_signed (regcache, SW64_SP_REGNUM, sp); ++ ++ return sp; ++} ++ ++/* Extract from REGCACHE the value about to be returned from a function ++ and copy it into VALBUF. */ ++ ++static void ++sw64_extract_return_value (struct type *valtype, struct regcache *regcache, ++ gdb_byte *valbuf) ++{ ++ struct gdbarch *gdbarch = regcache->arch (); ++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ++ gdb_byte raw_buffer[SW64_REGISTER_SIZE]; ++ ULONGEST l; ++ ++ switch (valtype->code ()) ++ { ++ case TYPE_CODE_FLT: ++ switch (valtype->length ()) ++ { ++ case 4: ++ regcache->cooked_read (SW64_FP0_REGNUM, raw_buffer); ++ sw64_sts (gdbarch, valbuf, raw_buffer); ++ break; ++ ++ case 8: ++ regcache->cooked_read (SW64_FP0_REGNUM, valbuf); ++ break; ++ ++ case 16: ++ regcache_cooked_read_unsigned (regcache, SW64_V0_REGNUM, &l); ++ read_memory (l, valbuf, 16); ++ break; ++ ++ default: ++ internal_error (_("unknown floating point width")); ++ } ++ break; ++ ++ case TYPE_CODE_COMPLEX: ++ switch (valtype->length ()) ++ { ++ case 8: ++ /* ??? This isn't correct wrt the ABI, but it's what GCC does. */ ++ regcache->cooked_read (SW64_FP0_REGNUM, valbuf); ++ break; ++ ++ case 16: ++ regcache->cooked_read (SW64_FP0_REGNUM, valbuf); ++ regcache->cooked_read (SW64_FP0_REGNUM + 1, valbuf + 8); ++ break; ++ ++ case 32: ++ regcache_cooked_read_unsigned (regcache, SW64_V0_REGNUM, &l); ++ read_memory (l, valbuf, 32); ++ break; ++ ++ default: ++ internal_error (_("unknown floating point width")); ++ } ++ break; ++ ++ default: ++ /* Assume everything else degenerates to an integer. */ ++ regcache_cooked_read_unsigned (regcache, SW64_V0_REGNUM, &l); ++ store_unsigned_integer (valbuf, valtype->length (), byte_order, l); ++ break; ++ } ++} ++ ++/* Insert the given value into REGCACHE as if it was being ++ returned by a function. */ ++ ++static void ++sw64_store_return_value (struct type *valtype, struct regcache *regcache, ++ const gdb_byte *valbuf) ++{ ++ struct gdbarch *gdbarch = regcache->arch (); ++ gdb_byte raw_buffer[SW64_REGISTER_SIZE]; ++ ULONGEST l; ++ ++ switch (valtype->code ()) ++ { ++ case TYPE_CODE_FLT: ++ switch (valtype->length ()) ++ { ++ case 4: ++ sw64_lds (gdbarch, raw_buffer, valbuf); ++ regcache->cooked_write (SW64_FP0_REGNUM, raw_buffer); ++ break; ++ ++ case 8: ++ regcache->cooked_write (SW64_FP0_REGNUM, valbuf); ++ break; ++ ++ case 16: ++ /* FIXME: 128-bit long doubles are returned like structures: ++ by writing into indirect storage provided by the caller ++ as the first argument. */ ++ error (_("Cannot set a 128-bit long double return value.")); ++ ++ default: ++ internal_error (_("unknown floating point width")); ++ } ++ break; ++ ++ case TYPE_CODE_COMPLEX: ++ switch (valtype->length ()) ++ { ++ case 8: ++ /* ??? This isn't correct wrt the ABI, but it's what GCC does. */ ++ regcache->cooked_write (SW64_FP0_REGNUM, valbuf); ++ break; ++ ++ case 16: ++ regcache->cooked_write (SW64_FP0_REGNUM, valbuf); ++ regcache->cooked_write (SW64_FP0_REGNUM + 1, valbuf + 8); ++ break; ++ ++ case 32: ++ /* FIXME: 128-bit long doubles are returned like structures: ++ by writing into indirect storage provided by the caller ++ as the first argument. */ ++ error (_("Cannot set a 128-bit long double return value.")); ++ ++ default: ++ internal_error (_("unknown floating point width")); ++ } ++ break; ++ ++ default: ++ /* Assume everything else degenerates to an integer. */ ++ /* 32-bit values must be sign-extended to 64 bits ++ even if the base data type is unsigned. */ ++ if (valtype->length () == 4) ++ valtype = builtin_type (gdbarch)->builtin_int32; ++ l = unpack_long (valtype, valbuf); ++ regcache_cooked_write_unsigned (regcache, SW64_V0_REGNUM, l); ++ break; ++ } ++} ++ ++static enum return_value_convention ++sw64_return_value (struct gdbarch *gdbarch, struct value *function, ++ struct type *type, struct regcache *regcache, ++ gdb_byte *readbuf, const gdb_byte *writebuf) ++{ ++ enum type_code code = type->code (); ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ ++ if ((code == TYPE_CODE_STRUCT ++ || code == TYPE_CODE_UNION ++ || code == TYPE_CODE_ARRAY) ++ && tdep->return_in_memory (type)) ++ { ++ if (readbuf) ++ { ++ ULONGEST addr; ++ regcache_raw_read_unsigned (regcache, SW64_V0_REGNUM, &addr); ++ read_memory (addr, readbuf, type->length ()); ++ } ++ ++ return RETURN_VALUE_ABI_RETURNS_ADDRESS; ++ } ++ ++ if (readbuf) ++ sw64_extract_return_value (type, regcache, readbuf); ++ if (writebuf) ++ sw64_store_return_value (type, regcache, writebuf); ++ ++ return RETURN_VALUE_REGISTER_CONVENTION; ++} ++ ++static int ++sw64_return_in_memory_always (struct type *type) ++{ ++ return 1; ++} ++ ++ ++constexpr gdb_byte sw64_break_insn[] = { 0x80, 0, 0, 0 }; /* call_pal bpt */ ++ ++typedef BP_MANIPULATION (sw64_break_insn) sw64_breakpoint; ++ ++ ++/* This returns the PC of the first insn after the prologue. ++ If we can't find the prologue, then return 0. */ ++ ++CORE_ADDR ++sw64_after_prologue (CORE_ADDR pc) ++{ ++ struct symtab_and_line sal; ++ CORE_ADDR func_addr, func_end; ++ ++ if (!find_pc_partial_function (pc, NULL, &func_addr, &func_end)) ++ return 0; ++ ++ sal = find_pc_line (func_addr, 0); ++ if (sal.end < func_end) ++ return sal.end; ++ ++ /* The line after the prologue is after the end of the function. In this ++ case, tell the caller to find the prologue the hard way. */ ++ return 0; ++} ++ ++/* Read an instruction from memory at PC, looking through breakpoints. */ ++ ++unsigned int ++sw64_read_insn (struct gdbarch *gdbarch, CORE_ADDR pc) ++{ ++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ++ gdb_byte buf[SW64_INSN_SIZE]; ++ int res; ++ ++ res = target_read_memory (pc, buf, sizeof (buf)); ++ if (res != 0) ++ memory_error (TARGET_XFER_E_IO, pc); ++ return extract_unsigned_integer (buf, sizeof (buf), byte_order); ++} ++ ++/* To skip prologues, I use this predicate. Returns either PC itself ++ if the code at PC does not look like a function prologue; otherwise ++ returns an address that (if we're lucky) follows the prologue. If ++ LENIENT, then we must skip everything which is involved in setting ++ up the frame (it's OK to skip more, just so long as we don't skip ++ anything which might clobber the registers which are being saved. */ ++ ++static CORE_ADDR ++sw64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) ++{ ++ unsigned long inst; ++ int offset; ++ CORE_ADDR post_prologue_pc; ++ gdb_byte buf[SW64_INSN_SIZE]; ++ ++ /* Silently return the unaltered pc upon memory errors. ++ This could happen on OSF/1 if decode_line_1 tries to skip the ++ prologue for quickstarted shared library functions when the ++ shared library is not yet mapped in. ++ Reading target memory is slow over serial lines, so we perform ++ this check only if the target has shared libraries (which all ++ SW64 targets do). */ ++ if (target_read_memory (pc, buf, sizeof (buf))) ++ return pc; ++ ++ /* See if we can determine the end of the prologue via the symbol table. ++ If so, then return either PC, or the PC after the prologue, whichever ++ is greater. */ ++ ++ post_prologue_pc = sw64_after_prologue (pc); ++ if (post_prologue_pc != 0) ++ return std::max (pc, post_prologue_pc); ++ ++ /* Can't determine prologue from the symbol table, need to examine ++ instructions. */ ++ ++ /* Skip the typical prologue instructions. These are the stack adjustment ++ instruction and the instructions that save registers on the stack ++ or in the gcc frame. */ ++ for (offset = 0; offset < 100; offset += SW64_INSN_SIZE) ++ { ++ inst = sw64_read_insn (gdbarch, pc + offset); ++#ifndef LHX20240710 ++ if ((inst & 0xffff0000) == 0xffbb0000) /* ldih $gp,n($t12) */ ++ continue; ++ if ((inst & 0xffff0000) == 0xfbbd0000) /* ldi $gp,n($gp) */ ++ continue; ++ if ((inst & 0xffff0000) == 0x8f7d0000) /* ldl t12,n($gp) */ ++ continue; ++ ++ if ((inst & 0xfffff000) == 0xfbde8000) /* ldi $sp,-n($sp) */ ++ continue; ++ if ((inst & 0xffe01fff) == 0x43c0153e) /* subq $sp,n,$sp */ ++ continue; ++ ++ if ((inst & 0xfc1f0000) == 0xac1e0000) /* stl reg,n($sp) */ ++ continue; ++ ++ if (inst == 0x43de074f) /* bis sp,sp,fp */ ++ continue; ++ if (inst == 0x43fe074f) /* bis zero,sp,fp */ ++ continue; ++#endif ++ break; ++ } ++ return pc + offset; ++} ++ ++ ++#ifndef LHX20240710 ++static const int ldq_l_opcode = 0x08; //lldl opcode ++static const int ldq_l_func = 0x01; //lldl function ++ ++static const int ldl_l_opcode = 0x08; //lldw opcode ++static const int ldl_l_func = 0x00; //lldw function ++ ++static const int stl_c_opcode = 0x08; //lstw opcode ++static const int stl_c_func = 0x08; //lstw function ++ ++static const int stq_c_opcode = 0x08; //lstl opcode ++static const int stq_c_func = 0x09; //lstl function ++#endif ++ ++/* Checks for an atomic sequence of instructions beginning with a LDL_L/LDQ_L ++ instruction and ending with a STL_C/STQ_C instruction. If such a sequence ++ is found, attempt to step through it. A breakpoint is placed at the end of ++ the sequence. */ ++ ++static std::vector ++sw64_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc) ++{ ++ CORE_ADDR breaks[2] = {CORE_ADDR_MAX, CORE_ADDR_MAX}; ++ CORE_ADDR loc = pc; ++ unsigned int insn = sw64_read_insn (gdbarch, loc); ++ int insn_count; ++ int index; ++ int last_breakpoint = 0; /* Defaults to 0 (no breakpoints placed). */ ++ const int atomic_sequence_length = 16; /* Instruction sequence length. */ ++ ++ /* Assume all atomic sequences start with a LDL_L/LDQ_L instruction. */ ++#ifndef LHX20240710 ++ if((INSN_OPCODE (insn) == ldl_l_opcode && (INSN_FUNC (insn) == ldl_l_func)) || ++ (INSN_OPCODE (insn) == ldq_l_opcode && (INSN_FUNC (insn) == ldq_l_func))) ++ ; // do nothing, continue ++ else ++ return {}; ++#endif ++ ++ /* Assume that no atomic sequence is longer than "atomic_sequence_length" ++ instructions. */ ++ for (insn_count = 0; insn_count < atomic_sequence_length; ++insn_count) ++ { ++ loc += SW64_INSN_SIZE; ++ insn = sw64_read_insn (gdbarch, loc); ++ ++ /* Assume that there is at most one branch in the atomic ++ sequence. If a branch is found, put a breakpoint in ++ its destination address. */ ++#if 0 // There is no branch in the atomic sequence in sw64 ++ if (INSN_OPCODE (insn) >= br_opcode) ++ { ++ int immediate = (insn & 0x001fffff) << 2; ++ ++ immediate = (immediate ^ 0x400000) - 0x400000; ++ ++ if (bc_insn_count >= 1) ++ return {}; /* More than one branch found, fallback ++ to the standard single-step code. */ ++ ++ breaks[1] = loc + SW64_INSN_SIZE + immediate; ++ ++ bc_insn_count++; ++ last_breakpoint++; ++ } ++#endif ++ ++#ifndef LHX20240710 ++ if((INSN_OPCODE (insn) == stl_c_opcode && (INSN_FUNC (insn) == stl_c_func)) ++ || (INSN_OPCODE (insn) == stq_c_opcode && (INSN_FUNC (insn) == stq_c_func))) ++ break; ++#endif ++ } ++ ++ /* Assume that the atomic sequence ends with a STL_C/STQ_C instruction. */ ++#ifndef LHX20220407 ++ if((INSN_OPCODE (insn) == stl_c_opcode && (INSN_FUNC (insn) == stl_c_func)) || ++ (INSN_OPCODE (insn) == stq_c_opcode && (INSN_FUNC (insn) == stq_c_func))) ++ ; // do nothing, continue ++ else ++ return {}; ++#endif ++ ++#ifndef LHX20240710 ++ loc += SW64_INSN_SIZE * 2; // also skip rd_f instruction which after lstw/lstl ++#endif ++ ++ /* Insert a breakpoint right after the end of the atomic sequence. */ ++ breaks[0] = loc; ++ ++ /* Check for duplicated breakpoints. Check also for a breakpoint ++ placed (branch instruction's destination) anywhere in sequence. */ ++ std::vector next_pcs; ++ ++ for (index = 0; index <= last_breakpoint; index++) ++ next_pcs.push_back (breaks[index]); ++ ++ return next_pcs; ++} ++ ++#ifndef LHX20240710 ++static void ++sw64_skip_permanent_breakpoint (struct regcache *regcache) ++{ ++ CORE_ADDR current_pc = regcache_read_pc (regcache); ++ current_pc += 4; ++ regcache_write_pc (regcache, current_pc); ++} ++#endif ++ ++ ++/* Figure out where the longjmp will land. ++ We expect the first arg to be a pointer to the jmp_buf structure from ++ which we extract the PC (JB_PC) that we will land at. The PC is copied ++ into the "pc". This routine returns true on success. */ ++ ++static int ++sw64_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc) ++{ ++ struct gdbarch *gdbarch = get_frame_arch (frame); ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ++ CORE_ADDR jb_addr; ++ gdb_byte raw_buffer[SW64_REGISTER_SIZE]; ++ ++ jb_addr = get_frame_register_unsigned (frame, SW64_A0_REGNUM); ++ ++ if (target_read_memory (jb_addr + (tdep->jb_pc * tdep->jb_elt_size), ++ raw_buffer, tdep->jb_elt_size)) ++ return 0; ++ ++ *pc = extract_unsigned_integer (raw_buffer, tdep->jb_elt_size, byte_order); ++ return 1; ++} ++ ++ ++/* Frame unwinder for signal trampolines. We use sw64 tdep bits that ++ describe the location and shape of the sigcontext structure. After ++ that, all registers are in memory, so it's easy. */ ++/* ??? Shouldn't we be able to do this generically, rather than with ++ OSABI data specific to SW64? */ ++ ++struct sw64_sigtramp_unwind_cache ++{ ++ CORE_ADDR sigcontext_addr; ++}; ++ ++static struct sw64_sigtramp_unwind_cache * ++sw64_sigtramp_frame_unwind_cache (frame_info_ptr this_frame, ++ void **this_prologue_cache) ++{ ++ struct sw64_sigtramp_unwind_cache *info; ++ ++ if (*this_prologue_cache) ++ return (struct sw64_sigtramp_unwind_cache *) *this_prologue_cache; ++ ++ info = FRAME_OBSTACK_ZALLOC (struct sw64_sigtramp_unwind_cache); ++ *this_prologue_cache = info; ++ ++ gdbarch *arch = get_frame_arch (this_frame); ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (arch); ++ info->sigcontext_addr = tdep->sigcontext_addr (this_frame); ++ ++ return info; ++} ++ ++/* Return the address of REGNUM in a sigtramp frame. Since this is ++ all arithmetic, it doesn't seem worthwhile to cache it. */ ++ ++static CORE_ADDR ++sw64_sigtramp_register_address (struct gdbarch *gdbarch, ++ CORE_ADDR sigcontext_addr, int regnum) ++{ ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ ++ if (regnum >= 0 && regnum < 32) ++ return sigcontext_addr + tdep->sc_regs_offset + regnum * 8; ++ else if (regnum >= SW64_FP0_REGNUM && regnum < SW64_FP0_REGNUM + 32) ++ return sigcontext_addr + tdep->sc_fpregs_offset + regnum * 8; ++ else if (regnum == SW64_PC_REGNUM) ++ return sigcontext_addr + tdep->sc_pc_offset; ++ ++ return 0; ++} ++ ++/* Given a GDB frame, determine the address of the calling function's ++ frame. This will be used to create a new GDB frame struct. */ ++ ++static void ++sw64_sigtramp_frame_this_id (frame_info_ptr this_frame, ++ void **this_prologue_cache, ++ struct frame_id *this_id) ++{ ++ struct gdbarch *gdbarch = get_frame_arch (this_frame); ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ struct sw64_sigtramp_unwind_cache *info ++ = sw64_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache); ++ CORE_ADDR stack_addr, code_addr; ++ ++ /* If the OSABI couldn't locate the sigcontext, give up. */ ++ if (info->sigcontext_addr == 0) ++ return; ++ ++ /* If we have dynamic signal trampolines, find their start. ++ If we do not, then we must assume there is a symbol record ++ that can provide the start address. */ ++ if (tdep->dynamic_sigtramp_offset) ++ { ++ int offset; ++ code_addr = get_frame_pc (this_frame); ++ offset = tdep->dynamic_sigtramp_offset (gdbarch, code_addr); ++ if (offset >= 0) ++ code_addr -= offset; ++ else ++ code_addr = 0; ++ } ++ else ++ code_addr = get_frame_func (this_frame); ++ ++ /* The stack address is trivially read from the sigcontext. */ ++ stack_addr = sw64_sigtramp_register_address (gdbarch, info->sigcontext_addr, ++ SW64_SP_REGNUM); ++ stack_addr = get_frame_memory_unsigned (this_frame, stack_addr, ++ SW64_REGISTER_SIZE); ++ ++ *this_id = frame_id_build (stack_addr, code_addr); ++} ++ ++/* Retrieve the value of REGNUM in FRAME. Don't give up! */ ++ ++static struct value * ++sw64_sigtramp_frame_prev_register (frame_info_ptr this_frame, ++ void **this_prologue_cache, int regnum) ++{ ++ struct sw64_sigtramp_unwind_cache *info ++ = sw64_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache); ++ CORE_ADDR addr; ++ ++ if (info->sigcontext_addr != 0) ++ { ++ /* All integer and fp registers are stored in memory. */ ++ addr = sw64_sigtramp_register_address (get_frame_arch (this_frame), ++ info->sigcontext_addr, regnum); ++ if (addr != 0) ++ return frame_unwind_got_memory (this_frame, regnum, addr); ++ } ++ ++ /* This extra register may actually be in the sigcontext, but our ++ current description of it in sw64_sigtramp_frame_unwind_cache ++ doesn't include it. Too bad. Fall back on whatever's in the ++ outer frame. */ ++ return frame_unwind_got_register (this_frame, regnum, regnum); ++} ++ ++static int ++sw64_sigtramp_frame_sniffer (const struct frame_unwind *self, ++ frame_info_ptr this_frame, ++ void **this_prologue_cache) ++{ ++ struct gdbarch *gdbarch = get_frame_arch (this_frame); ++ CORE_ADDR pc = get_frame_pc (this_frame); ++ const char *name; ++ ++ /* NOTE: cagney/2004-04-30: Do not copy/clone this code. Instead ++ look at tramp-frame.h and other simpler per-architecture ++ sigtramp unwinders. */ ++ ++ /* We shouldn't even bother to try if the OSABI didn't register a ++ sigcontext_addr handler or pc_in_sigtramp handler. */ ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ if (tdep->sigcontext_addr == NULL) ++ return 0; ++ ++ if (tdep->pc_in_sigtramp == NULL) ++ return 0; ++ ++ /* Otherwise we should be in a signal frame. */ ++ find_pc_partial_function (pc, &name, NULL, NULL); ++ if (tdep->pc_in_sigtramp (gdbarch, pc, name)) ++ return 1; ++ ++ return 0; ++} ++ ++static const struct frame_unwind sw64_sigtramp_frame_unwind = ++{ ++ "sw64 sigtramp", ++ SIGTRAMP_FRAME, ++ default_frame_unwind_stop_reason, ++ sw64_sigtramp_frame_this_id, ++ sw64_sigtramp_frame_prev_register, ++ NULL, ++ sw64_sigtramp_frame_sniffer ++}; ++ ++ ++ ++/* Heuristic_proc_start may hunt through the text section for a long ++ time across a 2400 baud serial line. Allows the user to limit this ++ search. */ ++#ifndef LHX20240710 ++static int heuristic_fence_post = 40; ++#else ++static int heuristic_fence_post = 0; ++#endif ++ ++/* Attempt to locate the start of the function containing PC. We assume that ++ the previous function ends with an about_to_return insn. Not foolproof by ++ any means, since gcc is happy to put the epilogue in the middle of a ++ function. But we're guessing anyway... */ ++ ++static CORE_ADDR ++sw64_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc) ++{ ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++ CORE_ADDR last_non_nop = pc; ++ CORE_ADDR fence = pc - heuristic_fence_post; ++ CORE_ADDR orig_pc = pc; ++ CORE_ADDR func; ++ struct inferior *inf; ++ ++ if (pc == 0) ++ return 0; ++ ++ /* First see if we can find the start of the function from minimal ++ symbol information. This can succeed with a binary that doesn't ++ have debug info, but hasn't been stripped. */ ++ func = get_pc_function_start (pc); ++ if (func) ++ return func; ++ ++ if (heuristic_fence_post == -1 ++ || fence < tdep->vm_min_address) ++ fence = tdep->vm_min_address; ++ ++ /* Search back for previous return; also stop at a 0, which might be ++ seen for instance before the start of a code section. Don't include ++ nops, since this usually indicates padding between functions. */ ++#ifdef LHX20240710 ++ for (pc -= SW64_INSN_SIZE; pc >= fence; pc -= SW64_INSN_SIZE) ++ { ++ unsigned int insn = sw64_read_insn (gdbarch, pc); ++ switch (insn) ++ { ++ case 0: /* invalid insn */ ++ case 0x6bfa8001: /* ret $31,($26),1 */ ++ return last_non_nop; ++ ++ case 0x2ffe0000: /* unop: ldq_u $31,0($30) */ ++ case 0x47ff041f: /* nop: bis $31,$31,$31 */ ++ break; ++ ++ default: ++ last_non_nop = pc; ++ break; ++ } ++ } ++#else ++ for (pc -= SW64_INSN_SIZE; pc >= fence; pc -= SW64_INSN_SIZE) ++ { ++ unsigned int insn = sw64_read_insn (gdbarch, pc); ++ ++ switch (insn) ++ { ++ case 0: /* invalid insn */ ++ case 0x6bfa8001: /* ret $31,($26),1 */ ++ case 0x0bfa0001: /* mater ret */ ++ return last_non_nop; ++ ++ case 0x2ffe0000: /* unop: ldq_u $31,0($30) */ ++ case 0x47ff041f: /* nop: bis $31,$31,$31 */ ++ break; ++ ++ default: ++ last_non_nop = pc; ++ break; ++ } ++ } ++#endif ++ ++ inf = current_inferior (); ++ ++ /* It's not clear to me why we reach this point when stopping quietly, ++ but with this test, at least we don't print out warnings for every ++ child forked (eg, on decstation). 22apr93 rich@cygnus.com. */ ++ if (inf->control.stop_soon == NO_STOP_QUIETLY) ++ { ++ static int blurb_printed = 0; ++ ++ if (fence == tdep->vm_min_address) ++ warning (_("Hit beginning of text section without finding \ ++enclosing function for address %s"), paddress (gdbarch, orig_pc)); ++ else ++ warning (_("Hit heuristic-fence-post without finding \ ++enclosing function for address %s"), paddress (gdbarch, orig_pc)); ++ ++ if (!blurb_printed) ++ { ++ gdb_printf (_("\ ++This warning occurs if you are debugging a function without any symbols\n\ ++(for example, in a stripped executable). In that case, you may wish to\n\ ++increase the size of the search with the `set heuristic-fence-post' command.\n\ ++\n\ ++Otherwise, you told GDB there was a function where there isn't one, or\n\ ++(more likely) you have encountered a bug in GDB.\n")); ++ blurb_printed = 1; ++ } ++ } ++ ++ return 0; ++} ++ ++/* Fallback sw64 frame unwinder. Uses instruction scanning and knows ++ something about the traditional layout of sw64 stack frames. */ ++ ++struct sw64_heuristic_unwind_cache ++{ ++ CORE_ADDR vfp; ++ CORE_ADDR start_pc; ++ struct trad_frame_saved_reg *saved_regs; ++ int return_reg; ++}; ++ ++/* If a probing loop sequence starts at PC, simulate it and compute ++ FRAME_SIZE and PC after its execution. Otherwise, return with PC and ++ FRAME_SIZE unchanged. */ ++ ++static void ++sw64_heuristic_analyze_probing_loop (struct gdbarch *gdbarch, CORE_ADDR *pc, ++ int *frame_size) ++{ ++ CORE_ADDR cur_pc = *pc; ++ int cur_frame_size = *frame_size; ++ int nb_of_iterations, reg_index, reg_probe; ++ unsigned int insn; ++ ++ /* The following pattern is recognized as a probing loop: ++ ++ lda REG_INDEX,NB_OF_ITERATIONS ++ lda REG_PROBE,(sp) ++ ++ LOOP_START: ++ stq zero,(REG_PROBE) ++ subq REG_INDEX,0x1,REG_INDEX ++ lda REG_PROBE,(REG_PROBE) ++ bne REG_INDEX, LOOP_START ++ ++ lda sp,(REG_PROBE) ++ ++ If anything different is found, the function returns without ++ changing PC and FRAME_SIZE. Otherwise, PC will point immediately ++ after this sequence, and FRAME_SIZE will be updated. */ ++ ++ /* lda REG_INDEX,NB_OF_ITERATIONS */ ++ ++ insn = sw64_read_insn (gdbarch, cur_pc); ++ if (INSN_OPCODE (insn) != lda_opcode) ++ return; ++ reg_index = MEM_RA (insn); ++ nb_of_iterations = MEM_DISP (insn); ++ ++ /* lda REG_PROBE,(sp) */ ++ ++ cur_pc += SW64_INSN_SIZE; ++ insn = sw64_read_insn (gdbarch, cur_pc); ++ if (INSN_OPCODE (insn) != lda_opcode ++ || MEM_RB (insn) != SW64_SP_REGNUM) ++ return; ++ reg_probe = MEM_RA (insn); ++ cur_frame_size -= MEM_DISP (insn); ++ ++ /* stq zero,(REG_PROBE) */ ++ ++ cur_pc += SW64_INSN_SIZE; ++ insn = sw64_read_insn (gdbarch, cur_pc); ++ if (INSN_OPCODE (insn) != stq_opcode ++ || MEM_RA (insn) != 0x1f ++ || MEM_RB (insn) != reg_probe) ++ return; ++ ++ /* subq REG_INDEX,0x1,REG_INDEX */ ++ ++ cur_pc += SW64_INSN_SIZE; ++ insn = sw64_read_insn (gdbarch, cur_pc); ++ if (INSN_OPCODE (insn) != subq_opcode ++ || !OPR_HAS_IMMEDIATE (insn) ++ || OPR_FUNCTION (insn) != subq_function ++ || OPR_LIT(insn) != 1 ++ || OPR_RA (insn) != reg_index ++ || OPR_RC (insn) != reg_index) ++ return; ++ ++ /* lda REG_PROBE,(REG_PROBE) */ ++ ++ cur_pc += SW64_INSN_SIZE; ++ insn = sw64_read_insn (gdbarch, cur_pc); ++ if (INSN_OPCODE (insn) != lda_opcode ++ || MEM_RA (insn) != reg_probe ++ || MEM_RB (insn) != reg_probe) ++ return; ++ cur_frame_size -= MEM_DISP (insn) * nb_of_iterations; ++ ++ /* bne REG_INDEX, LOOP_START */ ++ ++ cur_pc += SW64_INSN_SIZE; ++ insn = sw64_read_insn (gdbarch, cur_pc); ++ if (INSN_OPCODE (insn) != bne_opcode ++ || MEM_RA (insn) != reg_index) ++ return; ++ ++ /* lda sp,(REG_PROBE) */ ++ ++ cur_pc += SW64_INSN_SIZE; ++ insn = sw64_read_insn (gdbarch, cur_pc); ++ if (INSN_OPCODE (insn) != lda_opcode ++ || MEM_RA (insn) != SW64_SP_REGNUM ++ || MEM_RB (insn) != reg_probe) ++ return; ++ cur_frame_size -= MEM_DISP (insn); ++ ++ *pc = cur_pc; ++ *frame_size = cur_frame_size; ++} ++ ++static struct sw64_heuristic_unwind_cache * ++sw64_heuristic_frame_unwind_cache (frame_info_ptr this_frame, ++ void **this_prologue_cache, ++ CORE_ADDR start_pc) ++{ ++ struct gdbarch *gdbarch = get_frame_arch (this_frame); ++ struct sw64_heuristic_unwind_cache *info; ++ ULONGEST val; ++ CORE_ADDR limit_pc, cur_pc; ++ int frame_reg, frame_size, return_reg, reg; ++ ++ if (*this_prologue_cache) ++ return (struct sw64_heuristic_unwind_cache *) *this_prologue_cache; ++ ++ info = FRAME_OBSTACK_ZALLOC (struct sw64_heuristic_unwind_cache); ++ *this_prologue_cache = info; ++ info->saved_regs = trad_frame_alloc_saved_regs (this_frame); ++ ++ limit_pc = get_frame_pc (this_frame); ++ if (start_pc == 0) ++ start_pc = sw64_heuristic_proc_start (gdbarch, limit_pc); ++ info->start_pc = start_pc; ++ ++ frame_reg = SW64_SP_REGNUM; ++ frame_size = 0; ++ return_reg = -1; ++ ++ /* If we've identified a likely place to start, do code scanning. */ ++ if (start_pc != 0) ++ { ++ /* Limit the forward search to 50 instructions. */ ++ if (start_pc + 200 < limit_pc) ++ limit_pc = start_pc + 200; ++ ++ for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += SW64_INSN_SIZE) ++ { ++ unsigned int word = sw64_read_insn (gdbarch, cur_pc); ++ ++ //if ((word & 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */ ++ if ((word & 0xffff8000) == 0xfbde8000) ++ { ++ if (word & 0x8000) ++ { ++ /* Consider only the first stack allocation instruction ++ to contain the static size of the frame. */ ++ if (frame_size == 0) ++ frame_size = (-word) & 0xffff; ++ } ++ else ++ { ++ /* Exit loop if a positive stack adjustment is found, which ++ usually means that the stack cleanup code in the function ++ epilogue is reached. */ ++ break; ++ } ++ } ++ //else if ((word & 0xfc1f0000) == 0xb41e0000) /* stq reg,n($sp) */ ++ else if ((word & 0xfc1f8000) == 0xac1e0000 /* stl reg,n($sp) , n>0 */ ++ || (word & 0xfc1f8000) == 0xac0f0000) /* stl reg,n($fp) , n>0 */ ++ { ++ reg = (word & 0x03e00000) >> 21; ++ ++ /* Ignore this instruction if we have already encountered ++ an instruction saving the same register earlier in the ++ function code. The current instruction does not tell ++ us where the original value upon function entry is saved. ++ All it says is that the function we are scanning reused ++ that register for some computation of its own, and is now ++ saving its result. */ ++ if (info->saved_regs[reg].is_addr ()) ++ continue; ++ ++ if (reg == 31) ++ continue; ++ ++ /* Do not compute the address where the register was saved yet, ++ because we don't know yet if the offset will need to be ++ relative to $sp or $fp (we can not compute the address ++ relative to $sp if $sp is updated during the execution of ++ the current subroutine, for instance when doing some alloca). ++ So just store the offset for the moment, and compute the ++ address later when we know whether this frame has a frame ++ pointer or not. */ ++ /* Hack: temporarily add one, so that the offset is non-zero ++ and we can tell which registers have save offsets below. */ ++ info->saved_regs[reg].set_addr ((word & 0xffff) + 1); ++ ++ /* Starting with OSF/1-3.2C, the system libraries are shipped ++ without local symbols, but they still contain procedure ++ descriptors without a symbol reference. GDB is currently ++ unable to find these procedure descriptors and uses ++ heuristic_proc_desc instead. ++ As some low level compiler support routines (__div*, __add*) ++ use a non-standard return address register, we have to ++ add some heuristics to determine the return address register, ++ or stepping over these routines will fail. ++ Usually the return address register is the first register ++ saved on the stack, but assembler optimization might ++ rearrange the register saves. ++ So we recognize only a few registers (t7, t9, ra) within ++ the procedure prologue as valid return address registers. ++ If we encounter a return instruction, we extract the ++ return address register from it. ++ ++ FIXME: Rewriting GDB to access the procedure descriptors, ++ e.g. via the minimal symbol table, might obviate this ++ hack. */ ++ if (return_reg == -1 ++ && cur_pc < (start_pc + 80) ++ && (reg == SW64_T7_REGNUM ++ || reg == SW64_T9_REGNUM ++ || reg == SW64_RA_REGNUM)) ++ return_reg = reg; ++ } ++#ifndef LHX20240710 ++ else if ((word & 0xffe0ffff) == 0x0be00001) /* ret zero,reg,1 */ ++#endif ++ return_reg = (word >> 16) & 0x1f; ++#ifndef LHX20240710 ++ else if (word == 0x43de074f) /* bis sp,sp,fp */ ++ frame_reg = SW64_GCC_FP_REGNUM; ++ else if (word == 0x43fe074f) /* bis zero,sp,fp */ ++ frame_reg = SW64_GCC_FP_REGNUM; ++#endif ++ sw64_heuristic_analyze_probing_loop (gdbarch, &cur_pc, &frame_size); ++ } ++ ++ /* If we haven't found a valid return address register yet, keep ++ searching in the procedure prologue. */ ++ if (return_reg == -1) ++ { ++ while (cur_pc < (limit_pc + 80) && cur_pc < (start_pc + 80)) ++ { ++ unsigned int word = sw64_read_insn (gdbarch, cur_pc); ++ ++#ifndef LHX20240710 ++ if ((word & 0xfc1f0000) ==0xac1e0000 /* stl reg,n($sp) */ ++ || (word & 0xfc1f0000) == 0xac0f0000 /* stl reg,n($fp) */ ++ || (word & 0xfc1f0000) == 0xa80f0000 /* stw reg,n($fp) */ ++ || (word & 0xfc1f0000) == 0xa81e0000) /* stw reg,n($sp) */ ++#endif ++ { ++ reg = (word & 0x03e00000) >> 21; ++ if (reg == SW64_T7_REGNUM ++ || reg == SW64_T9_REGNUM ++ || reg == SW64_RA_REGNUM) ++ { ++ return_reg = reg; ++ break; ++ } ++ } ++#ifndef LHX20240710 ++ else if ((word & 0xffe0ffff) == 0x0be00001) /* ret zero,reg,1 */ ++#endif ++ { ++ return_reg = (word >> 16) & 0x1f; ++ break; ++ } ++ ++ cur_pc += SW64_INSN_SIZE; ++ } ++ } ++ } ++ ++ /* Failing that, do default to the customary RA. */ ++ if (return_reg == -1) ++ return_reg = SW64_RA_REGNUM; ++ info->return_reg = return_reg; ++ ++ val = get_frame_register_unsigned (this_frame, frame_reg); ++ info->vfp = val + frame_size; ++ ++ /* Convert offsets to absolute addresses. See above about adding ++ one to the offsets to make all detected offsets non-zero. */ ++ for (reg = 0; reg < SW64_NUM_REGS; ++reg) ++ if (info->saved_regs[reg].is_addr ()) ++ info->saved_regs[reg].set_addr (info->saved_regs[reg].addr () ++ + val - 1); ++ ++ /* The stack pointer of the previous frame is computed by popping ++ the current stack frame. */ ++ if (!info->saved_regs[SW64_SP_REGNUM].is_addr ()) ++ info->saved_regs[SW64_SP_REGNUM].set_value (info->vfp); ++ ++#ifndef LHX20240710 ++ if (frame_reg != SW64_SP_REGNUM ) ++ info->saved_regs[SW64_SP_REGNUM].set_addr (info->saved_regs[frame_reg].addr()); ++#endif ++ ++ return info; ++} ++ ++/* Given a GDB frame, determine the address of the calling function's ++ frame. This will be used to create a new GDB frame struct. */ ++ ++static void ++sw64_heuristic_frame_this_id (frame_info_ptr this_frame, ++ void **this_prologue_cache, ++ struct frame_id *this_id) ++{ ++ struct sw64_heuristic_unwind_cache *info ++ = sw64_heuristic_frame_unwind_cache (this_frame, this_prologue_cache, 0); ++ ++ *this_id = frame_id_build (info->vfp, info->start_pc); ++} ++ ++/* Retrieve the value of REGNUM in FRAME. Don't give up! */ ++ ++static struct value * ++sw64_heuristic_frame_prev_register (frame_info_ptr this_frame, ++ void **this_prologue_cache, int regnum) ++{ ++ struct sw64_heuristic_unwind_cache *info ++ = sw64_heuristic_frame_unwind_cache (this_frame, this_prologue_cache, 0); ++ ++ /* The PC of the previous frame is stored in the link register of ++ the current frame. Frob regnum so that we pull the value from ++ the correct place. */ ++ if (regnum == SW64_PC_REGNUM) ++ regnum = info->return_reg; ++ ++ return trad_frame_get_prev_register (this_frame, info->saved_regs, regnum); ++} ++ ++static const struct frame_unwind sw64_heuristic_frame_unwind = ++{ ++ "sw64 prologue", ++ NORMAL_FRAME, ++ default_frame_unwind_stop_reason, ++ sw64_heuristic_frame_this_id, ++ sw64_heuristic_frame_prev_register, ++ NULL, ++ default_frame_sniffer ++}; ++ ++static CORE_ADDR ++sw64_heuristic_frame_base_address (frame_info_ptr this_frame, ++ void **this_prologue_cache) ++{ ++ struct sw64_heuristic_unwind_cache *info ++ = sw64_heuristic_frame_unwind_cache (this_frame, this_prologue_cache, 0); ++ ++ return info->vfp; ++} ++ ++static const struct frame_base sw64_heuristic_frame_base = { ++ &sw64_heuristic_frame_unwind, ++ sw64_heuristic_frame_base_address, ++ sw64_heuristic_frame_base_address, ++ sw64_heuristic_frame_base_address ++}; ++ ++/* Just like reinit_frame_cache, but with the right arguments to be ++ callable as an sfunc. Used by the "set heuristic-fence-post" command. */ ++ ++static void ++reinit_frame_cache_sfunc (const char *args, ++ int from_tty, struct cmd_list_element *c) ++{ ++ reinit_frame_cache (); ++} ++ ++/* Helper routines for sw64*-nat.c files to move register sets to and ++ from core files. The UNIQUE pointer is allowed to be NULL, as most ++ targets don't supply this value in their core files. */ ++ ++void ++sw64_supply_int_regs (struct regcache *regcache, int regno, ++ const void *r0_r30, const void *pc, const void *unique) ++{ ++ const gdb_byte *regs = (const gdb_byte *) r0_r30; ++ int i; ++ ++ for (i = 0; i < 31; ++i) ++ if (regno == i || regno == -1) ++ regcache->raw_supply (i, regs + i * 8); ++ ++ if (regno == SW64_ZERO_REGNUM || regno == -1) ++ { ++ const gdb_byte zero[8] = { 0 }; ++ ++ regcache->raw_supply (SW64_ZERO_REGNUM, zero); ++ } ++ ++ if (regno == SW64_PC_REGNUM || regno == -1) ++ regcache->raw_supply (SW64_PC_REGNUM, pc); ++ ++ if (regno == SW64_UNIQUE_REGNUM || regno == -1) ++ regcache->raw_supply (SW64_UNIQUE_REGNUM, unique); ++} ++ ++void ++sw64_fill_int_regs (const struct regcache *regcache, ++ int regno, void *r0_r30, void *pc, void *unique) ++{ ++ gdb_byte *regs = (gdb_byte *) r0_r30; ++ int i; ++ ++ for (i = 0; i < 31; ++i) ++ if (regno == i || regno == -1) ++ regcache->raw_collect (i, regs + i * 8); ++ ++ if (regno == SW64_PC_REGNUM || regno == -1) ++ regcache->raw_collect (SW64_PC_REGNUM, pc); ++ ++ if (unique && (regno == SW64_UNIQUE_REGNUM || regno == -1)) ++ regcache->raw_collect (SW64_UNIQUE_REGNUM, unique); ++} ++ ++void ++sw64_supply_fp_regs (struct regcache *regcache, int regno, ++ const void *f0_f30, const void *fpcr) ++{ ++ const gdb_byte *regs = (const gdb_byte *) f0_f30; ++ int i; ++ ++ for (i = SW64_FP0_REGNUM; i < SW64_FP0_REGNUM + 31; ++i) ++ if (regno == i || regno == -1) ++ regcache->raw_supply (i, regs + (i - SW64_FP0_REGNUM) * 8); ++ ++ if (regno == SW64_FPCR_REGNUM || regno == -1) ++ regcache->raw_supply (SW64_FPCR_REGNUM, fpcr); ++} ++ ++void ++sw64_fill_fp_regs (const struct regcache *regcache, ++ int regno, void *f0_f30, void *fpcr) ++{ ++ gdb_byte *regs = (gdb_byte *) f0_f30; ++ int i; ++ ++ for (i = SW64_FP0_REGNUM; i < SW64_FP0_REGNUM + 31; ++i) ++ if (regno == i || regno == -1) ++ regcache->raw_collect (i, regs + (i - SW64_FP0_REGNUM) * 8); ++ ++ if (regno == SW64_FPCR_REGNUM || regno == -1) ++ regcache->raw_collect (SW64_FPCR_REGNUM, fpcr); ++} ++ ++ ++ ++/* Return nonzero if the G_floating register value in REG is equal to ++ zero for FP control instructions. */ ++ ++static int ++fp_register_zero_p (LONGEST reg) ++{ ++ /* Check that all bits except the sign bit are zero. */ ++ const LONGEST zero_mask = ((LONGEST) 1 << 63) ^ -1; ++ ++ return ((reg & zero_mask) == 0); ++} ++ ++/* Return the value of the sign bit for the G_floating register ++ value held in REG. */ ++ ++static int ++fp_register_sign_bit (LONGEST reg) ++{ ++ const LONGEST sign_mask = (LONGEST) 1 << 63; ++ ++ return ((reg & sign_mask) != 0); ++} ++ ++/* sw64_software_single_step() is called just before we want to resume ++ the inferior, if we want to single-step it but there is no hardware ++ or kernel single-step support (NetBSD on SW64, for example). We find ++ the target of the coming instruction and breakpoint it. */ ++ ++static CORE_ADDR ++sw64_next_pc (struct regcache *regcache, CORE_ADDR pc) ++{ ++ struct gdbarch *gdbarch = regcache->arch (); ++ unsigned int insn; ++ unsigned int op; ++ int regno; ++ int offset; ++ LONGEST rav; ++ ++ insn = sw64_read_insn (gdbarch, pc); ++ ++ /* Opcode is top 6 bits. */ ++ op = (insn >> 26) & 0x3f; ++ ++#ifndef LHX20240710 ++ switch (op) { ++ case 0x1: /* CALL */ ++ case 0x2: /* RET */ ++ case 0x3: /* JMP */ ++ return (regcache_raw_get_unsigned (regcache, (insn >> 16) & 0x1f) & ~3); ++ case 0x1d: /* LBR */ ++ offset = (insn & 0x03ffffff); ++ if (offset & 0x02000000) ++ offset |= 0xfc000000; ++ offset *= SW64_INSN_SIZE; ++ return (pc + SW64_INSN_SIZE + offset); ++ case 0x4: /* BR */ ++ case 0x5: /* BSR */ ++ branch_taken: ++ offset = (insn & 0x001fffff); ++ if (offset & 0x00100000) ++ offset |= 0xffe00000; ++ offset *= SW64_INSN_SIZE; ++ return (pc + SW64_INSN_SIZE + offset); ++ } ++ ++ /* Need to determine if branch is taken; read RA. */ ++ if ((op & 0x30) == 0x30) { ++ regno = (insn >> 21) & 0x1f; ++ switch (op) ++ { ++ case 0x38: /* FBEQ */ ++ case 0x39: /* FBNE */ ++ case 0x3a: /* FBLT */ ++ case 0x3b: /* FBLE */ ++ case 0x3c: /* FBGT */ ++ case 0x3d: /* FBGE */ ++ regno += gdbarch_fp0_regnum (gdbarch); ++ } ++ ++ rav = regcache_raw_get_signed (regcache, regno); ++ ++ switch (op) ++ { ++ case 0x36: /* BLBC */ ++ if ((rav & 1) == 0) ++ goto branch_taken; ++ break; ++ case 0x37: /* BLBS */ ++ if (rav & 1) ++ goto branch_taken; ++ break; ++ case 0x30: /* BEQ */ ++ if (rav == 0) ++ goto branch_taken; ++ break; ++ case 0x31: /* BNE */ ++ if (rav != 0) ++ goto branch_taken; ++ break; ++ case 0x32: /* BLT */ ++ if (rav < 0) ++ goto branch_taken; ++ break; ++ case 0x33: /* BLE */ ++ if (rav <= 0) ++ goto branch_taken; ++ break; ++ case 0x34: /* BGT */ ++ if (rav > 0) ++ goto branch_taken; ++ break; ++ case 0x35: /* BGE */ ++ if (rav >= 0) ++ goto branch_taken; ++ break; ++ ++ /* Floating point branches. */ ++ case 0x38: /* FBEQ */ ++ if (fp_register_zero_p (rav)) ++ goto branch_taken; ++ break; ++ case 0x3d: /* FBGE */ ++ if (fp_register_sign_bit (rav) == 0 || fp_register_zero_p (rav)) ++ goto branch_taken; ++ break; ++ case 0x3c: /* FBGT */ ++ if (fp_register_sign_bit (rav) == 0 && ! fp_register_zero_p (rav)) ++ goto branch_taken; ++ break; ++ case 0x3b: /* FBLE */ ++ if (fp_register_sign_bit (rav) == 1 || fp_register_zero_p (rav)) ++ goto branch_taken; ++ break; ++ case 0x3a: /* FBLT */ ++ if (fp_register_sign_bit (rav) == 1 && ! fp_register_zero_p (rav)) ++ goto branch_taken; ++ break; ++ case 0x39: /* FBNE */ ++ if (! fp_register_zero_p (rav)) ++ goto branch_taken; ++ break; ++ } ++ } ++#endif ++ ++ /* Not a branch or branch not taken; target PC is: ++ pc + 4 */ ++ return (pc + SW64_INSN_SIZE); ++} ++ ++std::vector ++sw64_software_single_step (struct regcache *regcache) ++{ ++ struct gdbarch *gdbarch = regcache->arch (); ++ ++ CORE_ADDR pc = regcache_read_pc (regcache); ++ ++ std::vector next_pcs ++ = sw64_deal_with_atomic_sequence (gdbarch, pc); ++ if (!next_pcs.empty ()) ++ return next_pcs; ++ ++ CORE_ADDR next_pc = sw64_next_pc (regcache, pc); ++ return {next_pc}; ++} ++ ++ ++/* Initialize the current architecture based on INFO. If possible, re-use an ++ architecture from ARCHES, which is a list of architectures already created ++ during this debugging session. ++ ++ Called e.g. at program startup, when reading a core file, and when reading ++ a binary file. */ ++ ++static struct gdbarch * ++sw64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) ++{ ++ //struct gdbarch *gdbarch; ++ ++ /* Find a candidate among extant architectures. */ ++ arches = gdbarch_list_lookup_by_info (arches, &info); ++ if (arches != NULL) ++ return arches->gdbarch; ++ ++ gdbarch *gdbarch ++ = gdbarch_alloc (&info, gdbarch_tdep_up (new sw64_gdbarch_tdep)); ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ++// sw64_gdbarch_tdep *tdep = new sw64_gdbarch_tdep; ++// gdbarch = gdbarch_alloc (&info, tdep); ++ ++ /* Lowest text address. This is used by heuristic_proc_start() ++ to decide when to stop looking. */ ++ tdep->vm_min_address = (CORE_ADDR) 0x120000000LL; ++ ++ tdep->dynamic_sigtramp_offset = NULL; ++ tdep->sigcontext_addr = NULL; ++ tdep->sc_pc_offset = 2 * 8; ++ tdep->sc_regs_offset = 4 * 8; ++ tdep->sc_fpregs_offset = tdep->sc_regs_offset + 32 * 8 + 8; ++ ++ tdep->jb_pc = -1; /* longjmp support not enabled by default. */ ++ ++ tdep->return_in_memory = sw64_return_in_memory_always; ++ ++#ifndef LHX20240710 ++ tdep->sw64_vec_type = 0; ++#endif ++ ++ /* Type sizes */ ++ set_gdbarch_short_bit (gdbarch, 16); ++ set_gdbarch_int_bit (gdbarch, 32); ++ set_gdbarch_long_bit (gdbarch, 64); ++ set_gdbarch_long_long_bit (gdbarch, 64); ++ set_gdbarch_wchar_bit (gdbarch, 64); ++ set_gdbarch_wchar_signed (gdbarch, 0); ++ set_gdbarch_float_bit (gdbarch, 32); ++ set_gdbarch_double_bit (gdbarch, 64); ++ set_gdbarch_long_double_bit (gdbarch, 64); ++ set_gdbarch_ptr_bit (gdbarch, 64); ++ ++ /* Register info */ ++ set_gdbarch_num_regs (gdbarch, SW64_NUM_REGS); ++ set_gdbarch_sp_regnum (gdbarch, SW64_SP_REGNUM); ++ set_gdbarch_pc_regnum (gdbarch, SW64_PC_REGNUM); ++ set_gdbarch_fp0_regnum (gdbarch, SW64_FP0_REGNUM); ++ ++ set_gdbarch_register_name (gdbarch, sw64_register_name); ++ set_gdbarch_register_type (gdbarch, sw64_register_type); ++ ++ set_gdbarch_cannot_fetch_register (gdbarch, sw64_cannot_fetch_register); ++ set_gdbarch_cannot_store_register (gdbarch, sw64_cannot_store_register); ++ ++ set_gdbarch_convert_register_p (gdbarch, sw64_convert_register_p); ++ set_gdbarch_register_to_value (gdbarch, sw64_register_to_value); ++ set_gdbarch_value_to_register (gdbarch, sw64_value_to_register); ++ ++ set_gdbarch_register_reggroup_p (gdbarch, sw64_register_reggroup_p); ++ ++ /* Prologue heuristics. */ ++ set_gdbarch_skip_prologue (gdbarch, sw64_skip_prologue); ++ ++#ifndef LHX20240710 ++ set_gdbarch_num_pseudo_regs (gdbarch, NVEC_REGS); ++ set_gdbarch_pseudo_register_read (gdbarch, sw64_vec_register_read); ++ set_gdbarch_pseudo_register_write (gdbarch, sw64_vec_register_write); ++ set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1); ++#endif ++ ++ /* Call info. */ ++ ++ set_gdbarch_return_value (gdbarch, sw64_return_value); ++ ++ /* Settings for calling functions in the inferior. */ ++ set_gdbarch_push_dummy_call (gdbarch, sw64_push_dummy_call); ++ ++ set_gdbarch_inner_than (gdbarch, core_addr_lessthan); ++ set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); ++ ++#ifndef LHX20240710 ++ set_gdbarch_skip_permanent_breakpoint (gdbarch, sw64_skip_permanent_breakpoint); ++#endif ++ ++ set_gdbarch_breakpoint_kind_from_pc (gdbarch, ++ sw64_breakpoint::kind_from_pc); ++ set_gdbarch_sw_breakpoint_from_kind (gdbarch, ++ sw64_breakpoint::bp_from_kind); ++ set_gdbarch_decr_pc_after_break (gdbarch, SW64_INSN_SIZE); ++ set_gdbarch_cannot_step_breakpoint (gdbarch, 1); ++ ++#ifndef LHX20240710 ++ set_gdbarch_num_pseudo_regs (gdbarch, NVEC_REGS); ++ set_gdbarch_pseudo_register_read (gdbarch, sw64_vec_register_read); ++ set_gdbarch_pseudo_register_write (gdbarch, sw64_vec_register_write); ++ set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1); ++#endif ++ ++ /* Handles single stepping of atomic sequences. */ ++ set_gdbarch_software_single_step (gdbarch, sw64_software_single_step); ++ ++ /* Hook in ABI-specific overrides, if they have been registered. */ ++ gdbarch_init_osabi (info, gdbarch); ++ ++ /* Now that we have tuned the configuration, set a few final things ++ based on what the OS ABI has told us. */ ++ ++ if (tdep->jb_pc >= 0) ++ set_gdbarch_get_longjmp_target (gdbarch, sw64_get_longjmp_target); ++ ++ frame_unwind_append_unwinder (gdbarch, &sw64_sigtramp_frame_unwind); ++ frame_unwind_append_unwinder (gdbarch, &sw64_heuristic_frame_unwind); ++ ++ frame_base_set_default (gdbarch, &sw64_heuristic_frame_base); ++ ++ return gdbarch; ++} ++ ++void ++sw64_dwarf2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) ++{ ++ dwarf2_append_unwinders (gdbarch); ++ frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer); ++} ++ ++void _initialize_sw64_tdep (); ++void ++_initialize_sw64_tdep () ++{ ++ ++ gdbarch_register (bfd_arch_sw64, sw64_gdbarch_init, NULL); ++ ++ /* Let the user set the fence post for heuristic_proc_start. */ ++ ++ /* We really would like to have both "0" and "unlimited" work, but ++ command.c doesn't deal with that. So make it a var_zinteger ++ because the user can always use "999999" or some such for unlimited. */ ++ /* We need to throw away the frame cache when we set this, since it ++ might change our ability to get backtraces. */ ++ add_setshow_zinteger_cmd ("heuristic-fence-post", class_support, ++ &heuristic_fence_post, _("\ ++Set the distance searched for the start of a function."), _("\ ++Show the distance searched for the start of a function."), _("\ ++If you are debugging a stripped executable, GDB needs to search through the\n\ ++program for the start of a function. This command sets the distance of the\n\ ++search. The only need to set it is when debugging a stripped executable."), ++ reinit_frame_cache_sfunc, ++ NULL, /* FIXME: i18n: The distance searched for ++ the start of a function is \"%d\". */ ++ &setlist, &showlist); ++} ++ ++#ifndef LHX20240716_record ++/* SW64 process record-replay related structures, defines etc. */ ++ ++#define REG_ALLOC(REGS, LENGTH, RECORD_BUF) \ ++ do \ ++ { \ ++ unsigned int reg_len = LENGTH; \ ++ if (reg_len) \ ++ { \ ++ REGS = XNEWVEC (uint32_t, reg_len); \ ++ memcpy(®S[0], &RECORD_BUF[0], sizeof(uint32_t)*LENGTH); \ ++ } \ ++ } \ ++ while (0) ++ ++#define MEM_ALLOC(MEMS, LENGTH, RECORD_BUF) \ ++ do \ ++ { \ ++ unsigned int mem_len = LENGTH; \ ++ if (mem_len) \ ++ { \ ++ MEMS = XNEWVEC (struct sw64_mem_r, mem_len); \ ++ memcpy(&MEMS->len, &RECORD_BUF[0], \ ++ sizeof(struct sw64_mem_r) * LENGTH); \ ++ } \ ++ } \ ++ while (0) ++ ++/* SW64 record/replay structures and enumerations. */ ++ ++struct sw64_mem_r ++{ ++ uint64_t len; /* Record length. */ ++ uint64_t addr; /* Memory address. */ ++}; ++ ++enum sw64_record_result ++{ ++ SW64_RECORD_SUCCESS, ++ SW64_RECORD_UNSUPPORTED, ++ SW64_RECORD_UNKNOWN ++}; ++ ++struct sw64_insn_decode_record ++{ ++ struct gdbarch *gdbarch; ++ struct regcache *regcache; ++ CORE_ADDR this_addr; /* Address of insn to be recorded. */ ++ uint32_t sw64_insn; /* Insn to be recorded. */ ++ uint32_t mem_rec_count; /* Count of memory records. */ ++ uint32_t reg_rec_count; /* Count of register records. */ ++ uint32_t *sw64_regs; /* Registers to be recorded. */ ++ struct sw64_mem_r *sw64_mems; /* Memory locations to be recorded. */ ++}; ++ ++static unsigned int ++sw64_record_data_proc_reg (sw64_insn_decode_record *sw64_insn_r) ++{ ++ uint8_t insn_bits21_25; ++ insn_bits21_25 = (rigg (sw64_insn_r->sw64_insn, 21) & 0x1F); ++ uint8_t ins_bits5_12; ++ ins_bits5_12 = (rigg(sw64_insn_r->sw64_insn,5) & 0xff); ++ uint32_t ins_bit31_26; ++ ins_bit31_26 = rigg (sw64_insn_r->sw64_insn,26); ++ uint8_t ins_bits0_4; ++ ins_bits0_4 = (sw64_insn_r->sw64_insn & 0x1F); ++ uint32_t record_buf[4]; ++ record_buf[0] = ins_bits0_4; ++ if(ins_bit31_26 == 0x18) ++ { ++ if(ins_bits5_12 == 0x50) ++ { ++ record_buf[0] = insn_bits21_25+32; ++ } ++ else if(ins_bits5_12 == 0x51 || (0x54 <= ins_bits5_12 && ins_bits5_12 <= 0x57)) ++ { ++ record_buf[0] = SW64_FPCR_REGNUM; ++ } ++ else ++ { ++ record_buf[0] = ins_bits0_4+32; ++ } ++ } ++ if(0x14 <= ins_bit31_26 && ins_bit31_26<= 0x17) ++ { ++ record_buf[0] = ins_bits0_4;//+167; ++ } ++ if(ins_bit31_26 == 0x1a) ++ { ++ if(ins_bits5_12 == 0x2 || ins_bits5_12 == 0x22 || ins_bits5_12 == 0x18 || ins_bits5_12 == 0x19) ++ { ++ record_buf[0] = ins_bits0_4+32; ++ } ++ else ++ { ++ record_buf[0] = ins_bits0_4;//+167; ++ } ++ } ++ if(ins_bit31_26 == 0x1b) ++ { ++ if(ins_bits5_12 == 0x22 || ins_bits5_12 == 0x23) ++ { ++ record_buf[0] = ins_bits0_4+32; ++ } ++ record_buf[0] = ins_bits0_4;//+167; ++ } ++ sw64_insn_r->reg_rec_count = 1; ++ REG_ALLOC (sw64_insn_r->sw64_regs, sw64_insn_r->reg_rec_count,record_buf); ++ return SW64_RECORD_SUCCESS; ++} ++ ++static unsigned int ++sw64_record_data_proc_imm (sw64_insn_decode_record *sw64_insn_r) ++{ ++ sw64_gdbarch_tdep *tdep = gdbarch_tdep (sw64_insn_r->gdbarch); ++ if(sw64_insn_r->sw64_insn == 0x200009e) ++ { ++ for(int i=0;i<32;i++) ++ { ++ record_full_arch_list_add_reg(sw64_insn_r->regcache,i); ++ } ++ return SW64_RECORD_SUCCESS; ++ } ++ if (tdep->sw64_syscall_record != NULL) ++ { ++ return tdep->sw64_syscall_record (sw64_insn_r->regcache); ++ ++ } ++ else ++ return SW64_RECORD_UNSUPPORTED; ++} ++ ++static unsigned int ++sw64_record_branch_except_sys (sw64_insn_decode_record *sw64_insn_r) ++{ ++ //struct gdbarch_tdep *tdep = gdbarch_tdep (sw64_insn_r->gdbarch); ++ uint32_t ins_bit31_26; ++ ins_bit31_26 = rigg (sw64_insn_r->sw64_insn, 26); ++ uint32_t record_buf[4]; ++ uint8_t insn_bits21_25; ++ insn_bits21_25 = (rigg (sw64_insn_r->sw64_insn, 21) & 0x1F); ++ /*Test & branch*/ ++ if (0x30 <= ins_bit31_26 && ins_bit31_26<= 0x3D) ++ { ++ record_buf[sw64_insn_r->reg_rec_count++] = SW64_PC_REGNUM; ++ } ++ else ++ { ++ //record_buf[sw64_insn_r->reg_rec_count++] = SW64_PC_REGNUM; ++ record_buf[sw64_insn_r->reg_rec_count++] = insn_bits21_25; ++ } ++ REG_ALLOC (sw64_insn_r->sw64_regs, sw64_insn_r->reg_rec_count, ++ record_buf); ++ return SW64_RECORD_SUCCESS; ++} ++ ++static unsigned int ++sw64_record_load_store (sw64_insn_decode_record *sw64_insn_r) ++{ ++ uint8_t bit12; ++ bit12=bit(sw64_insn_r->sw64_insn, 12); ++ uint8_t insn_bits12_15; ++ insn_bits12_15=(rigg(sw64_insn_r->sw64_insn, 12) & 0xf); ++ uint32_t insn_bits0_15; ++ insn_bits0_15 = (sw64_insn_r->sw64_insn & 0xffff); ++ uint8_t insn_bits21_25; ++ uint8_t insn_bits16_20; ++ uint8_t insn_bits8_15; ++ insn_bits8_15 = (rigg(sw64_insn_r->sw64_insn, 8) & 0xff); ++ uint32_t ins_bit31_26; ++ ins_bit31_26 = rigg (sw64_insn_r->sw64_insn, 26); ++ insn_bits16_20 = (rigg(sw64_insn_r->sw64_insn, 16) & 0x1f); ++ uint8_t insn_bit0_16; ++ insn_bit0_16=(sw64_insn_r->sw64_insn & 0xffff); ++ uint32_t record_buf[8]; ++ uint64_t record_buf_mem[8]; ++ CORE_ADDR address; ++ int save_size; ++ insn_bits21_25 = (rigg (sw64_insn_r->sw64_insn, 21) & 0x1F);// ++ int Byte4_len; ++ int disp15,disp11; ++ disp15 = sw64_insn_r->sw64_insn & 0xffff; ++ disp11 = sw64_insn_r->sw64_insn & 0xfff; ++ if(sw64_insn_r->sw64_insn & 0x8000) ++ { ++ disp15 |= 0xffff0000; ++ } ++ if(sw64_insn_r->sw64_insn & 0x800) ++ { ++ disp11 |= 0xfffff000; ++ } ++ /*load imme , transfer*/ ++ if ((0x3E <= ins_bit31_26 && ins_bit31_26<= 0x3F) || ins_bit31_26 ==0x07 || ins_bit31_26 == 0x25) ++ { ++ // if (record_debug) ++ // debug_printf ("Process record: load register (literal)\n"); ++ record_buf[0] = insn_bits21_25; ++ sw64_insn_r->reg_rec_count = 1; ++ } ++ else if((0x09 <= ins_bit31_26 && ins_bit31_26<= 0x0F) || ins_bit31_26 == 0x1C)//simd save and load ++ { ++ if(0x09 <= ins_bit31_26 && ins_bit31_26<= 0x0D) ++ { ++ record_buf[0] = insn_bits21_25;//+167; ++ sw64_insn_r->reg_rec_count = 1; ++ } ++ else if(0x0E == ins_bit31_26 || ins_bit31_26 == 0x0F || ins_bit31_26 == 0x1C) ++ { ++ if(ins_bit31_26 == 0x1C && insn_bits12_15 == 0xe) ++ { ++ regcache_raw_read_unsigned (sw64_insn_r->regcache, insn_bits16_20, ++ &address); ++ address+=disp11; ++ record_buf_mem[0] = 32; ++ record_buf_mem[1] = address; ++ sw64_insn_r->mem_rec_count = 1; ++ } ++ regcache_raw_read_unsigned (sw64_insn_r->regcache, insn_bits16_20, ++ &address); ++ if(ins_bit31_26 == 0xe && ins_bit31_26 == 0xf) ++ { ++ address+=disp15; ++ } ++ address+=(sw64_insn_r->sw64_insn & 0xfff); ++ if(ins_bit31_26 == 0x1C) ++ { ++ switch(insn_bits12_15) ++ { ++ case 0x9: ++ case 0x8: ++ case 0x1: ++ Byte4_len = ((address & 0x1f) >> 2); ++ address=address & 0xffffffffffffffe0; ++ break; ++ case 0xb: ++ case 0xa: ++ case 0x3: ++ Byte4_len = ((address & 0xf) >> 2); ++ address=address & 0xfffffffffffffff0; ++ break; ++ case 0xf: ++ save_size=32; ++ break; ++ case 0xd: ++ case 0xc: ++ case 0x5: ++ Byte4_len = ((address & 0x1f) >> 3); ++ address=address & 0xffffffffffffffe0; ++ break; ++ default: ++ goto simdsave; ++ break; ++ } ++ } ++ switch(ins_bit31_26) ++ { ++ case 0x0e: ++ save_size=16; ++ break; ++ case 0xf: ++ save_size=32; ++ break; ++ case 0x1C: ++ switch(insn_bits12_15) ++ { ++ case 0x01: ++ save_size=32; ++ break; ++ case 0x03: ++ /* fallthrough */ ++ case 0x05: ++ save_size=16; ++ break; ++ case 0x8: ++ save_size=32-4*Byte4_len; ++ address+=Byte4_len*4; ++ break; ++ case 0xf: ++ save_size=32; ++ break; ++ case 0xc: ++ /* fallthrough */ ++ case 0xA: ++ save_size=4*(4-Byte4_len); ++ address+=Byte4_len*4; ++ break; ++ case 0xB: ++ /* fallthrough */ ++ case 0x9: ++ /* fallthrough */ ++ case 0xd: ++ if(Byte4_len == 0) ++ { ++ return SW64_RECORD_UNSUPPORTED; ++ } ++ else ++ { ++ save_size = Byte4_len*4; ++ } ++ break; ++ default: ++ goto simdsave; ++ break; ++ } ++ /* fallthrough */ ++ default: ++ return SW64_RECORD_UNSUPPORTED; ++ } ++ record_buf_mem[0] = save_size; ++ record_buf_mem[1] = address; ++ sw64_insn_r->mem_rec_count = 1; ++ } ++ } ++ else if(0x01 <= ins_bit31_26 && ins_bit31_26<= 0x03) ++ { ++// record_buf[sw64_insn_r->reg_rec_count++] = SW64_PC_REGNUM; ++ record_buf[sw64_insn_r->reg_rec_count++] = insn_bits21_25; ++ goto log; ++ } ++ else if(ins_bit31_26 == 0x06 || ins_bit31_26 == 0x08 || ins_bit31_26 == 0x2D)//misc ++ { ++ if(ins_bit31_26 == 0x06) ++ { ++ switch(insn_bits0_15) ++ { ++ case 0x0: ++ case 0x1: ++ case 0x80: ++ return SW64_RECORD_UNSUPPORTED; ++ case 0x20: ++ case 0x40: ++ case 0x1040: ++ goto simdsave; ++ default: ++ return SW64_RECORD_UNSUPPORTED; ++ } ++ } ++ if(ins_bit31_26 == 0x06 && (insn_bits12_15 == 0x1000 || insn_bits12_15 == 0x1020))//lock ++ return SW64_RECORD_UNSUPPORTED; ++ ++ else if(ins_bit31_26 == 0x08 && (insn_bits12_15 == 0x0 || insn_bits12_15 == 0x1 || insn_bits12_15 == 0x8 || insn_bits12_15 == 0x9))//lock ++ { ++ // if(insn_bits12_15 == 0x0 || insn_bits12_15 == 0x1) ++ // { ++ // record_buf[0] = insn_bits21_25; ++ // sw64_insn_r->reg_rec_count = 1; ++ // } ++ // else ++ return SW64_RECORD_UNSUPPORTED; ++ } ++ else if(ins_bit31_26 == 0x06 && (insn_bits8_15 == 0xff || insn_bits8_15 == 0xfe)) ++ { ++ /*if(insn_bits8_15 == 0xff) ++ { ++ record_buf[0] = SW_CSR_REGNUM; ++ sw64_insn_r->reg_rec_count = 1; ++ } ++ else ++ { ++ record_buf[0] = insn_bits21_25; ++ sw64_insn_r->reg_rec_count = 1; ++ }*/ ++ return SW64_RECORD_UNSUPPORTED; ++ } ++ else if(ins_bit31_26 == 0x07 || ins_bit31_26 == 0x25 || ins_bit31_26 == 0x2D) ++ return SW64_RECORD_UNSUPPORTED;//PRI__ ++ else if(ins_bit31_26 == 0x08 && (0xA <= insn_bits12_15 && insn_bits12_15 <=0xC))//no catch ++ { ++ if(insn_bits12_15 == 0xC) ++ record_buf[0] = insn_bits21_25+32; ++ else ++ record_buf[0] = insn_bits21_25; ++ sw64_insn_r->reg_rec_count = 1; ++ } ++ else if(insn_bit0_16 == 0x20 || insn_bit0_16 == 0x40 || insn_bit0_16 == 0x1040) ++ { ++ record_buf[0] = insn_bits21_25; ++ sw64_insn_r->reg_rec_count = 1; ++ } ++ else if (ins_bit31_26 == 0x08 && ((0x2 <=insn_bits12_15 && insn_bits12_15 <= 0x7) || (0xd <=insn_bits12_15 && insn_bits12_15 <= 0xf))) ++ { ++ switch(insn_bits12_15) ++ { ++ case 0x2: ++ case 0x4: ++ case 0x6: ++ case 0xd: ++ save_size=4; ++ break; ++ case 0x3: ++ case 0x5: ++ case 0x7: ++ case 0xe: ++ case 0xf: ++ save_size=8; ++ break; ++ default: ++ return SW64_RECORD_UNSUPPORTED; ++ } ++ if(bit12 == 0) ++ { ++ save_size=4; ++ } ++ else ++ { ++ save_size=8; ++ } ++ regcache_raw_read_unsigned (sw64_insn_r->regcache, insn_bits16_20, ++ &address); ++ address+=disp11; ++ record_buf_mem[0] = save_size; ++ record_buf_mem[1] = address; ++ sw64_insn_r->mem_rec_count = 1; ++ } ++ else ++ return SW64_RECORD_UNSUPPORTED; ++ } ++ else if(ins_bit31_26 == 0x26 || ins_bit31_26 == 0x27)//float save ++ { ++ record_buf[0] = insn_bits21_25+32; ++ sw64_insn_r->reg_rec_count = 1; ++ goto log; ++ } ++ else ++ { ++ if (record_debug) ++ debug_printf ("Process record: load/store exclusive\n"); ++ ++ if (0x20 <= ins_bit31_26 && ins_bit31_26<= 0x24) ++ { ++ record_buf[0] = insn_bits21_25; ++ sw64_insn_r->reg_rec_count = 1; ++ } ++ else ++ { ++ switch(ins_bit31_26) ++ { ++ case 0x28: ++ save_size=1; ++ break; ++ case 0x29: ++ save_size=2; ++ break; ++ case 0x2A: ++ case 0x2E: ++ save_size=4; ++ break; ++ case 0x2B: ++ case 0x2F: ++ case 0x24: ++ save_size=8; ++ break; ++ default: ++ return SW64_RECORD_UNSUPPORTED; ++ } ++ regcache_raw_read_unsigned (sw64_insn_r->regcache, insn_bits16_20, ++ &address); ++ address+=disp15; ++ switch(ins_bit31_26) ++ { ++ case 0x24: ++ address&=0xfffffffffffffff8; ++ } ++ record_buf_mem[0] = save_size; ++ record_buf_mem[1] = address; ++ sw64_insn_r->mem_rec_count = 1; ++ goto log; ++ } ++ } ++simdsave: ++ record_buf[0] = insn_bits21_25; ++ sw64_insn_r->reg_rec_count = 1; ++log: ++ MEM_ALLOC (sw64_insn_r->sw64_mems, sw64_insn_r->mem_rec_count, ++ record_buf_mem); ++ REG_ALLOC (sw64_insn_r->sw64_regs, sw64_insn_r->reg_rec_count, ++ record_buf); ++ return SW64_RECORD_SUCCESS; ++} ++ ++static unsigned int ++sw64_record_data_proc_simd_fp (sw64_insn_decode_record *sw64_insn_r) ++{ ++ uint8_t ins_bits0_4; ++ ins_bits0_4 = (sw64_insn_r->sw64_insn & 0x1F); ++ uint32_t record_buf[4]; ++ record_buf[0] = ins_bits0_4; ++ sw64_insn_r->reg_rec_count = 1; ++ REG_ALLOC (sw64_insn_r->sw64_regs, sw64_insn_r->reg_rec_count,record_buf); ++ return SW64_RECORD_SUCCESS; ++} ++ ++/* Decodes insns type and invokes its record handler. */ ++static unsigned int ++sw64_record_decode_insn_handler (sw64_insn_decode_record *sw64_insn_r) ++{ ++ ++ ++ uint32_t ins_bit31_26; ++ ins_bit31_26 = rigg (sw64_insn_r->sw64_insn, 26); ++ /*five differrent instruction format*/ ++/* system format. */ ++ if (ins_bit31_26 == 0) ++ return sw64_record_data_proc_imm (sw64_insn_r); ++ ++ /* transfer format */ ++ if (ins_bit31_26 == 0x04 || ins_bit31_26 == 0x05 || (0x30 <= ins_bit31_26 && ins_bit31_26<= 0x3D)) ++ return sw64_record_branch_except_sys (sw64_insn_r); ++ ++ /* Load and store format. */ ++ if ((0x01 <= ins_bit31_26 && ins_bit31_26<= 0x03)/*jump*/|| (0x28 <= ins_bit31_26 && ins_bit31_26<= 0x2C)//save and load ++ || (0x20 <= ins_bit31_26 && ins_bit31_26<= 0x24) ++ || (ins_bit31_26 == 0x25)//PRI_LD ++ || (0x26 <= ins_bit31_26 && ins_bit31_26<= 0x27) ++ || (0x2D == ins_bit31_26)//PRI_ST ++ || (0x2E <= ins_bit31_26 && ins_bit31_26<= 0x2F) ++ || (0x3E <= ins_bit31_26 && ins_bit31_26<= 0x3F)//load immedia ++ || (ins_bit31_26 == 0x06)//PRI_RWCSR ++ || (ins_bit31_26 == 0x07)//PRI_RET:W ++ || (ins_bit31_26 == 0x08)//misc ++ || (0x09 <= ins_bit31_26 && ins_bit31_26<= 0x0F)//simd load and save ++ || (ins_bit31_26 == 0x1c)) ++ return sw64_record_load_store (sw64_insn_r); ++ ++ /* simple calculate format */ ++ if (ins_bit31_26 == 0x10 || ins_bit31_26 == 0x12//integer calculate ++ || ins_bit31_26 == 0x18//float calculate ++ || ins_bit31_26 == 0x1A//integer or float simd calculate ++ || (0x14 <= ins_bit31_26 && ins_bit31_26<= 0x17))//reconfig ++ return sw64_record_data_proc_reg (sw64_insn_r); ++ ++ /* combination calculate format */ ++ if (ins_bit31_26 == 0x1B || ins_bit31_26 == 0x19 || ins_bit31_26 == 0x11 || ins_bit31_26 == 0x13) ++ return sw64_record_data_proc_simd_fp (sw64_insn_r); ++ ++ return SW64_RECORD_UNSUPPORTED; ++} ++ ++static void ++deallocate_reg_mem (sw64_insn_decode_record *record) ++{ ++ xfree (record->sw64_regs); ++ xfree (record->sw64_mems); ++} ++ ++int ++sw64_process_record (struct gdbarch *gdbarch, struct regcache *regcache, ++ CORE_ADDR insn_addr) ++{ ++ uint32_t rec_no = 0; ++ uint8_t insn_size = 4; ++ uint32_t ret = 0; ++ gdb_byte buf[insn_size]; ++ sw64_insn_decode_record sw64_record; ++ ++ memset (&buf[0], 0, insn_size); ++ memset (&sw64_record, 0, sizeof (sw64_insn_decode_record)); ++ target_read_memory (insn_addr, &buf[0], insn_size); ++ sw64_record.sw64_insn ++ = (uint32_t) extract_unsigned_integer (&buf[0], ++ insn_size, ++ gdbarch_byte_order (gdbarch)); ++ ++ if (record_debug > 1) ++ gdb_printf (gdb_stderr, "Process record: sw64_process_record " ++ "addr = %s\n", ++ paddress (gdbarch, insn_addr)); ++ ++ sw64_record.regcache = regcache; ++ sw64_record.this_addr = insn_addr; ++ sw64_record.gdbarch = gdbarch; ++ ++ ret = sw64_record_decode_insn_handler (&sw64_record); ++ if (ret == SW64_RECORD_UNSUPPORTED) ++ { ++ gdb_printf (gdb_stderr, _("Process record does not support instruction " ++ "0x%0x at address %s.\n"), ++ sw64_record.sw64_insn, ++ paddress (gdbarch, insn_addr)); ++ ret = -1; ++ } ++ ++ if (0 == ret) ++ { ++ /* Record registers. */ ++ record_full_arch_list_add_reg (sw64_record.regcache, ++ SW64_PC_REGNUM); ++ /* Always record register CPSR. */ ++// record_full_arch_list_add_reg (sw64_record.regcache, ++// SW_CSR_REGNUM); ++ if (sw64_record.sw64_regs) ++ for (rec_no = 0; rec_no < sw64_record.reg_rec_count; rec_no++) ++ if (record_full_arch_list_add_reg (sw64_record.regcache, ++ sw64_record.sw64_regs[rec_no])) ++ ret = -1; ++ ++ /* Record memories. */ ++ if (sw64_record.sw64_mems) ++ for (rec_no = 0; rec_no < sw64_record.mem_rec_count; rec_no++) ++ if (record_full_arch_list_add_mem ++ ((CORE_ADDR)sw64_record.sw64_mems[rec_no].addr, ++ sw64_record.sw64_mems[rec_no].len)) ++ ret = -1; ++ ++ if (record_full_arch_list_add_end ()) ++ ret = -1; ++ } ++ ++ deallocate_reg_mem (&sw64_record); ++ return ret; ++} ++#endif +diff -Naur gdb-14.1-after-patch/gdb/sw64-tdep.h gdb-14.1-sw64/gdb/sw64-tdep.h +--- gdb-14.1-after-patch/gdb/sw64-tdep.h 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/sw64-tdep.h 2025-03-03 10:59:13.210000000 +0800 +@@ -0,0 +1,153 @@ ++/* Common target dependent code for GDB on SW64 systems. ++ Copyright (C) 1993-2023 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#ifndef SW64_TDEP_H ++#define SW64_TDEP_H ++ ++#include "gdbarch.h" ++ ++struct regcache; ++ ++/* Say how long (ordinary) registers are. This is a piece of bogosity ++ used in push_word and a few other places; register_size() is the ++ real way to know how big a register is. */ ++#define SW64_REGISTER_SIZE 8 ++ ++/* Number of machine registers. */ ++#define SW64_NUM_REGS 167 ++ ++/* Register numbers of various important registers. Note that most of ++ these values are "real" register numbers, and correspond to the ++ general registers of the machine. */ ++ ++#define SW64_V0_REGNUM 0 /* Function integer return value */ ++#define SW64_T7_REGNUM 8 /* Return address register for OSF/1 __add* */ ++#define SW64_S0_REGNUM 9 /* First saved register */ ++#define SW64_GCC_FP_REGNUM 15 /* Used by gcc as frame register */ ++#define SW64_A0_REGNUM 16 /* Loc of first arg during a subr call */ ++#define SW64_T9_REGNUM 23 /* Return address register for OSF/1 __div* */ ++#define SW64_RA_REGNUM 26 /* Contains return address value */ ++#define SW64_T12_REGNUM 27 /* Contains start addr of current proc */ ++#define SW64_GP_REGNUM 29 /* Contains the global pointer */ ++#define SW64_SP_REGNUM 30 /* Contains address of top of stack */ ++#define SW64_ZERO_REGNUM 31 /* Read-only register, always 0 */ ++#define SW64_FP0_REGNUM 32 /* Floating point register 0 */ ++#define SW64_FPA0_REGNUM 48 /* First float arg during a subr call */ ++#define SW64_FPCR_REGNUM 63 /* Floating point control register */ ++#define SW64_PC_REGNUM 64 /* Contains program counter */ ++#define SW64_UNIQUE_REGNUM 66 /* PAL_rduniq value */ ++ ++#ifndef LHX20240716_record ++#define SW64_CSR_REGNUM 66 /* Used for process-record */ ++#endif ++ ++#ifndef LHX20240710 ++#define SW64_V0F1_REGNUM 67 ++#define SW64_V0F2_REGNUM 99 ++#define SW64_V0F3_REGNUM 131 ++#define SW64_VEC0_REGNUM 167 /* First vector register V0 */ ++ ++#define REG_BASE 0 ++#define NGP_REGS 32 ++#define NFP_REGS 32 ++#define NVEC_REGS 32 ++#define GPR_BASE REG_BASE ++#define FPR_BASE (GPR_BASE+NGP_REGS) ++#endif ++ ++/* Instruction size. */ ++#define SW64_INSN_SIZE 4 ++ ++/* The sw64 has two different virtual pointers for arguments and locals. ++ ++ The virtual argument pointer is pointing to the bottom of the argument ++ transfer area, which is located immediately below the virtual frame ++ pointer. Its size is fixed for the native compiler, it is either zero ++ (for the no arguments case) or large enough to hold all argument registers. ++ gcc uses a variable sized argument transfer area. As it has ++ to stay compatible with the native debugging tools it has to use the same ++ virtual argument pointer and adjust the argument offsets accordingly. ++ ++ The virtual local pointer is localoff bytes below the virtual frame ++ pointer, the value of localoff is obtained from the PDR. */ ++#define SW64_NUM_ARG_REGS 6 ++ ++/* Target-dependent structure in gdbarch. */ ++struct sw64_gdbarch_tdep : gdbarch_tdep_base ++{ ++ CORE_ADDR vm_min_address = 0; /* Used by sw64_heuristic_proc_start. */ ++ ++ /* If PC is inside a dynamically-generated signal trampoline function ++ (i.e. one copied onto the user stack at run-time), return how many ++ bytes PC is beyond the start of that function. Otherwise, return -1. */ ++ LONGEST (*dynamic_sigtramp_offset) (struct gdbarch *, CORE_ADDR) = nullptr; ++ ++ /* Translate a signal handler stack base address into the address of ++ the sigcontext structure for that signal handler. */ ++ CORE_ADDR (*sigcontext_addr) (frame_info_ptr) = nullptr; ++ ++ /* Does the PC fall in a signal trampoline. */ ++ /* NOTE: cagney/2004-04-30: Do not copy/clone this code. Instead ++ look at tramp-frame.h and other simpler per-architecture ++ sigtramp unwinders. */ ++ int (*pc_in_sigtramp) (struct gdbarch *gdbarch, CORE_ADDR pc, ++ const char *name) = nullptr; ++ ++ /* If TYPE will be returned in memory, return true. */ ++ int (*return_in_memory) (struct type *type) = nullptr; ++ ++ /* Offset of registers in `struct sigcontext'. */ ++ int sc_pc_offset = 0; ++ int sc_regs_offset = 0; ++ int sc_fpregs_offset = 0; ++ ++ int jb_pc = 0; /* Offset to PC value in jump buffer. ++ If htis is negative, longjmp support ++ will be disabled. */ ++ size_t jb_elt_size = 0; /* And the size of each entry in the buf. */ ++ ++ /* construct vector register. */ ++ struct type *sw64_vec_type; ++ ++#ifndef LHX20240716_record ++ /* syscall record. */ ++ int (*sw64_syscall_record) (struct regcache *regcache); ++#endif ++}; ++ ++extern unsigned int sw64_read_insn (struct gdbarch *gdbarch, CORE_ADDR pc); ++extern std::vector sw64_software_single_step ++ (struct regcache *regcache); ++extern CORE_ADDR sw64_after_prologue (CORE_ADDR pc); ++ ++extern void sw64_mdebug_init_abi (struct gdbarch_info, struct gdbarch *); ++extern void sw64_dwarf2_init_abi (struct gdbarch_info, struct gdbarch *); ++ ++extern void sw64_supply_int_regs (struct regcache *, int, const void *, ++ const void *, const void *); ++extern void sw64_fill_int_regs (const struct regcache *, int, ++ void *, void *, void *); ++extern void sw64_supply_fp_regs (struct regcache *, int, ++ const void *, const void *); ++extern void sw64_fill_fp_regs (const struct regcache *, ++ int, void *, void *); ++#ifndef LHX20240716_record ++extern int sw64_process_record (struct gdbarch *gdbarch, ++ struct regcache *regcache, CORE_ADDR addr); ++#endif ++#endif /* SW64_TDEP_H */ +diff -Naur gdb-14.1-after-patch/gdb/syscalls/sw64-linux.xml gdb-14.1-sw64/gdb/syscalls/sw64-linux.xml +--- gdb-14.1-after-patch/gdb/syscalls/sw64-linux.xml 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/syscalls/sw64-linux.xml 2025-03-03 10:59:13.210000000 +0800 +@@ -0,0 +1,476 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff -Naur gdb-14.1-after-patch/gdb/syscalls/sw64-linux.xml.in gdb-14.1-sw64/gdb/syscalls/sw64-linux.xml.in +--- gdb-14.1-after-patch/gdb/syscalls/sw64-linux.xml.in 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdb/syscalls/sw64-linux.xml.in 2025-03-03 10:59:13.210000000 +0800 +@@ -0,0 +1,479 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff -Naur gdb-14.1-after-patch/gdbserver/configure.srv gdb-14.1-sw64/gdbserver/configure.srv +--- gdb-14.1-after-patch/gdbserver/configure.srv 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/gdbserver/configure.srv 2025-03-03 10:59:13.690000000 +0800 +@@ -159,6 +159,19 @@ + srv_linux_regsets=yes + srv_linux_thread_db=yes + ;; ++ sw64*-*-linux*) srv_regobj="sw64-linux.o" ++ srv_tgtobj="linux-sw64-low.o" ++ srv_tgtobj="${srv_tgtobj} ${srv_linux_obj}" ++ srv_tgtobj="${srv_tgtobj} nat/sw64-linux-watch.o" ++ srv_xmlfiles="sw64-linux.xml" ++ srv_xmlfiles="${srv_xmlfiles} sw64-cpu.xml" ++ srv_xmlfiles="${srv_xmlfiles} sw64-fpu.xml" ++ srv_xmlfiles="${srv_xmlfiles} sw64-efu.xml" ++ srv_xmlfiles="${srv_xmlfiles} sw64-vec.xml" ++ srv_linux_regsets=no ++ srv_linux_usrregs=yes ++ srv_linux_thread_db=yes ++ ;; + mips*-*-linux*) srv_regobj="mips-linux.o" + srv_regobj="${srv_regobj} mips-dsp-linux.o" + srv_regobj="${srv_regobj} mips64-linux.o" +diff -Naur gdb-14.1-after-patch/gdbserver/linux-sw64-low.cc gdb-14.1-sw64/gdbserver/linux-sw64-low.cc +--- gdb-14.1-after-patch/gdbserver/linux-sw64-low.cc 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/gdbserver/linux-sw64-low.cc 2025-03-03 10:59:13.700000000 +0800 +@@ -0,0 +1,928 @@ ++/* GNU/Linux/SW64 specific low level interface, for the remote server for GDB. ++ Copyright (C) 1995-2023 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#include "server.h" ++#include "linux-low.h" ++ ++#include "nat/gdb_ptrace.h" ++#include ++ ++#include "nat/sw64-linux-watch.h" ++#include "gdb_proc_service.h" ++ ++/* Linux target op definitions for the SW64 architecture. */ ++ ++class sw64_target : public linux_process_target ++{ ++public: ++ ++ const regs_info *get_regs_info () override; ++ ++ const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override; ++ ++ bool supports_z_point_type (char z_type) override; ++ ++protected: ++ ++ void low_arch_setup () override; ++ ++ bool low_cannot_fetch_register (int regno) override; ++ ++ bool low_cannot_store_register (int regno) override; ++ ++ bool low_fetch_register (regcache *regcache, int regno) override; ++ ++ bool low_supports_breakpoints () override; ++ ++ CORE_ADDR low_get_pc (regcache *regcache) override; ++ ++ void low_set_pc (regcache *regcache, CORE_ADDR newpc) override; ++ ++ int low_decr_pc_after_break () override; ++ ++ bool low_breakpoint_at (CORE_ADDR pc) override; ++ ++ int low_insert_point (raw_bkpt_type type, CORE_ADDR addr, ++ int size, raw_breakpoint *bp) override; ++ ++ int low_remove_point (raw_bkpt_type type, CORE_ADDR addr, ++ int size, raw_breakpoint *bp) override; ++ ++ bool low_stopped_by_watchpoint () override; ++ ++ CORE_ADDR low_stopped_data_address () override; ++ ++#if 0 ++ void low_collect_ptrace_register (regcache *regcache, int regno, ++ char *buf) override; ++ ++ void low_supply_ptrace_register (regcache *regcache, int regno, ++ const char *buf) override; ++#endif ++ ++ arch_process_info *low_new_process () override; ++ ++ void low_delete_process (arch_process_info *info) override; ++ ++ void low_new_thread (lwp_info *) override; ++ ++ void low_delete_thread (arch_lwp_info *) override; ++ ++ void low_new_fork (process_info *parent, process_info *child) override; ++ ++ void low_prepare_to_resume (lwp_info *lwp) override; ++}; ++ ++/* The singleton target ops object. */ ++ ++static sw64_target the_sw64_target; ++ ++/* Defined in auto-generated file sw64-linux.c. */ ++void init_registers_sw64_linux (void); ++extern const struct target_desc *tdesc_sw64_linux; ++ ++#ifndef PTRACE_GET_THREAD_AREA ++#define PTRACE_GET_THREAD_AREA 25 ++#endif ++ ++#ifdef HAVE_SYS_REG_H ++#include ++#endif ++ ++#define sw64_num_regs 165 ++ ++#include ++#include ++ ++union sw64_register ++{ ++ unsigned char buf[8]; ++ long long reg64; ++}; ++ ++int gcc_backtrace (); ++void exc_handler (int, siginfo_t*, void*); ++extern int tohex (int nib); ++extern int bin2hex (const gdb_byte *bin, char *hex, int count); ++extern long dva_match_addr; ++extern long status_cg[]; ++extern struct lwp_info *add_lwp (ptid_t ptid); ++ ++enum sw64_hw_bp_type sw64_hw_bp_type_from_raw_type (enum raw_bkpt_type raw_type); ++ ++/* Return the ptrace ``address'' of register REGNO. */ ++#if 0 ++#define sw64_base_regs \ ++ 0, 1, 2, 3, 4, 5, 6, 7, \ ++ 8, 9, 10, 11, 12, 13, 14, 15, \ ++ 16, 17, 18, 19, 20, 21, 22, 23, \ ++ 24, 25, 26, 27, 28, 29, 30, -1, \ ++ \ ++ FPR_BASE, FPR_BASE + 1, FPR_BASE + 2, FPR_BASE + 3, \ ++ FPR_BASE + 4, FPR_BASE + 5, FPR_BASE + 6, FPR_BASE + 7, \ ++ FPR_BASE + 8, FPR_BASE + 9, FPR_BASE + 10, FPR_BASE + 11, \ ++ FPR_BASE + 12, FPR_BASE + 13, FPR_BASE + 14, FPR_BASE + 15, \ ++ FPR_BASE + 16, FPR_BASE + 17, FPR_BASE + 18, FPR_BASE + 19, \ ++ FPR_BASE + 20, FPR_BASE + 21, FPR_BASE + 22, FPR_BASE + 23, \ ++ FPR_BASE + 24, FPR_BASE + 25, FPR_BASE + 26, FPR_BASE + 27, \ ++ FPR_BASE + 28, FPR_BASE + 29, FPR_BASE + 30, FPR_BASE + 31, \ ++ \ ++ PC, -1, -1 ++ ++static int mips_regmap[sw64_num_regs] = { ++ sw64_base_regs, ++ 0 ++}; ++#endif ++ ++/* ++ * The following table maps a register index into the stack offset at ++ * which the register is saved. Register indices are 0-31 for integer ++ * regs, 32-63 for fp regs, and 64 for the pc. Notice that sp and ++ * zero have no stack-slot and need to be treated specially (see ++ * get_reg/put_reg below). ++ */ ++ ++/* Return the ptrace 'address' of register REGNO. */ ++#define FPR_BASE 32 ++ ++/* 0~63 general, 64 pc, 65-69 hwbpt/da_match,70-101 simd */ ++static int sw64_regmap[sw64_num_regs] = { ++ 0, 1, 2, 3, 4, 5, 6, 7, ++ 8, 9, 10, 11, 12, 13, 14, 15, ++ 16, 17, 18, 19, 20, 21, 22, 23, ++ 24, 25, 26, 27, 28, 29, 30, 31, ++ FPR_BASE, FPR_BASE + 1, FPR_BASE + 2, FPR_BASE + 3, ++ FPR_BASE + 4, FPR_BASE + 5, FPR_BASE + 6, FPR_BASE + 7, ++ FPR_BASE + 8, FPR_BASE + 9, FPR_BASE + 10, FPR_BASE + 11, ++ FPR_BASE + 12, FPR_BASE + 13, FPR_BASE + 14, FPR_BASE + 15, ++ FPR_BASE + 16, FPR_BASE + 17, FPR_BASE + 18, FPR_BASE + 19, ++ FPR_BASE + 20, FPR_BASE + 21, FPR_BASE + 22, FPR_BASE + 23, ++ FPR_BASE + 24, FPR_BASE + 25, FPR_BASE + 26, FPR_BASE + 27, ++ FPR_BASE + 28, FPR_BASE + 29, FPR_BASE + 30, FPR_BASE + 31, ++ REG_PC, -1, -1, /* NULL and unique */ ++ REG_V0F1, REG_V0F1 + 1, REG_V0F1 + 2, REG_V0F1 + 3, ++ REG_V0F1 + 4, REG_V0F1 + 5, REG_V0F1 + 6, REG_V0F1 + 7, ++ REG_V0F1 + 8, REG_V0F1 + 9, REG_V0F1 + 10, REG_V0F1 + 11, ++ REG_V0F1 + 12, REG_V0F1 + 13, REG_V0F1 + 14, REG_V0F1 + 15, ++ REG_V0F1 + 16, REG_V0F1 + 17, REG_V0F1 + 18, REG_V0F1 + 19, ++ REG_V0F1 + 20, REG_V0F1 + 21, REG_V0F1 + 22, REG_V0F1 + 23, ++ REG_V0F1 + 24, REG_V0F1 + 25, REG_V0F1 + 26, REG_V0F1 + 27, ++ REG_V0F1 + 28, REG_V0F1 + 29, REG_V0F1 + 30, REG_V0F1 + 31, ++ REG_V0F2, REG_V0F2 + 1, REG_V0F2 + 2, REG_V0F2 + 3, ++ REG_V0F2 + 4, REG_V0F2 + 5, REG_V0F2 + 6, REG_V0F2 + 7, ++ REG_V0F2 + 8, REG_V0F2 + 9, REG_V0F2 + 10, REG_V0F2 + 11, ++ REG_V0F2 + 12, REG_V0F2 + 13, REG_V0F2 + 14, REG_V0F2 + 15, ++ REG_V0F2 + 16, REG_V0F2 + 17, REG_V0F2 + 18, REG_V0F2 + 19, ++ REG_V0F2 + 20, REG_V0F2 + 21, REG_V0F2 + 22, REG_V0F2 + 23, ++ REG_V0F2 + 24, REG_V0F2 + 25, REG_V0F2 + 26, REG_V0F2 + 27, ++ REG_V0F2 + 28, REG_V0F2 + 29, REG_V0F2 + 30, REG_V0F2 + 31, ++ REG_V0F3, REG_V0F3 + 1, REG_V0F3 + 2, REG_V0F3 + 3, ++ REG_V0F3 + 4, REG_V0F3 + 5, REG_V0F3 + 6, REG_V0F3 + 7, ++ REG_V0F3 + 8, REG_V0F3 + 9, REG_V0F3 + 10, REG_V0F3 + 11, ++ REG_V0F3 + 12, REG_V0F3 + 13, REG_V0F3 + 14, REG_V0F3 + 15, ++ REG_V0F3 + 16, REG_V0F3 + 17, REG_V0F3 + 18, REG_V0F3 + 19, ++ REG_V0F3 + 20, REG_V0F3 + 21, REG_V0F3 + 22, REG_V0F3 + 23, ++ REG_V0F3 + 24, REG_V0F3 + 25, REG_V0F3 + 26, REG_V0F3 + 27, ++ REG_V0F3 + 28, REG_V0F3 + 29, REG_V0F3 + 30, REG_V0F3 + 31, ++ -1, ++ 0 ++}; ++ ++static const struct target_desc * ++sw64_read_description (void) ++{ ++ return tdesc_sw64_linux; ++} ++ ++void ++sw64_target::low_arch_setup () ++{ ++ current_process ()->tdesc = sw64_read_description (); ++} ++ ++static struct usrregs_info * ++get_usrregs_info (void) ++{ ++ const struct regs_info *regs_info = the_linux_target->get_regs_info (); ++ ++ return regs_info->usrregs; ++} ++ ++/* Per-process arch-specific data we want to keep. */ ++ ++struct arch_process_info ++{ ++#if 0 ++ /* -1 if the kernel and/or CPU do not support watch registers. ++ 1 if watch_readback is valid and we can read style, num_valid ++ and the masks. ++ 0 if we need to read the watch_readback. */ ++ ++ int watch_readback_valid; ++ ++ /* Cached watch register read values. */ ++ ++ struct pt_watch_regs watch_readback; ++ ++ /* Current watchpoint requests for this process. */ ++ ++ struct mips_watchpoint *current_watches; ++ ++ /* The current set of watch register values for writing the ++ registers. */ ++ ++ struct pt_watch_regs watch_mirror; ++#endif ++}; ++ ++/* Per-thread arch-specific data we want to keep. */ ++#if 0 ++struct arch_lwp_info ++{ ++ /* Non-zero if our copy differs from what's recorded in the thread. */ ++ int watch_registers_changed; ++}; ++#endif ++ ++/* From sw64-linux-nat.c. */ ++ ++/* Pseudo registers can not be read. ptrace does not provide a way to ++ read (or set) PS_REGNUM, and there's no point in reading or setting ++ ZERO_REGNUM, it's always 0. We also can not set BADVADDR, CAUSE, ++ or FCRIR via ptrace(). */ ++ ++bool ++sw64_target::low_cannot_fetch_register (int regno) ++{ ++ const struct target_desc *tdesc; ++ tdesc = current_process ()->tdesc; ++ ++ if (get_usrregs_info ()->regmap[regno] == -1) ++ return true; ++ ++ if (get_regs_info ()->usrregs->regmap[regno] == -1) ++ return true; ++ ++ if (find_regno (tdesc, "r31") == regno) ++ return true; ++ ++ return false; ++} ++ ++bool ++sw64_target::low_cannot_store_register (int regno) ++{ ++ const struct target_desc *tdesc; ++ tdesc = current_process ()->tdesc; ++ ++ if (get_usrregs_info ()->regmap[regno] == -1) ++ return true; ++ ++ if (get_regs_info ()->usrregs->regmap[regno] == -1) ++ return true; ++ ++ if (find_regno (tdesc, "r31") == regno) ++ return true; ++ ++ return false; ++} ++ ++bool ++sw64_target::low_fetch_register (regcache *regcache, int regno) ++{ ++ const struct target_desc *tdesc = current_process ()->tdesc; ++ ++ if (find_regno (tdesc, "r31") == regno) ++ { ++ supply_register_zeroed (regcache, regno); ++ return true; ++ } ++ ++ return false; ++} ++ ++bool ++sw64_target::low_supports_breakpoints () ++{ ++ return true; ++} ++ ++CORE_ADDR ++sw64_target::low_get_pc (regcache *regcache) ++{ ++ union sw64_register pc; ++ collect_register_by_name (regcache, "pc", pc.buf); ++ return pc.reg64; ++} ++ ++void ++sw64_target::low_set_pc (regcache *regcache, CORE_ADDR pc) ++{ ++ union sw64_register newpc; ++ newpc.reg64 = pc; ++ ++ supply_register_by_name (regcache, "pc", newpc.buf); ++} ++ ++int ++sw64_target::low_decr_pc_after_break () ++{ ++ return 4; ++} ++ ++/* Correct in either endianness. */ ++static const unsigned int sw64_breakpoint = 0x00000080; ++#define sw64_breakpoint_len 4 ++ ++/* Implementation of target ops method "sw_breakpoint_from_kind". */ ++ ++const gdb_byte * ++sw64_target::sw_breakpoint_from_kind (int kind, int *size) ++{ ++ *size = sw64_breakpoint_len; ++ return (const gdb_byte *) &sw64_breakpoint; ++} ++ ++bool ++sw64_target::low_breakpoint_at (CORE_ADDR where) ++{ ++ unsigned int insn; ++ ++ read_memory (where, (unsigned char *) &insn, 4); ++ if (insn == sw64_breakpoint) ++ return true; ++ ++ /* If necessary, recognize more trap instructions here. GDB only uses the ++ one. */ ++ return false; ++} ++ ++/* Mark the watch registers of lwp, represented by ENTRY, as changed. */ ++ ++static void ++update_watch_registers_callback (thread_info *thread) ++{ ++ struct lwp_info *lwp = get_thread_lwp (thread); ++ ++ /* The actual update is done later just before resuming the lwp, ++ we just mark that the registers need updating. */ ++ lwp->arch_private->watch_registers_changed = 1; ++ ++ /* If the lwp isn't stopped, force it to momentarily pause, so ++ we can update its watch registers. */ ++ if (!lwp->stopped) ++ linux_stop_lwp (lwp); ++} ++ ++/* This is the implementation of linux target ops method ++ low_new_process. */ ++ ++arch_process_info * ++sw64_target::low_new_process () ++{ ++ struct arch_process_info *info = XCNEW (struct arch_process_info); ++ ++ return info; ++} ++ ++/* This is the implementation of linux target ops method ++ low_delete_process. */ ++ ++void ++sw64_target::low_delete_process (arch_process_info *info) ++{ ++ xfree (info); ++} ++ ++/* This is the implementation of linux target ops method low_new_thread. ++ Mark the watch registers as changed, so the threads' copies will ++ be updated. */ ++ ++void ++sw64_target::low_new_thread (lwp_info *lwp) ++{ ++ struct arch_lwp_info *info = XCNEW (struct arch_lwp_info); ++ ++ info->watch_registers_changed = 1; ++ ++ lwp->arch_private = info; ++} ++ ++/* Function to call when a thread is being deleted. */ ++ ++void ++sw64_target::low_delete_thread (arch_lwp_info *arch_lwp) ++{ ++ xfree (arch_lwp); ++} ++ ++/* Create a new sw64_watchpoint and add it to the list. */ ++ ++ ++/* Hook to call when a new fork is attached. */ ++ ++void ++sw64_target::low_new_fork (process_info *parent, ++ process_info *child) ++{ ++} ++ ++enum sw64_hw_bp_type ++sw64_hw_bp_type_from_raw_type (enum raw_bkpt_type raw_type) ++{ ++ switch (raw_type) ++ { ++ case raw_bkpt_type_hw: ++ return sw64_none; ++ case raw_bkpt_type_write_wp: ++ return sw64_write; ++ case raw_bkpt_type_read_wp: ++ return sw64_read; ++ case raw_bkpt_type_access_wp: ++ return sw64_access; ++ case raw_bkpt_type_value_wp: ++ return sw64_vstore; ++ default: ++ internal_error ("bad raw breakpoint type %d", (int) raw_type); ++ } ++} ++ ++/* This is the implementation of linux target ops method ++ low_prepare_to_resume. If the watch regs have changed, update the ++ thread's copies. */ ++ ++void ++sw64_target::low_prepare_to_resume (lwp_info *lwp) ++{ ++ int i = 0; ++ ptid_t ptid = ptid_of (get_lwp_thread (lwp)); ++ //struct process_info *proc = find_process_pid (ptid.pid ()); ++ //struct arch_process_info *priv = proc->priv->arch_private; ++ struct arch_lwp_info *priv = lwp->arch_private; ++ pid_t lwpid = ptid.lwp (); ++ ++ if (!(lwp->arch_private->watch_registers_changed)) ++ return; ++ ++ if ( priv->wpt[1].valid ) ++ { ++ //debug("write master dv_match %#lx, mask %#lx", priv->wpt[1].match, priv->wpt[1].mask); ++ store_debug_register (lwpid, M_DV_MATCH, priv->wpt[1].match); ++ store_debug_register (lwpid, M_DV_MATCH+1, priv->wpt[1].mask); ++ } ++ if ( priv->wpt[0].valid ) ++ { ++ //debug("write master da_match %#lx, mask %#lx", priv->wpt->match, priv->wpt->mask); ++ store_debug_register (lwpid, M_DA_MATCH, priv->wpt->match); ++ store_debug_register (lwpid, M_DA_MASK, priv->wpt->mask); ++ } ++ ++ i = (priv->wpt[1].valid<<1) | priv->wpt[0].valid; ++ ++ // setting dv_ctl ++ switch (i) ++ { ++ //da_match ++ case 0: ++ case 1: ++ //store_debug_register (lwpid, M_DV_MATCH+2, 0L); ++ break; ++ //dv_match ++ case 2: ++ store_debug_register (lwpid, M_DV_MATCH+2, 1); ++ break; ++ //dva_match ++ case 3: ++ store_debug_register (lwpid, M_DV_MATCH+2, 3); ++ break; ++ default: ++ ;; ++ } ++ ++ lwp->arch_private->watch_registers_changed = 0; ++ ++#if 0 ++ if (lwp->arch_private->watch_registers_changed) ++ { ++ /* Only update the watch registers if we have set or unset a ++ watchpoint already. */ ++ if (sw64_linux_watch_get_num_valid (&priv->watch_mirror) > 0) ++ { ++ /* Write the mirrored watch register values. */ ++ int tid = ptid.lwp (); ++ ++ if (-1 == ptrace (PTRACE_SET_WATCH_REGS, tid, ++ &priv->watch_mirror, NULL)) ++ perror_with_name ("Couldn't write watch register"); ++ } ++ ++ lwp->arch_private->watch_registers_changed = 0; ++ } ++#endif ++} ++ ++bool ++sw64_target::supports_z_point_type (char z_type) ++{ ++ switch (z_type) ++ { ++ case Z_PACKET_WRITE_WP: ++ case Z_PACKET_READ_WP: ++ case Z_PACKET_ACCESS_WP: ++ case Z_PACKET_SW_BP: ++ case Z_PACKET_HW_BP: ++ case Z_PACKET_DV_WP: ++ return true; ++ default: ++ return false; ++ } ++} ++ ++/* This is the implementation of linux target ops method ++ low_insert_point. */ ++ ++int ++sw64_target::low_insert_point (raw_bkpt_type type, CORE_ADDR addr, ++ int len, raw_breakpoint *bp) ++{ ++ int pid; ++ long lwpid; ++ enum sw64_hw_bp_type watch_type; ++ struct process_info *proc = current_process (); ++ struct lwp_info *lwp = get_thread_lwp (current_thread); ++ struct arch_lwp_info *priv = lwp->arch_private; ++ ++ if (!addr) ++ return 0; ++ ++ lwpid = lwpid_of (current_thread); ++ pid = pid_of (current_thread); ++ ++ if ( len <= 0 || !is_power_of_2 (len)) ++ return 0; ++ ++ /* Now try to add the new watch. */ ++ watch_type = sw64_hw_bp_type_from_raw_type(type); ++ ++ if (sw64_linux_try_one_watch(lwpid, priv, watch_type,addr,len)) ++ //find_inferior (&all_threads, update_watch_registers_callback, &pid); ++ /* Only update the threads of this process. */ ++ for_each_thread (pid, update_watch_registers_callback); ++ ++ return 0; ++ ++ /* Only update the threads of this process. */ ++ for_each_thread (proc->pid, update_watch_registers_callback); ++ ++ return 0; ++} ++ ++/* This is the implementation of linux target ops method ++ low_remove_point. */ ++ ++int ++sw64_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr, ++ int len, raw_breakpoint *bp) ++{ ++ int pid; ++ //uint64_t match; ++ //uint64_t data; ++ enum sw64_hw_bp_type watch_type; ++ long lwpid; ++ struct lwp_info *lwp = get_thread_lwp (current_thread); ++ struct arch_lwp_info *priv = lwp->arch_private; ++ ++ /* Search for a known watch that matches. Then unlink and free it. */ ++ watch_type = sw64_hw_bp_type_from_raw_type(type); ++ ++ pid = pid_of (current_thread); ++ lwpid = lwpid_of(current_thread); ++ if (!sw64_linux_del_one_watch(lwpid, priv, watch_type,addr,len)) ++ { ++ warning("none wp about %#lx\n", (long)addr); ++ return -1; /* We don't know about it, fail doing nothing. */ ++ } ++ /* Only update the threads of this process. */ ++ //find_inferior (&all_threads, update_watch_registers_callback, &pid); ++ for_each_thread (pid, update_watch_registers_callback); ++ return 0; ++} ++ ++/* This is the implementation of linux target ops method ++ low_stopped_by_watchpoint. The watchhi R and W bits indicate ++ the watch register triggered. */ ++ ++bool ++sw64_target::low_stopped_by_watchpoint () ++{ ++ pid_t lwpid = lwpid_of(current_thread); ++ struct lwp_info *lwp = get_thread_lwp (current_thread); ++ siginfo_t siginfo; ++ ++ /* Retrieve siginfo. */ ++ errno = 0; ++ ptrace (PTRACE_GETSIGINFO, lwpid, 0, &siginfo); ++ if (errno != 0) ++ { ++ warning("%s:%d GETSIGINFO return %d\n", __FILE__, __LINE__, errno); ++ return false; ++ } ++// debug("GETSIGINFO %#x si_code=%#x si_signo=%d si_errno = %x", ++// lwpid, siginfo.si_code, siginfo.si_signo,siginfo.si_errno); ++ /* This must be a hardware breakpoint. */ ++ if (siginfo.si_signo != SIGTRAP || (siginfo.si_code & 0xffff) != TRAP_HWBKPT) ++ return false; ++// debug("si_code=%#x si_signo=%d si_errno = %x pc=%#lx, data_address %#lx", ++// siginfo.si_code, siginfo.si_signo, siginfo.si_errno, ++// (long)siginfo.si_value.sival_ptr, (long)siginfo.si_addr); ++ /* siginfo should return the accessed data address, not pc */ ++ if (siginfo.si_errno == 1) ++ lwp->arch_private->stopped_data_address ++ = (CORE_ADDR) (uintptr_t) (lwp->arch_private->wpt->match & ((1L<<53)-1)); ++ else ++ lwp->arch_private->stopped_data_address ++ = (CORE_ADDR) (uintptr_t) (lwp->arch_private->value_address); // get the saved ++ return true; ++} ++ ++/* This is the implementation of linux target ops method ++ low_stopped_data_address. */ ++ ++CORE_ADDR ++sw64_target::low_stopped_data_address () ++{ ++ struct lwp_info *lwp; ++ ++ lwp = get_thread_lwp (current_thread); ++ low_stopped_by_watchpoint(); ++ ++ return lwp->arch_private->stopped_data_address; ++} ++ ++/* Fetch the thread-local storage pointer for libthread_db. */ ++ ++ps_err_e ++ps_get_thread_area (struct ps_prochandle *ph, ++ lwpid_t lwpid, int idx, void **base) ++{ ++ if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0) ++ return PS_ERR; ++ ++ /* IDX is the bias from the thread pointer to the beginning of the ++ thread descriptor. It has to be subtracted due to implementation ++ quirks in libthread_db. */ ++ *base = (void *) ((char *)*base - idx); ++ ++ return PS_OK; ++} ++ ++#ifdef HAVE_PTRACE_GETREGS ++ ++static void ++sw64_collect_register (struct regcache *regcache, ++ int use_64bit, int regno, union sw64_register *reg) ++{ ++ union sw64_register tmp_reg; ++ ++ collect_register (regcache, regno, &tmp_reg.reg64); ++ *reg = tmp_reg; ++} ++ ++static void ++sw64_supply_register (struct regcache *regcache, ++ int use_64bit, int regno, const union sw64_register *reg) ++{ ++ int offset = 0; ++ ++ supply_register (regcache, regno, reg->buf + offset); ++} ++ ++#ifdef HAVE_PTRACE_GETREGS ++ ++static void ++sw64_fill_gregset (struct regcache *regcache, void *buf) ++{ ++ union sw64_register *regset = (union sw64_register *) buf; ++ int i, use_64bit; ++ const struct target_desc *tdesc = regcache->tdesc; ++ ++ use_64bit = (register_size (tdesc, 0) == 8); ++ ++ for (i = 1; i < 32; i++) ++ sw64_collect_register (regcache, use_64bit, i, regset + i); ++} ++ ++static void ++sw64_store_gregset (struct regcache *regcache, const void *buf) ++{ ++ const union sw64_register *regset = (const union sw64_register *) buf; ++ int i, use_64bit; ++ ++ use_64bit = (register_size (regcache->tdesc, 0) == 8); ++ ++ supply_register_by_name_zeroed (regcache, "r31"); ++ ++ for (i = 1; i < 32; i++) ++ sw64_supply_register (regcache, use_64bit, i, regset + i); ++} ++ ++static void ++sw64_fill_fpregset (struct regcache *regcache, void *buf) ++{ ++ union sw64_register *regset = (union sw64_register *) buf; ++ int i, use_64bit, first_fp, big_endian; ++ ++ use_64bit = (register_size (regcache->tdesc, 0) == 8); ++ first_fp = find_regno (regcache->tdesc, "f0"); ++ big_endian = (__BYTE_ORDER == __BIG_ENDIAN); ++ ++ /* See GDB for a discussion of this peculiar layout. */ ++ for (i = 0; i < 32; i++) ++ if (use_64bit) ++ collect_register (regcache, first_fp + i, regset[i].buf); ++ else ++ collect_register (regcache, first_fp + i, ++ regset[i & ~1].buf + 4 * (big_endian != (i & 1))); ++} ++ ++static void ++sw64_store_fpregset (struct regcache *regcache, const void *buf) ++{ ++ const union sw64_register *regset = (const union sw64_register *) buf; ++ int i, use_64bit, first_fp, big_endian; ++ ++ use_64bit = (register_size (regcache->tdesc, 0) == 8); ++ first_fp = find_regno (regcache->tdesc, "f0"); ++ big_endian = (__BYTE_ORDER == __BIG_ENDIAN); ++ ++ /* See GDB for a discussion of this peculiar layout. */ ++ for (i = 0; i < 32; i++) ++ if (use_64bit) ++ supply_register (regcache, first_fp + i, regset[i].buf); ++ else ++ supply_register (regcache, first_fp + i, ++ regset[i & ~1].buf + 4 * (big_endian != (i & 1))); ++} ++#endif /* HAVE_PTRACE_GETREGS */ ++ ++#if 0 ++/* Take care of 32-bit registers with 64-bit ptrace, POKEUSER side. */ ++ ++void ++sw64_target::low_collect_ptrace_register (regcache *regcache, int regno, ++ char *buf) ++{ ++ int use_64bit = sizeof (PTRACE_XFER_TYPE) == 8; ++ ++ if (use_64bit && register_size (regcache->tdesc, regno) == 4) ++ { ++ union sw64_register reg; ++ ++ sw64_collect_register (regcache, 0, regno, ®); ++ memcpy (buf, ®, sizeof (reg)); ++ } ++ else ++ collect_register (regcache, regno, buf); ++} ++ ++/* Take care of 32-bit registers with 64-bit ptrace, PEEKUSER side. */ ++ ++void ++sw64_target::low_supply_ptrace_register (regcache *regcache, int regno, ++ const char *buf) ++{ ++ int use_64bit = sizeof (PTRACE_XFER_TYPE) == 8; ++ ++ if (use_64bit && register_size (regcache->tdesc, regno) == 4) ++ { ++ union sw64_register reg; ++ ++ memcpy (®, buf, sizeof (reg)); ++ sw64_supply_register (regcache, 0, regno, ®); ++ } ++ else ++ supply_register (regcache, regno, buf); ++} ++#endif ++ ++static struct regset_info sw64_regsets[] = { ++#ifdef HAVE_PTRACE_GETREGS ++ { PTRACE_GETREGS, PTRACE_SETREGS, 0, 33 * 8, GENERAL_REGS, ++ sw64_fill_gregset, sw64_store_gregset }, ++ { PTRACE_GETFPREGS, PTRACE_SETFPREGS, 0, 32 * 8, FP_REGS, ++ sw64_fill_fpregset, sw64_store_fpregset }, ++#endif /* HAVE_PTRACE_GETREGS */ ++ NULL_REGSET ++}; ++ ++static struct regsets_info sw64_regsets_info = ++{ ++ sw64_regsets, /* regsets */ ++ 0, /* num_regsets */ ++ NULL, /* disabled_regsets */ ++}; ++ ++#endif /* HAVE_PTRACE_GETREGS */ ++ ++static struct usrregs_info sw64_usrregs_info = ++{ ++ sw64_num_regs, ++ sw64_regmap, ++}; ++ ++static struct regs_info myregs_info = ++{ ++ NULL, /* regset_bitmap */ ++ &sw64_usrregs_info, ++#ifdef HAVE_PTRACE_GETREGS ++ &sw64_regsets_info ++#endif ++}; ++ ++const regs_info * ++sw64_target::get_regs_info () ++{ ++ return &myregs_info; ++} ++ ++#define BTSIZE 20 ++int gcc_backtrace() ++{ ++ int j, nptrs; ++ void *buffer[BTSIZE]; ++ char **strings; ++ ++ nptrs = backtrace(buffer, BTSIZE); ++ ++ /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO) ++ would produce similar output to the following: */ ++ ++ strings = backtrace_symbols(buffer, nptrs); ++ if (strings == NULL) { ++ perror("backtrace_symbols"); ++ return (EXIT_FAILURE); ++ } ++ ++ for (j = 0; j < nptrs; j++) ++ printf(" %s", strings[j]); ++ printf("\n"); ++ ++ free(strings); ++ return 0; ++} ++ ++ ++void exc_handler(int sig, siginfo_t* info, void *arg) ++{ ++ //unsigned long ra; ++ //unsigned long sp, pc; ++ //ucontext_t *uc = (ucontext_t *)arg; ++#if 0 ++ register unsigned long __ra __asm__("$26"); ++ pc = uc->uc_mcontext.sc_pc; ++ ra = uc->uc_mcontext.sc_regs[26]; ++ sp = uc->uc_mcontext.sc_regs[30]; ++ printf("pc = %#lx, ra = %#lx, sp=%#lx, called from %#lx\n", pc, ra, sp, *(unsigned long*)sp); fflush(stdout); ++#else ++ gcc_backtrace(); ++#endif ++ exit(1); ++} ++ ++/* The linux target ops object. */ ++ ++linux_process_target *the_linux_target = &the_sw64_target; ++ ++void ++initialize_low_arch (void) ++{ ++ struct sigaction sa, old_sa; ++ ++ /* Initialize the Linux target descriptions. */ ++ init_registers_sw64_linux (); ++ ++ //initialize_regsets_info (&sw64_regsets_info); ++ ++ sa.sa_sigaction = exc_handler; ++ sigemptyset (&sa.sa_mask); ++ sa.sa_flags = SA_RESTART|SA_SIGINFO; ++ sigaction (11, &sa, &old_sa); ++ sigaction (4, &sa, &old_sa); ++ sigaction (8, &sa, &old_sa); ++} +diff -Naur gdb-14.1-after-patch/gdbserver/Makefile.in gdb-14.1-sw64/gdbserver/Makefile.in +--- gdb-14.1-after-patch/gdbserver/Makefile.in 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/gdbserver/Makefile.in 2025-03-03 10:59:13.690000000 +0800 +@@ -173,6 +173,7 @@ + $(srcdir)/i387-fp.cc \ + $(srcdir)/inferiors.cc \ + $(srcdir)/linux-aarch64-low.cc \ ++ $(srcdir)/linux-sw64-low.cc \ + $(srcdir)/linux-arc-low.cc \ + $(srcdir)/linux-arm-low.cc \ + $(srcdir)/linux-csky-low.cc \ +@@ -224,6 +225,7 @@ + $(srcdir)/../gdb/nat/linux-osdata.c \ + $(srcdir)/../gdb/nat/linux-personality.c \ + $(srcdir)/../gdb/nat/mips-linux-watch.c \ ++ $(srcdir)/../gdb/nat/sw64-linux-watch.c \ + $(srcdir)/../gdb/nat/ppc-linux.c \ + $(srcdir)/../gdb/nat/riscv-linux-tdesc.c \ + $(srcdir)/../gdb/nat/fork-inferior.c \ +diff -Naur gdb-14.1-after-patch/gdbserver/mem-break.cc gdb-14.1-sw64/gdbserver/mem-break.cc +--- gdb-14.1-after-patch/gdbserver/mem-break.cc 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/gdbserver/mem-break.cc 2025-03-03 10:59:13.690000000 +0800 +@@ -70,7 +70,7 @@ + software breakpoints, a buffer holding a copy of the instructions + that would be in memory had not been a breakpoint there (we call + that the shadow memory of the breakpoint). We occasionally need to +- temporarily uninsert a breakpoint without the client knowing about ++ temporarilly uninsert a breakpoint without the client knowing about + it (e.g., to step over an internal breakpoint), so we keep an + `inserted' state associated with this low level breakpoint + structure. There can only be one such object for a given address. +@@ -252,6 +252,10 @@ + return hw_read; + case raw_bkpt_type_access_wp: + return hw_access; ++#ifndef LHX20240711_gdbserver ++ case raw_bkpt_type_value_wp: ++ return hw_vstore; ++#endif + default: + internal_error ("bad raw breakpoint type %d", (int) raw_type); + } +@@ -262,7 +266,11 @@ + static enum bkpt_type + Z_packet_to_bkpt_type (char z_type) + { ++#ifndef LHX20240711_gdbserver ++ gdb_assert (z_type >= '0' && z_type <= Z_PACKET_DV_WP); ++#else + gdb_assert ('0' <= z_type && z_type <= '4'); ++#endif + + return (enum bkpt_type) (gdb_breakpoint_Z0 + (z_type - '0')); + } +@@ -284,6 +292,10 @@ + return raw_bkpt_type_read_wp; + case Z_PACKET_ACCESS_WP: + return raw_bkpt_type_access_wp; ++#ifndef LHX20240711_gdbserver ++ case Z_PACKET_DV_WP: ++ return raw_bkpt_type_value_wp; ++#endif + default: + gdb_assert_not_reached ("unhandled Z packet type."); + } +diff -Naur gdb-14.1-after-patch/gdbserver/mem-break.h gdb-14.1-sw64/gdbserver/mem-break.h +--- gdb-14.1-after-patch/gdbserver/mem-break.h 2023-02-02 12:45:52.000000000 +0800 ++++ gdb-14.1-sw64/gdbserver/mem-break.h 2025-03-03 10:59:13.690000000 +0800 +@@ -35,6 +35,9 @@ + #define Z_PACKET_WRITE_WP '2' + #define Z_PACKET_READ_WP '3' + #define Z_PACKET_ACCESS_WP '4' ++#ifndef LHX20240711_gdbserver ++#define Z_PACKET_DV_WP '5' ++#endif + + /* The low level breakpoint types. */ + +@@ -54,6 +57,9 @@ + + /* Hardware-assisted access watchpoint. */ + raw_bkpt_type_access_wp ++#ifndef LHX20240711_gdbserver ++ , raw_bkpt_type_value_wp ++#endif + }; + + /* Map the protocol breakpoint/watchpoint type Z_TYPE to the internal +diff -Naur gdb-14.1-after-patch/gdbserver/regcache.cc gdb-14.1-sw64/gdbserver/regcache.cc +--- gdb-14.1-after-patch/gdbserver/regcache.cc 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/gdbserver/regcache.cc 2025-03-03 10:59:13.690000000 +0800 +@@ -200,7 +200,7 @@ + find_register_by_number (const struct target_desc *tdesc, int n) + { + gdb_assert (n >= 0); +- gdb_assert (n < tdesc->reg_defs.size ()); ++// gdb_assert (n < tdesc->reg_defs.size ()); + + return tdesc->reg_defs[n]; + } +diff -Naur gdb-14.1-after-patch/gdbsupport/break-common.h gdb-14.1-sw64/gdbsupport/break-common.h +--- gdb-14.1-after-patch/gdbsupport/break-common.h 2023-02-02 12:45:52.000000000 +0800 ++++ gdb-14.1-sw64/gdbsupport/break-common.h 2025-03-03 10:59:13.700000000 +0800 +@@ -26,6 +26,9 @@ + hw_read = 1, /* Read HW watchpoint */ + hw_access = 2, /* Access HW watchpoint */ + hw_execute = 3 /* Execute HW breakpoint */ ++#ifndef LHX20240711 ++ , hw_vstore = 4 ++#endif + }; + + #endif /* COMMON_BREAK_COMMON_H */ +diff -Naur gdb-14.1-after-patch/include/coff/ecoff.h gdb-14.1-sw64/include/coff/ecoff.h +--- gdb-14.1-after-patch/include/coff/ecoff.h 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/include/coff/ecoff.h 2025-03-03 10:59:13.750000000 +0800 +@@ -41,6 +41,9 @@ + #define MIPS_MAGIC_LITTLE3 0x142 + #define MIPS_MAGIC_BIG3 0x140 + ++/* SW64 magic numbers used in filehdr. */ ++#define SW64_MAGIC 0x9916 ++ + /* Alpha magic numbers used in filehdr. */ + #define ALPHA_MAGIC 0x183 + #define ALPHA_MAGIC_BSD 0x185 +diff -Naur gdb-14.1-after-patch/include/coff/sw64.h gdb-14.1-sw64/include/coff/sw64.h +--- gdb-14.1-after-patch/include/coff/sw64.h 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/include/coff/sw64.h 2025-03-03 10:59:13.750000000 +0800 +@@ -0,0 +1,386 @@ ++/* ECOFF support on SW64 machines. ++ coff/ecoff.h must be included before this file. ++ ++ Copyright (C) 2001-2023 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++ MA 02110-1301, USA. */ ++ ++/********************** FILE HEADER **********************/ ++ ++struct external_filehdr ++{ ++ unsigned char f_magic[2]; /* magic number */ ++ unsigned char f_nscns[2]; /* number of sections */ ++ unsigned char f_timdat[4]; /* time & date stamp */ ++ unsigned char f_symptr[8]; /* file pointer to symtab */ ++ unsigned char f_nsyms[4]; /* number of symtab entries */ ++ unsigned char f_opthdr[2]; /* sizeof(optional hdr) */ ++ unsigned char f_flags[2]; /* flags */ ++}; ++ ++/* Magic numbers are defined in coff/ecoff.h. */ ++#define SW64_ECOFF_BADMAG(x) \ ++ ((x).f_magic != SW64_MAGIC) ++ ++#define SW64_ECOFF_COMPRESSEDMAG(x) \ ++ ((x).f_magic == SW64_MAGIC) ++ ++/* The object type is encoded in the f_flags. */ ++#define F_SW64_OBJECT_TYPE_MASK 0x3000 ++#define F_SW64_NO_SHARED 0x1000 ++#define F_SW64_SHARABLE 0x2000 ++#define F_SW64_CALL_SHARED 0x3000 ++ ++#define FILHDR struct external_filehdr ++#define FILHSZ 24 ++ ++/********************** AOUT "OPTIONAL HEADER" **********************/ ++ ++typedef struct external_aouthdr ++{ ++ unsigned char magic[2]; /* type of file */ ++ unsigned char vstamp[2]; /* version stamp */ ++ unsigned char bldrev[2]; /* ?? */ ++ unsigned char padding[2]; /* pad to quadword boundary */ ++ unsigned char tsize[8]; /* text size in bytes */ ++ unsigned char dsize[8]; /* initialized data " " */ ++ unsigned char bsize[8]; /* uninitialized data " " */ ++ unsigned char entry[8]; /* entry pt. */ ++ unsigned char text_start[8]; /* base of text used for this file */ ++ unsigned char data_start[8]; /* base of data used for this file */ ++ unsigned char bss_start[8]; /* base of bss used for this file */ ++ unsigned char gprmask[4]; /* bitmask of general registers used */ ++ unsigned char fprmask[4]; /* bitmask of floating point registers used */ ++ unsigned char gp_value[8]; /* value for gp register */ ++} AOUTHDR; ++ ++/* compute size of a header */ ++ ++#define AOUTSZ 80 ++#define AOUTHDRSZ 80 ++ ++/********************** SECTION HEADER **********************/ ++ ++struct external_scnhdr ++{ ++ unsigned char s_name[8]; /* section name */ ++ unsigned char s_paddr[8]; /* physical address, aliased s_nlib */ ++ unsigned char s_vaddr[8]; /* virtual address */ ++ unsigned char s_size[8]; /* section size */ ++ unsigned char s_scnptr[8]; /* file ptr to raw data for section */ ++ unsigned char s_relptr[8]; /* file ptr to relocation */ ++ unsigned char s_lnnoptr[8]; /* file ptr to line numbers */ ++ unsigned char s_nreloc[2]; /* number of relocation entries */ ++ unsigned char s_nlnno[2]; /* number of line number entries*/ ++ unsigned char s_flags[4]; /* flags */ ++}; ++ ++#define SCNHDR struct external_scnhdr ++#define SCNHSZ 64 ++ ++/********************** RELOCATION DIRECTIVES **********************/ ++ ++struct external_reloc ++{ ++ unsigned char r_vaddr[8]; ++ unsigned char r_symndx[4]; ++ unsigned char r_bits[4]; ++}; ++ ++#define RELOC struct external_reloc ++#define RELSZ 16 ++ ++/* Constants to unpack the r_bits field. The SW64 seems to always be ++ little endian, so I haven't bothered to define big endian variants ++ of these. */ ++ ++#define RELOC_BITS0_TYPE_LITTLE 0xff ++#define RELOC_BITS0_TYPE_SH_LITTLE 0 ++ ++#define RELOC_BITS1_EXTERN_LITTLE 0x01 ++ ++#define RELOC_BITS1_OFFSET_LITTLE 0x7e ++#define RELOC_BITS1_OFFSET_SH_LITTLE 1 ++ ++#define RELOC_BITS1_RESERVED_LITTLE 0x80 ++#define RELOC_BITS1_RESERVED_SH_LITTLE 7 ++#define RELOC_BITS2_RESERVED_LITTLE 0xff ++#define RELOC_BITS2_RESERVED_SH_LEFT_LITTLE 1 ++#define RELOC_BITS3_RESERVED_LITTLE 0x03 ++#define RELOC_BITS3_RESERVED_SH_LEFT_LITTLE 9 ++ ++#define RELOC_BITS3_SIZE_LITTLE 0xfc ++#define RELOC_BITS3_SIZE_SH_LITTLE 2 ++ ++/* The r_type field in a reloc is one of the following values. */ ++#define SW64_R_IGNORE 0 ++#define SW64_R_REFLONG 1 ++#define SW64_R_REFQUAD 2 ++#define SW64_R_GPREL32 3 ++#define SW64_R_LITERAL 4 ++#define SW64_R_LITUSE 5 ++#define SW64_R_GPDISP 6 ++#define SW64_R_BRADDR 7 ++#define SW64_R_HINT 8 ++#define SW64_R_SREL16 9 ++#define SW64_R_SREL32 10 ++#define SW64_R_SREL64 11 ++#define SW64_R_OP_PUSH 12 ++#define SW64_R_OP_STORE 13 ++#define SW64_R_OP_PSUB 14 ++#define SW64_R_OP_PRSHIFT 15 ++#define SW64_R_GPVALUE 16 ++#define SW64_R_GPRELHIGH 17 ++#define SW64_R_GPRELLOW 18 ++#define SW64_R_IMMED 19 ++ ++/* Overloaded reloc value used by Net- and OpenBSD. */ ++#define SW64_R_LITERALSLEAZY 17 ++ ++/* With SW64_R_LITUSE, the r_size field is one of the following values. */ ++#define SW64_R_LU_BASE 1 ++#define SW64_R_LU_BYTOFF 2 ++#define SW64_R_LU_JSR 3 ++ ++/* With SW64_R_IMMED, the r_size field is one of the following values. */ ++#define SW64_R_IMMED_GP_16 1 ++#define SW64_R_IMMED_GP_HI32 2 ++#define SW64_R_IMMED_SCN_HI32 3 ++#define SW64_R_IMMED_BR_HI32 4 ++#define SW64_R_IMMED_LO32 5 ++ ++/********************** SYMBOLIC INFORMATION **********************/ ++ ++/* Written by John Gilmore. */ ++ ++/* ECOFF uses COFF-like section structures, but its own symbol format. ++ This file defines the symbol format in fields whose size and alignment ++ will not vary on different host systems. */ ++ ++/* File header as a set of bytes */ ++ ++struct hdr_ext ++{ ++ unsigned char h_magic[2]; ++ unsigned char h_vstamp[2]; ++ unsigned char h_ilineMax[4]; ++ unsigned char h_idnMax[4]; ++ unsigned char h_ipdMax[4]; ++ unsigned char h_isymMax[4]; ++ unsigned char h_ioptMax[4]; ++ unsigned char h_iauxMax[4]; ++ unsigned char h_issMax[4]; ++ unsigned char h_issExtMax[4]; ++ unsigned char h_ifdMax[4]; ++ unsigned char h_crfd[4]; ++ unsigned char h_iextMax[4]; ++ unsigned char h_cbLine[8]; ++ unsigned char h_cbLineOffset[8]; ++ unsigned char h_cbDnOffset[8]; ++ unsigned char h_cbPdOffset[8]; ++ unsigned char h_cbSymOffset[8]; ++ unsigned char h_cbOptOffset[8]; ++ unsigned char h_cbAuxOffset[8]; ++ unsigned char h_cbSsOffset[8]; ++ unsigned char h_cbSsExtOffset[8]; ++ unsigned char h_cbFdOffset[8]; ++ unsigned char h_cbRfdOffset[8]; ++ unsigned char h_cbExtOffset[8]; ++}; ++ ++/* File descriptor external record */ ++ ++struct fdr_ext ++{ ++ unsigned char f_adr[8]; ++ unsigned char f_cbLineOffset[8]; ++ unsigned char f_cbLine[8]; ++ unsigned char f_cbSs[8]; ++ unsigned char f_rss[4]; ++ unsigned char f_issBase[4]; ++ unsigned char f_isymBase[4]; ++ unsigned char f_csym[4]; ++ unsigned char f_ilineBase[4]; ++ unsigned char f_cline[4]; ++ unsigned char f_ioptBase[4]; ++ unsigned char f_copt[4]; ++ unsigned char f_ipdFirst[4]; ++ unsigned char f_cpd[4]; ++ unsigned char f_iauxBase[4]; ++ unsigned char f_caux[4]; ++ unsigned char f_rfdBase[4]; ++ unsigned char f_crfd[4]; ++ unsigned char f_bits1[1]; ++ unsigned char f_bits2[3]; ++ unsigned char f_padding[4]; ++}; ++ ++#define FDR_BITS1_LANG_BIG 0xF8 ++#define FDR_BITS1_LANG_SH_BIG 3 ++#define FDR_BITS1_LANG_LITTLE 0x1F ++#define FDR_BITS1_LANG_SH_LITTLE 0 ++ ++#define FDR_BITS1_FMERGE_BIG 0x04 ++#define FDR_BITS1_FMERGE_LITTLE 0x20 ++ ++#define FDR_BITS1_FREADIN_BIG 0x02 ++#define FDR_BITS1_FREADIN_LITTLE 0x40 ++ ++#define FDR_BITS1_FBIGENDIAN_BIG 0x01 ++#define FDR_BITS1_FBIGENDIAN_LITTLE 0x80 ++ ++#define FDR_BITS2_GLEVEL_BIG 0xC0 ++#define FDR_BITS2_GLEVEL_SH_BIG 6 ++#define FDR_BITS2_GLEVEL_LITTLE 0x03 ++#define FDR_BITS2_GLEVEL_SH_LITTLE 0 ++ ++/* We ignore the `reserved' field in bits2. */ ++ ++/* Procedure descriptor external record */ ++ ++struct pdr_ext { ++ unsigned char p_adr[8]; ++ unsigned char p_cbLineOffset[8]; ++ unsigned char p_isym[4]; ++ unsigned char p_iline[4]; ++ unsigned char p_regmask[4]; ++ unsigned char p_regoffset[4]; ++ unsigned char p_iopt[4]; ++ unsigned char p_fregmask[4]; ++ unsigned char p_fregoffset[4]; ++ unsigned char p_frameoffset[4]; ++ unsigned char p_lnLow[4]; ++ unsigned char p_lnHigh[4]; ++ unsigned char p_gp_prologue[1]; ++ unsigned char p_bits1[1]; ++ unsigned char p_bits2[1]; ++ unsigned char p_localoff[1]; ++ unsigned char p_framereg[2]; ++ unsigned char p_pcreg[2]; ++}; ++ ++#define PDR_BITS1_GP_USED_BIG 0x80 ++#define PDR_BITS1_REG_FRAME_BIG 0x40 ++#define PDR_BITS1_PROF_BIG 0x20 ++#define PDR_BITS1_RESERVED_BIG 0x1f ++#define PDR_BITS1_RESERVED_SH_LEFT_BIG 8 ++#define PDR_BITS2_RESERVED_BIG 0xff ++#define PDR_BITS2_RESERVED_SH_BIG 0 ++ ++#define PDR_BITS1_GP_USED_LITTLE 0x01 ++#define PDR_BITS1_REG_FRAME_LITTLE 0x02 ++#define PDR_BITS1_PROF_LITTLE 0x04 ++#define PDR_BITS1_RESERVED_LITTLE 0xf8 ++#define PDR_BITS1_RESERVED_SH_LITTLE 3 ++#define PDR_BITS2_RESERVED_LITTLE 0xff ++#define PDR_BITS2_RESERVED_SH_LEFT_LITTLE 5 ++ ++/* Line numbers */ ++ ++struct line_ext { ++ unsigned char l_line[4]; ++}; ++ ++/* Symbol external record */ ++ ++struct sym_ext { ++ unsigned char s_value[8]; ++ unsigned char s_iss[4]; ++ unsigned char s_bits1[1]; ++ unsigned char s_bits2[1]; ++ unsigned char s_bits3[1]; ++ unsigned char s_bits4[1]; ++}; ++ ++#define SYM_BITS1_ST_BIG 0xFC ++#define SYM_BITS1_ST_SH_BIG 2 ++#define SYM_BITS1_ST_LITTLE 0x3F ++#define SYM_BITS1_ST_SH_LITTLE 0 ++ ++#define SYM_BITS1_SC_BIG 0x03 ++#define SYM_BITS1_SC_SH_LEFT_BIG 3 ++#define SYM_BITS1_SC_LITTLE 0xC0 ++#define SYM_BITS1_SC_SH_LITTLE 6 ++ ++#define SYM_BITS2_SC_BIG 0xE0 ++#define SYM_BITS2_SC_SH_BIG 5 ++#define SYM_BITS2_SC_LITTLE 0x07 ++#define SYM_BITS2_SC_SH_LEFT_LITTLE 2 ++ ++#define SYM_BITS2_RESERVED_BIG 0x10 ++#define SYM_BITS2_RESERVED_LITTLE 0x08 ++ ++#define SYM_BITS2_INDEX_BIG 0x0F ++#define SYM_BITS2_INDEX_SH_LEFT_BIG 16 ++#define SYM_BITS2_INDEX_LITTLE 0xF0 ++#define SYM_BITS2_INDEX_SH_LITTLE 4 ++ ++#define SYM_BITS3_INDEX_SH_LEFT_BIG 8 ++#define SYM_BITS3_INDEX_SH_LEFT_LITTLE 4 ++ ++#define SYM_BITS4_INDEX_SH_LEFT_BIG 0 ++#define SYM_BITS4_INDEX_SH_LEFT_LITTLE 12 ++ ++/* External symbol external record */ ++ ++struct ext_ext { ++ struct sym_ext es_asym; ++ unsigned char es_bits1[1]; ++ unsigned char es_bits2[3]; ++ unsigned char es_ifd[4]; ++}; ++ ++#define EXT_BITS1_JMPTBL_BIG 0x80 ++#define EXT_BITS1_JMPTBL_LITTLE 0x01 ++ ++#define EXT_BITS1_COBOL_MAIN_BIG 0x40 ++#define EXT_BITS1_COBOL_MAIN_LITTLE 0x02 ++ ++#define EXT_BITS1_WEAKEXT_BIG 0x20 ++#define EXT_BITS1_WEAKEXT_LITTLE 0x04 ++ ++/* Dense numbers external record */ ++ ++struct dnr_ext { ++ unsigned char d_rfd[4]; ++ unsigned char d_index[4]; ++}; ++ ++/* Relative file descriptor */ ++ ++struct rfd_ext { ++ unsigned char rfd[4]; ++}; ++ ++/* Optimizer symbol external record */ ++ ++struct opt_ext { ++ unsigned char o_bits1[1]; ++ unsigned char o_bits2[1]; ++ unsigned char o_bits3[1]; ++ unsigned char o_bits4[1]; ++ struct rndx_ext o_rndx; ++ unsigned char o_offset[4]; ++}; ++ ++#define OPT_BITS2_VALUE_SH_LEFT_BIG 16 ++#define OPT_BITS2_VALUE_SH_LEFT_LITTLE 0 ++ ++#define OPT_BITS3_VALUE_SH_LEFT_BIG 8 ++#define OPT_BITS3_VALUE_SH_LEFT_LITTLE 8 ++ ++#define OPT_BITS4_VALUE_SH_LEFT_BIG 0 ++#define OPT_BITS4_VALUE_SH_LEFT_LITTLE 16 +diff -Naur gdb-14.1-after-patch/include/dis-asm.h gdb-14.1-sw64/include/dis-asm.h +--- gdb-14.1-after-patch/include/dis-asm.h 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/include/dis-asm.h 2025-03-03 10:59:13.750000000 +0800 +@@ -378,6 +378,7 @@ + extern disassembler_ftype cris_get_disassembler (bfd *); + + extern void print_aarch64_disassembler_options (FILE *); ++extern void print_sw64_disassembler_options (FILE *); + extern void print_i386_disassembler_options (FILE *); + extern void print_mips_disassembler_options (FILE *); + extern void print_nfp_disassembler_options (FILE *); +diff -Naur gdb-14.1-after-patch/include/elf/common.h gdb-14.1-sw64/include/elf/common.h +--- gdb-14.1-after-patch/include/elf/common.h 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/include/elf/common.h 2025-03-03 10:59:13.750000000 +0800 +@@ -415,6 +415,9 @@ + /* Alpha backend magic number. Written in the absence of an ABI. */ + #define EM_ALPHA 0x9026 + ++/* SW64 backend magic number. Written in the absence of an ABI. */ ++#define EM_SW64 0x9916 ++ + /* Cygnus M32R ELF backend. Written in the absence of an ABI. */ + #define EM_CYGNUS_M32R 0x9041 + +diff -Naur gdb-14.1-after-patch/include/elf/sw64.h gdb-14.1-sw64/include/elf/sw64.h +--- gdb-14.1-after-patch/include/elf/sw64.h 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/include/elf/sw64.h 2025-03-03 10:59:13.760000000 +0800 +@@ -0,0 +1,121 @@ ++/* SW64 ELF support for BFD. ++ Copyright (C) 1996-2023 Free Software Foundation, Inc. ++ ++ By Eric Youngdale, . No processor supplement available ++ for this platform. ++ ++ 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; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ++ MA 02110-1301, USA. */ ++ ++/* This file holds definitions specific to the SW64 ELF ABI. Note ++ that most of this is not actually implemented by BFD. */ ++ ++#ifndef _ELF_SW64_H ++#define _ELF_SW64_H ++ ++/* Processor specific flags for the ELF header e_flags field. */ ++ ++/* All addresses must be below 2GB. */ ++#define EF_SW64_32BIT 0x00000001 ++ ++/* All relocations needed for relaxation with code movement are present. */ ++#define EF_SW64_CANRELAX 0x00000002 ++ ++/* Processor specific section flags. */ ++ ++/* This section must be in the global data area. */ ++#define SHF_SW64_GPREL 0x10000000 ++ ++/* Section contains some sort of debugging information. The exact ++ format is unspecified. It's probably ECOFF symbols. */ ++#define SHT_SW64_DEBUG 0x70000001 ++ ++/* Section contains register usage information. */ ++#define SHT_SW64_REGINFO 0x70000002 ++ ++/* Special values for the st_other field in the symbol table. */ ++ ++#define STO_SW64_NOPV 0x80 ++#define STO_SW64_STD_GPLOAD 0x88 ++ ++/* Special values for Elf64_Dyn tag. */ ++#define DT_SW64_PLTRO DT_LOPROC ++ ++#include "elf/reloc-macros.h" ++ ++/* SW64 relocs. */ ++START_RELOC_NUMBERS (elf_sw64_reloc_type) ++ RELOC_NUMBER (R_SW64_NONE, 0) /* No reloc */ ++ RELOC_NUMBER (R_SW64_REFLONG, 1) /* Direct 32 bit */ ++ RELOC_NUMBER (R_SW64_REFQUAD, 2) /* Direct 64 bit */ ++ RELOC_NUMBER (R_SW64_GPREL32, 3) /* GP relative 32 bit */ ++ RELOC_NUMBER (R_SW64_LITERAL, 4) /* GP relative 16 bit w/optimization */ ++ RELOC_NUMBER (R_SW64_LITUSE, 5) /* Optimization hint for LITERAL */ ++ RELOC_NUMBER (R_SW64_GPDISP, 6) /* Add displacement to GP */ ++ RELOC_NUMBER (R_SW64_BRADDR, 7) /* PC+4 relative 23 bit shifted */ ++ RELOC_NUMBER (R_SW64_HINT, 8) /* PC+4 relative 16 bit shifted */ ++ RELOC_NUMBER (R_SW64_SREL16, 9) /* PC relative 16 bit */ ++ RELOC_NUMBER (R_SW64_SREL32, 10) /* PC relative 32 bit */ ++ RELOC_NUMBER (R_SW64_SREL64, 11) /* PC relative 64 bit */ ++ ++ /* Skip 12 - 16; deprecated ECOFF relocs. */ ++ ++ RELOC_NUMBER (R_SW64_GPRELHIGH, 17) /* GP relative 32 bit, high 16 bits */ ++ RELOC_NUMBER (R_SW64_GPRELLOW, 18) /* GP relative 32 bit, low 16 bits */ ++ RELOC_NUMBER (R_SW64_GPREL16, 19) /* GP relative 16 bit */ ++ ++ /* Skip 20 - 23; deprecated ECOFF relocs. */ ++ ++ /* These relocations are specific to shared libraries. */ ++ RELOC_NUMBER (R_SW64_COPY, 24) /* Copy symbol at runtime */ ++ RELOC_NUMBER (R_SW64_GLOB_DAT, 25) /* Create GOT entry */ ++ RELOC_NUMBER (R_SW64_JMP_SLOT, 26) /* Create PLT entry */ ++ RELOC_NUMBER (R_SW64_RELATIVE, 27) /* Adjust by program base */ ++ ++ /* Like BRADDR, but assert that the source and target object file ++ share the same GP value, and adjust the target address for ++ STO_SW64_STD_GPLOAD. */ ++ RELOC_NUMBER (R_SW64_BRSGP, 28) ++ ++ /* Thread-Local Storage. */ ++ RELOC_NUMBER (R_SW64_TLSGD, 29) ++ RELOC_NUMBER (R_SW64_TLSLDM, 30) ++ RELOC_NUMBER (R_SW64_DTPMOD64, 31) ++ RELOC_NUMBER (R_SW64_GOTDTPREL, 32) ++ RELOC_NUMBER (R_SW64_DTPREL64, 33) ++ RELOC_NUMBER (R_SW64_DTPRELHI, 34) ++ RELOC_NUMBER (R_SW64_DTPRELLO, 35) ++ RELOC_NUMBER (R_SW64_DTPREL16, 36) ++ RELOC_NUMBER (R_SW64_GOTTPREL, 37) ++ RELOC_NUMBER (R_SW64_TPREL64, 38) ++ RELOC_NUMBER (R_SW64_TPRELHI, 39) ++ RELOC_NUMBER (R_SW64_TPRELLO, 40) ++ RELOC_NUMBER (R_SW64_TPREL16, 41) ++ RELOC_NUMBER (R_SW64_BR26ADDR, 42) ++ RELOC_NUMBER (R_SW64_LITERAL_GOT, 43) /* GP relative 16 bit */ ++ ++END_RELOC_NUMBERS (R_SW64_max) ++ ++#define LITUSE_SW64_ADDR 0 ++#define LITUSE_SW64_BASE 1 ++#define LITUSE_SW64_BYTOFF 2 ++#define LITUSE_SW64_JSR 3 ++#define LITUSE_SW64_TLSGD 4 ++#define LITUSE_SW64_TLSLDM 5 ++#define LITUSE_SW64_JSRDIRECT 6 ++ ++#endif /* _ELF_SW64_H */ +diff -Naur gdb-14.1-after-patch/include/longlong.h gdb-14.1-sw64/include/longlong.h +--- gdb-14.1-after-patch/include/longlong.h 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/include/longlong.h 2025-03-03 10:59:13.760000000 +0800 +@@ -605,6 +605,14 @@ + # endif + #endif + ++#ifdef __sw_64__ ++# if W_TYPE_SIZE == 64 ++# define count_leading_zeros(count, x) ((count) = __builtin_clzll (x)) ++# define count_trailing_zeros(count, x) ((count) = __builtin_ctzll (x)) ++# define COUNT_LEADING_ZEROS_0 64 ++# endif ++#endif ++ + #if defined (__M32R__) && W_TYPE_SIZE == 32 + #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ + /* The cmp clears the condition bit. */ \ +diff -Naur gdb-14.1-after-patch/include/opcode/sw64.h gdb-14.1-sw64/include/opcode/sw64.h +--- gdb-14.1-after-patch/include/opcode/sw64.h 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/include/opcode/sw64.h 2025-03-03 10:59:13.770000000 +0800 +@@ -0,0 +1,252 @@ ++/* sw64.h -- Header file for SW64 opcode table ++ Copyright (C) 1996-2023 Free Software Foundation, Inc. ++ Contributed by Richard Henderson , ++ patterned after the PPC opcode table written by Ian Lance Taylor. ++ ++ This file is part of GDB, GAS, and the GNU binutils. ++ ++ GDB, GAS, and the GNU binutils are free software; you can redistribute ++ them and/or modify them under the terms of the GNU General Public ++ License as published by the Free Software Foundation; either version 3, ++ or (at your option) any later version. ++ ++ GDB, GAS, and the GNU binutils are distributed in the hope that they ++ 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 file; see the file COPYING3. If not, write to the Free ++ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, ++ MA 02110-1301, USA. */ ++ ++#ifndef OPCODE_SW64_H ++#define OPCODE_SW64_H ++ ++/* The opcode table is an array of struct sw64_opcode. */ ++ ++struct sw64_opcode ++{ ++ /* The opcode name. */ ++ const char *name; ++ ++ /* The opcode itself. Those bits which will be filled in with ++ operands are zeroes. */ ++ unsigned opcode; ++ ++ /* The opcode mask. This is used by the disassembler. This is a ++ mask containing ones indicating those bits which must match the ++ opcode field, and zeroes indicating those bits which need not ++ match (and are presumably filled in by operands). */ ++ unsigned mask; ++ ++ /* One bit flags for the opcode. These are primarily used to ++ indicate specific processors and environments support the ++ instructions. The defined values are listed below. */ ++ unsigned flags; ++ ++ /* An array of operand codes. Each code is an index into the ++ operand table. They appear in the order which the operands must ++ appear in assembly code, and are terminated by a zero. */ ++ unsigned char operands[4]; ++}; ++ ++/* The table itself is sorted by major opcode number, and is otherwise ++ in the order in which the disassembler should consider ++ instructions. */ ++extern const struct sw64_opcode sw64_opcodes[]; ++extern const unsigned sw64_num_opcodes; ++ ++/* Values defined for the flags field of a struct sw64_opcode. */ ++ ++/* CPU Availability */ ++#define AXP_OPCODE_BASE 0x0001 /* Base architecture -- all cpus. */ ++#define AXP_OPCODE_SW6A 0x0002 ++#define AXP_OPCODE_SW6B 0x0004 ++#define AXP_OPCODE_SW8A 0x0008 ++#define AXP_OPCODE_EV4 0x0002 /* EV4 specific PALcode insns. */ ++#define AXP_OPCODE_EV5 0x0004 /* EV5 specific PALcode insns. */ ++#define AXP_OPCODE_EV6 0x0008 /* EV6 specific PALcode insns. */ ++#define AXP_OPCODE_BWX 0x0100 /* Byte/word extension (amask bit 0). */ ++#define AXP_OPCODE_CIX 0x0200 /* "Count" extension (amask bit 1). */ ++#define AXP_OPCODE_MAX 0x0400 /* Multimedia extension (amask bit 8). */ ++ ++///* CPU Availability */ ++//#define AXP_OPCODE_BASE 0x0001 /* Base architecture -- all cpus. */ ++//#define AXP_OPCODE_SW6 0x0800 /* SW6 insns. */ ++//#define AXP_OPCODE_SW6A 0x1000 /* SW6A insns. */ ++//#define AXP_OPCODE_SW6B 0x2000 /* SW6B insns. */ ++//#define AXP_OPCODE_SW8A 0x4000 /* SW8A insns. */ ++ ++#define AXP_OPCODE_NOPAL (~(AXP_OPCODE_EV4|AXP_OPCODE_EV5|AXP_OPCODE_EV6|AXP_OPCODE_SW6A|AXP_OPCODE_SW6B|AXP_OPCODE_SW8A)) ++ ++/* A macro to extract the major opcode from an instruction. */ ++#define AXP_OP(i) (((i) >> 26) & 0x3F) ++ ++#define AXP_LITOP(i) (((i) >> 26) & 0x3D) ++ ++/* The total number of major opcodes. */ ++#define AXP_NOPS 0x40 ++ ++ ++/* The operands table is an array of struct sw64_operand. */ ++ ++struct sw64_operand ++{ ++ /* The number of bits in the operand. */ ++ unsigned int bits : 5; ++ ++ /* How far the operand is left shifted in the instruction. */ ++ unsigned int shift : 5; ++ ++ /* The default relocation type for this operand. */ ++ signed int default_reloc : 16; ++ ++ /* One bit syntax flags. */ ++ unsigned int flags : 16; ++ ++ /* Insertion function. This is used by the assembler. To insert an ++ operand value into an instruction, check this field. ++ ++ If it is NULL, execute ++ i |= (op & ((1 << o->bits) - 1)) << o->shift; ++ (i is the instruction which we are filling in, o is a pointer to ++ this structure, and op is the opcode value; this assumes twos ++ complement arithmetic). ++ ++ If this field is not NULL, then simply call it with the ++ instruction and the operand value. It will return the new value ++ of the instruction. If the ERRMSG argument is not NULL, then if ++ the operand value is illegal, *ERRMSG will be set to a warning ++ string (the operand will be inserted in any case). If the ++ operand value is legal, *ERRMSG will be unchanged (most operands ++ can accept any value). */ ++ unsigned (*insert) (unsigned instruction, int op, const char **errmsg); ++ ++ /* Extraction function. This is used by the disassembler. To ++ extract this operand type from an instruction, check this field. ++ ++ If it is NULL, compute ++ op = ((i) >> o->shift) & ((1 << o->bits) - 1); ++ if ((o->flags & AXP_OPERAND_SIGNED) != 0 ++ && (op & (1 << (o->bits - 1))) != 0) ++ op -= 1 << o->bits; ++ (i is the instruction, o is a pointer to this structure, and op ++ is the result; this assumes twos complement arithmetic). ++ ++ If this field is not NULL, then simply call it with the ++ instruction value. It will return the value of the operand. If ++ the INVALID argument is not NULL, *INVALID will be set to ++ non-zero if this operand type can not actually be extracted from ++ this operand (i.e., the instruction does not match). If the ++ operand is valid, *INVALID will not be changed. */ ++ int (*extract) (unsigned instruction, int *invalid); ++}; ++ ++/* Elements in the table are retrieved by indexing with values from ++ the operands field of the sw64_opcodes table. */ ++ ++extern const struct sw64_operand sw64_operands[]; ++extern const unsigned sw64_num_operands; ++ ++/* Values defined for the flags field of a struct sw64_operand. */ ++ ++/* Mask for selecting the type for typecheck purposes */ ++#define AXP_OPERAND_TYPECHECK_MASK \ ++ (AXP_OPERAND_PARENS | AXP_OPERAND_COMMA | AXP_OPERAND_IR | \ ++ AXP_OPERAND_FPR | AXP_OPERAND_RELATIVE | AXP_OPERAND_SIGNED | \ ++ AXP_OPERAND_UNSIGNED) ++ ++/* This operand does not actually exist in the assembler input. This ++ is used to support extended mnemonics, for which two operands fields ++ are identical. The assembler should call the insert function with ++ any op value. The disassembler should call the extract function, ++ ignore the return value, and check the value placed in the invalid ++ argument. */ ++#define AXP_OPERAND_FAKE 01 ++ ++/* The operand should be wrapped in parentheses rather than separated ++ from the previous by a comma. This is used for the load and store ++ instructions which want their operands to look like "Ra,disp(Rb)". */ ++#define AXP_OPERAND_PARENS 02 ++ ++/* Used in combination with PARENS, this supresses the supression of ++ the comma. This is used for "jmp Ra,(Rb),hint". */ ++#define AXP_OPERAND_COMMA 04 ++ ++/* This operand names an integer register. */ ++#define AXP_OPERAND_IR 010 ++ ++/* This operand names a floating point register. */ ++#define AXP_OPERAND_FPR 020 ++ ++/* This operand is a relative branch displacement. The disassembler ++ prints these symbolically if possible. */ ++#define AXP_OPERAND_RELATIVE 040 ++ ++/* This operand takes signed values. */ ++#define AXP_OPERAND_SIGNED 0100 ++ ++/* This operand takes unsigned values. This exists primarily so that ++ a flags value of 0 can be treated as end-of-arguments. */ ++#define AXP_OPERAND_UNSIGNED 0200 ++ ++/* Supress overflow detection on this field. This is used for hints. */ ++#define AXP_OPERAND_NOOVERFLOW 0400 ++ ++/* Mask for optional argument default value. */ ++#define AXP_OPERAND_OPTIONAL_MASK 07000 ++ ++/* This operand defaults to zero. This is used for jump hints. */ ++#define AXP_OPERAND_DEFAULT_ZERO 01000 ++ ++/* This operand should default to the first (real) operand and is used ++ in conjunction with AXP_OPERAND_OPTIONAL. This allows ++ "and $0,3,$0" to be written as "and $0,3", etc. I don't like ++ it, but it's what DEC does. */ ++#define AXP_OPERAND_DEFAULT_FIRST 02000 ++ ++/* Similarly, this operand should default to the second (real) operand. ++ This allows "negl $0" instead of "negl $0,$0". */ ++#define AXP_OPERAND_DEFAULT_SECOND 04000 ++ ++#define AXP_OPERAND_DEFAULT_THIRD 8000 ++ ++ ++/* Register common names */ ++ ++#define AXP_REG_V0 0 ++#define AXP_REG_T0 1 ++#define AXP_REG_T1 2 ++#define AXP_REG_T2 3 ++#define AXP_REG_T3 4 ++#define AXP_REG_T4 5 ++#define AXP_REG_T5 6 ++#define AXP_REG_T6 7 ++#define AXP_REG_T7 8 ++#define AXP_REG_S0 9 ++#define AXP_REG_S1 10 ++#define AXP_REG_S2 11 ++#define AXP_REG_S3 12 ++#define AXP_REG_S4 13 ++#define AXP_REG_S5 14 ++#define AXP_REG_FP 15 ++#define AXP_REG_A0 16 ++#define AXP_REG_A1 17 ++#define AXP_REG_A2 18 ++#define AXP_REG_A3 19 ++#define AXP_REG_A4 20 ++#define AXP_REG_A5 21 ++#define AXP_REG_T8 22 ++#define AXP_REG_T9 23 ++#define AXP_REG_T10 24 ++#define AXP_REG_T11 25 ++#define AXP_REG_RA 26 ++#define AXP_REG_PV 27 ++#define AXP_REG_T12 27 ++#define AXP_REG_AT 28 ++#define AXP_REG_GP 29 ++#define AXP_REG_SP 30 ++#define AXP_REG_ZERO 31 ++ ++#endif /* OPCODE_SW64_H */ +diff -Naur gdb-14.1-after-patch/opcodes/configure gdb-14.1-sw64/opcodes/configure +--- gdb-14.1-after-patch/opcodes/configure 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/opcodes/configure 2025-03-03 10:59:13.830000000 +0800 +@@ -12548,6 +12548,7 @@ + archdefs="$archdefs -DARCH_$ad" + case "$arch" in + bfd_aarch64_arch) ta="$ta aarch64-asm.lo aarch64-dis.lo aarch64-opc.lo aarch64-asm-2.lo aarch64-dis-2.lo aarch64-opc-2.lo" ;; ++ bfd_sw64_arch) ta="$ta sw64-dis.lo sw64-opc.lo" ;; + bfd_alpha_arch) ta="$ta alpha-dis.lo alpha-opc.lo" ;; + bfd_amdgcn_arch) ;; + bfd_arc_arch) ta="$ta arc-dis.lo arc-opc.lo arc-ext.lo" ;; +diff -Naur gdb-14.1-after-patch/opcodes/configure.ac gdb-14.1-sw64/opcodes/configure.ac +--- gdb-14.1-after-patch/opcodes/configure.ac 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/opcodes/configure.ac 2025-03-03 10:59:13.830000000 +0800 +@@ -265,6 +265,7 @@ + archdefs="$archdefs -DARCH_$ad" + case "$arch" in + bfd_aarch64_arch) ta="$ta aarch64-asm.lo aarch64-dis.lo aarch64-opc.lo aarch64-asm-2.lo aarch64-dis-2.lo aarch64-opc-2.lo" ;; ++ bfd_sw64_arch) ta="$ta sw64-dis.lo sw64-opc.lo" ;; + bfd_alpha_arch) ta="$ta alpha-dis.lo alpha-opc.lo" ;; + bfd_amdgcn_arch) ;; + bfd_arc_arch) ta="$ta arc-dis.lo arc-opc.lo arc-ext.lo" ;; +diff -Naur gdb-14.1-after-patch/opcodes/disassemble.c gdb-14.1-sw64/opcodes/disassemble.c +--- gdb-14.1-after-patch/opcodes/disassemble.c 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/opcodes/disassemble.c 2025-03-03 10:59:13.840000000 +0800 +@@ -26,6 +26,7 @@ + #ifdef ARCH_all + #ifdef BFD64 + #define ARCH_aarch64 ++#define ARCH_sw64 + #define ARCH_alpha + #define ARCH_bpf + #define ARCH_ia64 +@@ -126,6 +127,11 @@ + disassemble = print_insn_aarch64; + break; + #endif ++#ifdef ARCH_sw64 ++ case bfd_arch_sw64: ++ disassemble = print_insn_sw64; ++ break; ++#endif + #ifdef ARCH_alpha + case bfd_arch_alpha: + disassemble = print_insn_alpha; +@@ -553,6 +559,9 @@ + #ifdef ARCH_aarch64 + print_aarch64_disassembler_options (stream); + #endif ++#ifdef ARCH_sw64 ++ print_sw64_disassembler_options (stream); ++#endif + #ifdef ARCH_arc + print_arc_disassembler_options (stream); + #endif +@@ -607,6 +616,11 @@ + info->created_styled_output = true; + break; + #endif ++#ifdef ARCH_sw64 ++ case bfd_arch_sw64: ++ info->created_styled_output = true; ++ break; ++#endif + #ifdef ARCH_arc + case bfd_arch_arc: + info->created_styled_output = true; +diff -Naur gdb-14.1-after-patch/opcodes/disassemble.h gdb-14.1-sw64/opcodes/disassemble.h +--- gdb-14.1-after-patch/opcodes/disassemble.h 2023-10-08 15:51:14.000000000 +0800 ++++ gdb-14.1-sw64/opcodes/disassemble.h 2025-03-03 10:59:13.840000000 +0800 +@@ -22,6 +22,7 @@ + #include "dis-asm.h" + + extern int print_insn_aarch64 (bfd_vma, disassemble_info *); ++extern int print_insn_sw64 (bfd_vma, disassemble_info *); + extern int print_insn_alpha (bfd_vma, disassemble_info *); + extern int print_insn_avr (bfd_vma, disassemble_info *); + extern int print_insn_bfin (bfd_vma, disassemble_info *); +diff -Naur gdb-14.1-after-patch/opcodes/Makefile.in gdb-14.1-sw64/opcodes/Makefile.in +--- gdb-14.1-after-patch/opcodes/Makefile.in 2023-12-03 13:23:54.000000000 +0800 ++++ gdb-14.1-sw64/opcodes/Makefile.in 2025-03-03 10:59:13.820000000 +0800 +@@ -483,6 +483,8 @@ + aarch64-dis-2.c \ + aarch64-opc.c \ + aarch64-opc-2.c \ ++ sw64-dis.c \ ++ sw64-opc.c \ + alpha-dis.c \ + alpha-opc.c \ + bpf-dis.c \ +@@ -871,6 +873,8 @@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aarch64-dis.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aarch64-opc-2.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aarch64-opc.Plo@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sw64-dis.Plo@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sw64-opc.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha-dis.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha-opc.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arc-dis.Plo@am__quote@ +diff -Naur gdb-14.1-after-patch/opcodes/sw64-dis.c gdb-14.1-sw64/opcodes/sw64-dis.c +--- gdb-14.1-after-patch/opcodes/sw64-dis.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/opcodes/sw64-dis.c 2025-03-03 10:59:13.890000000 +0800 +@@ -0,0 +1,256 @@ ++/* sw64-dis.c -- Disassemble SW64 AXP instructions ++ Copyright (C) 1996-2023 Free Software Foundation, Inc. ++ Contributed by Richard Henderson , ++ patterned after the PPC opcode handling written by Ian Lance Taylor. ++ ++ This file is part of libopcodes. ++ ++ This library 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, or (at your option) ++ any later version. ++ ++ It 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 file; see the file COPYING. If not, write to the Free ++ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA ++ 02110-1301, USA. */ ++ ++#include "sysdep.h" ++#include "opintl.h" ++#include ++#include "disassemble.h" ++#include "opcode/sw64.h" ++ ++/* OSF register names. */ ++ ++static const char * const osf_regnames[64] = { ++ "$r0", "$r1", "$r2", "$r3" , "$r4", "$r5", "$r6", "$r7", ++ "$r8", "$r9", "$r10", "$r11" , "$r12", "$r13", "$r14", "fp", ++ "$r16", "$r17", "$r18", "$r19" , "$r20", "$r21", "$r22", "$r23", ++ "$r24", "$r25", "ra", "$r27" , "$r28", "$r29", "sp", "$r31", ++ "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", ++ "$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", ++ "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23", ++ "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31" ++}; ++ ++/* VMS register names. */ ++ ++static const char * const vms_regnames[64] = { ++ "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", ++ "R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15", ++ "R16", "R17", "R18", "R19", "R20", "R21", "R22", "R23", ++ "R24", "AI", "RA", "PV", "AT", "FP", "SP", "RZ", ++ "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7", ++ "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", ++ "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", ++ "F24", "F25", "F26", "F27", "F28", "F29", "F30", "FZ" ++}; ++ ++/* Disassemble SW64 instructions. */ ++ ++int ++print_insn_sw64 (bfd_vma memaddr, struct disassemble_info *info) ++{ ++ static const struct sw64_opcode *opcode_index[AXP_NOPS+1]; ++ const char * const * regnames; ++ const struct sw64_opcode *opcode, *opcode_end; ++ const unsigned char *opindex; ++ unsigned insn, op, isa_mask; ++ int need_comma; ++ ++ /* Initialize the majorop table the first time through */ ++ if (!opcode_index[0]) ++ { ++ opcode = sw64_opcodes; ++ opcode_end = opcode + sw64_num_opcodes; ++ ++ for (op = 0; op < AXP_NOPS; ++op) ++ { ++ opcode_index[op] = opcode; ++ if ((AXP_LITOP (opcode->opcode) != 0x10) ++ && (AXP_LITOP (opcode->opcode) != 0x11)) ++ { ++ while (opcode < opcode_end && op == AXP_OP (opcode->opcode)) ++ ++opcode; ++ } ++ else ++ { ++ while (opcode < opcode_end && op == AXP_LITOP (opcode->opcode)) ++ ++opcode; ++ } ++ } ++ opcode_index[op] = opcode; ++ } ++ ++ if (info->flavour == bfd_target_evax_flavour) ++ regnames = vms_regnames; ++ else ++ regnames = osf_regnames; ++ ++ isa_mask = AXP_OPCODE_NOPAL; ++ switch (info->mach) ++ { ++ case bfd_mach_sw64: ++ isa_mask |= AXP_OPCODE_BASE | AXP_OPCODE_SW6A; ++ break; ++ case bfd_mach_sw64_sw6b: ++ isa_mask |= AXP_OPCODE_BASE | AXP_OPCODE_SW6B; ++ break; ++ case bfd_mach_sw64_sw8a: ++ isa_mask |= AXP_OPCODE_BASE | AXP_OPCODE_SW8A; ++ break; ++ } ++ ++ /* Read the insn into a host word */ ++ { ++ bfd_byte buffer[4]; ++ int status = (*info->read_memory_func) (memaddr, buffer, 4, info); ++ if (status != 0) ++ { ++ (*info->memory_error_func) (status, memaddr, info); ++ return -1; ++ } ++ insn = bfd_getl32 (buffer); ++ } ++ ++ /* Get the major opcode of the instruction. */ ++ ++ if((AXP_LITOP (insn)==0x10) || (AXP_LITOP (insn)==0x11)) ++ op = AXP_LITOP (insn); ++ else if((AXP_OP(insn) & 0x3C) == 0x14 ) //logx ++ op=0x14; ++ else ++ op = AXP_OP (insn); ++ ++ /* Find the first match in the opcode table. */ ++ opcode_end = opcode_index[op + 1]; ++ for (opcode = opcode_index[op]; opcode < opcode_end; ++opcode) ++ { ++ if ((insn ^ opcode->opcode) & opcode->mask) ++ continue; ++ ++ if (!(opcode->flags & isa_mask)) ++ continue; ++ ++ /* Make two passes over the operands. First see if any of them ++ have extraction functions, and, if they do, make sure the ++ instruction is valid. */ ++ { ++ int invalid = 0; ++ for (opindex = opcode->operands; *opindex != 0; opindex++) ++ { ++ const struct sw64_operand *operand = sw64_operands + *opindex; ++ if (operand->extract) ++ (*operand->extract) (insn, &invalid); ++ } ++ if (invalid) ++ continue; ++ } ++ ++ /* The instruction is valid. */ ++ goto found; ++ } ++ ++ /* No instruction found */ ++ (*info->fprintf_func) (info->stream, ".long %#08x", insn); ++ ++ return 4; ++ ++found: ++ if (!strncmp ("sys_call", opcode->name,8)) ++ { ++ if (insn & (0x1 << 25)) ++ (*info->fprintf_func) (info->stream, "%s", "sys_call"); ++ else ++ (*info->fprintf_func) (info->stream, "%s", "sys_call/b"); ++ } ++ else ++ (*info->fprintf_func) (info->stream, "%s", opcode->name); ++ ++/* get zz[7:6] and zz[5:0] to form truth for vlog */ ++ if (!strcmp(opcode->name,"vlog")) ++ { ++ unsigned int truth; ++ char tr[4]; ++ truth = (AXP_OP (insn) & 3) << 6; ++ truth = truth | ((insn & 0xFC00) >> 10); ++ sprintf (tr,"%x",truth); ++ (*info->fprintf_func) (info->stream, "%s", tr); ++ } ++ if (opcode->operands[0] != 0) ++ (*info->fprintf_func) (info->stream, "\t"); ++ ++ /* Now extract and print the operands. */ ++ need_comma = 0; ++ for (opindex = opcode->operands; *opindex != 0; opindex++) ++ { ++ const struct sw64_operand *operand = sw64_operands + *opindex; ++ int value; ++ ++ /* Operands that are marked FAKE are simply ignored. We ++ already made sure that the extract function considered ++ the instruction to be valid. */ ++ if ((operand->flags & AXP_OPERAND_FAKE) != 0) ++ continue; ++ ++ /* Extract the value from the instruction. */ ++ if (operand->extract) ++ value = (*operand->extract) (insn, (int *) NULL); ++ else ++ { ++ value = (insn >> operand->shift) & ((1 << operand->bits) - 1); ++ if (operand->flags & AXP_OPERAND_SIGNED) ++ { ++ int signbit = 1 << (operand->bits - 1); ++ value = (value ^ signbit) - signbit; ++ } ++ } ++ ++ if (need_comma && ++ ((operand->flags & (AXP_OPERAND_PARENS | AXP_OPERAND_COMMA)) ++ != AXP_OPERAND_PARENS)) ++ { ++ (*info->fprintf_func) (info->stream, ","); ++ } ++ if (operand->flags & AXP_OPERAND_PARENS) ++ (*info->fprintf_func) (info->stream, "("); ++ ++ /* Print the operand as directed by the flags. */ ++ if (operand->flags & AXP_OPERAND_IR) ++ (*info->fprintf_func) (info->stream, "%s", regnames[value]); ++ else if (operand->flags & AXP_OPERAND_FPR) ++ (*info->fprintf_func) (info->stream, "%s", regnames[value + 32]); ++ else if (operand->flags & AXP_OPERAND_RELATIVE) ++ (*info->print_address_func) (memaddr + 4 + value, info); ++ else if (operand->flags & AXP_OPERAND_SIGNED) ++ (*info->fprintf_func) (info->stream, "%d", value); ++ else ++ (*info->fprintf_func) (info->stream, "%#x", value); ++ ++ if (operand->flags & AXP_OPERAND_PARENS) ++ (*info->fprintf_func) (info->stream, ")"); ++ need_comma = 1; ++ } ++ ++ return 4; ++} ++ ++void ++print_sw64_disassembler_options (FILE *stream) ++{ ++ fprintf (stream, _("\n\ ++The following SW64 disassembler options are supported for use\n\ ++with the -M switch (multiple options should be separated by commas):\n")); ++ ++ fprintf (stream, _("\n\ ++ no-aliases Use canonical instruction forms.\n")); ++ fprintf (stream, _("\n\ ++ numeric Print numeric register names, rather than ABI names.\n")); ++ fprintf (stream, _("\n")); ++} +diff -Naur gdb-14.1-after-patch/opcodes/sw64-opc.c gdb-14.1-sw64/opcodes/sw64-opc.c +--- gdb-14.1-after-patch/opcodes/sw64-opc.c 1970-01-01 08:00:00.000000000 +0800 ++++ gdb-14.1-sw64/opcodes/sw64-opc.c 2025-03-03 10:59:13.890000000 +0800 +@@ -0,0 +1,1057 @@ ++/* sw64-opc.c -- SW64 AXP opcode list ++ Copyright (C) 1996-2023 Free Software Foundation, Inc. ++ Contributed by Richard Henderson , ++ patterned after the PPC opcode handling written by Ian Lance Taylor. ++ ++ This file is part of libopcodes. ++ ++ This library 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, or (at your option) ++ any later version. ++ ++ It 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 file; see the file COPYING. If not, write to the ++ Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA ++ 02110-1301, USA. */ ++ ++#include "sysdep.h" ++#include ++#include "opcode/sw64.h" ++#include "bfd.h" ++#include "opintl.h" ++ ++/* This file holds the SW64 AXP opcode table. The opcode table includes ++ almost all of the extended instruction mnemonics. This permits the ++ disassembler to use them, and simplifies the assembler logic, at the ++ cost of increasing the table size. The table is strictly constant ++ data, so the compiler should be able to put it in the text segment. ++ ++ This file also holds the operand table. All knowledge about inserting ++ and extracting operands from instructions is kept in this file. ++ ++ The information for the base instruction set was compiled from the ++ _SW64 Architecture Handbook_, Digital Order Number EC-QD2KB-TE, ++ version 2. ++ */ ++ ++/* The RB field when it is the same as the RA field in the same insn. ++ This operand is marked fake. The insertion function just copies ++ the RA field into the RB field, and the extraction function just ++ checks that the fields are the same. */ ++ ++static unsigned ++insert_rba (unsigned insn, ++ int value ATTRIBUTE_UNUSED, ++ const char **errmsg ATTRIBUTE_UNUSED) ++{ ++ return insn | (((insn >> 21) & 0x1f) << 16); ++} ++ ++static int ++extract_rba (unsigned insn, int *invalid) ++{ ++ if (invalid != (int *) NULL ++ && ((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f)) ++ *invalid = 1; ++ return 0; ++} ++ ++/* The same for the RC field. */ ++ ++static unsigned ++insert_rca (unsigned insn, ++ int value ATTRIBUTE_UNUSED, ++ const char **errmsg ATTRIBUTE_UNUSED) ++{ ++ return insn | ((insn >> 21) & 0x1f); ++} ++ ++static int ++extract_rca (unsigned insn, int *invalid) ++{ ++ if (invalid != (int *) NULL ++ && ((insn >> 21) & 0x1f) != (insn & 0x1f)) ++ *invalid = 1; ++ return 0; ++} ++ ++static unsigned ++insert_rdc (unsigned insn, ++ int value ATTRIBUTE_UNUSED, ++ const char **errmsg ATTRIBUTE_UNUSED) ++{ ++ return insn | ((insn >> 5) & 0x1f); ++} ++ ++static int ++extract_rdc (unsigned insn, int *invalid) ++{ ++ if (invalid != (int *) NULL ++ && ((insn >> 5) & 0x1f) != (insn & 0x1f)) ++ *invalid = 1; ++ return 0; ++} ++ ++/* Fake arguments in which the registers must be set to ZERO. */ ++ ++static unsigned ++insert_za (unsigned insn, ++ int value ATTRIBUTE_UNUSED, ++ const char **errmsg ATTRIBUTE_UNUSED) ++{ ++ return insn | (31 << 21); ++} ++ ++static int ++extract_za (unsigned insn, int *invalid) ++{ ++ if (invalid != (int *) NULL && ((insn >> 21) & 0x1f) != 31) ++ *invalid = 1; ++ return 0; ++} ++ ++static unsigned ++insert_zb (unsigned insn, ++ int value ATTRIBUTE_UNUSED, ++ const char **errmsg ATTRIBUTE_UNUSED) ++{ ++ return insn | (31 << 16); ++} ++ ++static int ++extract_zb (unsigned insn, int *invalid) ++{ ++ if (invalid != (int *) NULL && ((insn >> 16) & 0x1f) != 31) ++ *invalid = 1; ++ return 0; ++} ++ ++static unsigned ++insert_zc (unsigned insn, ++ int value ATTRIBUTE_UNUSED, ++ const char **errmsg ATTRIBUTE_UNUSED) ++{ ++ return insn | 31; ++} ++ ++static int ++extract_zc (unsigned insn, int *invalid) ++{ ++ if (invalid != (int *) NULL && (insn & 0x1f) != 31) ++ *invalid = 1; ++ return 0; ++} ++ ++ ++/* The displacement field of a Branch format insn. */ ++ ++static unsigned ++insert_bdisp (unsigned insn, int value, const char **errmsg) ++{ ++ if (errmsg != (const char **)NULL && (value & 3)) ++ *errmsg = _("branch operand unaligned"); ++ return insn | ((value / 4) & 0x1FFFFF); ++} ++ ++static int ++extract_bdisp (unsigned insn, int *invalid ATTRIBUTE_UNUSED) ++{ ++ return 4 * (((insn & 0x1FFFFF) ^ 0x100000) - 0x100000); ++} ++ ++/* The hint field of a JMP/JSR insn. */ ++ ++/* sw use 16 bits hint disp. */ ++static unsigned ++insert_jhint (unsigned insn, int value, const char **errmsg) ++{ ++ if (errmsg != (const char **)NULL && (value & 3)) ++ *errmsg = _("jump hint unaligned"); ++ return insn | ((value / 4) & 0xFFFF); ++} ++ ++static int ++extract_jhint (unsigned insn, int *invalid ATTRIBUTE_UNUSED) ++{ ++ return 4 * (((insn & 0xFFFF) ^ 0x8000) - 0x8000); ++} ++ ++/* The hint field of an SW6 HW_JMP/JSR insn. */ ++ ++static unsigned ++insert_sw6hwjhint (unsigned insn, int value, const char **errmsg) ++{ ++ if (errmsg != (const char **)NULL && (value & 3)) ++ *errmsg = _("jump hint unaligned"); ++ return insn | ((value / 4) & 0x1FFF); ++} ++ ++static int ++extract_sw6hwjhint (unsigned insn, int *invalid ATTRIBUTE_UNUSED) ++{ ++ return 4 * (((insn & 0x1FFF) ^ 0x1000) - 0x1000); ++} ++ ++/* The operands table. */ ++ ++const struct sw64_operand sw64_operands[] = ++{ ++ /* The fields are bits, shift, insert, extract, flags */ ++ /* The zero index is used to indicate end-of-list */ ++#define UNUSED 0 ++ { 0, 0, 0, 0, 0, 0 }, ++ ++ /* The plain integer register fields. */ ++#define RA (UNUSED + 1) ++ { 5, 21, 0, AXP_OPERAND_IR, 0, 0 }, ++#define RB (RA + 1) ++ { 5, 16, 0, AXP_OPERAND_IR, 0, 0 }, ++#define RC (RB + 1) ++ { 5, 0, 0, AXP_OPERAND_IR, 0, 0 }, ++ ++ /* The plain fp register fields. */ ++#define FA (RC + 1) ++ { 5, 21, 0, AXP_OPERAND_FPR, 0, 0 }, ++#define FB (FA + 1) ++ { 5, 16, 0, AXP_OPERAND_FPR, 0, 0 }, ++#define FC (FB + 1) ++ { 5, 0, 0, AXP_OPERAND_FPR, 0, 0 }, ++ ++ /* The integer registers when they are ZERO. */ ++#define ZA (FC + 1) ++ { 5, 21, 0, AXP_OPERAND_FAKE, insert_za, extract_za }, ++#define ZB (ZA + 1) ++ { 5, 16, 0, AXP_OPERAND_FAKE, insert_zb, extract_zb }, ++#define ZC (ZB + 1) ++ { 5, 0, 0, AXP_OPERAND_FAKE, insert_zc, extract_zc }, ++ ++ /* The RB field when it needs parentheses. */ ++#define PRB (ZC + 1) ++ { 5, 16, 0, AXP_OPERAND_IR|AXP_OPERAND_PARENS, 0, 0 }, ++ ++ /* The RB field when it needs parentheses _and_ a preceding comma. */ ++#define CPRB (PRB + 1) ++ { 5, 16, 0, ++ AXP_OPERAND_IR|AXP_OPERAND_PARENS|AXP_OPERAND_COMMA, 0, 0 }, ++ ++ /* The RB field when it must be the same as the RA field. */ ++#define RBA (CPRB + 1) ++ { 5, 16, 0, AXP_OPERAND_FAKE, insert_rba, extract_rba }, ++ ++ /* The RC field when it must be the same as the RB field. */ ++#define RCA (RBA + 1) ++ { 5, 0, 0, AXP_OPERAND_FAKE, insert_rca, extract_rca }, ++ ++#define RDC (RCA + 1) ++ { 5, 0, 0, AXP_OPERAND_FAKE, insert_rdc, extract_rdc }, ++ ++ /* The RC field when it can *default* to RA. */ ++#define DRC1 (RDC + 1) ++ { 5, 0, 0, ++ AXP_OPERAND_IR|AXP_OPERAND_DEFAULT_FIRST, 0, 0 }, ++ ++ /* The RC field when it can *default* to RB. */ ++#define DRC2 (DRC1 + 1) ++ { 5, 0, 0, ++ AXP_OPERAND_IR|AXP_OPERAND_DEFAULT_SECOND, 0, 0 }, ++ ++ /* The RD field when it can *default* to RC. */ ++#define DRC3 (DRC2 + 1) ++ { 5, 0, 0, ++ AXP_OPERAND_IR|AXP_OPERAND_DEFAULT_THIRD, 0, 0 }, ++ ++ /* The FC field when it can *default* to RA. */ ++#define DFC1 (DRC3 + 1) ++ { 5, 0, 0, ++ AXP_OPERAND_FPR|AXP_OPERAND_DEFAULT_FIRST, 0, 0 }, ++ ++ /* The FC field when it can *default* to RB. */ ++#define DFC2 (DFC1 + 1) ++ { 5, 0, 0, ++ AXP_OPERAND_FPR|AXP_OPERAND_DEFAULT_SECOND, 0, 0 }, ++ ++ /* The FD field when it can *default* to FC. */ ++#define DFC3 (DFC2 + 1) ++ { 5, 0, 0, ++ AXP_OPERAND_FPR|AXP_OPERAND_DEFAULT_THIRD, 0, 0 }, ++ ++ /* The unsigned 8-bit literal of Operate format insns. */ ++#define LIT (DFC3 + 1) ++ { 8, 13, -LIT, AXP_OPERAND_UNSIGNED, 0, 0 }, ++ ++ /* The signed 16-bit displacement of Memory format insns. From here ++ we can't tell what relocation should be used, so don't use a default. */ ++#define MDISP (LIT + 1) ++ { 16, 0, -MDISP, AXP_OPERAND_SIGNED, 0, 0 }, ++ ++ /* The signed "23-bit" aligned displacement of Branch format insns. */ ++#define BDISP (MDISP + 1) ++ { 21, 0, BFD_RELOC_23_PCREL_S2, ++ AXP_OPERAND_RELATIVE, insert_bdisp, extract_bdisp }, ++ ++ /* The 25-bit PALcode function. */ ++#define PALFN (BDISP + 1) ++ { 25, 0, -PALFN, AXP_OPERAND_UNSIGNED, 0, 0 }, ++ ++ /* sw jsr/ret insntructions has no function bits. */ ++ /* The optional signed "16-bit" aligned displacement of the JMP/JSR hint. */ ++#define JMPHINT (PALFN + 1) ++ { 16, 0, BFD_RELOC_SW64_HINT, ++ AXP_OPERAND_RELATIVE|AXP_OPERAND_DEFAULT_ZERO|AXP_OPERAND_NOOVERFLOW, ++ insert_jhint, extract_jhint }, ++ ++ /* The optional hint to RET/JSR_COROUTINE. */ ++#define RETHINT (JMPHINT + 1) ++ { 16, 0, -RETHINT, ++ AXP_OPERAND_UNSIGNED|AXP_OPERAND_DEFAULT_ZERO, 0, 0 }, ++ ++#define SW6HWDISP (RETHINT + 1) ++ {12, 0, -SW6HWDISP, AXP_OPERAND_SIGNED, 0, 0 }, ++ ++ /* The 16-bit combined index/scoreboard mask for the sw6 ++ hw_m[ft]pr (pal19/pal1d) insns. */ ++#define SW6HWINDEX (SW6HWDISP + 1) ++ { 16, 0, -SW6HWINDEX, AXP_OPERAND_UNSIGNED, 0, 0 }, ++ ++ /* The 13-bit branch hint for the sw6 hw_jmp/jsr (pal1e) insn. */ ++#define SW6HWJMPHINT (SW6HWINDEX+ 1) ++ { 8, 0, -SW6HWJMPHINT, ++ AXP_OPERAND_RELATIVE|AXP_OPERAND_DEFAULT_ZERO|AXP_OPERAND_NOOVERFLOW, ++ insert_sw6hwjhint, extract_sw6hwjhint }, ++ ++ /* for the third operand of ternary operands integer insn. */ ++#define R3 (SW6HWJMPHINT + 1) ++ { 5, 5, 0, AXP_OPERAND_IR, 0, 0 }, ++ ++ /* The plain fp register fields */ ++#define F3 (R3 + 1) ++ { 5, 5, 0, AXP_OPERAND_FPR, 0, 0 }, ++ ++/* sw simd settle instruction lit */ ++#define FMALIT (F3 + 1) ++ { 5, 5, -FMALIT, AXP_OPERAND_UNSIGNED, 0, 0 },//V1.1 ++ ++/*for pal to check disp which must be plus sign and less than 0x8000,WCH20080901*/ ++#define LMDISP (FMALIT + 1) ++ { 15, 0, -LMDISP, AXP_OPERAND_UNSIGNED, 0, 0 }, ++ ++#define RPIINDEX (LMDISP + 1) ++ { 8, 0, -RPIINDEX, AXP_OPERAND_UNSIGNED, 0, 0 }, ++ ++#define ATMDISP (RPIINDEX + 1) ++ { 12, 0, -ATMDISP, AXP_OPERAND_SIGNED, 0, 0 }, ++}; ++ ++const unsigned sw64_num_operands = sizeof(sw64_operands)/sizeof(*sw64_operands); ++ ++ ++/* Macros used to form opcodes. */ ++ ++/* The main opcode. */ ++#define OP(x) (((x) & 0x3Fu) << 26) ++#define OP_MASK 0xFC000000 ++ ++/* Branch format instructions. */ ++#define BRA_(oo) OP(oo) ++#define BRA_MASK OP_MASK ++#define BRA(oo) BRA_(oo), BRA_MASK ++ ++/* Floating point format instructions. */ ++#define FP_(oo,fff) (OP(oo) | (((fff) & 0xFF) << 5)) ++#define FP_MASK (OP_MASK | 0x1FE0) ++#define FP(oo,fff) FP_(oo,fff), FP_MASK ++ ++#define FMA_(oo,fff) (OP(oo) | (((fff) & 0x3F) << 10 )) ++#define FMA_MASK (OP_MASK | 0xFC00) ++#define FMA(oo,fff) FMA_(oo,fff), FMA_MASK ++ ++/* Memory format instructions. */ ++#define MEM_(oo) OP(oo) ++#define MEM_MASK OP_MASK ++#define MEM(oo) MEM_(oo), MEM_MASK ++ ++/* Memory/Func Code format instructions. */ ++#define MFC_(oo,ffff) (OP(oo) | ((ffff) & 0xFFFF)) ++#define MFC_MASK (OP_MASK | 0xFFFF) ++#define MFC(oo,ffff) MFC_(oo,ffff), MFC_MASK ++ ++/* Memory/Branch format instructions. */ ++#define MBR_(oo,h) (OP(oo) | (((h) & 3) << 14)) ++#define MBR_MASK (OP_MASK | 0xC000) ++#define MBR(oo,h) MBR_(oo,h), MBR_MASK ++ ++/* Operate format instructions. The OPRL variant specifies a ++ literal second argument. */ ++#define OPR_(oo,ff) (OP(oo) | (((ff) & 0xFF) << 5)) ++#define OPRL_(oo,ff) (OPR_((oo),(ff)) ) ++#define OPR_MASK (OP_MASK | 0x1FE0) ++#define OPR(oo,ff) OPR_(oo,ff), OPR_MASK ++#define OPRL(oo,ff) OPRL_(oo,ff), OPR_MASK ++ ++/* sw ternary operands Operate format instructions. */ ++#define TOPR_(oo,ff) (OP(oo) | (((ff) & 0x07) << 10)) ++#define TOPRL_(oo,ff) (TOPR_((oo),(ff))) ++#define TOPR_MASK (OP_MASK | 0x1C00) ++#define TOPR(oo,ff) TOPR_(oo,ff), TOPR_MASK ++#define TOPRL(oo,ff) TOPRL_(oo,ff), TOPR_MASK ++ ++/* sw atom instructions. */ ++#define ATMEM_(oo,h) (OP(oo) | (((h) & 0xF) << 12)) ++#define ATMEM_MASK (OP_MASK | 0xF000) ++#define ATMEM(oo,h) ATMEM_(oo,h), ATMEM_MASK ++ ++/* sw privilege instructions. */ ++#define PRIRET_(oo,h) (OP(oo) | (((h) & 0x1) << 20)) ++#define PRIRET_MASK (OP_MASK | 0x100000) ++#define PRIRET(oo,h) PRIRET_(oo,h), PRIRET_MASK ++ ++/* sw rpi_rcsr,rpi_wcsr. */ ++#define CSR_(oo,ff) (OP(oo) | (((ff) & 0xFF) << 8)) ++#define CSR_MASK (OP_MASK | 0xFF00) ++#define CSR(oo,ff) CSR_(oo,ff), CSR_MASK ++ ++/* Generic PALcode format instructions. */ ++#define PCD_(oo,ff) (OP(oo) | (ff << 25)) ++#define PCD_MASK OP_MASK ++#define PCD(oo,ff) PCD_(oo,ff), PCD_MASK ++ ++/* Specific PALcode instructions. */ ++#define SPCD_(oo,ffff) (OP(oo) | ((ffff) & 0x3FFFFFF)) ++#define SPCD_MASK 0xFFFFFFFF ++#define SPCD(oo,ffff) SPCD_(oo,ffff), SPCD_MASK ++ ++/* Hardware memory (hw_{ld,st}) instructions. */ ++#define SW6HWMEM_(oo,f) (OP(oo) | (((f) & 0xF) << 12)) ++#define SW6HWMEM_MASK (OP_MASK | 0xF000) ++#define SW6HWMEM(oo,f) SW6HWMEM_(oo,f), SW6HWMEM_MASK ++ ++#define SW6HWMBR_(oo,h) (OP(oo) | (((h) & 7) << 13)) ++#define SW6HWMBR_MASK (OP_MASK | 0xE000) ++#define SW6HWMBR(oo,h) SW6HWMBR_(oo,h), SW6HWMBR_MASK ++ ++#define LOGX_(oo,ff) (OP(oo) | (((ff) & 0x3F) << 10)) ++#define LOGX_MASK (0xF0000000) ++#define LOGX(oo,ff) LOGX_(oo,ff), LOGX_MASK ++ ++#define PSE_LOGX_(oo,ff) (OP(oo) | (((ff) & 0x3F) << 10) | (((ff) >> 0x6) << 26 ) | 0x3E0 ) ++#define PSE_LOGX(oo,ff) PSE_LOGX_(oo,ff), LOGX_MASK ++ ++/* Abbreviations for instruction subsets. */ ++//#define SW6 AXP_OPCODE_SW6 ++#define BASE AXP_OPCODE_BASE ++#define SW6A AXP_OPCODE_SW6A ++#define SW6B AXP_OPCODE_SW6B ++#define SW8A AXP_OPCODE_SW8A ++ ++/* Common combinations of arguments. */ ++#define ARG_NONE { 0 } ++#define ARG_BRA { RA, BDISP } ++#define ARG_FBRA { FA, BDISP } ++#define ARG_FP { FA, FB, DFC1 } ++#define ARG_FPZ1 { ZA, FB, DFC1 } ++#define ARG_MEM { RA, MDISP, PRB } ++#define ARG_FMEM { FA, MDISP, PRB } ++#define ARG_OPR { RA, RB, DRC1 } ++#define ARG_OPRL { RA, LIT, DRC1 } ++#define ARG_OPRZ1 { ZA, RB, DRC1 } ++#define ARG_OPRLZ1 { ZA, LIT, RC } ++#define ARG_PCD { PALFN } ++#define ARG_SW6HWMEM { RA, SW6HWDISP, PRB } ++ ++#define ARG_FPL { FA,LIT, DFC1 } ++#define ARG_FMA { FA,FB,F3, DFC1 } ++#define ARG_PREFETCH { ZA, MDISP, PRB } ++#define ARG_FCMOV { FA,FB,F3, DFC3 } ++#define ARG_TOPR { RA, RB,R3, DRC3 } ++#define ARG_TOPRL { RA, LIT, R3,DRC3 } ++ ++/* for cmov** instruction. */ ++#define ARG_TOPC { RA, RB, R3, RDC } ++#define ARG_TOPCL { RA, LIT, R3, RDC } ++#define ARG_TOPFC { FA, FB, F3, RDC } ++#define ARG_TOPFCL { FA, LIT, F3, RDC } ++ ++/* sw settle instruction. */ ++#define ARG_FMAL { FA,FB,FMALIT, DFC1 } ++/* sw atom insitruction. */ ++#define ARG_ATMEM { RA, ATMDISP, PRB } ++ ++#define ARG_VUAMEM { FA, ATMDISP, PRB } ++#define ARG_OPRLZ3 { RA, LIT, ZC } ++ ++/* The opcode table. ++ ++ The format of the opcode table is: ++ ++ NAME OPCODE MASK { OPERANDS } ++ ++ NAME is the name of the instruction. ++ ++ OPCODE is the instruction opcode. ++ ++ MASK is the opcode mask; this is used to tell the disassembler ++ which bits in the actual opcode must match OPCODE. ++ ++ OPERANDS is the list of operands. ++ ++ The preceding macros merge the text of the OPCODE and MASK fields. ++ ++ The disassembler reads the table in order and prints the first ++ instruction which matches, so this table is sorted to put more ++ specific instructions before more general instructions. ++ ++ Otherwise, it is sorted by major opcode and minor function code. ++ ++ There are three classes of not-really-instructions in this table: ++ ++ ALIAS is another name for another instruction. Some of ++ these come from the Architecture Handbook, some ++ come from the original gas opcode tables. In all ++ cases, the functionality of the opcode is unchanged. ++ ++ PSEUDO a stylized code form endorsed by Chapter A.4 of the ++ Architecture Handbook. ++ ++ EXTRA a stylized code form found in the original gas tables. ++ */ ++ ++const struct sw64_opcode sw64_opcodes[] = ++{ ++ { "sys_call/b", PCD(0x00,0x00), BASE, ARG_PCD }, ++ { "sys_call", PCD(0x00,0x01), BASE, ARG_PCD }, ++ { "draina", SPCD(0x00,0x0002), BASE, ARG_NONE }, ++ { "bpt", SPCD(0x00,0x0080), BASE, ARG_NONE }, ++ { "bugchk", SPCD(0x00,0x0081), BASE, ARG_NONE }, ++ { "callsys", SPCD(0x00,0x0083), BASE, ARG_NONE }, ++ { "chmk", SPCD(0x00,0x0083), BASE, ARG_NONE }, ++ { "imb", SPCD(0x00,0x0086), BASE, ARG_NONE }, ++ { "rduniq", SPCD(0x00,0x009e), BASE, ARG_NONE }, ++ { "wruniq", SPCD(0x00,0x009f), BASE, ARG_NONE }, ++ { "gentrap", SPCD(0x00,0x00aa), BASE, ARG_NONE }, ++ { "call", MEM(0x01), BASE, { RA, CPRB, JMPHINT } }, ++ { "ret", MEM(0x02), BASE, { RA, CPRB, RETHINT } }, ++ { "ret", MEM_(0x02)| (31 << 21) | (26 << 16) | 1,0xFFFFFFFF, BASE, { 0 } }, /*pseudo*/ ++ { "jmp", MEM(0x03), BASE, { RA, CPRB, JMPHINT } }, ++ { "br", BRA(0x04), BASE, { ZA, BDISP } }, /* pseudo */ ++ { "br", BRA(0x04), BASE, ARG_BRA }, ++ { "bsr", BRA(0x05), BASE, ARG_BRA }, ++ { "memb", MFC(0x06,0x0000), BASE, ARG_NONE }, ++ { "imemb", MFC(0x06,0x0001), BASE, ARG_NONE }, ++ { "rtc", MFC(0x06,0x0020), BASE, { RA, ZB } }, ++ { "rtc", MFC(0x06,0x0020), BASE, { RA, RB } }, ++ { "rcid", MFC(0x06,0x0040), BASE, { RA , ZB} }, ++ { "halt", MFC(0x06,0x0080), BASE, { ZA, ZB } }, ++ { "rd_f", MFC(0x06,0x1000), BASE, { RA, ZB } }, ++ { "wr_f", MFC(0x06,0x1020), BASE, { RA, ZB } }, ++ { "rtid", MFC(0x06,0x1040), BASE, { RA } }, ++ { "pri_rcsr", CSR(0x06,0xFE), BASE, { RA, RPIINDEX ,ZB } }, ++ { "pri_wcsr", CSR(0x06,0xFF), BASE, { RA, RPIINDEX ,ZB } }, ++ { "pri_ret", PRIRET(0x07,0x0), BASE, { RA } }, ++ { "pri_ret/b", PRIRET(0x07,0x1), BASE, { RA } }, ++ { "lldw", ATMEM(0x08,0x0), BASE, ARG_ATMEM }, ++ { "lldl", ATMEM(0x08,0x1), BASE, ARG_ATMEM }, ++ { "ldw_inc", ATMEM(0x08,0x2), BASE, ARG_ATMEM }, ++ { "ldl_inc", ATMEM(0x08,0x3), BASE, ARG_ATMEM }, ++ { "ldw_dec", ATMEM(0x08,0x4), BASE, ARG_ATMEM }, ++ { "ldl_dec", ATMEM(0x08,0x5), BASE, ARG_ATMEM }, ++ { "ldw_set", ATMEM(0x08,0x6), BASE, ARG_ATMEM }, ++ { "ldl_set", ATMEM(0x08,0x7), BASE, ARG_ATMEM }, ++ { "lstw", ATMEM(0x08,0x8), BASE, ARG_ATMEM }, ++ { "lstl", ATMEM(0x08,0x9), BASE, ARG_ATMEM }, ++ { "ldw_nc", ATMEM(0x08,0xA), BASE, ARG_ATMEM }, ++ { "ldl_nc", ATMEM(0x08,0xB), BASE, ARG_ATMEM }, ++ { "ldd_nc", ATMEM(0x08,0xC), BASE, ARG_VUAMEM }, ++ { "stw_nc", ATMEM(0x08,0xD), BASE, ARG_ATMEM }, ++ { "stl_nc", ATMEM(0x08,0xE), BASE, ARG_ATMEM }, ++ { "std_nc", ATMEM(0x08,0xF), BASE, ARG_VUAMEM }, ++ { "fillcs", MEM(0x09), BASE, ARG_PREFETCH }, ++ { "ldwe", MEM(0x09), BASE, ARG_FMEM }, //sw6 v0.2a ++ { "e_fillcs", MEM(0x0A), BASE, ARG_PREFETCH }, ++ { "ldse", MEM(0x0A), BASE, ARG_FMEM }, ++ { "lds4e", MEM(0x0A), BASE, ARG_FMEM },/* pseudo BASE SIMD WCH20081028*/ ++ { "fillcs_e", MEM(0x0B), BASE, ARG_PREFETCH }, ++ { "ldde", MEM(0x0B), BASE, ARG_FMEM }, ++ { "ldd4e", MEM(0x0B), BASE, ARG_FMEM },/* pseudo BASE SIMD WCH20081028*/ ++ { "e_fillde", MEM(0x0C), BASE, ARG_PREFETCH }, ++ { "vlds", MEM(0x0C), BASE, ARG_FMEM }, ++ { "v4lds", MEM(0x0C), BASE, ARG_FMEM }, ++ { "vldd", MEM(0x0D), BASE, ARG_FMEM }, ++ { "v4ldd", MEM(0x0D), BASE, ARG_FMEM }, ++ { "vsts", MEM(0x0E), BASE, ARG_FMEM }, ++ { "v4sts", MEM(0x0E), BASE, ARG_FMEM }, ++ { "vstd", MEM(0x0F), BASE, ARG_FMEM }, ++ { "v4std", MEM(0x0F), BASE, ARG_FMEM }, ++ { "addw", OPR(0x10,0x00), BASE, ARG_OPR }, ++ { "addw", OPRL(0x12,0x00), BASE, ARG_OPRL }, ++ { "sextl", OPR(0x10,0x00), BASE, ARG_OPRZ1 }, /* pseudo */ ++ { "sextl", OPRL(0x12,0x00), BASE, ARG_OPRLZ1 }, /* pseudo */ ++ { "subw", OPR(0x10,0x01), BASE, ARG_OPR }, ++ { "subw", OPRL(0x12,0x01), BASE, ARG_OPRL }, ++ { "negw", OPR(0x10,0x01), BASE, ARG_OPRZ1 }, /* pseudo swgcc */ ++ { "negw", OPRL(0x12,0x01), BASE, ARG_OPRLZ1 }, /* pseudo swgcc */ ++ { "s4addw", OPR(0x10,0x02), BASE, ARG_OPR }, ++ { "s4addw", OPRL(0x12,0x02), BASE, ARG_OPRL }, ++ { "s4subw", OPR(0x10,0x03), BASE, ARG_OPR }, ++ { "s4subw", OPRL(0x12,0x03), BASE, ARG_OPRL }, ++ { "s8addw", OPR(0x10,0x04), BASE, ARG_OPR }, ++ { "s8addw", OPRL(0x12,0x04), BASE, ARG_OPRL }, ++ { "s8subw", OPR(0x10,0x05), BASE, ARG_OPR }, ++ { "s8subw", OPRL(0x12,0x05), BASE, ARG_OPRL }, ++ { "addl", OPR(0x10,0x08), BASE, ARG_OPR }, ++ { "addl", OPRL(0x12,0x08), BASE, ARG_OPRL }, ++ { "subl", OPR(0x10,0x09), BASE, ARG_OPR }, ++ { "subl", OPRL(0x12,0x09), BASE, ARG_OPRL }, ++ { "negl", OPR(0x10,0x09), BASE, ARG_OPRZ1 }, /* pseudo swgcc */ ++ { "negl", OPRL(0x12,0x09), BASE, ARG_OPRLZ1 }, /* pseudo swgcc */ ++ { "neglv", OPR(0x10,0x09), BASE, ARG_OPRZ1 }, /* pseudo swgcc */ ++ { "neglv", OPRL(0x12,0x09), BASE, ARG_OPRLZ1 }, /* pseudo swgcc */ ++ { "s4addl", OPR(0x10,0x0A), BASE, ARG_OPR }, ++ { "s4addl", OPRL(0x12,0x0A), BASE, ARG_OPRL }, ++ { "s4subl", OPR(0x10,0x0B), BASE, ARG_OPR }, ++ { "s4subl", OPRL(0x12,0x0B), BASE, ARG_OPRL }, ++ { "s8addl", OPR(0x10,0x0C), BASE, ARG_OPR }, ++ { "s8addl", OPRL(0x12,0x0C), BASE, ARG_OPRL }, ++ { "s8subl", OPR(0x10,0x0D), BASE, ARG_OPR }, ++ { "s8subl", OPRL(0x12,0x0D), BASE, ARG_OPRL }, ++ { "mulw", OPR(0x10,0x10), BASE, ARG_OPR }, ++ { "mulw", OPRL(0x12,0x10), BASE, ARG_OPRL }, ++ { "divw", OPR(0x10,0x11), BASE, ARG_OPR }, ++ { "udivw", OPR(0x10,0x12), BASE, ARG_OPR }, ++ { "remw", OPR(0x10,0x13), BASE, ARG_OPR }, ++ { "uremw", OPR(0x10,0x14), BASE, ARG_OPR }, ++ { "mull", OPR(0x10,0x18), BASE, ARG_OPR }, ++ { "mull", OPRL(0x12,0x18), BASE, ARG_OPRL }, ++ { "umulh", OPR(0x10,0x19), BASE, ARG_OPR }, ++ { "umulh", OPRL(0x12,0x19), BASE, ARG_OPRL }, ++ { "cmpeq", OPR(0x10,0x28), BASE, ARG_OPR }, ++ { "cmpeq", OPRL(0x12,0x28), BASE, ARG_OPRL }, ++ { "cmplt", OPR(0x10,0x29), BASE, ARG_OPR }, ++ { "cmplt", OPRL(0x12,0x29), BASE, ARG_OPRL }, ++ { "cmple", OPR(0x10,0x2A), BASE, ARG_OPR }, ++ { "cmple", OPRL(0x12,0x2A), BASE, ARG_OPRL }, ++ { "cmpult", OPR(0x10,0x2B), BASE, ARG_OPR }, ++ { "cmpult", OPRL(0x12,0x2B), BASE, ARG_OPRL }, ++ { "cmpule", OPR(0x10,0x2C), BASE, ARG_OPR }, ++ { "cmpule", OPRL(0x12,0x2C), BASE, ARG_OPRL }, ++ { "and", OPR(0x10,0x38), BASE, ARG_OPR }, ++ { "and", OPRL(0x12,0x38),BASE, ARG_OPRL }, ++ { "bic", OPR(0x10,0x39), BASE, ARG_OPR }, ++ { "bic", OPRL(0x12,0x39),BASE, ARG_OPRL }, ++ { "andnot", OPR(0x10,0x39), BASE, ARG_OPR },/* pseudo */ ++ { "andnot", OPRL(0x12,0x39),BASE, ARG_OPRL },/* pseudo */ ++ { "nop", OPR(0x10,0x3A), BASE, { ZA, ZB, ZC } }, /* now unop has a new expression */ ++ { "excb", OPR(0x10,0x3A), BASE, { ZA, ZB, ZC } }, /* pseudo */ ++ { "clr", OPR(0x10,0x3A),BASE, { ZA, ZB, RC } }, /* pseudo swgcc */ ++ { "mov", OPR(0x10,0x3A), BASE, { ZA, RB, RC } }, /* pseudo */ ++ { "mov", OPRL(0x12,0x3A),BASE, { ZA, LIT, RC } }, /* pseudo */ ++ { "implver", OPRL_(0x12,0x3A)|2<<13,0xFFFFFFE0,BASE, {ZA,RC } }, /* pseudo swgcc */ ++ { "amask", OPR_(0x10,0x3A)|31<<16,OPR_MASK, BASE, { ZA, RB, RC } }, /* pseudo */ ++ { "amask", OPRL(0x12,0x3A), BASE, { ZA, LIT, RC } }, /* pseudo */ ++ { "or", OPR(0x10,0x3A), BASE, ARG_OPR }, ++ { "or", OPRL(0x12,0x3A),BASE, ARG_OPRL }, ++ { "bis", OPR(0x10,0x3A), BASE, ARG_OPR }, ++ { "bis", OPRL(0x12,0x3A),BASE, ARG_OPRL }, ++ { "not", OPR(0x10,0x3B), BASE, ARG_OPRZ1 }, /* pseudo swgcc */ ++ { "not", OPRL(0x12,0x3B),BASE, ARG_OPRLZ1 }, /* pseudo swgcc */ ++ { "ornot", OPR(0x10,0x3B), BASE, ARG_OPR }, ++ { "ornot", OPRL(0x12,0x3B),BASE, ARG_OPRL }, ++ { "xor", OPR(0x10,0x3C), BASE, ARG_OPR }, ++ { "xor", OPRL(0x12,0x3C),BASE, ARG_OPRL }, ++ { "eqv", OPR(0x10,0x3D), BASE, ARG_OPR }, ++ { "eqv", OPRL(0x12,0x3D),BASE, ARG_OPRL }, ++ { "xornot", OPR(0x10,0x3D), BASE, ARG_OPR }, /* pseudo swgcc */ ++ { "xornot", OPRL(0x12,0x3D),BASE, ARG_OPRL },/* pseudo swgcc */ ++ { "inslb", OPR(0x10,0x40), BASE, ARG_OPR }, ++ { "inslb", OPRL(0x12,0x40),BASE, ARG_OPRL }, ++ { "ins0b", OPR(0x10,0x40), BASE, ARG_OPR }, ++ { "ins0b", OPRL(0x12,0x40),BASE, ARG_OPRL }, ++ { "inslh", OPR(0x10,0x41), BASE, ARG_OPR }, ++ { "inslh", OPRL(0x12,0x41),BASE, ARG_OPRL }, ++ { "ins1b", OPR(0x10,0x41), BASE, ARG_OPR }, ++ { "ins1b", OPRL(0x12,0x41),BASE, ARG_OPRL }, ++ { "inslw", OPR(0x10,0x42), BASE, ARG_OPR }, ++ { "inslw", OPRL(0x12,0x42),BASE, ARG_OPRL }, ++ { "ins2b", OPR(0x10,0x42), BASE, ARG_OPR }, ++ { "ins2b", OPRL(0x12,0x42),BASE, ARG_OPRL }, ++ { "insll", OPR(0x10,0x43), BASE, ARG_OPR }, ++ { "insll", OPRL(0x12,0x43),BASE, ARG_OPRL }, ++ { "ins3b", OPR(0x10,0x43), BASE, ARG_OPR }, ++ { "ins3b", OPRL(0x12,0x43),BASE, ARG_OPRL }, ++ { "inshb", OPR(0x10,0x44), BASE, ARG_OPR }, ++ { "inshb", OPRL(0x12,0x44),BASE, ARG_OPRL }, ++ { "ins4b", OPR(0x10,0x44), BASE, ARG_OPR }, ++ { "ins4b", OPRL(0x12,0x44),BASE, ARG_OPRL }, ++ { "inshh", OPR(0x10,0x45), BASE, ARG_OPR }, ++ { "inshh", OPRL(0x12,0x45),BASE, ARG_OPRL }, ++ { "ins5b", OPR(0x10,0x45), BASE, ARG_OPR }, ++ { "ins5b", OPRL(0x12,0x45),BASE, ARG_OPRL }, ++ { "inshw", OPR(0x10,0x46), BASE, ARG_OPR }, ++ { "inshw", OPRL(0x12,0x46),BASE, ARG_OPRL }, ++ { "ins6b", OPR(0x10,0x46), BASE, ARG_OPR }, ++ { "ins6b", OPRL(0x12,0x46),BASE, ARG_OPRL }, ++ { "inshl", OPR(0x10,0x47), BASE, ARG_OPR }, ++ { "inshl", OPRL(0x12,0x47),BASE, ARG_OPRL }, ++ { "ins7b", OPR(0x10,0x47), BASE, ARG_OPR }, ++ { "ins7b", OPRL(0x12,0x47),BASE, ARG_OPRL }, ++ { "sll", OPR(0x10,0x48), BASE, ARG_OPR }, ++ { "sll", OPRL(0x12,0x48),BASE, ARG_OPRL }, ++ { "srl", OPR(0x10,0x49), BASE, ARG_OPR }, ++ { "srl", OPRL(0x12,0x49),BASE, ARG_OPRL }, ++ { "sra", OPR(0x10,0x4A), BASE, ARG_OPR }, ++ { "sra", OPRL(0x12,0x4A),BASE, ARG_OPRL }, ++ { "sllw2", OPR(0x10,0x4C), BASE, ARG_OPR }, //sw6 v0.2a ++ { "sllw2", OPRL(0x12,0x4C),BASE, ARG_OPRL },//sw6 v0.2a ++ { "srlw2", OPR(0x10,0x4D), BASE, ARG_OPR }, //sw6 v0.2a ++ { "srlw2", OPRL(0x12,0x4D),BASE, ARG_OPRL },//sw6 v0.2a ++ { "sraw2", OPR(0x10,0x4E), BASE, ARG_OPR }, //sw6 v0.2a ++ { "sraw2", OPRL(0x12,0x4E),BASE, ARG_OPRL },//sw6 v0.2a ++ { "extlb", OPR(0x10,0x50), BASE, ARG_OPR }, ++ { "extlb", OPRL(0x12,0x50),BASE, ARG_OPRL }, ++ { "ext0b", OPR(0x10,0x50), BASE, ARG_OPR }, ++ { "ext0b", OPRL(0x12,0x50),BASE, ARG_OPRL }, ++ { "extlh", OPR(0x10,0x51), BASE, ARG_OPR }, ++ { "extlh", OPRL(0x12,0x51),BASE, ARG_OPRL }, ++ { "ext1b", OPR(0x10,0x51), BASE, ARG_OPR }, ++ { "ext1b", OPRL(0x12,0x51),BASE, ARG_OPRL }, ++ { "extlw", OPR(0x10,0x52), BASE, ARG_OPR }, ++ { "extlw", OPRL(0x12,0x52),BASE, ARG_OPRL }, ++ { "ext2b", OPR(0x10,0x52), BASE, ARG_OPR }, ++ { "ext2b", OPRL(0x12,0x52),BASE, ARG_OPRL }, ++ { "extll", OPR(0x10,0x53), BASE, ARG_OPR }, ++ { "extll", OPRL(0x12,0x53),BASE, ARG_OPRL }, ++ { "ext3b", OPR(0x10,0x53), BASE, ARG_OPR }, ++ { "ext3b", OPRL(0x12,0x53),BASE, ARG_OPRL }, ++ { "exthb", OPR(0x10,0x54), BASE, ARG_OPR }, ++ { "exthb", OPRL(0x12,0x54),BASE, ARG_OPRL }, ++ { "ext4b", OPR(0x10,0x54), BASE, ARG_OPR }, ++ { "ext4b", OPRL(0x12,0x54),BASE, ARG_OPRL }, ++ { "exthh", OPR(0x10,0x55), BASE, ARG_OPR }, ++ { "exthh", OPRL(0x12,0x55),BASE, ARG_OPRL }, ++ { "ext5b", OPR(0x10,0x55), BASE, ARG_OPR }, ++ { "ext5b", OPRL(0x12,0x55),BASE, ARG_OPRL }, ++ { "exthw", OPR(0x10,0x56), BASE, ARG_OPR }, ++ { "exthw", OPRL(0x12,0x56),BASE, ARG_OPRL }, ++ { "ext6b", OPR(0x10,0x56), BASE, ARG_OPR }, ++ { "ext6b", OPRL(0x12,0x56),BASE, ARG_OPRL }, ++ { "exthl", OPR(0x10,0x57), BASE, ARG_OPR }, ++ { "exthl", OPRL(0x12,0x57),BASE, ARG_OPRL }, ++ { "ext7b", OPR(0x10,0x57), BASE, ARG_OPR }, ++ { "ext7b", OPRL(0x12,0x57),BASE, ARG_OPRL }, ++ { "ctpop", OPR(0x10,0x58), BASE, ARG_OPRZ1 }, ++ { "ctlz", OPR(0x10,0x59), BASE, ARG_OPRZ1 }, ++ { "cttz", OPR(0x10,0x5A), BASE, ARG_OPRZ1 }, ++ { "masklb", OPR(0x10,0x60), BASE, ARG_OPR }, ++ { "masklb", OPRL(0x12,0x60),BASE, ARG_OPRL }, ++ { "mask0b", OPR(0x10,0x60), BASE, ARG_OPR }, ++ { "mask0b", OPRL(0x12,0x60),BASE, ARG_OPRL }, ++ { "masklh", OPR(0x10,0x61), BASE, ARG_OPR }, ++ { "masklh", OPRL(0x12,0x61),BASE, ARG_OPRL }, ++ { "mask1b", OPR(0x10,0x61), BASE, ARG_OPR }, ++ { "mask1b", OPRL(0x12,0x61),BASE, ARG_OPRL }, ++ { "masklw", OPR(0x10,0x62), BASE, ARG_OPR }, ++ { "masklw", OPRL(0x12,0x62),BASE, ARG_OPRL }, ++ { "mask2b", OPR(0x10,0x62), BASE, ARG_OPR }, ++ { "mask2b", OPRL(0x12,0x62),BASE, ARG_OPRL }, ++ { "maskll", OPR(0x10,0x63), BASE, ARG_OPR }, ++ { "maskll", OPRL(0x12,0x63),BASE, ARG_OPRL }, ++ { "mask3b", OPR(0x10,0x63), BASE, ARG_OPR }, ++ { "mask3b", OPRL(0x12,0x63),BASE, ARG_OPRL }, ++ { "maskhb", OPR(0x10,0x64), BASE, ARG_OPR }, ++ { "maskhb", OPRL(0x12,0x64),BASE, ARG_OPRL }, ++ { "mask4b", OPR(0x10,0x64), BASE, ARG_OPR }, ++ { "mask4b", OPRL(0x12,0x64),BASE, ARG_OPRL }, ++ { "maskhh", OPR(0x10,0x65), BASE, ARG_OPR }, ++ { "maskhh", OPRL(0x12,0x65),BASE, ARG_OPRL }, ++ { "mask5b", OPR(0x10,0x65), BASE, ARG_OPR }, ++ { "mask5b", OPRL(0x12,0x65),BASE, ARG_OPRL }, ++ { "maskhw", OPR(0x10,0x66), BASE, ARG_OPR }, ++ { "maskhw", OPRL(0x12,0x66),BASE, ARG_OPRL }, ++ { "mask6b", OPR(0x10,0x66), BASE, ARG_OPR }, ++ { "mask6b", OPRL(0x12,0x66),BASE, ARG_OPRL }, ++ { "maskhl", OPR(0x10,0x67), BASE, ARG_OPR }, ++ { "maskhl", OPRL(0x12,0x67),BASE, ARG_OPRL }, ++ { "mask7b", OPR(0x10,0x67), BASE, ARG_OPR }, ++ { "mask7b", OPRL(0x12,0x67),BASE, ARG_OPRL }, ++ { "zap", OPR(0x10,0x68), BASE, ARG_OPR }, ++ { "zap", OPRL(0x12,0x68),BASE, ARG_OPRL }, ++ { "zapnot", OPR(0x10,0x69), BASE, ARG_OPR }, ++ { "zapnot", OPRL(0x12,0x69),BASE, ARG_OPRL }, ++ { "sextb", OPR(0x10,0x6A), BASE, ARG_OPRZ1}, ++ { "sextb", OPRL(0x12,0x6A),BASE, ARG_OPRLZ1 }, ++ { "sexth", OPR(0x10,0x6B), BASE, ARG_OPRZ1 }, ++ { "sexth", OPRL(0x12,0x6B),BASE, ARG_OPRLZ1 }, ++ { "cmpgeb", OPR(0x10,0x6C), BASE, ARG_OPR }, ++ { "cmpgeb", OPRL(0x12,0x6C),BASE, ARG_OPRL }, ++ { "fimovs", OPR(0x10,0x70), BASE, { FA, ZB, RC } }, ++ { "fimovd", OPR(0x10,0x78), BASE, { FA, ZB, RC } }, ++ { "ftoid", OPR(0x10,0x78), BASE, { FA, ZB, RC } }, ++ { "seleq", TOPR(0x11,0x0), BASE, ARG_TOPR }, ++ { "seleq", TOPRL(0x13,0x0),BASE, ARG_TOPRL }, ++ { "selge", TOPR(0x11,0x1), BASE, ARG_TOPR }, ++ { "selge", TOPRL(0x13,0x1),BASE, ARG_TOPRL }, ++ { "selgt", TOPR(0x11,0x2), BASE, ARG_TOPR }, ++ { "selgt", TOPRL(0x13,0x2),BASE, ARG_TOPRL }, ++ { "selle", TOPR(0x11,0x3), BASE, ARG_TOPR }, ++ { "selle", TOPRL(0x13,0x3),BASE, ARG_TOPRL }, ++ { "sellt", TOPR(0x11,0x4), BASE, ARG_TOPR }, ++ { "sellt", TOPRL(0x13,0x4),BASE, ARG_TOPRL }, ++ { "selne", TOPR(0x11,0x5), BASE, ARG_TOPR }, ++ { "selne", TOPRL(0x13,0x5),BASE, ARG_TOPRL }, ++ { "sellbc", TOPR(0x11,0x6), BASE, ARG_TOPR }, ++ { "sellbc", TOPRL(0x13,0x6),BASE, ARG_TOPRL }, ++ { "sellbs", TOPR(0x11,0x7), BASE, ARG_TOPR }, ++ { "sellbs", TOPRL(0x13,0x7),BASE, ARG_TOPRL }, ++ { "vlog", LOGX(0x14,0x00), BASE, ARG_FMA }, ++ ++ { "vbicw", PSE_LOGX(0x14,0x30), BASE, { FA , FB , DFC1 } }, ++ { "vxorw", PSE_LOGX(0x14,0x3c), BASE, { FA , FB , DFC1 } }, ++ { "vandw", PSE_LOGX(0x14,0xc0), BASE, { FA , FB , DFC1 } }, ++ { "veqvw", PSE_LOGX(0x14,0xc3), BASE, { FA , FB , DFC1 } }, ++ { "vornotw", PSE_LOGX(0x14,0xf3), BASE, { FA , FB , DFC1 } }, ++ { "vbisw", PSE_LOGX(0x14,0xfc), BASE, { FA , FB , DFC1 } }, ++ ++ { "fadds", FP(0x18,0x00), BASE, ARG_FP }, ++ { "faddd", FP(0x18,0x01), BASE, ARG_FP }, ++ { "fsubs", FP(0x18,0x02), BASE, ARG_FP }, ++ { "fsubd", FP(0x18,0x03), BASE, ARG_FP }, ++ { "fmuls", FP(0x18,0x04), BASE, ARG_FP }, ++ { "fmuld", FP(0x18,0x05), BASE, ARG_FP }, ++ { "fdivs", FP(0x18,0x06), BASE, ARG_FP }, ++ { "fdivd", FP(0x18,0x07), BASE, ARG_FP }, ++ { "fsqrts", FP(0x18,0x08), BASE, ARG_FPZ1 }, ++ { "fsqrtd", FP(0x18,0x09), BASE, ARG_FPZ1 }, ++ { "fcmpeq", FP(0x18,0x10), BASE, ARG_FP }, ++ { "fcmple", FP(0x18,0x11), BASE, ARG_FP }, ++ { "fcmplt", FP(0x18,0x12), BASE, ARG_FP }, ++ { "fcmpun", FP(0x18,0x13), BASE, ARG_FP }, ++ ++ { "fcvtsd", FP(0x18,0x20), BASE, ARG_FPZ1 }, ++ { "fcvtds", FP(0x18,0x21), BASE, ARG_FPZ1 }, ++ { "fcvtdl_g", FP(0x18,0x22), BASE, ARG_FPZ1 }, ++ { "fcvtdl_p", FP(0x18,0x23), BASE, ARG_FPZ1 }, ++ { "fcvtdl_z", FP(0x18,0x24), BASE, ARG_FPZ1 }, ++ { "fcvtdl_n", FP(0x18,0x25), BASE, ARG_FPZ1 }, ++ { "fcvtdl", FP(0x18,0x27), BASE, ARG_FPZ1 }, ++ { "fcvtwl", FP(0x18,0x28), BASE, ARG_FPZ1 }, ++ { "fcvtlw", FP(0x18,0x29), BASE, ARG_FPZ1 }, ++ { "fcvtls", FP(0x18,0x2d), BASE, ARG_FPZ1 }, ++ { "fcvtld", FP(0x18,0x2f), BASE, ARG_FPZ1 }, ++ ++ { "fnop", FP(0x18,0x030), BASE, { ZA, ZB, ZC } }, ++ { "fclr", FP(0x18,0x030), BASE, { ZA, ZB, FC } }, ++ { "fabs", FP(0x18,0x030), BASE, ARG_FPZ1 }, ++ { "fcpys", FP(0x18,0x30), BASE, ARG_FP }, ++ { "fmov", FP(0x18,0x30), BASE, { FA, RBA, FC } }, ++ { "fcpyse", FP(0x18,0x31), BASE, ARG_FP }, ++ { "fneg", FP(0x18,0x32), BASE, { FA, RBA, FC } }, ++ { "fcpysn", FP(0x18,0x32), BASE, ARG_FP }, ++ ++ { "ifmovs", FP(0x18,0x40), BASE, { RA, ZB, FC } }, ++ { "ifmovd", FP(0x18,0x41), BASE, { RA, ZB, FC } }, ++ { "itofd", FP(0x18,0x41), BASE, { RA, ZB, FC } }, ++ ++ { "rfpcr", FP(0x18,0x50), BASE, { FA, RBA, RCA } }, ++ { "wfpcr", FP(0x18,0x51), BASE, { FA, RBA, RCA } }, ++ { "setfpec0", FP(0x18,0x54), BASE, ARG_NONE }, ++ { "setfpec1", FP(0x18,0x55), BASE, ARG_NONE }, ++ { "setfpec2", FP(0x18,0x56), BASE, ARG_NONE }, ++ { "setfpec3", FP(0x18,0x57), BASE, ARG_NONE }, ++ { "fmas", FMA(0x19,0x00), BASE, ARG_FMA }, ++ { "fmad", FMA(0x19,0x01), BASE, ARG_FMA }, ++ { "fmss", FMA(0x19,0x02), BASE, ARG_FMA }, ++ { "fmsd", FMA(0x19,0x03), BASE, ARG_FMA }, ++ { "fnmas", FMA(0x19,0x04), BASE, ARG_FMA }, ++ { "fnmad", FMA(0x19,0x05), BASE, ARG_FMA }, ++ { "fnmss", FMA(0x19,0x06), BASE, ARG_FMA }, ++ { "fnmsd", FMA(0x19,0x07), BASE, ARG_FMA }, ++ ++//fcmov*(BASE) to fcmov*(BASE) for fcmov* no need in sw64, and fsel*->fcmov* has difference in operands number,so it should not repalce directly. The default FD should be the same FC but not FA ++ { "fseleq", FMA(0x19,0x10), BASE, ARG_FCMOV }, ++ { "fselne", FMA(0x19,0x11), BASE, ARG_FCMOV }, ++ { "fsellt", FMA(0x19,0x12), BASE, ARG_FCMOV }, ++ { "fselle", FMA(0x19,0x13), BASE, ARG_FCMOV }, ++ { "fselgt", FMA(0x19,0x14), BASE, ARG_FCMOV }, ++ { "fselge", FMA(0x19,0x15), BASE, ARG_FCMOV }, ++ ++ { "vaddw", FP(0x1A,0x00), BASE, ARG_FP }, ++ { "vaddw", FP(0x1A,0x20), BASE, ARG_FPL }, ++ { "vsubw", FP(0x1A,0x01), BASE, ARG_FP }, ++ { "vsubw", FP(0x1A,0x21), BASE, ARG_FPL }, ++ { "vcmpgew", FP(0x1A,0x02), BASE, ARG_FP }, ++ { "vcmpgew", FP(0x1A,0x22), BASE, ARG_FPL }, ++ { "vcmpeqw", FP(0x1A,0x03), BASE, ARG_FP }, ++ { "vcmpeqw", FP(0x1A,0x23), BASE, ARG_FPL }, ++ { "vcmplew", FP(0x1A,0x04), BASE, ARG_FP }, ++ { "vcmplew", FP(0x1A,0x24), BASE, ARG_FPL }, ++ { "vcmpltw", FP(0x1A,0x05), BASE, ARG_FP }, ++ { "vcmpltw", FP(0x1A,0x25), BASE, ARG_FPL }, ++ { "vcmpulew", FP(0x1A,0x06), BASE, ARG_FP }, ++ { "vcmpulew", FP(0x1A,0x26), BASE, ARG_FPL }, ++ { "vcmpultw", FP(0x1A,0x07), BASE, ARG_FP }, ++ { "vcmpultw", FP(0x1A,0x27), BASE, ARG_FPL }, ++ ++ { "vsllw", FP(0x1A,0x08), BASE, ARG_FP }, ++ { "vsllw", FP(0x1A,0x28), BASE, ARG_FPL }, ++ { "vsrlw", FP(0x1A,0x09), BASE, ARG_FP }, ++ { "vsrlw", FP(0x1A,0x29), BASE, ARG_FPL }, ++ { "vsraw", FP(0x1A,0x0A), BASE, ARG_FP }, ++ { "vsraw", FP(0x1A,0x2A), BASE, ARG_FPL }, ++ { "vrolw", FP(0x1A,0x0B), BASE, ARG_FP }, ++ { "vrolw", FP(0x1A,0x2B), BASE, ARG_FPL }, ++ { "sllow", FP(0x1A,0x0C), BASE, ARG_FP }, ++ { "sllow", FP(0x1A,0x2C), BASE, ARG_FPL }, ++ { "srlow", FP(0x1A,0x0D), BASE, ARG_FP }, ++ { "srlow", FP(0x1A,0x2D), BASE, ARG_FPL }, ++ { "vaddl", FP(0x1A,0x0E), BASE, ARG_FP }, ++ { "vaddl", FP(0x1A,0x2E), BASE, ARG_FPL }, ++ { "vsubl", FP(0x1A,0x0F), BASE, ARG_FP }, ++ { "vsubl", FP(0x1A,0x2F), BASE, ARG_FPL }, ++ { "ctpopow", FP(0x1A,0x18), BASE, { FA, ZB, DFC1 } }, ++ { "ctlzow", FP(0x1A,0x19), BASE, { FA, ZB, DFC1 } }, ++ { "vucaddw", FP(0x1A,0x40), BASE, ARG_FP }, ++ { "vucaddw", FP(0x1A,0x60), BASE, ARG_FPL }, ++ { "vucsubw", FP(0x1A,0x41), BASE, ARG_FP }, ++ { "vucsubw", FP(0x1A,0x61), BASE, ARG_FPL }, ++ { "vucaddh", FP(0x1A,0x42), BASE, ARG_FP }, ++ { "vucaddh", FP(0x1A,0x62), BASE, ARG_FPL }, ++ { "vucsubh", FP(0x1A,0x43), BASE, ARG_FP }, ++ { "vucsubh", FP(0x1A,0x63), BASE, ARG_FPL }, ++ { "vucaddb", FP(0x1A,0x44), BASE, ARG_FP }, ++ { "vucaddb", FP(0x1A,0x64), BASE, ARG_FPL }, ++ { "vucsubb", FP(0x1A,0x45), BASE, ARG_FP }, ++ { "vucsubb", FP(0x1A,0x65), BASE, ARG_FPL }, ++ { "vadds", FP(0x1A,0x80), BASE, ARG_FP }, ++ { "v4adds", FP(0x1A,0x80), BASE, ARG_FP },/* pseudo SW6 SIMD*/ ++ { "vaddd", FP(0x1A,0x81), BASE, ARG_FP }, ++ { "v4addd", FP(0x1A,0x81), BASE, ARG_FP },/* pseudo SW6 SIMD*/ ++ { "vsubs", FP(0x1A,0x82), BASE, ARG_FP }, ++ { "v4subs", FP(0x1A,0x82), BASE, ARG_FP },/* pseudo SW6 SIMD*/ ++ { "vsubd", FP(0x1A,0x83), BASE, ARG_FP }, ++ { "v4subd", FP(0x1A,0x83), BASE, ARG_FP },/* pseudo SW6 SIMD*/ ++ { "vmuls", FP(0x1A,0x84), BASE, ARG_FP }, ++ { "v4muls", FP(0x1A,0x84), BASE, ARG_FP },/* pseudo SW6 SIMD*/ ++ { "vmuld", FP(0x1A,0x85), BASE, ARG_FP }, ++ { "v4muld", FP(0x1A,0x85), BASE, ARG_FP },/* pseudo SW6 SIMD*/ ++ { "vdivs", FP(0x1A,0x86), BASE, ARG_FP }, ++ { "vdivd", FP(0x1A,0x87), BASE, ARG_FP }, ++ { "vsqrts", FP(0x1A,0x88), BASE, ARG_FPZ1 }, ++ { "vsqrtd", FP(0x1A,0x89), BASE, ARG_FPZ1 }, ++ { "vfcmpeq", FP(0x1A,0x8C), BASE, ARG_FP }, ++ { "vfcmple", FP(0x1A,0x8D), BASE, ARG_FP }, ++ { "vfcmplt", FP(0x1A,0x8E), BASE, ARG_FP }, ++ { "vfcmpun", FP(0x1A,0x8F), BASE, ARG_FP }, ++ { "vcpys", FP(0x1A,0x90), BASE, ARG_FP }, ++ { "vfmov", FP(0x1A,0x90), BASE, { FA, RBA, FC } }, //V1.1 ++ { "vcpyse", FP(0x1A,0x91), BASE, ARG_FP }, // SW6 1.0 ++ { "vcpysn", FP(0x1A,0x92), BASE, ARG_FP }, // SW6 1.0 ++ { "vmas", FMA(0x1B,0x00), BASE, ARG_FMA }, ++ { "vmad", FMA(0x1B,0x01), BASE, ARG_FMA }, ++ { "vmss", FMA(0x1B,0x02), BASE, ARG_FMA }, ++ { "vmsd", FMA(0x1B,0x03), BASE, ARG_FMA }, ++ { "vnmas", FMA(0x1B,0x04), BASE, ARG_FMA }, ++ { "vnmad", FMA(0x1B,0x05), BASE, ARG_FMA }, ++ { "vnmss", FMA(0x1B,0x06), BASE, ARG_FMA }, ++ { "vnmsd", FMA(0x1B,0x07), BASE, ARG_FMA }, ++ { "vfseleq", FMA(0x1B,0x10), BASE, ARG_FMA }, ++ { "vfsellt", FMA(0x1B,0x12), BASE, ARG_FMA }, ++ { "vfselle", FMA(0x1B,0x13), BASE, ARG_FMA }, ++ { "vseleqw", FMA(0x1B,0x18), BASE, ARG_FMA }, ++ { "vseleqw", FMA(0x1B,0x38), BASE, ARG_FMAL }, ++ { "vsellbcw", FMA(0x1B,0x19), BASE, ARG_FMA }, ++ { "vsellbcw", FMA(0x1B,0x39), BASE, ARG_FMAL }, ++ { "vselltw", FMA(0x1B,0x1A), BASE, ARG_FMA }, ++ { "vselltw", FMA(0x1B,0x3A), BASE, ARG_FMAL }, ++ { "vsellew", FMA(0x1B,0x1B), BASE, ARG_FMA }, ++ { "vsellew", FMA(0x1B,0x3B), BASE, ARG_FMAL }, ++ { "vinsw", FMA(0x1B,0x20), BASE, ARG_FMAL }, ++ { "vinsf", FMA(0x1B,0x21), BASE, ARG_FMAL }, ++ { "vextw", FMA(0x1B,0x22), BASE, { FA, FMALIT, DFC1 }}, ++ { "vextf", FMA(0x1B,0x23), BASE, { FA, FMALIT, DFC1 }}, ++ { "vcpyw", FMA(0x1B,0x24), BASE, { FA, DFC1 }}, ++ { "vcpyf", FMA(0x1B,0x25), BASE, { FA, DFC1 }}, ++ { "vconw", FMA(0x1B,0x26), BASE, ARG_FMA }, ++ { "vshfw", FMA(0x1B,0x27), BASE, ARG_FMA }, ++ { "vcons", FMA(0x1B,0x28), BASE, ARG_FMA }, ++ { "vcond", FMA(0x1B,0x29), BASE, ARG_FMA }, ++ { "vldw_u", ATMEM(0x1C,0x0), BASE, ARG_VUAMEM }, ++ { "vstw_u", ATMEM(0x1C,0x1), BASE, ARG_VUAMEM }, ++ { "vlds_u", ATMEM(0x1C,0x2), BASE, ARG_VUAMEM }, ++ { "vsts_u", ATMEM(0x1C,0x3), BASE, ARG_VUAMEM }, ++ { "vldd_u", ATMEM(0x1C,0x4), BASE, ARG_VUAMEM }, ++ { "vstd_u", ATMEM(0x1C,0x5), BASE, ARG_VUAMEM }, ++ { "vstw_ul", ATMEM(0x1C,0x8), BASE, ARG_VUAMEM }, ++ { "vstw_uh", ATMEM(0x1C,0x9), BASE, ARG_VUAMEM }, ++ { "vsts_ul", ATMEM(0x1C,0xA), BASE, ARG_VUAMEM }, ++ { "vsts_uh", ATMEM(0x1C,0xB), BASE, ARG_VUAMEM }, ++ { "vstd_ul", ATMEM(0x1C,0xC), BASE, ARG_VUAMEM }, ++ { "vstd_uh", ATMEM(0x1C,0xD), BASE, ARG_VUAMEM }, ++ { "vldd_nc", ATMEM(0x1C,0xE), BASE, ARG_VUAMEM }, ++ { "vstd_nc", ATMEM(0x1C,0xF), BASE, ARG_VUAMEM }, ++ { "flushd", MEM(0x20), BASE, ARG_PREFETCH }, ++ { "ldbu", MEM(0x20), BASE, ARG_MEM }, ++ { "evictdg", MEM(0x21), BASE, ARG_PREFETCH }, ++ { "ldhu", MEM(0x21), BASE, ARG_MEM }, ++ { "s_fillcs", MEM(0x22), BASE, ARG_PREFETCH }, ++ { "ldw", MEM(0x22), BASE, ARG_MEM }, ++ { "wh64", MFC(0x22,0xF800), BASE, { ZA, PRB } }, ++ { "s_fillde", MEM(0x23), BASE, ARG_PREFETCH }, ++ { "ldl", MEM(0x23), BASE, ARG_MEM }, ++ { "evictdl", MEM(0x24), BASE, ARG_PREFETCH }, ++ { "ldl_u", MEM(0x24), BASE, ARG_MEM }, ++ { "pri_ldw/p", SW6HWMEM(0x25,0x0), BASE, ARG_SW6HWMEM }, ++ { "pri_ldw_inc/p", SW6HWMEM(0x25,0x2), BASE, ARG_SW6HWMEM }, ++ { "pri_ldw_dec/p", SW6HWMEM(0x25,0x4), BASE, ARG_SW6HWMEM }, ++ { "pri_ldw_set/p", SW6HWMEM(0x25,0x6), BASE, ARG_SW6HWMEM }, ++ { "pri_ldw/v", SW6HWMEM(0x25,0x8), BASE, ARG_SW6HWMEM }, ++ { "pri_ldw/vpte", SW6HWMEM(0x25,0xA), BASE, ARG_SW6HWMEM }, ++ { "pri_ldl/p", SW6HWMEM(0x25,0x1), BASE, ARG_SW6HWMEM }, ++ { "pri_ldl_inc/p", SW6HWMEM(0x25,0x3), BASE, ARG_SW6HWMEM }, ++ { "pri_ldl_dec/p", SW6HWMEM(0x25,0x5), BASE, ARG_SW6HWMEM }, ++ { "pri_ldl_set/p", SW6HWMEM(0x25,0x7), BASE, ARG_SW6HWMEM }, ++ { "pri_ldl/v", SW6HWMEM(0x25,0x9), BASE, ARG_SW6HWMEM }, ++ { "pri_ldl/vpte", SW6HWMEM(0x25,0xB), BASE, ARG_SW6HWMEM }, ++ { "fillde", MEM(0x26), BASE, ARG_PREFETCH }, ++ { "flds", MEM(0x26), BASE, ARG_FMEM }, ++ { "fillde_e", MEM(0x27), BASE, ARG_PREFETCH }, ++ { "fldd", MEM(0x27), BASE, ARG_FMEM }, ++ ++ { "stb", MEM(0x28), BASE, ARG_MEM }, ++ { "sth", MEM(0x29), BASE, ARG_MEM }, ++ { "stw", MEM(0x2A), BASE, ARG_MEM }, ++ { "stl", MEM(0x2B), BASE, ARG_MEM }, ++ { "stl_u", MEM(0x2C), BASE, ARG_MEM }, ++ { "pri_stw/p", SW6HWMEM(0x2D,0x0), BASE, ARG_SW6HWMEM }, ++ { "pri_stw/v", SW6HWMEM(0x2D,0x8), BASE, ARG_SW6HWMEM }, ++ { "pri_stl/p", SW6HWMEM(0x2D,0x1), BASE, ARG_SW6HWMEM }, ++ { "pri_stl/v", SW6HWMEM(0x2D,0x9), BASE, ARG_SW6HWMEM }, ++ { "fsts", MEM(0x2E), BASE, ARG_FMEM }, ++ { "fstd", MEM(0x2F), BASE, ARG_FMEM }, ++ { "beq", BRA(0x30), BASE, ARG_BRA }, ++ { "bne", BRA(0x31), BASE, ARG_BRA }, ++ { "blt", BRA(0x32), BASE, ARG_BRA }, ++ { "ble", BRA(0x33), BASE, ARG_BRA }, ++ { "bgt", BRA(0x34), BASE, ARG_BRA }, ++ { "bge", BRA(0x35), BASE, ARG_BRA }, ++ { "blbc", BRA(0x36), BASE, ARG_BRA }, ++ { "blbs", BRA(0x37), BASE, ARG_BRA }, ++ ++ { "fbeq", BRA(0x38), BASE, ARG_FBRA }, ++ { "fbne", BRA(0x39), BASE, ARG_FBRA }, ++ { "fblt", BRA(0x3A), BASE, ARG_FBRA }, ++ { "fble", BRA(0x3B), BASE, ARG_FBRA }, ++ { "fbgt", BRA(0x3C), BASE, ARG_FBRA }, ++ { "fbge", BRA(0x3D), BASE, ARG_FBRA }, ++ { "ldi", MEM(0x3E), BASE, { RA, MDISP, ZB } }, ++ { "ldi", MEM(0x3E), BASE, ARG_MEM }, ++ { "ldih", MEM(0x3F), BASE, { RA, MDISP, ZB } }, ++ { "ldih", MEM(0x3F), BASE, ARG_MEM }, ++ { "unop", MEM_(0x3F) | (30 << 16), MEM_MASK, BASE , { ZA } }, ++}; ++ ++const unsigned sw64_num_opcodes = sizeof(sw64_opcodes)/sizeof(*sw64_opcodes); diff --git a/gdb.spec b/gdb.spec index 7fed17d..5d8db2f 100644 --- a/gdb.spec +++ b/gdb.spec @@ -1,6 +1,6 @@ Name: gdb Version: 14.1 -Release: 4 +Release: 5 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL-1.3 Source: https://ftp.gnu.org/gnu/gdb/gdb-%{version}.tar.xz @@ -57,6 +57,7 @@ Patch44: gdb-rhbz2250652-gdbpy_gil.patch Patch45: gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch Patch46: gdb-rhbz2257562-cp-namespace-null-ptr-check.patch Patch47: gdb-ftbs-swapped-calloc-args.patch +patch54: gdb-14.1-add-support-for-SW64.patch # Fedra patch end Patch9000: 0001-set-entry-point-when-text-segment-is-missing.patch @@ -195,7 +196,7 @@ export CXXFLAGS="$CFLAGS" --with-lzma \ --without-libunwind \ --enable-64-bit-bfd \ -%ifnarch riscv64 loongarch64 +%ifnarch riscv64 loongarch64 || sw_64 --enable-inprocess-agent \ %endif --with-system-zlib \ @@ -317,7 +318,7 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/gdb/python/gdb/command/backtrace.py %files gdbserver %{_bindir}/gdbserver -%ifnarch riscv64 loongarch64 +%ifnarch riscv64 loongarch64 sw_64 %{_libdir}/libinproctrace.so %endif @@ -335,6 +336,9 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/gdb/python/gdb/command/backtrace.py %{_infodir}/ctf-spec.info* %changelog +* Mon Mar 3 2025 Liu Hanxu - 14.1-5 +- Add support for SW64 + * Fri Jan 17 2025 Funda Wang - 14.1-4 - Disable guile support as it is not used for years -- Gitee