149d3bc91SRichard Lowe /* 249d3bc91SRichard Lowe 307dc1947SRichard Lowe Copyright (C) 2000,2002,2004 Silicon Graphics, Inc. All Rights Reserved. 407dc1947SRichard Lowe Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved. 5*4d9fdb46SRobert Mustacchi Portions Copyright 2008-2012 David Anderson. All rights reserved. 6*4d9fdb46SRobert Mustacchi Portions Copyright 2010-2012 SN Systems Ltd. All rights reserved. 749d3bc91SRichard Lowe 849d3bc91SRichard Lowe This program is free software; you can redistribute it and/or modify it 9*4d9fdb46SRobert Mustacchi under the terms of version 2.1 of the GNU Lesser General Public License 1049d3bc91SRichard Lowe as published by the Free Software Foundation. 1149d3bc91SRichard Lowe 1249d3bc91SRichard Lowe This program is distributed in the hope that it would be useful, but 1349d3bc91SRichard Lowe WITHOUT ANY WARRANTY; without even the implied warranty of 14*4d9fdb46SRobert Mustacchi MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1549d3bc91SRichard Lowe 1649d3bc91SRichard Lowe Further, this software is distributed without any warranty that it is 17*4d9fdb46SRobert Mustacchi free of the rightful claim of any third person regarding infringement 18*4d9fdb46SRobert Mustacchi or the like. Any license provided herein, whether implied or 1949d3bc91SRichard Lowe otherwise, applies only to this software file. Patent licenses, if 20*4d9fdb46SRobert Mustacchi any, provided herein do not apply to combinations of this program with 21*4d9fdb46SRobert Mustacchi other software, or any other product whatsoever. 2249d3bc91SRichard Lowe 2307dc1947SRichard Lowe You should have received a copy of the GNU Lesser General Public 2407dc1947SRichard Lowe License along with this program; if not, write the Free Software 2507dc1947SRichard Lowe Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 2649d3bc91SRichard Lowe USA. 2749d3bc91SRichard Lowe 2849d3bc91SRichard Lowe */ 2949d3bc91SRichard Lowe 30*4d9fdb46SRobert Mustacchi /* Windows specific header files */ 31*4d9fdb46SRobert Mustacchi #if defined(_WIN32) && defined(HAVE_STDAFX_H) 32*4d9fdb46SRobert Mustacchi #include "stdafx.h" 33*4d9fdb46SRobert Mustacchi #endif /* HAVE_STDAFX_H */ 3449d3bc91SRichard Lowe 35*4d9fdb46SRobert Mustacchi #ifdef DWARF_WITH_LIBELF 36*4d9fdb46SRobert Mustacchi #ifdef HAVE_ELF_H /* does includes of elf.h libelf.h here. */ 3749d3bc91SRichard Lowe #include <elf.h> 38*4d9fdb46SRobert Mustacchi #elif defined(HAVE_LIBELF_H) 39*4d9fdb46SRobert Mustacchi /* On one platform without elf.h this gets Elf32_Rel 4007dc1947SRichard Lowe type defined (a required type). */ 4107dc1947SRichard Lowe #include <libelf.h> 42*4d9fdb46SRobert Mustacchi /* Consider the other known directory too */ 43*4d9fdb46SRobert Mustacchi #elif defined(HAVE_LIBELF_LIBELF_H) 44*4d9fdb46SRobert Mustacchi #include <libelf/libelf.h> 45*4d9fdb46SRobert Mustacchi #endif /* HAVE_ELF_H or HAVE_LIBELF*H */ 46*4d9fdb46SRobert Mustacchi #endif /* DWARF_WITH_LIBELF */ 4707dc1947SRichard Lowe 4807dc1947SRichard Lowe #if defined(sun) 4907dc1947SRichard Lowe #include <sys/elf_SPARC.h> 5007dc1947SRichard Lowe #include <sys/elf_386.h> 5149d3bc91SRichard Lowe #endif 5249d3bc91SRichard Lowe 5349d3bc91SRichard Lowe /* The target address is given: the place in the source integer 5449d3bc91SRichard Lowe is to be determined. 5549d3bc91SRichard Lowe */ 5649d3bc91SRichard Lowe #ifdef WORDS_BIGENDIAN 5749d3bc91SRichard Lowe #define WRITE_UNALIGNED(dbg,dest,source, srclength,len_out) \ 5849d3bc91SRichard Lowe { \ 59*4d9fdb46SRobert Mustacchi dbg->de_copy_word(dest, \ 60*4d9fdb46SRobert Mustacchi ((const char *)source) +(srclength)-(len_out),\ 61*4d9fdb46SRobert Mustacchi (len_out)) ; \ 6249d3bc91SRichard Lowe } 6349d3bc91SRichard Lowe #else /* LITTLE ENDIAN */ 6449d3bc91SRichard Lowe #define WRITE_UNALIGNED(dbg,dest,source, srclength,len_out) \ 6549d3bc91SRichard Lowe { \ 66*4d9fdb46SRobert Mustacchi dbg->de_copy_word( (dest) , \ 67*4d9fdb46SRobert Mustacchi ((const char *)source) , \ 68*4d9fdb46SRobert Mustacchi (len_out)) ; \ 6949d3bc91SRichard Lowe } 70*4d9fdb46SRobert Mustacchi #endif /* BIG- LITTLE-ENDIAN */ 7149d3bc91SRichard Lowe 7249d3bc91SRichard Lowe 7307dc1947SRichard Lowe #if defined(sparc) && defined(sun) 7407dc1947SRichard Lowe #define REL32 Elf32_Rela 7507dc1947SRichard Lowe #define REL64 Elf64_Rela 7607dc1947SRichard Lowe #define REL_SEC_PREFIX ".rela" 7707dc1947SRichard Lowe #else 7807dc1947SRichard Lowe #define REL32 Elf32_Rel 7907dc1947SRichard Lowe #define REL64 Elf64_Rel 8007dc1947SRichard Lowe #define REL_SEC_PREFIX ".rel" 8107dc1947SRichard Lowe #endif 82