1 /* Generic symbol-table support for the BFD library.
2 Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
3 Written by Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 BFD tries to maintain as much symbol information as it can when
26 it moves information from file to file. BFD passes information
27 to applications though the <<asymbol>> structure. When the
28 application requests the symbol table, BFD reads the table in
29 the native form and translates parts of it into the internal
30 format. To maintain more than the information passed to
31 applications, some targets keep some information ``behind the
32 scenes'' in a structure only the particular back end knows
33 about. For example, the coff back end keeps the original
34 symbol table structure as well as the canonical structure when
35 a BFD is read in. On output, the coff back end can reconstruct
36 the output symbol table so that no information is lost, even
37 information unique to coff which BFD doesn't know or
38 understand. If a coff symbol table were read, but were written
39 through an a.out back end, all the coff specific information
40 would be lost. The symbol table of a BFD
41 is not necessarily read in until a canonicalize request is
42 made. Then the BFD back end fills in a table provided by the
43 application with pointers to the canonical information. To
44 output symbols, the application provides BFD with a table of
45 pointers to pointers to <<asymbol>>s. This allows applications
46 like the linker to output a symbol as it was read, since the ``behind
47 the scenes'' information will be still available.
53 @* symbol handling functions::
57 Reading Symbols, Writing Symbols, Symbols, Symbols
61 There are two stages to reading a symbol table from a BFD:
62 allocating storage, and the actual reading process. This is an
63 excerpt from an application which reads the symbol table:
65 | long storage_needed;
66 | asymbol **symbol_table;
67 | long number_of_symbols;
70 | storage_needed = bfd_get_symtab_upper_bound (abfd);
72 | if (storage_needed < 0)
75 | if (storage_needed == 0) {
78 | symbol_table = (asymbol **) xmalloc (storage_needed);
81 | bfd_canonicalize_symtab (abfd, symbol_table);
83 | if (number_of_symbols < 0)
86 | for (i = 0; i < number_of_symbols; i++) {
87 | process_symbol (symbol_table[i]);
90 All storage for the symbols themselves is in an obstack
91 connected to the BFD; it is freed when the BFD is closed.
95 Writing Symbols, Mini Symbols, Reading Symbols, Symbols
99 Writing of a symbol table is automatic when a BFD open for
100 writing is closed. The application attaches a vector of
101 pointers to pointers to symbols to the BFD being written, and
102 fills in the symbol count. The close and cleanup code reads
103 through the table provided and performs all the necessary
104 operations. The BFD output code must always be provided with an
105 ``owned'' symbol: one which has come from another BFD, or one
106 which has been created using <<bfd_make_empty_symbol>>. Here is an
107 example showing the creation of a symbol table with only one element:
116 | abfd = bfd_openw("foo","a.out-sunos-big");
117 | bfd_set_format(abfd, bfd_object);
118 | new = bfd_make_empty_symbol(abfd);
119 | new->name = "dummy_symbol";
120 | new->section = bfd_make_section_old_way(abfd, ".text");
121 | new->flags = BSF_GLOBAL;
122 | new->value = 0x12345;
125 | ptrs[1] = (asymbol *)0;
127 | bfd_set_symtab(abfd, ptrs, 1);
133 | 00012345 A dummy_symbol
135 Many formats cannot represent arbitary symbol information; for
136 instance, the <<a.out>> object format does not allow an
137 arbitary number of sections. A symbol pointing to a section
138 which is not one of <<.text>>, <<.data>> or <<.bss>> cannot
142 Mini Symbols, typedef asymbol, Writing Symbols, Symbols
146 Mini symbols provide read-only access to the symbol table.
147 They use less memory space, but require more time to access.
148 They can be useful for tools like nm or objdump, which may
149 have to handle symbol tables of extremely large executables.
151 The <<bfd_read_minisymbols>> function will read the symbols
152 into memory in an internal form. It will return a <<void *>>
153 pointer to a block of memory, a symbol count, and the size of
154 each symbol. The pointer is allocated using <<malloc>>, and
155 should be freed by the caller when it is no longer needed.
157 The function <<bfd_minisymbol_to_symbol>> will take a pointer
158 to a minisymbol, and a pointer to a structure returned by
159 <<bfd_make_empty_symbol>>, and return a <<asymbol>> structure.
160 The return value may or may not be the same as the value from
161 <<bfd_make_empty_symbol>> which was passed in.
170 typedef asymbol, symbol handling functions, Mini Symbols, Symbols
177 An <<asymbol>> has the form:
185 .typedef struct symbol_cache_entry
187 . {* A pointer to the BFD which owns the symbol. This information
188 . is necessary so that a back end can work out what additional
189 . information (invisible to the application writer) is carried
192 . This field is *almost* redundant, since you can use section->owner
193 . instead, except that some symbols point to the global sections
194 . bfd_{abs,com,und}_section. This could be fixed by making
195 . these globals be per-bfd (or per-target-flavor). FIXME. *}
197 . struct _bfd *the_bfd; {* Use bfd_asymbol_bfd(sym) to access this field. *}
199 . {* The text of the symbol. The name is left alone, and not copied; the
200 . application may not alter it. *}
203 . {* The value of the symbol. This really should be a union of a
204 . numeric value with a pointer, since some flags indicate that
205 . a pointer to another symbol is stored here. *}
208 . {* Attributes of a symbol: *}
210 .#define BSF_NO_FLAGS 0x00
212 . {* The symbol has local scope; <<static>> in <<C>>. The value
213 . is the offset into the section of the data. *}
214 .#define BSF_LOCAL 0x01
216 . {* The symbol has global scope; initialized data in <<C>>. The
217 . value is the offset into the section of the data. *}
218 .#define BSF_GLOBAL 0x02
220 . {* The symbol has global scope and is exported. The value is
221 . the offset into the section of the data. *}
222 .#define BSF_EXPORT BSF_GLOBAL {* no real difference *}
224 . {* A normal C symbol would be one of:
225 . <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or
228 . {* The symbol is a debugging record. The value has an arbitary
230 .#define BSF_DEBUGGING 0x08
232 . {* The symbol denotes a function entry point. Used in ELF,
233 . perhaps others someday. *}
234 .#define BSF_FUNCTION 0x10
236 . {* Used by the linker. *}
237 .#define BSF_KEEP 0x20
238 .#define BSF_KEEP_G 0x40
240 . {* A weak global symbol, overridable without warnings by
241 . a regular global symbol of the same name. *}
242 .#define BSF_WEAK 0x80
244 . {* This symbol was created to point to a section, e.g. ELF's
245 . STT_SECTION symbols. *}
246 .#define BSF_SECTION_SYM 0x100
248 . {* The symbol used to be a common symbol, but now it is
250 .#define BSF_OLD_COMMON 0x200
252 . {* The default value for common data. *}
253 .#define BFD_FORT_COMM_DEFAULT_VALUE 0
255 . {* In some files the type of a symbol sometimes alters its
256 . location in an output file - ie in coff a <<ISFCN>> symbol
257 . which is also <<C_EXT>> symbol appears where it was
258 . declared and not at the end of a section. This bit is set
259 . by the target BFD part to convey this information. *}
261 .#define BSF_NOT_AT_END 0x400
263 . {* Signal that the symbol is the label of constructor section. *}
264 .#define BSF_CONSTRUCTOR 0x800
266 . {* Signal that the symbol is a warning symbol. The name is a
267 . warning. The name of the next symbol is the one to warn about;
268 . if a reference is made to a symbol with the same name as the next
269 . symbol, a warning is issued by the linker. *}
270 .#define BSF_WARNING 0x1000
272 . {* Signal that the symbol is indirect. This symbol is an indirect
273 . pointer to the symbol with the same name as the next symbol. *}
274 .#define BSF_INDIRECT 0x2000
276 . {* BSF_FILE marks symbols that contain a file name. This is used
277 . for ELF STT_FILE symbols. *}
278 .#define BSF_FILE 0x4000
280 . {* Symbol is from dynamic linking information. *}
281 .#define BSF_DYNAMIC 0x8000
283 . {* The symbol denotes a data object. Used in ELF, and perhaps
285 .#define BSF_OBJECT 0x10000
289 . {* A pointer to the section to which this symbol is
290 . relative. This will always be non NULL, there are special
291 . sections for undefined and absolute symbols. *}
292 . struct sec *section;
294 . {* Back end special data. *}
308 #include "aout/stab_gnu.h"
313 symbol handling functions, , typedef asymbol, Symbols
315 Symbol handling functions
320 bfd_get_symtab_upper_bound
323 Return the number of bytes required to store a vector of pointers
324 to <<asymbols>> for all the symbols in the BFD @var{abfd},
325 including a terminal NULL pointer. If there are no symbols in
326 the BFD, then return 0. If an error occurs, return -1.
328 .#define bfd_get_symtab_upper_bound(abfd) \
329 . BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
338 boolean bfd_is_local_label(bfd *abfd, asymbol *sym);
341 Return true if the given symbol @var{sym} in the BFD @var{abfd} is
342 a compiler generated local label, else return false.
343 .#define bfd_is_local_label(abfd, sym) \
344 . BFD_SEND (abfd, _bfd_is_local_label,(abfd, sym))
349 bfd_canonicalize_symtab
352 Read the symbols from the BFD @var{abfd}, and fills in
353 the vector @var{location} with pointers to the symbols and
355 Return the actual number of symbol pointers, not
359 .#define bfd_canonicalize_symtab(abfd, location) \
360 . BFD_SEND (abfd, _bfd_canonicalize_symtab,\
371 boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);
374 Arrange that when the output BFD @var{abfd} is closed,
375 the table @var{location} of @var{count} pointers to symbols
380 bfd_set_symtab (abfd, location, symcount)
383 unsigned int symcount;
385 if ((abfd->format != bfd_object) || (bfd_read_p (abfd)))
387 bfd_set_error (bfd_error_invalid_operation);
391 bfd_get_outsymbols (abfd) = location;
392 bfd_get_symcount (abfd) = symcount;
398 bfd_print_symbol_vandf
401 void bfd_print_symbol_vandf(PTR file, asymbol *symbol);
404 Print the value and flags of the @var{symbol} supplied to the
408 bfd_print_symbol_vandf (arg, symbol)
412 FILE *file = (FILE *) arg;
413 flagword type = symbol->flags;
414 if (symbol->section != (asection *) NULL)
416 fprintf_vma (file, symbol->value + symbol->section->vma);
420 fprintf_vma (file, symbol->value);
423 /* This presumes that a symbol can not be both BSF_DEBUGGING and
424 BSF_DYNAMIC, nor more than one of BSF_FUNCTION, BSF_FILE, and
426 fprintf (file, " %c%c%c%c%c%c%c",
428 ? (type & BSF_GLOBAL) ? '!' : 'l'
429 : (type & BSF_GLOBAL) ? 'g' : ' '),
430 (type & BSF_WEAK) ? 'w' : ' ',
431 (type & BSF_CONSTRUCTOR) ? 'C' : ' ',
432 (type & BSF_WARNING) ? 'W' : ' ',
433 (type & BSF_INDIRECT) ? 'I' : ' ',
434 (type & BSF_DEBUGGING) ? 'd' : (type & BSF_DYNAMIC) ? 'D' : ' ',
435 ((type & BSF_FUNCTION)
439 : ((type & BSF_OBJECT) ? 'O' : ' '))));
445 bfd_make_empty_symbol
448 Create a new <<asymbol>> structure for the BFD @var{abfd}
449 and return a pointer to it.
451 This routine is necessary because each back end has private
452 information surrounding the <<asymbol>>. Building your own
453 <<asymbol>> and pointing to it will not create the private
454 information, and will cause problems later on.
456 .#define bfd_make_empty_symbol(abfd) \
457 . BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
462 bfd_make_debug_symbol
465 Create a new <<asymbol>> structure for the BFD @var{abfd},
466 to be used as a debugging symbol. Further details of its use have
467 yet to be worked out.
469 .#define bfd_make_debug_symbol(abfd,ptr,size) \
470 . BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
473 struct section_to_type
479 /* Map section names to POSIX/BSD single-character symbol types.
480 This table is probably incomplete. It is sorted for convenience of
481 adding entries. Since it is so short, a linear search is used. */
482 static CONST struct section_to_type stt[] =
486 {"zerovars", 'b'}, /* MRI .bss */
488 {"vars", 'd'}, /* MRI .data */
489 {".rdata", 'r'}, /* Read only data. */
490 {".rodata", 'r'}, /* Read only data. */
491 {".sbss", 's'}, /* Small BSS (uninitialized data). */
492 {".scommon", 'c'}, /* Small common. */
493 {".sdata", 'g'}, /* Small initialized data. */
495 {"code", 't'}, /* MRI .text */
499 /* Return the single-character symbol type corresponding to
500 section S, or '?' for an unknown COFF section.
502 Check for any leading string which matches, so .text5 returns
503 't' as well as .text */
506 coff_section_type (s)
509 CONST struct section_to_type *t;
511 for (t = &stt[0]; t->section; t++)
512 if (!strncmp (s, t->section, strlen (t->section)))
519 #define islower(c) ((c) >= 'a' && (c) <= 'z')
522 #define toupper(c) (islower(c) ? ((c) & ~0x20) : (c))
530 Return a character corresponding to the symbol
531 class of @var{symbol}, or '?' for an unknown class.
534 int bfd_decode_symclass(asymbol *symbol);
537 bfd_decode_symclass (symbol)
542 if (bfd_is_com_section (symbol->section))
544 if (bfd_is_und_section (symbol->section))
546 if (bfd_is_ind_section (symbol->section))
548 if (symbol->flags & BSF_WEAK)
550 if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL)))
553 if (bfd_is_abs_section (symbol->section))
555 else if (symbol->section)
556 c = coff_section_type (symbol->section->name);
559 if (symbol->flags & BSF_GLOBAL)
563 /* We don't have to handle these cases just yet, but we will soon:
578 Fill in the basic info about symbol that nm needs.
579 Additional info may be added by the back-ends after
580 calling this function.
583 void bfd_symbol_info(asymbol *symbol, symbol_info *ret);
587 bfd_symbol_info (symbol, ret)
591 ret->type = bfd_decode_symclass (symbol);
592 if (ret->type != 'U')
593 ret->value = symbol->value + symbol->section->vma;
596 ret->name = symbol->name;
600 bfd_symbol_is_absolute ()
607 bfd_copy_private_symbol_data
610 boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
613 Copy private symbol information from @var{isym} in the BFD
614 @var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}.
615 Return <<true>> on success, <<false>> on error. Possible error
618 o <<bfd_error_no_memory>> -
619 Not enough memory exists to create private data for @var{osec}.
621 .#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
622 . BFD_SEND (ibfd, _bfd_copy_private_symbol_data, \
623 . (ibfd, isymbol, obfd, osymbol))
627 /* The generic version of the function which returns mini symbols.
628 This is used when the backend does not provide a more efficient
629 version. It just uses BFD asymbol structures as mini symbols. */
632 _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep)
639 asymbol **syms = NULL;
643 storage = bfd_get_dynamic_symtab_upper_bound (abfd);
645 storage = bfd_get_symtab_upper_bound (abfd);
649 syms = (asymbol **) bfd_malloc ((size_t) storage);
654 symcount = bfd_canonicalize_dynamic_symtab (abfd, syms);
656 symcount = bfd_canonicalize_symtab (abfd, syms);
660 *minisymsp = (PTR) syms;
661 *sizep = sizeof (asymbol *);
670 /* The generic version of the function which converts a minisymbol to
671 an asymbol. We don't worry about the sym argument we are passed;
672 we just return the asymbol the minisymbol points to. */
676 _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym)
682 return *(asymbol **) minisym;
685 /* Look through stabs debugging information in .stab and .stabstr
686 sections to find the source file and line closest to a desired
687 location. This is used by COFF and ELF targets. It sets *pfound
688 to true if it finds some information. The *pinfo field is used to
689 pass cached information in and out of this routine; this first time
690 the routine is called for a BFD, *pinfo should be NULL. The value
691 placed in *pinfo should be saved with the BFD, and passed back each
692 time this function is called. */
694 /* A pointer to this structure is stored in *pinfo. */
696 struct stab_find_info
698 /* The .stab section. */
700 /* The .stabstr section. */
702 /* The contents of the .stab section. */
704 /* The contents of the .stabstr section. */
706 /* An malloc buffer to hold the file name. */
708 /* Cached values to restart quickly. */
709 bfd_vma cached_offset;
710 bfd_byte *cached_stab;
711 bfd_byte *cached_str;
712 bfd_size_type cached_stroff;
716 _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound,
717 pfilename, pfnname, pline, pinfo)
723 const char **pfilename;
724 const char **pfnname;
728 struct stab_find_info *info;
729 bfd_size_type stabsize, strsize;
730 bfd_byte *stab, *stabend, *str;
731 bfd_size_type stroff;
733 char *directory_name, *main_file_name, *current_file_name, *line_file_name;
735 bfd_vma low_func_vma, low_line_vma;
738 *pfilename = bfd_get_filename (abfd);
742 info = (struct stab_find_info *) *pinfo;
745 if (info->stabsec == NULL || info->strsec == NULL)
747 /* No stabs debugging information. */
751 stabsize = info->stabsec->_raw_size;
752 strsize = info->strsec->_raw_size;
756 long reloc_size, reloc_count;
757 arelent **reloc_vector;
759 info = (struct stab_find_info *) bfd_zalloc (abfd, sizeof *info);
763 /* FIXME: When using the linker --split-by-file or
764 --split-by-reloc options, it is possible for the .stab and
765 .stabstr sections to be split. We should handle that. */
767 info->stabsec = bfd_get_section_by_name (abfd, ".stab");
768 info->strsec = bfd_get_section_by_name (abfd, ".stabstr");
770 if (info->stabsec == NULL || info->strsec == NULL)
772 /* No stabs debugging information. Set *pinfo so that we
773 can return quickly in the info != NULL case above. */
778 stabsize = info->stabsec->_raw_size;
779 strsize = info->strsec->_raw_size;
781 info->stabs = (bfd_byte *) bfd_alloc (abfd, stabsize);
782 info->strs = (bfd_byte *) bfd_alloc (abfd, strsize);
783 if (info->stabs == NULL || info->strs == NULL)
786 if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 0,
788 || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 0,
792 /* If this is a relocateable object file, we have to relocate
793 the entries in .stab. This should always be simple 32 bit
794 relocations against symbols defined in this object file, so
795 this should be no big deal. */
796 reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
799 reloc_vector = (arelent **) bfd_malloc (reloc_size);
800 if (reloc_vector == NULL && reloc_size != 0)
802 reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
806 if (reloc_vector != NULL)
814 for (pr = reloc_vector; *pr != NULL; pr++)
821 if (r->howto->rightshift != 0
822 || r->howto->size != 2
823 || r->howto->bitsize != 32
824 || r->howto->pc_relative
825 || r->howto->bitpos != 0
826 || r->howto->dst_mask != 0xffffffff)
828 (*_bfd_error_handler)
829 ("Unsupported .stab relocation");
830 bfd_set_error (bfd_error_invalid_operation);
831 if (reloc_vector != NULL)
836 val = bfd_get_32 (abfd, info->stabs + r->address);
837 val &= r->howto->src_mask;
838 sym = *r->sym_ptr_ptr;
839 val += sym->value + sym->section->vma + r->addend;
840 bfd_put_32 (abfd, val, info->stabs + r->address);
844 if (reloc_vector != NULL)
850 /* We are passed a section relative offset. The offsets in the
851 stabs information are absolute. */
852 offset += bfd_get_section_vma (abfd, section);
854 /* Stabs entries use a 12 byte format:
855 4 byte string table index
857 1 byte stab other field
858 2 byte stab desc field
860 FIXME: This will have to change for a 64 bit object format.
862 The stabs symbols are divided into compilation units. For the
863 first entry in each unit, the type of 0, the value is the length
864 of the string table for this unit, and the desc field is the
865 number of stabs symbols for this unit. */
872 #define STABSIZE (12)
874 /* It would be nice if we could skip ahead to the stabs symbols for
875 the next compilation unit to quickly scan through the compilation
876 units. Unfortunately, since each line number gets a separate
877 stabs entry, it is entirely plausible that a large source file
878 will overflow the 16 bit count of stabs entries. */
880 directory_name = NULL;
881 main_file_name = NULL;
882 current_file_name = NULL;
883 line_file_name = NULL;
888 stabend = info->stabs + stabsize;
890 if (info->cached_stab == NULL || offset < info->cached_offset)
898 stab = info->cached_stab;
899 str = info->cached_str;
900 stroff = info->cached_stroff;
903 info->cached_offset = offset;
905 for (; stab < stabend; stab += STABSIZE)
913 switch (stab[TYPEOFF])
916 /* This is the first entry in a compilation unit. */
917 if ((bfd_size_type) ((info->strs + strsize) - str) < stroff)
923 stroff = bfd_get_32 (abfd, stab + VALOFF);
927 /* The main file name. */
929 val = bfd_get_32 (abfd, stab + VALOFF);
936 name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
938 /* An empty string indicates the end of the compilation
942 /* If there are functions in different sections, they
943 may have addresses larger than val, but we don't want
944 to forget the file name. When there are functions in
945 different cases, there is supposed to be an N_FUN at
946 the end of the function indicating where it ends. */
947 if (low_func_vma < val || fnname == NULL)
948 main_file_name = NULL;
952 /* We know that we have to get to at least this point in the
953 stabs entries for this offset. */
954 info->cached_stab = stab;
955 info->cached_str = str;
956 info->cached_stroff = stroff;
958 current_file_name = name;
960 /* Look ahead to the next symbol. Two consecutive N_SO
961 symbols are a directory and a file name. */
962 if (stab + STABSIZE >= stabend
963 || *(stab + STABSIZE + TYPEOFF) != N_SO)
964 directory_name = NULL;
968 directory_name = current_file_name;
969 current_file_name = ((char *) str
970 + bfd_get_32 (abfd, stab + STRDXOFF));
973 main_file_name = current_file_name;
978 /* The name of an include file. */
979 current_file_name = ((char *) str
980 + bfd_get_32 (abfd, stab + STRDXOFF));
986 /* A line number. The value is relative to the start of the
988 val = fnaddr + bfd_get_32 (abfd, stab + VALOFF);
989 if (val >= low_line_vma && val <= offset)
991 *pline = bfd_get_16 (abfd, stab + DESCOFF);
993 line_file_name = current_file_name;
998 /* A function name. */
999 val = bfd_get_32 (abfd, stab + VALOFF);
1000 name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
1002 /* An empty string here indicates the end of a function, and
1003 the value is relative to fnaddr. */
1008 if (val >= low_func_vma && val < offset)
1013 if (val >= low_func_vma && val <= offset)
1029 if (main_file_name == NULL)
1031 /* No information found. */
1038 main_file_name = line_file_name;
1040 if (main_file_name != NULL)
1042 if (main_file_name[0] == '/' || directory_name == NULL)
1043 *pfilename = main_file_name;
1048 dirlen = strlen (directory_name);
1049 if (info->filename == NULL
1050 || strncmp (info->filename, directory_name, dirlen) != 0
1051 || strcmp (info->filename + dirlen, main_file_name) != 0)
1053 if (info->filename != NULL)
1054 free (info->filename);
1055 info->filename = (char *) bfd_malloc (dirlen +
1056 strlen (main_file_name)
1058 if (info->filename == NULL)
1060 strcpy (info->filename, directory_name);
1061 strcpy (info->filename + dirlen, main_file_name);
1064 *pfilename = info->filename;
1072 /* This will typically be something like main:F(0,1), so we want
1073 to clobber the colon. It's OK to change the name, since the
1074 string is in our own local storage anyhow. */
1076 s = strchr (fnname, ':');