public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix mach setting when reading core file
@ 2005-01-24 15:12 Orjan Friberg
  2005-02-14 19:22 ` Orjan Friberg
  0 siblings, 1 reply; 4+ messages in thread
From: Orjan Friberg @ 2005-01-24 15:12 UTC (permalink / raw)
  To: binutils; +Cc: gdb-patches

(Cross-posting to gdb-patches since the discussion originates from there.)

The CRISv32 binutils port exposed a problem concerning the mach setting when 
reading a core file.  The exposure results from checking the bfd's mach setting 
before touching prstatus and psinfo (see cris_elf_grok_prstatus and 
cris_elf_grok_psinfo in bfd/elf32-cris.c).

The problem is that the call to bfd_default_set_arch_mach in elf_core_file_p (in 
elfcore.h) will select the default mach for that arch, and this call immediately 
precedes the reading of the core file's program headers.  As a consequence, if 
the default mach is not the correct one cris_elf_grok_prstatus and 
cris_elf_grok_psinfo will not recognize the core file.

The patch below simply moves the call to the elf backend to before processing 
the program headers.  This way we can let the backend set the correct machine 
like they all do already.  (Of course, for this to have any real effect, the 
e_flags value must be set correctly in the core file.)  I checked the other 
ports' elf_backend_object_p implementations and AFAICT, they will be unaffected 
by moving the call.

FWIW: No regressions on i386 and CRIS when running the gdb.base testsuite.


2005-01-24  Orjan Friberg  <orjanf@axis.com>

     * elfcore.h (elf_core_file_p): Move the call to elf_backend_object_p
     to allow the correct machine to be set before processing the program
     headers.


  Index: elfcore.h
===================================================================
RCS file: /cvs/src/src/bfd/elfcore.h,v
retrieving revision 1.20
diff -u -p -r1.20 elfcore.h
--- elfcore.h    7 Aug 2003 08:38:09 -0000    1.20
+++ elfcore.h    14 Jan 2005 17:03:02 -0000
@@ -214,6 +214,15 @@ elf_core_file_p (bfd *abfd)
      goto fail;
      }

+  /* Let the backend double check the format and override global
+     information.  We do this before processing the program headers
+     to allow the correct machine (as opposed to just the default
+     machine) to be set, making it possible for grok_prstatus and
+     grok_psinfo to rely on the mach setting.  */
+  if (ebd->elf_backend_object_p
+      && (! (*ebd->elf_backend_object_p) (abfd)))
+    goto wrong;
+
    /* Process each program header.  */
    for (phindex = 0; phindex < i_ehdrp->e_phnum; ++phindex)
      if (! bfd_section_from_phdr (abfd, i_phdrp + phindex, (int) phindex))
@@ -222,12 +231,6 @@ elf_core_file_p (bfd *abfd)
    /* Save the entry point from the ELF header.  */
    bfd_get_start_address (abfd) = i_ehdrp->e_entry;

-  /* Let the backend double check the format and override global
-     information.  */
-  if (ebd->elf_backend_object_p
-      && (! (*ebd->elf_backend_object_p) (abfd)))
-    goto wrong;
-
    bfd_preserve_finish (abfd, &preserve);
    return abfd->xvec;


-- 
Orjan Friberg
Axis Communications

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix mach setting when reading core file
  2005-01-24 15:12 [PATCH] Fix mach setting when reading core file Orjan Friberg
@ 2005-02-14 19:22 ` Orjan Friberg
  2005-02-14 22:10   ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Orjan Friberg @ 2005-02-14 19:22 UTC (permalink / raw)
  To: binutils; +Cc: gdb-patches

Orjan Friberg wrote:
> 
> 2005-01-24  Orjan Friberg  <orjanf@axis.com>
> 
>     * elfcore.h (elf_core_file_p): Move the call to elf_backend_object_p
>     to allow the correct machine to be set before processing the program
>     headers.

Ping.

-- 
Orjan Friberg
Axis Communications

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix mach setting when reading core file
  2005-02-14 19:22 ` Orjan Friberg
@ 2005-02-14 22:10   ` Nick Clifton
  2005-02-15 16:56     ` Orjan Friberg
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2005-02-14 22:10 UTC (permalink / raw)
  To: Orjan Friberg; +Cc: binutils, gdb-patches

Hi Orjan,

>> 2005-01-24  Orjan Friberg  <orjanf@axis.com>
>>
>>     * elfcore.h (elf_core_file_p): Move the call to elf_backend_object_p
>>     to allow the correct machine to be set before processing the program
>>     headers.

Approved and applied.

> Ping.

Sorry for not responding to your original posting.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix mach setting when reading core file
  2005-02-14 22:10   ` Nick Clifton
@ 2005-02-15 16:56     ` Orjan Friberg
  0 siblings, 0 replies; 4+ messages in thread
From: Orjan Friberg @ 2005-02-15 16:56 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, gdb-patches

Nick Clifton wrote:
> 
> Approved and applied.

Thanks a lot.

> Sorry for not responding to your original posting.

No problem at all.

-- 
Orjan Friberg
Axis Communications

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-02-15 10:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-24 15:12 [PATCH] Fix mach setting when reading core file Orjan Friberg
2005-02-14 19:22 ` Orjan Friberg
2005-02-14 22:10   ` Nick Clifton
2005-02-15 16:56     ` Orjan Friberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).