daily update
[binutils.git] / bfd / stabs.c
blob42944a41bf19a1afa81234667f109cd62db89f5f
1 /* Stabs in sections linking support.
2 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support.
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 /* This file contains support for linking stabs in sections, as used
23 on COFF and ELF. */
25 #include "bfd.h"
26 #include "sysdep.h"
27 #include "libbfd.h"
28 #include "aout/stab_gnu.h"
29 #include "safe-ctype.h"
31 /* Stabs entries use a 12 byte format:
32 4 byte string table index
33 1 byte stab type
34 1 byte stab other field
35 2 byte stab desc field
36 4 byte stab value
37 FIXME: This will have to change for a 64 bit object format.
39 The stabs symbols are divided into compilation units. For the
40 first entry in each unit, the type of 0, the value is the length of
41 the string table for this unit, and the desc field is the number of
42 stabs symbols for this unit. */
44 #define STRDXOFF (0)
45 #define TYPEOFF (4)
46 #define OTHEROFF (5)
47 #define DESCOFF (6)
48 #define VALOFF (8)
49 #define STABSIZE (12)
51 /* A hash table used for header files with N_BINCL entries. */
53 struct stab_link_includes_table
55 struct bfd_hash_table root;
58 /* A linked list of totals that we have found for a particular header
59 file. */
61 struct stab_link_includes_totals
63 struct stab_link_includes_totals *next;
64 bfd_vma total;
67 /* An entry in the header file hash table. */
69 struct stab_link_includes_entry
71 struct bfd_hash_entry root;
72 /* List of totals we have found for this file. */
73 struct stab_link_includes_totals *totals;
76 /* Look up an entry in an the header file hash table. */
78 #define stab_link_includes_lookup(table, string, create, copy) \
79 ((struct stab_link_includes_entry *) \
80 bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
82 /* This structure is used to hold a list of N_BINCL symbols, some of
83 which might be converted into N_EXCL symbols. */
85 struct stab_excl_list
87 /* The next symbol to convert. */
88 struct stab_excl_list *next;
89 /* The offset to this symbol in the section contents. */
90 bfd_size_type offset;
91 /* The value to use for the symbol. */
92 bfd_vma val;
93 /* The type of this symbol (N_BINCL or N_EXCL). */
94 int type;
97 /* This structure is stored with each .stab section. */
99 struct stab_section_info
101 /* This is a linked list of N_BINCL symbols which should be
102 converted into N_EXCL symbols. */
103 struct stab_excl_list *excls;
105 /* This is used to map input stab offsets within their sections
106 to output stab offsets, to take into account stabs that have
107 been deleted. If it is NULL, the output offsets are the same
108 as the input offsets, because no stabs have been deleted from
109 this section. Otherwise the i'th entry is the number of
110 bytes of stabs that have been deleted prior to the i'th
111 stab. */
112 bfd_size_type *cumulative_skips;
114 /* This is an array of string indices. For each stab symbol, we
115 store the string index here. If a stab symbol should not be
116 included in the final output, the string index is -1. */
117 bfd_size_type stridxs[1];
120 /* This structure is used to keep track of stabs in sections
121 information while linking. */
123 struct stab_info
125 /* A hash table used to hold stabs strings. */
126 struct bfd_strtab_hash *strings;
127 /* The header file hash table. */
128 struct stab_link_includes_table includes;
129 /* The first .stabstr section. */
130 asection *stabstr;
133 static struct bfd_hash_entry *stab_link_includes_newfunc
134 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
136 /* The function to create a new entry in the header file hash table. */
138 static struct bfd_hash_entry *
139 stab_link_includes_newfunc (entry, table, string)
140 struct bfd_hash_entry *entry;
141 struct bfd_hash_table *table;
142 const char *string;
144 struct stab_link_includes_entry *ret =
145 (struct stab_link_includes_entry *) entry;
147 /* Allocate the structure if it has not already been allocated by a
148 subclass. */
149 if (ret == (struct stab_link_includes_entry *) NULL)
150 ret = ((struct stab_link_includes_entry *)
151 bfd_hash_allocate (table,
152 sizeof (struct stab_link_includes_entry)));
153 if (ret == (struct stab_link_includes_entry *) NULL)
154 return (struct bfd_hash_entry *) ret;
156 /* Call the allocation method of the superclass. */
157 ret = ((struct stab_link_includes_entry *)
158 bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
159 if (ret)
161 /* Set local fields. */
162 ret->totals = NULL;
165 return (struct bfd_hash_entry *) ret;
168 /* This function is called for each input file from the add_symbols
169 pass of the linker. */
171 bfd_boolean
172 _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo, pstring_offset)
173 bfd *abfd;
174 PTR *psinfo;
175 asection *stabsec;
176 asection *stabstrsec;
177 PTR *psecinfo;
178 bfd_size_type *pstring_offset;
180 bfd_boolean first;
181 struct stab_info *sinfo;
182 bfd_size_type count, amt;
183 struct stab_section_info *secinfo;
184 bfd_byte *stabbuf = NULL;
185 bfd_byte *stabstrbuf = NULL;
186 bfd_byte *sym, *symend;
187 bfd_size_type stroff, next_stroff, skip;
188 bfd_size_type *pstridx;
190 if (stabsec->_raw_size == 0
191 || stabstrsec->_raw_size == 0)
193 /* This file does not contain stabs debugging information. */
194 return TRUE;
197 if (stabsec->_raw_size % STABSIZE != 0)
199 /* Something is wrong with the format of these stab symbols.
200 Don't try to optimize them. */
201 return TRUE;
204 if ((stabstrsec->flags & SEC_RELOC) != 0)
206 /* We shouldn't see relocations in the strings, and we aren't
207 prepared to handle them. */
208 return TRUE;
211 if ((stabsec->output_section != NULL
212 && bfd_is_abs_section (stabsec->output_section))
213 || (stabstrsec->output_section != NULL
214 && bfd_is_abs_section (stabstrsec->output_section)))
216 /* At least one of the sections is being discarded from the
217 link, so we should just ignore them. */
218 return TRUE;
221 first = FALSE;
223 if (*psinfo == NULL)
225 /* Initialize the stabs information we need to keep track of. */
226 first = TRUE;
227 amt = sizeof (struct stab_info);
228 *psinfo = (PTR) bfd_alloc (abfd, amt);
229 if (*psinfo == NULL)
230 goto error_return;
231 sinfo = (struct stab_info *) *psinfo;
232 sinfo->strings = _bfd_stringtab_init ();
233 if (sinfo->strings == NULL)
234 goto error_return;
235 /* Make sure the first byte is zero. */
236 (void) _bfd_stringtab_add (sinfo->strings, "", TRUE, TRUE);
237 if (! bfd_hash_table_init_n (&sinfo->includes.root,
238 stab_link_includes_newfunc,
239 251))
240 goto error_return;
241 sinfo->stabstr = bfd_make_section_anyway (abfd, ".stabstr");
242 sinfo->stabstr->flags |= SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING;
245 sinfo = (struct stab_info *) *psinfo;
247 /* Initialize the information we are going to store for this .stab
248 section. */
250 count = stabsec->_raw_size / STABSIZE;
252 amt = sizeof (struct stab_section_info);
253 amt += (count - 1) * sizeof (bfd_size_type);
254 *psecinfo = bfd_alloc (abfd, amt);
255 if (*psecinfo == NULL)
256 goto error_return;
258 secinfo = (struct stab_section_info *) *psecinfo;
259 secinfo->excls = NULL;
260 secinfo->cumulative_skips = NULL;
261 memset (secinfo->stridxs, 0, (size_t) count * sizeof (bfd_size_type));
263 /* Read the stabs information from abfd. */
265 stabbuf = (bfd_byte *) bfd_malloc (stabsec->_raw_size);
266 stabstrbuf = (bfd_byte *) bfd_malloc (stabstrsec->_raw_size);
267 if (stabbuf == NULL || stabstrbuf == NULL)
268 goto error_return;
270 if (! bfd_get_section_contents (abfd, stabsec, stabbuf, (bfd_vma) 0,
271 stabsec->_raw_size)
272 || ! bfd_get_section_contents (abfd, stabstrsec, stabstrbuf, (bfd_vma) 0,
273 stabstrsec->_raw_size))
274 goto error_return;
276 /* Look through the stabs symbols, work out the new string indices,
277 and identify N_BINCL symbols which can be eliminated. */
279 stroff = 0;
280 /* The stabs sections can be split when
281 -split-by-reloc/-split-by-file is used. We must keep track of
282 each stab section's place in the single concatenated string
283 table. */
284 next_stroff = pstring_offset ? *pstring_offset : 0;
285 skip = 0;
287 symend = stabbuf + stabsec->_raw_size;
288 for (sym = stabbuf, pstridx = secinfo->stridxs;
289 sym < symend;
290 sym += STABSIZE, ++pstridx)
292 bfd_size_type symstroff;
293 int type;
294 const char *string;
296 if (*pstridx != 0)
298 /* This symbol has already been handled by an N_BINCL pass. */
299 continue;
302 type = sym[TYPEOFF];
304 if (type == 0)
306 /* Special type 0 stabs indicate the offset to the next
307 string table. We only copy the very first one. */
308 stroff = next_stroff;
309 next_stroff += bfd_get_32 (abfd, sym + 8);
310 if (pstring_offset)
311 *pstring_offset = next_stroff;
312 if (! first)
314 *pstridx = (bfd_size_type) -1;
315 ++skip;
316 continue;
318 first = FALSE;
321 /* Store the string in the hash table, and record the index. */
322 symstroff = stroff + bfd_get_32 (abfd, sym + STRDXOFF);
323 if (symstroff >= stabstrsec->_raw_size)
325 (*_bfd_error_handler)
326 (_("%s(%s+0x%lx): Stabs entry has invalid string index."),
327 bfd_archive_filename (abfd),
328 bfd_get_section_name (abfd, stabsec),
329 (long) (sym - stabbuf));
330 bfd_set_error (bfd_error_bad_value);
331 goto error_return;
333 string = (char *) stabstrbuf + symstroff;
334 *pstridx = _bfd_stringtab_add (sinfo->strings, string, TRUE, TRUE);
336 /* An N_BINCL symbol indicates the start of the stabs entries
337 for a header file. We need to scan ahead to the next N_EINCL
338 symbol, ignoring nesting, adding up all the characters in the
339 symbol names, not including the file numbers in types (the
340 first number after an open parenthesis). */
341 if (type == (int) N_BINCL)
343 bfd_vma val;
344 int nest;
345 bfd_byte *incl_sym;
346 struct stab_link_includes_entry *incl_entry;
347 struct stab_link_includes_totals *t;
348 struct stab_excl_list *ne;
350 val = 0;
351 nest = 0;
352 for (incl_sym = sym + STABSIZE;
353 incl_sym < symend;
354 incl_sym += STABSIZE)
356 int incl_type;
358 incl_type = incl_sym[TYPEOFF];
359 if (incl_type == 0)
360 break;
361 else if (incl_type == (int) N_EXCL)
362 continue;
363 else if (incl_type == (int) N_EINCL)
365 if (nest == 0)
366 break;
367 --nest;
369 else if (incl_type == (int) N_BINCL)
370 ++nest;
371 else if (nest == 0)
373 const char *str;
375 str = ((char *) stabstrbuf
376 + stroff
377 + bfd_get_32 (abfd, incl_sym + STRDXOFF));
378 for (; *str != '\0'; str++)
380 val += *str;
381 if (*str == '(')
383 /* Skip the file number. */
384 ++str;
385 while (ISDIGIT (*str))
386 ++str;
387 --str;
393 /* If we have already included a header file with the same
394 value, then replaced this one with an N_EXCL symbol. */
395 incl_entry = stab_link_includes_lookup (&sinfo->includes, string,
396 TRUE, TRUE);
397 if (incl_entry == NULL)
398 goto error_return;
400 for (t = incl_entry->totals; t != NULL; t = t->next)
401 if (t->total == val)
402 break;
404 /* Record this symbol, so that we can set the value
405 correctly. */
406 amt = sizeof *ne;
407 ne = (struct stab_excl_list *) bfd_alloc (abfd, amt);
408 if (ne == NULL)
409 goto error_return;
410 ne->offset = sym - stabbuf;
411 ne->val = val;
412 ne->type = (int) N_BINCL;
413 ne->next = secinfo->excls;
414 secinfo->excls = ne;
416 if (t == NULL)
418 /* This is the first time we have seen this header file
419 with this set of stabs strings. */
420 t = ((struct stab_link_includes_totals *)
421 bfd_hash_allocate (&sinfo->includes.root, sizeof *t));
422 if (t == NULL)
423 goto error_return;
424 t->total = val;
425 t->next = incl_entry->totals;
426 incl_entry->totals = t;
428 else
430 bfd_size_type *incl_pstridx;
432 /* We have seen this header file before. Tell the final
433 pass to change the type to N_EXCL. */
434 ne->type = (int) N_EXCL;
436 /* Mark the skipped symbols. */
438 nest = 0;
439 for (incl_sym = sym + STABSIZE, incl_pstridx = pstridx + 1;
440 incl_sym < symend;
441 incl_sym += STABSIZE, ++incl_pstridx)
443 int incl_type;
445 incl_type = incl_sym[TYPEOFF];
447 if (incl_type == (int) N_EINCL)
449 if (nest == 0)
451 *incl_pstridx = (bfd_size_type) -1;
452 ++skip;
453 break;
455 --nest;
457 else if (incl_type == (int) N_BINCL)
458 ++nest;
459 else if (nest == 0)
461 *incl_pstridx = (bfd_size_type) -1;
462 ++skip;
469 free (stabbuf);
470 stabbuf = NULL;
471 free (stabstrbuf);
472 stabstrbuf = NULL;
474 /* We need to set the section sizes such that the linker will
475 compute the output section sizes correctly. We set the .stab
476 size to not include the entries we don't want. We set
477 SEC_EXCLUDE for the .stabstr section, so that it will be dropped
478 from the link. We record the size of the strtab in the first
479 .stabstr section we saw, and make sure we don't set SEC_EXCLUDE
480 for that section. */
481 stabsec->_cooked_size = (count - skip) * STABSIZE;
482 if (stabsec->_cooked_size == 0)
483 stabsec->flags |= SEC_EXCLUDE;
484 stabstrsec->flags |= SEC_EXCLUDE;
485 sinfo->stabstr->_cooked_size = _bfd_stringtab_size (sinfo->strings);
487 /* Calculate the `cumulative_skips' array now that stabs have been
488 deleted for this section. */
490 if (skip != 0)
492 bfd_size_type i, offset;
493 bfd_size_type *pskips;
495 amt = count * sizeof (bfd_size_type);
496 secinfo->cumulative_skips = (bfd_size_type *) bfd_alloc (abfd, amt);
497 if (secinfo->cumulative_skips == NULL)
498 goto error_return;
500 pskips = secinfo->cumulative_skips;
501 pstridx = secinfo->stridxs;
502 offset = 0;
504 for (i = 0; i < count; i++, pskips++, pstridx++)
506 *pskips = offset;
507 if (*pstridx == (bfd_size_type) -1)
508 offset += STABSIZE;
511 BFD_ASSERT (offset != 0);
514 return TRUE;
516 error_return:
517 if (stabbuf != NULL)
518 free (stabbuf);
519 if (stabstrbuf != NULL)
520 free (stabstrbuf);
521 return FALSE;
525 /* This function is called for each input file before the stab
526 section is relocated. It discards stab entries for discarded
527 functions and variables. The function returns TRUE iff
528 any entries have been deleted.
531 bfd_boolean
532 _bfd_discard_section_stabs (abfd, stabsec, psecinfo,
533 reloc_symbol_deleted_p, cookie)
534 bfd *abfd;
535 asection *stabsec;
536 PTR psecinfo;
537 bfd_boolean (*reloc_symbol_deleted_p) PARAMS ((bfd_vma, PTR));
538 PTR cookie;
540 bfd_size_type count, amt;
541 struct stab_section_info *secinfo;
542 bfd_byte *stabbuf = NULL;
543 bfd_byte *sym, *symend;
544 bfd_size_type skip;
545 bfd_size_type *pstridx;
546 int deleting;
548 if (stabsec->_raw_size == 0)
550 /* This file does not contain stabs debugging information. */
551 return FALSE;
554 if (stabsec->_raw_size % STABSIZE != 0)
556 /* Something is wrong with the format of these stab symbols.
557 Don't try to optimize them. */
558 return FALSE;
561 if ((stabsec->output_section != NULL
562 && bfd_is_abs_section (stabsec->output_section)))
564 /* At least one of the sections is being discarded from the
565 link, so we should just ignore them. */
566 return FALSE;
569 /* We should have initialized our data in _bfd_link_stab_sections.
570 If there was some bizarre error reading the string sections, though,
571 we might not have. Bail rather than asserting. */
572 if (psecinfo == NULL)
573 return FALSE;
575 count = stabsec->_raw_size / STABSIZE;
576 secinfo = (struct stab_section_info *) psecinfo;
578 /* Read the stabs information from abfd. */
580 stabbuf = (bfd_byte *) bfd_malloc (stabsec->_raw_size);
581 if (stabbuf == NULL)
582 goto error_return;
584 if (! bfd_get_section_contents (abfd, stabsec, stabbuf, (bfd_vma) 0,
585 stabsec->_raw_size))
586 goto error_return;
588 /* Look through the stabs symbols and discard any information for
589 discarded functions. */
591 skip = 0;
592 deleting = -1;
594 symend = stabbuf + stabsec->_raw_size;
595 for (sym = stabbuf, pstridx = secinfo->stridxs;
596 sym < symend;
597 sym += STABSIZE, ++pstridx)
599 int type;
601 if (*pstridx == (bfd_size_type) -1)
603 /* This stab was deleted in a previous pass. */
604 continue;
607 type = sym[TYPEOFF];
609 if (type == (int) N_FUN)
611 int strx = bfd_get_32 (abfd, sym + STRDXOFF);
613 if (strx == 0)
615 if (deleting)
617 skip++;
618 *pstridx = -1;
620 deleting = -1;
621 continue;
623 deleting = 0;
624 if ((*reloc_symbol_deleted_p) (sym + VALOFF - stabbuf, cookie))
625 deleting = 1;
628 if (deleting == 1)
630 *pstridx = -1;
631 skip++;
633 else if (deleting == -1)
635 /* Outside of a function. Check for deleted variables. */
636 if (type == (int) N_STSYM || type == (int) N_LCSYM)
637 if ((*reloc_symbol_deleted_p) (sym + VALOFF - stabbuf, cookie))
639 *pstridx = -1;
640 skip ++;
642 /* We should also check for N_GSYM entries which reference a
643 deleted global, but those are less harmful to debuggers
644 and would require parsing the stab strings. */
648 free (stabbuf);
649 stabbuf = NULL;
651 /* Shrink the stabsec as needed. */
652 stabsec->_cooked_size -= skip * STABSIZE;
653 if (stabsec->_cooked_size == 0)
654 stabsec->flags |= SEC_EXCLUDE;
656 /* Recalculate the `cumulative_skips' array now that stabs have been
657 deleted for this section. */
659 if (skip != 0)
661 bfd_size_type i, offset;
662 bfd_size_type *pskips;
664 if (secinfo->cumulative_skips == NULL)
666 amt = count * sizeof (bfd_size_type);
667 secinfo->cumulative_skips = (bfd_size_type *) bfd_alloc (abfd, amt);
668 if (secinfo->cumulative_skips == NULL)
669 goto error_return;
672 pskips = secinfo->cumulative_skips;
673 pstridx = secinfo->stridxs;
674 offset = 0;
676 for (i = 0; i < count; i++, pskips++, pstridx++)
678 *pskips = offset;
679 if (*pstridx == (bfd_size_type) -1)
680 offset += STABSIZE;
683 BFD_ASSERT (offset != 0);
686 return skip > 0;
688 error_return:
689 if (stabbuf != NULL)
690 free (stabbuf);
691 return FALSE;
694 /* Write out the stab section. This is called with the relocated
695 contents. */
697 bfd_boolean
698 _bfd_write_section_stabs (output_bfd, psinfo, stabsec, psecinfo, contents)
699 bfd *output_bfd;
700 PTR *psinfo;
701 asection *stabsec;
702 PTR *psecinfo;
703 bfd_byte *contents;
705 struct stab_info *sinfo;
706 struct stab_section_info *secinfo;
707 struct stab_excl_list *e;
708 bfd_byte *sym, *tosym, *symend;
709 bfd_size_type *pstridx;
711 sinfo = (struct stab_info *) *psinfo;
712 secinfo = (struct stab_section_info *) *psecinfo;
714 if (secinfo == NULL)
715 return bfd_set_section_contents (output_bfd, stabsec->output_section,
716 contents,
717 (file_ptr) stabsec->output_offset,
718 stabsec->_raw_size);
720 /* Handle each N_BINCL entry. */
721 for (e = secinfo->excls; e != NULL; e = e->next)
723 bfd_byte *excl_sym;
725 BFD_ASSERT (e->offset < stabsec->_raw_size);
726 excl_sym = contents + e->offset;
727 bfd_put_32 (output_bfd, e->val, excl_sym + VALOFF);
728 excl_sym[TYPEOFF] = e->type;
731 /* Copy over all the stabs symbols, omitting the ones we don't want,
732 and correcting the string indices for those we do want. */
733 tosym = contents;
734 symend = contents + stabsec->_raw_size;
735 for (sym = contents, pstridx = secinfo->stridxs;
736 sym < symend;
737 sym += STABSIZE, ++pstridx)
739 if (*pstridx != (bfd_size_type) -1)
741 if (tosym != sym)
742 memcpy (tosym, sym, STABSIZE);
743 bfd_put_32 (output_bfd, *pstridx, tosym + STRDXOFF);
745 if (sym[TYPEOFF] == 0)
747 /* This is the header symbol for the stabs section. We
748 don't really need one, since we have merged all the
749 input stabs sections into one, but we generate one
750 for the benefit of readers which expect to see one. */
751 BFD_ASSERT (sym == contents);
752 bfd_put_32 (output_bfd, _bfd_stringtab_size (sinfo->strings),
753 tosym + VALOFF);
754 bfd_put_16 (output_bfd,
755 stabsec->output_section->_raw_size / STABSIZE - 1,
756 tosym + DESCOFF);
759 tosym += STABSIZE;
763 BFD_ASSERT ((bfd_size_type) (tosym - contents) == stabsec->_cooked_size);
765 return bfd_set_section_contents (output_bfd, stabsec->output_section,
766 contents, (file_ptr) stabsec->output_offset,
767 stabsec->_cooked_size);
770 /* Write out the .stabstr section. */
772 bfd_boolean
773 _bfd_write_stab_strings (output_bfd, psinfo)
774 bfd *output_bfd;
775 PTR *psinfo;
777 struct stab_info *sinfo;
779 sinfo = (struct stab_info *) *psinfo;
781 if (sinfo == NULL)
782 return TRUE;
784 if (bfd_is_abs_section (sinfo->stabstr->output_section))
786 /* The section was discarded from the link. */
787 return TRUE;
790 BFD_ASSERT ((sinfo->stabstr->output_offset
791 + _bfd_stringtab_size (sinfo->strings))
792 <= sinfo->stabstr->output_section->_raw_size);
794 if (bfd_seek (output_bfd,
795 (file_ptr) (sinfo->stabstr->output_section->filepos
796 + sinfo->stabstr->output_offset),
797 SEEK_SET) != 0)
798 return FALSE;
800 if (! _bfd_stringtab_emit (output_bfd, sinfo->strings))
801 return FALSE;
803 /* We no longer need the stabs information. */
804 _bfd_stringtab_free (sinfo->strings);
805 bfd_hash_table_free (&sinfo->includes.root);
807 return TRUE;
810 /* Adjust an address in the .stab section. Given OFFSET within
811 STABSEC, this returns the new offset in the adjusted stab section,
812 or -1 if the address refers to a stab which has been removed. */
814 bfd_vma
815 _bfd_stab_section_offset (output_bfd, psinfo, stabsec, psecinfo, offset)
816 bfd *output_bfd ATTRIBUTE_UNUSED;
817 PTR *psinfo ATTRIBUTE_UNUSED;
818 asection *stabsec;
819 PTR *psecinfo;
820 bfd_vma offset;
822 struct stab_section_info *secinfo;
824 secinfo = (struct stab_section_info *) *psecinfo;
826 if (secinfo == NULL)
827 return offset;
829 if (offset >= stabsec->_raw_size)
830 return offset - (stabsec->_cooked_size - stabsec->_raw_size);
832 if (secinfo->cumulative_skips)
834 bfd_vma i;
836 i = offset / STABSIZE;
838 if (secinfo->stridxs [i] == (bfd_size_type) -1)
839 return (bfd_vma) -1;
841 return offset - secinfo->cumulative_skips [i];
844 return offset;