summaryrefslogtreecommitdiff
path: root/usr/src/tools/ctf/dwarf/common/pro_reloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/tools/ctf/dwarf/common/pro_reloc.c')
-rw-r--r--usr/src/tools/ctf/dwarf/common/pro_reloc.c163
1 files changed, 82 insertions, 81 deletions
diff --git a/usr/src/tools/ctf/dwarf/common/pro_reloc.c b/usr/src/tools/ctf/dwarf/common/pro_reloc.c
index f608759577..66f16acbd0 100644
--- a/usr/src/tools/ctf/dwarf/common/pro_reloc.c
+++ b/usr/src/tools/ctf/dwarf/common/pro_reloc.c
@@ -1,6 +1,7 @@
/*
- Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ Copyright (C) 2000,2004 Silicon Graphics, 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 +20,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,39 +58,39 @@
*/
int
_dwarf_pro_pre_alloc_n_reloc_slots(Dwarf_P_Debug dbg,
- int rel_sec_index,
- Dwarf_Unsigned newslots)
+ int rel_sec_index,
+ Dwarf_Unsigned newslots)
{
- unsigned long len;
- struct Dwarf_P_Relocation_Block_s *data;
+ unsigned long len = 0;
+ struct Dwarf_P_Relocation_Block_s *data = 0;
Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[rel_sec_index];
unsigned long slots_in_blk = (unsigned long) newslots;
unsigned long rel_rec_size = dbg->de_relocation_record_size;
if (prel->pr_first_block)
- return DW_DLV_OK; /* do nothing */
+ return DW_DLV_OK; /* do nothing */
len = sizeof(struct Dwarf_P_Relocation_Block_s) +
- slots_in_blk * rel_rec_size;
+ slots_in_blk * rel_rec_size;
data = (struct Dwarf_P_Relocation_Block_s *)
- _dwarf_p_get_alloc(dbg, len);
+ _dwarf_p_get_alloc(dbg, len);
if (!data) {
- return DW_DLV_ERROR;
+ return DW_DLV_ERROR;
}
- data->rb_slots_in_block = slots_in_blk; /* could use default
- here, as fallback in
- case our origininal
- estimate wrong.
- When we call this we
- presumably know what
- we are doing, so
- keep this count for
- now */
+ data->rb_slots_in_block = slots_in_blk; /* could use default
+ here, as fallback in
+ case our origininal
+ estimate wrong. When
+ we call this we
+ presumably know what
+ we are doing, so
+ keep this count for
+ now */
data->rb_next_slot_to_use = 0;
data->rb_where_to_add_next =
- ((char *) data) + sizeof(struct Dwarf_P_Relocation_Block_s);
+ ((char *) data) + sizeof(struct Dwarf_P_Relocation_Block_s);
data->rb_data = data->rb_where_to_add_next;
prel->pr_first_block = data;
@@ -111,37 +112,37 @@ _dwarf_pro_pre_alloc_n_reloc_slots(Dwarf_P_Debug dbg,
int
_dwarf_pro_alloc_reloc_slots(Dwarf_P_Debug dbg, int rel_sec_index)
{
- unsigned long len;
- struct Dwarf_P_Relocation_Block_s *data;
+ unsigned long len = 0;
+ struct Dwarf_P_Relocation_Block_s *data = 0;
Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[rel_sec_index];
unsigned long slots_in_blk = prel->pr_slots_per_block_to_alloc;
unsigned long rel_rec_size = dbg->de_relocation_record_size;
len = sizeof(struct Dwarf_P_Relocation_Block_s) +
- slots_in_blk * rel_rec_size;
+ slots_in_blk * rel_rec_size;
data = (struct Dwarf_P_Relocation_Block_s *)
- _dwarf_p_get_alloc(dbg, len);
+ _dwarf_p_get_alloc(dbg, len);
if (!data) {
- return DW_DLV_ERROR;
+ return DW_DLV_ERROR;
}
if (prel->pr_first_block) {
- prel->pr_last_block->rb_next = data;
- prel->pr_last_block = data;
- prel->pr_block_count += 1;
+ prel->pr_last_block->rb_next = data;
+ prel->pr_last_block = data;
+ prel->pr_block_count += 1;
} else {
- prel->pr_first_block = data;
- prel->pr_last_block = data;
- prel->pr_block_count = 1;
+ prel->pr_first_block = data;
+ prel->pr_last_block = data;
+ prel->pr_block_count = 1;
}
data->rb_slots_in_block = slots_in_blk;
data->rb_next_slot_to_use = 0;
data->rb_where_to_add_next =
- ((char *) data) + sizeof(struct Dwarf_P_Relocation_Block_s);
+ ((char *) data) + sizeof(struct Dwarf_P_Relocation_Block_s);
data->rb_data = data->rb_where_to_add_next;
return DW_DLV_OK;
@@ -149,32 +150,32 @@ _dwarf_pro_alloc_reloc_slots(Dwarf_P_Debug dbg, int rel_sec_index)
}
/*
- Reserve a slot. return DW_DLV_OK if succeeds.
+ Reserve a slot. return DW_DLV_OK if succeeds.
- Return DW_DLV_ERROR if fails (malloc error).
+ Return DW_DLV_ERROR if fails (malloc error).
- Use the relrec_to_fill to pass back a pointer to
- a slot space to use.
+ Use the relrec_to_fill to pass back a pointer to
+ a slot space to use.
*/
int
_dwarf_pro_reloc_get_a_slot(Dwarf_P_Debug dbg,
- int base_sec_index, void **relrec_to_fill)
+ int base_sec_index, void **relrec_to_fill)
{
- struct Dwarf_P_Relocation_Block_s *data;
+ struct Dwarf_P_Relocation_Block_s *data = 0;
Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[base_sec_index];
unsigned long rel_rec_size = dbg->de_relocation_record_size;
- char *ret_addr;
+ char *ret_addr = 0;
data = prel->pr_last_block;
if ((data == 0) ||
- (data->rb_next_slot_to_use >= data->rb_slots_in_block)) {
- int res;
+ (data->rb_next_slot_to_use >= data->rb_slots_in_block)) {
+ int res;
- res = _dwarf_pro_alloc_reloc_slots(dbg, base_sec_index);
- if (res != DW_DLV_OK) {
- return res;
- }
+ res = _dwarf_pro_alloc_reloc_slots(dbg, base_sec_index);
+ if (res != DW_DLV_OK) {
+ return res;
+ }
}
data = prel->pr_last_block;
@@ -211,58 +212,58 @@ _dwarf_pro_reloc_get_a_slot(Dwarf_P_Debug dbg,
/*ARGSUSED*/ int
dwarf_get_relocation_info_count(Dwarf_P_Debug dbg,
- Dwarf_Unsigned *
- count_of_relocation_sections,
- int *drd_buffer_version,
- Dwarf_Error * error)
+ Dwarf_Unsigned *
+ count_of_relocation_sections,
+ int *drd_buffer_version,
+ Dwarf_Error * error)
{
if (dbg->de_flags & DW_DLC_SYMBOLIC_RELOCATIONS) {
- int i;
- unsigned int count = 0;
-
- for (i = 0; i < NUM_DEBUG_SECTIONS; ++i) {
- if (dbg->de_reloc_sect[i].pr_reloc_total_count > 0) {
- ++count;
- }
- }
- *count_of_relocation_sections = (Dwarf_Unsigned) count;
- *drd_buffer_version = DWARF_DRD_BUFFER_VERSION;
- return DW_DLV_OK;
+ int i;
+ unsigned int count = 0;
+
+ for (i = 0; i < NUM_DEBUG_SECTIONS; ++i) {
+ if (dbg->de_reloc_sect[i].pr_reloc_total_count > 0) {
+ ++count;
+ }
+ }
+ *count_of_relocation_sections = (Dwarf_Unsigned) count;
+ *drd_buffer_version = DWARF_DRD_BUFFER_VERSION;
+ return DW_DLV_OK;
}
return DW_DLV_NO_ENTRY;
}
int
dwarf_get_relocation_info(Dwarf_P_Debug dbg,
- Dwarf_Signed * elf_section_index,
- Dwarf_Signed * elf_section_index_link,
- Dwarf_Unsigned * relocation_buffer_count,
- Dwarf_Relocation_Data * reldata_buffer,
- Dwarf_Error * error)
+ Dwarf_Signed * elf_section_index,
+ Dwarf_Signed * elf_section_index_link,
+ Dwarf_Unsigned * relocation_buffer_count,
+ Dwarf_Relocation_Data * reldata_buffer,
+ Dwarf_Error * error)
{
int next = dbg->de_reloc_next_to_return;
if (dbg->de_flags & DW_DLC_SYMBOLIC_RELOCATIONS) {
- int i;
+ int i;
- for (i = next; i < NUM_DEBUG_SECTIONS; ++i) {
- Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[i];
+ for (i = next; i < NUM_DEBUG_SECTIONS; ++i) {
+ Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[i];
- if (prel->pr_reloc_total_count > 0) {
- dbg->de_reloc_next_to_return = i + 1;
+ if (prel->pr_reloc_total_count > 0) {
+ dbg->de_reloc_next_to_return = i + 1;
- /* ASSERT: prel->.pr_block_count == 1 */
+ /* ASSERT: prel->.pr_block_count == 1 */
- *elf_section_index = prel->pr_sect_num_of_reloc_sect;
- *elf_section_index_link = dbg->de_elf_sects[i];
- *relocation_buffer_count = prel->pr_reloc_total_count;
- *reldata_buffer = (Dwarf_Relocation_Data)
- (prel->pr_first_block->rb_data);
- return DW_DLV_OK;
- }
- }
- DWARF_P_DBG_ERROR(dbg, DW_DLE_REL_ALLOC, DW_DLV_ERROR);
+ *elf_section_index = prel->pr_sect_num_of_reloc_sect;
+ *elf_section_index_link = dbg->de_elf_sects[i];
+ *relocation_buffer_count = prel->pr_reloc_total_count;
+ *reldata_buffer = (Dwarf_Relocation_Data)
+ (prel->pr_first_block->rb_data);
+ return DW_DLV_OK;
+ }
+ }
+ DWARF_P_DBG_ERROR(dbg, DW_DLE_REL_ALLOC, DW_DLV_ERROR);
}
return DW_DLV_NO_ENTRY;
}