1 /* ELF object file format
2 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2,
9 or (at your option) any later version.
11 GAS is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
14 the GNU General Public License for more details.
16 You should have received a copy of the GNU General Public
17 License along with GAS; see the file COPYING. If not, write
18 to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
24 #ifdef ECOFF_DEBUGGING
32 #ifdef ECOFF_DEBUGGING
33 static boolean elf_get_extr
PARAMS ((asymbol
*, EXTR
*));
34 static void elf_set_index
PARAMS ((asymbol
*, bfd_size_type
));
37 static void obj_elf_line
PARAMS ((int));
38 void obj_elf_version
PARAMS ((int));
39 static void obj_elf_size
PARAMS ((int));
40 static void obj_elf_type
PARAMS ((int));
41 static void obj_elf_ident
PARAMS ((int));
42 static void obj_elf_weak
PARAMS ((int));
43 static void obj_elf_local
PARAMS ((int));
44 static void obj_elf_common
PARAMS ((int));
45 static void obj_elf_data
PARAMS ((int));
46 static void obj_elf_text
PARAMS ((int));
48 const pseudo_typeS obj_pseudo_table
[] =
50 {"comm", obj_elf_common
, 0},
51 {"ident", obj_elf_ident
, 0},
52 {"local", obj_elf_local
, 0},
53 {"previous", obj_elf_previous
, 0},
54 {"section", obj_elf_section
, 0},
55 {"size", obj_elf_size
, 0},
56 {"type", obj_elf_type
, 0},
57 {"version", obj_elf_version
, 0},
58 {"weak", obj_elf_weak
, 0},
60 /* These are used for stabs-in-elf configurations. */
61 {"line", obj_elf_line
, 0},
63 /* These are used for dwarf. */
68 /* We need to trap the section changing calls to handle .previous. */
69 {"data", obj_elf_data
, 0},
70 {"text", obj_elf_text
, 0},
72 #ifdef ECOFF_DEBUGGING
73 /* COFF style debugging information for ECOFF. .ln is not used; .loc
75 { "def", ecoff_directive_def
, 0 },
76 { "dim", ecoff_directive_dim
, 0 },
77 { "endef", ecoff_directive_endef
, 0 },
78 { "file", ecoff_directive_file
, 0 },
79 { "scl", ecoff_directive_scl
, 0 },
80 { "tag", ecoff_directive_tag
, 0 },
81 { "val", ecoff_directive_val
, 0 },
83 /* COFF debugging requires pseudo-ops .size and .type, but ELF
84 already has meanings for those. We use .esize and .etype
85 instead. These are only generated by gcc anyhow. */
86 { "esize", ecoff_directive_size
, 0 },
87 { "etype", ecoff_directive_type
, 0 },
89 /* ECOFF specific debugging information. */
90 { "begin", ecoff_directive_begin
, 0 },
91 { "bend", ecoff_directive_bend
, 0 },
92 { "end", ecoff_directive_end
, 0 },
93 { "ent", ecoff_directive_ent
, 0 },
94 { "fmask", ecoff_directive_fmask
, 0 },
95 { "frame", ecoff_directive_frame
, 0 },
96 { "loc", ecoff_directive_loc
, 0 },
97 { "mask", ecoff_directive_mask
, 0 },
99 /* These are used on Irix. I don't know how to implement them. */
100 { "alias", s_ignore
, 0 },
101 { "bgnb", s_ignore
, 0 },
102 { "endb", s_ignore
, 0 },
103 { "lab", s_ignore
, 0 },
104 { "noalias", s_ignore
, 0 },
105 { "verstamp", s_ignore
, 0 },
106 { "vreg", s_ignore
, 0 },
107 #endif /* ECOFF_DEBUGGING */
109 {NULL
} /* end sentinel */
113 #include "aout/aout64.h"
121 sym
= symbol_new (s
, absolute_section
, (valueT
) 0, (struct frag
*) 0);
122 sym
->sy_frag
= &zero_address_frag
;
123 sym
->bsym
->flags
|= BSF_FILE
;
125 if (symbol_rootP
!= sym
)
127 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
128 symbol_insert (sym
, symbol_rootP
, &symbol_rootP
, &symbol_lastP
);
130 verify_symbol_chain (symbol_rootP
, symbol_lastP
);
136 obj_elf_common (ignore
)
146 name
= input_line_pointer
;
147 c
= get_symbol_end ();
148 /* just after name is now '\0' */
149 p
= input_line_pointer
;
152 if (*input_line_pointer
!= ',')
154 as_bad ("Expected comma after symbol-name");
155 ignore_rest_of_line ();
158 input_line_pointer
++; /* skip ',' */
159 if ((temp
= get_absolute_expression ()) < 0)
161 as_bad (".COMMon length (%d.) <0! Ignored.", temp
);
162 ignore_rest_of_line ();
167 symbolP
= symbol_find_or_make (name
);
169 if (S_IS_DEFINED (symbolP
))
171 as_bad ("Ignoring attempt to re-define symbol");
172 ignore_rest_of_line ();
175 if (S_GET_VALUE (symbolP
) != 0)
177 if (S_GET_VALUE (symbolP
) != size
)
179 as_warn ("Length of .comm \"%s\" is already %ld. Not changed to %d.",
180 S_GET_NAME (symbolP
), (long) S_GET_VALUE (symbolP
), size
);
183 know (symbolP
->sy_frag
== &zero_address_frag
);
184 if (*input_line_pointer
!= ',')
189 input_line_pointer
++;
192 if (! have_align
|| *input_line_pointer
!= '"')
198 temp
= get_absolute_expression ();
202 as_warn ("Common alignment negative; 0 assumed");
214 old_subsec
= now_subseg
;
216 record_alignment (bss_section
, align
);
217 subseg_set (bss_section
, 0);
219 frag_align (align
, 0);
220 if (S_GET_SEGMENT (symbolP
) == bss_section
)
221 symbolP
->sy_frag
->fr_symbol
= 0;
222 symbolP
->sy_frag
= frag_now
;
223 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
, size
,
226 S_SET_SEGMENT (symbolP
, bss_section
);
227 S_CLEAR_EXTERNAL (symbolP
);
228 subseg_set (old_sec
, old_subsec
);
233 S_SET_VALUE (symbolP
, (valueT
) size
);
234 S_SET_EXTERNAL (symbolP
);
235 /* should be common, but this is how gas does it for now */
236 S_SET_SEGMENT (symbolP
, &bfd_und_section
);
241 input_line_pointer
++;
242 /* @@ Some use the dot, some don't. Can we get some consistency?? */
243 if (*input_line_pointer
== '.')
244 input_line_pointer
++;
245 /* @@ Some say data, some say bss. */
246 if (strncmp (input_line_pointer
, "bss\"", 4)
247 && strncmp (input_line_pointer
, "data\"", 5))
249 while (*--input_line_pointer
!= '"')
251 input_line_pointer
--;
252 goto bad_common_segment
;
254 while (*input_line_pointer
++ != '"')
256 goto allocate_common
;
258 demand_empty_rest_of_line ();
263 p
= input_line_pointer
;
264 while (*p
&& *p
!= '\n')
268 as_bad ("bad .common segment %s", input_line_pointer
+ 1);
270 input_line_pointer
= p
;
271 ignore_rest_of_line ();
277 obj_elf_local (ignore
)
286 name
= input_line_pointer
;
287 c
= get_symbol_end ();
288 symbolP
= symbol_find_or_make (name
);
289 *input_line_pointer
= c
;
291 S_CLEAR_EXTERNAL (symbolP
);
295 input_line_pointer
++;
297 if (*input_line_pointer
== '\n')
302 demand_empty_rest_of_line ();
306 obj_elf_weak (ignore
)
315 name
= input_line_pointer
;
316 c
= get_symbol_end ();
317 symbolP
= symbol_find_or_make (name
);
318 *input_line_pointer
= c
;
320 S_SET_WEAK (symbolP
);
324 input_line_pointer
++;
326 if (*input_line_pointer
== '\n')
331 demand_empty_rest_of_line ();
334 static segT previous_section
;
335 static int previous_subsection
;
337 /* Handle the .section pseudo-op. This code supports two different
340 The first is found on Solaris, and looks like
341 .section ".sec1",#alloc,#execinstr,#write
342 Here the names after '#' are the SHF_* flags to turn on for the
343 section. I'm not sure how it determines the SHT_* type (BFD
344 doesn't really give us control over the type, anyhow).
346 The second format is found on UnixWare, and probably most SVR4
347 machines, and looks like
348 .section .sec1,"a",@progbits
349 The quoted string may contain any combination of a, w, x, and
350 represents the SHF_* flags to turn on for the section. The string
351 beginning with '@' can be progbits or nobits. There should be
352 other possibilities, but I don't know what they are. In any case,
353 BFD doesn't really let us set the section type. */
355 /* Certain named sections have particular defined types, listed on p.
357 struct special_section
364 static struct special_section special_sections
[] =
366 { ".bss", SHT_NOBITS
, SHF_ALLOC
+ SHF_WRITE
},
367 { ".comment", SHT_PROGBITS
, 0 },
368 { ".data", SHT_PROGBITS
, SHF_ALLOC
+ SHF_WRITE
},
369 { ".data1", SHT_PROGBITS
, SHF_ALLOC
+ SHF_WRITE
},
370 { ".debug", SHT_PROGBITS
, 0 },
371 { ".fini", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
372 { ".init", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
373 { ".line", SHT_PROGBITS
, 0 },
374 { ".note", SHT_NOTE
, 0 },
375 { ".rodata", SHT_PROGBITS
, SHF_ALLOC
},
376 { ".rodata1", SHT_PROGBITS
, SHF_ALLOC
},
377 { ".text", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
379 #ifdef ELF_TC_SPECIAL_SECTIONS
380 ELF_TC_SPECIAL_SECTIONS
384 /* The following section names are special, but they can not
385 reasonably appear in assembler code. Some of the attributes are
386 processor dependent. */
387 { ".dynamic", SHT_DYNAMIC
, SHF_ALLOC
/* + SHF_WRITE */ },
388 { ".dynstr", SHT_STRTAB
, SHF_ALLOC
},
389 { ".dynsym", SHT_DYNSYM
, SHF_ALLOC
},
390 { ".got", SHT_PROGBITS
, 0 },
391 { ".hash", SHT_HASH
, SHF_ALLOC
},
392 { ".interp", SHT_PROGBITS
, /* SHF_ALLOC */ },
393 { ".plt", SHT_PROGBITS
, 0 },
394 { ".shstrtab",SHT_STRTAB
, 0 },
395 { ".strtab", SHT_STRTAB
, /* SHF_ALLOC */ },
396 { ".symtab", SHT_SYMTAB
, /* SHF_ALLOC */ },
403 obj_elf_section (xxx
)
413 /* Get name of section. */
415 if (*input_line_pointer
== '"')
417 string
= demand_copy_C_string (&xxx
);
420 ignore_rest_of_line ();
426 char *p
= input_line_pointer
;
428 while (0 == strchr ("\n\t,; ", *p
))
430 if (p
== input_line_pointer
)
432 as_warn ("Missing section name");
433 ignore_rest_of_line ();
438 string
= xmalloc ((unsigned long) (p
- input_line_pointer
+ 1));
439 strcpy (string
, input_line_pointer
);
441 input_line_pointer
= p
;
444 /* Switch to the section, creating it if necessary. */
445 previous_section
= now_seg
;
446 previous_subsection
= now_subseg
;
448 new_sec
= bfd_get_section_by_name (stdoutput
, string
) == NULL
;
449 sec
= subseg_new (string
, 0);
451 /* If this section already existed, we don't bother to change the
455 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
456 ++input_line_pointer
;
457 ++input_line_pointer
;
466 if (*input_line_pointer
== ',')
468 /* Skip the comma. */
469 ++input_line_pointer
;
472 if (*input_line_pointer
== '"')
474 /* Pick up a string with a combination of a, w, x. */
475 ++input_line_pointer
;
476 while (*input_line_pointer
!= '"')
478 switch (*input_line_pointer
)
487 attr
|= SHF_EXECINSTR
;
490 as_warn ("Bad .section directive: want a,w,x in string");
491 ignore_rest_of_line ();
494 ++input_line_pointer
;
497 /* Skip the closing quote. */
498 ++input_line_pointer
;
501 if (*input_line_pointer
== ',')
503 ++input_line_pointer
;
505 if (*input_line_pointer
== '@')
507 ++input_line_pointer
;
508 if (strncmp (input_line_pointer
, "progbits",
509 sizeof "progbits" - 1) == 0)
512 input_line_pointer
+= sizeof "progbits" - 1;
514 else if (strncmp (input_line_pointer
, "nobits",
515 sizeof "nobits" - 1) == 0)
518 input_line_pointer
+= sizeof "nobits" - 1;
522 as_warn ("Unrecognized section type");
523 ignore_rest_of_line ();
533 if (*input_line_pointer
!= '#')
535 as_warn ("Bad .section directive");
536 ignore_rest_of_line ();
539 ++input_line_pointer
;
540 if (strncmp (input_line_pointer
, "write",
541 sizeof "write" - 1) == 0)
544 input_line_pointer
+= sizeof "write" - 1;
546 else if (strncmp (input_line_pointer
, "alloc",
547 sizeof "alloc" - 1) == 0)
550 input_line_pointer
+= sizeof "alloc" - 1;
552 else if (strncmp (input_line_pointer
, "execinstr",
553 sizeof "execinstr" - 1) == 0)
555 attr
|= SHF_EXECINSTR
;
556 input_line_pointer
+= sizeof "execinstr" - 1;
560 as_warn ("Unrecognized section attribute");
561 ignore_rest_of_line ();
566 while (*input_line_pointer
++ == ',');
567 --input_line_pointer
;
571 /* See if this is one of the special sections. */
572 for (i
= 0; special_sections
[i
].name
!= NULL
; i
++)
574 if (string
[1] == special_sections
[i
].name
[1]
575 && strcmp (string
, special_sections
[i
].name
) == 0)
577 if (type
== SHT_NULL
)
578 type
= special_sections
[i
].type
;
579 else if (type
!= special_sections
[i
].type
)
580 as_warn ("Setting incorrect section type for %s", string
);
582 if ((attr
&~ special_sections
[i
].attributes
) != 0)
583 as_warn ("Setting incorrect section attributes for %s", string
);
584 attr
|= special_sections
[i
].attributes
;
591 | ((attr
& SHF_WRITE
) ? 0 : SEC_READONLY
)
592 | ((attr
& SHF_ALLOC
) ? SEC_ALLOC
| SEC_LOAD
: 0)
593 | ((attr
& SHF_EXECINSTR
) ? SEC_CODE
: 0));
594 if (type
== SHT_PROGBITS
)
595 flags
|= SEC_ALLOC
| SEC_LOAD
;
596 else if (type
== SHT_NOBITS
)
602 bfd_set_section_flags (stdoutput
, sec
, flags
);
604 demand_empty_rest_of_line ();
607 /* Change to the .data section. */
613 previous_section
= now_seg
;
614 previous_subsection
= now_subseg
;
618 /* Change to the .text section. */
624 previous_section
= now_seg
;
625 previous_subsection
= now_subseg
;
630 obj_elf_previous (ignore
)
633 if (previous_section
== 0)
635 as_bad (".previous without corresponding .section; ignored");
638 subseg_set (previous_section
, previous_subsection
);
639 previous_section
= 0;
643 obj_elf_line (ignore
)
646 /* Assume delimiter is part of expression. BSD4.2 as fails with
647 delightful bug, so we are not being incompatible here. */
648 new_logical_line ((char *) NULL
, (int) (get_absolute_expression ()));
649 demand_empty_rest_of_line ();
653 obj_read_begin_hook ()
655 #ifdef ECOFF_DEBUGGING
656 ecoff_read_begin_hook ();
661 obj_symbol_new_hook (symbolP
)
664 #if 0 /* BFD already takes care of this */
665 elf32_symbol_type
*esym
= (elf32_symbol_type
*) symbolP
;
667 /* There is an Elf_Internal_Sym and an Elf_External_Sym. For now,
668 just zero them out. */
670 bzero ((char *) &esym
->internal_elf_sym
, sizeof (esym
->internal_elf_sym
));
671 bzero ((char *) &esym
->native_elf_sym
, sizeof (esym
->native_elf_sym
));
672 bzero ((char *) &esym
->tc_data
, sizeof (esym
->tc_data
));
674 #ifdef ECOFF_DEBUGGING
675 ecoff_symbol_new_hook (symbolP
);
680 obj_elf_version (ignore
)
687 asection
*seg
= now_seg
;
688 subsegT subseg
= now_subseg
;
689 Elf_Internal_Note i_note
;
690 Elf_External_Note e_note
;
691 asection
*note_secp
= (asection
*) NULL
;
695 if (*input_line_pointer
== '\"')
697 ++input_line_pointer
; /* -> 1st char of string. */
698 name
= input_line_pointer
;
700 while (is_a_char (c
= next_char_of_string ()))
702 c
= *input_line_pointer
;
703 *input_line_pointer
= '\0';
704 *(input_line_pointer
- 1) = '\0';
705 *input_line_pointer
= c
;
707 /* create the .note section */
709 note_secp
= subseg_new (".note", 0);
710 bfd_set_section_flags (stdoutput
,
712 SEC_HAS_CONTENTS
| SEC_READONLY
);
714 /* process the version string */
718 i_note
.namesz
= ((len
+ 1) + 3) & ~3; /* round this to word boundary */
719 i_note
.descsz
= 0; /* no description */
720 i_note
.type
= NT_VERSION
;
721 p
= frag_more (sizeof (e_note
.namesz
));
722 md_number_to_chars (p
, (valueT
) i_note
.namesz
, 4);
723 p
= frag_more (sizeof (e_note
.descsz
));
724 md_number_to_chars (p
, (valueT
) i_note
.descsz
, 4);
725 p
= frag_more (sizeof (e_note
.type
));
726 md_number_to_chars (p
, (valueT
) i_note
.type
, 4);
728 for (i
= 0; i
< len
; i
++)
732 FRAG_APPEND_1_CHAR (ch
);
737 subseg_set (seg
, subseg
);
741 as_bad ("Expected quoted string");
743 demand_empty_rest_of_line ();
747 obj_elf_size (ignore
)
750 char *name
= input_line_pointer
;
751 char c
= get_symbol_end ();
756 p
= input_line_pointer
;
759 if (*input_line_pointer
!= ',')
762 as_bad ("expected comma after name `%s' in .size directive", name
);
764 ignore_rest_of_line ();
767 input_line_pointer
++;
769 if (exp
.X_op
== O_absent
)
771 as_bad ("missing expression in .size directive");
772 exp
.X_op
= O_constant
;
773 exp
.X_add_number
= 0;
776 sym
= symbol_find_or_make (name
);
778 if (exp
.X_op
== O_constant
)
779 S_SET_SIZE (sym
, exp
.X_add_number
);
786 as_tsktsk (".size expressions not yet supported, ignored");
791 demand_empty_rest_of_line ();
795 obj_elf_type (ignore
)
798 char *name
= input_line_pointer
;
799 char c
= get_symbol_end ();
804 p
= input_line_pointer
;
807 if (*input_line_pointer
!= ',')
809 as_bad ("expected comma after name in .type directive");
811 ignore_rest_of_line ();
814 input_line_pointer
++;
816 if (*input_line_pointer
!= '#' && *input_line_pointer
!= '@')
818 as_bad ("expected `#' or `@' after comma in .type directive");
821 input_line_pointer
++;
822 if (!strncmp ("function", input_line_pointer
, sizeof ("function") - 1))
825 input_line_pointer
+= sizeof ("function") - 1;
827 else if (!strncmp ("object", input_line_pointer
, sizeof ("object") - 1))
829 input_line_pointer
+= sizeof ("object") - 1;
833 as_bad ("unrecognized symbol type, ignored");
836 demand_empty_rest_of_line ();
838 sym
= symbol_find_or_make (name
);
839 sym
->bsym
->flags
|= type
;
843 obj_elf_ident (ignore
)
846 static segT comment_section
;
847 segT old_section
= now_seg
;
848 int old_subsection
= now_subseg
;
850 if (!comment_section
)
853 comment_section
= subseg_new (".comment", 0);
854 bfd_set_section_flags (stdoutput
, comment_section
,
855 SEC_READONLY
| SEC_HAS_CONTENTS
);
860 subseg_set (comment_section
, 0);
862 subseg_set (old_section
, old_subsection
);
865 #ifdef INIT_STAB_SECTION
867 /* The first entry in a .stabs section is special. */
870 obj_elf_init_stab_section (seg
)
878 /* Force the section to align to a longword boundary. Without this,
879 UnixWare ar crashes. */
880 bfd_set_section_alignment (stdoutput
, seg
, 2);
883 as_where (&file
, (unsigned int *) NULL
);
884 stabstr_name
= (char *) alloca (strlen (segment_name (seg
)) + 4);
885 strcpy (stabstr_name
, segment_name (seg
));
886 strcat (stabstr_name
, "str");
887 stroff
= get_stab_string_offset (file
, stabstr_name
);
889 md_number_to_chars (p
, stroff
, 4);
890 seg_info (seg
)->stabu
.p
= p
;
895 /* Fill in the counts in the first entry in a .stabs section. */
898 adjust_stab_sections (abfd
, sec
, xxx
)
908 if (strncmp (".stab", sec
->name
, 5))
910 if (!strcmp ("str", sec
->name
+ strlen (sec
->name
) - 3))
913 name
= (char *) alloca (strlen (sec
->name
) + 4);
914 strcpy (name
, sec
->name
);
915 strcat (name
, "str");
916 strsec
= bfd_get_section_by_name (abfd
, name
);
918 strsz
= bfd_section_size (abfd
, strsec
);
921 nsyms
= bfd_section_size (abfd
, sec
) / 12 - 1;
923 p
= seg_info (sec
)->stabu
.p
;
926 bfd_h_put_16 (abfd
, (bfd_vma
) nsyms
, (bfd_byte
*) p
+ 6);
927 bfd_h_put_32 (abfd
, (bfd_vma
) strsz
, (bfd_byte
*) p
+ 8);
930 #ifdef ECOFF_DEBUGGING
932 /* This function is called by the ECOFF code. It is supposed to
933 record the external symbol information so that the backend can
934 write it out correctly. The ELF backend doesn't actually handle
935 this at the moment, so we do it ourselves. We save the information
939 obj_ecoff_set_ext (sym
, ext
)
943 sym
->bsym
->udata
= (PTR
) ext
;
946 /* This function is called by bfd_ecoff_debug_externals. It is
947 supposed to *EXT to the external symbol information, and return
948 whether the symbol should be used at all. */
951 elf_get_extr (sym
, ext
)
955 if (sym
->udata
== NULL
)
957 *ext
= *(EXTR
*) sym
->udata
;
961 /* This function is called by bfd_ecoff_debug_externals. It has
962 nothing to do for ELF. */
966 elf_set_index (sym
, indx
)
972 #endif /* ECOFF_DEBUGGING */
977 bfd_map_over_sections (stdoutput
, adjust_stab_sections
, (PTR
) 0);
983 for (i
= 0; i
< stdoutput
->symcount
; i
++)
984 elf_tc_symbol (stdoutput
, (PTR
) (stdoutput
->outsymbols
[i
]),
989 #ifdef elf_tc_final_processing
990 elf_tc_final_processing ();
993 /* Finally, we must make any target-specific sections. */
995 #ifdef elf_tc_make_sections
996 elf_tc_make_sections (stdoutput
);
999 #ifdef ECOFF_DEBUGGING
1000 /* Generate the ECOFF debugging information. */
1002 const struct ecoff_debug_swap
*debug_swap
;
1003 struct ecoff_debug_info debug
;
1008 = get_elf_backend_data (stdoutput
)->elf_backend_ecoff_debug_swap
;
1009 know (debug_swap
!= (const struct ecoff_debug_swap
*) NULL
);
1010 ecoff_build_debug (&debug
.symbolic_header
, &buf
, debug_swap
);
1012 /* Set up the pointers in debug. */
1013 #define SET(ptr, offset, type) \
1014 debug.ptr = (type) (buf + debug.symbolic_header.offset)
1016 SET (line
, cbLineOffset
, unsigned char *);
1017 SET (external_dnr
, cbDnOffset
, PTR
);
1018 SET (external_pdr
, cbPdOffset
, PTR
);
1019 SET (external_sym
, cbSymOffset
, PTR
);
1020 SET (external_opt
, cbOptOffset
, PTR
);
1021 SET (external_aux
, cbAuxOffset
, union aux_ext
*);
1022 SET (ss
, cbSsOffset
, char *);
1023 SET (external_fdr
, cbFdOffset
, PTR
);
1024 SET (external_rfd
, cbRfdOffset
, PTR
);
1025 /* ssext and external_ext are set up just below. */
1029 /* Set up the external symbols. */
1030 debug
.ssext
= debug
.ssext_end
= NULL
;
1031 debug
.external_ext
= debug
.external_ext_end
= NULL
;
1032 if (! bfd_ecoff_debug_externals (stdoutput
, &debug
, debug_swap
, true,
1033 elf_get_extr
, elf_set_index
))
1034 as_fatal ("Failed to set up debugging information: %s",
1035 bfd_errmsg (bfd_error
));
1037 sec
= bfd_get_section_by_name (stdoutput
, ".mdebug");
1038 assert (sec
!= NULL
);
1040 know (stdoutput
->output_has_begun
== false);
1042 /* We set the size of the section, call bfd_set_section_contents
1043 to force the ELF backend to allocate a file position, and then
1044 write out the data. FIXME: Is this really the best way to do
1046 sec
->_raw_size
= bfd_ecoff_debug_size (stdoutput
, &debug
, debug_swap
);
1048 if (! bfd_set_section_contents (stdoutput
, sec
, (PTR
) NULL
,
1049 (file_ptr
) 0, (bfd_size_type
) 0))
1050 as_fatal ("Can't start writing .mdebug section: %s",
1051 bfd_errmsg (bfd_error
));
1053 know (stdoutput
->output_has_begun
== true);
1054 know (sec
->filepos
!= 0);
1056 if (! bfd_ecoff_write_debug (stdoutput
, &debug
, debug_swap
,
1058 as_fatal ("Could not write .mdebug section: %s",
1059 bfd_errmsg (bfd_error
));
1061 #endif /* ECOFF_DEBUGGING */