diff options
author | Nick Clifton <nickc@redhat.com> | 2025-08-15 14:03:59 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2025-08-15 14:03:59 +0100 |
commit | 09e56f0515c3f911eaf322f4ec4c07f46e5f53da (patch) | |
tree | 9368a13223657e22904743269c2d9761a3d1ef81 | |
parent | bd619420b35508495bb4ae8cf0b32a3257411fa3 (diff) | |
download | binutils-09e56f0515c3f911eaf322f4ec4c07f46e5f53da.zip binutils-09e56f0515c3f911eaf322f4ec4c07f46e5f53da.tar.gz binutils-09e56f0515c3f911eaf322f4ec4c07f46e5f53da.tar.bz2 |
Code tidy: bfd/elf.c: T|idy up core note handling code.
-rw-r--r-- | bfd/elf.c | 1037 |
1 files changed, 374 insertions, 663 deletions
@@ -49,9 +49,71 @@ SECTION #include CORE_HEADER #endif -/* Name of a pseudo-section which represents NT_386_TLS notes within a core - file. */ -#define PSEUDO_SECTION_NAME_I386_TLS ".reg-i386-tls" +/* Utility macro to make testing for string equality easier to read. */ +#ifndef streq +#define streq(A,B) strcmp ((A), (B)) == 0 +#endif + +/* Core note names. */ +#define NOTE_NAME_CORE "CORE" +#define NOTE_NAME_FREEBSD "FreeBSD" +#define NOTE_NAME_GDB "GDB" +#define NOTE_NAME_LINUX "LINUX" + +/* Names of a pseudo-section which represent core notes. */ +#define NOTE_PSEUDO_SECTION_AARCH_GCS ".reg-aarch-gcs" +#define NOTE_PSEUDO_SECTION_AARCH_HW_BREAK ".reg-aarch-hw-break" +#define NOTE_PSEUDO_SECTION_AARCH_HW_WATCH ".reg-aarch-hw-watch" +#define NOTE_PSEUDO_SECTION_AARCH_MTE ".reg-aarch-mte" +#define NOTE_PSEUDO_SECTION_AARCH_PAUTH ".reg-aarch-pauth" +#define NOTE_PSEUDO_SECTION_AARCH_SSVE ".reg-aarch-ssve" +#define NOTE_PSEUDO_SECTION_AARCH_SVE ".reg-aarch-sve" +#define NOTE_PSEUDO_SECTION_AARCH_TLS ".reg-aarch-tls" +#define NOTE_PSEUDO_SECTION_AARCH_ZA ".reg-aarch-za" +#define NOTE_PSEUDO_SECTION_AARCH_ZT ".reg-aarch-zt" +#define NOTE_PSEUDO_SECTION_ARC_V2 ".reg-arc-v2" +#define NOTE_PSEUDO_SECTION_ARM_VFP ".reg-arm-vfp" +#define NOTE_PSEUDO_SECTION_I386_TLS ".reg-i386-tls" +#define NOTE_PSEUDO_SECTION_LOONGARCH_CPUCFG ".reg-loongarch-cpucfg" +#define NOTE_PSEUDO_SECTION_LOONGARCH_LASX ".reg-loongarch-lasx" +#define NOTE_PSEUDO_SECTION_LOONGARCH_LBT ".reg-loongarch-lbt" +#define NOTE_PSEUDO_SECTION_LOONGARCH_LSX ".reg-loongarch-lsx" +#define NOTE_PSEUDO_SECTION_PPC_DSCR ".reg-ppc-dscr" +#define NOTE_PSEUDO_SECTION_PPC_EBB ".reg-ppc-ebb" +#define NOTE_PSEUDO_SECTION_PPC_PMU ".reg-ppc-pmu" +#define NOTE_PSEUDO_SECTION_PPC_PPR ".reg-ppc-ppr" +#define NOTE_PSEUDO_SECTION_PPC_TAR ".reg-ppc-tar" +#define NOTE_PSEUDO_SECTION_PPC_TM_CDSCR ".reg-ppc-tm-cdscr" +#define NOTE_PSEUDO_SECTION_PPC_TM_CFPR ".reg-ppc-tm-cfpr" +#define NOTE_PSEUDO_SECTION_PPC_TM_CGPR ".reg-ppc-tm-cgpr" +#define NOTE_PSEUDO_SECTION_PPC_TM_CPPR ".reg-ppc-tm-cppr" +#define NOTE_PSEUDO_SECTION_PPC_TM_CTAR ".reg-ppc-tm-ctar" +#define NOTE_PSEUDO_SECTION_PPC_TM_CVMX ".reg-ppc-tm-cvmx" +#define NOTE_PSEUDO_SECTION_PPC_TM_CVSX ".reg_ppc_tm_cvsx" +#define NOTE_PSEUDO_SECTION_PPC_TM_SPR ".reg_ppc_tm_spr" +#define NOTE_PSEUDO_SECTION_PPC_VSX ".reg_ppc_vsx" +#define NOTE_PSEUDO_SECTION_PPC_VMX ".reg_ppc_vmx" +#define NOTE_PSEUDO_SECTION_REG ".reg" +#define NOTE_PSEUDO_SECTION_REG2 ".reg2" +#define NOTE_PSEUDO_SECTION_RISCV_CSR ".reg_riscv_csr" +#define NOTE_PSEUDO_SECTION_S390_CTRS ".reg_s390_ctrs" +#define NOTE_PSEUDO_SECTION_S390_GS_BC ".reg-s390-gs-bc" +#define NOTE_PSEUDO_SECTION_S390_GS_CB ".reg-s390-gs-cb" +#define NOTE_PSEUDO_SECTION_S390_HIGH_GPRS ".reg-s390-high-gprs" +#define NOTE_PSEUDO_SECTION_S390_LAST_BREAK ".reg-s390-last-break" +#define NOTE_PSEUDO_SECTION_S390_PREFIX ".reg-s390-prefix" +#define NOTE_PSEUDO_SECTION_S390_SYSTEM_CALL ".reg-s390-system-call" +#define NOTE_PSEUDO_SECTION_S390_TDB ".reg-s390-tdb" +#define NOTE_PSEUDO_SECTION_S390_TIMER ".reg-s390-timer" +#define NOTE_PSEUDO_SECTION_S390_TODCMP ".reg-s390-todcmp" +#define NOTE_PSEUDO_SECTION_S390_TODPREG ".reg-s390-todpreg" +#define NOTE_PSEUDO_SECTION_S390_VXRS_HIGH ".reg-s390-vxrs-high" +#define NOTE_PSEUDO_SECTION_S390_VXRS_LOW ".reg-s390-vxrs-low" +#define NOTE_PSEUDO_SECTION_SSP ".reg-ssp" +#define NOTE_PSEUDO_SECTION_TDESC ".reg-tdesc" +#define NOTE_PSEUDO_SECTION_X86_SEGBASES ".reg-x86-segbases" +#define NOTE_PSEUDO_SECTION_XFP ".reg-xfp" +#define NOTE_PSEUDO_SECTION_XSTATE ".reg-xstate" static int elf_sort_sections (const void *, const void *); static bool assign_file_positions_except_relocs (bfd *, struct bfd_link_info *); @@ -914,7 +976,7 @@ _bfd_elf_make_section_from_shdr (bfd *abfd, } else if (startswith (name, ".line") || startswith (name, ".stab") - || strcmp (name, ".gdb_index") == 0) + || streq (name, ".gdb_index")) flags |= SEC_DEBUGGING; } } @@ -1558,7 +1620,7 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg) if (bed->elf_backend_get_target_dtag) name = (*bed->elf_backend_get_target_dtag) (dyn.d_tag); - if (!strcmp (name, "")) + if (streq (name, "")) { sprintf (ab, "%#" PRIx64, (uint64_t) dyn.d_tag); name = ab; @@ -2303,7 +2365,7 @@ _bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol, if (base_p || nodename == NULL || symbol->name == NULL - || strcmp (symbol->name, nodename) != 0) + || ! streq (symbol->name, nodename)) version_string = nodename; } else @@ -4003,7 +4065,7 @@ _bfd_elf_plt_get_reloc_section (bfd *abfd, const char *name) /* If a target needs .got.plt section, relocations in rela.plt/rel.plt section likely apply to .got.plt or .got section. */ if (get_elf_backend_data (abfd)->want_got_plt - && strcmp (name, ".plt") == 0) + && streq (name, ".plt")) { asection *sec; @@ -4309,7 +4371,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) but without the trailing ``str'', and set its sh_link field to point to this section. */ if (startswith (sec->name, ".stab") - && strcmp (sec->name + strlen (sec->name) - 3, "str") == 0) + && streq (sec->name + strlen (sec->name) - 3, "str")) { size_t len; char *alc; @@ -6102,7 +6164,7 @@ assign_file_positions_for_load_sections (bfd *abfd, PT_DYNAMIC segment. */ else if (p->p_type == PT_DYNAMIC && m->count > 1 - && strcmp (m->sections[0]->name, ".dynamic") != 0) + && ! streq (m->sections[0]->name, ".dynamic")) { _bfd_error_handler (_("%pB: The first section in the PT_DYNAMIC segment" @@ -7467,7 +7529,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd, bfd_vma maxpagesize) || (segment->p_paddr \ ? segment->p_paddr != section->lma * (opb) \ : segment->p_vaddr != section->vma * (opb)) \ - || (strcmp (bfd_section_name (section), ".dynamic") == 0)) \ + || (streq (bfd_section_name (section), ".dynamic"))) \ && (segment->p_type != PT_LOAD || !section->segment_mark)) /* If the output section of a section in the input segment is NULL, @@ -10379,7 +10441,7 @@ elfcore_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) } /* Make a ".reg/999" section and a ".reg" section. */ - return _bfd_elfcore_make_pseudosection (abfd, ".reg", + return _bfd_elfcore_make_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, size, note->descpos + offset); } #endif /* defined (HAVE_PRSTATUS_T) */ @@ -10401,7 +10463,7 @@ elfcore_make_note_pseudosection (bfd *abfd, static bool elfcore_grok_prfpreg (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg2", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, note); } /* Linux dumps the Intel SSE regs in a note named "LINUX" with a note @@ -10411,7 +10473,7 @@ elfcore_grok_prfpreg (bfd *abfd, Elf_Internal_Note *note) static bool elfcore_grok_prxfpreg (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_XFP, note); } /* Linux dumps the Intel XSAVE extended state in a note named "LINUX" @@ -10421,236 +10483,235 @@ elfcore_grok_prxfpreg (bfd *abfd, Elf_Internal_Note *note) static bool elfcore_grok_xstatereg (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-xstate", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_XSTATE, note); } static bool elfcore_grok_sspreg (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ssp", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_SSP, note); } static bool elfcore_grok_ppc_vmx (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-vmx", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_VMX, note); } static bool elfcore_grok_ppc_vsx (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-vsx", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_VSX, note); } static bool elfcore_grok_ppc_tar (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tar", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TAR, note); } static bool elfcore_grok_ppc_ppr (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-ppr", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_PPR, note); } static bool elfcore_grok_ppc_dscr (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-dscr", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_DSCR, note); } static bool elfcore_grok_ppc_ebb (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-ebb", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_EBB, note); } static bool elfcore_grok_ppc_pmu (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-pmu", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_PMU, note); } static bool elfcore_grok_ppc_tm_cgpr (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cgpr", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CGPR, note); } static bool elfcore_grok_ppc_tm_cfpr (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cfpr", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CFPR, note); } static bool elfcore_grok_ppc_tm_cvmx (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cvmx", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CVMX, note); } static bool elfcore_grok_ppc_tm_cvsx (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cvsx", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CVSX, note); } static bool elfcore_grok_ppc_tm_spr (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-spr", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_SPR, note); } static bool elfcore_grok_ppc_tm_ctar (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-ctar", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CTAR, note); } static bool elfcore_grok_ppc_tm_cppr (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cppr", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CPPR, note); } static bool elfcore_grok_ppc_tm_cdscr (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cdscr", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CDSCR, note); } static bool elfcore_grok_s390_high_gprs (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-high-gprs", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_HIGH_GPRS, note); } static bool elfcore_grok_s390_timer (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-timer", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_TIMER, note); } static bool elfcore_grok_s390_todcmp (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-todcmp", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_TODCMP, note); } static bool elfcore_grok_s390_todpreg (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-todpreg", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_TODPREG, note); } static bool elfcore_grok_s390_ctrs (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-ctrs", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_CTRS, note); } static bool elfcore_grok_s390_prefix (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-prefix", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_PREFIX, note); } static bool elfcore_grok_s390_last_break (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-last-break", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_LAST_BREAK, note); } static bool elfcore_grok_s390_system_call (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-system-call", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_SYSTEM_CALL, note); } static bool elfcore_grok_s390_tdb (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-tdb", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_TDB, note); } static bool elfcore_grok_s390_vxrs_low (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-vxrs-low", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_VXRS_LOW, note); } static bool elfcore_grok_s390_vxrs_high (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-vxrs-high", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_VXRS_HIGH, note); } static bool elfcore_grok_s390_gs_cb (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-gs-cb", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_GS_CB, note); } static bool elfcore_grok_s390_gs_bc (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-s390-gs-bc", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_S390_GS_BC, note); } static bool elfcore_grok_arm_vfp (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-arm-vfp", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_ARM_VFP, note); } static bool elfcore_grok_aarch_tls (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-aarch-tls", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_TLS, note); } static bool elfcore_grok_aarch_hw_break (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-aarch-hw-break", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_HW_BREAK, note); } static bool elfcore_grok_aarch_hw_watch (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-aarch-hw-watch", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_HW_WATCH, note); } static bool elfcore_grok_aarch_sve (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-aarch-sve", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_SVE, note); } static bool elfcore_grok_aarch_pauth (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-aarch-pauth", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_PAUTH, note); } static bool elfcore_grok_aarch_mte (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-aarch-mte", - note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_MTE, note); } static bool elfcore_grok_aarch_ssve (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-aarch-ssve", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_SSVE, note); } static bool elfcore_grok_aarch_za (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-aarch-za", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_ZA, note); } /* Convert NOTE into a bfd_section called ".reg-aarch-zt". Return TRUE if @@ -10659,7 +10720,7 @@ elfcore_grok_aarch_za (bfd *abfd, Elf_Internal_Note *note) static bool elfcore_grok_aarch_zt (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-aarch-zt", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_ZT, note); } /* Convert NOTE into a bfd_section called ".reg-aarch-gcs". Return TRUE if @@ -10668,13 +10729,13 @@ elfcore_grok_aarch_zt (bfd *abfd, Elf_Internal_Note *note) static bool elfcore_grok_aarch_gcs (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-aarch-gcs", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_GCS, note); } static bool elfcore_grok_arc_v2 (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-arc-v2", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_ARC_V2, note); } /* Convert NOTE into a bfd_section called ".reg-riscv-csr". Return TRUE if @@ -10683,7 +10744,7 @@ elfcore_grok_arc_v2 (bfd *abfd, Elf_Internal_Note *note) static bool elfcore_grok_riscv_csr (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-riscv-csr", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_RISCV_CSR, note); } /* Convert NOTE into a bfd_section called ".gdb-tdesc". Return TRUE if @@ -10698,32 +10759,32 @@ elfcore_grok_gdb_tdesc (bfd *abfd, Elf_Internal_Note *note) static bool elfcore_grok_i386_tls (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, PSEUDO_SECTION_NAME_I386_TLS, + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_I386_TLS, note); } static bool elfcore_grok_loongarch_cpucfg (bfd *abfd, Elf_Internal_Note *note) { - return elfcore_make_note_pseudosection (abfd, ".reg-loongarch-cpucfg", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_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); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_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); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_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); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_LOONGARCH_LASX, note); } #if defined (HAVE_PRPSINFO_T) @@ -10893,7 +10954,7 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note) /* Make a ".reg/999" section. */ - sprintf (buf, ".reg/%d", elfcore_make_pid (abfd)); + sprintf (buf, NOTE_PSEUDO_SECTION_REG "/%d", elfcore_make_pid (abfd)); len = strlen (buf) + 1; name = bfd_alloc (abfd, len); if (name == NULL) @@ -10917,12 +10978,12 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note) sect->alignment_power = 2; - if (!elfcore_maybe_make_sect (abfd, ".reg", sect)) + if (!elfcore_maybe_make_sect (abfd, NOTE_PSEUDO_SECTION_REG, sect)) return false; /* Make a ".reg2/999" section */ - sprintf (buf, ".reg2/%d", elfcore_make_pid (abfd)); + sprintf (buf, NOTE_PSEUDO_SECTION_REG2 "/%d", elfcore_make_pid (abfd)); len = strlen (buf) + 1; name = bfd_alloc (abfd, len); if (name == NULL) @@ -10946,7 +11007,7 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note) sect->alignment_power = 2; - return elfcore_maybe_make_sect (abfd, ".reg2", sect); + return elfcore_maybe_make_sect (abfd, NOTE_PSEUDO_SECTION_REG2, sect); } #endif /* defined (HAVE_LWPSTATUS_T) */ @@ -11012,7 +11073,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note) /* Make a ".reg/<tid>" section containing the Win32 API thread CONTEXT structure. */ /* thread_info.tid */ - sprintf (buf, ".reg/%ld", (long) bfd_get_32 (abfd, note->descdata + 4)); + sprintf (buf, NOTE_PSEUDO_SECTION_REG "/%ld", (long) bfd_get_32 (abfd, note->descdata + 4)); len = strlen (buf) + 1; name = (char *) bfd_alloc (abfd, len); @@ -11035,7 +11096,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note) is_active_thread = bfd_get_32 (abfd, note->descdata + 8); if (is_active_thread) - if (! elfcore_maybe_make_sect (abfd, ".reg", sect)) + if (! elfcore_maybe_make_sect (abfd, NOTE_PSEUDO_SECTION_REG, sect)) return false; break; @@ -11096,6 +11157,64 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note) { const struct elf_backend_data *bed = get_elf_backend_data (abfd); + /* Short cut for LINUX notes. */ + if (note->namesz == 6 /* strlen (NOTE_NAME_LINUX) + 1 */ + && streq (note->namedata, NOTE_NAME_LINUX)) + { + switch (note->type) + { + case NT_386_TLS: return elfcore_grok_i386_tls (abfd, note); + case NT_ARC_V2: return elfcore_grok_arc_v2 (abfd, note); + case NT_ARM_GCS: return elfcore_grok_aarch_gcs (abfd, note); + case NT_ARM_HW_BREAK: return elfcore_grok_aarch_hw_break (abfd, note); + case NT_ARM_HW_WATCH: return elfcore_grok_aarch_hw_watch (abfd, note); + case NT_ARM_PAC_MASK: return elfcore_grok_aarch_pauth (abfd, note); + case NT_ARM_SSVE: return elfcore_grok_aarch_ssve (abfd, note); + case NT_ARM_SVE: return elfcore_grok_aarch_sve (abfd, note); + case NT_ARM_TAGGED_ADDR_CTRL: return elfcore_grok_aarch_mte (abfd, note); + case NT_ARM_TLS: return elfcore_grok_aarch_tls (abfd, note); + case NT_ARM_VFP: return elfcore_grok_arm_vfp (abfd, note); + case NT_ARM_ZA: return elfcore_grok_aarch_za (abfd, note); + case NT_ARM_ZT: return elfcore_grok_aarch_zt (abfd, note); + case NT_LARCH_CPUCFG: return elfcore_grok_loongarch_cpucfg (abfd, note); + case NT_LARCH_LASX: return elfcore_grok_loongarch_lasx (abfd, note); + case NT_LARCH_LBT: return elfcore_grok_loongarch_lbt (abfd, note); + case NT_LARCH_LSX: return elfcore_grok_loongarch_lsx (abfd, note); + case NT_PPC_DSCR: return elfcore_grok_ppc_dscr (abfd, note); + case NT_PPC_EBB: return elfcore_grok_ppc_ebb (abfd, note); + case NT_PPC_PMU: return elfcore_grok_ppc_pmu (abfd, note); + case NT_PPC_PPR: return elfcore_grok_ppc_ppr (abfd, note); + case NT_PPC_TAR: return elfcore_grok_ppc_tar (abfd, note); + case NT_PPC_TM_CDSCR: return elfcore_grok_ppc_tm_cdscr (abfd, note); + case NT_PPC_TM_CFPR: return elfcore_grok_ppc_tm_cfpr (abfd, note); + case NT_PPC_TM_CGPR: return elfcore_grok_ppc_tm_cgpr (abfd, note); + case NT_PPC_TM_CPPR: return elfcore_grok_ppc_tm_cppr (abfd, note); + case NT_PPC_TM_CTAR: return elfcore_grok_ppc_tm_ctar (abfd, note); + case NT_PPC_TM_CVMX: return elfcore_grok_ppc_tm_cvmx (abfd, note); + case NT_PPC_TM_CVSX: return elfcore_grok_ppc_tm_cvsx (abfd, note); + case NT_PPC_TM_SPR: return elfcore_grok_ppc_tm_spr (abfd, note); + case NT_PPC_VMX: return elfcore_grok_ppc_vmx (abfd, note); + case NT_PPC_VSX: return elfcore_grok_ppc_vsx (abfd, note); + case NT_PRXFPREG: return elfcore_grok_prxfpreg (abfd, note); + case NT_S390_CTRS: return elfcore_grok_s390_ctrs (abfd, note); + case NT_S390_GS_BC: return elfcore_grok_s390_gs_bc (abfd, note); + case NT_S390_GS_CB: return elfcore_grok_s390_gs_cb (abfd, note); + case NT_S390_HIGH_GPRS: return elfcore_grok_s390_high_gprs (abfd, note); + case NT_S390_LAST_BREAK: return elfcore_grok_s390_last_break (abfd, note); + case NT_S390_PREFIX: return elfcore_grok_s390_prefix (abfd, note); + case NT_S390_SYSTEM_CALL: return elfcore_grok_s390_system_call (abfd, note); + case NT_S390_TDB: return elfcore_grok_s390_tdb (abfd, note); + case NT_S390_TIMER: return elfcore_grok_s390_timer (abfd, note); + case NT_S390_TODCMP: return elfcore_grok_s390_todcmp (abfd, note); + case NT_S390_TODPREG: return elfcore_grok_s390_todpreg (abfd, note); + case NT_S390_VXRS_HIGH: return elfcore_grok_s390_vxrs_high (abfd, note); + case NT_S390_VXRS_LOW: return elfcore_grok_s390_vxrs_low (abfd, note); + case NT_X86_SHSTK: return elfcore_grok_sspreg (abfd, note); + case NT_X86_XSTATE: return elfcore_grok_xstatereg (abfd, note); + default: break; + } + } + switch (note->type) { default: @@ -11121,361 +11240,24 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note) return elfcore_grok_lwpstatus (abfd, note); #endif - case NT_FPREGSET: /* FIXME: rename to NT_PRFPREG */ + case NT_FPREGSET: /* FIXME: rename to NT_PRFPREG. */ return elfcore_grok_prfpreg (abfd, note); case NT_WIN32PSTATUS: return elfcore_grok_win32pstatus (abfd, note); - case NT_PRXFPREG: /* Linux SSE extension */ - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_prxfpreg (abfd, note); - else - return true; - - case NT_X86_XSTATE: /* Linux XSAVE extension */ - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_xstatereg (abfd, note); - else - return true; - - case NT_X86_SHSTK: /* Linux CET extension. */ - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_sspreg (abfd, note); - else - return true; - - case NT_PPC_VMX: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_vmx (abfd, note); - else - return true; - - case NT_PPC_VSX: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_vsx (abfd, note); - else - return true; - - case NT_PPC_TAR: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_tar (abfd, note); - else - return true; - - case NT_PPC_PPR: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_ppr (abfd, note); - else - return true; - - case NT_PPC_DSCR: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_dscr (abfd, note); - else - return true; - - case NT_PPC_EBB: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_ebb (abfd, note); - else - return true; - - case NT_PPC_PMU: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_pmu (abfd, note); - else - return true; - - case NT_PPC_TM_CGPR: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_tm_cgpr (abfd, note); - else - return true; - - case NT_PPC_TM_CFPR: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_tm_cfpr (abfd, note); - else - return true; - - case NT_PPC_TM_CVMX: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_tm_cvmx (abfd, note); - else - return true; - - case NT_PPC_TM_CVSX: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_tm_cvsx (abfd, note); - else - return true; - - case NT_PPC_TM_SPR: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_tm_spr (abfd, note); - else - return true; - - case NT_PPC_TM_CTAR: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_tm_ctar (abfd, note); - else - return true; - - case NT_PPC_TM_CPPR: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_tm_cppr (abfd, note); - else - return true; - - case NT_PPC_TM_CDSCR: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_ppc_tm_cdscr (abfd, note); - else - return true; - - case NT_S390_HIGH_GPRS: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_high_gprs (abfd, note); - else - return true; - - case NT_S390_TIMER: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_timer (abfd, note); - else - return true; - - case NT_S390_TODCMP: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_todcmp (abfd, note); - else - return true; - - case NT_S390_TODPREG: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_todpreg (abfd, note); - else - return true; - - case NT_S390_CTRS: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_ctrs (abfd, note); - else - return true; - - case NT_S390_PREFIX: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_prefix (abfd, note); - else - return true; - - case NT_S390_LAST_BREAK: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_last_break (abfd, note); - else - return true; - - case NT_S390_SYSTEM_CALL: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_system_call (abfd, note); - else - return true; - - case NT_S390_TDB: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_tdb (abfd, note); - else - return true; - - case NT_S390_VXRS_LOW: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_vxrs_low (abfd, note); - else - return true; - - case NT_S390_VXRS_HIGH: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_vxrs_high (abfd, note); - else - return true; - - case NT_S390_GS_CB: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_gs_cb (abfd, note); - else - return true; - - case NT_S390_GS_BC: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_s390_gs_bc (abfd, note); - else - return true; - - case NT_ARC_V2: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_arc_v2 (abfd, note); - else - return true; - - case NT_ARM_VFP: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_arm_vfp (abfd, note); - else - return true; - - case NT_ARM_TLS: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_aarch_tls (abfd, note); - else - return true; - - case NT_386_TLS: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_i386_tls (abfd, note); - else - return true; - - case NT_ARM_HW_BREAK: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_aarch_hw_break (abfd, note); - else - return true; - - case NT_ARM_HW_WATCH: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_aarch_hw_watch (abfd, note); - else - return true; - - case NT_ARM_SVE: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_aarch_sve (abfd, note); - else - return true; - - case NT_ARM_PAC_MASK: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_aarch_pauth (abfd, note); - else - return true; - - case NT_ARM_TAGGED_ADDR_CTRL: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_aarch_mte (abfd, note); - else - return true; - - case NT_ARM_SSVE: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_aarch_ssve (abfd, note); - else - return true; - - case NT_ARM_ZA: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_aarch_za (abfd, note); - else - return true; - - case NT_ARM_ZT: - if (note->namesz == 6 - && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_aarch_zt (abfd, note); - else - return true; - - case NT_ARM_GCS: - if (note->namesz == 6 && strcmp (note->namedata, "LINUX") == 0) - return elfcore_grok_aarch_gcs (abfd, note); - else - return true; - case NT_GDB_TDESC: - if (note->namesz == 4 - && strcmp (note->namedata, "GDB") == 0) + if (note->namesz == 4 && streq (note->namedata, NOTE_NAME_GDB)) return elfcore_grok_gdb_tdesc (abfd, note); else return true; case NT_RISCV_CSR: - if (note->namesz == 4 - && strcmp (note->namedata, "GDB") == 0) + if (note->namesz == 4 && streq (note->namedata, NOTE_NAME_GDB)) return elfcore_grok_riscv_csr (abfd, 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) @@ -11497,7 +11279,6 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note) case NT_SIGINFO: return elfcore_make_note_pseudosection (abfd, ".note.linuxcore.siginfo", note); - } } @@ -11692,7 +11473,7 @@ elfcore_grok_freebsd_prstatus (bfd *abfd, Elf_Internal_Note *note) return false; /* Make a ".reg/999" section and a ".reg" section. */ - return _bfd_elfcore_make_pseudosection (abfd, ".reg", + return _bfd_elfcore_make_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, size, note->descpos + offset); } @@ -11734,7 +11515,7 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note) return elfcore_make_auxv_note_section (abfd, note, 4); case NT_FREEBSD_X86_SEGBASES: - return elfcore_make_note_pseudosection (abfd, ".reg-x86-segbases", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_X86_SEGBASES, note); case NT_X86_XSTATE: return elfcore_grok_xstatereg (abfd, note); @@ -11837,10 +11618,10 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note) switch (note->type) { case NT_NETBSDCORE_FIRSTMACH+0: - return elfcore_make_note_pseudosection (abfd, ".reg", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, note); case NT_NETBSDCORE_FIRSTMACH+2: - return elfcore_make_note_pseudosection (abfd, ".reg2", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, note); default: return true; @@ -11854,10 +11635,10 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note) switch (note->type) { case NT_NETBSDCORE_FIRSTMACH+3: - return elfcore_make_note_pseudosection (abfd, ".reg", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, note); case NT_NETBSDCORE_FIRSTMACH+5: - return elfcore_make_note_pseudosection (abfd, ".reg2", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, note); default: return true; @@ -11870,10 +11651,10 @@ elfcore_grok_netbsd_note (bfd *abfd, Elf_Internal_Note *note) switch (note->type) { case NT_NETBSDCORE_FIRSTMACH+1: - return elfcore_make_note_pseudosection (abfd, ".reg", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, note); case NT_NETBSDCORE_FIRSTMACH+3: - return elfcore_make_note_pseudosection (abfd, ".reg2", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, note); default: return true; @@ -11923,11 +11704,11 @@ elfcore_grok_solaris_prstatus (bfd *abfd, Elf_Internal_Note* note, int sig_off, elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + lwpid_off); - sect = bfd_get_section_by_name (abfd, ".reg"); + sect = bfd_get_section_by_name (abfd, NOTE_PSEUDO_SECTION_REG); if (sect != NULL) sect->size = gregset_size; - return _bfd_elfcore_make_pseudosection (abfd, ".reg", gregset_size, + return _bfd_elfcore_make_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, gregset_size, note->descpos + gregset_offset); } @@ -11961,7 +11742,7 @@ elfcore_grok_solaris_lwpstatus (bfd *abfd, Elf_Internal_Note* note, asection *sect = NULL; char reg2_section_name[16] = { 0 }; - (void) snprintf (reg2_section_name, 16, "%s/%i", ".reg2", + (void) snprintf (reg2_section_name, 16, "%s/%i", NOTE_PSEUDO_SECTION_REG2, elf_tdata (abfd)->core->lwpid); /* offsetof(lwpstatus_t, pr_lwpid) */ @@ -11971,10 +11752,10 @@ elfcore_grok_solaris_lwpstatus (bfd *abfd, Elf_Internal_Note* note, elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12); - sect = bfd_get_section_by_name (abfd, ".reg"); + sect = bfd_get_section_by_name (abfd, NOTE_PSEUDO_SECTION_REG); if (sect != NULL) sect->size = gregset_size; - else if (!_bfd_elfcore_make_pseudosection (abfd, ".reg", gregset_size, + else if (!_bfd_elfcore_make_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, gregset_size, note->descpos + gregset_off)) return false; @@ -11985,7 +11766,7 @@ elfcore_grok_solaris_lwpstatus (bfd *abfd, Elf_Internal_Note* note, sect->filepos = note->descpos + fpregset_off; sect->alignment_power = 2; } - else if (!_bfd_elfcore_make_pseudosection (abfd, ".reg2", fpregset_size, + else if (!_bfd_elfcore_make_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, fpregset_size, note->descpos + fpregset_off)) return false; @@ -12099,13 +11880,13 @@ elfcore_grok_openbsd_note (bfd *abfd, Elf_Internal_Note *note) return elfcore_grok_openbsd_procinfo (abfd, note); if (note->type == NT_OPENBSD_REGS) - return elfcore_make_note_pseudosection (abfd, ".reg", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG, note); if (note->type == NT_OPENBSD_FPREGS) - return elfcore_make_note_pseudosection (abfd, ".reg2", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_REG2, note); if (note->type == NT_OPENBSD_XFPREGS) - return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note); + return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_XFP, note); if (note->type == NT_OPENBSD_AUXV) return elfcore_make_auxv_note_section (abfd, note, 0); @@ -12229,9 +12010,9 @@ elfcore_grok_nto_note (bfd *abfd, Elf_Internal_Note *note) case QNT_CORE_STATUS: return elfcore_grok_nto_status (abfd, note, &tid); case QNT_CORE_GREG: - return elfcore_grok_nto_regs (abfd, note, tid, ".reg"); + return elfcore_grok_nto_regs (abfd, note, tid, NOTE_PSEUDO_SECTION_REG); case QNT_CORE_FPREG: - return elfcore_grok_nto_regs (abfd, note, tid, ".reg2"); + return elfcore_grok_nto_regs (abfd, note, tid, NOTE_PSEUDO_SECTION_REG2); default: return true; } @@ -12381,7 +12162,7 @@ elfcore_write_prpsinfo (bfd *abfd, strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); return elfcore_write_note (abfd, buf, bufsiz, - "CORE", note_type, &data, sizeof (data)); + NOTE_NAME_CORE, note_type, &data, sizeof (data)); } else # endif @@ -12398,7 +12179,7 @@ elfcore_write_prpsinfo (bfd *abfd, strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); return elfcore_write_note (abfd, buf, bufsiz, - "CORE", note_type, &data, sizeof (data)); + NOTE_NAME_CORE, note_type, &data, sizeof (data)); } #endif /* PSINFO_T or PRPSINFO_T */ @@ -12419,7 +12200,7 @@ elfcore_write_linux_prpsinfo32 struct elf_external_linux_prpsinfo32_ugid16 data; swap_linux_prpsinfo32_ugid16_out (abfd, prpsinfo, &data); - return elfcore_write_note (abfd, buf, bufsiz, "CORE", NT_PRPSINFO, + return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE, NT_PRPSINFO, &data, sizeof (data)); } else @@ -12427,7 +12208,7 @@ elfcore_write_linux_prpsinfo32 struct elf_external_linux_prpsinfo32_ugid32 data; swap_linux_prpsinfo32_ugid32_out (abfd, prpsinfo, &data); - return elfcore_write_note (abfd, buf, bufsiz, "CORE", NT_PRPSINFO, + return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE, NT_PRPSINFO, &data, sizeof (data)); } } @@ -12443,7 +12224,7 @@ elfcore_write_linux_prpsinfo64 swap_linux_prpsinfo64_ugid16_out (abfd, prpsinfo, &data); return elfcore_write_note (abfd, buf, bufsiz, - "CORE", NT_PRPSINFO, &data, sizeof (data)); + NOTE_NAME_CORE, NT_PRPSINFO, &data, sizeof (data)); } else { @@ -12451,7 +12232,7 @@ elfcore_write_linux_prpsinfo64 swap_linux_prpsinfo64_ugid32_out (abfd, prpsinfo, &data); return elfcore_write_note (abfd, buf, bufsiz, - "CORE", NT_PRPSINFO, &data, sizeof (data)); + NOTE_NAME_CORE, NT_PRPSINFO, &data, sizeof (data)); } } @@ -12485,7 +12266,7 @@ elfcore_write_prstatus (bfd *abfd, prstat.pr_pid = pid; prstat.pr_cursig = cursig; memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg)); - return elfcore_write_note (abfd, buf, bufsiz, "CORE", + return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE, NT_PRSTATUS, &prstat, sizeof (prstat)); } else @@ -12497,7 +12278,7 @@ elfcore_write_prstatus (bfd *abfd, prstat.pr_pid = pid; prstat.pr_cursig = cursig; memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg)); - return elfcore_write_note (abfd, buf, bufsiz, "CORE", + return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE, NT_PRSTATUS, &prstat, sizeof (prstat)); } #endif /* HAVE_PRSTATUS_T */ @@ -12516,7 +12297,6 @@ elfcore_write_lwpstatus (bfd *abfd, const void *gregs) { lwpstatus_t lwpstat; - const char *note_name = "CORE"; memset (&lwpstat, 0, sizeof (lwpstat)); lwpstat.pr_lwpid = pid >> 16; @@ -12532,7 +12312,7 @@ elfcore_write_lwpstatus (bfd *abfd, gregs, sizeof (lwpstat.pr_context.uc_mcontext.__gregs)); #endif #endif - return elfcore_write_note (abfd, buf, bufsiz, note_name, + return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE, NT_LWPSTATUS, &lwpstat, sizeof (lwpstat)); } #endif /* HAVE_LWPSTATUS_T */ @@ -12546,7 +12326,6 @@ elfcore_write_pstatus (bfd *abfd, int cursig ATTRIBUTE_UNUSED, const void *gregs ATTRIBUTE_UNUSED) { - const char *note_name = "CORE"; #if defined (HAVE_PSTATUS32_T) const struct elf_backend_data *bed = get_elf_backend_data (abfd); @@ -12556,7 +12335,7 @@ elfcore_write_pstatus (bfd *abfd, memset (&pstat, 0, sizeof (pstat)); pstat.pr_pid = pid & 0xffff; - buf = elfcore_write_note (abfd, buf, bufsiz, note_name, + buf = elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE, NT_PSTATUS, &pstat, sizeof (pstat)); return buf; } @@ -12567,7 +12346,7 @@ elfcore_write_pstatus (bfd *abfd, memset (&pstat, 0, sizeof (pstat)); pstat.pr_pid = pid & 0xffff; - buf = elfcore_write_note (abfd, buf, bufsiz, note_name, + buf = elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_CORE, NT_PSTATUS, &pstat, sizeof (pstat)); return buf; } @@ -12581,9 +12360,8 @@ elfcore_write_prfpreg (bfd *abfd, const void *fpregs, int size) { - const char *note_name = "CORE"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_FPREGSET, fpregs, size); + NOTE_NAME_CORE, NT_FPREGSET, fpregs, size); } char * @@ -12593,9 +12371,8 @@ elfcore_write_prxfpreg (bfd *abfd, const void *xfpregs, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PRXFPREG, xfpregs, size); + NOTE_NAME_LINUX, NT_PRXFPREG, xfpregs, size); } char * @@ -12603,10 +12380,12 @@ elfcore_write_xstatereg (bfd *abfd, char *buf, int *bufsiz, const void *xfpregs, int size) { char *note_name; + if (get_elf_backend_data (abfd)->elf_osabi == ELFOSABI_FREEBSD) - note_name = "FreeBSD"; + note_name = NOTE_NAME_FREEBSD; else - note_name = "LINUX"; + note_name = NOTE_NAME_LINUX; + return elfcore_write_note (abfd, buf, bufsiz, note_name, NT_X86_XSTATE, xfpregs, size); } @@ -12615,25 +12394,24 @@ static char * elfcore_write_sspreg (bfd *abfd, char *buf, int *bufsiz, const void *ssp, int size) { - const char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_X86_SHSTK, ssp, size); + NOTE_NAME_LINUX, NT_X86_SHSTK, ssp, size); } char * elfcore_write_x86_segbases (bfd *abfd, char *buf, int *bufsiz, const void *regs, int size) { - char *note_name = "FreeBSD"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_FREEBSD_X86_SEGBASES, regs, size); + NOTE_NAME_FREEBSD, NT_FREEBSD_X86_SEGBASES, + regs, size); } char * elfcore_write_i386_tls (bfd *abfd, char *buf, int *bufsiz, const void *regs, int size) { - return elfcore_write_note (abfd, buf, bufsiz, "LINUX", NT_386_TLS, + return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_LINUX, NT_386_TLS, regs, size); } @@ -12644,9 +12422,8 @@ elfcore_write_ppc_vmx (bfd *abfd, const void *ppc_vmx, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_VMX, ppc_vmx, size); + NOTE_NAME_LINUX, NT_PPC_VMX, ppc_vmx, size); } char * @@ -12656,9 +12433,8 @@ elfcore_write_ppc_vsx (bfd *abfd, const void *ppc_vsx, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_VSX, ppc_vsx, size); + NOTE_NAME_LINUX, NT_PPC_VSX, ppc_vsx, size); } char * @@ -12668,9 +12444,8 @@ elfcore_write_ppc_tar (bfd *abfd, const void *ppc_tar, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_TAR, ppc_tar, size); + NOTE_NAME_LINUX, NT_PPC_TAR, ppc_tar, size); } char * @@ -12680,9 +12455,8 @@ elfcore_write_ppc_ppr (bfd *abfd, const void *ppc_ppr, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_PPR, ppc_ppr, size); + NOTE_NAME_LINUX, NT_PPC_PPR, ppc_ppr, size); } char * @@ -12692,9 +12466,8 @@ elfcore_write_ppc_dscr (bfd *abfd, const void *ppc_dscr, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_DSCR, ppc_dscr, size); + NOTE_NAME_LINUX, NT_PPC_DSCR, ppc_dscr, size); } char * @@ -12704,9 +12477,8 @@ elfcore_write_ppc_ebb (bfd *abfd, const void *ppc_ebb, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_EBB, ppc_ebb, size); + NOTE_NAME_LINUX, NT_PPC_EBB, ppc_ebb, size); } char * @@ -12716,9 +12488,8 @@ elfcore_write_ppc_pmu (bfd *abfd, const void *ppc_pmu, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_PMU, ppc_pmu, size); + NOTE_NAME_LINUX, NT_PPC_PMU, ppc_pmu, size); } char * @@ -12728,9 +12499,9 @@ elfcore_write_ppc_tm_cgpr (bfd *abfd, const void *ppc_tm_cgpr, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_TM_CGPR, ppc_tm_cgpr, size); + NOTE_NAME_LINUX, NT_PPC_TM_CGPR, + ppc_tm_cgpr, size); } char * @@ -12740,9 +12511,9 @@ elfcore_write_ppc_tm_cfpr (bfd *abfd, const void *ppc_tm_cfpr, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_TM_CFPR, ppc_tm_cfpr, size); + NOTE_NAME_LINUX, NT_PPC_TM_CFPR, + ppc_tm_cfpr, size); } char * @@ -12752,9 +12523,9 @@ elfcore_write_ppc_tm_cvmx (bfd *abfd, const void *ppc_tm_cvmx, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_TM_CVMX, ppc_tm_cvmx, size); + NOTE_NAME_LINUX, NT_PPC_TM_CVMX, + ppc_tm_cvmx, size); } char * @@ -12764,9 +12535,9 @@ elfcore_write_ppc_tm_cvsx (bfd *abfd, const void *ppc_tm_cvsx, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_TM_CVSX, ppc_tm_cvsx, size); + NOTE_NAME_LINUX, NT_PPC_TM_CVSX, + ppc_tm_cvsx, size); } char * @@ -12776,9 +12547,9 @@ elfcore_write_ppc_tm_spr (bfd *abfd, const void *ppc_tm_spr, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_TM_SPR, ppc_tm_spr, size); + NOTE_NAME_LINUX, NT_PPC_TM_SPR, + ppc_tm_spr, size); } char * @@ -12788,9 +12559,9 @@ elfcore_write_ppc_tm_ctar (bfd *abfd, const void *ppc_tm_ctar, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_TM_CTAR, ppc_tm_ctar, size); + NOTE_NAME_LINUX, NT_PPC_TM_CTAR, + ppc_tm_ctar, size); } char * @@ -12800,9 +12571,9 @@ elfcore_write_ppc_tm_cppr (bfd *abfd, const void *ppc_tm_cppr, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_TM_CPPR, ppc_tm_cppr, size); + NOTE_NAME_LINUX, NT_PPC_TM_CPPR, + ppc_tm_cppr, size); } char * @@ -12812,9 +12583,9 @@ elfcore_write_ppc_tm_cdscr (bfd *abfd, const void *ppc_tm_cdscr, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_PPC_TM_CDSCR, ppc_tm_cdscr, size); + NOTE_NAME_LINUX, NT_PPC_TM_CDSCR, + ppc_tm_cdscr, size); } static char * @@ -12824,9 +12595,8 @@ elfcore_write_s390_high_gprs (bfd *abfd, const void *s390_high_gprs, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_HIGH_GPRS, + NOTE_NAME_LINUX, NT_S390_HIGH_GPRS, s390_high_gprs, size); } @@ -12837,9 +12607,9 @@ elfcore_write_s390_timer (bfd *abfd, const void *s390_timer, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_TIMER, s390_timer, size); + NOTE_NAME_LINUX, NT_S390_TIMER, + s390_timer, size); } char * @@ -12849,9 +12619,9 @@ elfcore_write_s390_todcmp (bfd *abfd, const void *s390_todcmp, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_TODCMP, s390_todcmp, size); + NOTE_NAME_LINUX, NT_S390_TODCMP, + s390_todcmp, size); } char * @@ -12861,9 +12631,9 @@ elfcore_write_s390_todpreg (bfd *abfd, const void *s390_todpreg, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_TODPREG, s390_todpreg, size); + NOTE_NAME_LINUX, NT_S390_TODPREG, + s390_todpreg, size); } char * @@ -12873,9 +12643,8 @@ elfcore_write_s390_ctrs (bfd *abfd, const void *s390_ctrs, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_CTRS, s390_ctrs, size); + NOTE_NAME_LINUX, NT_S390_CTRS, s390_ctrs, size); } char * @@ -12885,9 +12654,9 @@ elfcore_write_s390_prefix (bfd *abfd, const void *s390_prefix, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_PREFIX, s390_prefix, size); + NOTE_NAME_LINUX, NT_S390_PREFIX, + s390_prefix, size); } char * @@ -12897,9 +12666,8 @@ elfcore_write_s390_last_break (bfd *abfd, const void *s390_last_break, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_LAST_BREAK, + NOTE_NAME_LINUX, NT_S390_LAST_BREAK, s390_last_break, size); } @@ -12910,9 +12678,8 @@ elfcore_write_s390_system_call (bfd *abfd, const void *s390_system_call, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_SYSTEM_CALL, + NOTE_NAME_LINUX, NT_S390_SYSTEM_CALL, s390_system_call, size); } @@ -12923,9 +12690,8 @@ elfcore_write_s390_tdb (bfd *abfd, const void *s390_tdb, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_TDB, s390_tdb, size); + NOTE_NAME_LINUX, NT_S390_TDB, s390_tdb, size); } char * @@ -12935,9 +12701,9 @@ elfcore_write_s390_vxrs_low (bfd *abfd, const void *s390_vxrs_low, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_VXRS_LOW, s390_vxrs_low, size); + NOTE_NAME_LINUX, NT_S390_VXRS_LOW, + s390_vxrs_low, size); } char * @@ -12947,9 +12713,8 @@ elfcore_write_s390_vxrs_high (bfd *abfd, const void *s390_vxrs_high, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_VXRS_HIGH, + NOTE_NAME_LINUX, NT_S390_VXRS_HIGH, s390_vxrs_high, size); } @@ -12960,9 +12725,8 @@ elfcore_write_s390_gs_cb (bfd *abfd, const void *s390_gs_cb, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_GS_CB, + NOTE_NAME_LINUX, NT_S390_GS_CB, s390_gs_cb, size); } @@ -12973,9 +12737,8 @@ elfcore_write_s390_gs_bc (bfd *abfd, const void *s390_gs_bc, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_S390_GS_BC, + NOTE_NAME_LINUX, NT_S390_GS_BC, s390_gs_bc, size); } @@ -12986,9 +12749,9 @@ elfcore_write_arm_vfp (bfd *abfd, const void *arm_vfp, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARM_VFP, arm_vfp, size); + NOTE_NAME_LINUX, NT_ARM_VFP, + arm_vfp, size); } char * @@ -12998,9 +12761,8 @@ elfcore_write_aarch_tls (bfd *abfd, const void *aarch_tls, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARM_TLS, aarch_tls, size); + NOTE_NAME_LINUX, NT_ARM_TLS, aarch_tls, size); } char * @@ -13010,9 +12772,9 @@ elfcore_write_aarch_hw_break (bfd *abfd, const void *aarch_hw_break, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARM_HW_BREAK, aarch_hw_break, size); + NOTE_NAME_LINUX, NT_ARM_HW_BREAK, + aarch_hw_break, size); } char * @@ -13022,9 +12784,9 @@ elfcore_write_aarch_hw_watch (bfd *abfd, const void *aarch_hw_watch, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARM_HW_WATCH, aarch_hw_watch, size); + NOTE_NAME_LINUX, NT_ARM_HW_WATCH, + aarch_hw_watch, size); } char * @@ -13034,9 +12796,8 @@ elfcore_write_aarch_sve (bfd *abfd, const void *aarch_sve, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARM_SVE, aarch_sve, size); + NOTE_NAME_LINUX, NT_ARM_SVE, aarch_sve, size); } char * @@ -13046,23 +12807,21 @@ elfcore_write_aarch_pauth (bfd *abfd, const void *aarch_pauth, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARM_PAC_MASK, aarch_pauth, size); + NOTE_NAME_LINUX, NT_ARM_PAC_MASK, + aarch_pauth, size); } char * elfcore_write_aarch_mte (bfd *abfd, - char *buf, - int *bufsiz, - const void *aarch_mte, - int size) + char *buf, + int *bufsiz, + const void *aarch_mte, + int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARM_TAGGED_ADDR_CTRL, - aarch_mte, - size); + NOTE_NAME_LINUX, NT_ARM_TAGGED_ADDR_CTRL, + aarch_mte, size); } char * @@ -13072,11 +12831,9 @@ elfcore_write_aarch_ssve (bfd *abfd, const void *aarch_ssve, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARM_SSVE, - aarch_ssve, - size); + NOTE_NAME_LINUX, NT_ARM_SSVE, + aarch_ssve, size); } char * @@ -13086,11 +12843,9 @@ elfcore_write_aarch_za (bfd *abfd, const void *aarch_za, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARM_ZA, - aarch_za, - size); + NOTE_NAME_LINUX, NT_ARM_ZA, + aarch_za, size); } /* Write the buffer of zt register values in aarch_zt (length SIZE) into @@ -13105,11 +12860,9 @@ elfcore_write_aarch_zt (bfd *abfd, const void *aarch_zt, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARM_ZT, - aarch_zt, - size); + NOTE_NAME_LINUX, NT_ARM_ZT, + aarch_zt, size); } /* Write the buffer of GCS register values in AARCH_GCS (length SIZE) into @@ -13121,8 +12874,7 @@ static char * elfcore_write_aarch_gcs (bfd *abfd, char *buf, int *bufsiz, const void *aarch_gcs, int size) { - const char *note_name = "LINUX"; - return elfcore_write_note (abfd, buf, bufsiz, note_name, NT_ARM_GCS, + return elfcore_write_note (abfd, buf, bufsiz, NOTE_NAME_LINUX, NT_ARM_GCS, aarch_gcs, size); } @@ -13133,9 +12885,8 @@ elfcore_write_arc_v2 (bfd *abfd, const void *arc_v2, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_ARC_V2, arc_v2, size); + NOTE_NAME_LINUX, NT_ARC_V2, arc_v2, size); } char * @@ -13145,9 +12896,8 @@ elfcore_write_loongarch_cpucfg (bfd *abfd, const void *loongarch_cpucfg, int size) { - char *note_name = "LINUX"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_LARCH_CPUCFG, + NOTE_NAME_LINUX, NT_LARCH_CPUCFG, loongarch_cpucfg, size); } @@ -13158,9 +12908,9 @@ elfcore_write_loongarch_lbt (bfd *abfd, 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); + NOTE_NAME_LINUX, NT_LARCH_LBT, + loongarch_lbt, size); } char * @@ -13170,9 +12920,9 @@ elfcore_write_loongarch_lsx (bfd *abfd, 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); + NOTE_NAME_LINUX, NT_LARCH_LSX, + loongarch_lsx, size); } char * @@ -13182,9 +12932,9 @@ elfcore_write_loongarch_lasx (bfd *abfd, 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); + NOTE_NAME_LINUX, NT_LARCH_LASX, + loongarch_lasx, size); } /* Write the buffer of csr values in CSRS (length SIZE) into the note @@ -13199,9 +12949,8 @@ elfcore_write_riscv_csr (bfd *abfd, const void *csrs, int size) { - const char *note_name = "GDB"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_RISCV_CSR, csrs, size); + NOTE_NAME_GDB, NT_RISCV_CSR, csrs, size); } /* Write the target description (a string) pointed to by TDESC, length @@ -13216,9 +12965,8 @@ elfcore_write_gdb_tdesc (bfd *abfd, const void *tdesc, int size) { - const char *note_name = "GDB"; return elfcore_write_note (abfd, buf, bufsiz, - note_name, NT_GDB_TDESC, tdesc, size); + NOTE_NAME_GDB, NT_GDB_TDESC, tdesc, size); } char * @@ -13229,110 +12977,73 @@ elfcore_write_register_note (bfd *abfd, const void *data, int size) { - if (strcmp (section, ".reg2") == 0) - return elfcore_write_prfpreg (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-xfp") == 0) - return elfcore_write_prxfpreg (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-xstate") == 0) - return elfcore_write_xstatereg (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-x86-segbases") == 0) - return elfcore_write_x86_segbases (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ssp") == 0) - return elfcore_write_sspreg (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-vmx") == 0) - return elfcore_write_ppc_vmx (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-vsx") == 0) - return elfcore_write_ppc_vsx (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-tar") == 0) - return elfcore_write_ppc_tar (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-ppr") == 0) - return elfcore_write_ppc_ppr (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-dscr") == 0) - return elfcore_write_ppc_dscr (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-ebb") == 0) - return elfcore_write_ppc_ebb (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-pmu") == 0) - return elfcore_write_ppc_pmu (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-tm-cgpr") == 0) - return elfcore_write_ppc_tm_cgpr (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-tm-cfpr") == 0) - return elfcore_write_ppc_tm_cfpr (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-tm-cvmx") == 0) - return elfcore_write_ppc_tm_cvmx (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-tm-cvsx") == 0) - return elfcore_write_ppc_tm_cvsx (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-tm-spr") == 0) - return elfcore_write_ppc_tm_spr (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-tm-ctar") == 0) - return elfcore_write_ppc_tm_ctar (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-tm-cppr") == 0) - return elfcore_write_ppc_tm_cppr (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-ppc-tm-cdscr") == 0) - return elfcore_write_ppc_tm_cdscr (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-high-gprs") == 0) - return elfcore_write_s390_high_gprs (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-timer") == 0) - return elfcore_write_s390_timer (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-todcmp") == 0) - return elfcore_write_s390_todcmp (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-todpreg") == 0) - return elfcore_write_s390_todpreg (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-ctrs") == 0) - return elfcore_write_s390_ctrs (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-prefix") == 0) - return elfcore_write_s390_prefix (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-last-break") == 0) - return elfcore_write_s390_last_break (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-system-call") == 0) - return elfcore_write_s390_system_call (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-tdb") == 0) - return elfcore_write_s390_tdb (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-vxrs-low") == 0) - return elfcore_write_s390_vxrs_low (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-vxrs-high") == 0) - return elfcore_write_s390_vxrs_high (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-gs-cb") == 0) - return elfcore_write_s390_gs_cb (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-s390-gs-bc") == 0) - return elfcore_write_s390_gs_bc (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-arm-vfp") == 0) - return elfcore_write_arm_vfp (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-aarch-tls") == 0) - return elfcore_write_aarch_tls (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-aarch-hw-break") == 0) - return elfcore_write_aarch_hw_break (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-aarch-hw-watch") == 0) - return elfcore_write_aarch_hw_watch (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-aarch-sve") == 0) - return elfcore_write_aarch_sve (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-aarch-pauth") == 0) - return elfcore_write_aarch_pauth (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-aarch-mte") == 0) - return elfcore_write_aarch_mte (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-aarch-ssve") == 0) - return elfcore_write_aarch_ssve (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-aarch-za") == 0) - return elfcore_write_aarch_za (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-aarch-zt") == 0) - return elfcore_write_aarch_zt (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-aarch-gcs") == 0) - return elfcore_write_aarch_gcs (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".reg-arc-v2") == 0) - return elfcore_write_arc_v2 (abfd, buf, bufsiz, data, size); - if (strcmp (section, ".gdb-tdesc") == 0) - 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); - if (strcmp (section, PSEUDO_SECTION_NAME_I386_TLS) == 0) - return elfcore_write_i386_tls (abfd, buf, bufsiz, data, size); + static const struct + { + const char * section_name; + char * (*writer) (bfd *, char *, int *, const void *, int); + } + note_writers [] = + { + { NOTE_PSEUDO_SECTION_AARCH_GCS, elfcore_write_aarch_gcs}, + { NOTE_PSEUDO_SECTION_AARCH_HW_BREAK, elfcore_write_aarch_hw_break}, + { NOTE_PSEUDO_SECTION_AARCH_HW_WATCH, elfcore_write_aarch_hw_watch}, + { NOTE_PSEUDO_SECTION_AARCH_MTE, elfcore_write_aarch_mte}, + { NOTE_PSEUDO_SECTION_AARCH_PAUTH, elfcore_write_aarch_pauth}, + { NOTE_PSEUDO_SECTION_AARCH_SSVE, elfcore_write_aarch_ssve}, + { NOTE_PSEUDO_SECTION_AARCH_SVE, elfcore_write_aarch_sve}, + { NOTE_PSEUDO_SECTION_AARCH_TLS, elfcore_write_aarch_tls}, + { NOTE_PSEUDO_SECTION_AARCH_ZA, elfcore_write_aarch_za}, + { NOTE_PSEUDO_SECTION_AARCH_ZT, elfcore_write_aarch_zt}, + { NOTE_PSEUDO_SECTION_ARC_V2, elfcore_write_arc_v2}, + { NOTE_PSEUDO_SECTION_ARM_VFP, elfcore_write_arm_vfp}, + { NOTE_PSEUDO_SECTION_I386_TLS, elfcore_write_i386_tls}, + { NOTE_PSEUDO_SECTION_LOONGARCH_CPUCFG, elfcore_write_loongarch_cpucfg}, + { NOTE_PSEUDO_SECTION_LOONGARCH_LASX, elfcore_write_loongarch_lasx}, + { NOTE_PSEUDO_SECTION_LOONGARCH_LBT, elfcore_write_loongarch_lbt}, + { NOTE_PSEUDO_SECTION_LOONGARCH_LSX, elfcore_write_loongarch_lsx}, + { NOTE_PSEUDO_SECTION_PPC_DSCR, elfcore_write_ppc_dscr}, + { NOTE_PSEUDO_SECTION_PPC_EBB, elfcore_write_ppc_ebb}, + { NOTE_PSEUDO_SECTION_PPC_PMU, elfcore_write_ppc_pmu}, + { NOTE_PSEUDO_SECTION_PPC_PPR, elfcore_write_ppc_ppr}, + { NOTE_PSEUDO_SECTION_PPC_TAR, elfcore_write_ppc_tar}, + { NOTE_PSEUDO_SECTION_PPC_TM_CDSCR, elfcore_write_ppc_tm_cdscr}, + { NOTE_PSEUDO_SECTION_PPC_TM_CFPR, elfcore_write_ppc_tm_cfpr}, + { NOTE_PSEUDO_SECTION_PPC_TM_CGPR, elfcore_write_ppc_tm_cgpr}, + { NOTE_PSEUDO_SECTION_PPC_TM_CPPR, elfcore_write_ppc_tm_cppr}, + { NOTE_PSEUDO_SECTION_PPC_TM_CTAR, elfcore_write_ppc_tm_ctar}, + { NOTE_PSEUDO_SECTION_PPC_TM_CVMX, elfcore_write_ppc_tm_cvmx}, + { NOTE_PSEUDO_SECTION_PPC_TM_CVSX, elfcore_write_ppc_tm_cvsx}, + { NOTE_PSEUDO_SECTION_PPC_TM_SPR, elfcore_write_ppc_tm_spr}, + { NOTE_PSEUDO_SECTION_PPC_VMX, elfcore_write_ppc_vmx}, + { NOTE_PSEUDO_SECTION_PPC_VSX, elfcore_write_ppc_vsx}, + { NOTE_PSEUDO_SECTION_REG2, elfcore_write_prfpreg}, + { NOTE_PSEUDO_SECTION_RISCV_CSR, elfcore_write_riscv_csr}, + { NOTE_PSEUDO_SECTION_S390_CTRS, elfcore_write_s390_ctrs}, + { NOTE_PSEUDO_SECTION_S390_GS_BC, elfcore_write_s390_gs_bc}, + { NOTE_PSEUDO_SECTION_S390_GS_CB, elfcore_write_s390_gs_cb}, + { NOTE_PSEUDO_SECTION_S390_HIGH_GPRS, elfcore_write_s390_high_gprs}, + { NOTE_PSEUDO_SECTION_S390_LAST_BREAK, elfcore_write_s390_last_break}, + { NOTE_PSEUDO_SECTION_S390_PREFIX, elfcore_write_s390_prefix}, + { NOTE_PSEUDO_SECTION_S390_SYSTEM_CALL, elfcore_write_s390_system_call}, + { NOTE_PSEUDO_SECTION_S390_TDB, elfcore_write_s390_tdb}, + { NOTE_PSEUDO_SECTION_S390_TIMER, elfcore_write_s390_timer}, + { NOTE_PSEUDO_SECTION_S390_TODCMP, elfcore_write_s390_todcmp}, + { NOTE_PSEUDO_SECTION_S390_TODPREG, elfcore_write_s390_todpreg}, + { NOTE_PSEUDO_SECTION_S390_VXRS_HIGH, elfcore_write_s390_vxrs_high}, + { NOTE_PSEUDO_SECTION_S390_VXRS_LOW, elfcore_write_s390_vxrs_low}, + { NOTE_PSEUDO_SECTION_SSP, elfcore_write_sspreg}, + { NOTE_PSEUDO_SECTION_TDESC, elfcore_write_gdb_tdesc}, + { NOTE_PSEUDO_SECTION_X86_SEGBASES, elfcore_write_x86_segbases}, + { NOTE_PSEUDO_SECTION_XFP, elfcore_write_prxfpreg}, + { NOTE_PSEUDO_SECTION_XSTATE, elfcore_write_xstatereg} /* NB/ No comma. */ + }; + + int i; + + for (i = ARRAY_SIZE (note_writers); i--;) + if (streq (section, note_writers[i].section_name)) + return note_writers[i].writer (abfd, buf, bufsiz, data, size); + return NULL; } @@ -13341,7 +13052,7 @@ elfcore_write_file_note (bfd *obfd, char *note_data, int *note_size, const void *buf, int bufsiz) { return elfcore_write_note (obfd, note_data, note_size, - "CORE", NT_FILE, buf, bufsiz); + NOTE_NAME_CORE, NT_FILE, buf, bufsiz); } static bool @@ -13400,13 +13111,13 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset, grokers[] = { GROKER_ELEMENT ("", elfcore_grok_note), - GROKER_ELEMENT ("FreeBSD", elfcore_grok_freebsd_note), + GROKER_ELEMENT (NOTE_NAME_FREEBSD, elfcore_grok_freebsd_note), GROKER_ELEMENT ("NetBSD-CORE", elfcore_grok_netbsd_note), GROKER_ELEMENT ("OpenBSD", elfcore_grok_openbsd_note), GROKER_ELEMENT ("QNX", elfcore_grok_nto_note), GROKER_ELEMENT ("SPU/", elfcore_grok_spu_note), GROKER_ELEMENT ("GNU", elfobj_grok_gnu_note), - GROKER_ELEMENT ("CORE", elfcore_grok_solaris_note) + GROKER_ELEMENT (NOTE_NAME_CORE, elfcore_grok_solaris_note) }; #undef GROKER_ELEMENT int i; |