1 /*
2   Copyright (C) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
3   Portions Copyright (C) 2007-2016 David Anderson. All Rights Reserved.
4   Portions Copyright 2012 SN Systems Ltd. All rights reserved.
5 
6   This program is free software; you can redistribute it and/or modify it
7   under the terms of version 2.1 of the GNU Lesser General Public License
8   as published by the Free Software Foundation.
9 
10   This program is distributed in the hope that it would be useful, but
11   WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 
14   Further, this software is distributed without any warranty that it is
15   free of the rightful claim of any third person regarding infringement
16   or the like.  Any license provided herein, whether implied or
17   otherwise, applies only to this software file.  Patent licenses, if
18   any, provided herein do not apply to combinations of this program with
19   other software, or any other product whatsoever.
20 
21   You should have received a copy of the GNU Lesser General Public
22   License along with this program; if not, write the Free Software
23   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
24   USA.
25 
26 */
27 
28 #include "config.h"
29 #include "dwarf_incl.h"
30 #include <stdio.h>
31 #include <stdarg.h>
32 #include <stdlib.h> /* For free() */
33 #include "dwarf_die_deliv.h"
34 #include "pro_encode_nm.h"
35 
36 
37 #define MINBUFLEN 1000
38 #define TRUE  1
39 #define FALSE 0
40 
41 Dwarf_Bool
_dwarf_file_has_debug_fission_cu_index(Dwarf_Debug dbg)42 _dwarf_file_has_debug_fission_cu_index(Dwarf_Debug dbg)
43 {
44     if(!dbg) {
45         return FALSE;
46     }
47     if (dbg->de_cu_hashindex_data) {
48         return TRUE;
49     }
50     return FALSE;
51 }
52 Dwarf_Bool
_dwarf_file_has_debug_fission_tu_index(Dwarf_Debug dbg)53 _dwarf_file_has_debug_fission_tu_index(Dwarf_Debug dbg)
54 {
55     if(!dbg) {
56         return FALSE;
57     }
58     if (dbg->de_tu_hashindex_data ) {
59         return TRUE;
60     }
61     return FALSE;
62 }
63 
64 
65 Dwarf_Bool
_dwarf_file_has_debug_fission_index(Dwarf_Debug dbg)66 _dwarf_file_has_debug_fission_index(Dwarf_Debug dbg)
67 {
68     if(!dbg) {
69         return FALSE;
70     }
71     if (dbg->de_cu_hashindex_data ||
72         dbg->de_tu_hashindex_data) {
73         return 1;
74     }
75     return FALSE;
76 }
77 
78 int
_dwarf_internal_get_die_comp_dir(Dwarf_Die die,const char ** compdir_out,const char ** compname_out,Dwarf_Error * error)79 _dwarf_internal_get_die_comp_dir(Dwarf_Die die, const char **compdir_out,
80     const char **compname_out,
81     Dwarf_Error *error)
82 {
83     Dwarf_Attribute comp_dir_attr = 0;
84     Dwarf_Attribute comp_name_attr = 0;
85     int resattr = 0;
86     Dwarf_Debug dbg = 0;
87 
88     dbg = die->di_cu_context->cc_dbg;
89     resattr = dwarf_attr(die, DW_AT_name, &comp_name_attr, error);
90     if (resattr == DW_DLV_ERROR) {
91         return resattr;
92     }
93     if (resattr == DW_DLV_OK) {
94         int cres = DW_DLV_ERROR;
95         char *name = 0;
96 
97         cres = dwarf_formstring(comp_name_attr, &name, error);
98         if (cres == DW_DLV_ERROR) {
99             dwarf_dealloc(dbg, comp_name_attr, DW_DLA_ATTR);
100             return cres;
101         } else if (cres == DW_DLV_OK) {
102             *compname_out = (const char *)name;
103         } else {
104             /* FALL thru */
105         }
106     }
107     if (resattr == DW_DLV_OK) {
108         dwarf_dealloc(dbg, comp_name_attr, DW_DLA_ATTR);
109     }
110     resattr = dwarf_attr(die, DW_AT_comp_dir, &comp_dir_attr, error);
111     if (resattr == DW_DLV_ERROR) {
112         return resattr;
113     }
114     if (resattr == DW_DLV_OK) {
115         int cres = DW_DLV_ERROR;
116         char *cdir = 0;
117 
118         cres = dwarf_formstring(comp_dir_attr, &cdir, error);
119         if (cres == DW_DLV_ERROR) {
120             dwarf_dealloc(dbg, comp_dir_attr, DW_DLA_ATTR);
121             return cres;
122         } else if (cres == DW_DLV_OK) {
123             *compdir_out = (const char *) cdir;
124         } else {
125             /* FALL thru */
126         }
127     }
128     if (resattr == DW_DLV_OK) {
129         dwarf_dealloc(dbg, comp_dir_attr, DW_DLA_ATTR);
130     }
131     return resattr;
132 }
133 
134 
135 /*  Given a form, and a pointer to the bytes encoding
136     a value of that form, val_ptr, this function returns
137     the length, in bytes, of a value of that form.
138     When using this function, check for a return of 0
139     a recursive DW_FORM_INDIRECT value.  */
140 int
_dwarf_get_size_of_val(Dwarf_Debug dbg,Dwarf_Unsigned form,Dwarf_Half cu_version,Dwarf_Half address_size,Dwarf_Small * val_ptr,int v_length_size,Dwarf_Unsigned * size_out,Dwarf_Small * section_end_ptr,Dwarf_Error * error)141 _dwarf_get_size_of_val(Dwarf_Debug dbg,
142     Dwarf_Unsigned form,
143     Dwarf_Half cu_version,
144     Dwarf_Half address_size,
145     Dwarf_Small * val_ptr,
146     int v_length_size,
147     Dwarf_Unsigned *size_out,
148     Dwarf_Small *section_end_ptr,
149     Dwarf_Error*error)
150 {
151     Dwarf_Unsigned length = 0;
152     Dwarf_Word leb128_length = 0;
153     Dwarf_Unsigned form_indirect = 0;
154     Dwarf_Unsigned ret_value = 0;
155 
156     switch (form) {
157 
158     /*  When we encounter a FORM here that
159         we know about but forgot to enter here,
160         we had better not just continue.
161         Usually means we forgot to update this function
162         when implementing form handling of a new FORM.
163         Disaster results from using a bogus value,
164         so generate error. */
165     default:
166         _dwarf_error(dbg,error,DW_DLE_DEBUG_FORM_HANDLING_INCOMPLETE);
167         return DW_DLV_ERROR;
168 
169 
170     case 0:  return DW_DLV_OK;
171     case DW_FORM_GNU_ref_alt:
172     case DW_FORM_GNU_strp_alt:
173     case DW_FORM_strp_sup:
174         *size_out = v_length_size;
175         return DW_DLV_OK;
176 
177     case DW_FORM_addr:
178         if (address_size) {
179             *size_out = address_size;
180         } else {
181             /* This should never happen, address_size should be set. */
182             *size_out = dbg->de_pointer_size;
183         }
184         return DW_DLV_OK;
185     case DW_FORM_ref_sig8:
186         *size_out = 8;
187         /* sizeof Dwarf_Sig8 */
188         return DW_DLV_OK;
189 
190     /*  DWARF2 was wrong on the size of the attribute for
191         DW_FORM_ref_addr.  We assume compilers are using the
192         corrected DWARF3 text (for 32bit pointer target objects pointer and
193         offsets are the same size anyway).
194         It is clear (as of 2014) that for 64bit folks used
195         the V2 spec in the way V2 was
196         written, so the ref_addr has to account for that.*/
197     case DW_FORM_ref_addr:
198         if (cu_version == DW_CU_VERSION2) {
199             *size_out = address_size;
200         } else {
201             *size_out = v_length_size;
202         }
203         return DW_DLV_OK;
204 
205     case DW_FORM_block1: {
206         ptrdiff_t sizeasptrdiff = 0;
207 
208         if (val_ptr >= section_end_ptr) {
209             _dwarf_error(dbg,error,DW_DLE_FORM_BLOCK_LENGTH_ERROR);
210             return DW_DLV_ERROR;
211         }
212         ret_value =  *(Dwarf_Small *) val_ptr;
213         sizeasptrdiff = (ptrdiff_t)ret_value;
214         if (sizeasptrdiff > (section_end_ptr - val_ptr) ||
215             sizeasptrdiff < 0) {
216             _dwarf_error(dbg,error,DW_DLE_FORM_BLOCK_LENGTH_ERROR);
217             return DW_DLV_ERROR;
218         }
219         *size_out = ret_value +1;
220         }
221         return DW_DLV_OK;
222 
223     case DW_FORM_block2: {
224         ptrdiff_t sizeasptrdiff = 0;
225 
226         READ_UNALIGNED_CK(dbg, ret_value, Dwarf_Unsigned,
227             val_ptr, sizeof(Dwarf_Half),error,section_end_ptr);
228         sizeasptrdiff = (ptrdiff_t)ret_value;
229         if (sizeasptrdiff > (section_end_ptr - val_ptr) ||
230             sizeasptrdiff < 0) {
231             _dwarf_error(dbg,error,DW_DLE_FORM_BLOCK_LENGTH_ERROR);
232             return DW_DLV_ERROR;
233         }
234         *size_out = ret_value + sizeof(Dwarf_Half);
235         }
236         return DW_DLV_OK;
237 
238     case DW_FORM_block4: {
239         ptrdiff_t sizeasptrdiff = 0;
240 
241         READ_UNALIGNED_CK(dbg, ret_value, Dwarf_Unsigned,
242             val_ptr, sizeof(Dwarf_ufixed),
243             error,section_end_ptr);
244         sizeasptrdiff = (ptrdiff_t)ret_value;
245         if (sizeasptrdiff > (section_end_ptr - val_ptr) ||
246             sizeasptrdiff < 0) {
247             _dwarf_error(dbg,error,DW_DLE_FORM_BLOCK_LENGTH_ERROR);
248             return DW_DLV_ERROR;
249         }
250         *size_out = ret_value + sizeof(Dwarf_ufixed);
251         }
252         return DW_DLV_OK;
253 
254     case DW_FORM_data1:
255         *size_out = 1;
256         return DW_DLV_OK;
257 
258     case DW_FORM_data2:
259         *size_out = 2;
260         return DW_DLV_OK;
261 
262     case DW_FORM_data4:
263         *size_out = 4;
264         return DW_DLV_OK;
265 
266     case DW_FORM_data8:
267         *size_out = 8;
268         return DW_DLV_OK;
269 
270     case DW_FORM_string: {
271         int res = 0;
272         res = _dwarf_check_string_valid(dbg,val_ptr,
273             val_ptr,
274             section_end_ptr,
275             DW_DLE_FORM_STRING_BAD_STRING,
276             error);
277         if ( res != DW_DLV_OK) {
278             return res;
279         }
280         }
281         *size_out = strlen((char *) val_ptr) + 1;
282         return DW_DLV_OK;
283 
284     case DW_FORM_block:
285     case DW_FORM_exprloc: {
286         DECODE_LEB128_UWORD_LEN_CK(val_ptr,length,leb128_length,
287             dbg,error,section_end_ptr);
288         *size_out = length + leb128_length;
289         return DW_DLV_OK;;
290     }
291 
292     case DW_FORM_flag_present:
293         *size_out = 0;
294         return DW_DLV_OK;
295 
296     case DW_FORM_flag:
297         *size_out = 1;
298         return DW_DLV_OK;
299 
300     case DW_FORM_sec_offset:
301         /* If 32bit dwarf, is 4. Else is 64bit dwarf and is 8. */
302         *size_out = v_length_size;
303         return DW_DLV_OK;
304 
305     case DW_FORM_ref_udata: {
306         UNUSEDARG Dwarf_Unsigned v = 0;
307 
308         /*  Discard the decoded value, we just want the length
309             of the value. */
310         DECODE_LEB128_UWORD_LEN_CK(val_ptr,v,leb128_length,
311             dbg,error,section_end_ptr);
312         *size_out = leb128_length;
313         return DW_DLV_OK;;
314     }
315 
316     case DW_FORM_indirect:
317         {
318             Dwarf_Word indir_len = 0;
319             int res = 0;
320             Dwarf_Unsigned real_form_len = 0;
321 
322             DECODE_LEB128_UWORD_LEN_CK(val_ptr,form_indirect,indir_len,
323                 dbg,error,section_end_ptr);
324             if (form_indirect == DW_FORM_indirect) {
325                 /* We are in big trouble: The true form
326                     of DW_FORM_indirect is
327                     DW_FORM_indirect? Nonsense. Should
328                     never happen. */
329                 _dwarf_error(dbg,error,DW_DLE_NESTED_FORM_INDIRECT_ERROR);
330                 return DW_DLV_ERROR;
331             }
332             res = _dwarf_get_size_of_val(dbg,
333                 form_indirect,
334                 cu_version,
335                 address_size,
336                 val_ptr + indir_len,
337                 v_length_size,
338                 &real_form_len,
339                 section_end_ptr,
340                 error);
341             if(res != DW_DLV_OK) {
342                 return res;
343             }
344             *size_out = indir_len + real_form_len;
345             return DW_DLV_OK;
346         }
347 
348     case DW_FORM_ref1:
349         *size_out = 1;
350         return DW_DLV_OK;
351 
352     case DW_FORM_ref2:
353         *size_out = 2;
354         return DW_DLV_OK;
355 
356     case DW_FORM_ref4:
357         *size_out = 4;
358         return DW_DLV_OK;
359 
360     case DW_FORM_ref8:
361         *size_out = 8;
362         return DW_DLV_OK;
363 
364     case DW_FORM_sdata: {
365         /*  Discard the decoded value, we just want the length
366             of the value. */
367         UNUSEDARG Dwarf_Signed v = 0;
368 
369         /*  Discard the decoded value, we just want the length
370             of the value. */
371         DECODE_LEB128_SWORD_LEN_CK(val_ptr,v,leb128_length,
372             dbg,error,section_end_ptr);
373         *size_out = leb128_length;
374         return DW_DLV_OK;
375     }
376 
377 
378     case DW_FORM_addrx:
379     case DW_FORM_GNU_addr_index:
380     case DW_FORM_strx:
381     case DW_FORM_GNU_str_index: {
382         UNUSEDARG Dwarf_Unsigned v = 0;
383 
384         DECODE_LEB128_UWORD_LEN_CK(val_ptr,v,leb128_length,
385             dbg,error,section_end_ptr);
386         *size_out = leb128_length;
387         return DW_DLV_OK;
388     }
389 
390     case DW_FORM_strp:
391         *size_out = v_length_size;
392         return DW_DLV_OK;
393 
394     case DW_FORM_udata: {
395         /*  Discard the decoded value, we just want the length
396             of the value. */
397         UNUSEDARG Dwarf_Unsigned v = 0;
398 
399         DECODE_LEB128_UWORD_LEN_CK(val_ptr,v,leb128_length,
400             dbg,error,section_end_ptr);
401         *size_out = leb128_length;
402         return DW_DLV_OK;
403     }
404     }
405 }
406 
407 /*  We allow an arbitrary number of HT_MULTIPLE entries
408     before resizing.  It seems up to 20 or 30
409     would work nearly as well.
410     We could have a different resize multiple than 'resize now'
411     test multiple, but for now we don't do that.  */
412 #define HT_MULTIPLE 8
413 
414 /*  Copy the old entries, updating each to be in
415     a new list.  Don't delete anything. Leave the
416     htin with stale data. */
417 static void
copy_abbrev_table_to_new_table(Dwarf_Hash_Table htin,Dwarf_Hash_Table htout)418 copy_abbrev_table_to_new_table(Dwarf_Hash_Table htin,
419   Dwarf_Hash_Table htout)
420 {
421     Dwarf_Hash_Table_Entry entry_in = htin->tb_entries;
422     unsigned entry_in_count = htin->tb_table_entry_count;
423     Dwarf_Hash_Table_Entry entry_out = htout->tb_entries;
424     unsigned entry_out_count = htout->tb_table_entry_count;
425     unsigned k = 0;
426     for (; k < entry_in_count; ++k,++entry_in) {
427         Dwarf_Abbrev_List listent = entry_in->at_head;
428         Dwarf_Abbrev_List nextlistent = 0;
429 
430         for (; listent ; listent = nextlistent) {
431             unsigned newtmp = listent->abl_code;
432             unsigned newhash = newtmp%entry_out_count;
433             Dwarf_Hash_Table_Entry e;
434             nextlistent = listent->abl_next;
435             e = entry_out+newhash;
436             /*  Move_entry_to_new_hash. This reverses the
437                 order of the entries, effectively, but
438                 that does not seem significant. */
439             listent->abl_next = e->at_head;
440             e->at_head = listent;
441 
442             htout->tb_total_abbrev_count++;
443         }
444     }
445 }
446 
447 /*  We allow zero form here, end of list. */
448 int
_dwarf_valid_form_we_know(UNUSEDARG Dwarf_Debug dbg,Dwarf_Unsigned at_form,Dwarf_Unsigned at_name)449 _dwarf_valid_form_we_know(UNUSEDARG Dwarf_Debug dbg,
450     Dwarf_Unsigned at_form,
451     Dwarf_Unsigned at_name)
452 {
453     if(at_form == 0 && at_name == 0) {
454         return TRUE;
455     }
456     if (at_name == 0) {
457         return FALSE;
458     }
459     if (at_form <= DW_FORM_ref_sig8) {
460         return TRUE;
461     }
462     if (at_form == DW_FORM_GNU_addr_index ||
463         at_form == DW_FORM_GNU_str_index  ||
464         at_form == DW_FORM_GNU_ref_alt ||
465         at_form == DW_FORM_GNU_strp_alt) {
466         return TRUE;
467     }
468     return FALSE;
469 }
470 
471 /*  This function returns a pointer to a Dwarf_Abbrev_List_s
472     struct for the abbrev with the given code.  It puts the
473     struct on the appropriate hash table.  It also adds all
474     the abbrev between the last abbrev added and this one to
475     the hash table.  In other words, the .debug_abbrev section
476     is scanned sequentially from the top for an abbrev with
477     the given code.  All intervening abbrevs are also put
478     into the hash table.
479 
480     This function hashes the given code, and checks the chain
481     at that hash table entry to see if a Dwarf_Abbrev_List_s
482     with the given code exists.  If yes, it returns a pointer
483     to that struct.  Otherwise, it scans the .debug_abbrev
484     section from the last byte scanned for that CU till either
485     an abbrev with the given code is found, or an abbrev code
486     of 0 is read.  It puts Dwarf_Abbrev_List_s entries for all
487     abbrev's read till that point into the hash table.  The
488     hash table contains both a head pointer and a tail pointer
489     for each entry.
490 
491     While the lists can move and entries can be moved between
492     lists on reallocation, any given Dwarf_Abbrev_list entry
493     never moves once allocated, so the pointer is safe to return.
494 
495     See also dwarf_get_abbrev() in dwarf_abbrev.c.
496 
497     Returns NULL on error.  */
498 int
_dwarf_get_abbrev_for_code(Dwarf_CU_Context cu_context,Dwarf_Unsigned code,Dwarf_Abbrev_List * list_out,Dwarf_Error * error)499 _dwarf_get_abbrev_for_code(Dwarf_CU_Context cu_context, Dwarf_Unsigned code,
500     Dwarf_Abbrev_List *list_out,
501     Dwarf_Error *error)
502 {
503     Dwarf_Debug dbg = cu_context->cc_dbg;
504     Dwarf_Hash_Table hash_table_base = cu_context->cc_abbrev_hash_table;
505     Dwarf_Hash_Table_Entry entry_base = 0;
506     Dwarf_Hash_Table_Entry entry_cur = 0;
507     Dwarf_Word hash_num = 0;
508     Dwarf_Unsigned abbrev_code = 0;
509     Dwarf_Unsigned abbrev_tag  = 0;
510     Dwarf_Unsigned attr_name = 0;
511     Dwarf_Unsigned attr_form = 0;
512     Dwarf_Abbrev_List hash_abbrev_entry = 0;
513     Dwarf_Abbrev_List inner_list_entry = 0;
514     Dwarf_Hash_Table_Entry inner_hash_entry = 0;
515 
516     Dwarf_Byte_Ptr abbrev_ptr = 0;
517     Dwarf_Byte_Ptr end_abbrev_ptr = 0;
518     unsigned hashable_val = 0;
519 
520     if (!hash_table_base->tb_entries) {
521         hash_table_base->tb_table_entry_count =  HT_MULTIPLE;
522         hash_table_base->tb_total_abbrev_count= 0;
523         hash_table_base->tb_entries =
524             (struct  Dwarf_Hash_Table_Entry_s *)_dwarf_get_alloc(dbg,
525             DW_DLA_HASH_TABLE_ENTRY,
526             hash_table_base->tb_table_entry_count);
527         if (!hash_table_base->tb_entries) {
528             return DW_DLV_NO_ENTRY;
529         }
530 
531     } else if (hash_table_base->tb_total_abbrev_count >
532         ( hash_table_base->tb_table_entry_count * HT_MULTIPLE) ) {
533         struct Dwarf_Hash_Table_s newht;
534         /* Effectively multiplies by >= HT_MULTIPLE */
535         newht.tb_table_entry_count =  hash_table_base->tb_total_abbrev_count;
536         newht.tb_total_abbrev_count = 0;
537         newht.tb_entries =
538             (struct  Dwarf_Hash_Table_Entry_s *)_dwarf_get_alloc(dbg,
539             DW_DLA_HASH_TABLE_ENTRY,
540             newht.tb_table_entry_count);
541 
542         if (!newht.tb_entries) {
543             return DW_DLV_NO_ENTRY;
544         }
545         /*  Copy the existing entries to the new table,
546             rehashing each.  */
547         copy_abbrev_table_to_new_table(hash_table_base, &newht);
548         /*  Dealloc only the entries hash table array, not the lists
549             of things pointed to by a hash table entry array. */
550         dwarf_dealloc(dbg, hash_table_base->tb_entries,DW_DLA_HASH_TABLE_ENTRY);
551         hash_table_base->tb_entries = 0;
552         /*  Now overwrite the existing table descriptor with
553             the new, newly valid, contents. */
554         *hash_table_base = newht;
555     } /* Else is ok as is, add entry */
556 
557     hashable_val = code;
558     hash_num = hashable_val %
559         hash_table_base->tb_table_entry_count;
560     entry_base = hash_table_base->tb_entries;
561     entry_cur  = entry_base + hash_num;
562 
563     /* Determine if the 'code' is the list of synonyms already. */
564     for (hash_abbrev_entry = entry_cur->at_head;
565         hash_abbrev_entry != NULL && hash_abbrev_entry->abl_code != code;
566         hash_abbrev_entry = hash_abbrev_entry->abl_next);
567     if (hash_abbrev_entry != NULL) {
568         /*  This returns a pointer to an abbrev list entry, not
569             the list itself. */
570         *list_out = hash_abbrev_entry;
571         return DW_DLV_OK;
572     }
573 
574     if (cu_context->cc_last_abbrev_ptr) {
575         abbrev_ptr = cu_context->cc_last_abbrev_ptr;
576         end_abbrev_ptr = cu_context->cc_last_abbrev_endptr;
577     } else {
578         /*  This is ok because cc_abbrev_offset includes DWP
579             offset if appropriate. */
580         abbrev_ptr = dbg->de_debug_abbrev.dss_data +
581             cu_context->cc_abbrev_offset;
582 
583         if (cu_context->cc_dwp_offsets.pcu_type)  {
584             /*  In a DWP the abbrevs
585                 for this context are known quite precisely. */
586             Dwarf_Unsigned size = 0;
587             /* Ignore the offset returned. Already in cc_abbrev_offset. */
588             _dwarf_get_dwp_extra_offset(&cu_context->cc_dwp_offsets,
589                 DW_SECT_ABBREV,&size);
590             /*  ASSERT: size != 0 */
591             end_abbrev_ptr = abbrev_ptr + size;
592         } else {
593             end_abbrev_ptr = dbg->de_debug_abbrev.dss_data +
594                 dbg->de_debug_abbrev.dss_size;
595         }
596     }
597 
598     /*  End of abbrev's as we are past the end entirely.
599         This can happen,though it seems wrong.
600         Or we are at the end of the data block,
601         which we also take as
602         meaning done with abbrevs for this CU. An abbreviations table
603         is supposed to end with a zero byte. Not ended by end
604         of data block.  But we are allowing what is possibly a bit
605         more flexible end policy here. */
606     if (abbrev_ptr >= end_abbrev_ptr) {
607         return DW_DLV_NO_ENTRY;
608     }
609     /*  End of abbrev's for this cu, since abbrev code is 0. */
610     if (*abbrev_ptr == 0) {
611         return DW_DLV_NO_ENTRY;
612     }
613 
614     do {
615         unsigned new_hashable_val = 0;
616         Dwarf_Off  abb_goff = 0;
617         Dwarf_Unsigned atcount = 0;
618 
619         abb_goff = abbrev_ptr - dbg->de_debug_abbrev.dss_data;
620         DECODE_LEB128_UWORD_CK(abbrev_ptr, abbrev_code,
621             dbg,error,end_abbrev_ptr);
622         DECODE_LEB128_UWORD_CK(abbrev_ptr, abbrev_tag,
623             dbg,error,end_abbrev_ptr);
624 
625         if (abbrev_ptr >= end_abbrev_ptr) {
626             _dwarf_error(dbg, error, DW_DLE_ABBREV_OFF_END);
627             return DW_DLV_ERROR;
628         }
629 
630         inner_list_entry = (Dwarf_Abbrev_List)
631             _dwarf_get_alloc(cu_context->cc_dbg, DW_DLA_ABBREV_LIST, 1);
632         if (inner_list_entry == NULL) {
633             _dwarf_error(dbg, error, DW_DLE_ALLOC_FAIL);
634             return DW_DLV_ERROR;
635         }
636 
637         new_hashable_val = abbrev_code;
638         hash_num = new_hashable_val %
639             hash_table_base->tb_table_entry_count;
640         inner_hash_entry = entry_base + hash_num;
641         /* Move_entry_to_new_hash */
642         inner_list_entry->abl_next = inner_hash_entry->at_head;
643         inner_hash_entry->at_head = inner_list_entry;
644 
645         hash_table_base->tb_total_abbrev_count++;
646 
647         inner_list_entry->abl_code = abbrev_code;
648         inner_list_entry->abl_tag = abbrev_tag;
649         inner_list_entry->abl_has_child = *(abbrev_ptr++);
650         inner_list_entry->abl_abbrev_ptr = abbrev_ptr;
651         inner_list_entry->abl_goffset =  abb_goff;
652 
653         hash_table_base->tb_total_abbrev_count++;
654 
655         /*  Cycle thru the abbrev content, ignoring the content except
656             to find the end of the content. */
657         do {
658             DECODE_LEB128_UWORD_CK(abbrev_ptr, attr_name,
659                 dbg,error,end_abbrev_ptr);
660             DECODE_LEB128_UWORD_CK(abbrev_ptr, attr_form,
661                 dbg,error,end_abbrev_ptr);
662             if (!_dwarf_valid_form_we_know(dbg,attr_form,attr_name)) {
663                 _dwarf_error(dbg,error,DW_DLE_UNKNOWN_FORM);
664                 return DW_DLV_ERROR;
665             }
666             atcount++;
667         } while (attr_name != 0 && attr_form != 0);
668         /*  We counted one too high, by counting the NUL
669             byte pair at end of list. So decrement. */
670         inner_list_entry->abl_count = atcount-1;
671 
672         /*  The abbreviations table ends with an entry with a single
673             byte of zero for the abbreviation code.
674             Padding bytes following that zero are allowed, but
675             here we simply stop looking past that zero abbrev.
676 
677             We also stop looking if the block/section ends,
678             though the DWARF2 and later standards do not specifically
679             allow section/block end to terminate an abbreviations list. */
680 
681     } while ((abbrev_ptr < end_abbrev_ptr) &&
682         *abbrev_ptr != 0 && abbrev_code != code);
683 
684     cu_context->cc_last_abbrev_ptr = abbrev_ptr;
685     cu_context->cc_last_abbrev_endptr = end_abbrev_ptr;
686     if(abbrev_code == code) {
687         *list_out = inner_list_entry;
688         return DW_DLV_OK;
689     }
690     return DW_DLV_NO_ENTRY;
691 }
692 
693 
694 /*
695     We check that:
696         areaptr <= strptr.
697         a NUL byte (*p) exists at p < end.
698     and return DW_DLV_ERROR if a check fails.
699 
700     de_assume_string_in_bounds
701 */
702 int
_dwarf_check_string_valid(Dwarf_Debug dbg,void * areaptr,void * strptr,void * areaendptr,int suggested_error,Dwarf_Error * error)703 _dwarf_check_string_valid(Dwarf_Debug dbg,void *areaptr,
704     void *strptr, void *areaendptr,
705     int suggested_error,
706     Dwarf_Error*error)
707 {
708     Dwarf_Small *start = areaptr;
709     Dwarf_Small *p = strptr;
710     Dwarf_Small *end = areaendptr;
711 
712     if (p < start) {
713         _dwarf_error(dbg,error,suggested_error);
714         return DW_DLV_ERROR;
715     }
716     if (p >= end) {
717         _dwarf_error(dbg,error,suggested_error);
718         return DW_DLV_ERROR;
719     }
720     if (dbg->de_assume_string_in_bounds) {
721         /* This NOT the default. But folks can choose
722             to live dangerously and just assume strings ok. */
723         return DW_DLV_OK;
724     }
725     while (p < end) {
726         if (*p == 0) {
727             return DW_DLV_OK;
728         }
729         ++p;
730     }
731     _dwarf_error(dbg,error,DW_DLE_STRING_NOT_TERMINATED);
732     return DW_DLV_ERROR;
733 }
734 
735 
736 /*  Return non-zero if the start/end are not valid for the
737     die's section.
738     If pastend matches the dss_data+dss_size then
739     pastend is a pointer that cannot be dereferenced.
740     But we allow it as valid here, it is normal for
741     a pointer to point one-past-end in
742     various circumstances (one must
743     avoid dereferencing it, of course).
744     Return 0 if valid. Return 1 if invalid. */
745 int
_dwarf_reference_outside_section(Dwarf_Die die,Dwarf_Small * startaddr,Dwarf_Small * pastend)746 _dwarf_reference_outside_section(Dwarf_Die die,
747     Dwarf_Small * startaddr,
748     Dwarf_Small * pastend)
749 {
750     Dwarf_Debug dbg = 0;
751     Dwarf_CU_Context contxt = 0;
752     struct Dwarf_Section_s *sec = 0;
753 
754     contxt = die->di_cu_context;
755     dbg = contxt->cc_dbg;
756     if (die->di_is_info) {
757         sec = &dbg->de_debug_info;
758     } else {
759         sec = &dbg->de_debug_types;
760     }
761     if (startaddr < sec->dss_data) {
762         return 1;
763     }
764     if (pastend > (sec->dss_data + sec->dss_size)) {
765         return 1;
766     }
767     return 0;
768 }
769 
770 
771 /*
772   A byte-swapping version of memcpy
773   for cross-endian use.
774   Only 2,4,8 should be lengths passed in.
775 */
776 void *
_dwarf_memcpy_swap_bytes(void * s1,const void * s2,size_t len)777 _dwarf_memcpy_swap_bytes(void *s1, const void *s2, size_t len)
778 {
779     void *orig_s1 = s1;
780     unsigned char *targ = (unsigned char *) s1;
781     const unsigned char *src = (const unsigned char *) s2;
782 
783     if (len == 4) {
784         targ[3] = src[0];
785         targ[2] = src[1];
786         targ[1] = src[2];
787         targ[0] = src[3];
788     } else if (len == 8) {
789         targ[7] = src[0];
790         targ[6] = src[1];
791         targ[5] = src[2];
792         targ[4] = src[3];
793         targ[3] = src[4];
794         targ[2] = src[5];
795         targ[1] = src[6];
796         targ[0] = src[7];
797     } else if (len == 2) {
798         targ[1] = src[0];
799         targ[0] = src[1];
800     }
801 /* should NOT get below here: is not the intended use */
802     else if (len == 1) {
803         targ[0] = src[0];
804     } else {
805         memcpy(s1, s2, len);
806     }
807 
808     return orig_s1;
809 }
810 
811 
812 /*  This calculation used to be sprinkled all over.
813     Now brought to one place.
814 
815     We try to accurately compute the size of a cu header
816     given a known cu header location ( an offset in .debug_info
817     or debug_types).  */
818 /* ARGSUSED */
819 int
_dwarf_length_of_cu_header(Dwarf_Debug dbg,Dwarf_Unsigned offset,Dwarf_Bool is_info,Dwarf_Unsigned * area_length_out,Dwarf_Error * error)820 _dwarf_length_of_cu_header(Dwarf_Debug dbg, Dwarf_Unsigned offset,
821     Dwarf_Bool is_info,
822     Dwarf_Unsigned *area_length_out,
823     Dwarf_Error *error)
824 {
825     int local_length_size = 0;
826     int local_extension_size = 0;
827     Dwarf_Unsigned length = 0;
828     Dwarf_Unsigned final_size = 0;
829     Dwarf_Small *section_start =
830         is_info? dbg->de_debug_info.dss_data:
831             dbg->de_debug_types.dss_data;
832     Dwarf_Small *cuptr = section_start + offset;
833     Dwarf_Unsigned section_length =
834         is_info? dbg->de_debug_info.dss_size:
835             dbg->de_debug_types.dss_size;
836     Dwarf_Small * section_end_ptr =
837         section_start + section_length;
838 
839     READ_AREA_LENGTH_CK(dbg, length, Dwarf_Unsigned,
840         cuptr, local_length_size, local_extension_size,
841         error,section_length,section_end_ptr);
842 
843     final_size = local_extension_size +  /* initial extension, if present */
844         local_length_size +     /* Size of cu length field. */
845         sizeof(Dwarf_Half) +    /* Size of version stamp field. */
846         local_length_size +     /* Size of abbrev offset field. */
847         sizeof(Dwarf_Small);    /* Size of address size field. */
848 
849     if (!is_info) {
850         final_size +=
851             /* type signature size */
852             sizeof (Dwarf_Sig8) +
853             /* type offset size */
854             local_length_size;
855     }
856     *area_length_out = final_size;
857     return DW_DLV_OK;
858 }
859 
860 /*  Pretend we know nothing about the CU
861     and just roughly compute the result.  */
862 Dwarf_Unsigned
_dwarf_length_of_cu_header_simple(Dwarf_Debug dbg,Dwarf_Bool dinfo)863 _dwarf_length_of_cu_header_simple(Dwarf_Debug dbg,
864     Dwarf_Bool dinfo)
865 {
866     Dwarf_Unsigned finalsize = 0;
867     finalsize =  dbg->de_length_size +        /* Size of cu length field. */
868         sizeof(Dwarf_Half) +    /* Size of version stamp field. */
869         dbg->de_length_size +   /* Size of abbrev offset field. */
870         sizeof(Dwarf_Small);    /* Size of address size field. */
871     if (!dinfo) {
872         finalsize +=
873             /* type signature size */
874             sizeof (Dwarf_Sig8) +
875             /* type offset size */
876             dbg->de_length_size;
877     }
878     return finalsize;
879 }
880 
881 /*  Now that we delay loading .debug_info, we need to do the
882     load in more places. So putting the load
883     code in one place now instead of replicating it in multiple
884     places.  */
885 int
_dwarf_load_debug_info(Dwarf_Debug dbg,Dwarf_Error * error)886 _dwarf_load_debug_info(Dwarf_Debug dbg, Dwarf_Error * error)
887 {
888     int res = DW_DLV_ERROR;
889     if (dbg->de_debug_info.dss_data) {
890         return DW_DLV_OK;
891     }
892     res = _dwarf_load_section(dbg, &dbg->de_debug_abbrev,error);
893     if (res != DW_DLV_OK) {
894         return res;
895     }
896     res = _dwarf_load_section(dbg, &dbg->de_debug_info, error);
897     return res;
898 }
899 int
_dwarf_load_debug_types(Dwarf_Debug dbg,Dwarf_Error * error)900 _dwarf_load_debug_types(Dwarf_Debug dbg, Dwarf_Error * error)
901 {
902     int res = DW_DLV_ERROR;
903     if (dbg->de_debug_types.dss_data) {
904         return DW_DLV_OK;
905     }
906     res = _dwarf_load_section(dbg, &dbg->de_debug_abbrev,error);
907     if (res != DW_DLV_OK) {
908         return res;
909     }
910     res = _dwarf_load_section(dbg, &dbg->de_debug_types, error);
911     return res;
912 }
913 void
_dwarf_free_abbrev_hash_table_contents(Dwarf_Debug dbg,Dwarf_Hash_Table hash_table)914 _dwarf_free_abbrev_hash_table_contents(Dwarf_Debug dbg,Dwarf_Hash_Table hash_table)
915 {
916     /*  A Hash Table is an array with tb_table_entry_count struct
917         Dwarf_Hash_Table_s entries in the array. */
918     unsigned hashnum = 0;
919     for (; hashnum < hash_table->tb_table_entry_count; ++hashnum) {
920         struct Dwarf_Abbrev_List_s *abbrev = 0;
921         struct Dwarf_Abbrev_List_s *nextabbrev = 0;
922         struct  Dwarf_Hash_Table_Entry_s *tb =  &hash_table->tb_entries[hashnum];
923 
924         abbrev = tb->at_head;
925         for (; abbrev; abbrev = nextabbrev) {
926             nextabbrev = abbrev->abl_next;
927             abbrev->abl_next = 0;
928             dwarf_dealloc(dbg, abbrev, DW_DLA_ABBREV_LIST);
929         }
930         tb->at_head = 0;
931     }
932     /* Frees all the entries at once: an array. */
933     dwarf_dealloc(dbg,hash_table->tb_entries,DW_DLA_HASH_TABLE_ENTRY);
934     hash_table->tb_entries = 0;
935 }
936 
937 /*
938     If no die provided the size value returned might be wrong.
939     If different compilation units have different address sizes
940     this may not give the correct value in all contexts if the die
941     pointer is NULL.
942     If the Elf offset size != address_size
943     (for example if address_size = 4 but recorded in elf64 object)
944     this may not give the correct value in all contexts if the die
945     pointer is NULL.
946     If the die pointer is non-NULL (in which case it must point to
947     a valid DIE) this will return the correct size.
948 */
949 int
_dwarf_get_address_size(Dwarf_Debug dbg,Dwarf_Die die)950 _dwarf_get_address_size(Dwarf_Debug dbg, Dwarf_Die die)
951 {
952     Dwarf_CU_Context context = 0;
953     Dwarf_Half addrsize = 0;
954     if (!die) {
955         return dbg->de_pointer_size;
956     }
957     context = die->di_cu_context;
958     addrsize = context->cc_address_size;
959     return addrsize;
960 }
961 
962 /* Encode val as an unsigned LEB128. */
dwarf_encode_leb128(Dwarf_Unsigned val,int * nbytes,char * space,int splen)963 int dwarf_encode_leb128(Dwarf_Unsigned val, int *nbytes,
964     char *space, int splen)
965 {
966     /* Encode val as an unsigned LEB128. */
967     return _dwarf_pro_encode_leb128_nm(val,nbytes,space,splen);
968 }
969 
970 /* Encode val as a signed LEB128. */
dwarf_encode_signed_leb128(Dwarf_Signed val,int * nbytes,char * space,int splen)971 int dwarf_encode_signed_leb128(Dwarf_Signed val, int *nbytes,
972     char *space, int splen)
973 {
974     /* Encode val as a signed LEB128. */
975     return _dwarf_pro_encode_signed_leb128_nm(val,nbytes,space,splen);
976 }
977 
978 
979 struct  Dwarf_Printf_Callback_Info_s
dwarf_register_printf_callback(Dwarf_Debug dbg,struct Dwarf_Printf_Callback_Info_s * newvalues)980 dwarf_register_printf_callback( Dwarf_Debug dbg,
981     struct  Dwarf_Printf_Callback_Info_s * newvalues)
982 {
983     struct  Dwarf_Printf_Callback_Info_s oldval = dbg->de_printf_callback;
984     if (!newvalues) {
985         return oldval;
986     }
987     if( newvalues->dp_buffer_user_provided) {
988         if( oldval.dp_buffer_user_provided) {
989             /* User continues to control the buffer. */
990             dbg->de_printf_callback = *newvalues;
991         }else {
992             /*  Switch from our control of buffer to user
993                 control.  */
994             free(oldval.dp_buffer);
995             oldval.dp_buffer = 0;
996             dbg->de_printf_callback = *newvalues;
997         }
998     } else if (oldval.dp_buffer_user_provided){
999         /* Switch from user control to our control */
1000         dbg->de_printf_callback = *newvalues;
1001         dbg->de_printf_callback.dp_buffer_len = 0;
1002         dbg->de_printf_callback.dp_buffer= 0;
1003     } else {
1004         /* User does not control the buffer. */
1005         dbg->de_printf_callback = *newvalues;
1006         dbg->de_printf_callback.dp_buffer_len =
1007             oldval.dp_buffer_len;
1008         dbg->de_printf_callback.dp_buffer =
1009             oldval.dp_buffer;
1010     }
1011     return oldval;
1012 }
1013 
1014 
1015 /* start is a minimum size, but may be zero. */
bufferdoublesize(struct Dwarf_Printf_Callback_Info_s * bufdata)1016 static void bufferdoublesize(struct  Dwarf_Printf_Callback_Info_s *bufdata)
1017 {
1018     char *space = 0;
1019     unsigned int targlen = 0;
1020     if (bufdata->dp_buffer_len == 0) {
1021         targlen = MINBUFLEN;
1022     } else {
1023         targlen = bufdata->dp_buffer_len * 2;
1024         if (targlen < bufdata->dp_buffer_len) {
1025             /* Overflow, we cannot do this doubling. */
1026             return;
1027         }
1028     }
1029     /* Make big enough for a trailing NUL char. */
1030     space = (char *)malloc(targlen+1);
1031     if (!space) {
1032         /* Out of space, we cannot double it. */
1033         return;
1034     }
1035     free(bufdata->dp_buffer);
1036     bufdata->dp_buffer = space;
1037     bufdata->dp_buffer_len = targlen;
1038     return;
1039 }
1040 
1041 int
dwarf_printf(Dwarf_Debug dbg,const char * format,...)1042 dwarf_printf(Dwarf_Debug dbg,
1043     const char * format,
1044     ...)
1045 {
1046     va_list ap;
1047     int maxtries = 4;
1048     int tries = 0;
1049     struct Dwarf_Printf_Callback_Info_s *bufdata =
1050         &dbg->de_printf_callback;
1051     dwarf_printf_callback_function_type func = bufdata->dp_fptr;
1052     if (!func) {
1053         return 0;
1054     }
1055     if (!bufdata->dp_buffer) {
1056         bufferdoublesize(bufdata);
1057         if (!bufdata->dp_buffer) {
1058             /*  Something is wrong. Possibly caller
1059                 set up callback wrong. */
1060             return 0;
1061         }
1062     }
1063 
1064     /*  Here we ensure (or nearly ensure) we expand
1065         the buffer when necessary, but not excessively
1066         (but only if we control the buffer size).  */
1067     while (1) {
1068         int olen = 0;
1069         tries++;
1070         va_start(ap,format);
1071         olen = vsnprintf(bufdata->dp_buffer,
1072             bufdata->dp_buffer_len, format,ap);
1073         /*  "The object ap may be passed as an argument to another
1074             function; if that function invokes the va_arg()
1075             macro with parameter ap, the value of ap in the calling
1076             function is unspecified and shall be passed to the va_end()
1077             macro prior to any further reference to ap."
1078             Single Unix Specification. */
1079         va_end(ap);
1080         if (olen > -1 && (long)olen < (long)bufdata->dp_buffer_len) {
1081             /*  The caller had better copy or dispose
1082                 of the contents, as next-call will overwrite them. */
1083             func(bufdata->dp_user_pointer,bufdata->dp_buffer);
1084             return 0;
1085         }
1086         if (bufdata->dp_buffer_user_provided) {
1087             func(bufdata->dp_user_pointer,bufdata->dp_buffer);
1088             return 0;
1089         }
1090         if (tries > maxtries) {
1091             /* we did all we could, print what we have space for. */
1092             func(bufdata->dp_user_pointer,bufdata->dp_buffer);
1093             return 0;
1094         }
1095         bufferdoublesize(bufdata);
1096     }
1097     /* Not reached. */
1098     return 0;
1099 }
1100 
1101 /*  Often errs and errt point to the same Dwarf_Error,
1102     So exercise care.
1103     All the arguments MUST be non-null.*/
1104 void
_dwarf_error_mv_s_to_t(Dwarf_Debug dbgs,Dwarf_Error * errs,Dwarf_Debug dbgt,Dwarf_Error * errt)1105 _dwarf_error_mv_s_to_t(Dwarf_Debug dbgs,Dwarf_Error *errs,
1106     Dwarf_Debug dbgt,Dwarf_Error *errt)
1107 {
1108     if (!errt || !errs) {
1109         return;
1110     }
1111     if (!dbgs || !dbgt) {
1112         return;
1113     }
1114     if(dbgs == dbgt) {
1115         if(errs != errt) {
1116             Dwarf_Error ers = *errs;
1117             *errs = 0;
1118             *errt = ers;
1119         }
1120     } else {
1121         /*  Do not stomp on the system errno
1122             variable if there is one! */
1123         int mydw_errno = dwarf_errno(*errs);
1124 
1125         dwarf_dealloc(dbgs,*errs, DW_DLA_ERROR);
1126         *errs = 0;
1127         _dwarf_error(dbgt,errt, mydw_errno);
1128     }
1129 }
1130 
1131 static int
inthissection(struct Dwarf_Section_s * sec,Dwarf_Small * ptr)1132 inthissection(struct Dwarf_Section_s *sec,Dwarf_Small *ptr)
1133 {
1134     if (!sec->dss_data) {
1135         return FALSE;
1136     }
1137     if (ptr < sec->dss_data ) {
1138         return FALSE;
1139     }
1140     if (ptr >= (sec->dss_data + sec->dss_size) ) {
1141         return FALSE;
1142     }
1143     return TRUE;
1144 }
1145 
1146 #define FINDSEC(m_s,m_p,n,st,l,e)    \
1147 do {                                 \
1148     if (inthissection((m_s),(m_p))) { \
1149         *(n) = (m_s)->dss_name;      \
1150         *(st)= (m_s)->dss_data;      \
1151         *(l) = (m_s)->dss_size;      \
1152         *(e) = (m_s)->dss_data + (m_s)->dss_size; \
1153         return DW_DLV_OK;            \
1154     }                                \
1155 } while (0)
1156 
1157 
1158 /* So we can know a section end even when we do not
1159     have the section info apriori  It's only
1160     needed for a subset of sections. */
1161 int
_dwarf_what_section_are_we(Dwarf_Debug dbg,Dwarf_Small * our_pointer,const char ** section_name_out,Dwarf_Small ** sec_start_ptr_out,Dwarf_Unsigned * sec_len_out,Dwarf_Small ** sec_end_ptr_out,UNUSEDARG Dwarf_Error * error)1162 _dwarf_what_section_are_we(Dwarf_Debug dbg,
1163     Dwarf_Small    *  our_pointer,
1164     const char     ** section_name_out,
1165     Dwarf_Small    ** sec_start_ptr_out,
1166     Dwarf_Unsigned *  sec_len_out,
1167     Dwarf_Small    ** sec_end_ptr_out,
1168     UNUSEDARG Dwarf_Error    *  error)
1169 {
1170     FINDSEC(&dbg->de_debug_info,
1171         our_pointer, section_name_out,
1172         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1173     FINDSEC(&dbg->de_debug_loc,
1174         our_pointer, section_name_out,
1175         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1176     FINDSEC(&dbg->de_debug_line,
1177         our_pointer, section_name_out,
1178         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1179     FINDSEC(&dbg->de_debug_aranges,
1180         our_pointer, section_name_out,
1181         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1182     FINDSEC(&dbg->de_debug_macro,
1183         our_pointer, section_name_out,
1184         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1185     FINDSEC(&dbg->de_debug_ranges,
1186         our_pointer, section_name_out,
1187         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1188     FINDSEC(&dbg->de_debug_str_offsets,
1189         our_pointer, section_name_out,
1190         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1191     FINDSEC(&dbg->de_debug_addr,
1192         our_pointer, section_name_out,
1193         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1194     FINDSEC(&dbg->de_debug_pubtypes,
1195         our_pointer, section_name_out,
1196         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1197     FINDSEC(&dbg->de_debug_gdbindex,
1198         our_pointer, section_name_out,
1199         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1200     FINDSEC(&dbg->de_debug_abbrev,
1201         our_pointer, section_name_out,
1202         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1203     FINDSEC(&dbg->de_debug_cu_index,
1204         our_pointer, section_name_out,
1205         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1206     FINDSEC(&dbg->de_debug_tu_index,
1207         our_pointer, section_name_out,
1208         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1209     FINDSEC(&dbg->de_debug_line_str,
1210         our_pointer, section_name_out,
1211         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1212     FINDSEC(&dbg->de_debug_types,
1213         our_pointer, section_name_out,
1214         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1215     FINDSEC(&dbg->de_debug_sup,
1216         our_pointer, section_name_out,
1217         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1218     FINDSEC(&dbg->de_debug_frame,
1219         our_pointer, section_name_out,
1220         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1221     FINDSEC(&dbg->de_debug_frame_eh_gnu,
1222         our_pointer, section_name_out,
1223         sec_start_ptr_out, sec_len_out, sec_end_ptr_out);
1224     return DW_DLV_NO_ENTRY;
1225 }
1226 
1227 
1228 
1229