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. */
20 #define OBJ_HEADER "obj-elf.h"
25 #ifndef ECOFF_DEBUGGING
26 #define ECOFF_DEBUGGING 0
38 static boolean elf_get_extr
PARAMS ((asymbol
*, EXTR
*));
39 static void elf_set_index
PARAMS ((asymbol
*, bfd_size_type
));
42 static void obj_elf_line
PARAMS ((int));
43 void obj_elf_version
PARAMS ((int));
44 static void obj_elf_size
PARAMS ((int));
45 static void obj_elf_type
PARAMS ((int));
46 static void obj_elf_ident
PARAMS ((int));
47 static void obj_elf_weak
PARAMS ((int));
48 static void obj_elf_local
PARAMS ((int));
49 static void obj_elf_common
PARAMS ((int));
50 static void obj_elf_data
PARAMS ((int));
51 static void obj_elf_text
PARAMS ((int));
53 static const pseudo_typeS elf_pseudo_table
[] =
55 {"comm", obj_elf_common
, 0},
56 {"ident", obj_elf_ident
, 0},
57 {"local", obj_elf_local
, 0},
58 {"previous", obj_elf_previous
, 0},
59 {"section", obj_elf_section
, 0},
60 {"size", obj_elf_size
, 0},
61 {"type", obj_elf_type
, 0},
62 {"version", obj_elf_version
, 0},
63 {"weak", obj_elf_weak
, 0},
65 /* These are used for stabs-in-elf configurations. */
66 {"line", obj_elf_line
, 0},
68 /* These are used for dwarf. */
73 /* We need to trap the section changing calls to handle .previous. */
74 {"data", obj_elf_data
, 0},
75 {"text", obj_elf_text
, 0},
81 static const pseudo_typeS ecoff_debug_pseudo_table
[] =
83 /* COFF style debugging information for ECOFF. .ln is not used; .loc
85 { "def", ecoff_directive_def
, 0 },
86 { "dim", ecoff_directive_dim
, 0 },
87 { "endef", ecoff_directive_endef
, 0 },
88 { "file", ecoff_directive_file
, 0 },
89 { "scl", ecoff_directive_scl
, 0 },
90 { "tag", ecoff_directive_tag
, 0 },
91 { "val", ecoff_directive_val
, 0 },
93 /* COFF debugging requires pseudo-ops .size and .type, but ELF
94 already has meanings for those. We use .esize and .etype
95 instead. These are only generated by gcc anyhow. */
96 { "esize", ecoff_directive_size
, 0 },
97 { "etype", ecoff_directive_type
, 0 },
99 /* ECOFF specific debugging information. */
100 { "begin", ecoff_directive_begin
, 0 },
101 { "bend", ecoff_directive_bend
, 0 },
102 { "end", ecoff_directive_end
, 0 },
103 { "ent", ecoff_directive_ent
, 0 },
104 { "fmask", ecoff_directive_fmask
, 0 },
105 { "frame", ecoff_directive_frame
, 0 },
106 { "loc", ecoff_directive_loc
, 0 },
107 { "mask", ecoff_directive_mask
, 0 },
109 /* These are used on Irix. I don't know how to implement them. */
110 { "alias", s_ignore
, 0 },
111 { "bgnb", s_ignore
, 0 },
112 { "endb", s_ignore
, 0 },
113 { "lab", s_ignore
, 0 },
114 { "noalias", s_ignore
, 0 },
115 { "verstamp", s_ignore
, 0 },
116 { "vreg", s_ignore
, 0 },
118 {NULL
} /* end sentinel */
122 #include "aout/aout64.h"
127 pop_insert (elf_pseudo_table
);
129 pop_insert (ecoff_debug_pseudo_table
);
136 return S_GET_SIZE (sym
);
140 elf_s_set_size (sym
, sz
)
144 S_SET_SIZE (sym
, sz
);
148 elf_s_get_align (sym
)
151 return S_GET_ALIGN (sym
);
155 elf_s_set_align (sym
, align
)
159 S_SET_ALIGN (sym
, align
);
163 elf_copy_symbol_attributes (dest
, src
)
166 OBJ_COPY_SYMBOL_ATTRIBUTES (dest
, src
);
170 elf_sec_sym_ok_for_reloc (sec
)
173 return obj_sec_sym_ok_for_reloc (sec
);
182 sym
= symbol_new (s
, absolute_section
, (valueT
) 0, (struct frag
*) 0);
183 sym
->sy_frag
= &zero_address_frag
;
184 sym
->bsym
->flags
|= BSF_FILE
;
186 if (symbol_rootP
!= sym
)
188 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
189 symbol_insert (sym
, symbol_rootP
, &symbol_rootP
, &symbol_lastP
);
191 verify_symbol_chain (symbol_rootP
, symbol_lastP
);
197 obj_elf_common (ignore
)
207 name
= input_line_pointer
;
208 c
= get_symbol_end ();
209 /* just after name is now '\0' */
210 p
= input_line_pointer
;
213 if (*input_line_pointer
!= ',')
215 as_bad ("Expected comma after symbol-name");
216 ignore_rest_of_line ();
219 input_line_pointer
++; /* skip ',' */
220 if ((temp
= get_absolute_expression ()) < 0)
222 as_bad (".COMMon length (%d.) <0! Ignored.", temp
);
223 ignore_rest_of_line ();
228 symbolP
= symbol_find_or_make (name
);
230 if (S_IS_DEFINED (symbolP
))
232 as_bad ("Ignoring attempt to re-define symbol");
233 ignore_rest_of_line ();
236 if (S_GET_VALUE (symbolP
) != 0)
238 if (S_GET_VALUE (symbolP
) != size
)
240 as_warn ("Length of .comm \"%s\" is already %ld. Not changed to %d.",
241 S_GET_NAME (symbolP
), (long) S_GET_VALUE (symbolP
), size
);
244 know (symbolP
->sy_frag
== &zero_address_frag
);
245 if (*input_line_pointer
!= ',')
250 input_line_pointer
++;
253 if (! have_align
|| *input_line_pointer
!= '"')
259 temp
= get_absolute_expression ();
263 as_warn ("Common alignment negative; 0 assumed");
275 old_subsec
= now_subseg
;
277 record_alignment (bss_section
, align
);
278 subseg_set (bss_section
, 0);
280 frag_align (align
, 0);
281 if (S_GET_SEGMENT (symbolP
) == bss_section
)
282 symbolP
->sy_frag
->fr_symbol
= 0;
283 symbolP
->sy_frag
= frag_now
;
284 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
, size
,
287 S_SET_SEGMENT (symbolP
, bss_section
);
288 S_CLEAR_EXTERNAL (symbolP
);
289 subseg_set (old_sec
, old_subsec
);
294 S_SET_VALUE (symbolP
, (valueT
) size
);
295 S_SET_ALIGN (symbolP
, temp
);
296 S_SET_EXTERNAL (symbolP
);
297 /* should be common, but this is how gas does it for now */
298 S_SET_SEGMENT (symbolP
, bfd_und_section_ptr
);
303 input_line_pointer
++;
304 /* @@ Some use the dot, some don't. Can we get some consistency?? */
305 if (*input_line_pointer
== '.')
306 input_line_pointer
++;
307 /* @@ Some say data, some say bss. */
308 if (strncmp (input_line_pointer
, "bss\"", 4)
309 && strncmp (input_line_pointer
, "data\"", 5))
311 while (*--input_line_pointer
!= '"')
313 input_line_pointer
--;
314 goto bad_common_segment
;
316 while (*input_line_pointer
++ != '"')
318 goto allocate_common
;
320 demand_empty_rest_of_line ();
325 p
= input_line_pointer
;
326 while (*p
&& *p
!= '\n')
330 as_bad ("bad .common segment %s", input_line_pointer
+ 1);
332 input_line_pointer
= p
;
333 ignore_rest_of_line ();
339 obj_elf_local (ignore
)
348 name
= input_line_pointer
;
349 c
= get_symbol_end ();
350 symbolP
= symbol_find_or_make (name
);
351 *input_line_pointer
= c
;
353 S_CLEAR_EXTERNAL (symbolP
);
357 input_line_pointer
++;
359 if (*input_line_pointer
== '\n')
364 demand_empty_rest_of_line ();
368 obj_elf_weak (ignore
)
377 name
= input_line_pointer
;
378 c
= get_symbol_end ();
379 symbolP
= symbol_find_or_make (name
);
380 *input_line_pointer
= c
;
382 S_SET_WEAK (symbolP
);
386 input_line_pointer
++;
388 if (*input_line_pointer
== '\n')
393 demand_empty_rest_of_line ();
396 static segT previous_section
;
397 static int previous_subsection
;
399 /* Handle the .section pseudo-op. This code supports two different
402 The first is found on Solaris, and looks like
403 .section ".sec1",#alloc,#execinstr,#write
404 Here the names after '#' are the SHF_* flags to turn on for the
405 section. I'm not sure how it determines the SHT_* type (BFD
406 doesn't really give us control over the type, anyhow).
408 The second format is found on UnixWare, and probably most SVR4
409 machines, and looks like
410 .section .sec1,"a",@progbits
411 The quoted string may contain any combination of a, w, x, and
412 represents the SHF_* flags to turn on for the section. The string
413 beginning with '@' can be progbits or nobits. There should be
414 other possibilities, but I don't know what they are. In any case,
415 BFD doesn't really let us set the section type. */
417 /* Certain named sections have particular defined types, listed on p.
419 struct special_section
426 static struct special_section special_sections
[] =
428 { ".bss", SHT_NOBITS
, SHF_ALLOC
+ SHF_WRITE
},
429 { ".comment", SHT_PROGBITS
, 0 },
430 { ".data", SHT_PROGBITS
, SHF_ALLOC
+ SHF_WRITE
},
431 { ".data1", SHT_PROGBITS
, SHF_ALLOC
+ SHF_WRITE
},
432 { ".debug", SHT_PROGBITS
, 0 },
433 { ".fini", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
434 { ".init", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
435 { ".line", SHT_PROGBITS
, 0 },
436 { ".note", SHT_NOTE
, 0 },
437 { ".rodata", SHT_PROGBITS
, SHF_ALLOC
},
438 { ".rodata1", SHT_PROGBITS
, SHF_ALLOC
},
439 { ".text", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
441 #ifdef ELF_TC_SPECIAL_SECTIONS
442 ELF_TC_SPECIAL_SECTIONS
446 /* The following section names are special, but they can not
447 reasonably appear in assembler code. Some of the attributes are
448 processor dependent. */
449 { ".dynamic", SHT_DYNAMIC
, SHF_ALLOC
/* + SHF_WRITE */ },
450 { ".dynstr", SHT_STRTAB
, SHF_ALLOC
},
451 { ".dynsym", SHT_DYNSYM
, SHF_ALLOC
},
452 { ".got", SHT_PROGBITS
, 0 },
453 { ".hash", SHT_HASH
, SHF_ALLOC
},
454 { ".interp", SHT_PROGBITS
, /* SHF_ALLOC */ },
455 { ".plt", SHT_PROGBITS
, 0 },
456 { ".shstrtab",SHT_STRTAB
, 0 },
457 { ".strtab", SHT_STRTAB
, /* SHF_ALLOC */ },
458 { ".symtab", SHT_SYMTAB
, /* SHF_ALLOC */ },
465 obj_elf_section (xxx
)
475 #ifdef md_flush_pending_output
476 md_flush_pending_output ();
479 /* Get name of section. */
481 if (*input_line_pointer
== '"')
483 string
= demand_copy_C_string (&xxx
);
486 ignore_rest_of_line ();
492 char *p
= input_line_pointer
;
494 while (0 == strchr ("\n\t,; ", *p
))
496 if (p
== input_line_pointer
)
498 as_warn ("Missing section name");
499 ignore_rest_of_line ();
504 string
= xmalloc ((unsigned long) (p
- input_line_pointer
+ 1));
505 strcpy (string
, input_line_pointer
);
507 input_line_pointer
= p
;
510 /* Switch to the section, creating it if necessary. */
511 previous_section
= now_seg
;
512 previous_subsection
= now_subseg
;
514 new_sec
= bfd_get_section_by_name (stdoutput
, string
) == NULL
;
515 sec
= subseg_new (string
, 0);
517 /* If this section already existed, we don't bother to change the
521 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
522 ++input_line_pointer
;
523 ++input_line_pointer
;
525 #ifdef md_elf_section_change_hook
526 md_elf_section_change_hook ();
537 if (*input_line_pointer
== ',')
539 /* Skip the comma. */
540 ++input_line_pointer
;
543 if (*input_line_pointer
== '"')
545 /* Pick up a string with a combination of a, w, x. */
546 ++input_line_pointer
;
547 while (*input_line_pointer
!= '"')
549 switch (*input_line_pointer
)
558 attr
|= SHF_EXECINSTR
;
561 as_warn ("Bad .section directive: want a,w,x in string");
562 ignore_rest_of_line ();
565 ++input_line_pointer
;
568 /* Skip the closing quote. */
569 ++input_line_pointer
;
572 if (*input_line_pointer
== ',')
574 ++input_line_pointer
;
576 if (*input_line_pointer
== '@')
578 ++input_line_pointer
;
579 if (strncmp (input_line_pointer
, "progbits",
580 sizeof "progbits" - 1) == 0)
583 input_line_pointer
+= sizeof "progbits" - 1;
585 else if (strncmp (input_line_pointer
, "nobits",
586 sizeof "nobits" - 1) == 0)
589 input_line_pointer
+= sizeof "nobits" - 1;
593 as_warn ("Unrecognized section type");
594 ignore_rest_of_line ();
604 if (*input_line_pointer
!= '#')
606 as_warn ("Bad .section directive");
607 ignore_rest_of_line ();
610 ++input_line_pointer
;
611 if (strncmp (input_line_pointer
, "write",
612 sizeof "write" - 1) == 0)
615 input_line_pointer
+= sizeof "write" - 1;
617 else if (strncmp (input_line_pointer
, "alloc",
618 sizeof "alloc" - 1) == 0)
621 input_line_pointer
+= sizeof "alloc" - 1;
623 else if (strncmp (input_line_pointer
, "execinstr",
624 sizeof "execinstr" - 1) == 0)
626 attr
|= SHF_EXECINSTR
;
627 input_line_pointer
+= sizeof "execinstr" - 1;
631 as_warn ("Unrecognized section attribute");
632 ignore_rest_of_line ();
637 while (*input_line_pointer
++ == ',');
638 --input_line_pointer
;
642 /* See if this is one of the special sections. */
643 for (i
= 0; special_sections
[i
].name
!= NULL
; i
++)
645 if (string
[1] == special_sections
[i
].name
[1]
646 && strcmp (string
, special_sections
[i
].name
) == 0)
648 if (type
== SHT_NULL
)
649 type
= special_sections
[i
].type
;
650 else if (type
!= special_sections
[i
].type
)
651 as_warn ("Setting incorrect section type for %s", string
);
653 if ((attr
&~ special_sections
[i
].attributes
) != 0)
654 as_warn ("Setting incorrect section attributes for %s", string
);
655 attr
|= special_sections
[i
].attributes
;
662 | ((attr
& SHF_WRITE
) ? 0 : SEC_READONLY
)
663 | ((attr
& SHF_ALLOC
) ? SEC_ALLOC
| SEC_LOAD
: 0)
664 | ((attr
& SHF_EXECINSTR
) ? SEC_CODE
: 0));
665 if (special_sections
[i
].name
== NULL
)
667 if (type
== SHT_PROGBITS
)
668 flags
|= SEC_ALLOC
| SEC_LOAD
;
669 else if (type
== SHT_NOBITS
)
676 bfd_set_section_flags (stdoutput
, sec
, flags
);
678 #ifdef md_elf_section_change_hook
679 md_elf_section_change_hook ();
682 demand_empty_rest_of_line ();
685 /* Change to the .data section. */
691 previous_section
= now_seg
;
692 previous_subsection
= now_subseg
;
696 /* Change to the .text section. */
702 previous_section
= now_seg
;
703 previous_subsection
= now_subseg
;
708 obj_elf_previous (ignore
)
711 if (previous_section
== 0)
713 as_bad (".previous without corresponding .section; ignored");
716 subseg_set (previous_section
, previous_subsection
);
717 previous_section
= 0;
721 obj_elf_line (ignore
)
724 /* Assume delimiter is part of expression. BSD4.2 as fails with
725 delightful bug, so we are not being incompatible here. */
726 new_logical_line ((char *) NULL
, (int) (get_absolute_expression ()));
727 demand_empty_rest_of_line ();
731 obj_read_begin_hook ()
734 ecoff_read_begin_hook ();
738 obj_symbol_new_hook (symbolP
)
744 ecoff_symbol_new_hook (symbolP
);
748 obj_elf_version (ignore
)
755 asection
*seg
= now_seg
;
756 subsegT subseg
= now_subseg
;
757 Elf_Internal_Note i_note
;
758 Elf_External_Note e_note
;
759 asection
*note_secp
= (asection
*) NULL
;
763 if (*input_line_pointer
== '\"')
765 ++input_line_pointer
; /* -> 1st char of string. */
766 name
= input_line_pointer
;
768 while (is_a_char (c
= next_char_of_string ()))
770 c
= *input_line_pointer
;
771 *input_line_pointer
= '\0';
772 *(input_line_pointer
- 1) = '\0';
773 *input_line_pointer
= c
;
775 /* create the .note section */
777 note_secp
= subseg_new (".note", 0);
778 bfd_set_section_flags (stdoutput
,
780 SEC_HAS_CONTENTS
| SEC_READONLY
);
782 /* process the version string */
786 i_note
.namesz
= ((len
+ 1) + 3) & ~3; /* round this to word boundary */
787 i_note
.descsz
= 0; /* no description */
788 i_note
.type
= NT_VERSION
;
789 p
= frag_more (sizeof (e_note
.namesz
));
790 md_number_to_chars (p
, (valueT
) i_note
.namesz
, 4);
791 p
= frag_more (sizeof (e_note
.descsz
));
792 md_number_to_chars (p
, (valueT
) i_note
.descsz
, 4);
793 p
= frag_more (sizeof (e_note
.type
));
794 md_number_to_chars (p
, (valueT
) i_note
.type
, 4);
796 for (i
= 0; i
< len
; i
++)
800 FRAG_APPEND_1_CHAR (ch
);
805 subseg_set (seg
, subseg
);
809 as_bad ("Expected quoted string");
811 demand_empty_rest_of_line ();
815 obj_elf_size (ignore
)
818 char *name
= input_line_pointer
;
819 char c
= get_symbol_end ();
824 p
= input_line_pointer
;
827 if (*input_line_pointer
!= ',')
830 as_bad ("expected comma after name `%s' in .size directive", name
);
832 ignore_rest_of_line ();
835 input_line_pointer
++;
837 if (exp
.X_op
== O_absent
)
839 as_bad ("missing expression in .size directive");
840 exp
.X_op
= O_constant
;
841 exp
.X_add_number
= 0;
844 sym
= symbol_find_or_make (name
);
846 if (exp
.X_op
== O_constant
)
847 S_SET_SIZE (sym
, exp
.X_add_number
);
850 sym
->sy_obj
= (expressionS
*) xmalloc (sizeof (expressionS
));
853 demand_empty_rest_of_line ();
856 /* Handle the ELF .type pseudo-op. This sets the type of a symbol.
857 There are three syntaxes. The first (used on Solaris) is
859 The second (used on UnixWare) is
861 The third (reportedly to be used on Irix 6.0) is
864 FIXME: We do not fully support this pseudo-op. In fact, the only
865 case we do support is setting the type to STT_FUNC, which we do by
866 setting the BSF_FUNCTION flag. */
869 obj_elf_type (ignore
)
875 const char *typename
;
878 name
= input_line_pointer
;
879 c
= get_symbol_end ();
880 sym
= symbol_find_or_make (name
);
881 *input_line_pointer
= c
;
884 if (*input_line_pointer
== ',')
885 ++input_line_pointer
;
888 if (*input_line_pointer
== '#' || *input_line_pointer
== '@')
889 ++input_line_pointer
;
891 typename
= input_line_pointer
;
892 c
= get_symbol_end ();
895 if (strcmp (typename
, "function") == 0
896 || strcmp (typename
, "STT_FUNC") == 0)
898 else if (strcmp (typename
, "object") == 0
899 || strcmp (typename
, "STT_OBJECT") == 0)
902 as_bad ("ignoring unrecognized symbol type \"%s\"", typename
);
904 *input_line_pointer
= c
;
906 sym
->bsym
->flags
|= type
;
908 demand_empty_rest_of_line ();
912 obj_elf_ident (ignore
)
915 static segT comment_section
;
916 segT old_section
= now_seg
;
917 int old_subsection
= now_subseg
;
919 if (!comment_section
)
922 comment_section
= subseg_new (".comment", 0);
923 bfd_set_section_flags (stdoutput
, comment_section
,
924 SEC_READONLY
| SEC_HAS_CONTENTS
);
929 subseg_set (comment_section
, 0);
931 subseg_set (old_section
, old_subsection
);
934 #ifdef INIT_STAB_SECTION
936 /* The first entry in a .stabs section is special. */
939 obj_elf_init_stab_section (seg
)
947 /* Force the section to align to a longword boundary. Without this,
948 UnixWare ar crashes. */
949 bfd_set_section_alignment (stdoutput
, seg
, 2);
951 /* Make space for this first symbol. */
955 as_where (&file
, (unsigned int *) NULL
);
956 stabstr_name
= (char *) alloca (strlen (segment_name (seg
)) + 4);
957 strcpy (stabstr_name
, segment_name (seg
));
958 strcat (stabstr_name
, "str");
959 stroff
= get_stab_string_offset (file
, stabstr_name
);
961 md_number_to_chars (p
, stroff
, 4);
962 seg_info (seg
)->stabu
.p
= p
;
967 /* Fill in the counts in the first entry in a .stabs section. */
970 adjust_stab_sections (abfd
, sec
, xxx
)
980 if (strncmp (".stab", sec
->name
, 5))
982 if (!strcmp ("str", sec
->name
+ strlen (sec
->name
) - 3))
985 name
= (char *) alloca (strlen (sec
->name
) + 4);
986 strcpy (name
, sec
->name
);
987 strcat (name
, "str");
988 strsec
= bfd_get_section_by_name (abfd
, name
);
990 strsz
= bfd_section_size (abfd
, strsec
);
993 nsyms
= bfd_section_size (abfd
, sec
) / 12 - 1;
995 p
= seg_info (sec
)->stabu
.p
;
998 bfd_h_put_16 (abfd
, (bfd_vma
) nsyms
, (bfd_byte
*) p
+ 6);
999 bfd_h_put_32 (abfd
, (bfd_vma
) strsz
, (bfd_byte
*) p
+ 8);
1002 /* #ifdef ECOFF_DEBUGGING */
1004 /* This function is called by the ECOFF code. It is supposed to
1005 record the external symbol information so that the backend can
1006 write it out correctly. The ELF backend doesn't actually handle
1007 this at the moment, so we do it ourselves. We save the information
1011 elf_ecoff_set_ext (sym
, ext
)
1013 struct ecoff_extr
*ext
;
1015 sym
->bsym
->udata
.p
= (PTR
) ext
;
1018 /* This function is called by bfd_ecoff_debug_externals. It is
1019 supposed to *EXT to the external symbol information, and return
1020 whether the symbol should be used at all. */
1023 elf_get_extr (sym
, ext
)
1027 if (sym
->udata
.p
== NULL
)
1029 *ext
= *(EXTR
*) sym
->udata
.p
;
1033 /* This function is called by bfd_ecoff_debug_externals. It has
1034 nothing to do for ELF. */
1038 elf_set_index (sym
, indx
)
1044 /* #endif /* ECOFF_DEBUGGING */
1047 elf_frob_symbol (symp
, puntp
)
1051 if (ECOFF_DEBUGGING
)
1052 ecoff_frob_symbol (symp
);
1056 switch (symp
->sy_obj
->X_op
)
1060 (S_GET_VALUE (symp
->sy_obj
->X_add_symbol
)
1061 + symp
->sy_obj
->X_add_number
1062 - S_GET_VALUE (symp
->sy_obj
->X_op_symbol
)));
1066 (S_GET_VALUE (symp
->sy_obj
->X_add_symbol
)
1067 + symp
->sy_obj
->X_add_number
));
1070 as_bad (".size expression too complicated to fix up");
1074 free (symp
->sy_obj
);
1077 /* Double check weak symbols. */
1078 if (symp
->bsym
->flags
& BSF_WEAK
)
1080 if (S_IS_COMMON (symp
))
1081 as_bad ("Symbol `%s' can not be both weak and common",
1089 bfd_map_over_sections (stdoutput
, adjust_stab_sections
, (PTR
) 0);
1091 #ifdef elf_tc_final_processing
1092 elf_tc_final_processing ();
1095 if (ECOFF_DEBUGGING
)
1096 /* Generate the ECOFF debugging information. */
1098 const struct ecoff_debug_swap
*debug_swap
;
1099 struct ecoff_debug_info debug
;
1104 = get_elf_backend_data (stdoutput
)->elf_backend_ecoff_debug_swap
;
1105 know (debug_swap
!= (const struct ecoff_debug_swap
*) NULL
);
1106 ecoff_build_debug (&debug
.symbolic_header
, &buf
, debug_swap
);
1108 /* Set up the pointers in debug. */
1109 #define SET(ptr, offset, type) \
1110 debug.ptr = (type) (buf + debug.symbolic_header.offset)
1112 SET (line
, cbLineOffset
, unsigned char *);
1113 SET (external_dnr
, cbDnOffset
, PTR
);
1114 SET (external_pdr
, cbPdOffset
, PTR
);
1115 SET (external_sym
, cbSymOffset
, PTR
);
1116 SET (external_opt
, cbOptOffset
, PTR
);
1117 SET (external_aux
, cbAuxOffset
, union aux_ext
*);
1118 SET (ss
, cbSsOffset
, char *);
1119 SET (external_fdr
, cbFdOffset
, PTR
);
1120 SET (external_rfd
, cbRfdOffset
, PTR
);
1121 /* ssext and external_ext are set up just below. */
1125 /* Set up the external symbols. */
1126 debug
.ssext
= debug
.ssext_end
= NULL
;
1127 debug
.external_ext
= debug
.external_ext_end
= NULL
;
1128 if (! bfd_ecoff_debug_externals (stdoutput
, &debug
, debug_swap
, true,
1129 elf_get_extr
, elf_set_index
))
1130 as_fatal ("Failed to set up debugging information: %s",
1131 bfd_errmsg (bfd_get_error ()));
1133 sec
= bfd_get_section_by_name (stdoutput
, ".mdebug");
1134 assert (sec
!= NULL
);
1136 know (stdoutput
->output_has_begun
== false);
1138 /* We set the size of the section, call bfd_set_section_contents
1139 to force the ELF backend to allocate a file position, and then
1140 write out the data. FIXME: Is this really the best way to do
1142 sec
->_raw_size
= bfd_ecoff_debug_size (stdoutput
, &debug
, debug_swap
);
1144 if (! bfd_set_section_contents (stdoutput
, sec
, (PTR
) NULL
,
1145 (file_ptr
) 0, (bfd_size_type
) 0))
1146 as_fatal ("Can't start writing .mdebug section: %s",
1147 bfd_errmsg (bfd_get_error ()));
1149 know (stdoutput
->output_has_begun
== true);
1150 know (sec
->filepos
!= 0);
1152 if (! bfd_ecoff_write_debug (stdoutput
, &debug
, debug_swap
,
1154 as_fatal ("Could not write .mdebug section: %s",
1155 bfd_errmsg (bfd_get_error ()));
1159 const struct format_ops elf_format_ops
=
1161 bfd_target_elf_flavour
,
1166 elf_s_get_size
, elf_s_set_size
,
1167 elf_s_get_align
, elf_s_set_align
,
1168 elf_copy_symbol_attributes
,
1169 #ifdef ECOFF_DEBUGGING
1170 ecoff_generate_asm_lineno
,
1174 0, /* process_stab */
1175 elf_sec_sym_ok_for_reloc
,
1178 obj_read_begin_hook
,
1179 obj_symbol_new_hook
,