|
Packit |
cdaae3 |
/*
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
Copyright (C) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
|
|
Packit |
cdaae3 |
Portions Copyright (C) 2009-2011 David Anderson. All Rights Reserved.
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
This program is free software; you can redistribute it and/or modify it
|
|
Packit |
cdaae3 |
under the terms of version 2.1 of the GNU Lesser General Public License
|
|
Packit |
cdaae3 |
as published by the Free Software Foundation.
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
This program is distributed in the hope that it would be useful, but
|
|
Packit |
cdaae3 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
cdaae3 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
Further, this software is distributed without any warranty that it is
|
|
Packit |
cdaae3 |
free of the rightful claim of any third person regarding infringement
|
|
Packit |
cdaae3 |
or the like. Any license provided herein, whether implied or
|
|
Packit |
cdaae3 |
otherwise, applies only to this software file. Patent licenses, if
|
|
Packit |
cdaae3 |
any, provided herein do not apply to combinations of this program with
|
|
Packit |
cdaae3 |
other software, or any other product whatsoever.
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
cdaae3 |
License along with this program; if not, write the Free Software
|
|
Packit |
cdaae3 |
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
|
Packit |
cdaae3 |
USA.
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
*/
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
#include "config.h"
|
|
Packit |
cdaae3 |
#include "dwarf_incl.h"
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_get_str(Dwarf_Debug dbg,
|
|
Packit |
cdaae3 |
Dwarf_Off offset,
|
|
Packit |
cdaae3 |
char **string,
|
|
Packit |
cdaae3 |
Dwarf_Signed * returned_str_len, Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
int res = DW_DLV_ERROR;
|
|
Packit |
cdaae3 |
void *secptr = 0;
|
|
Packit |
cdaae3 |
void *begin = 0;
|
|
Packit |
cdaae3 |
void *end = 0;
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
if (dbg == NULL) {
|
|
Packit |
cdaae3 |
_dwarf_error(NULL, error, DW_DLE_DBG_NULL);
|
|
Packit |
cdaae3 |
return (DW_DLV_ERROR);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
if (offset == dbg->de_debug_str.dss_size) {
|
|
Packit |
cdaae3 |
/* Normal (if we've iterated thru the set of strings using
|
|
Packit |
cdaae3 |
dwarf_get_str and are at the end). */
|
|
Packit |
cdaae3 |
return DW_DLV_NO_ENTRY;
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
if (offset > dbg->de_debug_str.dss_size) {
|
|
Packit |
cdaae3 |
_dwarf_error(dbg, error, DW_DLE_DEBUG_STR_OFFSET_BAD);
|
|
Packit |
cdaae3 |
return (DW_DLV_ERROR);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
if (string == NULL) {
|
|
Packit |
cdaae3 |
_dwarf_error(dbg, error, DW_DLE_STRING_PTR_NULL);
|
|
Packit |
cdaae3 |
return (DW_DLV_ERROR);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
res = _dwarf_load_section(dbg, &dbg->de_debug_str,error);
|
|
Packit |
cdaae3 |
if (res != DW_DLV_OK) {
|
|
Packit |
cdaae3 |
return res;
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
if (!dbg->de_debug_str.dss_size) {
|
|
Packit |
cdaae3 |
return (DW_DLV_NO_ENTRY);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
secptr =dbg->de_debug_str.dss_data;
|
|
Packit |
cdaae3 |
begin = (char *)secptr + offset;
|
|
Packit |
cdaae3 |
end = (char *)secptr + dbg->de_debug_str.dss_size;
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
res = _dwarf_check_string_valid(dbg,secptr,begin,end,
|
|
Packit |
cdaae3 |
DW_DLE_DEBUG_STR_OFFSET_BAD,error);
|
|
Packit |
cdaae3 |
if (res != DW_DLV_OK) {
|
|
Packit |
cdaae3 |
return res;
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
*string = (char *) begin;
|
|
Packit |
cdaae3 |
*returned_str_len = strlen(*string);
|
|
Packit |
cdaae3 |
return DW_DLV_OK;
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|