1 /*
2     Copyright (C) 2000-2006 Silicon Graphics, Inc.  All Rights Reserved.
3     Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved.
4     Portions Copyright 2009-2011 SN Systems Ltd. All rights reserved.
5     Portions Copyright 2008-2011 David Anderson. All rights reserved.
6 
7     This program is free software; you can redistribute it and/or modify it
8     under the terms of version 2 of the GNU General Public License as
9     published by the Free Software Foundation.
10 
11     This program is distributed in the hope that it would be useful, but
12     WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 
15     Further, this software is distributed without any warranty that it is
16     free of the rightful claim of any third person regarding infringement
17     or the like.  Any license provided herein, whether implied or
18     otherwise, applies only to this software file.  Patent licenses, if
19     any, provided herein do not apply to combinations of this program with
20     other software, or any other product whatsoever.
21 
22     You should have received a copy of the GNU General Public License along
23     with this program; if not, write the Free Software Foundation, Inc., 51
24     Franklin Street - Fifth Floor, Boston MA 02110-1301, USA.
25 
26 */
27 
28 #include "globals.h"
29 #include "naming.h"
30 #include "dwconf.h"
31 #include "esb.h"
32 
33 #include "print_sections.h"
34 
35 /* Get all the data in .debug_weaknames */
36 extern void
print_weaknames(Dwarf_Debug dbg)37 print_weaknames(Dwarf_Debug dbg)
38 {
39     Dwarf_Weak *weaknamebuf = NULL;
40     Dwarf_Signed count = 0;
41     Dwarf_Signed i = 0;
42     Dwarf_Off die_off = 0;
43     Dwarf_Off cu_off = 0;
44     char *name = NULL;
45     int wkres = 0;
46     Dwarf_Error err = 0;
47 
48     current_section_id = DEBUG_WEAKNAMES;
49 
50     if (!do_print_dwarf) {
51         return;
52     }
53     /*  No need to get the real section name, this
54         section not used in modern compilers. */
55     printf("\n.debug_weaknames\n");
56     wkres = dwarf_get_weaks(dbg, &weaknamebuf, &count, &err);
57     if (wkres == DW_DLV_ERROR) {
58         print_error(dbg, "dwarf_get_weaks", wkres, err);
59     } else if (wkres == DW_DLV_NO_ENTRY) {
60         /* no weaknames */
61     } else {
62         Dwarf_Unsigned maxoff = get_info_max_offset(dbg);
63 
64         for (i = 0; i < count; i++) {
65             int tnres = 0;
66             int cures3 = 0;
67             Dwarf_Unsigned global_cu_off = 0;
68 
69             tnres = dwarf_weak_name_offsets(weaknamebuf[i],
70                 &name, &die_off, &cu_off,
71                 &err);
72             deal_with_name_offset_err(dbg,
73                 "dwarf_weak_name_offsets",
74                 name, die_off, tnres, err);
75             cures3 = dwarf_weak_cu_offset(weaknamebuf[i],
76                 &global_cu_off, &err);
77             if (cures3 != DW_DLV_OK) {
78                 print_error(dbg, "dwarf_weakname_cu_offset",
79                     cures3, err);
80             }
81             print_pubname_style_entry(dbg,
82                 "weakname",
83                 name, die_off, cu_off,
84                 global_cu_off, maxoff);
85 
86             /* print associated die too? */
87         }
88         dwarf_weaks_dealloc(dbg, weaknamebuf, count);
89     }
90 }   /* print_weaknames() */
91