public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH octets vs bytes for objdump
@ 2000-01-26  4:29 Timothy Wall
  2000-01-26  7:33 ` Ian Lance Taylor
  2000-01-26  7:33 ` Ian Lance Taylor
  0 siblings, 2 replies; 4+ messages in thread
From: Timothy Wall @ 2000-01-26  4:29 UTC (permalink / raw)
  To: binutils, nickc

This patch implements non-octet-sized bytes functionality for objdump.

  * include/dis-asm.h (struct disassemble_info): Added octets_per_byte
field and initialize it to one (1)
  * opcodes/dis-buf.c (buffer_read_memory):  Use octets_per_byte field
to adjust target address bounds checking and calculate the appropriate
octet offset into data
  * binutils/objdump.c (dump_section_header, find_symbol_for_address,
show_line, disassemble_bytes, disassemble_data, dump_data): distinguish
between octets and bytes.


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

* Re: PATCH octets vs bytes for objdump
  2000-01-26  4:29 PATCH octets vs bytes for objdump Timothy Wall
  2000-01-26  7:33 ` Ian Lance Taylor
@ 2000-01-26  7:33 ` Ian Lance Taylor
  2000-01-26  8:19   ` Timothy Wall
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2000-01-26  7:33 UTC (permalink / raw)
  To: twall; +Cc: binutils, nickc

   Date: Wed, 26 Jan 2000 07:28:57 -0500
   From: Timothy Wall <twall@tiac.net>

   *************** buffer_read_memory (memaddr, myaddr, len
   *** 29,39 ****
	  int length;
	  struct disassemble_info *info;
     {
       if (memaddr < info->buffer_vma
   !       || memaddr - info->buffer_vma + length > info->buffer_length)
	 /* Out of bounds.  Use EIO because GDB uses it.  */
	 return EIO;
   !   memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
       return 0;
     }

   --- 29,45 ----
	  int length;
	  struct disassemble_info *info;
     {
   +   int opb = info->octets_per_byte;
   +   int end_addr_offset = length / opb;
   +   int max_addr_offset = info->buffer_length / opb; 
   +   int octets = (memaddr - info->buffer_vma) * opb;
   + 
       if (memaddr < info->buffer_vma
   !       || memaddr + end_addr_offset > info->buffer_vma + max_addr_offset)
	 /* Out of bounds.  Use EIO because GDB uses it.  */
	 return EIO;
   !   memcpy (myaddr, info->buffer + octets, length);
   ! 
       return 0;
     }

Note that the original version of the condition was careful to never
form an address which extended past the end of the buffer.  The new
condition does not preserve that property, because memaddr +
end_addr_offset might be past the end of the buffer.  ISO C does not
guarantee that you can form an address beyond the end of a buffer.  I
admit that this is just a quibble.

Ian

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

* Re: PATCH octets vs bytes for objdump
  2000-01-26  4:29 PATCH octets vs bytes for objdump Timothy Wall
@ 2000-01-26  7:33 ` Ian Lance Taylor
  2000-01-26  7:33 ` Ian Lance Taylor
  1 sibling, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2000-01-26  7:33 UTC (permalink / raw)
  To: twall; +Cc: binutils, nickc

   Date: Wed, 26 Jan 2000 07:28:57 -0500
   From: Timothy Wall <twall@tiac.net>

   +   int opb = bfd_octets_per_byte(abfd);

Oh yeah--use a space before a left paren in a function call in GNU
sources.

Ian

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

* Re: PATCH octets vs bytes for objdump
  2000-01-26  7:33 ` Ian Lance Taylor
@ 2000-01-26  8:19   ` Timothy Wall
  0 siblings, 0 replies; 4+ messages in thread
From: Timothy Wall @ 2000-01-26  8:19 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: twall, binutils, nickc

So while algebraically they are equivalent, ISO C-ically they're not.  Good
point.

The condition should be:

    memaddr - info->buffer_vma + end_addr_offset > max_addr_offset

instead of:

    memaddr + end_addr_offset > info->buffer_vma + max_addr_offset


T.

Ian Lance Taylor wrote:

>    Date: Wed, 26 Jan 2000 07:28:57 -0500
>    From: Timothy Wall <twall@tiac.net>
>
>    *************** buffer_read_memory (memaddr, myaddr, len
>    *** 29,39 ****
>           int length;
>           struct disassemble_info *info;
>      {
>        if (memaddr < info->buffer_vma
>    !       || memaddr - info->buffer_vma + length > info->buffer_length)
>          /* Out of bounds.  Use EIO because GDB uses it.  */
>          return EIO;
>    !   memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
>        return 0;
>      }
>
>    --- 29,45 ----
>           int length;
>           struct disassemble_info *info;
>      {
>    +   int opb = info->octets_per_byte;
>    +   int end_addr_offset = length / opb;
>    +   int max_addr_offset = info->buffer_length / opb;
>    +   int octets = (memaddr - info->buffer_vma) * opb;
>    +
>        if (memaddr < info->buffer_vma
>    !       || memaddr + end_addr_offset > info->buffer_vma + max_addr_offset)
>          /* Out of bounds.  Use EIO because GDB uses it.  */
>          return EIO;
>    !   memcpy (myaddr, info->buffer + octets, length);
>    !
>        return 0;
>      }
>
> Note that the original version of the condition was careful to never
> form an address which extended past the end of the buffer.  The new
> condition does not preserve that property, because memaddr +
> end_addr_offset might be past the end of the buffer.  ISO C does not
> guarantee that you can form an address beyond the end of a buffer.  I
> admit that this is just a quibble.
>
> Ian

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

end of thread, other threads:[~2000-01-26  8:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-26  4:29 PATCH octets vs bytes for objdump Timothy Wall
2000-01-26  7:33 ` Ian Lance Taylor
2000-01-26  7:33 ` Ian Lance Taylor
2000-01-26  8:19   ` Timothy Wall

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