1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/x86dasm/dis-buf.c Wed Nov 14 10:18:21 2007 +0000
1.4 +/* Disassemble from a buffer, for GNU.
1.5 + Copyright 1993, 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2005
1.6 + Free Software Foundation, Inc.
1.8 +This program is free software; you can redistribute it and/or modify
1.9 +it under the terms of the GNU General Public License as published by
1.10 +the Free Software Foundation; either version 2 of the License, or
1.11 +(at your option) any later version.
1.13 +This program is distributed in the hope that it will be useful,
1.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
1.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.16 +GNU General Public License for more details.
1.18 +You should have received a copy of the GNU General Public License
1.19 +along with this program; if not, write to the Free Software
1.20 +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
1.22 +#include "sysdep.h"
1.23 +#include "dis-asm.h"
1.25 +#include "opintl.h"
1.27 +/* Get LENGTH bytes from info's buffer, at target address memaddr.
1.28 + Transfer them to myaddr. */
1.30 +buffer_read_memory (memaddr, myaddr, length, info)
1.33 + unsigned int length;
1.34 + struct disassemble_info *info;
1.36 + unsigned int opb = info->octets_per_byte;
1.37 + unsigned int end_addr_offset = length / opb;
1.38 + unsigned int max_addr_offset = info->buffer_length / opb;
1.39 + unsigned int octets = (memaddr - info->buffer_vma) * opb;
1.41 + if (memaddr < info->buffer_vma
1.42 + || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset)
1.43 + /* Out of bounds. Use EIO because GDB uses it. */
1.45 + memcpy (myaddr, info->buffer + octets, length);
1.50 +/* Print an error message. We can assume that this is in response to
1.51 + an error return from buffer_read_memory. */
1.53 +perror_memory (status, memaddr, info)
1.56 + struct disassemble_info *info;
1.58 + if (status != EIO)
1.59 + /* Can't happen. */
1.60 + info->fprintf_func (info->stream, _("Unknown error %d\n"), status);
1.65 + /* Actually, address between memaddr and memaddr + len was
1.67 + sprintf_vma (buf, memaddr);
1.68 + info->fprintf_func (info->stream,
1.69 + _("Address 0x%s is out of bounds.\n"), buf);
1.73 +/* This could be in a separate file, to save miniscule amounts of space
1.74 + in statically linked executables. */
1.76 +/* Just print the address is hex. This is included for completeness even
1.77 + though both GDB and objdump provide their own (to print symbolic
1.81 +generic_print_address (addr, info)
1.83 + struct disassemble_info *info;
1.87 + sprintf_vma (buf, addr);
1.88 + (*info->fprintf_func) (info->stream, "0x%s", buf);
1.92 +/* Just concatenate the address as hex. This is included for
1.93 + completeness even though both GDB and objdump provide their own (to
1.94 + print symbolic addresses). */
1.96 +void generic_strcat_address PARAMS ((bfd_vma, char *, int));
1.99 +generic_strcat_address (addr, buf, len)
1.104 + if (buf != (char *)NULL && len > 0)
1.108 + sprintf_vma (tmpBuf, addr);
1.109 + if ((strlen (buf) + strlen (tmpBuf)) <= (unsigned int) len)
1.110 + strcat (buf, tmpBuf);
1.112 + strncat (buf, tmpBuf, (len - strlen(buf)));
1.118 +/* Just return true. */
1.121 +generic_symbol_at_address (addr, info)
1.122 + bfd_vma addr ATTRIBUTE_UNUSED;
1.123 + struct disassemble_info *info ATTRIBUTE_UNUSED;
1.128 +/* Just return TRUE. */
1.131 +generic_symbol_is_valid (asymbol * sym ATTRIBUTE_UNUSED,
1.132 + struct disassemble_info *info ATTRIBUTE_UNUSED)