summaryrefslogtreecommitdiff
path: root/usr/src/tools/ctf/dwarf/common/pro_arange.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/tools/ctf/dwarf/common/pro_arange.c')
-rw-r--r--usr/src/tools/ctf/dwarf/common/pro_arange.c273
1 files changed, 137 insertions, 136 deletions
diff --git a/usr/src/tools/ctf/dwarf/common/pro_arange.c b/usr/src/tools/ctf/dwarf/common/pro_arange.c
index 292f3d28d0..4e5c37795c 100644
--- a/usr/src/tools/ctf/dwarf/common/pro_arange.c
+++ b/usr/src/tools/ctf/dwarf/common/pro_arange.c
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ Copyright (C) 2000,2004 Silicon Graphics, 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 +19,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
@@ -57,14 +57,14 @@
*/
Dwarf_Unsigned
dwarf_add_arange(Dwarf_P_Debug dbg,
- Dwarf_Addr begin_address,
- Dwarf_Unsigned length,
- Dwarf_Signed symbol_index, Dwarf_Error * error)
+ Dwarf_Addr begin_address,
+ Dwarf_Unsigned length,
+ Dwarf_Signed symbol_index, Dwarf_Error * error)
{
return dwarf_add_arange_b(dbg, begin_address, length, symbol_index,
- /* end_symbol_index */ 0,
- /* offset_from_end_sym */ 0,
- error);
+ /* end_symbol_index */ 0,
+ /* offset_from_end_sym */ 0,
+ error);
}
/*
@@ -75,24 +75,24 @@ dwarf_add_arange(Dwarf_P_Debug dbg,
*/
Dwarf_Unsigned
dwarf_add_arange_b(Dwarf_P_Debug dbg,
- Dwarf_Addr begin_address,
- Dwarf_Unsigned length,
- Dwarf_Unsigned symbol_index,
- Dwarf_Unsigned end_symbol_index,
- Dwarf_Addr offset_from_end_sym, Dwarf_Error * error)
+ Dwarf_Addr begin_address,
+ Dwarf_Unsigned length,
+ Dwarf_Unsigned symbol_index,
+ Dwarf_Unsigned end_symbol_index,
+ Dwarf_Addr offset_from_end_sym, Dwarf_Error * error)
{
Dwarf_P_Arange arange;
if (dbg == NULL) {
- _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
- return (0);
+ _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
+ return (0);
}
arange = (Dwarf_P_Arange)
- _dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Arange_s));
+ _dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Arange_s));
if (arange == NULL) {
- _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
- return (0);
+ _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
+ return (0);
}
arange->ag_begin_address = begin_address;
@@ -102,10 +102,10 @@ dwarf_add_arange_b(Dwarf_P_Debug dbg,
arange->ag_end_symbol_offset = offset_from_end_sym;
if (dbg->de_arange == NULL)
- dbg->de_arange = dbg->de_last_arange = arange;
+ dbg->de_arange = dbg->de_last_arange = arange;
else {
- dbg->de_last_arange->ag_next = arange;
- dbg->de_last_arange = arange;
+ dbg->de_last_arange->ag_next = arange;
+ dbg->de_last_arange = arange;
}
dbg->de_arange_count++;
@@ -148,15 +148,15 @@ _dwarf_transform_arange_to_disk(Dwarf_P_Debug dbg, Dwarf_Error * error)
/* ***** BEGIN CODE ***** */
/* Size of the .debug_aranges section header. */
- arange_num_bytes = extension_word_size + uword_size + /* Size
- of
- length
- field.
- */
- sizeof(Dwarf_Half) + /* Size of version field. */
- uword_size + /* Size of .debug_info offset. */
- sizeof(Dwarf_Small) + /* Size of address size field. */
- sizeof(Dwarf_Small); /* Size of segment size field. */
+ arange_num_bytes = extension_word_size + uword_size + /* Size
+ of
+ length
+ field.
+ */
+ sizeof(Dwarf_Half) + /* Size of version field. */
+ uword_size + /* Size of .debug_info offset. */
+ sizeof(Dwarf_Small) + /* Size of address size field. */
+ sizeof(Dwarf_Small); /* Size of segment size field. */
/*
Adjust the size so that the set of aranges begins on a boundary
@@ -164,82 +164,82 @@ _dwarf_transform_arange_to_disk(Dwarf_P_Debug dbg, Dwarf_Error * error)
requirement. */
remainder = arange_num_bytes % (2 * upointer_size);
if (remainder != 0)
- arange_num_bytes += (2 * upointer_size) - remainder;
+ arange_num_bytes += (2 * upointer_size) - remainder;
/* Add the bytes for the actual address ranges. */
arange_num_bytes += upointer_size * 2 * (dbg->de_arange_count + 1);
GET_CHUNK(dbg, dbg->de_elf_sects[DEBUG_ARANGES],
- arange, (unsigned long) arange_num_bytes, error);
+ arange, (unsigned long) arange_num_bytes, error);
arange_ptr = arange;
if (arange == NULL) {
- _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
- return (0);
+ _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
+ return (0);
}
if (extension_word_size) {
- Dwarf_Word x = DISTINGUISHED_VALUE;
+ Dwarf_Word x = DISTINGUISHED_VALUE;
- WRITE_UNALIGNED(dbg, (void *) arange_ptr,
- (const void *) &x,
- sizeof(x), extension_word_size);
- arange_ptr += extension_word_size;
+ WRITE_UNALIGNED(dbg, (void *) arange_ptr,
+ (const void *) &x,
+ sizeof(x), extension_word_size);
+ arange_ptr += extension_word_size;
}
/* Write the total length of .debug_aranges section. */
adjusted_length = arange_num_bytes - uword_size
- - extension_word_size;
+ - extension_word_size;
{
- Dwarf_Unsigned du = adjusted_length;
+ Dwarf_Unsigned du = adjusted_length;
- WRITE_UNALIGNED(dbg, (void *) arange_ptr,
- (const void *) &du, sizeof(du), uword_size);
- arange_ptr += uword_size;
+ WRITE_UNALIGNED(dbg, (void *) arange_ptr,
+ (const void *) &du, sizeof(du), uword_size);
+ arange_ptr += uword_size;
}
/* Write the version as 2 bytes. */
{
- Dwarf_Half verstamp = CURRENT_VERSION_STAMP;
+ Dwarf_Half verstamp = CURRENT_VERSION_STAMP;
- WRITE_UNALIGNED(dbg, (void *) arange_ptr,
- (const void *) &verstamp,
- sizeof(verstamp), sizeof(Dwarf_Half));
- arange_ptr += sizeof(Dwarf_Half);
+ WRITE_UNALIGNED(dbg, (void *) arange_ptr,
+ (const void *) &verstamp,
+ sizeof(verstamp), sizeof(Dwarf_Half));
+ arange_ptr += sizeof(Dwarf_Half);
}
/* Write the .debug_info offset. This is always 0. */
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
- (const void *) &big_zero,
- sizeof(big_zero), uword_size);
+ (const void *) &big_zero,
+ sizeof(big_zero), uword_size);
arange_ptr += uword_size;
{
- unsigned long count = dbg->de_arange_count + 1;
- int res;
-
- if (dbg->de_reloc_pair) {
- count = (3 * dbg->de_arange_count) + 1;
- }
- /* the following is a small optimization: not needed for
- correctness */
- res = _dwarf_pro_pre_alloc_n_reloc_slots(dbg,
- DEBUG_ARANGES, count);
- if (res != DW_DLV_OK) {
- {
- _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
- return (0);
- }
- }
+ unsigned long count = dbg->de_arange_count + 1;
+ int res;
+
+ if (dbg->de_reloc_pair) {
+ count = (3 * dbg->de_arange_count) + 1;
+ }
+ /* the following is a small optimization: not needed for
+ correctness */
+ res = _dwarf_pro_pre_alloc_n_reloc_slots(dbg,
+ DEBUG_ARANGES, count);
+ if (res != DW_DLV_OK) {
+ {
+ _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
+ return (0);
+ }
+ }
}
/* reloc for .debug_info */
res = dbg->de_reloc_name(dbg,
- DEBUG_ARANGES,
- extension_word_size +
- uword_size + sizeof(Dwarf_Half),
- dbg->de_sect_name_idx[DEBUG_INFO],
- dwarf_drt_data_reloc, uword_size);
+ DEBUG_ARANGES,
+ extension_word_size +
+ uword_size + sizeof(Dwarf_Half),
+ dbg->de_sect_name_idx[DEBUG_INFO],
+ dwarf_drt_data_reloc, uword_size);
/* Write the size of addresses. */
*arange_ptr = dbg->de_pointer_size;
@@ -255,7 +255,7 @@ _dwarf_transform_arange_to_disk(Dwarf_P_Debug dbg, Dwarf_Error * error)
Skip over the padding to align the start of the actual address
ranges to twice the address size. */
if (remainder != 0)
- arange_ptr += (2 * upointer_size) - remainder;
+ arange_ptr += (2 * upointer_size) - remainder;
@@ -264,73 +264,74 @@ _dwarf_transform_arange_to_disk(Dwarf_P_Debug dbg, Dwarf_Error * error)
/* The arange address, length are pointer-size fields of the target
machine. */
for (given_arange = dbg->de_arange; given_arange != NULL;
- given_arange = given_arange->ag_next) {
-
- /* Write relocation record for beginning of address range. */
- res = dbg->de_reloc_name(dbg, DEBUG_ARANGES, arange_ptr - arange, /* r_offset */
- (long) given_arange->ag_symbol_index,
- dwarf_drt_data_reloc, upointer_size);
- if (res != DW_DLV_OK) {
- {
- _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
- return (0);
- }
- }
-
- /* Copy beginning address of range. */
- WRITE_UNALIGNED(dbg, (void *) arange_ptr,
- (const void *) &given_arange->ag_begin_address,
- sizeof(given_arange->ag_begin_address),
- upointer_size);
- arange_ptr += upointer_size;
-
- if (dbg->de_reloc_pair &&
- given_arange->ag_end_symbol_index != 0 &&
- given_arange->ag_length == 0) {
- /* symbolic reloc, need reloc for length What if we really
- know the length? If so, should use the other part of
- 'if'. */
- Dwarf_Unsigned val;
-
- res = dbg->de_reloc_pair(dbg, DEBUG_ARANGES, arange_ptr - arange, /* r_offset
- */
- given_arange->ag_symbol_index,
- given_arange->ag_end_symbol_index,
- dwarf_drt_first_of_length_pair,
- upointer_size);
- if (res != DW_DLV_OK) {
- {
- _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
- return (0);
- }
- }
-
- /* arrange pre-calc so assem text can do .word end - begin
- + val (gets val from stream) */
- val = given_arange->ag_end_symbol_offset -
- given_arange->ag_begin_address;
- WRITE_UNALIGNED(dbg, (void *) arange_ptr,
- (const void *) &val,
- sizeof(val), upointer_size);
- arange_ptr += upointer_size;
-
- } else {
- /* plain old length to copy, no relocation at all */
- WRITE_UNALIGNED(dbg, (void *) arange_ptr,
- (const void *) &given_arange->ag_length,
- sizeof(given_arange->ag_length),
- upointer_size);
- arange_ptr += upointer_size;
- }
+ given_arange = given_arange->ag_next) {
+
+ /* Write relocation record for beginning of address range. */
+ res = dbg->de_reloc_name(dbg, DEBUG_ARANGES, arange_ptr - arange, /* r_offset
+ */
+ (long) given_arange->ag_symbol_index,
+ dwarf_drt_data_reloc, upointer_size);
+ if (res != DW_DLV_OK) {
+ {
+ _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
+ return (0);
+ }
+ }
+
+ /* Copy beginning address of range. */
+ WRITE_UNALIGNED(dbg, (void *) arange_ptr,
+ (const void *) &given_arange->ag_begin_address,
+ sizeof(given_arange->ag_begin_address),
+ upointer_size);
+ arange_ptr += upointer_size;
+
+ if (dbg->de_reloc_pair &&
+ given_arange->ag_end_symbol_index != 0 &&
+ given_arange->ag_length == 0) {
+ /* symbolic reloc, need reloc for length What if we really
+ know the length? If so, should use the other part of
+ 'if'. */
+ Dwarf_Unsigned val;
+
+ res = dbg->de_reloc_pair(dbg, DEBUG_ARANGES, arange_ptr - arange, /* r_offset
+ */
+ given_arange->ag_symbol_index,
+ given_arange->ag_end_symbol_index,
+ dwarf_drt_first_of_length_pair,
+ upointer_size);
+ if (res != DW_DLV_OK) {
+ {
+ _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
+ return (0);
+ }
+ }
+
+ /* arrange pre-calc so assem text can do .word end - begin
+ + val (gets val from stream) */
+ val = given_arange->ag_end_symbol_offset -
+ given_arange->ag_begin_address;
+ WRITE_UNALIGNED(dbg, (void *) arange_ptr,
+ (const void *) &val,
+ sizeof(val), upointer_size);
+ arange_ptr += upointer_size;
+
+ } else {
+ /* plain old length to copy, no relocation at all */
+ WRITE_UNALIGNED(dbg, (void *) arange_ptr,
+ (const void *) &given_arange->ag_length,
+ sizeof(given_arange->ag_length),
+ upointer_size);
+ arange_ptr += upointer_size;
+ }
}
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
- (const void *) &big_zero,
- sizeof(big_zero), upointer_size);
+ (const void *) &big_zero,
+ sizeof(big_zero), upointer_size);
arange_ptr += upointer_size;
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
- (const void *) &big_zero,
- sizeof(big_zero), upointer_size);
+ (const void *) &big_zero,
+ sizeof(big_zero), upointer_size);
return (int) dbg->de_n_debug_sect;
}