From a4f89e9870e5ed92527bb6879187c5cc28e98001 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 4 Mar 2020 10:43:43 -0800 Subject: [PATCH] Copy ELF header flags from executable to core file. --- gdb/fbsd-tdep.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 26e1ea5c12b..026232f05ea 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -697,12 +697,16 @@ static gdb::unique_xmalloc_ptr fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) { gdb::unique_xmalloc_ptr 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)); -- 2.47.2