1/*
2
3  Copyright (C) 2000,2004 Silicon Graphics, Inc.  All Rights Reserved.
4
5  This program is free software; you can redistribute it and/or modify it
6  under the terms of version 2.1 of the GNU Lesser General Public License
7  as published by the Free Software Foundation.
8
9  This program is distributed in the hope that it would be useful, but
10  WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13  Further, this software is distributed without any warranty that it is
14  free of the rightful claim of any third person regarding infringement
15  or the like.  Any license provided herein, whether implied or
16  otherwise, applies only to this software file.  Patent licenses, if
17  any, provided herein do not apply to combinations of this program with
18  other software, or any other product whatsoever.
19
20  You should have received a copy of the GNU Lesser General Public
21  License along with this program; if not, write the Free Software
22  Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307,
23  USA.
24
25  Contact information:  Silicon Graphics, Inc., 1500 Crittenden Lane,
26  Mountain View, CA 94043, or:
27
28  http://www.sgi.com
29
30  For further information regarding this notice, see:
31
32  http://oss.sgi.com/projects/GenInfo/NoticeExplan
33
34*/
35
36
37
38
39#define IS_64BIT(dbg) 	((dbg)->de_flags & DW_DLC_SIZE_64 ? 1 : 0)
40#define ISA_IA64(dbg) 	((dbg)->de_flags & DW_DLC_ISA_IA64 ? 1 : 0)
41
42/* definition of sizes of types, given target machine */
43#define sizeof_sbyte(dbg) 	sizeof(Dwarf_Sbyte)
44#define sizeof_ubyte(dbg)	sizeof(Dwarf_Ubyte)
45#define sizeof_uhalf(dbg)	sizeof(Dwarf_Half)
46/* certain sizes not defined here, but set in dbg record.
47   See pro_init.c
48*/
49
50/* Computes amount of padding necessary to align n to a k-boundary. */
51/* Important: Assumes n, k both GREATER than zero. */
52#define PADDING(n, k) ( (k)-1 - ((n)-1)%(k) )
53
54/* The following defines are only important for users of the
55** producer part of libdwarf, and such should have these
56** defined correctly (as necessary)
57** by the #include <elf.h> done in pro_incl.h
58** before the #include "pro_util.h".
59** For others producer macros do not matter so 0 is a usable value, and
60** zero values let compilation succeed on more non-MIPS architectures.
61** A better approach would be welcome.
62*/
63/* R_MIPS* are #define so #ifndef works */
64/* R_IA_64* are not necessarily #define (might be enum) so #ifndef
65   is useless, we use the configure script generating
66   HAVE_R_IA_64_DIR32LSB and HAVE_R_IA64_DIR32LSB.
67*/
68#ifndef R_MIPS_64
69#define R_MIPS_64 0
70#endif
71#ifndef R_MIPS_32
72#define R_MIPS_32 0
73#endif
74#ifndef R_MIPS_SCN_DISP
75#define R_MIPS_SCN_DISP 0
76#endif
77
78/* R_IA_64_DIR32LSB came before the now-standard R_IA64_DIR32LSB
79   (etc) was defined.  This now deals with either form,
80   preferring the new form if available.  */
81#ifdef HAVE_R_IA64_DIR32LSB
82#define DWARF_PRO_R_IA64_DIR32LSB R_IA64_DIR32LSB
83#define DWARF_PRO_R_IA64_DIR64LSB R_IA64_DIR64LSB
84#define DWARF_PRO_R_IA64_SEGREL64LSB R_IA64_SEGREL64LSB
85#define DWARF_PRO_R_IA64_SEGREL32LSB R_IA64_SEGREL32LSB
86#endif
87#if defined(HAVE_R_IA_64_DIR32LSB) && !defined(HAVE_R_IA64_DIR32LSB)
88#define DWARF_PRO_R_IA64_DIR32LSB R_IA_64_DIR32LSB
89#define DWARF_PRO_R_IA64_DIR64LSB R_IA_64_DIR64LSB
90#define DWARF_PRO_R_IA64_SEGREL64LSB R_IA_64_SEGREL64LSB
91#define DWARF_PRO_R_IA64_SEGREL32LSB R_IA_64_SEGREL32LSB
92#endif
93#if !defined(HAVE_R_IA_64_DIR32LSB) && !defined(HAVE_R_IA64_DIR32LSB)
94#define DWARF_PRO_R_IA64_DIR32LSB 0
95#define DWARF_PRO_R_IA64_DIR64LSB 0
96#define DWARF_PRO_R_IA64_SEGREL64LSB 0
97#define DWARF_PRO_R_IA64_SEGREL32LSB 0
98#endif
99
100
101
102#ifdef HAVE_SYS_IA64_ELF_H
103#define Get_REL64_isa(dbg)         (ISA_IA64(dbg) ? \
104				DWARF_PRO_R_IA64_DIR64LSB : R_MIPS_64)
105#define Get_REL32_isa(dbg)         (ISA_IA64(dbg) ? \
106				DWARF_PRO_R_IA64_DIR32LSB : R_MIPS_32)
107
108
109/* ia64 uses 32bit dwarf offsets for sections */
110#define Get_REL_SEGREL_isa(dbg)    (ISA_IA64(dbg) ? \
111				DWARF_PRO_R_IA64_SEGREL32LSB : R_MIPS_SCN_DISP)
112#else /* HAVE_SYS_IA64_ELF_H */
113
114#if !defined(linux) && !defined(__BEOS__)
115#define Get_REL64_isa(dbg)         (R_MIPS_64)
116#define Get_REL32_isa(dbg)         (R_MIPS_32)
117#define Get_REL_SEGREL_isa(dbg)    (R_MIPS_SCN_DISP)
118#else
119#define Get_REL64_isa(dbg)	(DWARF_PRO_R_IA64_DIR64LSB)
120#define Get_REL32_isa(dbg)	(DWARF_PRO_R_IA64_DIR32LSB)
121#define Get_REL_SEGREL_isa(dbg)	(DWARF_PRO_R_IA64_SEGREL64LSB)
122#endif
123
124#endif /* HAVE_SYS_IA64_ELF_H */
125