| 1 |
/* |
| 2 |
Copyright 2020 David Anderson. All Rights Reserved. |
| 3 |
|
| 4 |
This program is free software; you can redistribute it |
| 5 |
and/or modify it under the terms of version 2.1 of the |
| 6 |
GNU Lesser General Public License as published by the Free |
| 7 |
Software Foundation. |
| 8 |
|
| 9 |
This program is distributed in the hope that it would be |
| 10 |
useful, but WITHOUT ANY WARRANTY; without even the implied |
| 11 |
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 12 |
PURPOSE. |
| 13 |
|
| 14 |
Further, this software is distributed without any warranty |
| 15 |
that it is free of the rightful claim of any third person |
| 16 |
regarding infringement or the like. Any license provided |
| 17 |
herein, whether implied or otherwise, applies only to this |
| 18 |
software file. Patent licenses, if any, provided herein |
| 19 |
do not apply to combinations of this program with other |
| 20 |
software, or any other product whatsoever. |
| 21 |
|
| 22 |
You should have received a copy of the GNU Lesser General |
| 23 |
Public License along with this program; if not, write the |
| 24 |
Free Software Foundation, Inc., 51 Franklin Street - Fifth |
| 25 |
Floor, Boston MA 02110-1301, USA. |
| 26 |
|
| 27 |
*/ |
| 28 |
|
| 29 |
#include <config.h> |
| 30 |
|
| 31 |
#include <stdlib.h> /* free() malloc() */ |
| 32 |
#include <string.h> /* memcpy() strdup() */ |
| 33 |
|
| 34 |
#include "dwarf.h" |
| 35 |
#include "libdwarf.h" |
| 36 |
#include "dwarf_base_types.h" |
| 37 |
#include "libdwarfp.h" |
| 38 |
#include "dwarf_pro_incl.h" |
| 39 |
#include "dwarf_pro_opaque.h" |
| 40 |
#include "dwarf_pro_error.h" |
| 41 |
#include "dwarf_pro_alloc.h" |
| 42 |
|
| 43 |
int |
| 44 |
dwarf_add_debug_sup(Dwarf_P_Debug dbg, |
| 45 |
Dwarf_Half version, |
| 46 |
Dwarf_Small is_supplementary, |
| 47 |
char * filename, |
| 48 |
Dwarf_Unsigned checksum_len, |
| 49 |
Dwarf_Small * checksum, |
| 50 |
Dwarf_Error * error) |
| 51 |
{ |
| 52 |
dbg->de_debug_sup.ds_version = version; |
| 53 |
dbg->de_debug_sup.ds_is_supplementary = is_supplementary; |
| 54 |
dbg->de_debug_sup.ds_filename = strdup(filename); |
| 55 |
dbg->de_debug_sup.ds_checksum_len = checksum_len; |
| 56 |
dbg->de_debug_sup.ds_checksum = malloc(checksum_len); |
| 57 |
if (!dbg->de_debug_sup.ds_checksum) { |
| 58 |
free(dbg->de_debug_sup.ds_filename); |
| 59 |
dbg->de_debug_sup.ds_filename = 0; |
| 60 |
dbg->de_debug_sup.ds_version = 0; |
| 61 |
dbg->de_debug_sup.ds_checksum_len = 0; |
| 62 |
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL); |
| 63 |
return DW_DLV_ERROR; |
| 64 |
} |
| 65 |
memcpy(dbg->de_debug_sup.ds_checksum,checksum,checksum_len); |
| 66 |
return DW_DLV_OK; |
| 67 |
} |