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 five 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
1414 The fifth (used on SVR4/860) is
1415 .type SYM,"function"
1419 obj_elf_type (ignore
)
1420 int ignore ATTRIBUTE_UNUSED
;
1425 const char *typename
;
1428 name
= input_line_pointer
;
1429 c
= get_symbol_end ();
1430 sym
= symbol_find_or_make (name
);
1431 *input_line_pointer
= c
;
1434 if (*input_line_pointer
== ',')
1435 ++input_line_pointer
;
1438 if ( *input_line_pointer
== '#'
1439 || *input_line_pointer
== '@'
1440 || *input_line_pointer
== '"'
1441 || *input_line_pointer
== '%')
1442 ++input_line_pointer
;
1444 typename
= input_line_pointer
;
1445 c
= get_symbol_end ();
1448 if (strcmp (typename
, "function") == 0
1449 || strcmp (typename
, "STT_FUNC") == 0)
1450 type
= BSF_FUNCTION
;
1451 else if (strcmp (typename
, "object") == 0
1452 || strcmp (typename
, "STT_OBJECT") == 0)
1455 as_bad (_("ignoring unrecognized symbol type \"%s\""), typename
);
1457 *input_line_pointer
= c
;
1459 if (*input_line_pointer
== '"')
1460 ++input_line_pointer
;
1462 symbol_get_bfdsym (sym
)->flags
|= type
;
1464 demand_empty_rest_of_line ();
1468 obj_elf_ident (ignore
)
1469 int ignore ATTRIBUTE_UNUSED
;
1471 static segT comment_section
;
1472 segT old_section
= now_seg
;
1473 int old_subsection
= now_subseg
;
1475 #ifdef md_flush_pending_output
1476 md_flush_pending_output ();
1479 if (!comment_section
)
1482 comment_section
= subseg_new (".comment", 0);
1483 bfd_set_section_flags (stdoutput
, comment_section
,
1484 SEC_READONLY
| SEC_HAS_CONTENTS
);
1489 subseg_set (comment_section
, 0);
1491 subseg_set (old_section
, old_subsection
);
1494 #ifdef INIT_STAB_SECTION
1496 /* The first entry in a .stabs section is special. */
1499 obj_elf_init_stab_section (seg
)
1505 unsigned int stroff
;
1507 /* Force the section to align to a longword boundary. Without this,
1508 UnixWare ar crashes. */
1509 bfd_set_section_alignment (stdoutput
, seg
, 2);
1511 /* Make space for this first symbol. */
1515 as_where (&file
, (unsigned int *) NULL
);
1516 stabstr_name
= (char *) alloca (strlen (segment_name (seg
)) + 4);
1517 strcpy (stabstr_name
, segment_name (seg
));
1518 strcat (stabstr_name
, "str");
1519 stroff
= get_stab_string_offset (file
, stabstr_name
);
1521 md_number_to_chars (p
, stroff
, 4);
1522 seg_info (seg
)->stabu
.p
= p
;
1527 /* Fill in the counts in the first entry in a .stabs section. */
1530 adjust_stab_sections (abfd
, sec
, xxx
)
1533 PTR xxx ATTRIBUTE_UNUSED
;
1540 if (strncmp (".stab", sec
->name
, 5))
1542 if (!strcmp ("str", sec
->name
+ strlen (sec
->name
) - 3))
1545 name
= (char *) alloca (strlen (sec
->name
) + 4);
1546 strcpy (name
, sec
->name
);
1547 strcat (name
, "str");
1548 strsec
= bfd_get_section_by_name (abfd
, name
);
1550 strsz
= bfd_section_size (abfd
, strsec
);
1553 nsyms
= bfd_section_size (abfd
, sec
) / 12 - 1;
1555 p
= seg_info (sec
)->stabu
.p
;
1558 bfd_h_put_16 (abfd
, (bfd_vma
) nsyms
, (bfd_byte
*) p
+ 6);
1559 bfd_h_put_32 (abfd
, (bfd_vma
) strsz
, (bfd_byte
*) p
+ 8);
1562 #ifdef NEED_ECOFF_DEBUG
1564 /* This function is called by the ECOFF code. It is supposed to
1565 record the external symbol information so that the backend can
1566 write it out correctly. The ELF backend doesn't actually handle
1567 this at the moment, so we do it ourselves. We save the information
1571 elf_ecoff_set_ext (sym
, ext
)
1573 struct ecoff_extr
*ext
;
1575 symbol_get_bfdsym (sym
)->udata
.p
= (PTR
) ext
;
1578 /* This function is called by bfd_ecoff_debug_externals. It is
1579 supposed to *EXT to the external symbol information, and return
1580 whether the symbol should be used at all. */
1583 elf_get_extr (sym
, ext
)
1587 if (sym
->udata
.p
== NULL
)
1589 *ext
= *(EXTR
*) sym
->udata
.p
;
1593 /* This function is called by bfd_ecoff_debug_externals. It has
1594 nothing to do for ELF. */
1598 elf_set_index (sym
, indx
)
1599 asymbol
*sym ATTRIBUTE_UNUSED
;
1600 bfd_size_type indx ATTRIBUTE_UNUSED
;
1604 #endif /* NEED_ECOFF_DEBUG */
1607 elf_frob_symbol (symp
, puntp
)
1611 struct elf_obj_sy
*sy_obj
;
1613 #ifdef NEED_ECOFF_DEBUG
1614 if (ECOFF_DEBUGGING
)
1615 ecoff_frob_symbol (symp
);
1618 sy_obj
= symbol_get_obj (symp
);
1620 if (sy_obj
->size
!= NULL
)
1622 switch (sy_obj
->size
->X_op
)
1626 (S_GET_VALUE (sy_obj
->size
->X_add_symbol
)
1627 + sy_obj
->size
->X_add_number
1628 - S_GET_VALUE (sy_obj
->size
->X_op_symbol
)));
1632 (S_GET_VALUE (sy_obj
->size
->X_add_symbol
)
1633 + sy_obj
->size
->X_add_number
));
1636 as_bad (_(".size expression too complicated to fix up"));
1639 free (sy_obj
->size
);
1640 sy_obj
->size
= NULL
;
1643 if (sy_obj
->versioned_name
!= NULL
)
1645 /* This symbol was given a new name with the .symver directive.
1647 If this is an external reference, just rename the symbol to
1648 include the version string. This will make the relocs be
1649 against the correct versioned symbol.
1651 If this is a definition, add an alias. FIXME: Using an alias
1652 will permit the debugging information to refer to the right
1653 symbol. However, it's not clear whether it is the best
1656 if (! S_IS_DEFINED (symp
))
1660 /* Verify that the name isn't using the @@ syntax--this is
1661 reserved for definitions of the default version to link
1663 p
= strchr (sy_obj
->versioned_name
, ELF_VER_CHR
);
1665 if (p
[1] == ELF_VER_CHR
)
1667 as_bad (_("invalid attempt to declare external version name as default in symbol `%s'"),
1668 sy_obj
->versioned_name
);
1671 S_SET_NAME (symp
, sy_obj
->versioned_name
);
1677 /* FIXME: Creating a new symbol here is risky. We're in the
1678 final loop over the symbol table. We can get away with
1679 it only because the symbol goes to the end of the list,
1680 where the loop will still see it. It would probably be
1681 better to do this in obj_frob_file_before_adjust. */
1683 symp2
= symbol_find_or_make (sy_obj
->versioned_name
);
1685 /* Now we act as though we saw symp2 = sym. */
1687 S_SET_SEGMENT (symp2
, S_GET_SEGMENT (symp
));
1689 /* Subtracting out the frag address here is a hack because
1690 we are in the middle of the final loop. */
1693 - symbol_get_frag (symp
)->fr_address
));
1695 symbol_set_frag (symp2
, symbol_get_frag (symp
));
1697 /* This will copy over the size information. */
1698 copy_symbol_attributes (symp2
, symp
);
1700 if (S_IS_WEAK (symp
))
1703 if (S_IS_EXTERNAL (symp
))
1704 S_SET_EXTERNAL (symp2
);
1708 /* Double check weak symbols. */
1709 if (S_IS_WEAK (symp
))
1711 if (S_IS_COMMON (symp
))
1712 as_bad (_("Symbol `%s' can not be both weak and common"),
1717 /* The Irix 5 and 6 assemblers set the type of any common symbol and
1718 any undefined non-function symbol to STT_OBJECT. We try to be
1719 compatible, since newer Irix 5 and 6 linkers care. However, we
1720 only set undefined symbols to be STT_OBJECT if we are on Irix,
1721 because that is the only time gcc will generate the necessary
1722 .global directives to mark functions. */
1724 if (S_IS_COMMON (symp
))
1725 symbol_get_bfdsym (symp
)->flags
|= BSF_OBJECT
;
1727 if (strstr (TARGET_OS
, "irix") != NULL
1728 && ! S_IS_DEFINED (symp
)
1729 && (symbol_get_bfdsym (symp
)->flags
& BSF_FUNCTION
) == 0)
1730 symbol_get_bfdsym (symp
)->flags
|= BSF_OBJECT
;
1734 /* If TC_PPC is defined, we used to force the type of a symbol to be
1735 BSF_OBJECT if it was otherwise unset. This was required by some
1736 version of VxWorks. Thomas de Lellis <tdel@windriver.com> says
1737 that this is no longer needed, so it is now commented out. */
1738 if ((symbol_get_bfdsym (symp
)->flags
1739 & (BSF_FUNCTION
| BSF_FILE
| BSF_SECTION_SYM
)) == 0
1740 && S_IS_DEFINED (symp
))
1741 symbol_get_bfdsym (symp
)->flags
|= BSF_OBJECT
;
1748 bfd_map_over_sections (stdoutput
, adjust_stab_sections
, (PTR
) 0);
1750 #ifdef elf_tc_final_processing
1751 elf_tc_final_processing ();
1755 /* It is required that we let write_relocs have the opportunity to
1756 optimize away fixups before output has begun, since it is possible
1757 to eliminate all fixups for a section and thus we never should
1758 have generated the relocation section. */
1761 elf_frob_file_after_relocs ()
1763 #ifdef NEED_ECOFF_DEBUG
1764 if (ECOFF_DEBUGGING
)
1765 /* Generate the ECOFF debugging information. */
1767 const struct ecoff_debug_swap
*debug_swap
;
1768 struct ecoff_debug_info debug
;
1773 = get_elf_backend_data (stdoutput
)->elf_backend_ecoff_debug_swap
;
1774 know (debug_swap
!= (const struct ecoff_debug_swap
*) NULL
);
1775 ecoff_build_debug (&debug
.symbolic_header
, &buf
, debug_swap
);
1777 /* Set up the pointers in debug. */
1778 #define SET(ptr, offset, type) \
1779 debug.ptr = (type) (buf + debug.symbolic_header.offset)
1781 SET (line
, cbLineOffset
, unsigned char *);
1782 SET (external_dnr
, cbDnOffset
, PTR
);
1783 SET (external_pdr
, cbPdOffset
, PTR
);
1784 SET (external_sym
, cbSymOffset
, PTR
);
1785 SET (external_opt
, cbOptOffset
, PTR
);
1786 SET (external_aux
, cbAuxOffset
, union aux_ext
*);
1787 SET (ss
, cbSsOffset
, char *);
1788 SET (external_fdr
, cbFdOffset
, PTR
);
1789 SET (external_rfd
, cbRfdOffset
, PTR
);
1790 /* ssext and external_ext are set up just below. */
1794 /* Set up the external symbols. */
1795 debug
.ssext
= debug
.ssext_end
= NULL
;
1796 debug
.external_ext
= debug
.external_ext_end
= NULL
;
1797 if (! bfd_ecoff_debug_externals (stdoutput
, &debug
, debug_swap
, true,
1798 elf_get_extr
, elf_set_index
))
1799 as_fatal (_("Failed to set up debugging information: %s"),
1800 bfd_errmsg (bfd_get_error ()));
1802 sec
= bfd_get_section_by_name (stdoutput
, ".mdebug");
1803 assert (sec
!= NULL
);
1805 know (stdoutput
->output_has_begun
== false);
1807 /* We set the size of the section, call bfd_set_section_contents
1808 to force the ELF backend to allocate a file position, and then
1809 write out the data. FIXME: Is this really the best way to do
1811 sec
->_raw_size
= bfd_ecoff_debug_size (stdoutput
, &debug
, debug_swap
);
1813 /* Pass BUF to bfd_set_section_contents because this will
1814 eventually become a call to fwrite, and ISO C prohibits
1815 passing a NULL pointer to a stdio function even if the
1816 pointer will not be used. */
1817 if (! bfd_set_section_contents (stdoutput
, sec
, (PTR
) buf
,
1818 (file_ptr
) 0, (bfd_size_type
) 0))
1819 as_fatal (_("Can't start writing .mdebug section: %s"),
1820 bfd_errmsg (bfd_get_error ()));
1822 know (stdoutput
->output_has_begun
== true);
1823 know (sec
->filepos
!= 0);
1825 if (! bfd_ecoff_write_debug (stdoutput
, &debug
, debug_swap
,
1827 as_fatal (_("Could not write .mdebug section: %s"),
1828 bfd_errmsg (bfd_get_error ()));
1830 #endif /* NEED_ECOFF_DEBUG */
1835 /* Heavily plagarized from obj_elf_version. The idea is to emit the
1836 SCO specific identifier in the .notes section to satisfy the SCO
1839 This looks more complicated than it really is. As opposed to the
1840 "obvious" solution, this should handle the cross dev cases
1841 correctly. (i.e, hosting on a 64 bit big endian processor, but
1842 generating SCO Elf code) Efficiency isn't a concern, as there
1843 should be exactly one of these sections per object module.
1845 SCO OpenServer 5 identifies it's ELF modules with a standard ELF
1848 int_32 namesz = 4 ; Name size
1849 int_32 descsz = 12 ; Descriptive information
1851 char name[4] = "SCO" ; Originator name ALWAYS SCO + NULL
1852 int_32 version = (major ver # << 16) | version of tools ;
1853 int_32 source = (tool_id << 16 ) | 1 ;
1854 int_32 info = 0 ; These are set by the SCO tools, but we
1855 don't know enough about the source
1856 environment to set them. SCO ld currently
1857 ignores them, and recommends we set them
1860 #define SCO_MAJOR_VERSION 0x1
1861 #define SCO_MINOR_VERSION 0x1
1871 asection
*seg
= now_seg
;
1872 subsegT subseg
= now_subseg
;
1873 Elf_Internal_Note i_note
;
1874 Elf_External_Note e_note
;
1875 asection
*note_secp
= (asection
*) NULL
;
1878 /* create the .note section */
1880 note_secp
= subseg_new (".note", 0);
1881 bfd_set_section_flags (stdoutput
,
1883 SEC_HAS_CONTENTS
| SEC_READONLY
);
1885 /* process the version string */
1888 i_note
.descsz
= 12; /* 12 descriptive bytes */
1889 i_note
.type
= NT_VERSION
; /* Contains a version string */
1891 p
= frag_more (sizeof (i_note
.namesz
));
1892 md_number_to_chars (p
, (valueT
) i_note
.namesz
, 4);
1894 p
= frag_more (sizeof (i_note
.descsz
));
1895 md_number_to_chars (p
, (valueT
) i_note
.descsz
, 4);
1897 p
= frag_more (sizeof (i_note
.type
));
1898 md_number_to_chars (p
, (valueT
) i_note
.type
, 4);
1903 /* Note: this is the version number of the ELF we're representing */
1905 md_number_to_chars (p
, (SCO_MAJOR_VERSION
<< 16) | (SCO_MINOR_VERSION
), 4);
1907 /* Here, we pick a magic number for ourselves (yes, I "registered"
1908 it with SCO. The bottom bit shows that we are compat with the
1911 md_number_to_chars (p
, 0x4c520000 | 0x0001, 4);
1913 /* If we knew (or cared) what the source language options were, we'd
1914 fill them in here. SCO has given us permission to ignore these
1915 and just set them to zero. */
1917 md_number_to_chars (p
, 0x0000, 4);
1919 frag_align (2, 0, 0);
1921 /* We probably can't restore the current segment, for there likely
1924 subseg_set (seg
, subseg
);
1928 #endif /* SCO_ELF */
1931 elf_separate_stab_sections ()
1933 #ifdef NEED_ECOFF_DEBUG
1934 return (!ECOFF_DEBUGGING
);
1941 elf_init_stab_section (seg
)
1944 #ifdef NEED_ECOFF_DEBUG
1945 if (!ECOFF_DEBUGGING
)
1947 obj_elf_init_stab_section (seg
);
1950 const struct format_ops elf_format_ops
=
1952 bfd_target_elf_flavour
,
1953 0, /* dfl_leading_underscore */
1954 1, /* emit_section_symbols */
1959 elf_frob_file_after_relocs
,
1960 elf_s_get_size
, elf_s_set_size
,
1961 elf_s_get_align
, elf_s_set_align
,
1968 elf_copy_symbol_attributes
,
1969 #ifdef NEED_ECOFF_DEBUG
1970 ecoff_generate_asm_lineno
,
1973 0, /* generate_asm_lineno */
1974 0, /* process_stab */
1976 elf_separate_stab_sections
,
1977 elf_init_stab_section
,
1978 elf_sec_sym_ok_for_reloc
,
1980 #ifdef NEED_ECOFF_DEBUG
1983 0, /* ecoff_set_ext */
1985 elf_obj_read_begin_hook
,
1986 elf_obj_symbol_new_hook