source: trunk/src/binutils/opcodes/dis-buf.c@ 610

Last change on this file since 610 was 610, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r609,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.3 KB
Line 
1/* Disassemble from a buffer, for GNU.
2 Copyright 1993, 1994, 1996, 1997, 1998, 1999, 2000
3 Free Software Foundation, Inc.
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation; either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18
19#include "sysdep.h"
20#include "dis-asm.h"
21#include <errno.h>
22#include "opintl.h"
23
24/* Get LENGTH bytes from info's buffer, at target address memaddr.
25 Transfer them to myaddr. */
26int
27buffer_read_memory (memaddr, myaddr, length, info)
28 bfd_vma memaddr;
29 bfd_byte *myaddr;
30 unsigned int length;
31 struct disassemble_info *info;
32{
33 unsigned int opb = info->octets_per_byte;
34 unsigned int end_addr_offset = length / opb;
35 unsigned int max_addr_offset = info->buffer_length / opb;
36 unsigned int octets = (memaddr - info->buffer_vma) * opb;
37
38 if (memaddr < info->buffer_vma
39 || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset)
40 /* Out of bounds. Use EIO because GDB uses it. */
41 return EIO;
42 memcpy (myaddr, info->buffer + octets, length);
43
44 return 0;
45}
46