This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Handle loading improper core files gracefully in the mips backend.
- From: Pedro Alves <palves at redhat dot com>
- To: "Maciej W. Rozycki" <macro at imgtec dot com>, Luis Machado <lgustavo at codesourcery dot com>
- Cc: gdb-patches at sourceware dot org, jan dot kratochvil at redhat dot com
- Date: Tue, 12 Jan 2016 19:08:22 +0000
- Subject: Re: [PATCH] Handle loading improper core files gracefully in the mips backend.
- Authentication-results: sourceware.org; auth=none
- References: <1452277948-25292-1-git-send-email-lgustavo at codesourcery dot com> <alpine dot DEB dot 2 dot 00 dot 1601090245560 dot 5958 at tp dot orcam dot me dot uk> <5693CE90 dot 1060709 at codesourcery dot com> <5694F5BC dot 3050904 at redhat dot com> <5694FEB8 dot 10406 at codesourcery dot com> <56950952 dot 2030504 at redhat dot com> <56951F29 dot 7070000 at codesourcery dot com> <alpine dot DEB dot 2 dot 00 dot 1601121710020 dot 5958 at tp dot orcam dot me dot uk>
On 01/12/2016 06:30 PM, Maciej W. Rozycki wrote:
> On Tue, 12 Jan 2016, Luis Machado wrote:
>> Pedro Alves wrote:
>
>>> I also wonder whether the bfd arch detection couldn't be always
>>> compiled in, at least for elf. Why does bfd fail to detect that this
>>> is an bfd_arch_i386 file in the first place?
>
> The mapping between `e_machine' and `bfd_architecture' is only provided
> by individual BFD ELF target backends, via the ELF_MACHINE_CODE and
> ELF_ARCH macros.
Thanks. In principle, it sounds to me that at least the
ELF_MACHINE_CODE -> bfd_architecture sniffing bits could be
factored out and always be present. But, that might not be practical.
>> Sounds like we have a couple issues. The mips backend not handling weird
>> abi/isa combinations and GDB not preventing clearly incompatible core files
>> from proceeding further into processing in the target's backend?
>
> I have given it some thought and came to a conclusion that we should at
> least try being consistent. Which means I think we should not try to
> handle files within the MIPS backend which would not be passed in the
> first place in an `--enable-targets=all' configuration. Rather than
> checking `e_machine' explicitly I'd be leaning towards using BFD to detect
> such a situation though, perhaps by using a condition like
>
> if (info.abfd != NULL
> && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour
> && bfd_get_arch (info.abfd) != bfd_arch_mips)
> return NULL;
>
> (maybe with an additional error message) though ultimately I think it
> would make sense to define different BFD architecture codes for file
> formats which by definition carry no architecture information and for ones
> that do but are not supported.
Agreed. Seems like that could be the job of bfd_arch_obscure -- it's used
as default/unhandled case in some formats that do have architecture
information. Though it isn't used throughout all bfd backends.
> Then for the formers we could continue
> selecting the target using the current algorithm and for the latters we'd
> just reject them as incompatible with the given backend -- all somewhere
> in generic code so that individual target backends do not have to repeat
> it all.
>
> As to ABI, ISA, etc. settings -- these are internal to the MIPS backend,
> so its the backend's job to sanitise them.
/me nods.
Thanks,
Pedro Alves