diff options
author | liuzhensong <liuzhensong@loongson.cn> | 2021-10-22 16:42:03 +0800 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-10-24 21:36:31 +1030 |
commit | e214f8db56f65531b0a5ec296c42339dcaa5af31 (patch) | |
tree | 98bd755197a63aaf79bda89bb3ea792e5a49aaab /bfd/elf.c | |
parent | e515d93264b8c74993d8c9f3ac76bd6deaa666f8 (diff) | |
download | fsf-binutils-gdb-e214f8db56f65531b0a5ec296c42339dcaa5af31.zip fsf-binutils-gdb-e214f8db56f65531b0a5ec296c42339dcaa5af31.tar.gz fsf-binutils-gdb-e214f8db56f65531b0a5ec296c42339dcaa5af31.tar.bz2 |
LoongArch bfd support
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn>
Zhensong Liu <liuzhensong@loongson.cn>
Weinan Liu <liuweinan@loongson.cn>
bfd/
* Makefile.am: Add LoongArch.
* archures.c: Likewise.
* config.bfd: Likewise.
* configure.ac: Likewise.
* cpu-loongarch.c: New.
* elf-bfd.h: Add LoongArch.
* elf.c: Add LoongArch elfcore_grok_xxx.
* elfnn-loongarch.c: New.
* elfxx-loongarch.c: New.
* elfxx-loongarch.h: New.
* reloc.c: Add LoongArch BFD RELOC ENUM.
* targets.c: Add LoongArch target.
* Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* configure: Regenerate.
* libbfd.h: Regenerate.
* po/BLD-POTFILES.in: Regenerate.
* po/SRC-POTFILES.in: Regenerate.
include/
* elf/common.h: Add NT_LARCH_{CPUCFG,CSR,LSX,LASX}.
* elf/loongarch.h: New.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 109 |
1 files changed, 109 insertions, 0 deletions
@@ -9951,6 +9951,30 @@ elfcore_grok_gdb_tdesc (bfd *abfd, Elf_Internal_Note *note) return elfcore_make_note_pseudosection (abfd, ".gdb-tdesc", note); } +static bool +elfcore_grok_loongarch_cpucfg (bfd *abfd, Elf_Internal_Note *note) +{ + return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-cpucfg", note); +} + +static bool +elfcore_grok_loongarch_lbt (bfd *abfd, Elf_Internal_Note *note) +{ + return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-lbt", note); +} + +static bool +elfcore_grok_loongarch_lsx (bfd *abfd, Elf_Internal_Note *note) +{ + return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-lsx", note); +} + +static bool +elfcore_grok_loongarch_lasx (bfd *abfd, Elf_Internal_Note *note) +{ + return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-lasx", note); +} + #if defined (HAVE_PRPSINFO_T) typedef prpsinfo_t elfcore_psinfo_t; #if defined (HAVE_PRPSINFO32_T) /* Sparc64 cross Sparc32 */ @@ -10630,6 +10654,34 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note) else return true; + case NT_LARCH_CPUCFG: + if (note->namesz == 6 + && strcmp (note->namedata, "LINUX") == 0) + return elfcore_grok_loongarch_cpucfg (abfd, note); + else + return true; + + case NT_LARCH_LBT: + if (note->namesz == 6 + && strcmp (note->namedata, "LINUX") == 0) + return elfcore_grok_loongarch_lbt (abfd, note); + else + return true; + + case NT_LARCH_LSX: + if (note->namesz == 6 + && strcmp (note->namedata, "LINUX") == 0) + return elfcore_grok_loongarch_lsx (abfd, note); + else + return true; + + case NT_LARCH_LASX: + if (note->namesz == 6 + && strcmp (note->namedata, "LINUX") == 0) + return elfcore_grok_loongarch_lasx (abfd, note); + else + return true; + case NT_PRPSINFO: case NT_PSINFO: if (bed->elf_backend_grok_psinfo) @@ -12210,6 +12262,55 @@ elfcore_write_arc_v2 (bfd *abfd, note_name, NT_ARC_V2, arc_v2, size); } +char * +elfcore_write_loongarch_cpucfg (bfd *abfd, + char *buf, + int *bufsiz, + const void *loongarch_cpucfg, + int size) +{ + char *note_name = "LINUX"; + return elfcore_write_note (abfd, buf, bufsiz, + note_name, NT_LARCH_CPUCFG, + loongarch_cpucfg, size); +} + +char * +elfcore_write_loongarch_lbt (bfd *abfd, + char *buf, + int *bufsiz, + const void *loongarch_lbt, + int size) +{ + char *note_name = "LINUX"; + return elfcore_write_note (abfd, buf, bufsiz, + note_name, NT_LARCH_LBT, loongarch_lbt, size); +} + +char * +elfcore_write_loongarch_lsx (bfd *abfd, + char *buf, + int *bufsiz, + const void *loongarch_lsx, + int size) +{ + char *note_name = "LINUX"; + return elfcore_write_note (abfd, buf, bufsiz, + note_name, NT_LARCH_LSX, loongarch_lsx, size); +} + +char * +elfcore_write_loongarch_lasx (bfd *abfd, + char *buf, + int *bufsiz, + const void *loongarch_lasx, + int size) +{ + char *note_name = "LINUX"; + return elfcore_write_note (abfd, buf, bufsiz, + note_name, NT_LARCH_LASX, loongarch_lasx, size); +} + /* Write the buffer of csr values in CSRS (length SIZE) into the note buffer BUF and update *BUFSIZ. ABFD is the bfd the note is being written into. Return a pointer to the new start of the note buffer, to @@ -12334,6 +12435,14 @@ elfcore_write_register_note (bfd *abfd, return elfcore_write_gdb_tdesc (abfd, buf, bufsiz, data, size); if (strcmp (section, ".reg-riscv-csr") == 0) return elfcore_write_riscv_csr (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-loongarch-cpucfg") == 0) + return elfcore_write_loongarch_cpucfg (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-loongarch-lbt") == 0) + return elfcore_write_loongarch_lbt (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-loongarch-lsx") == 0) + return elfcore_write_loongarch_lsx (abfd, buf, bufsiz, data, size); + if (strcmp (section, ".reg-loongarch-lasx") == 0) + return elfcore_write_loongarch_lasx (abfd, buf, bufsiz, data, size); return NULL; } |