xref: /illumos-gate/usr/src/lib/libdwarf/common/pro_dnames.c (revision 3cac7b0d73edf3f2674ad0f64d1fff3d2e59ae8c)
1 /*
2   Copyright 2018-2018 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 #include "libdwarfdefs.h"
31 #include <stdio.h>
32 #include <string.h>
33 #ifdef HAVE_ELFACCESS_H
34 #include <elfaccess.h>
35 #endif
36 #include "pro_incl.h"
37 #include <stddef.h>
38 #include "dwarf.h"
39 #include "libdwarf.h"
40 #include "pro_opaque.h"
41 #include "pro_error.h"
42 #include "pro_alloc.h"
43 #include "pro_arange.h"
44 #include "pro_section.h"
45 #include "pro_reloc.h"
46 #include "pro_dnames.h"
47 
48 #define FALSE 0
49 #define TRUE  1
50 
51 
52 int
53 dwarf_force_debug_names(Dwarf_P_Debug dbg,
54     Dwarf_Error * error)
55 {
56 
57     Dwarf_P_Dnames dn;
58 
59     if (dbg == NULL) {
60         _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
61         return DW_DLV_ERROR;
62     }
63 
64     dn = (Dwarf_P_Dnames)
65         _dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Dnames_s));
66     if (dn == NULL) {
67         _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
68         return DW_DLV_ERROR;
69     }
70     if (!dbg->de_dnames) {
71         dbg->de_dnames = dn;
72     }
73     dn->dn_create_section = TRUE;
74 
75     return DW_DLV_OK;
76 }
77