Example #1
0
int
_dwarf_pro_reloc_name_symbolic(Dwarf_P_Debug dbg, int base_sec_index, Dwarf_Unsigned offset,	/* r_offset 
												   of 
												   reloc 
												 */
			       Dwarf_Unsigned symidx,
			       enum Dwarf_Rel_Type type,
			       int reltarget_length)
{
    /* get a slot, fill in the slot entry */
    void *relrec_to_fill;
    int res;
    struct Dwarf_Relocation_Data_s *slotp;

    res = _dwarf_pro_reloc_get_a_slot(dbg, base_sec_index,
				      &relrec_to_fill);
    if (res != DW_DLV_OK)
	return res;

    slotp = (struct Dwarf_Relocation_Data_s *) relrec_to_fill;
    slotp->drd_type = type;
    slotp->drd_length = reltarget_length;
    slotp->drd_offset = offset;
    slotp->drd_symbol_index = symidx;
    return DW_DLV_OK;

}
Example #2
0
/*
	Return DW_DLV_ERROR on malloc error.
	Return DW_DLV_OK otherwise
*/
int
_dwarf_pro_reloc_length_symbolic(Dwarf_P_Debug dbg, int base_sec_index, Dwarf_Unsigned offset,	/* r_offset 
												   of 
												   reloc 
												 */
				 Dwarf_Unsigned start_symidx,
				 Dwarf_Unsigned end_symidx,
				 enum Dwarf_Rel_Type type,
				 int reltarget_length)
{
    /* get a slot, fill in the slot entry */
    void *relrec_to_fill;
    int res;
    struct Dwarf_Relocation_Data_s *slotp1;
    struct Dwarf_Relocation_Data_s *slotp2;



    res = _dwarf_pro_reloc_get_a_slot(dbg, base_sec_index,
				      &relrec_to_fill);
    if (res != DW_DLV_OK)
	return res;
    slotp1 = (struct Dwarf_Relocation_Data_s *) relrec_to_fill;
    res = _dwarf_pro_reloc_get_a_slot(dbg, base_sec_index,
				      &relrec_to_fill);
    if (res != DW_DLV_OK)
	return res;
    slotp2 = (struct Dwarf_Relocation_Data_s *) relrec_to_fill;

    /* ASSERT: type == dwarf_drt_first_of_length_type_pair */
    slotp1->drd_type = type;
    slotp1->drd_length = reltarget_length;
    slotp1->drd_offset = offset;
    slotp1->drd_symbol_index = start_symidx;

    slotp2->drd_type = dwarf_drt_second_of_length_pair;
    slotp2->drd_length = reltarget_length;
    slotp2->drd_offset = offset;
    slotp2->drd_symbol_index = end_symidx;

    return DW_DLV_OK;
}
Example #3
0
/*
        Return DW_DLV_ERROR on malloc error or reltarget_length error.
        Return DW_DLV_OK otherwise



*/
 /*ARGSUSED*/ int
_dwarf_pro_reloc_name_stream64(Dwarf_P_Debug dbg,
    int base_sec_index,
    Dwarf_Unsigned offset,      /* r_offset of reloc */
    Dwarf_Unsigned symidx,
    enum Dwarf_Rel_Type type,
    int reltarget_length)
{
#if HAVE_ELF64_GETEHDR
    REL64 *elf64_reloc = 0;
    void *relrec_to_fill = 0;
    int res = 0;
    int rel_type = 0;

    res = _dwarf_pro_reloc_get_a_slot(dbg, base_sec_index,
                                      &relrec_to_fill);
    if (res != DW_DLV_OK)
        return res;


    if (type == dwarf_drt_data_reloc) {
        if (reltarget_length == dbg->de_offset_size) {
            rel_type = dbg->de_offset_reloc;
        } else if (reltarget_length == dbg->de_pointer_size) {
            rel_type = dbg->de_ptr_reloc;
        } else {
            return DW_DLV_ERROR;
        }
    } else if (type == dwarf_drt_segment_rel) {
        rel_type = dbg->de_exc_reloc;
    } else {
        /* We are in trouble: improper use of stream relocations.
           Someone else will diagnose */
        rel_type = 0;
    }

    elf64_reloc = (REL64 *)relrec_to_fill;
    elf64_reloc->r_offset = offset;
    Set_REL64_info(*elf64_reloc, symidx, rel_type);
    return DW_DLV_OK;
#else /* !HAVE_ELF64_GETEHDR */
    return DW_DLV_ERROR;
#endif /* #if HAVE_ELF64_GETEHDR */
}
Example #4
0
/*
        Return DW_DLV_ERROR on malloc error or reltarget_length error.
        Return DW_DLV_OK otherwise
        a binary reloc: 32bit ABI
*/
int
_dwarf_pro_reloc_name_stream32(Dwarf_P_Debug dbg, int base_sec_index, 
    Dwarf_Unsigned offset,      /* r_offset of reloc */
    Dwarf_Unsigned symidx,
    enum Dwarf_Rel_Type type,
    int reltarget_length)
{
    REL32 *elf32_reloc = 0;
    void *relrec_to_fill = 0;
    int res = 0;
    int rel_type = 0;

    res = _dwarf_pro_reloc_get_a_slot(dbg, base_sec_index,
                                      &relrec_to_fill);
    if (res != DW_DLV_OK)
        return res;
    if (type == dwarf_drt_data_reloc) {
        if (reltarget_length == dbg->de_offset_size) {
            rel_type = dbg->de_offset_reloc;
        } else if (reltarget_length == dbg->de_pointer_size) {
            rel_type = dbg->de_ptr_reloc;
        } else {
            return DW_DLV_ERROR;
        }
    } else if (type == dwarf_drt_segment_rel) {
        rel_type = dbg->de_exc_reloc;
    } else {
        /* We are in trouble: improper use of stream relocations.
           Someone else will diagnose */
        rel_type = 0;
    }

    elf32_reloc = (REL32*)relrec_to_fill;
    elf32_reloc->r_offset = (Elf32_Addr) offset;
    Set_REL32_info(*elf32_reloc, (Dwarf_Word) symidx, rel_type);
    return DW_DLV_OK;

    /* get a slot, fill in the slot entry */
}