/* Allocate and clear an extra byte at the end, to prevent crashes
in case the string table is not terminated. */
if (shstrtabsize + 1 <= 1
+ || shstrtabsize > bfd_get_file_size (abfd)
|| bfd_seek (abfd, offset, SEEK_SET) != 0
|| (shstrtab = (bfd_byte *) bfd_alloc (abfd, shstrtabsize + 1)) == NULL)
shstrtab = NULL;
bfd_alloc2 (abfd, num_group, sizeof (Elf_Internal_Shdr *));
if (elf_tdata (abfd)->group_sect_ptr == NULL)
return FALSE;
- memset (elf_tdata (abfd)->group_sect_ptr, 0, num_group * sizeof (Elf_Internal_Shdr *));
+ memset (elf_tdata (abfd)->group_sect_ptr, 0,
+ num_group * sizeof (Elf_Internal_Shdr *));
num_group = 0;
for (i = 0; i < shnum; i++)
|= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
break;
}
- if (idx >= shnum)
+ if (idx < shnum)
+ {
+ dest->shdr = elf_elfsections (abfd)[idx];
+ /* PR binutils/23199: All sections in a
+ section group should be marked with
+ SHF_GROUP. But some tools generate
+ broken objects without SHF_GROUP. Fix
+ them up here. */
+ dest->shdr->sh_flags |= SHF_GROUP;
+ }
+ if (idx >= shnum
+ || dest->shdr->sh_type == SHT_GROUP)
{
_bfd_error_handler
- (_("%pB: invalid SHT_GROUP entry"), abfd);
- idx = 0;
+ (_("%pB: invalid entry in SHT_GROUP section [%u]"),
+ abfd, i);
+ dest->shdr = NULL;
}
- dest->shdr = elf_elfsections (abfd)[idx];
}
}
}
idx = (Elf_Internal_Group *) shdr->contents;
n_elt = shdr->sh_size / 4;
while (--n_elt != 0)
- if ((s = (++idx)->shdr->bfd_section) != NULL
+ if ((++idx)->shdr != NULL
+ && (s = idx->shdr->bfd_section) != NULL
&& elf_next_in_group (s) != NULL)
break;
if (n_elt != 0)
if (vernum == 0)
version_string = "";
- else if (vernum == 1)
+ else if (vernum == 1
+ && (vernum > elf_tdata (abfd)->cverdefs
+ || (elf_tdata (abfd)->verdef[0].vd_flags
+ == VER_FLG_BASE)))
version_string = "Base";
else if (vernum <= elf_tdata (abfd)->cverdefs)
version_string =
{
Elf_Internal_Verneed *t;
- version_string = "";
+ version_string = _("<corrupt>");
for (t = elf_tdata (abfd)->verref;
t != NULL;
t = t->vn_nextref)
if (++ nesting > 3)
{
/* PR17512: A corrupt ELF binary might contain a recursive group of
- sections, with each the string indicies pointing to the next in the
+ sections, with each the string indices pointing to the next in the
loop. Detect this here, by refusing to load a section that we are
already in the process of loading. We only trigger this test if
we have nested at least three sections deep as normal ELF binaries
{
elf_symbol_type *type_ptr;
+ if (sym == NULL)
+ return FALSE;
+
if ((sym->flags & BSF_SECTION_SYM) == 0)
return FALSE;
+ if (sym->section == NULL)
+ return TRUE;
+
type_ptr = elf_symbol_from (abfd, sym);
return ((type_ptr != NULL
&& type_ptr->internal_elf_sym.st_shndx != 0
&& bfd_is_abs_section (sym->section))
|| !(sym->section->owner == abfd
- || (sym->section->output_section->owner == abfd
+ || (sym->section->output_section != NULL
+ && sym->section->output_section->owner == abfd
&& sym->section->output_offset == 0)
|| bfd_is_abs_section (sym->section)));
}
{
if (TOEND (sec2))
{
- /* If the indicies are the same, do not return 0
+ /* If the indices are the same, do not return 0
here, but continue to try the next comparison. */
if (sec1->target_index - sec2->target_index != 0)
return sec1->target_index - sec2->target_index;
if (! abfd->output_has_begun
&& ! _bfd_elf_compute_section_file_positions (abfd, NULL))
return FALSE;
+ /* Do not rewrite ELF data when the BFD has been opened for update.
+ abfd->output_has_begun was set to TRUE on opening, so creation of new
+ sections, and modification of existing section sizes was restricted.
+ This means the ELF header, program headers and section headers can't have
+ changed.
+ If the contents of any sections has been modified, then those changes have
+ already been written to the BFD. */
+ else if (abfd->direction == both_direction)
+ {
+ BFD_ASSERT (abfd->output_has_begun);
+ return TRUE;
+ }
i_shdrp = elf_elfsections (abfd);
: segment->p_vaddr != section->vma) \
|| (strcmp (bfd_get_section_name (ibfd, section), ".dynamic") \
== 0)) \
- && !section->segment_mark)
+ && (segment->p_type != PT_LOAD || !section->segment_mark))
/* If the output section of a section in the input segment is NULL,
it is removed from the corresponding output segment. */
asection **sections;
asection *output_section;
unsigned int isec;
- bfd_vma matching_lma;
- bfd_vma suggested_lma;
+ asection *matching_lma;
+ asection *suggested_lma;
unsigned int j;
bfd_size_type amt;
asection *first_section;
- bfd_boolean first_matching_lma;
- bfd_boolean first_suggested_lma;
if (segment->p_type == PT_NULL)
continue;
we have completely filled the segment, and there is nothing
more to do. */
isec = 0;
- matching_lma = 0;
- suggested_lma = 0;
- first_matching_lma = TRUE;
- first_suggested_lma = TRUE;
+ matching_lma = NULL;
+ suggested_lma = NULL;
for (section = first_section, j = 0;
section != NULL;
&& !bed->want_p_paddr_set_to_zero
&& isec == 0
&& output_section->lma != 0
- && output_section->vma == (segment->p_vaddr
- + (map->includes_filehdr
- ? iehdr->e_ehsize
- : 0)
- + (map->includes_phdrs
- ? (iehdr->e_phnum
- * iehdr->e_phentsize)
- : 0)))
+ && (align_power (segment->p_vaddr
+ + (map->includes_filehdr
+ ? iehdr->e_ehsize : 0)
+ + (map->includes_phdrs
+ ? iehdr->e_phnum * iehdr->e_phentsize
+ : 0),
+ output_section->alignment_power)
+ == output_section->vma))
map->p_paddr = segment->p_vaddr;
/* Match up the physical address of the segment with the
|| (bed->want_p_paddr_set_to_zero
&& IS_CONTAINED_BY_VMA (output_section, segment)))
{
- if (first_matching_lma || output_section->lma < matching_lma)
- {
- matching_lma = output_section->lma;
- first_matching_lma = FALSE;
- }
+ if (matching_lma == NULL
+ || output_section->lma < matching_lma->lma)
+ matching_lma = output_section;
/* We assume that if the section fits within the segment
then it does not overlap any other section within that
segment. */
map->sections[isec++] = output_section;
}
- else if (first_suggested_lma)
- {
- suggested_lma = output_section->lma;
- first_suggested_lma = FALSE;
- }
+ else if (suggested_lma == NULL)
+ suggested_lma = output_section;
if (j == section_count)
break;
if (p_paddr_valid
&& !bed->want_p_paddr_set_to_zero
- && matching_lma != map->p_paddr
+ && matching_lma->lma != map->p_paddr
&& !map->includes_filehdr
&& !map->includes_phdrs)
/* There is some padding before the first section in the
segment. So, we must account for that in the output
segment's vma. */
- map->p_vaddr_offset = matching_lma - map->p_paddr;
+ map->p_vaddr_offset = matching_lma->lma - map->p_paddr;
free (sections);
continue;
}
else
{
- if (!first_matching_lma)
- {
- /* At least one section fits inside the current segment.
- Keep it, but modify its physical address to match the
- LMA of the first section that fitted. */
- map->p_paddr = matching_lma;
- }
- else
- {
- /* None of the sections fitted inside the current segment.
- Change the current segment's physical address to match
- the LMA of the first section. */
- map->p_paddr = suggested_lma;
- }
+ /* Change the current segment's physical address to match
+ the LMA of the first section that fitted, or if no
+ section fitted, the first section. */
+ if (matching_lma == NULL)
+ matching_lma = suggested_lma;
+
+ map->p_paddr = matching_lma->lma;
/* Offset the segment physical address from the lma
to allow for space taken up by elf headers. */
- if (map->includes_filehdr)
+ if (map->includes_phdrs)
{
- if (map->p_paddr >= iehdr->e_ehsize)
- map->p_paddr -= iehdr->e_ehsize;
- else
- {
- map->includes_filehdr = FALSE;
- map->includes_phdrs = FALSE;
- }
+ map->p_paddr -= iehdr->e_phnum * iehdr->e_phentsize;
+
+ /* iehdr->e_phnum is just an estimate of the number
+ of program headers that we will need. Make a note
+ here of the number we used and the segment we chose
+ to hold these headers, so that we can adjust the
+ offset when we know the correct value. */
+ phdr_adjust_num = iehdr->e_phnum;
+ phdr_adjust_seg = map;
}
- if (map->includes_phdrs)
+ if (map->includes_filehdr)
{
- if (map->p_paddr >= iehdr->e_phnum * iehdr->e_phentsize)
- {
- map->p_paddr -= iehdr->e_phnum * iehdr->e_phentsize;
-
- /* iehdr->e_phnum is just an estimate of the number
- of program headers that we will need. Make a note
- here of the number we used and the segment we chose
- to hold these headers, so that we can adjust the
- offset when we know the correct value. */
- phdr_adjust_num = iehdr->e_phnum;
- phdr_adjust_seg = map;
- }
- else
- map->includes_phdrs = FALSE;
+ bfd_vma align = (bfd_vma) 1 << matching_lma->alignment_power;
+ map->p_paddr -= iehdr->e_ehsize;
+ /* We've subtracted off the size of headers from the
+ first section lma, but there may have been some
+ alignment padding before that section too. Try to
+ account for that by adjusting the segment lma down to
+ the same alignment. */
+ if (segment->p_align != 0 && segment->p_align < align)
+ align = segment->p_align;
+ map->p_paddr &= -align;
}
}
do
{
map->count = 0;
- suggested_lma = 0;
- first_suggested_lma = TRUE;
+ suggested_lma = NULL;
/* Fill the current segment with sections that fit. */
for (j = 0; j < section_count; j++)
/* If the first section in a segment does not start at
the beginning of the segment, then something is
wrong. */
- if (output_section->lma
- != (map->p_paddr
- + (map->includes_filehdr ? iehdr->e_ehsize : 0)
- + (map->includes_phdrs
- ? iehdr->e_phnum * iehdr->e_phentsize
- : 0)))
+ if (align_power (map->p_paddr
+ + (map->includes_filehdr
+ ? iehdr->e_ehsize : 0)
+ + (map->includes_phdrs
+ ? iehdr->e_phnum * iehdr->e_phentsize
+ : 0),
+ output_section->alignment_power)
+ != output_section->lma)
abort ();
}
else
|| (prev_sec->lma + prev_sec->size
> output_section->lma))
{
- if (first_suggested_lma)
- {
- suggested_lma = output_section->lma;
- first_suggested_lma = FALSE;
- }
+ if (suggested_lma == NULL)
+ suggested_lma = output_section;
continue;
}
map->sections[map->count++] = output_section;
++isec;
sections[j] = NULL;
- section->segment_mark = TRUE;
- }
- else if (first_suggested_lma)
- {
- suggested_lma = output_section->lma;
- first_suggested_lma = FALSE;
+ if (segment->p_type == PT_LOAD)
+ section->segment_mark = TRUE;
}
+ else if (suggested_lma == NULL)
+ suggested_lma = output_section;
}
BFD_ASSERT (map->count > 0);
map->p_type = segment->p_type;
map->p_flags = segment->p_flags;
map->p_flags_valid = 1;
- map->p_paddr = suggested_lma;
+ map->p_paddr = suggested_lma->lma;
map->p_paddr_valid = p_paddr_valid;
map->includes_filehdr = 0;
map->includes_phdrs = 0;
if (count > phdr_adjust_num)
phdr_adjust_seg->p_paddr
-= (count - phdr_adjust_num) * iehdr->e_phentsize;
+
+ for (map = map_first; map != NULL; map = map->next)
+ if (map->p_type == PT_PHDR)
+ {
+ bfd_vma adjust
+ = phdr_adjust_seg->includes_filehdr ? iehdr->e_ehsize : 0;
+ map->p_paddr = phdr_adjust_seg->p_paddr + adjust;
+ break;
+ }
}
#undef SEGMENT_END
Elf_Internal_Shdr *this_hdr;
asection *first_section = NULL;
asection *lowest_section;
+ bfd_boolean no_contents = TRUE;
/* Compute how many sections are in this segment. */
for (section = ibfd->sections, section_count = 0;
{
if (first_section == NULL)
first_section = section;
+ if (elf_section_type (section) != SHT_NOBITS)
+ no_contents = FALSE;
section_count++;
}
}
}
if (map->includes_filehdr && lowest_section != NULL)
- /* We need to keep the space used by the headers fixed. */
- map->header_size = lowest_section->vma - segment->p_vaddr;
+ {
+ /* Try to keep the space used by the headers plus any
+ padding fixed. If there are sections with file contents
+ in this segment then the lowest sh_offset is the best
+ guess. Otherwise the segment only has file contents for
+ the headers, and p_filesz is the best guess. */
+ if (no_contents)
+ map->header_size = segment->p_filesz;
+ else
+ map->header_size = lowest_section->filepos;
+ }
if (!map->includes_phdrs
&& !map->includes_filehdr
return TRUE;
}
-void
+bfd_boolean
_bfd_elf_no_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
arelent *cache_ptr ATTRIBUTE_UNUSED,
Elf_Internal_Rela *dst ATTRIBUTE_UNUSED)
{
abort ();
+ return FALSE;
}
/* Try to convert a non-ELF reloc into an ELF one. */
return elfcore_make_note_pseudosection (abfd, ".reg-ppc-vsx", note);
}
+static bfd_boolean
+elfcore_grok_ppc_tar (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tar", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_ppr (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-ppr", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_dscr (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-dscr", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_ebb (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-ebb", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_pmu (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-pmu", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_tm_cgpr (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cgpr", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_tm_cfpr (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cfpr", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_tm_cvmx (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cvmx", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_tm_cvsx (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cvsx", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_tm_spr (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-spr", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_tm_ctar (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-ctar", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_tm_cppr (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cppr", note);
+}
+
+static bfd_boolean
+elfcore_grok_ppc_tm_cdscr (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-ppc-tm-cdscr", note);
+}
+
static bfd_boolean
elfcore_grok_s390_high_gprs (bfd *abfd, Elf_Internal_Note *note)
{
return elfcore_make_note_pseudosection (abfd, ".reg-aarch-hw-watch", note);
}
+static bfd_boolean
+elfcore_grok_aarch_sve (bfd *abfd, Elf_Internal_Note *note)
+{
+ return elfcore_make_note_pseudosection (abfd, ".reg-aarch-sve", note);
+}
+
#if defined (HAVE_PRPSINFO_T)
typedef prpsinfo_t elfcore_psinfo_t;
#if defined (HAVE_PRPSINFO32_T) /* Sparc64 cross Sparc32 */
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)
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_PRPSINFO:
case NT_PSINFO:
if (bed->elf_backend_grok_psinfo)
return buf;
}
+/* gcc-8 warns (*) on all the strncpy calls in this function about
+ possible string truncation. The "truncation" is not a bug. We
+ have an external representation of structs with fields that are not
+ necessarily NULL terminated and corresponding internal
+ representation fields that are one larger so that they can always
+ be NULL terminated.
+ gcc versions between 4.2 and 4.6 do not allow pragma control of
+ diagnostics inside functions, giving a hard error if you try to use
+ the finer control available with later versions.
+ gcc prior to 4.2 warns about diagnostic push and pop.
+ gcc-5, gcc-6 and gcc-7 warn that -Wstringop-truncation is unknown,
+ unless you also add #pragma GCC diagnostic ignored "-Wpragma".
+ (*) Depending on your system header files! */
+#if GCC_VERSION >= 8000
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wstringop-truncation"
+#endif
char *
elfcore_write_prpsinfo (bfd *abfd,
char *buf,
}
#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
-#if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T)
+# if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T)
if (bed->s->elfclass == ELFCLASS32)
{
-#if defined (HAVE_PSINFO32_T)
+# if defined (HAVE_PSINFO32_T)
psinfo32_t data;
int note_type = NT_PSINFO;
-#else
+# else
prpsinfo32_t data;
int note_type = NT_PRPSINFO;
-#endif
+# endif
memset (&data, 0, sizeof (data));
strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
"CORE", note_type, &data, sizeof (data));
}
else
-#endif
+# endif
{
-#if defined (HAVE_PSINFO_T)
+# if defined (HAVE_PSINFO_T)
psinfo_t data;
int note_type = NT_PSINFO;
-#else
+# else
prpsinfo_t data;
int note_type = NT_PRPSINFO;
-#endif
+# endif
memset (&data, 0, sizeof (data));
strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
free (buf);
return NULL;
}
+#if GCC_VERSION >= 8000
+# pragma GCC diagnostic pop
+#endif
char *
elfcore_write_linux_prpsinfo32
note_name, NT_PPC_VSX, ppc_vsx, size);
}
+char *
+elfcore_write_ppc_tar (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_ppr (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_dscr (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_ebb (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_pmu (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_tm_cgpr (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_tm_cfpr (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_tm_cvmx (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_tm_cvsx (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_tm_spr (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_tm_ctar (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_tm_cppr (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
+char *
+elfcore_write_ppc_tm_cdscr (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
static char *
elfcore_write_s390_high_gprs (bfd *abfd,
char *buf,
note_name, NT_ARM_HW_WATCH, aarch_hw_watch, size);
}
+char *
+elfcore_write_aarch_sve (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ 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);
+}
+
char *
elfcore_write_register_note (bfd *abfd,
char *buf,
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_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);
return NULL;
}
}
num_phdrs = elf_elfheader (abfd)->e_phnum;
- memcpy (phdrs, elf_tdata (abfd)->phdr,
- num_phdrs * sizeof (Elf_Internal_Phdr));
+ if (num_phdrs != 0)
+ memcpy (phdrs, elf_tdata (abfd)->phdr,
+ num_phdrs * sizeof (Elf_Internal_Phdr));
return num_phdrs;
}