149d3bc9Richard Lowe/*
249d3bc9Richard Lowe
307dc194Richard Lowe  Copyright (C) 2000,2002,2004 Silicon Graphics, Inc.  All Rights Reserved.
407dc194Richard Lowe  Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
507dc194Richard Lowe  Portions Copyright 2008-2010 David Anderson. All rights reserved.
649d3bc9Richard Lowe
749d3bc9Richard Lowe  This program is free software; you can redistribute it and/or modify it
849d3bc9Richard Lowe  under the terms of version 2.1 of the GNU Lesser General Public License
949d3bc9Richard Lowe  as published by the Free Software Foundation.
1049d3bc9Richard Lowe
1149d3bc9Richard Lowe  This program is distributed in the hope that it would be useful, but
1249d3bc9Richard Lowe  WITHOUT ANY WARRANTY; without even the implied warranty of
1449d3bc9Richard Lowe
1549d3bc9Richard Lowe  Further, this software is distributed without any warranty that it is
1649d3bc9Richard Lowe  free of the rightful claim of any third person regarding infringement
1749d3bc9Richard Lowe  or the like.  Any license provided herein, whether implied or
1849d3bc9Richard Lowe  otherwise, applies only to this software file.  Patent licenses, if
1949d3bc9Richard Lowe  any, provided herein do not apply to combinations of this program with
2049d3bc9Richard Lowe  other software, or any other product whatsoever.
2149d3bc9Richard Lowe
2207dc194Richard Lowe  You should have received a copy of the GNU Lesser General Public
2307dc194Richard Lowe  License along with this program; if not, write the Free Software
2407dc194Richard Lowe  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
2549d3bc9Richard Lowe  USA.
2649d3bc9Richard Lowe
2707dc194Richard Lowe  Contact information:  Silicon Graphics, Inc., 1500 Crittenden Lane,
2849d3bc9Richard Lowe  Mountain View, CA 94043, or:
2949d3bc9Richard Lowe
3049d3bc9Richard Lowe  http://www.sgi.com
3149d3bc9Richard Lowe
3249d3bc9Richard Lowe  For further information regarding this notice, see:
3349d3bc9Richard Lowe
3449d3bc9Richard Lowe  http://oss.sgi.com/projects/GenInfo/NoticeExplan
3549d3bc9Richard Lowe
3649d3bc9Richard Lowe*/
3749d3bc9Richard Lowe
3849d3bc9Richard Lowe
3949d3bc9Richard Lowe#ifdef HAVE_ELF_H
4049d3bc9Richard Lowe#include <elf.h>
4107dc194Richard Lowe#elif defined(HAVE_LIBELF_H)
4207dc194Richard Lowe/* On one platform without elf.h this gets Elf32_Rel
4307dc194Richard Lowe   type defined (a required type). */
4407dc194Richard Lowe#include <libelf.h>
4507dc194Richard Lowe#endif
4607dc194Richard Lowe
4707dc194Richard Lowe#if defined(sun)
4807dc194Richard Lowe#include <sys/elf_SPARC.h>
4907dc194Richard Lowe#include <sys/elf_386.h>
5049d3bc9Richard Lowe#endif
5149d3bc9Richard Lowe
5249d3bc9Richard Lowe/* The target address is given: the place in the source integer
5349d3bc9Richard Lowe   is to be determined.
5449d3bc9Richard Lowe*/
5549d3bc9Richard Lowe#ifdef WORDS_BIGENDIAN
5649d3bc9Richard Lowe#define WRITE_UNALIGNED(dbg,dest,source, srclength,len_out) \
5749d3bc9Richard Lowe    { \
5849d3bc9Richard Lowe      dbg->de_copy_word(dest, \
5949d3bc9Richard Lowe                        ((char *)source) +srclength-len_out,  \
6049d3bc9Richard Lowe			len_out) ; \
6149d3bc9Richard Lowe    }
6249d3bc9Richard Lowe
6349d3bc9Richard Lowe
6449d3bc9Richard Lowe#else /* LITTLE ENDIAN */
6549d3bc9Richard Lowe
6649d3bc9Richard Lowe#define WRITE_UNALIGNED(dbg,dest,source, srclength,len_out) \
6749d3bc9Richard Lowe    { \
6849d3bc9Richard Lowe      dbg->de_copy_word( (dest) , \
6949d3bc9Richard Lowe                        ((char *)source) ,  \
7049d3bc9Richard Lowe			len_out) ; \
7149d3bc9Richard Lowe    }
7249d3bc9Richard Lowe#endif
7349d3bc9Richard Lowe
7449d3bc9Richard Lowe
7507dc194Richard Lowe#if defined(sparc) && defined(sun)
7607dc194Richard Lowe#define REL32 Elf32_Rela
7707dc194Richard Lowe#define REL64 Elf64_Rela
7807dc194Richard Lowe#define REL_SEC_PREFIX ".rela"
7907dc194Richard Lowe#else
8007dc194Richard Lowe#define REL32 Elf32_Rel
8107dc194Richard Lowe#define REL64 Elf64_Rel
8207dc194Richard Lowe#define REL_SEC_PREFIX ".rel"
8307dc194Richard Lowe#endif
8449d3bc9Richard Lowe
8507dc194Richard Lowe#include "dwarf.h"
8649d3bc9Richard Lowe#include "libdwarf.h"
8749d3bc9Richard Lowe
8849d3bc9Richard Lowe#include "pro_opaque.h"
8949d3bc9Richard Lowe#include "pro_error.h"
9049d3bc9Richard Lowe#include "pro_util.h"
9149d3bc9Richard Lowe#include "pro_encode_nm.h"
9249d3bc9Richard Lowe#include "pro_alloc.h"