public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* GDB Stub with ARM BE8 target.
@ 2022-05-30 23:03 Jon Wilson
  2022-05-31 14:38 ` Fwd: " Jon Wilson
  2022-06-01  8:55 ` Luis Machado
  0 siblings, 2 replies; 3+ messages in thread
From: Jon Wilson @ 2022-05-30 23:03 UTC (permalink / raw)
  To: gdb

I am trying to integrate a GDB stub with a ARM BE8 target. However, it 
would appear that using "set endian big" defaults to BE32 architecture. 
I cannot seem to find a way to have the debugger interpret memory 
according to the BE8 architecture. The only support for BE8 mode I can 
see seems to be for when using BE8 core dumps or processes 
(https://github.com/bminor/binutils-gdb/blob/9606310bbbf8a2d529b5c2aa71cac48a46f65869/gdb/arm-tdep.c#L9781). 
I can't seem to find any documentation on the topic (which is pretty 
forgivable given how niche it is).

I looked at handling the endianness in the stub itself (e.g. inverting 
the endianness of memory based on permissions), but given the code 
stream can contain both instructions (which should be little endian in 
BE8) as well as data (which should be interpretted as big endian), this 
is not possible.

Have I missed an option somewhere? If this support is missing, then how 
should it be added? Should it be handled in a similar way to how GDB 
handles ARM versus Thumb mode? 
(https://github.com/bminor/binutils-gdb/blob/9606310bbbf8a2d529b5c2aa71cac48a46f65869/gdb/arm-tdep.c#L10589)?

I'd be very grateful for any advice.

Kind Regards.


Jon


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

* Fwd: GDB Stub with ARM BE8 target.
  2022-05-30 23:03 GDB Stub with ARM BE8 target Jon Wilson
@ 2022-05-31 14:38 ` Jon Wilson
  2022-06-01  8:55 ` Luis Machado
  1 sibling, 0 replies; 3+ messages in thread
From: Jon Wilson @ 2022-05-31 14:38 UTC (permalink / raw)
  To: gdb

I am trying to integrate a GDB stub with a ARM BE8 target. However, it 
would appear that using "set endian big" defaults to BE32 architecture. 
I cannot seem to find a way to have the debugger interpret memory 
according to the BE8 architecture. The only support for BE8 mode I can 
see seems to be for when using BE8 core dumps or processes 
(https://github.com/bminor/binutils-gdb/blob/9606310bbbf8a2d529b5c2aa71cac48a46f65869/gdb/arm-tdep.c#L9781). 
I can't seem to find any documentation on the topic (which is pretty 
forgivable given how niche it is).

I looked at handling the endianness in the stub itself (e.g. inverting 
the endianness of memory based on permissions), but given the code 
stream can contain both instructions (which should be little endian in 
BE8) as well as data (which should be interpretted as big endian), this 
is not possible.

Have I missed an option somewhere? If this support is missing, then how 
should it be added? Should it be handled in a similar way to how GDB 
handles ARM versus Thumb mode? 
(https://github.com/bminor/binutils-gdb/blob/9606310bbbf8a2d529b5c2aa71cac48a46f65869/gdb/arm-tdep.c#L10589)?

I'd be very grateful for any advice.

Kind Regards.


Jon


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

* Re: GDB Stub with ARM BE8 target.
  2022-05-30 23:03 GDB Stub with ARM BE8 target Jon Wilson
  2022-05-31 14:38 ` Fwd: " Jon Wilson
@ 2022-06-01  8:55 ` Luis Machado
  1 sibling, 0 replies; 3+ messages in thread
From: Luis Machado @ 2022-06-01  8:55 UTC (permalink / raw)
  To: Jon Wilson, gdb

Hi Jon,

On 5/31/22 00:03, Jon Wilson via Gdb wrote:
> I am trying to integrate a GDB stub with a ARM BE8 target. However, it would appear that using "set endian big" defaults to BE32 architecture. I cannot seem to find a way to have the debugger interpret memory according to the BE8 architecture. The only support for BE8 mode I can see seems to be for when using BE8 core dumps or processes (https://github.com/bminor/binutils-gdb/blob/9606310bbbf8a2d529b5c2aa71cac48a46f65869/gdb/arm-tdep.c#L9781). I can't seem to find any documentation on the topic (which is pretty forgivable given how niche it is).

The "set endian" command might not do what you'd expect, as it will set the endianness for data accesses only. The "code access" endianness
will be set by the binary's ELF flag EF_ARM_BE8. So once you load a BE8 binary, GDB will know how to deal with it.

> 
> I looked at handling the endianness in the stub itself (e.g. inverting the endianness of memory based on permissions), but given the code stream can contain both instructions (which should be little endian in BE8) as well as data (which should be interpretted as big endian), this is not possible.
> 
> Have I missed an option somewhere? If this support is missing, then how should it be added? Should it be handled in a similar way to how GDB handles ARM versus Thumb mode? (https://github.com/bminor/binutils-gdb/blob/9606310bbbf8a2d529b5c2aa71cac48a46f65869/gdb/arm-tdep.c#L10589)?

I don't think you've missed an option. Technically GDB should support BE8 mode, but in practice, since it is less exercised, it may have regressed and may need to be fixed.

Basically GDB needs to be aware of data/code endianess when dealing with memory. There might be places that are not dealing with this correctly. Detection of BE8 should happen
through the ELF flag mentioned above, so you wouldn't need to fiddle with GDB option or thumb-like heuristics.

> 
> I'd be very grateful for any advice.
> 
> Kind Regards.
> 
> 
> Jon
> 


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

end of thread, other threads:[~2022-06-01  8:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30 23:03 GDB Stub with ARM BE8 target Jon Wilson
2022-05-31 14:38 ` Fwd: " Jon Wilson
2022-06-01  8:55 ` Luis Machado

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).