summaryrefslogtreecommitdiff
path: root/usr/src/tools/ctf/dwarf/common/pro_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/tools/ctf/dwarf/common/pro_init.c')
-rw-r--r--usr/src/tools/ctf/dwarf/common/pro_init.c182
1 files changed, 97 insertions, 85 deletions
diff --git a/usr/src/tools/ctf/dwarf/common/pro_init.c b/usr/src/tools/ctf/dwarf/common/pro_init.c
index f4dd526718..d696113a67 100644
--- a/usr/src/tools/ctf/dwarf/common/pro_init.c
+++ b/usr/src/tools/ctf/dwarf/common/pro_init.c
@@ -1,6 +1,8 @@
/*
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
+ Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
+ Portions Copyright 2008-2010 David Anderson, Inc. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the terms of version 2.1 of the GNU Lesser General Public License
@@ -19,10 +21,10 @@
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307,
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
USA.
- Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,
+ Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
Mountain View, CA 94043, or:
http://www.sgi.com
@@ -40,7 +42,7 @@
#include <stdio.h>
#include <string.h>
#include "pro_incl.h"
-#include "pro_section.h" /* for MAGIC_SECT_NO */
+#include "pro_section.h" /* for MAGIC_SECT_NO */
#include "pro_reloc_symbolic.h"
#include "pro_reloc_stream.h"
@@ -50,12 +52,12 @@ static void common_init(Dwarf_P_Debug dbg, Dwarf_Unsigned flags);
void *_dwarf_memcpy_swap_bytes(void *s1, const void *s2, size_t len);
/*--------------------------------------------------------------------
- This function sets up a new dwarf producing region.
- flags: Indicates type of access method, one of DW_DLC* macros
- func(): Used to create a new object file, a call back function
- errhand(): Error Handler provided by user
- errarg: Argument to errhand()
- error: returned error value
+ This function sets up a new dwarf producing region.
+ flags: Indicates type of access method, one of DW_DLC* macros
+ func(): Used to create a new object file, a call back function
+ errhand(): Error Handler provided by user
+ errarg: Argument to errhand()
+ error: returned error value
--------------------------------------------------------------------*/
/* We want the following to have an elf section number that matches
'nothing' */
@@ -65,25 +67,25 @@ static struct Dwarf_P_Section_Data_s init_sect = {
Dwarf_P_Debug
dwarf_producer_init_b(Dwarf_Unsigned flags,
- Dwarf_Callback_Func_b func,
- Dwarf_Handler errhand,
- Dwarf_Ptr errarg, Dwarf_Error * error)
+ Dwarf_Callback_Func_b func,
+ Dwarf_Handler errhand,
+ Dwarf_Ptr errarg, Dwarf_Error * error)
{
Dwarf_P_Debug dbg;
dbg = (Dwarf_P_Debug) _dwarf_p_get_alloc(NULL,
- sizeof(struct
- Dwarf_P_Debug_s));
+ sizeof(struct
+ Dwarf_P_Debug_s));
if (dbg == NULL) {
- DWARF_P_DBG_ERROR(dbg, DW_DLE_DBG_ALLOC,
- (Dwarf_P_Debug) DW_DLV_BADADDR);
+ DWARF_P_DBG_ERROR(dbg, DW_DLE_DBG_ALLOC,
+ (Dwarf_P_Debug) DW_DLV_BADADDR);
}
- memset((void *) dbg,0, sizeof(struct Dwarf_P_Debug_s));
+ memset((void *) dbg, 0, sizeof(struct Dwarf_P_Debug_s));
/* For the time being */
if (func == NULL) {
- DWARF_P_DBG_ERROR(dbg, DW_DLE_NO_CALLBACK_FUNC,
- (Dwarf_P_Debug) DW_DLV_BADADDR);
+ DWARF_P_DBG_ERROR(dbg, DW_DLE_NO_CALLBACK_FUNC,
+ (Dwarf_P_Debug) DW_DLV_BADADDR);
}
- dbg->de_func_b = func;
+ dbg->de_callback_func_b = func;
dbg->de_errhand = errhand;
dbg->de_errarg = errarg;
common_init(dbg, flags);
@@ -93,9 +95,9 @@ dwarf_producer_init_b(Dwarf_Unsigned flags,
Dwarf_P_Debug
dwarf_producer_init(Dwarf_Unsigned flags,
- Dwarf_Callback_Func func,
- Dwarf_Handler errhand,
- Dwarf_Ptr errarg, Dwarf_Error * error)
+ Dwarf_Callback_Func func,
+ Dwarf_Handler errhand,
+ Dwarf_Ptr errarg, Dwarf_Error * error)
{
Dwarf_P_Debug dbg;
@@ -103,19 +105,19 @@ dwarf_producer_init(Dwarf_Unsigned flags,
dbg = (Dwarf_P_Debug) _dwarf_p_get_alloc(NULL,
- sizeof(struct
- Dwarf_P_Debug_s));
+ sizeof(struct
+ Dwarf_P_Debug_s));
if (dbg == NULL) {
- DWARF_P_DBG_ERROR(dbg, DW_DLE_DBG_ALLOC,
- (Dwarf_P_Debug) DW_DLV_BADADDR);
+ DWARF_P_DBG_ERROR(dbg, DW_DLE_DBG_ALLOC,
+ (Dwarf_P_Debug) DW_DLV_BADADDR);
}
- memset((void *) dbg,0, sizeof(struct Dwarf_P_Debug_s));
+ memset((void *) dbg, 0, sizeof(struct Dwarf_P_Debug_s));
/* For the time being */
if (func == NULL) {
- DWARF_P_DBG_ERROR(dbg, DW_DLE_NO_CALLBACK_FUNC,
- (Dwarf_P_Debug) DW_DLV_BADADDR);
+ DWARF_P_DBG_ERROR(dbg, DW_DLE_NO_CALLBACK_FUNC,
+ (Dwarf_P_Debug) DW_DLV_BADADDR);
}
- dbg->de_func = func;
+ dbg->de_callback_func = func;
dbg->de_errhand = errhand;
dbg->de_errarg = errarg;
common_init(dbg, flags);
@@ -137,31 +139,15 @@ common_init(Dwarf_P_Debug dbg, Dwarf_Unsigned flags)
-#if defined(HAVE_DWARF2_99_EXTENSION)
- /* Revised 64 bit output, using distingushed values. Per 1999
- dwarf2 revision This produces 64bit extension with ia64 objects.
-
- Some might want library run time selection of offset size. Not
- provided here at present. */
- dbg->de_64bit_extension = (IS_64BIT(dbg) ? 1 : 0);
- dbg->de_pointer_size = (IS_64BIT(dbg) ? 8 : 4);
- dbg->de_offset_size = (IS_64BIT(dbg) ? 8 : 4);
- dbg->de_ptr_reloc =
- IS_64BIT(dbg) ? Get_REL64_isa(dbg) : Get_REL32_isa(dbg);
- /* Non-MIPS, dwarf lengths and offsets are 32 bits even for 64bit
- pointer environments. */
- /* Get_REL??_isa here supports 64bit-offset dwarf. For 64bit, we
- emit the extension bytes. */
-
- dbg->de_offset_reloc = IS_64BIT(dbg) ? Get_REL64_isa(dbg)
- : Get_REL32_isa(dbg);
-#elif defined(HAVE_OLD_DWARF2_32BIT_OFFSET)
- /* This is cygnus 32bit offset, as specified in pure dwarf2 v2.0.0 */
+#if defined(HAVE_STRICT_DWARF2_32BIT_OFFSET)
+ /* This is cygnus 32bit offset, as specified in pure dwarf2 v2.0.0.
+ It is consistent with normal DWARF2/3 generation of always
+ generating 32 bit offsets. */
dbg->de_64bit_extension = 0;
dbg->de_pointer_size = (IS_64BIT(dbg) ? 8 : 4);
dbg->de_offset_size = (IS_64BIT(dbg) ? 4 : 4);
dbg->de_ptr_reloc =
- IS_64BIT(dbg) ? Get_REL64_isa(dbg) : Get_REL32_isa(dbg);
+ IS_64BIT(dbg) ? Get_REL64_isa(dbg) : Get_REL32_isa(dbg);
/* non-MIPS, dwarf lengths and offsets are 32 bits even for 64bit
pointer environments. */
/* Get_REL32_isa here supports 64-bit-pointer dwarf with pure
@@ -169,62 +155,88 @@ common_init(Dwarf_P_Debug dbg, Dwarf_Unsigned flags)
pure 32 bit offset dwarf for 32bit pointer apps. */
dbg->de_offset_reloc = Get_REL32_isa(dbg);
-#else
- /* MIPS-SGI 32 or 64, where offsets and lengths are both 64 bit for
- 64bit pointer objects and both 32 bit for 32bit pointer
- objects. And a dwarf-reader must check elf info to tell which
- applies. */
+#elif defined(HAVE_SGI_IRIX_OFFSETS)
+ /* MIPS-SGI-IRIX 32 or 64, where offsets and lengths are both 64 bit for
+ 64bit pointer objects and both 32 bit for 32bit pointer objects.
+ And a dwarf-reader must check elf info to tell which applies. */
dbg->de_64bit_extension = 0;
dbg->de_pointer_size = (IS_64BIT(dbg) ? 8 : 4);
dbg->de_offset_size = (IS_64BIT(dbg) ? 8 : 4);
dbg->de_ptr_reloc =
- IS_64BIT(dbg) ? Get_REL64_isa(dbg) : Get_REL32_isa(dbg);
+ IS_64BIT(dbg) ? Get_REL64_isa(dbg) : Get_REL32_isa(dbg);
dbg->de_offset_reloc = dbg->de_ptr_reloc;
-#endif
+#else /* HAVE_DWARF2_99_EXTENSION or default. */
+ /* Revised 64 bit output, using distingushed values. Per 1999
+ dwarf3. This allows run-time selection of offset size. */
+ dbg->de_64bit_extension = (IS_64BIT(dbg) ? 1 : 0);
+ dbg->de_pointer_size = (IS_64BIT(dbg) ? 8 : 4);
+ if( flags & DW_DLC_OFFSET_SIZE_64 && (dbg->de_pointer_size == 8)) {
+ /* When it's 64 bit address, a 64bit offset is sensible.
+ Arguably a 32 bit address with 64 bit offset could be
+ sensible, but who would want that? */
+ dbg->de_offset_size = 8;
+ dbg->de_64bit_extension = 1;
+ } else {
+ dbg->de_offset_size = 4;
+ dbg->de_64bit_extension = 0;
+ }
+ dbg->de_ptr_reloc =
+ IS_64BIT(dbg) ? Get_REL64_isa(dbg) : Get_REL32_isa(dbg);
+ /* Non-MIPS, dwarf lengths and offsets are 32 bits even for 64bit
+ pointer environments. */
+ /* Get_REL??_isa here supports 64bit-offset dwarf. For 64bit, we
+ emit the extension bytes. */
+
+ dbg->de_offset_reloc = IS_64BIT(dbg) ? Get_REL64_isa(dbg)
+ : Get_REL32_isa(dbg);
+#endif /* HAVE_DWARF2_99_EXTENSION etc. */
+
dbg->de_exc_reloc = Get_REL_SEGREL_isa(dbg);
dbg->de_is_64bit = IS_64BIT(dbg);
if (flags & DW_DLC_SYMBOLIC_RELOCATIONS) {
- dbg->de_relocation_record_size =
- sizeof(struct Dwarf_Relocation_Data_s);
+ dbg->de_relocation_record_size =
+ sizeof(struct Dwarf_Relocation_Data_s);
} else {
+
#if HAVE_ELF64_GETEHDR
- dbg->de_relocation_record_size =
- IS_64BIT(dbg) ? sizeof(Elf64_Rel) : sizeof(Elf32_Rel);
+ dbg->de_relocation_record_size =
+ IS_64BIT(dbg)? sizeof(REL64) : sizeof(REL32);
#else
- dbg->de_relocation_record_size = sizeof(Elf32_Rel);
+ dbg->de_relocation_record_size = sizeof(REL32);
#endif
+
}
if (dbg->de_offset_size == 8) {
- dbg->de_ar_data_attribute_form = DW_FORM_data8;
- dbg->de_ar_ref_attr_form = DW_FORM_ref8;
+ dbg->de_ar_data_attribute_form = DW_FORM_data8;
+ dbg->de_ar_ref_attr_form = DW_FORM_ref8;
} else {
- dbg->de_ar_data_attribute_form = DW_FORM_data4;
- dbg->de_ar_ref_attr_form = DW_FORM_ref4;
+ dbg->de_ar_data_attribute_form = DW_FORM_data4;
+ dbg->de_ar_ref_attr_form = DW_FORM_ref4;
}
if (flags & DW_DLC_SYMBOLIC_RELOCATIONS) {
- dbg->de_reloc_name = _dwarf_pro_reloc_name_symbolic;
- dbg->de_reloc_pair = _dwarf_pro_reloc_length_symbolic;
- dbg->de_transform_relocs_to_disk =
- _dwarf_symbolic_relocs_to_disk;
+ dbg->de_reloc_name = _dwarf_pro_reloc_name_symbolic;
+ dbg->de_reloc_pair = _dwarf_pro_reloc_length_symbolic;
+ dbg->de_transform_relocs_to_disk =
+ _dwarf_symbolic_relocs_to_disk;
} else {
- if (IS_64BIT(dbg)) {
- dbg->de_reloc_name = _dwarf_pro_reloc_name_stream64;
- } else {
- dbg->de_reloc_name = _dwarf_pro_reloc_name_stream32;
- }
- dbg->de_reloc_pair = 0;
- dbg->de_transform_relocs_to_disk = _dwarf_stream_relocs_to_disk;
+ if (IS_64BIT(dbg)) {
+ dbg->de_reloc_name = _dwarf_pro_reloc_name_stream64;
+ } else {
+ dbg->de_reloc_name = _dwarf_pro_reloc_name_stream32;
+ }
+ dbg->de_reloc_pair = 0;
+ dbg->de_transform_relocs_to_disk = _dwarf_stream_relocs_to_disk;
}
for (k = 0; k < NUM_DEBUG_SECTIONS; ++k) {
- Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[k];
+ Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[k];
- prel->pr_slots_per_block_to_alloc = DEFAULT_SLOTS_PER_BLOCK;
+ prel->pr_slots_per_block_to_alloc = DEFAULT_SLOTS_PER_BLOCK;
}
/* First assume host, target same endianness */
dbg->de_same_endian = 1;
@@ -232,14 +244,14 @@ common_init(Dwarf_P_Debug dbg, Dwarf_Unsigned flags)
#ifdef WORDS_BIGENDIAN
/* host is big endian, so what endian is target? */
if (flags & DW_DLC_TARGET_LITTLEENDIAN) {
- dbg->de_same_endian = 0;
- dbg->de_copy_word = _dwarf_memcpy_swap_bytes;
+ dbg->de_same_endian = 0;
+ dbg->de_copy_word = _dwarf_memcpy_swap_bytes;
}
#else /* little endian */
/* host is little endian, so what endian is target? */
if (flags & DW_DLC_TARGET_BIGENDIAN) {
- dbg->de_same_endian = 0;
- dbg->de_copy_word = _dwarf_memcpy_swap_bytes;
+ dbg->de_same_endian = 0;
+ dbg->de_copy_word = _dwarf_memcpy_swap_bytes;
}
#endif /* !WORDS_BIGENDIAN */