]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Copy ELF header flags from executable to core file.
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 4 Mar 2020 18:43:43 +0000 (10:43 -0800)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 23:47:42 +0000 (16:47 -0700)
gdb/fbsd-tdep.c

index 26e1ea5c12b97635941cf2531385f5b3a91840a0..026232f05ea899d6e56689b14e04f1bccf3f6fc4 100644 (file)
@@ -697,12 +697,16 @@ static gdb::unique_xmalloc_ptr<char>
 fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
 {
   gdb::unique_xmalloc_ptr<char> note_data;
-  Elf_Internal_Ehdr *i_ehdrp;
+  Elf_Internal_Ehdr *c_ehdrp, *e_ehdrp;
   struct thread_info *curr_thr, *signalled_thr;
 
   /* Put a "FreeBSD" label in the ELF header.  */
-  i_ehdrp = elf_elfheader (obfd);
-  i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
+  c_ehdrp = elf_elfheader (obfd);
+  c_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
+
+  bfd *exec_bfd = current_program_space->exec_bfd ();
+  if (exec_bfd != NULL && (e_ehdrp = elf_elfheader (exec_bfd)) != NULL)
+    c_ehdrp->e_flags = e_ehdrp->e_flags;
 
   gdb_assert (gdbarch_iterate_over_regset_sections_p (gdbarch));