* elf32-mips.c (_bfd_mips_elf_size_dynamic_sections): Always
[deliverable/binutils-gdb.git] / opcodes / dis-buf.c
CommitLineData
252b5132 1/* Disassemble from a buffer, for GNU.
57d91c3c 2 Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
252b5132
RH
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
18#include "sysdep.h"
19#include "dis-asm.h"
20#include <errno.h>
21#include "opintl.h"
22
23/* Get LENGTH bytes from info's buffer, at target address memaddr.
24 Transfer them to myaddr. */
25int
26buffer_read_memory (memaddr, myaddr, length, info)
27 bfd_vma memaddr;
28 bfd_byte *myaddr;
29 int length;
30 struct disassemble_info *info;
31{
32 if (memaddr < info->buffer_vma
33 || memaddr + length > info->buffer_vma + info->buffer_length)
34 /* Out of bounds. Use EIO because GDB uses it. */
35 return EIO;
36 memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
37 return 0;
38}
39
40/* Print an error message. We can assume that this is in response to
41 an error return from buffer_read_memory. */
42void
43perror_memory (status, memaddr, info)
44 int status;
45 bfd_vma memaddr;
46 struct disassemble_info *info;
47{
48 if (status != EIO)
49 /* Can't happen. */
50 info->fprintf_func (info->stream, _("Unknown error %d\n"), status);
51 else
52 /* Actually, address between memaddr and memaddr + len was
53 out of bounds. */
54 info->fprintf_func (info->stream,
55 _("Address 0x%x is out of bounds.\n"), memaddr);
56}
57
58/* This could be in a separate file, to save miniscule amounts of space
59 in statically linked executables. */
60
61/* Just print the address is hex. This is included for completeness even
62 though both GDB and objdump provide their own (to print symbolic
63 addresses). */
64
65void
66generic_print_address (addr, info)
67 bfd_vma addr;
68 struct disassemble_info *info;
69{
70 (*info->fprintf_func) (info->stream, "0x%x", addr);
71}
72
73/* Just concatenate the address as hex. This is included for
74 completeness even though both GDB and objdump provide their own (to
75 print symbolic addresses). */
76
77void
78generic_strcat_address (addr, buf, len)
79 bfd_vma addr;
80 char *buf;
81 int len;
82{
83 if (buf != (char *)NULL && len > 0)
84 {
85 char tmpBuf[30];
86
87 sprintf_vma (tmpBuf, addr);
57d91c3c 88 if ((strlen (buf) + strlen (tmpBuf)) <= (unsigned int) len)
252b5132
RH
89 strcat (buf, tmpBuf);
90 else
91 strncat (buf, tmpBuf, (len - strlen(buf)));
92 }
93 return;
94}
95
96/* Just return the given address. */
97
98int
99generic_symbol_at_address (addr, info)
57d91c3c
ILT
100 bfd_vma addr ATTRIBUTE_UNUSED;
101 struct disassemble_info *info ATTRIBUTE_UNUSED;
252b5132
RH
102{
103 return 1;
104}
This page took 0.033716 seconds and 4 git commands to generate.