1 /* ELF object file format
2 Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2,
10 or (at your option) any later version.
12 GAS is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #define OBJ_HEADER "obj-elf.h"
27 #ifndef ECOFF_DEBUGGING
28 #define ECOFF_DEBUGGING 0
30 #define NEED_ECOFF_DEBUG
33 #ifdef NEED_ECOFF_DEBUG
38 #include "elf/alpha.h"
53 static bfd_vma elf_s_get_size
PARAMS ((symbolS
*));
54 static void elf_s_set_size
PARAMS ((symbolS
*, bfd_vma
));
55 static bfd_vma elf_s_get_align
PARAMS ((symbolS
*));
56 static void elf_s_set_align
PARAMS ((symbolS
*, bfd_vma
));
57 static void elf_s_set_other
PARAMS ((symbolS
*, int));
58 static void elf_copy_symbol_attributes
PARAMS ((symbolS
*, symbolS
*));
59 static int elf_sec_sym_ok_for_reloc
PARAMS ((asection
*));
60 static void adjust_stab_sections
PARAMS ((bfd
*, asection
*, PTR
));
61 static int elf_separate_stab_sections
PARAMS ((void));
62 static void elf_init_stab_section
PARAMS ((segT
));
64 #ifdef NEED_ECOFF_DEBUG
65 static boolean elf_get_extr
PARAMS ((asymbol
*, EXTR
*));
66 static void elf_set_index
PARAMS ((asymbol
*, bfd_size_type
));
69 static void obj_elf_line
PARAMS ((int));
70 void obj_elf_version
PARAMS ((int));
71 static void obj_elf_size
PARAMS ((int));
72 static void obj_elf_type
PARAMS ((int));
73 static void obj_elf_ident
PARAMS ((int));
74 static void obj_elf_weak
PARAMS ((int));
75 static void obj_elf_local
PARAMS ((int));
76 static void obj_elf_visibility
PARAMS ((int));
77 static void obj_elf_symver
PARAMS ((int));
78 static void obj_elf_vtable_inherit
PARAMS ((int));
79 static void obj_elf_vtable_entry
PARAMS ((int));
80 static void obj_elf_subsection
PARAMS ((int));
81 static void obj_elf_popsection
PARAMS ((int));
83 static const pseudo_typeS elf_pseudo_table
[] =
85 {"comm", obj_elf_common
, 0},
86 {"common", obj_elf_common
, 1},
87 {"ident", obj_elf_ident
, 0},
88 {"local", obj_elf_local
, 0},
89 {"previous", obj_elf_previous
, 0},
90 {"section", obj_elf_section
, 0},
91 {"section.s", obj_elf_section
, 0},
92 {"sect", obj_elf_section
, 0},
93 {"sect.s", obj_elf_section
, 0},
94 {"pushsection", obj_elf_section
, 1},
95 {"popsection", obj_elf_popsection
, 0},
96 {"size", obj_elf_size
, 0},
97 {"type", obj_elf_type
, 0},
98 {"version", obj_elf_version
, 0},
99 {"weak", obj_elf_weak
, 0},
101 /* These define symbol visibility. */
102 {"internal", obj_elf_visibility
, STV_INTERNAL
},
103 {"hidden", obj_elf_visibility
, STV_HIDDEN
},
104 {"protected", obj_elf_visibility
, STV_PROTECTED
},
106 /* These are used for stabs-in-elf configurations. */
107 {"line", obj_elf_line
, 0},
109 /* This is a GNU extension to handle symbol versions. */
110 {"symver", obj_elf_symver
, 0},
112 /* A GNU extension to change subsection only. */
113 {"subsection", obj_elf_subsection
, 0},
115 /* These are GNU extensions to aid in garbage collecting C++ vtables. */
116 {"vtable_inherit", obj_elf_vtable_inherit
, 0},
117 {"vtable_entry", obj_elf_vtable_entry
, 0},
119 /* These are used for dwarf. */
124 /* We need to trap the section changing calls to handle .previous. */
125 {"data", obj_elf_data
, 0},
126 {"text", obj_elf_text
, 0},
132 static const pseudo_typeS ecoff_debug_pseudo_table
[] =
134 #ifdef NEED_ECOFF_DEBUG
135 /* COFF style debugging information for ECOFF. .ln is not used; .loc
137 { "def", ecoff_directive_def
, 0 },
138 { "dim", ecoff_directive_dim
, 0 },
139 { "endef", ecoff_directive_endef
, 0 },
140 { "file", ecoff_directive_file
, 0 },
141 { "scl", ecoff_directive_scl
, 0 },
142 { "tag", ecoff_directive_tag
, 0 },
143 { "val", ecoff_directive_val
, 0 },
145 /* COFF debugging requires pseudo-ops .size and .type, but ELF
146 already has meanings for those. We use .esize and .etype
147 instead. These are only generated by gcc anyhow. */
148 { "esize", ecoff_directive_size
, 0 },
149 { "etype", ecoff_directive_type
, 0 },
151 /* ECOFF specific debugging information. */
152 { "begin", ecoff_directive_begin
, 0 },
153 { "bend", ecoff_directive_bend
, 0 },
154 { "end", ecoff_directive_end
, 0 },
155 { "ent", ecoff_directive_ent
, 0 },
156 { "fmask", ecoff_directive_fmask
, 0 },
157 { "frame", ecoff_directive_frame
, 0 },
158 { "loc", ecoff_directive_loc
, 0 },
159 { "mask", ecoff_directive_mask
, 0 },
161 /* Other ECOFF directives. */
162 { "extern", ecoff_directive_extern
, 0 },
164 /* These are used on Irix. I don't know how to implement them. */
165 { "alias", s_ignore
, 0 },
166 { "bgnb", s_ignore
, 0 },
167 { "endb", s_ignore
, 0 },
168 { "lab", s_ignore
, 0 },
169 { "noalias", s_ignore
, 0 },
170 { "verstamp", s_ignore
, 0 },
171 { "vreg", s_ignore
, 0 },
174 {NULL
, NULL
, 0} /* end sentinel */
178 #include "aout/aout64.h"
180 /* This is called when the assembler starts. */
185 /* Add symbols for the known sections to the symbol table. */
186 symbol_table_insert (section_symbol (bfd_get_section_by_name (stdoutput
,
187 TEXT_SECTION_NAME
)));
188 symbol_table_insert (section_symbol (bfd_get_section_by_name (stdoutput
,
189 DATA_SECTION_NAME
)));
190 symbol_table_insert (section_symbol (bfd_get_section_by_name (stdoutput
,
197 pop_insert (elf_pseudo_table
);
199 pop_insert (ecoff_debug_pseudo_table
);
206 return S_GET_SIZE (sym
);
210 elf_s_set_size (sym
, sz
)
214 S_SET_SIZE (sym
, sz
);
218 elf_s_get_align (sym
)
221 return S_GET_ALIGN (sym
);
225 elf_s_set_align (sym
, align
)
229 S_SET_ALIGN (sym
, align
);
233 elf_s_get_other (sym
)
236 return elf_symbol (symbol_get_bfdsym (sym
))->internal_elf_sym
.st_other
;
240 elf_s_set_other (sym
, other
)
244 S_SET_OTHER (sym
, other
);
248 elf_copy_symbol_attributes (dest
, src
)
251 OBJ_COPY_SYMBOL_ATTRIBUTES (dest
, src
);
255 elf_sec_sym_ok_for_reloc (sec
)
258 return obj_sec_sym_ok_for_reloc (sec
);
267 sym
= symbol_new (s
, absolute_section
, (valueT
) 0, (struct frag
*) 0);
268 symbol_set_frag (sym
, &zero_address_frag
);
269 symbol_get_bfdsym (sym
)->flags
|= BSF_FILE
;
271 if (symbol_rootP
!= sym
)
273 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
274 symbol_insert (sym
, symbol_rootP
, &symbol_rootP
, &symbol_lastP
);
276 verify_symbol_chain (symbol_rootP
, symbol_lastP
);
280 #ifdef NEED_ECOFF_DEBUG
286 obj_elf_common (is_common
)
296 if (flag_mri
&& is_common
)
302 name
= input_line_pointer
;
303 c
= get_symbol_end ();
304 /* just after name is now '\0' */
305 p
= input_line_pointer
;
308 if (*input_line_pointer
!= ',')
310 as_bad (_("Expected comma after symbol-name"));
311 ignore_rest_of_line ();
314 input_line_pointer
++; /* skip ',' */
315 if ((temp
= get_absolute_expression ()) < 0)
317 as_bad (_(".COMMon length (%d.) <0! Ignored."), temp
);
318 ignore_rest_of_line ();
323 symbolP
= symbol_find_or_make (name
);
325 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
327 as_bad (_("Ignoring attempt to re-define symbol"));
328 ignore_rest_of_line ();
331 if (S_GET_VALUE (symbolP
) != 0)
333 if (S_GET_VALUE (symbolP
) != (valueT
) size
)
335 as_warn (_("Length of .comm \"%s\" is already %ld. Not changed to %d."),
336 S_GET_NAME (symbolP
), (long) S_GET_VALUE (symbolP
), size
);
339 know (symbolP
->sy_frag
== &zero_address_frag
);
340 if (*input_line_pointer
!= ',')
345 input_line_pointer
++;
348 if (! have_align
|| *input_line_pointer
!= '"')
354 temp
= get_absolute_expression ();
358 as_warn (_("Common alignment negative; 0 assumed"));
361 if (symbol_get_obj (symbolP
)->local
)
370 old_subsec
= now_subseg
;
373 /* convert to a power of 2 alignment */
374 for (align
= 0; (temp
& 1) == 0; temp
>>= 1, ++align
);
377 as_bad (_("Common alignment not a power of 2"));
378 ignore_rest_of_line ();
384 record_alignment (bss_section
, align
);
385 subseg_set (bss_section
, 0);
387 frag_align (align
, 0, 0);
388 if (S_GET_SEGMENT (symbolP
) == bss_section
)
389 symbol_get_frag (symbolP
)->fr_symbol
= 0;
390 symbol_set_frag (symbolP
, frag_now
);
391 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
392 (offsetT
) size
, (char *) 0);
394 S_SET_SIZE (symbolP
, size
);
395 S_SET_SEGMENT (symbolP
, bss_section
);
396 S_CLEAR_EXTERNAL (symbolP
);
397 subseg_set (old_sec
, old_subsec
);
402 S_SET_VALUE (symbolP
, (valueT
) size
);
403 S_SET_ALIGN (symbolP
, temp
);
404 S_SET_EXTERNAL (symbolP
);
405 S_SET_SEGMENT (symbolP
, bfd_com_section_ptr
);
410 input_line_pointer
++;
411 /* @@ Some use the dot, some don't. Can we get some consistency?? */
412 if (*input_line_pointer
== '.')
413 input_line_pointer
++;
414 /* @@ Some say data, some say bss. */
415 if (strncmp (input_line_pointer
, "bss\"", 4)
416 && strncmp (input_line_pointer
, "data\"", 5))
418 while (*--input_line_pointer
!= '"')
420 input_line_pointer
--;
421 goto bad_common_segment
;
423 while (*input_line_pointer
++ != '"')
425 goto allocate_common
;
428 symbol_get_bfdsym (symbolP
)->flags
|= BSF_OBJECT
;
430 demand_empty_rest_of_line ();
435 p
= input_line_pointer
;
436 while (*p
&& *p
!= '\n')
440 as_bad (_("bad .common segment %s"), input_line_pointer
+ 1);
442 input_line_pointer
= p
;
443 ignore_rest_of_line ();
449 obj_elf_local (ignore
)
450 int ignore ATTRIBUTE_UNUSED
;
458 name
= input_line_pointer
;
459 c
= get_symbol_end ();
460 symbolP
= symbol_find_or_make (name
);
461 *input_line_pointer
= c
;
463 S_CLEAR_EXTERNAL (symbolP
);
464 symbol_get_obj (symbolP
)->local
= 1;
467 input_line_pointer
++;
469 if (*input_line_pointer
== '\n')
474 demand_empty_rest_of_line ();
478 obj_elf_weak (ignore
)
479 int ignore ATTRIBUTE_UNUSED
;
487 name
= input_line_pointer
;
488 c
= get_symbol_end ();
489 symbolP
= symbol_find_or_make (name
);
490 *input_line_pointer
= c
;
492 S_SET_WEAK (symbolP
);
493 symbol_get_obj (symbolP
)->local
= 1;
496 input_line_pointer
++;
498 if (*input_line_pointer
== '\n')
503 demand_empty_rest_of_line ();
507 obj_elf_visibility (visibility
)
514 elf_symbol_type
*elfsym
;
518 name
= input_line_pointer
;
519 c
= get_symbol_end ();
520 symbolP
= symbol_find_or_make (name
);
521 *input_line_pointer
= c
;
525 bfdsym
= symbol_get_bfdsym (symbolP
);
526 elfsym
= elf_symbol_from (bfd_asymbol_bfd (bfdsym
), bfdsym
);
530 elfsym
->internal_elf_sym
.st_other
= visibility
;
534 input_line_pointer
++;
538 if (*input_line_pointer
== '\n')
544 demand_empty_rest_of_line ();
548 static segT previous_section
;
549 static int previous_subsection
;
553 struct section_stack
*next
;
555 int subseg
, prev_subseg
;
558 static struct section_stack
*section_stack
;
561 /* Handle the .section pseudo-op. This code supports two different
564 The first is found on Solaris, and looks like
565 .section ".sec1",#alloc,#execinstr,#write
566 Here the names after '#' are the SHF_* flags to turn on for the
567 section. I'm not sure how it determines the SHT_* type (BFD
568 doesn't really give us control over the type, anyhow).
570 The second format is found on UnixWare, and probably most SVR4
571 machines, and looks like
572 .section .sec1,"a",@progbits
573 The quoted string may contain any combination of a, w, x, and
574 represents the SHF_* flags to turn on for the section. The string
575 beginning with '@' can be progbits or nobits. There should be
576 other possibilities, but I don't know what they are. In any case,
577 BFD doesn't really let us set the section type. */
579 /* Certain named sections have particular defined types, listed on p.
581 struct special_section
588 static struct special_section
const special_sections
[] =
590 { ".bss", SHT_NOBITS
, SHF_ALLOC
+ SHF_WRITE
},
591 { ".comment", SHT_PROGBITS
, 0 },
592 { ".data", SHT_PROGBITS
, SHF_ALLOC
+ SHF_WRITE
},
593 { ".data1", SHT_PROGBITS
, SHF_ALLOC
+ SHF_WRITE
},
594 { ".debug", SHT_PROGBITS
, 0 },
595 { ".fini", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
596 { ".init", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
597 { ".line", SHT_PROGBITS
, 0 },
598 { ".note", SHT_NOTE
, 0 },
599 { ".rodata", SHT_PROGBITS
, SHF_ALLOC
},
600 { ".rodata1", SHT_PROGBITS
, SHF_ALLOC
},
601 { ".text", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
603 #ifdef ELF_TC_SPECIAL_SECTIONS
604 ELF_TC_SPECIAL_SECTIONS
608 /* The following section names are special, but they can not
609 reasonably appear in assembler code. Some of the attributes are
610 processor dependent. */
611 { ".dynamic", SHT_DYNAMIC
, SHF_ALLOC
/* + SHF_WRITE */ },
612 { ".dynstr", SHT_STRTAB
, SHF_ALLOC
},
613 { ".dynsym", SHT_DYNSYM
, SHF_ALLOC
},
614 { ".got", SHT_PROGBITS
, 0 },
615 { ".hash", SHT_HASH
, SHF_ALLOC
},
616 { ".interp", SHT_PROGBITS
, /* SHF_ALLOC */ },
617 { ".plt", SHT_PROGBITS
, 0 },
618 { ".shstrtab",SHT_STRTAB
, 0 },
619 { ".strtab", SHT_STRTAB
, /* SHF_ALLOC */ },
620 { ".symtab", SHT_SYMTAB
, /* SHF_ALLOC */ },
627 obj_elf_change_section (name
, type
, attr
, push
)
629 int type
, attr
, push
;
636 #ifdef md_flush_pending_output
637 md_flush_pending_output ();
640 /* Switch to the section, creating it if necessary. */
643 struct section_stack
*elt
;
644 elt
= xmalloc (sizeof (struct section_stack
));
645 elt
->next
= section_stack
;
647 elt
->prev_seg
= previous_section
;
648 elt
->subseg
= now_subseg
;
649 elt
->prev_subseg
= previous_subsection
;
652 previous_section
= now_seg
;
653 previous_subsection
= now_subseg
;
655 old_sec
= bfd_get_section_by_name (stdoutput
, name
);
656 sec
= subseg_new (name
, 0);
658 /* See if this is one of the special sections. */
659 for (i
= 0; special_sections
[i
].name
!= NULL
; i
++)
660 if (strcmp (name
, special_sections
[i
].name
) == 0)
662 if (type
== SHT_NULL
)
663 type
= special_sections
[i
].type
;
664 else if (type
!= special_sections
[i
].type
)
668 as_warn (_("Setting incorrect section type for %s"), name
);
672 as_warn (_("Ignoring incorrect section type for %s"), name
);
673 type
= special_sections
[i
].type
;
676 if ((attr
&~ special_sections
[i
].attributes
) != 0
679 /* As a GNU extension, we permit a .note section to be
680 allocatable. If the linker sees an allocateable .note
681 section, it will create a PT_NOTE segment in the output
683 if (strcmp (name
, ".note") != 0
684 || attr
!= SHF_ALLOC
)
685 as_warn (_("Setting incorrect section attributes for %s"),
688 attr
|= special_sections
[i
].attributes
;
692 /* Convert ELF type and flags to BFD flags. */
694 | ((attr
& SHF_WRITE
) ? 0 : SEC_READONLY
)
695 | ((attr
& SHF_ALLOC
) ? SEC_ALLOC
: 0)
696 | (((attr
& SHF_ALLOC
) && type
!= SHT_NOBITS
) ? SEC_LOAD
: 0)
697 | ((attr
& SHF_EXECINSTR
) ? SEC_CODE
: 0));
698 #ifdef md_elf_section_flags
699 flags
= md_elf_section_flags (flags
, attr
, type
);
706 /* Prevent SEC_HAS_CONTENTS from being inadvertently set. */
707 if (type
== SHT_NOBITS
)
708 seg_info (sec
)->bss
= 1;
710 bfd_set_section_flags (stdoutput
, sec
, flags
);
712 /* Add a symbol for this section to the symbol table. */
713 secsym
= symbol_find (name
);
715 symbol_set_bfdsym (secsym
, sec
->symbol
);
717 symbol_table_insert (section_symbol (sec
));
721 /* If section attributes are specified the second time we see a
722 particular section, then check that they are the same as we
723 saw the first time. */
724 if ((old_sec
->flags
^ flags
)
725 & (SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
726 | SEC_EXCLUDE
| SEC_SORT_ENTRIES
))
727 as_warn (_("Ignoring changed section attributes for %s"), name
);
730 #ifdef md_elf_section_change_hook
731 md_elf_section_change_hook ();
736 obj_elf_parse_section_letters (str
, len
)
753 attr
|= SHF_EXECINSTR
;
757 char *bad_msg
= _("Unrecognized .section attribute: want a,w,x");
758 #ifdef md_elf_section_letter
759 int md_attr
= md_elf_section_letter (*str
, &bad_msg
);
765 as_warn ("%s", bad_msg
);
778 obj_elf_section_word (str
, len
)
782 if (len
== 5 && strncmp (str
, "write", 5) == 0)
784 if (len
== 5 && strncmp (str
, "alloc", 5) == 0)
786 if (len
== 9 && strncmp (str
, "execinstr", 9) == 0)
787 return SHF_EXECINSTR
;
789 #ifdef md_elf_section_word
791 int md_attr
= md_elf_section_word (str
, len
);
797 as_warn (_("Unrecognized section attribute"));
802 obj_elf_section_type (str
, len
)
806 if (len
== 8 && strncmp (str
, "progbits", 8) == 0)
808 if (len
== 6 && strncmp (str
, "nobits", 6) == 0)
811 #ifdef md_elf_section_type
813 int md_type
= md_elf_section_type (str
, len
);
819 as_warn (_("Unrecognized section type"));
824 obj_elf_section (push
)
827 char *name
, *beg
, *end
;
828 int type
, attr
, dummy
;
835 #ifdef md_flush_pending_output
836 md_flush_pending_output ();
839 previous_section
= now_seg
;
840 previous_subsection
= now_subseg
;
842 s_mri_sect (&mri_type
);
844 #ifdef md_elf_section_change_hook
845 md_elf_section_change_hook ();
850 #endif /* ! defined (TC_I370) */
852 /* Get name of section. */
854 if (*input_line_pointer
== '"')
856 name
= demand_copy_C_string (&dummy
);
859 ignore_rest_of_line ();
865 end
= input_line_pointer
;
866 while (0 == strchr ("\n\t,; ", *end
))
868 if (end
== input_line_pointer
)
870 as_warn (_("Missing section name"));
871 ignore_rest_of_line ();
875 name
= xmalloc (end
- input_line_pointer
+ 1);
876 memcpy (name
, input_line_pointer
, end
- input_line_pointer
);
877 name
[end
- input_line_pointer
] = '\0';
878 input_line_pointer
= end
;
885 if (*input_line_pointer
== ',')
887 /* Skip the comma. */
888 ++input_line_pointer
;
891 if (*input_line_pointer
== '"')
893 beg
= demand_copy_C_string (&dummy
);
896 ignore_rest_of_line ();
899 attr
|= obj_elf_parse_section_letters (beg
, strlen (beg
));
902 if (*input_line_pointer
== ',')
905 ++input_line_pointer
;
907 c
= *input_line_pointer
;
910 beg
= demand_copy_C_string (&dummy
);
913 ignore_rest_of_line ();
916 type
= obj_elf_section_type (beg
, strlen (beg
));
918 else if (c
== '@' || c
== '%')
920 beg
= ++input_line_pointer
;
921 c
= get_symbol_end ();
922 *input_line_pointer
= c
;
923 type
= obj_elf_section_type (beg
, input_line_pointer
- beg
);
934 if (*input_line_pointer
!= '#')
936 as_warn (_("Bad .section directive - character following name is not '#'"));
937 ignore_rest_of_line ();
940 beg
= ++input_line_pointer
;
941 c
= get_symbol_end ();
942 *input_line_pointer
= c
;
944 attr
|= obj_elf_section_word (beg
, input_line_pointer
- beg
);
948 while (*input_line_pointer
++ == ',');
949 --input_line_pointer
;
953 demand_empty_rest_of_line ();
955 obj_elf_change_section (name
, type
, attr
, push
);
958 /* Change to the .data section. */
964 #ifdef md_flush_pending_output
965 md_flush_pending_output ();
968 previous_section
= now_seg
;
969 previous_subsection
= now_subseg
;
972 #ifdef md_elf_section_change_hook
973 md_elf_section_change_hook ();
977 /* Change to the .text section. */
983 #ifdef md_flush_pending_output
984 md_flush_pending_output ();
987 previous_section
= now_seg
;
988 previous_subsection
= now_subseg
;
991 #ifdef md_elf_section_change_hook
992 md_elf_section_change_hook ();
997 obj_elf_subsection (ignore
)
998 int ignore ATTRIBUTE_UNUSED
;
1002 #ifdef md_flush_pending_output
1003 md_flush_pending_output ();
1006 previous_section
= now_seg
;
1007 previous_subsection
= now_subseg
;
1009 temp
= get_absolute_expression ();
1010 subseg_set (now_seg
, (subsegT
) temp
);
1011 demand_empty_rest_of_line ();
1013 #ifdef md_elf_section_change_hook
1014 md_elf_section_change_hook ();
1018 /* This can be called from the processor backends if they change
1022 obj_elf_section_change_hook ()
1024 previous_section
= now_seg
;
1025 previous_subsection
= now_subseg
;
1029 obj_elf_previous (ignore
)
1030 int ignore ATTRIBUTE_UNUSED
;
1035 if (previous_section
== 0)
1037 as_bad (_(".previous without corresponding .section; ignored"));
1041 #ifdef md_flush_pending_output
1042 md_flush_pending_output ();
1045 new_section
= previous_section
;
1046 new_subsection
= previous_subsection
;
1047 previous_section
= now_seg
;
1048 previous_subsection
= now_subseg
;
1049 subseg_set (new_section
, new_subsection
);
1051 #ifdef md_elf_section_change_hook
1052 md_elf_section_change_hook ();
1057 obj_elf_popsection (xxx
)
1058 int xxx ATTRIBUTE_UNUSED
;
1060 struct section_stack
*top
= section_stack
;
1064 as_bad (_(".popsection without corresponding .pushsection; ignored"));
1068 #ifdef md_flush_pending_output
1069 md_flush_pending_output ();
1072 section_stack
= top
->next
;
1073 previous_section
= top
->prev_seg
;
1074 previous_subsection
= top
->prev_subseg
;
1075 subseg_set (top
->seg
, top
->subseg
);
1078 #ifdef md_elf_section_change_hook
1079 md_elf_section_change_hook ();
1084 obj_elf_line (ignore
)
1085 int ignore ATTRIBUTE_UNUSED
;
1087 /* Assume delimiter is part of expression. BSD4.2 as fails with
1088 delightful bug, so we are not being incompatible here. */
1089 new_logical_line ((char *) NULL
, (int) (get_absolute_expression ()));
1090 demand_empty_rest_of_line ();
1093 /* This handles the .symver pseudo-op, which is used to specify a
1094 symbol version. The syntax is ``.symver NAME,SYMVERNAME''.
1095 SYMVERNAME may contain ELF_VER_CHR ('@') characters. This
1096 pseudo-op causes the assembler to emit a symbol named SYMVERNAME
1097 with the same value as the symbol NAME. */
1100 obj_elf_symver (ignore
)
1101 int ignore ATTRIBUTE_UNUSED
;
1107 name
= input_line_pointer
;
1108 c
= get_symbol_end ();
1110 sym
= symbol_find_or_make (name
);
1112 *input_line_pointer
= c
;
1114 if (symbol_get_obj (sym
)->versioned_name
!= NULL
)
1116 as_bad (_("multiple .symver directives for symbol `%s'"),
1118 ignore_rest_of_line ();
1123 if (*input_line_pointer
!= ',')
1125 as_bad (_("expected comma after name in .symver"));
1126 ignore_rest_of_line ();
1130 ++input_line_pointer
;
1131 name
= input_line_pointer
;
1134 c
= get_symbol_end ();
1135 if (c
!= ELF_VER_CHR
)
1137 *input_line_pointer
++ = c
;
1140 symbol_get_obj (sym
)->versioned_name
= xstrdup (name
);
1142 *input_line_pointer
= c
;
1144 if (strchr (symbol_get_obj (sym
)->versioned_name
, ELF_VER_CHR
) == NULL
)
1146 as_bad (_("missing version name in `%s' for symbol `%s'"),
1147 symbol_get_obj (sym
)->versioned_name
, S_GET_NAME (sym
));
1148 ignore_rest_of_line ();
1152 demand_empty_rest_of_line ();
1155 /* This handles the .vtable_inherit pseudo-op, which is used to indicate
1156 to the linker the hierarchy in which a particular table resides. The
1157 syntax is ".vtable_inherit CHILDNAME, PARENTNAME". */
1160 obj_elf_vtable_inherit (ignore
)
1161 int ignore ATTRIBUTE_UNUSED
;
1163 char *cname
, *pname
;
1164 symbolS
*csym
, *psym
;
1167 if (*input_line_pointer
== '#')
1168 ++input_line_pointer
;
1170 cname
= input_line_pointer
;
1171 c
= get_symbol_end ();
1172 csym
= symbol_find (cname
);
1174 /* GCFIXME: should check that we don't have two .vtable_inherits for
1175 the same child symbol. Also, we can currently only do this if the
1176 child symbol is already exists and is placed in a fragment. */
1178 if (csym
== NULL
|| symbol_get_frag (csym
) == NULL
)
1180 as_bad ("expected `%s' to have already been set for .vtable_inherit",
1185 *input_line_pointer
= c
;
1188 if (*input_line_pointer
!= ',')
1190 as_bad ("expected comma after name in .vtable_inherit");
1191 ignore_rest_of_line ();
1195 ++input_line_pointer
;
1198 if (*input_line_pointer
== '#')
1199 ++input_line_pointer
;
1201 if (input_line_pointer
[0] == '0'
1202 && (input_line_pointer
[1] == '\0'
1203 || isspace ((unsigned char) input_line_pointer
[1])))
1205 psym
= section_symbol (absolute_section
);
1206 ++input_line_pointer
;
1210 pname
= input_line_pointer
;
1211 c
= get_symbol_end ();
1212 psym
= symbol_find_or_make (pname
);
1213 *input_line_pointer
= c
;
1216 demand_empty_rest_of_line ();
1221 assert (symbol_get_value_expression (csym
)->X_op
== O_constant
);
1222 fix_new (symbol_get_frag (csym
),
1223 symbol_get_value_expression (csym
)->X_add_number
, 0, psym
, 0, 0,
1224 BFD_RELOC_VTABLE_INHERIT
);
1227 /* This handles the .vtable_entry pseudo-op, which is used to indicate
1228 to the linker that a vtable slot was used. The syntax is
1229 ".vtable_entry tablename, offset". */
1232 obj_elf_vtable_entry (ignore
)
1233 int ignore ATTRIBUTE_UNUSED
;
1240 if (*input_line_pointer
== '#')
1241 ++input_line_pointer
;
1243 name
= input_line_pointer
;
1244 c
= get_symbol_end ();
1245 sym
= symbol_find_or_make (name
);
1246 *input_line_pointer
= c
;
1249 if (*input_line_pointer
!= ',')
1251 as_bad ("expected comma after name in .vtable_entry");
1252 ignore_rest_of_line ();
1256 ++input_line_pointer
;
1257 if (*input_line_pointer
== '#')
1258 ++input_line_pointer
;
1260 offset
= get_absolute_expression ();
1262 fix_new (frag_now
, frag_now_fix (), 0, sym
, offset
, 0,
1263 BFD_RELOC_VTABLE_ENTRY
);
1265 demand_empty_rest_of_line ();
1269 elf_obj_read_begin_hook ()
1271 #ifdef NEED_ECOFF_DEBUG
1272 if (ECOFF_DEBUGGING
)
1273 ecoff_read_begin_hook ();
1278 elf_obj_symbol_new_hook (symbolP
)
1281 struct elf_obj_sy
*sy_obj
;
1283 sy_obj
= symbol_get_obj (symbolP
);
1284 sy_obj
->size
= NULL
;
1285 sy_obj
->versioned_name
= NULL
;
1287 #ifdef NEED_ECOFF_DEBUG
1288 if (ECOFF_DEBUGGING
)
1289 ecoff_symbol_new_hook (symbolP
);
1294 obj_elf_version (ignore
)
1295 int ignore ATTRIBUTE_UNUSED
;
1301 asection
*seg
= now_seg
;
1302 subsegT subseg
= now_subseg
;
1303 Elf_Internal_Note i_note
;
1304 Elf_External_Note e_note
;
1305 asection
*note_secp
= (asection
*) NULL
;
1309 if (*input_line_pointer
== '\"')
1311 ++input_line_pointer
; /* -> 1st char of string. */
1312 name
= input_line_pointer
;
1314 while (is_a_char (c
= next_char_of_string ()))
1316 c
= *input_line_pointer
;
1317 *input_line_pointer
= '\0';
1318 *(input_line_pointer
- 1) = '\0';
1319 *input_line_pointer
= c
;
1321 /* create the .note section */
1323 note_secp
= subseg_new (".note", 0);
1324 bfd_set_section_flags (stdoutput
,
1326 SEC_HAS_CONTENTS
| SEC_READONLY
);
1328 /* process the version string */
1330 len
= strlen (name
);
1332 i_note
.namesz
= ((len
+ 1) + 3) & ~3; /* round this to word boundary */
1333 i_note
.descsz
= 0; /* no description */
1334 i_note
.type
= NT_VERSION
;
1335 p
= frag_more (sizeof (e_note
.namesz
));
1336 md_number_to_chars (p
, (valueT
) i_note
.namesz
, 4);
1337 p
= frag_more (sizeof (e_note
.descsz
));
1338 md_number_to_chars (p
, (valueT
) i_note
.descsz
, 4);
1339 p
= frag_more (sizeof (e_note
.type
));
1340 md_number_to_chars (p
, (valueT
) i_note
.type
, 4);
1342 for (i
= 0; i
< len
; i
++)
1346 FRAG_APPEND_1_CHAR (ch
);
1349 frag_align (2, 0, 0);
1351 subseg_set (seg
, subseg
);
1355 as_bad (_("Expected quoted string"));
1357 demand_empty_rest_of_line ();
1361 obj_elf_size (ignore
)
1362 int ignore ATTRIBUTE_UNUSED
;
1364 char *name
= input_line_pointer
;
1365 char c
= get_symbol_end ();
1370 p
= input_line_pointer
;
1373 if (*input_line_pointer
!= ',')
1376 as_bad (_("expected comma after name `%s' in .size directive"), name
);
1378 ignore_rest_of_line ();
1381 input_line_pointer
++;
1383 if (exp
.X_op
== O_absent
)
1385 as_bad (_("missing expression in .size directive"));
1386 exp
.X_op
= O_constant
;
1387 exp
.X_add_number
= 0;
1390 sym
= symbol_find_or_make (name
);
1392 if (exp
.X_op
== O_constant
)
1393 S_SET_SIZE (sym
, exp
.X_add_number
);
1396 symbol_get_obj (sym
)->size
=
1397 (expressionS
*) xmalloc (sizeof (expressionS
));
1398 *symbol_get_obj (sym
)->size
= exp
;
1400 demand_empty_rest_of_line ();
1403 /* Handle the ELF .type pseudo-op. This sets the type of a symbol.
1404 There are four syntaxes:
1406 The first (used on Solaris) is
1408 The second (used on UnixWare) is
1410 The third (reportedly to be used on Irix 6.0) is
1412 The fourth (used on NetBSD/Arm and Linux/ARM) is
1417 obj_elf_type (ignore
)
1418 int ignore ATTRIBUTE_UNUSED
;
1423 const char *typename
;
1426 name
= input_line_pointer
;
1427 c
= get_symbol_end ();
1428 sym
= symbol_find_or_make (name
);
1429 *input_line_pointer
= c
;
1432 if (*input_line_pointer
== ',')
1433 ++input_line_pointer
;
1436 if ( *input_line_pointer
== '#'
1437 || *input_line_pointer
== '@'
1438 || *input_line_pointer
== '%')
1439 ++input_line_pointer
;
1441 typename
= input_line_pointer
;
1442 c
= get_symbol_end ();
1445 if (strcmp (typename
, "function") == 0
1446 || strcmp (typename
, "STT_FUNC") == 0)
1447 type
= BSF_FUNCTION
;
1448 else if (strcmp (typename
, "object") == 0
1449 || strcmp (typename
, "STT_OBJECT") == 0)
1452 as_bad (_("ignoring unrecognized symbol type \"%s\""), typename
);
1454 *input_line_pointer
= c
;
1456 symbol_get_bfdsym (sym
)->flags
|= type
;
1458 demand_empty_rest_of_line ();
1462 obj_elf_ident (ignore
)
1463 int ignore ATTRIBUTE_UNUSED
;
1465 static segT comment_section
;
1466 segT old_section
= now_seg
;
1467 int old_subsection
= now_subseg
;
1469 #ifdef md_flush_pending_output
1470 md_flush_pending_output ();
1473 if (!comment_section
)
1476 comment_section
= subseg_new (".comment", 0);
1477 bfd_set_section_flags (stdoutput
, comment_section
,
1478 SEC_READONLY
| SEC_HAS_CONTENTS
);
1483 subseg_set (comment_section
, 0);
1485 subseg_set (old_section
, old_subsection
);
1488 #ifdef INIT_STAB_SECTION
1490 /* The first entry in a .stabs section is special. */
1493 obj_elf_init_stab_section (seg
)
1499 unsigned int stroff
;
1501 /* Force the section to align to a longword boundary. Without this,
1502 UnixWare ar crashes. */
1503 bfd_set_section_alignment (stdoutput
, seg
, 2);
1505 /* Make space for this first symbol. */
1509 as_where (&file
, (unsigned int *) NULL
);
1510 stabstr_name
= (char *) alloca (strlen (segment_name (seg
)) + 4);
1511 strcpy (stabstr_name
, segment_name (seg
));
1512 strcat (stabstr_name
, "str");
1513 stroff
= get_stab_string_offset (file
, stabstr_name
);
1515 md_number_to_chars (p
, stroff
, 4);
1516 seg_info (seg
)->stabu
.p
= p
;
1521 /* Fill in the counts in the first entry in a .stabs section. */
1524 adjust_stab_sections (abfd
, sec
, xxx
)
1527 PTR xxx ATTRIBUTE_UNUSED
;
1534 if (strncmp (".stab", sec
->name
, 5))
1536 if (!strcmp ("str", sec
->name
+ strlen (sec
->name
) - 3))
1539 name
= (char *) alloca (strlen (sec
->name
) + 4);
1540 strcpy (name
, sec
->name
);
1541 strcat (name
, "str");
1542 strsec
= bfd_get_section_by_name (abfd
, name
);
1544 strsz
= bfd_section_size (abfd
, strsec
);
1547 nsyms
= bfd_section_size (abfd
, sec
) / 12 - 1;
1549 p
= seg_info (sec
)->stabu
.p
;
1552 bfd_h_put_16 (abfd
, (bfd_vma
) nsyms
, (bfd_byte
*) p
+ 6);
1553 bfd_h_put_32 (abfd
, (bfd_vma
) strsz
, (bfd_byte
*) p
+ 8);
1556 #ifdef NEED_ECOFF_DEBUG
1558 /* This function is called by the ECOFF code. It is supposed to
1559 record the external symbol information so that the backend can
1560 write it out correctly. The ELF backend doesn't actually handle
1561 this at the moment, so we do it ourselves. We save the information
1565 elf_ecoff_set_ext (sym
, ext
)
1567 struct ecoff_extr
*ext
;
1569 symbol_get_bfdsym (sym
)->udata
.p
= (PTR
) ext
;
1572 /* This function is called by bfd_ecoff_debug_externals. It is
1573 supposed to *EXT to the external symbol information, and return
1574 whether the symbol should be used at all. */
1577 elf_get_extr (sym
, ext
)
1581 if (sym
->udata
.p
== NULL
)
1583 *ext
= *(EXTR
*) sym
->udata
.p
;
1587 /* This function is called by bfd_ecoff_debug_externals. It has
1588 nothing to do for ELF. */
1592 elf_set_index (sym
, indx
)
1593 asymbol
*sym ATTRIBUTE_UNUSED
;
1594 bfd_size_type indx ATTRIBUTE_UNUSED
;
1598 #endif /* NEED_ECOFF_DEBUG */
1601 elf_frob_symbol (symp
, puntp
)
1605 struct elf_obj_sy
*sy_obj
;
1607 #ifdef NEED_ECOFF_DEBUG
1608 if (ECOFF_DEBUGGING
)
1609 ecoff_frob_symbol (symp
);
1612 sy_obj
= symbol_get_obj (symp
);
1614 if (sy_obj
->size
!= NULL
)
1616 switch (sy_obj
->size
->X_op
)
1620 (S_GET_VALUE (sy_obj
->size
->X_add_symbol
)
1621 + sy_obj
->size
->X_add_number
1622 - S_GET_VALUE (sy_obj
->size
->X_op_symbol
)));
1626 (S_GET_VALUE (sy_obj
->size
->X_add_symbol
)
1627 + sy_obj
->size
->X_add_number
));
1630 as_bad (_(".size expression too complicated to fix up"));
1633 free (sy_obj
->size
);
1634 sy_obj
->size
= NULL
;
1637 if (sy_obj
->versioned_name
!= NULL
)
1639 /* This symbol was given a new name with the .symver directive.
1641 If this is an external reference, just rename the symbol to
1642 include the version string. This will make the relocs be
1643 against the correct versioned symbol.
1645 If this is a definition, add an alias. FIXME: Using an alias
1646 will permit the debugging information to refer to the right
1647 symbol. However, it's not clear whether it is the best
1650 if (! S_IS_DEFINED (symp
))
1654 /* Verify that the name isn't using the @@ syntax--this is
1655 reserved for definitions of the default version to link
1657 p
= strchr (sy_obj
->versioned_name
, ELF_VER_CHR
);
1659 if (p
[1] == ELF_VER_CHR
)
1661 as_bad (_("invalid attempt to declare external version name as default in symbol `%s'"),
1662 sy_obj
->versioned_name
);
1665 S_SET_NAME (symp
, sy_obj
->versioned_name
);
1671 /* FIXME: Creating a new symbol here is risky. We're in the
1672 final loop over the symbol table. We can get away with
1673 it only because the symbol goes to the end of the list,
1674 where the loop will still see it. It would probably be
1675 better to do this in obj_frob_file_before_adjust. */
1677 symp2
= symbol_find_or_make (sy_obj
->versioned_name
);
1679 /* Now we act as though we saw symp2 = sym. */
1681 S_SET_SEGMENT (symp2
, S_GET_SEGMENT (symp
));
1683 /* Subtracting out the frag address here is a hack because
1684 we are in the middle of the final loop. */
1687 - symbol_get_frag (symp
)->fr_address
));
1689 symbol_set_frag (symp2
, symbol_get_frag (symp
));
1691 /* This will copy over the size information. */
1692 copy_symbol_attributes (symp2
, symp
);
1694 if (S_IS_WEAK (symp
))
1697 if (S_IS_EXTERNAL (symp
))
1698 S_SET_EXTERNAL (symp2
);
1702 /* Double check weak symbols. */
1703 if (S_IS_WEAK (symp
))
1705 if (S_IS_COMMON (symp
))
1706 as_bad (_("Symbol `%s' can not be both weak and common"),
1711 /* The Irix 5 and 6 assemblers set the type of any common symbol and
1712 any undefined non-function symbol to STT_OBJECT. We try to be
1713 compatible, since newer Irix 5 and 6 linkers care. However, we
1714 only set undefined symbols to be STT_OBJECT if we are on Irix,
1715 because that is the only time gcc will generate the necessary
1716 .global directives to mark functions. */
1718 if (S_IS_COMMON (symp
))
1719 symbol_get_bfdsym (symp
)->flags
|= BSF_OBJECT
;
1721 if (strstr (TARGET_OS
, "irix") != NULL
1722 && ! S_IS_DEFINED (symp
)
1723 && (symbol_get_bfdsym (symp
)->flags
& BSF_FUNCTION
) == 0)
1724 symbol_get_bfdsym (symp
)->flags
|= BSF_OBJECT
;
1728 /* If TC_PPC is defined, we used to force the type of a symbol to be
1729 BSF_OBJECT if it was otherwise unset. This was required by some
1730 version of VxWorks. Thomas de Lellis <tdel@windriver.com> says
1731 that this is no longer needed, so it is now commented out. */
1732 if ((symbol_get_bfdsym (symp
)->flags
1733 & (BSF_FUNCTION
| BSF_FILE
| BSF_SECTION_SYM
)) == 0
1734 && S_IS_DEFINED (symp
))
1735 symbol_get_bfdsym (symp
)->flags
|= BSF_OBJECT
;
1742 bfd_map_over_sections (stdoutput
, adjust_stab_sections
, (PTR
) 0);
1744 #ifdef elf_tc_final_processing
1745 elf_tc_final_processing ();
1749 /* It is required that we let write_relocs have the opportunity to
1750 optimize away fixups before output has begun, since it is possible
1751 to eliminate all fixups for a section and thus we never should
1752 have generated the relocation section. */
1755 elf_frob_file_after_relocs ()
1757 #ifdef NEED_ECOFF_DEBUG
1758 if (ECOFF_DEBUGGING
)
1759 /* Generate the ECOFF debugging information. */
1761 const struct ecoff_debug_swap
*debug_swap
;
1762 struct ecoff_debug_info debug
;
1767 = get_elf_backend_data (stdoutput
)->elf_backend_ecoff_debug_swap
;
1768 know (debug_swap
!= (const struct ecoff_debug_swap
*) NULL
);
1769 ecoff_build_debug (&debug
.symbolic_header
, &buf
, debug_swap
);
1771 /* Set up the pointers in debug. */
1772 #define SET(ptr, offset, type) \
1773 debug.ptr = (type) (buf + debug.symbolic_header.offset)
1775 SET (line
, cbLineOffset
, unsigned char *);
1776 SET (external_dnr
, cbDnOffset
, PTR
);
1777 SET (external_pdr
, cbPdOffset
, PTR
);
1778 SET (external_sym
, cbSymOffset
, PTR
);
1779 SET (external_opt
, cbOptOffset
, PTR
);
1780 SET (external_aux
, cbAuxOffset
, union aux_ext
*);
1781 SET (ss
, cbSsOffset
, char *);
1782 SET (external_fdr
, cbFdOffset
, PTR
);
1783 SET (external_rfd
, cbRfdOffset
, PTR
);
1784 /* ssext and external_ext are set up just below. */
1788 /* Set up the external symbols. */
1789 debug
.ssext
= debug
.ssext_end
= NULL
;
1790 debug
.external_ext
= debug
.external_ext_end
= NULL
;
1791 if (! bfd_ecoff_debug_externals (stdoutput
, &debug
, debug_swap
, true,
1792 elf_get_extr
, elf_set_index
))
1793 as_fatal (_("Failed to set up debugging information: %s"),
1794 bfd_errmsg (bfd_get_error ()));
1796 sec
= bfd_get_section_by_name (stdoutput
, ".mdebug");
1797 assert (sec
!= NULL
);
1799 know (stdoutput
->output_has_begun
== false);
1801 /* We set the size of the section, call bfd_set_section_contents
1802 to force the ELF backend to allocate a file position, and then
1803 write out the data. FIXME: Is this really the best way to do
1805 sec
->_raw_size
= bfd_ecoff_debug_size (stdoutput
, &debug
, debug_swap
);
1807 /* Pass BUF to bfd_set_section_contents because this will
1808 eventually become a call to fwrite, and ISO C prohibits
1809 passing a NULL pointer to a stdio function even if the
1810 pointer will not be used. */
1811 if (! bfd_set_section_contents (stdoutput
, sec
, (PTR
) buf
,
1812 (file_ptr
) 0, (bfd_size_type
) 0))
1813 as_fatal (_("Can't start writing .mdebug section: %s"),
1814 bfd_errmsg (bfd_get_error ()));
1816 know (stdoutput
->output_has_begun
== true);
1817 know (sec
->filepos
!= 0);
1819 if (! bfd_ecoff_write_debug (stdoutput
, &debug
, debug_swap
,
1821 as_fatal (_("Could not write .mdebug section: %s"),
1822 bfd_errmsg (bfd_get_error ()));
1824 #endif /* NEED_ECOFF_DEBUG */
1829 /* Heavily plagarized from obj_elf_version. The idea is to emit the
1830 SCO specific identifier in the .notes section to satisfy the SCO
1833 This looks more complicated than it really is. As opposed to the
1834 "obvious" solution, this should handle the cross dev cases
1835 correctly. (i.e, hosting on a 64 bit big endian processor, but
1836 generating SCO Elf code) Efficiency isn't a concern, as there
1837 should be exactly one of these sections per object module.
1839 SCO OpenServer 5 identifies it's ELF modules with a standard ELF
1842 int_32 namesz = 4 ; Name size
1843 int_32 descsz = 12 ; Descriptive information
1845 char name[4] = "SCO" ; Originator name ALWAYS SCO + NULL
1846 int_32 version = (major ver # << 16) | version of tools ;
1847 int_32 source = (tool_id << 16 ) | 1 ;
1848 int_32 info = 0 ; These are set by the SCO tools, but we
1849 don't know enough about the source
1850 environment to set them. SCO ld currently
1851 ignores them, and recommends we set them
1854 #define SCO_MAJOR_VERSION 0x1
1855 #define SCO_MINOR_VERSION 0x1
1865 asection
*seg
= now_seg
;
1866 subsegT subseg
= now_subseg
;
1867 Elf_Internal_Note i_note
;
1868 Elf_External_Note e_note
;
1869 asection
*note_secp
= (asection
*) NULL
;
1872 /* create the .note section */
1874 note_secp
= subseg_new (".note", 0);
1875 bfd_set_section_flags (stdoutput
,
1877 SEC_HAS_CONTENTS
| SEC_READONLY
);
1879 /* process the version string */
1882 i_note
.descsz
= 12; /* 12 descriptive bytes */
1883 i_note
.type
= NT_VERSION
; /* Contains a version string */
1885 p
= frag_more (sizeof (i_note
.namesz
));
1886 md_number_to_chars (p
, (valueT
) i_note
.namesz
, 4);
1888 p
= frag_more (sizeof (i_note
.descsz
));
1889 md_number_to_chars (p
, (valueT
) i_note
.descsz
, 4);
1891 p
= frag_more (sizeof (i_note
.type
));
1892 md_number_to_chars (p
, (valueT
) i_note
.type
, 4);
1897 /* Note: this is the version number of the ELF we're representing */
1899 md_number_to_chars (p
, (SCO_MAJOR_VERSION
<< 16) | (SCO_MINOR_VERSION
), 4);
1901 /* Here, we pick a magic number for ourselves (yes, I "registered"
1902 it with SCO. The bottom bit shows that we are compat with the
1905 md_number_to_chars (p
, 0x4c520000 | 0x0001, 4);
1907 /* If we knew (or cared) what the source language options were, we'd
1908 fill them in here. SCO has given us permission to ignore these
1909 and just set them to zero. */
1911 md_number_to_chars (p
, 0x0000, 4);
1913 frag_align (2, 0, 0);
1915 /* We probably can't restore the current segment, for there likely
1918 subseg_set (seg
, subseg
);
1922 #endif /* SCO_ELF */
1925 elf_separate_stab_sections ()
1927 #ifdef NEED_ECOFF_DEBUG
1928 return (!ECOFF_DEBUGGING
);
1935 elf_init_stab_section (seg
)
1938 #ifdef NEED_ECOFF_DEBUG
1939 if (!ECOFF_DEBUGGING
)
1941 obj_elf_init_stab_section (seg
);
1944 const struct format_ops elf_format_ops
=
1946 bfd_target_elf_flavour
,
1947 0, /* dfl_leading_underscore */
1948 1, /* emit_section_symbols */
1953 elf_frob_file_after_relocs
,
1954 elf_s_get_size
, elf_s_set_size
,
1955 elf_s_get_align
, elf_s_set_align
,
1962 elf_copy_symbol_attributes
,
1963 #ifdef NEED_ECOFF_DEBUG
1964 ecoff_generate_asm_lineno
,
1967 0, /* generate_asm_lineno */
1968 0, /* process_stab */
1970 elf_separate_stab_sections
,
1971 elf_init_stab_section
,
1972 elf_sec_sym_ok_for_reloc
,
1974 #ifdef NEED_ECOFF_DEBUG
1977 0, /* ecoff_set_ext */
1979 elf_obj_read_begin_hook
,
1980 elf_obj_symbol_new_hook