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_copy_symbol_attributes
PARAMS ((symbolS
*, symbolS
*));
58 static int elf_sec_sym_ok_for_reloc
PARAMS ((asection
*));
59 static void adjust_stab_sections
PARAMS ((bfd
*, asection
*, PTR
));
61 #ifdef NEED_ECOFF_DEBUG
62 static boolean elf_get_extr
PARAMS ((asymbol
*, EXTR
*));
63 static void elf_set_index
PARAMS ((asymbol
*, bfd_size_type
));
66 static void obj_elf_line
PARAMS ((int));
67 void obj_elf_version
PARAMS ((int));
68 static void obj_elf_size
PARAMS ((int));
69 static void obj_elf_type
PARAMS ((int));
70 static void obj_elf_ident
PARAMS ((int));
71 static void obj_elf_weak
PARAMS ((int));
72 static void obj_elf_local
PARAMS ((int));
73 static void obj_elf_visibility
PARAMS ((int));
74 static void obj_elf_symver
PARAMS ((int));
75 static void obj_elf_vtable_inherit
PARAMS ((int));
76 static void obj_elf_vtable_entry
PARAMS ((int));
77 static void obj_elf_subsection
PARAMS ((int));
78 static void obj_elf_popsection
PARAMS ((int));
80 static const pseudo_typeS elf_pseudo_table
[] =
82 {"comm", obj_elf_common
, 0},
83 {"common", obj_elf_common
, 1},
84 {"ident", obj_elf_ident
, 0},
85 {"local", obj_elf_local
, 0},
86 {"previous", obj_elf_previous
, 0},
87 {"section", obj_elf_section
, 0},
88 {"section.s", obj_elf_section
, 0},
89 {"sect", obj_elf_section
, 0},
90 {"sect.s", obj_elf_section
, 0},
91 {"pushsection", obj_elf_section
, 1},
92 {"popsection", obj_elf_popsection
, 0},
93 {"size", obj_elf_size
, 0},
94 {"type", obj_elf_type
, 0},
95 {"version", obj_elf_version
, 0},
96 {"weak", obj_elf_weak
, 0},
98 /* These define symbol visibility. */
99 {"internal", obj_elf_visibility
, STV_INTERNAL
},
100 {"hidden", obj_elf_visibility
, STV_HIDDEN
},
101 {"protected", obj_elf_visibility
, STV_PROTECTED
},
103 /* These are used for stabs-in-elf configurations. */
104 {"line", obj_elf_line
, 0},
106 /* This is a GNU extension to handle symbol versions. */
107 {"symver", obj_elf_symver
, 0},
109 /* A GNU extension to change subsection only. */
110 {"subsection", obj_elf_subsection
, 0},
112 /* These are GNU extensions to aid in garbage collecting C++ vtables. */
113 {"vtable_inherit", obj_elf_vtable_inherit
, 0},
114 {"vtable_entry", obj_elf_vtable_entry
, 0},
116 /* These are used for dwarf. */
121 /* We need to trap the section changing calls to handle .previous. */
122 {"data", obj_elf_data
, 0},
123 {"text", obj_elf_text
, 0},
129 static const pseudo_typeS ecoff_debug_pseudo_table
[] =
131 #ifdef NEED_ECOFF_DEBUG
132 /* COFF style debugging information for ECOFF. .ln is not used; .loc
134 { "def", ecoff_directive_def
, 0 },
135 { "dim", ecoff_directive_dim
, 0 },
136 { "endef", ecoff_directive_endef
, 0 },
137 { "file", ecoff_directive_file
, 0 },
138 { "scl", ecoff_directive_scl
, 0 },
139 { "tag", ecoff_directive_tag
, 0 },
140 { "val", ecoff_directive_val
, 0 },
142 /* COFF debugging requires pseudo-ops .size and .type, but ELF
143 already has meanings for those. We use .esize and .etype
144 instead. These are only generated by gcc anyhow. */
145 { "esize", ecoff_directive_size
, 0 },
146 { "etype", ecoff_directive_type
, 0 },
148 /* ECOFF specific debugging information. */
149 { "begin", ecoff_directive_begin
, 0 },
150 { "bend", ecoff_directive_bend
, 0 },
151 { "end", ecoff_directive_end
, 0 },
152 { "ent", ecoff_directive_ent
, 0 },
153 { "fmask", ecoff_directive_fmask
, 0 },
154 { "frame", ecoff_directive_frame
, 0 },
155 { "loc", ecoff_directive_loc
, 0 },
156 { "mask", ecoff_directive_mask
, 0 },
158 /* Other ECOFF directives. */
159 { "extern", ecoff_directive_extern
, 0 },
161 /* These are used on Irix. I don't know how to implement them. */
162 { "alias", s_ignore
, 0 },
163 { "bgnb", s_ignore
, 0 },
164 { "endb", s_ignore
, 0 },
165 { "lab", s_ignore
, 0 },
166 { "noalias", s_ignore
, 0 },
167 { "verstamp", s_ignore
, 0 },
168 { "vreg", s_ignore
, 0 },
171 {NULL
, NULL
, 0} /* end sentinel */
175 #include "aout/aout64.h"
177 /* This is called when the assembler starts. */
182 /* Add symbols for the known sections to the symbol table. */
183 symbol_table_insert (section_symbol (bfd_get_section_by_name (stdoutput
,
184 TEXT_SECTION_NAME
)));
185 symbol_table_insert (section_symbol (bfd_get_section_by_name (stdoutput
,
186 DATA_SECTION_NAME
)));
187 symbol_table_insert (section_symbol (bfd_get_section_by_name (stdoutput
,
194 pop_insert (elf_pseudo_table
);
196 pop_insert (ecoff_debug_pseudo_table
);
203 return S_GET_SIZE (sym
);
207 elf_s_set_size (sym
, sz
)
211 S_SET_SIZE (sym
, sz
);
215 elf_s_get_align (sym
)
218 return S_GET_ALIGN (sym
);
222 elf_s_set_align (sym
, align
)
226 S_SET_ALIGN (sym
, align
);
230 elf_s_get_other (sym
)
233 return elf_symbol (symbol_get_bfdsym (sym
))->internal_elf_sym
.st_other
;
237 elf_copy_symbol_attributes (dest
, src
)
240 OBJ_COPY_SYMBOL_ATTRIBUTES (dest
, src
);
244 elf_sec_sym_ok_for_reloc (sec
)
247 return obj_sec_sym_ok_for_reloc (sec
);
256 sym
= symbol_new (s
, absolute_section
, (valueT
) 0, (struct frag
*) 0);
257 symbol_set_frag (sym
, &zero_address_frag
);
258 symbol_get_bfdsym (sym
)->flags
|= BSF_FILE
;
260 if (symbol_rootP
!= sym
)
262 symbol_remove (sym
, &symbol_rootP
, &symbol_lastP
);
263 symbol_insert (sym
, symbol_rootP
, &symbol_rootP
, &symbol_lastP
);
265 verify_symbol_chain (symbol_rootP
, symbol_lastP
);
269 #ifdef NEED_ECOFF_DEBUG
275 obj_elf_common (is_common
)
285 if (flag_mri
&& is_common
)
291 name
= input_line_pointer
;
292 c
= get_symbol_end ();
293 /* just after name is now '\0' */
294 p
= input_line_pointer
;
297 if (*input_line_pointer
!= ',')
299 as_bad (_("Expected comma after symbol-name"));
300 ignore_rest_of_line ();
303 input_line_pointer
++; /* skip ',' */
304 if ((temp
= get_absolute_expression ()) < 0)
306 as_bad (_(".COMMon length (%d.) <0! Ignored."), temp
);
307 ignore_rest_of_line ();
312 symbolP
= symbol_find_or_make (name
);
314 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
316 as_bad (_("Ignoring attempt to re-define symbol"));
317 ignore_rest_of_line ();
320 if (S_GET_VALUE (symbolP
) != 0)
322 if (S_GET_VALUE (symbolP
) != (valueT
) size
)
324 as_warn (_("Length of .comm \"%s\" is already %ld. Not changed to %d."),
325 S_GET_NAME (symbolP
), (long) S_GET_VALUE (symbolP
), size
);
328 know (symbolP
->sy_frag
== &zero_address_frag
);
329 if (*input_line_pointer
!= ',')
334 input_line_pointer
++;
337 if (! have_align
|| *input_line_pointer
!= '"')
343 temp
= get_absolute_expression ();
347 as_warn (_("Common alignment negative; 0 assumed"));
350 if (symbol_get_obj (symbolP
)->local
)
359 old_subsec
= now_subseg
;
362 /* convert to a power of 2 alignment */
363 for (align
= 0; (temp
& 1) == 0; temp
>>= 1, ++align
);
366 as_bad (_("Common alignment not a power of 2"));
367 ignore_rest_of_line ();
373 record_alignment (bss_section
, align
);
374 subseg_set (bss_section
, 0);
376 frag_align (align
, 0, 0);
377 if (S_GET_SEGMENT (symbolP
) == bss_section
)
378 symbol_get_frag (symbolP
)->fr_symbol
= 0;
379 symbol_set_frag (symbolP
, frag_now
);
380 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
381 (offsetT
) size
, (char *) 0);
383 S_SET_SIZE (symbolP
, size
);
384 S_SET_SEGMENT (symbolP
, bss_section
);
385 S_CLEAR_EXTERNAL (symbolP
);
386 subseg_set (old_sec
, old_subsec
);
391 S_SET_VALUE (symbolP
, (valueT
) size
);
392 S_SET_ALIGN (symbolP
, temp
);
393 S_SET_EXTERNAL (symbolP
);
394 S_SET_SEGMENT (symbolP
, bfd_com_section_ptr
);
399 input_line_pointer
++;
400 /* @@ Some use the dot, some don't. Can we get some consistency?? */
401 if (*input_line_pointer
== '.')
402 input_line_pointer
++;
403 /* @@ Some say data, some say bss. */
404 if (strncmp (input_line_pointer
, "bss\"", 4)
405 && strncmp (input_line_pointer
, "data\"", 5))
407 while (*--input_line_pointer
!= '"')
409 input_line_pointer
--;
410 goto bad_common_segment
;
412 while (*input_line_pointer
++ != '"')
414 goto allocate_common
;
417 symbol_get_bfdsym (symbolP
)->flags
|= BSF_OBJECT
;
419 demand_empty_rest_of_line ();
424 p
= input_line_pointer
;
425 while (*p
&& *p
!= '\n')
429 as_bad (_("bad .common segment %s"), input_line_pointer
+ 1);
431 input_line_pointer
= p
;
432 ignore_rest_of_line ();
438 obj_elf_local (ignore
)
439 int ignore ATTRIBUTE_UNUSED
;
447 name
= input_line_pointer
;
448 c
= get_symbol_end ();
449 symbolP
= symbol_find_or_make (name
);
450 *input_line_pointer
= c
;
452 S_CLEAR_EXTERNAL (symbolP
);
453 symbol_get_obj (symbolP
)->local
= 1;
456 input_line_pointer
++;
458 if (*input_line_pointer
== '\n')
463 demand_empty_rest_of_line ();
467 obj_elf_weak (ignore
)
468 int ignore ATTRIBUTE_UNUSED
;
476 name
= input_line_pointer
;
477 c
= get_symbol_end ();
478 symbolP
= symbol_find_or_make (name
);
479 *input_line_pointer
= c
;
481 S_SET_WEAK (symbolP
);
482 symbol_get_obj (symbolP
)->local
= 1;
485 input_line_pointer
++;
487 if (*input_line_pointer
== '\n')
492 demand_empty_rest_of_line ();
496 obj_elf_visibility (visibility
)
503 elf_symbol_type
*elfsym
;
507 name
= input_line_pointer
;
508 c
= get_symbol_end ();
509 symbolP
= symbol_find_or_make (name
);
510 *input_line_pointer
= c
;
514 bfdsym
= symbol_get_bfdsym (symbolP
);
515 elfsym
= elf_symbol_from (bfd_asymbol_bfd (bfdsym
), bfdsym
);
519 elfsym
->internal_elf_sym
.st_other
= visibility
;
523 input_line_pointer
++;
527 if (*input_line_pointer
== '\n')
533 demand_empty_rest_of_line ();
537 static segT previous_section
;
538 static int previous_subsection
;
542 struct section_stack
*next
;
544 int subseg
, prev_subseg
;
547 static struct section_stack
*section_stack
;
550 /* Handle the .section pseudo-op. This code supports two different
553 The first is found on Solaris, and looks like
554 .section ".sec1",#alloc,#execinstr,#write
555 Here the names after '#' are the SHF_* flags to turn on for the
556 section. I'm not sure how it determines the SHT_* type (BFD
557 doesn't really give us control over the type, anyhow).
559 The second format is found on UnixWare, and probably most SVR4
560 machines, and looks like
561 .section .sec1,"a",@progbits
562 The quoted string may contain any combination of a, w, x, and
563 represents the SHF_* flags to turn on for the section. The string
564 beginning with '@' can be progbits or nobits. There should be
565 other possibilities, but I don't know what they are. In any case,
566 BFD doesn't really let us set the section type. */
568 /* Certain named sections have particular defined types, listed on p.
570 struct special_section
577 static struct special_section
const special_sections
[] =
579 { ".bss", SHT_NOBITS
, SHF_ALLOC
+ SHF_WRITE
},
580 { ".comment", SHT_PROGBITS
, 0 },
581 { ".data", SHT_PROGBITS
, SHF_ALLOC
+ SHF_WRITE
},
582 { ".data1", SHT_PROGBITS
, SHF_ALLOC
+ SHF_WRITE
},
583 { ".debug", SHT_PROGBITS
, 0 },
584 { ".fini", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
585 { ".init", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
586 { ".line", SHT_PROGBITS
, 0 },
587 { ".note", SHT_NOTE
, 0 },
588 { ".rodata", SHT_PROGBITS
, SHF_ALLOC
},
589 { ".rodata1", SHT_PROGBITS
, SHF_ALLOC
},
590 { ".text", SHT_PROGBITS
, SHF_ALLOC
+ SHF_EXECINSTR
},
592 #ifdef ELF_TC_SPECIAL_SECTIONS
593 ELF_TC_SPECIAL_SECTIONS
597 /* The following section names are special, but they can not
598 reasonably appear in assembler code. Some of the attributes are
599 processor dependent. */
600 { ".dynamic", SHT_DYNAMIC
, SHF_ALLOC
/* + SHF_WRITE */ },
601 { ".dynstr", SHT_STRTAB
, SHF_ALLOC
},
602 { ".dynsym", SHT_DYNSYM
, SHF_ALLOC
},
603 { ".got", SHT_PROGBITS
, 0 },
604 { ".hash", SHT_HASH
, SHF_ALLOC
},
605 { ".interp", SHT_PROGBITS
, /* SHF_ALLOC */ },
606 { ".plt", SHT_PROGBITS
, 0 },
607 { ".shstrtab",SHT_STRTAB
, 0 },
608 { ".strtab", SHT_STRTAB
, /* SHF_ALLOC */ },
609 { ".symtab", SHT_SYMTAB
, /* SHF_ALLOC */ },
616 obj_elf_change_section (name
, type
, attr
, push
)
618 int type
, attr
, push
;
625 #ifdef md_flush_pending_output
626 md_flush_pending_output ();
629 /* Switch to the section, creating it if necessary. */
632 struct section_stack
*elt
;
633 elt
= xmalloc (sizeof (struct section_stack
));
634 elt
->next
= section_stack
;
636 elt
->prev_seg
= previous_section
;
637 elt
->subseg
= now_subseg
;
638 elt
->prev_subseg
= previous_subsection
;
641 previous_section
= now_seg
;
642 previous_subsection
= now_subseg
;
644 old_sec
= bfd_get_section_by_name (stdoutput
, name
);
645 sec
= subseg_new (name
, 0);
647 /* See if this is one of the special sections. */
648 for (i
= 0; special_sections
[i
].name
!= NULL
; i
++)
649 if (strcmp (name
, special_sections
[i
].name
) == 0)
651 if (type
== SHT_NULL
)
652 type
= special_sections
[i
].type
;
653 else if (type
!= special_sections
[i
].type
)
657 as_warn (_("Setting incorrect section type for %s"), name
);
661 as_warn (_("Ignoring incorrect section type for %s"), name
);
662 type
= special_sections
[i
].type
;
665 if ((attr
&~ special_sections
[i
].attributes
) != 0
668 /* As a GNU extension, we permit a .note section to be
669 allocatable. If the linker sees an allocateable .note
670 section, it will create a PT_NOTE segment in the output
672 if (strcmp (name
, ".note") != 0
673 || attr
!= SHF_ALLOC
)
674 as_warn (_("Setting incorrect section attributes for %s"),
677 attr
|= special_sections
[i
].attributes
;
681 /* Convert ELF type and flags to BFD flags. */
683 | ((attr
& SHF_WRITE
) ? 0 : SEC_READONLY
)
684 | ((attr
& SHF_ALLOC
) ? SEC_ALLOC
: 0)
685 | (((attr
& SHF_ALLOC
) && type
!= SHT_NOBITS
) ? SEC_LOAD
: 0)
686 | ((attr
& SHF_EXECINSTR
) ? SEC_CODE
: 0));
687 #ifdef md_elf_section_flags
688 flags
= md_elf_section_flags (flags
, attr
, type
);
695 /* Prevent SEC_HAS_CONTENTS from being inadvertently set. */
696 if (type
== SHT_NOBITS
)
697 seg_info (sec
)->bss
= 1;
699 bfd_set_section_flags (stdoutput
, sec
, flags
);
701 /* Add a symbol for this section to the symbol table. */
702 secsym
= symbol_find (name
);
704 symbol_set_bfdsym (secsym
, sec
->symbol
);
706 symbol_table_insert (section_symbol (sec
));
710 /* If section attributes are specified the second time we see a
711 particular section, then check that they are the same as we
712 saw the first time. */
713 if ((old_sec
->flags
^ flags
)
714 & (SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
715 | SEC_EXCLUDE
| SEC_SORT_ENTRIES
))
716 as_warn (_("Ignoring changed section attributes for %s"), name
);
719 #ifdef md_elf_section_change_hook
720 md_elf_section_change_hook ();
725 obj_elf_parse_section_letters (str
, len
)
742 attr
|= SHF_EXECINSTR
;
746 char *bad_msg
= _("Unrecognized .section attribute: want a,w,x");
747 #ifdef md_elf_section_letter
748 int md_attr
= md_elf_section_letter (*str
, &bad_msg
);
754 as_warn ("%s", bad_msg
);
767 obj_elf_section_word (str
, len
)
771 if (len
== 5 && strncmp (str
, "write", 5) == 0)
773 if (len
== 5 && strncmp (str
, "alloc", 5) == 0)
775 if (len
== 9 && strncmp (str
, "execinstr", 9) == 0)
776 return SHF_EXECINSTR
;
778 #ifdef md_elf_section_word
780 int md_attr
= md_elf_section_word (str
, len
);
786 as_warn (_("Unrecognized section attribute"));
791 obj_elf_section_type (str
, len
)
795 if (len
== 8 && strncmp (str
, "progbits", 8) == 0)
797 if (len
== 6 && strncmp (str
, "nobits", 6) == 0)
800 #ifdef md_elf_section_type
802 int md_type
= md_elf_section_type (str
, len
);
808 as_warn (_("Unrecognized section type"));
813 obj_elf_section (push
)
816 char *name
, *beg
, *end
;
817 int type
, attr
, dummy
;
824 #ifdef md_flush_pending_output
825 md_flush_pending_output ();
828 previous_section
= now_seg
;
829 previous_subsection
= now_subseg
;
831 s_mri_sect (&mri_type
);
833 #ifdef md_elf_section_change_hook
834 md_elf_section_change_hook ();
839 #endif /* ! defined (TC_I370) */
841 /* Get name of section. */
843 if (*input_line_pointer
== '"')
845 name
= demand_copy_C_string (&dummy
);
848 ignore_rest_of_line ();
854 end
= input_line_pointer
;
855 while (0 == strchr ("\n\t,; ", *end
))
857 if (end
== input_line_pointer
)
859 as_warn (_("Missing section name"));
860 ignore_rest_of_line ();
864 name
= xmalloc (end
- input_line_pointer
+ 1);
865 memcpy (name
, input_line_pointer
, end
- input_line_pointer
);
866 name
[end
- input_line_pointer
] = '\0';
867 input_line_pointer
= end
;
874 if (*input_line_pointer
== ',')
876 /* Skip the comma. */
877 ++input_line_pointer
;
880 if (*input_line_pointer
== '"')
882 beg
= demand_copy_C_string (&dummy
);
885 ignore_rest_of_line ();
888 attr
|= obj_elf_parse_section_letters (beg
, strlen (beg
));
891 if (*input_line_pointer
== ',')
894 ++input_line_pointer
;
896 c
= *input_line_pointer
;
899 beg
= demand_copy_C_string (&dummy
);
902 ignore_rest_of_line ();
905 type
= obj_elf_section_type (beg
, strlen (beg
));
907 else if (c
== '@' || c
== '%')
909 beg
= ++input_line_pointer
;
910 c
= get_symbol_end ();
911 *input_line_pointer
= c
;
912 type
= obj_elf_section_type (beg
, input_line_pointer
- beg
);
923 if (*input_line_pointer
!= '#')
925 as_warn (_("Bad .section directive - character following name is not '#'"));
926 ignore_rest_of_line ();
929 beg
= ++input_line_pointer
;
930 c
= get_symbol_end ();
931 *input_line_pointer
= c
;
933 attr
|= obj_elf_section_word (beg
, input_line_pointer
- beg
);
937 while (*input_line_pointer
++ == ',');
938 --input_line_pointer
;
942 demand_empty_rest_of_line ();
944 obj_elf_change_section (name
, type
, attr
, push
);
947 /* Change to the .data section. */
953 #ifdef md_flush_pending_output
954 md_flush_pending_output ();
957 previous_section
= now_seg
;
958 previous_subsection
= now_subseg
;
961 #ifdef md_elf_section_change_hook
962 md_elf_section_change_hook ();
966 /* Change to the .text section. */
972 #ifdef md_flush_pending_output
973 md_flush_pending_output ();
976 previous_section
= now_seg
;
977 previous_subsection
= now_subseg
;
980 #ifdef md_elf_section_change_hook
981 md_elf_section_change_hook ();
986 obj_elf_subsection (ignore
)
987 int ignore ATTRIBUTE_UNUSED
;
991 #ifdef md_flush_pending_output
992 md_flush_pending_output ();
995 previous_section
= now_seg
;
996 previous_subsection
= now_subseg
;
998 temp
= get_absolute_expression ();
999 subseg_set (now_seg
, (subsegT
) temp
);
1000 demand_empty_rest_of_line ();
1002 #ifdef md_elf_section_change_hook
1003 md_elf_section_change_hook ();
1007 /* This can be called from the processor backends if they change
1011 obj_elf_section_change_hook ()
1013 previous_section
= now_seg
;
1014 previous_subsection
= now_subseg
;
1018 obj_elf_previous (ignore
)
1019 int ignore ATTRIBUTE_UNUSED
;
1024 if (previous_section
== 0)
1026 as_bad (_(".previous without corresponding .section; ignored"));
1030 #ifdef md_flush_pending_output
1031 md_flush_pending_output ();
1034 new_section
= previous_section
;
1035 new_subsection
= previous_subsection
;
1036 previous_section
= now_seg
;
1037 previous_subsection
= now_subseg
;
1038 subseg_set (new_section
, new_subsection
);
1040 #ifdef md_elf_section_change_hook
1041 md_elf_section_change_hook ();
1046 obj_elf_popsection (xxx
)
1047 int xxx ATTRIBUTE_UNUSED
;
1049 struct section_stack
*top
= section_stack
;
1053 as_bad (_(".popsection without corresponding .pushsection; ignored"));
1057 #ifdef md_flush_pending_output
1058 md_flush_pending_output ();
1061 section_stack
= top
->next
;
1062 previous_section
= top
->prev_seg
;
1063 previous_subsection
= top
->prev_subseg
;
1064 subseg_set (top
->seg
, top
->subseg
);
1067 #ifdef md_elf_section_change_hook
1068 md_elf_section_change_hook ();
1073 obj_elf_line (ignore
)
1074 int ignore ATTRIBUTE_UNUSED
;
1076 /* Assume delimiter is part of expression. BSD4.2 as fails with
1077 delightful bug, so we are not being incompatible here. */
1078 new_logical_line ((char *) NULL
, (int) (get_absolute_expression ()));
1079 demand_empty_rest_of_line ();
1082 /* This handles the .symver pseudo-op, which is used to specify a
1083 symbol version. The syntax is ``.symver NAME,SYMVERNAME''.
1084 SYMVERNAME may contain ELF_VER_CHR ('@') characters. This
1085 pseudo-op causes the assembler to emit a symbol named SYMVERNAME
1086 with the same value as the symbol NAME. */
1089 obj_elf_symver (ignore
)
1090 int ignore ATTRIBUTE_UNUSED
;
1096 name
= input_line_pointer
;
1097 c
= get_symbol_end ();
1099 sym
= symbol_find_or_make (name
);
1101 *input_line_pointer
= c
;
1103 if (symbol_get_obj (sym
)->versioned_name
!= NULL
)
1105 as_bad (_("multiple .symver directives for symbol `%s'"),
1107 ignore_rest_of_line ();
1112 if (*input_line_pointer
!= ',')
1114 as_bad (_("expected comma after name in .symver"));
1115 ignore_rest_of_line ();
1119 ++input_line_pointer
;
1120 name
= input_line_pointer
;
1123 c
= get_symbol_end ();
1124 if (c
!= ELF_VER_CHR
)
1126 *input_line_pointer
++ = c
;
1129 symbol_get_obj (sym
)->versioned_name
= xstrdup (name
);
1131 *input_line_pointer
= c
;
1133 if (strchr (symbol_get_obj (sym
)->versioned_name
, ELF_VER_CHR
) == NULL
)
1135 as_bad (_("missing version name in `%s' for symbol `%s'"),
1136 symbol_get_obj (sym
)->versioned_name
, S_GET_NAME (sym
));
1137 ignore_rest_of_line ();
1141 demand_empty_rest_of_line ();
1144 /* This handles the .vtable_inherit pseudo-op, which is used to indicate
1145 to the linker the hierarchy in which a particular table resides. The
1146 syntax is ".vtable_inherit CHILDNAME, PARENTNAME". */
1149 obj_elf_vtable_inherit (ignore
)
1150 int ignore ATTRIBUTE_UNUSED
;
1152 char *cname
, *pname
;
1153 symbolS
*csym
, *psym
;
1156 if (*input_line_pointer
== '#')
1157 ++input_line_pointer
;
1159 cname
= input_line_pointer
;
1160 c
= get_symbol_end ();
1161 csym
= symbol_find (cname
);
1163 /* GCFIXME: should check that we don't have two .vtable_inherits for
1164 the same child symbol. Also, we can currently only do this if the
1165 child symbol is already exists and is placed in a fragment. */
1167 if (csym
== NULL
|| symbol_get_frag (csym
) == NULL
)
1169 as_bad ("expected `%s' to have already been set for .vtable_inherit",
1174 *input_line_pointer
= c
;
1177 if (*input_line_pointer
!= ',')
1179 as_bad ("expected comma after name in .vtable_inherit");
1180 ignore_rest_of_line ();
1184 ++input_line_pointer
;
1187 if (*input_line_pointer
== '#')
1188 ++input_line_pointer
;
1190 if (input_line_pointer
[0] == '0'
1191 && (input_line_pointer
[1] == '\0'
1192 || isspace ((unsigned char) input_line_pointer
[1])))
1194 psym
= section_symbol (absolute_section
);
1195 ++input_line_pointer
;
1199 pname
= input_line_pointer
;
1200 c
= get_symbol_end ();
1201 psym
= symbol_find_or_make (pname
);
1202 *input_line_pointer
= c
;
1205 demand_empty_rest_of_line ();
1210 assert (symbol_get_value_expression (csym
)->X_op
== O_constant
);
1211 fix_new (symbol_get_frag (csym
),
1212 symbol_get_value_expression (csym
)->X_add_number
, 0, psym
, 0, 0,
1213 BFD_RELOC_VTABLE_INHERIT
);
1216 /* This handles the .vtable_entry pseudo-op, which is used to indicate
1217 to the linker that a vtable slot was used. The syntax is
1218 ".vtable_entry tablename, offset". */
1221 obj_elf_vtable_entry (ignore
)
1222 int ignore ATTRIBUTE_UNUSED
;
1229 if (*input_line_pointer
== '#')
1230 ++input_line_pointer
;
1232 name
= input_line_pointer
;
1233 c
= get_symbol_end ();
1234 sym
= symbol_find_or_make (name
);
1235 *input_line_pointer
= c
;
1238 if (*input_line_pointer
!= ',')
1240 as_bad ("expected comma after name in .vtable_entry");
1241 ignore_rest_of_line ();
1245 ++input_line_pointer
;
1246 if (*input_line_pointer
== '#')
1247 ++input_line_pointer
;
1249 offset
= get_absolute_expression ();
1251 fix_new (frag_now
, frag_now_fix (), 0, sym
, offset
, 0,
1252 BFD_RELOC_VTABLE_ENTRY
);
1254 demand_empty_rest_of_line ();
1258 elf_obj_read_begin_hook ()
1260 #ifdef NEED_ECOFF_DEBUG
1261 if (ECOFF_DEBUGGING
)
1262 ecoff_read_begin_hook ();
1267 elf_obj_symbol_new_hook (symbolP
)
1270 struct elf_obj_sy
*sy_obj
;
1272 sy_obj
= symbol_get_obj (symbolP
);
1273 sy_obj
->size
= NULL
;
1274 sy_obj
->versioned_name
= NULL
;
1276 #ifdef NEED_ECOFF_DEBUG
1277 if (ECOFF_DEBUGGING
)
1278 ecoff_symbol_new_hook (symbolP
);
1283 obj_elf_version (ignore
)
1284 int ignore ATTRIBUTE_UNUSED
;
1290 asection
*seg
= now_seg
;
1291 subsegT subseg
= now_subseg
;
1292 Elf_Internal_Note i_note
;
1293 Elf_External_Note e_note
;
1294 asection
*note_secp
= (asection
*) NULL
;
1298 if (*input_line_pointer
== '\"')
1300 ++input_line_pointer
; /* -> 1st char of string. */
1301 name
= input_line_pointer
;
1303 while (is_a_char (c
= next_char_of_string ()))
1305 c
= *input_line_pointer
;
1306 *input_line_pointer
= '\0';
1307 *(input_line_pointer
- 1) = '\0';
1308 *input_line_pointer
= c
;
1310 /* create the .note section */
1312 note_secp
= subseg_new (".note", 0);
1313 bfd_set_section_flags (stdoutput
,
1315 SEC_HAS_CONTENTS
| SEC_READONLY
);
1317 /* process the version string */
1319 len
= strlen (name
);
1321 i_note
.namesz
= ((len
+ 1) + 3) & ~3; /* round this to word boundary */
1322 i_note
.descsz
= 0; /* no description */
1323 i_note
.type
= NT_VERSION
;
1324 p
= frag_more (sizeof (e_note
.namesz
));
1325 md_number_to_chars (p
, (valueT
) i_note
.namesz
, 4);
1326 p
= frag_more (sizeof (e_note
.descsz
));
1327 md_number_to_chars (p
, (valueT
) i_note
.descsz
, 4);
1328 p
= frag_more (sizeof (e_note
.type
));
1329 md_number_to_chars (p
, (valueT
) i_note
.type
, 4);
1331 for (i
= 0; i
< len
; i
++)
1335 FRAG_APPEND_1_CHAR (ch
);
1338 frag_align (2, 0, 0);
1340 subseg_set (seg
, subseg
);
1344 as_bad (_("Expected quoted string"));
1346 demand_empty_rest_of_line ();
1350 obj_elf_size (ignore
)
1351 int ignore ATTRIBUTE_UNUSED
;
1353 char *name
= input_line_pointer
;
1354 char c
= get_symbol_end ();
1359 p
= input_line_pointer
;
1362 if (*input_line_pointer
!= ',')
1365 as_bad (_("expected comma after name `%s' in .size directive"), name
);
1367 ignore_rest_of_line ();
1370 input_line_pointer
++;
1372 if (exp
.X_op
== O_absent
)
1374 as_bad (_("missing expression in .size directive"));
1375 exp
.X_op
= O_constant
;
1376 exp
.X_add_number
= 0;
1379 sym
= symbol_find_or_make (name
);
1381 if (exp
.X_op
== O_constant
)
1382 S_SET_SIZE (sym
, exp
.X_add_number
);
1385 symbol_get_obj (sym
)->size
=
1386 (expressionS
*) xmalloc (sizeof (expressionS
));
1387 *symbol_get_obj (sym
)->size
= exp
;
1389 demand_empty_rest_of_line ();
1392 /* Handle the ELF .type pseudo-op. This sets the type of a symbol.
1393 There are four syntaxes:
1395 The first (used on Solaris) is
1397 The second (used on UnixWare) is
1399 The third (reportedly to be used on Irix 6.0) is
1401 The fourth (used on NetBSD/Arm and Linux/ARM) is
1406 obj_elf_type (ignore
)
1407 int ignore ATTRIBUTE_UNUSED
;
1412 const char *typename
;
1415 name
= input_line_pointer
;
1416 c
= get_symbol_end ();
1417 sym
= symbol_find_or_make (name
);
1418 *input_line_pointer
= c
;
1421 if (*input_line_pointer
== ',')
1422 ++input_line_pointer
;
1425 if ( *input_line_pointer
== '#'
1426 || *input_line_pointer
== '@'
1427 || *input_line_pointer
== '%')
1428 ++input_line_pointer
;
1430 typename
= input_line_pointer
;
1431 c
= get_symbol_end ();
1434 if (strcmp (typename
, "function") == 0
1435 || strcmp (typename
, "STT_FUNC") == 0)
1436 type
= BSF_FUNCTION
;
1437 else if (strcmp (typename
, "object") == 0
1438 || strcmp (typename
, "STT_OBJECT") == 0)
1441 as_bad (_("ignoring unrecognized symbol type \"%s\""), typename
);
1443 *input_line_pointer
= c
;
1445 symbol_get_bfdsym (sym
)->flags
|= type
;
1447 demand_empty_rest_of_line ();
1451 obj_elf_ident (ignore
)
1452 int ignore ATTRIBUTE_UNUSED
;
1454 static segT comment_section
;
1455 segT old_section
= now_seg
;
1456 int old_subsection
= now_subseg
;
1458 #ifdef md_flush_pending_output
1459 md_flush_pending_output ();
1462 if (!comment_section
)
1465 comment_section
= subseg_new (".comment", 0);
1466 bfd_set_section_flags (stdoutput
, comment_section
,
1467 SEC_READONLY
| SEC_HAS_CONTENTS
);
1472 subseg_set (comment_section
, 0);
1474 subseg_set (old_section
, old_subsection
);
1477 #ifdef INIT_STAB_SECTION
1479 /* The first entry in a .stabs section is special. */
1482 obj_elf_init_stab_section (seg
)
1488 unsigned int stroff
;
1490 /* Force the section to align to a longword boundary. Without this,
1491 UnixWare ar crashes. */
1492 bfd_set_section_alignment (stdoutput
, seg
, 2);
1494 /* Make space for this first symbol. */
1498 as_where (&file
, (unsigned int *) NULL
);
1499 stabstr_name
= (char *) alloca (strlen (segment_name (seg
)) + 4);
1500 strcpy (stabstr_name
, segment_name (seg
));
1501 strcat (stabstr_name
, "str");
1502 stroff
= get_stab_string_offset (file
, stabstr_name
);
1504 md_number_to_chars (p
, stroff
, 4);
1505 seg_info (seg
)->stabu
.p
= p
;
1510 /* Fill in the counts in the first entry in a .stabs section. */
1513 adjust_stab_sections (abfd
, sec
, xxx
)
1516 PTR xxx ATTRIBUTE_UNUSED
;
1523 if (strncmp (".stab", sec
->name
, 5))
1525 if (!strcmp ("str", sec
->name
+ strlen (sec
->name
) - 3))
1528 name
= (char *) alloca (strlen (sec
->name
) + 4);
1529 strcpy (name
, sec
->name
);
1530 strcat (name
, "str");
1531 strsec
= bfd_get_section_by_name (abfd
, name
);
1533 strsz
= bfd_section_size (abfd
, strsec
);
1536 nsyms
= bfd_section_size (abfd
, sec
) / 12 - 1;
1538 p
= seg_info (sec
)->stabu
.p
;
1541 bfd_h_put_16 (abfd
, (bfd_vma
) nsyms
, (bfd_byte
*) p
+ 6);
1542 bfd_h_put_32 (abfd
, (bfd_vma
) strsz
, (bfd_byte
*) p
+ 8);
1545 #ifdef NEED_ECOFF_DEBUG
1547 /* This function is called by the ECOFF code. It is supposed to
1548 record the external symbol information so that the backend can
1549 write it out correctly. The ELF backend doesn't actually handle
1550 this at the moment, so we do it ourselves. We save the information
1554 elf_ecoff_set_ext (sym
, ext
)
1556 struct ecoff_extr
*ext
;
1558 symbol_get_bfdsym (sym
)->udata
.p
= (PTR
) ext
;
1561 /* This function is called by bfd_ecoff_debug_externals. It is
1562 supposed to *EXT to the external symbol information, and return
1563 whether the symbol should be used at all. */
1566 elf_get_extr (sym
, ext
)
1570 if (sym
->udata
.p
== NULL
)
1572 *ext
= *(EXTR
*) sym
->udata
.p
;
1576 /* This function is called by bfd_ecoff_debug_externals. It has
1577 nothing to do for ELF. */
1581 elf_set_index (sym
, indx
)
1582 asymbol
*sym ATTRIBUTE_UNUSED
;
1583 bfd_size_type indx ATTRIBUTE_UNUSED
;
1587 #endif /* NEED_ECOFF_DEBUG */
1590 elf_frob_symbol (symp
, puntp
)
1594 struct elf_obj_sy
*sy_obj
;
1596 #ifdef NEED_ECOFF_DEBUG
1597 if (ECOFF_DEBUGGING
)
1598 ecoff_frob_symbol (symp
);
1601 sy_obj
= symbol_get_obj (symp
);
1603 if (sy_obj
->size
!= NULL
)
1605 switch (sy_obj
->size
->X_op
)
1609 (S_GET_VALUE (sy_obj
->size
->X_add_symbol
)
1610 + sy_obj
->size
->X_add_number
1611 - S_GET_VALUE (sy_obj
->size
->X_op_symbol
)));
1615 (S_GET_VALUE (sy_obj
->size
->X_add_symbol
)
1616 + sy_obj
->size
->X_add_number
));
1619 as_bad (_(".size expression too complicated to fix up"));
1622 free (sy_obj
->size
);
1623 sy_obj
->size
= NULL
;
1626 if (sy_obj
->versioned_name
!= NULL
)
1628 /* This symbol was given a new name with the .symver directive.
1630 If this is an external reference, just rename the symbol to
1631 include the version string. This will make the relocs be
1632 against the correct versioned symbol.
1634 If this is a definition, add an alias. FIXME: Using an alias
1635 will permit the debugging information to refer to the right
1636 symbol. However, it's not clear whether it is the best
1639 if (! S_IS_DEFINED (symp
))
1643 /* Verify that the name isn't using the @@ syntax--this is
1644 reserved for definitions of the default version to link
1646 p
= strchr (sy_obj
->versioned_name
, ELF_VER_CHR
);
1648 if (p
[1] == ELF_VER_CHR
)
1650 as_bad (_("invalid attempt to declare external version name as default in symbol `%s'"),
1651 sy_obj
->versioned_name
);
1654 S_SET_NAME (symp
, sy_obj
->versioned_name
);
1660 /* FIXME: Creating a new symbol here is risky. We're in the
1661 final loop over the symbol table. We can get away with
1662 it only because the symbol goes to the end of the list,
1663 where the loop will still see it. It would probably be
1664 better to do this in obj_frob_file_before_adjust. */
1666 symp2
= symbol_find_or_make (sy_obj
->versioned_name
);
1668 /* Now we act as though we saw symp2 = sym. */
1670 S_SET_SEGMENT (symp2
, S_GET_SEGMENT (symp
));
1672 /* Subtracting out the frag address here is a hack because
1673 we are in the middle of the final loop. */
1676 - symbol_get_frag (symp
)->fr_address
));
1678 symbol_set_frag (symp2
, symbol_get_frag (symp
));
1680 /* This will copy over the size information. */
1681 copy_symbol_attributes (symp2
, symp
);
1683 if (S_IS_WEAK (symp
))
1686 if (S_IS_EXTERNAL (symp
))
1687 S_SET_EXTERNAL (symp2
);
1691 /* Double check weak symbols. */
1692 if (S_IS_WEAK (symp
))
1694 if (S_IS_COMMON (symp
))
1695 as_bad (_("Symbol `%s' can not be both weak and common"),
1700 /* The Irix 5 and 6 assemblers set the type of any common symbol and
1701 any undefined non-function symbol to STT_OBJECT. We try to be
1702 compatible, since newer Irix 5 and 6 linkers care. However, we
1703 only set undefined symbols to be STT_OBJECT if we are on Irix,
1704 because that is the only time gcc will generate the necessary
1705 .global directives to mark functions. */
1707 if (S_IS_COMMON (symp
))
1708 symbol_get_bfdsym (symp
)->flags
|= BSF_OBJECT
;
1710 if (strstr (TARGET_OS
, "irix") != NULL
1711 && ! S_IS_DEFINED (symp
)
1712 && (symbol_get_bfdsym (symp
)->flags
& BSF_FUNCTION
) == 0)
1713 symbol_get_bfdsym (symp
)->flags
|= BSF_OBJECT
;
1717 /* If TC_PPC is defined, we used to force the type of a symbol to be
1718 BSF_OBJECT if it was otherwise unset. This was required by some
1719 version of VxWorks. Thomas de Lellis <tdel@windriver.com> says
1720 that this is no longer needed, so it is now commented out. */
1721 if ((symbol_get_bfdsym (symp
)->flags
1722 & (BSF_FUNCTION
| BSF_FILE
| BSF_SECTION_SYM
)) == 0
1723 && S_IS_DEFINED (symp
))
1724 symbol_get_bfdsym (symp
)->flags
|= BSF_OBJECT
;
1731 bfd_map_over_sections (stdoutput
, adjust_stab_sections
, (PTR
) 0);
1733 #ifdef elf_tc_final_processing
1734 elf_tc_final_processing ();
1738 /* It is required that we let write_relocs have the opportunity to
1739 optimize away fixups before output has begun, since it is possible
1740 to eliminate all fixups for a section and thus we never should
1741 have generated the relocation section. */
1744 elf_frob_file_after_relocs ()
1746 #ifdef NEED_ECOFF_DEBUG
1747 if (ECOFF_DEBUGGING
)
1748 /* Generate the ECOFF debugging information. */
1750 const struct ecoff_debug_swap
*debug_swap
;
1751 struct ecoff_debug_info debug
;
1756 = get_elf_backend_data (stdoutput
)->elf_backend_ecoff_debug_swap
;
1757 know (debug_swap
!= (const struct ecoff_debug_swap
*) NULL
);
1758 ecoff_build_debug (&debug
.symbolic_header
, &buf
, debug_swap
);
1760 /* Set up the pointers in debug. */
1761 #define SET(ptr, offset, type) \
1762 debug.ptr = (type) (buf + debug.symbolic_header.offset)
1764 SET (line
, cbLineOffset
, unsigned char *);
1765 SET (external_dnr
, cbDnOffset
, PTR
);
1766 SET (external_pdr
, cbPdOffset
, PTR
);
1767 SET (external_sym
, cbSymOffset
, PTR
);
1768 SET (external_opt
, cbOptOffset
, PTR
);
1769 SET (external_aux
, cbAuxOffset
, union aux_ext
*);
1770 SET (ss
, cbSsOffset
, char *);
1771 SET (external_fdr
, cbFdOffset
, PTR
);
1772 SET (external_rfd
, cbRfdOffset
, PTR
);
1773 /* ssext and external_ext are set up just below. */
1777 /* Set up the external symbols. */
1778 debug
.ssext
= debug
.ssext_end
= NULL
;
1779 debug
.external_ext
= debug
.external_ext_end
= NULL
;
1780 if (! bfd_ecoff_debug_externals (stdoutput
, &debug
, debug_swap
, true,
1781 elf_get_extr
, elf_set_index
))
1782 as_fatal (_("Failed to set up debugging information: %s"),
1783 bfd_errmsg (bfd_get_error ()));
1785 sec
= bfd_get_section_by_name (stdoutput
, ".mdebug");
1786 assert (sec
!= NULL
);
1788 know (stdoutput
->output_has_begun
== false);
1790 /* We set the size of the section, call bfd_set_section_contents
1791 to force the ELF backend to allocate a file position, and then
1792 write out the data. FIXME: Is this really the best way to do
1794 sec
->_raw_size
= bfd_ecoff_debug_size (stdoutput
, &debug
, debug_swap
);
1796 /* Pass BUF to bfd_set_section_contents because this will
1797 eventually become a call to fwrite, and ISO C prohibits
1798 passing a NULL pointer to a stdio function even if the
1799 pointer will not be used. */
1800 if (! bfd_set_section_contents (stdoutput
, sec
, (PTR
) buf
,
1801 (file_ptr
) 0, (bfd_size_type
) 0))
1802 as_fatal (_("Can't start writing .mdebug section: %s"),
1803 bfd_errmsg (bfd_get_error ()));
1805 know (stdoutput
->output_has_begun
== true);
1806 know (sec
->filepos
!= 0);
1808 if (! bfd_ecoff_write_debug (stdoutput
, &debug
, debug_swap
,
1810 as_fatal (_("Could not write .mdebug section: %s"),
1811 bfd_errmsg (bfd_get_error ()));
1813 #endif /* NEED_ECOFF_DEBUG */
1818 /* Heavily plagarized from obj_elf_version. The idea is to emit the
1819 SCO specific identifier in the .notes section to satisfy the SCO
1822 This looks more complicated than it really is. As opposed to the
1823 "obvious" solution, this should handle the cross dev cases
1824 correctly. (i.e, hosting on a 64 bit big endian processor, but
1825 generating SCO Elf code) Efficiency isn't a concern, as there
1826 should be exactly one of these sections per object module.
1828 SCO OpenServer 5 identifies it's ELF modules with a standard ELF
1831 int_32 namesz = 4 ; Name size
1832 int_32 descsz = 12 ; Descriptive information
1834 char name[4] = "SCO" ; Originator name ALWAYS SCO + NULL
1835 int_32 version = (major ver # << 16) | version of tools ;
1836 int_32 source = (tool_id << 16 ) | 1 ;
1837 int_32 info = 0 ; These are set by the SCO tools, but we
1838 don't know enough about the source
1839 environment to set them. SCO ld currently
1840 ignores them, and recommends we set them
1843 #define SCO_MAJOR_VERSION 0x1
1844 #define SCO_MINOR_VERSION 0x1
1854 asection
*seg
= now_seg
;
1855 subsegT subseg
= now_subseg
;
1856 Elf_Internal_Note i_note
;
1857 Elf_External_Note e_note
;
1858 asection
*note_secp
= (asection
*) NULL
;
1861 /* create the .note section */
1863 note_secp
= subseg_new (".note", 0);
1864 bfd_set_section_flags (stdoutput
,
1866 SEC_HAS_CONTENTS
| SEC_READONLY
);
1868 /* process the version string */
1871 i_note
.descsz
= 12; /* 12 descriptive bytes */
1872 i_note
.type
= NT_VERSION
; /* Contains a version string */
1874 p
= frag_more (sizeof (i_note
.namesz
));
1875 md_number_to_chars (p
, (valueT
) i_note
.namesz
, 4);
1877 p
= frag_more (sizeof (i_note
.descsz
));
1878 md_number_to_chars (p
, (valueT
) i_note
.descsz
, 4);
1880 p
= frag_more (sizeof (i_note
.type
));
1881 md_number_to_chars (p
, (valueT
) i_note
.type
, 4);
1886 /* Note: this is the version number of the ELF we're representing */
1888 md_number_to_chars (p
, (SCO_MAJOR_VERSION
<< 16) | (SCO_MINOR_VERSION
), 4);
1890 /* Here, we pick a magic number for ourselves (yes, I "registered"
1891 it with SCO. The bottom bit shows that we are compat with the
1894 md_number_to_chars (p
, 0x4c520000 | 0x0001, 4);
1896 /* If we knew (or cared) what the source language options were, we'd
1897 fill them in here. SCO has given us permission to ignore these
1898 and just set them to zero. */
1900 md_number_to_chars (p
, 0x0000, 4);
1902 frag_align (2, 0, 0);
1904 /* We probably can't restore the current segment, for there likely
1907 subseg_set (seg
, subseg
);
1911 #endif /* SCO_ELF */
1913 const struct format_ops elf_format_ops
=
1915 bfd_target_elf_flavour
,
1916 0, /* dfl_leading_underscore */
1917 1, /* emit_section_symbols */
1920 elf_frob_file_after_relocs
,
1921 elf_s_get_size
, elf_s_set_size
,
1922 elf_s_get_align
, elf_s_set_align
,
1925 elf_copy_symbol_attributes
,
1926 #ifdef NEED_ECOFF_DEBUG
1927 ecoff_generate_asm_lineno
,
1930 0, /* generate_asm_lineno */
1931 0, /* process_stab */
1933 elf_sec_sym_ok_for_reloc
,
1935 #ifdef NEED_ECOFF_DEBUG
1938 0, /* ecoff_set_ext */
1940 elf_obj_read_begin_hook
,
1941 elf_obj_symbol_new_hook
,