/* ELF object file format
- Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc.
+ Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
+ 02111-1307, USA. */
#define OBJ_HEADER "obj-elf.h"
#include "as.h"
+#include "safe-ctype.h"
#include "subsegs.h"
#include "obstack.h"
#include "elf/ppc.h"
#endif
+#ifdef TC_I370
+#include "elf/i370.h"
+#endif
+
static bfd_vma elf_s_get_size PARAMS ((symbolS *));
static void elf_s_set_size PARAMS ((symbolS *, bfd_vma));
static bfd_vma elf_s_get_align PARAMS ((symbolS *));
static void elf_s_set_align PARAMS ((symbolS *, bfd_vma));
-static void elf_copy_symbol_attributes PARAMS ((symbolS *, symbolS *));
+static void elf_s_set_other PARAMS ((symbolS *, int));
static int elf_sec_sym_ok_for_reloc PARAMS ((asection *));
static void adjust_stab_sections PARAMS ((bfd *, asection *, PTR));
+static int elf_separate_stab_sections PARAMS ((void));
+static void elf_init_stab_section PARAMS ((segT));
#ifdef NEED_ECOFF_DEBUG
static boolean elf_get_extr PARAMS ((asymbol *, EXTR *));
static void obj_elf_ident PARAMS ((int));
static void obj_elf_weak PARAMS ((int));
static void obj_elf_local PARAMS ((int));
+static void obj_elf_visibility PARAMS ((int));
+static void obj_elf_change_section PARAMS ((char *, int, int, int, int));
+static int obj_elf_parse_section_letters PARAMS ((char *, size_t));
+static int obj_elf_section_word PARAMS ((char *, size_t));
+static int obj_elf_section_type PARAMS ((char *, size_t));
static void obj_elf_symver PARAMS ((int));
-static void obj_elf_vtable_inherit PARAMS ((int));
-static void obj_elf_vtable_entry PARAMS ((int));
static void obj_elf_subsection PARAMS ((int));
static void obj_elf_popsection PARAMS ((int));
{"version", obj_elf_version, 0},
{"weak", obj_elf_weak, 0},
+ /* These define symbol visibility. */
+ {"internal", obj_elf_visibility, STV_INTERNAL},
+ {"hidden", obj_elf_visibility, STV_HIDDEN},
+ {"protected", obj_elf_visibility, STV_PROTECTED},
+
/* These are used for stabs-in-elf configurations. */
{"line", obj_elf_line, 0},
{"subsection", obj_elf_subsection, 0},
/* These are GNU extensions to aid in garbage collecting C++ vtables. */
- {"vtable_inherit", obj_elf_vtable_inherit, 0},
- {"vtable_entry", obj_elf_vtable_entry, 0},
+ {"vtable_inherit", (void (*) PARAMS ((int))) &obj_elf_vtable_inherit, 0},
+ {"vtable_entry", (void (*) PARAMS ((int))) &obj_elf_vtable_entry, 0},
- /* These are used for dwarf. */
+ /* These are used for dwarf. */
{"2byte", cons, 2},
{"4byte", cons, 4},
{"8byte", cons, 8},
S_SET_ALIGN (sym, align);
}
+int
+elf_s_get_other (sym)
+ symbolS *sym;
+{
+ return elf_symbol (symbol_get_bfdsym (sym))->internal_elf_sym.st_other;
+}
+
static void
-elf_copy_symbol_attributes (dest, src)
- symbolS *dest, *src;
+elf_s_set_other (sym, other)
+ symbolS *sym;
+ int other;
{
- OBJ_COPY_SYMBOL_ATTRIBUTES (dest, src);
+ S_SET_OTHER (sym, other);
}
static int
void
elf_file_symbol (s)
- char *s;
+ const char *s;
{
symbolS *sym;
demand_empty_rest_of_line ();
}
+static void
+obj_elf_visibility (visibility)
+ int visibility;
+{
+ char *name;
+ int c;
+ symbolS *symbolP;
+ asymbol *bfdsym;
+ elf_symbol_type *elfsym;
+
+ do
+ {
+ name = input_line_pointer;
+ c = get_symbol_end ();
+ symbolP = symbol_find_or_make (name);
+ *input_line_pointer = c;
+
+ SKIP_WHITESPACE ();
+
+ bfdsym = symbol_get_bfdsym (symbolP);
+ elfsym = elf_symbol_from (bfd_asymbol_bfd (bfdsym), bfdsym);
+
+ assert (elfsym);
+
+ elfsym->internal_elf_sym.st_other = visibility;
+
+ if (c == ',')
+ {
+ input_line_pointer ++;
+
+ SKIP_WHITESPACE ();
+
+ if (*input_line_pointer == '\n')
+ c = '\n';
+ }
+ }
+ while (c == ',');
+
+ demand_empty_rest_of_line ();
+}
+
static segT previous_section;
static int previous_subsection;
static struct section_stack *section_stack;
-
/* Handle the .section pseudo-op. This code supports two different
syntaxes.
{ NULL, 0, 0 }
};
-void
-obj_elf_change_section (name, type, attr, push)
+static void
+obj_elf_change_section (name, type, attr, entsize, push)
char *name;
- int type, attr, push;
+ int type, attr, entsize, push;
{
- int new_sec;
+ asection *old_sec;
segT sec;
+ flagword flags;
+ int i;
#ifdef md_flush_pending_output
md_flush_pending_output ();
previous_section = now_seg;
previous_subsection = now_subseg;
- new_sec = bfd_get_section_by_name (stdoutput, name) == NULL;
+ old_sec = bfd_get_section_by_name (stdoutput, name);
sec = subseg_new (name, 0);
- if (new_sec)
- {
- flagword flags;
- symbolS *secsym;
- int i;
-
- /* See if this is one of the special sections. */
- for (i = 0; special_sections[i].name != NULL; i++)
- if (strcmp (name, special_sections[i].name) == 0)
- {
- if (type == SHT_NULL)
- type = special_sections[i].type;
- else if (type != special_sections[i].type)
- as_warn (_("Setting incorrect section type for %s"), name);
-
- if ((attr &~ special_sections[i].attributes) != 0)
+ /* See if this is one of the special sections. */
+ for (i = 0; special_sections[i].name != NULL; i++)
+ if (strcmp (name, special_sections[i].name) == 0)
+ {
+ if (type == SHT_NULL)
+ type = special_sections[i].type;
+ else if (type != special_sections[i].type)
+ {
+ if (old_sec == NULL)
+ {
+ as_warn (_("Setting incorrect section type for %s"), name);
+ }
+ else
{
- /* As a GNU extension, we permit a .note section to be
- allocatable. If the linker sees an allocateable .note
- section, it will create a PT_NOTE segment in the output
- file. */
- if (strcmp (name, ".note") != 0
- || attr != SHF_ALLOC)
- as_warn (_("Setting incorrect section attributes for %s"),
- name);
+ as_warn (_("Ignoring incorrect section type for %s"), name);
+ type = special_sections[i].type;
}
- attr |= special_sections[i].attributes;
- break;
}
-
- /* Convert ELF type and flags to BFD flags. */
- flags = (SEC_RELOC
- | ((attr & SHF_WRITE) ? 0 : SEC_READONLY)
- | ((attr & SHF_ALLOC) ? SEC_ALLOC : 0)
- | (((attr & SHF_ALLOC) && type != SHT_NOBITS) ? SEC_LOAD : 0)
- | ((attr & SHF_EXECINSTR) ? SEC_CODE : 0));
+ if ((attr &~ special_sections[i].attributes) != 0
+ && old_sec == NULL)
+ {
+ /* As a GNU extension, we permit a .note section to be
+ allocatable. If the linker sees an allocateable .note
+ section, it will create a PT_NOTE segment in the output
+ file. */
+ if (strcmp (name, ".note") != 0
+ || attr != SHF_ALLOC)
+ as_warn (_("Setting incorrect section attributes for %s"),
+ name);
+ }
+ attr |= special_sections[i].attributes;
+ break;
+ }
+
+ /* Convert ELF type and flags to BFD flags. */
+ flags = (SEC_RELOC
+ | ((attr & SHF_WRITE) ? 0 : SEC_READONLY)
+ | ((attr & SHF_ALLOC) ? SEC_ALLOC : 0)
+ | (((attr & SHF_ALLOC) && type != SHT_NOBITS) ? SEC_LOAD : 0)
+ | ((attr & SHF_EXECINSTR) ? SEC_CODE : 0)
+ | ((attr & SHF_MERGE) ? SEC_MERGE : 0)
+ | ((attr & SHF_STRINGS) ? SEC_STRINGS : 0));
#ifdef md_elf_section_flags
- flags = md_elf_section_flags (flags, attr, type);
+ flags = md_elf_section_flags (flags, attr, type);
#endif
+ if (old_sec == NULL)
+ {
+ symbolS *secsym;
+
/* Prevent SEC_HAS_CONTENTS from being inadvertently set. */
if (type == SHT_NOBITS)
seg_info (sec)->bss = 1;
bfd_set_section_flags (stdoutput, sec, flags);
+ if (flags & SEC_MERGE)
+ sec->entsize = entsize;
/* Add a symbol for this section to the symbol table. */
secsym = symbol_find (name);
else
symbol_table_insert (section_symbol (sec));
}
+ else if (attr != 0)
+ {
+ /* If section attributes are specified the second time we see a
+ particular section, then check that they are the same as we
+ saw the first time. */
+ if ((old_sec->flags ^ flags)
+ & (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
+ | SEC_EXCLUDE | SEC_SORT_ENTRIES | SEC_MERGE | SEC_STRINGS))
+ as_warn (_("Ignoring changed section attributes for %s"), name);
+ else if ((flags & SEC_MERGE) && old_sec->entsize != (unsigned) entsize)
+ as_warn (_("Ignoring changed section entity size for %s"), name);
+ }
#ifdef md_elf_section_change_hook
- md_elf_section_change_hook ();
+ md_elf_section_change_hook ();
#endif
}
-int
+static int
obj_elf_parse_section_letters (str, len)
char *str;
size_t len;
case 'x':
attr |= SHF_EXECINSTR;
break;
+ case 'M':
+ attr |= SHF_MERGE;
+ break;
+ case 'S':
+ attr |= SHF_STRINGS;
+ break;
default:
{
- char *bad_msg = _("Unrecognized .section attribute: want a,w,x");
+ char *bad_msg = _("Unrecognized .section attribute: want a,w,x,M,S");
#ifdef md_elf_section_letter
int md_attr = md_elf_section_letter (*str, &bad_msg);
if (md_attr >= 0)
else
#endif
{
- as_warn (bad_msg);
+ as_warn ("%s", bad_msg);
attr = -1;
}
}
return attr;
}
-int
+static int
obj_elf_section_word (str, len)
char *str;
size_t len;
return 0;
}
-int
+static int
obj_elf_section_type (str, len)
char *str;
size_t len;
{
char *name, *beg, *end;
int type, attr, dummy;
+ int entsize;
+#ifndef TC_I370
if (flag_mri)
{
char mri_type;
#ifdef md_flush_pending_output
- md_flush_pending_output ();
+ md_flush_pending_output ();
#endif
previous_section = now_seg;
return;
}
+#endif /* ! defined (TC_I370) */
/* Get name of section. */
SKIP_WHITESPACE ();
ignore_rest_of_line ();
return;
}
-
+
name = xmalloc (end - input_line_pointer + 1);
memcpy (name, input_line_pointer, end - input_line_pointer);
name[end - input_line_pointer] = '\0';
type = SHT_NULL;
attr = 0;
+ entsize = 0;
if (*input_line_pointer == ',')
{
type = obj_elf_section_type (beg, input_line_pointer - beg);
}
}
+
+ SKIP_WHITESPACE ();
+ if ((attr & SHF_MERGE) && *input_line_pointer == ',')
+ {
+ ++input_line_pointer;
+ SKIP_WHITESPACE ();
+ entsize = get_absolute_expression ();
+ if (entsize < 0)
+ {
+ as_warn (_("Bad .section directive - invalid merge entity size"));
+ attr &= ~SHF_MERGE;
+ entsize = 0;
+ }
+ }
}
else
{
demand_empty_rest_of_line ();
- obj_elf_change_section (name, type, attr, push);
+ if ((attr & SHF_MERGE) && entsize == 0)
+ {
+ as_warn (_("Entity size for SHF_MERGE not specified.\nSpecify entity size as 4th argument"));
+ attr &= SHF_MERGE;
+ }
+
+ obj_elf_change_section (name, type, attr, entsize, push);
}
/* Change to the .data section. */
int ignore ATTRIBUTE_UNUSED;
{
/* Assume delimiter is part of expression. BSD4.2 as fails with
- delightful bug, so we are not being incompatible here. */
+ delightful bug, so we are not being incompatible here. */
new_logical_line ((char *) NULL, (int) (get_absolute_expression ()));
demand_empty_rest_of_line ();
}
{
char *name;
char c;
+ char old_lexat;
symbolS *sym;
name = input_line_pointer;
*input_line_pointer = c;
- if (symbol_get_obj (sym)->versioned_name != NULL)
- {
- as_bad (_("multiple .symver directives for symbol `%s'"),
- S_GET_NAME (sym));
- ignore_rest_of_line ();
- return;
- }
-
SKIP_WHITESPACE ();
if (*input_line_pointer != ',')
{
++input_line_pointer;
name = input_line_pointer;
- while (1)
- {
- c = get_symbol_end ();
- if (c != ELF_VER_CHR)
- break;
- *input_line_pointer++ = c;
- }
- symbol_get_obj (sym)->versioned_name = xstrdup (name);
+ /* Temporarily include '@' in symbol names. */
+ old_lexat = lex_type[(unsigned char) '@'];
+ lex_type[(unsigned char) '@'] |= LEX_NAME;
+ c = get_symbol_end ();
+ lex_type[(unsigned char) '@'] = old_lexat;
- *input_line_pointer = c;
+ if (symbol_get_obj (sym)->versioned_name == NULL)
+ {
+ symbol_get_obj (sym)->versioned_name = xstrdup (name);
- if (strchr (symbol_get_obj (sym)->versioned_name, ELF_VER_CHR) == NULL)
+ *input_line_pointer = c;
+
+ if (strchr (symbol_get_obj (sym)->versioned_name,
+ ELF_VER_CHR) == NULL)
+ {
+ as_bad (_("missing version name in `%s' for symbol `%s'"),
+ symbol_get_obj (sym)->versioned_name,
+ S_GET_NAME (sym));
+ ignore_rest_of_line ();
+ return;
+ }
+ }
+ else
{
- as_bad (_("missing version name in `%s' for symbol `%s'"),
- symbol_get_obj (sym)->versioned_name, S_GET_NAME (sym));
- ignore_rest_of_line ();
- return;
+ if (strcmp (symbol_get_obj (sym)->versioned_name, name))
+ {
+ as_bad (_("multiple versions [`%s'|`%s'] for symbol `%s'"),
+ name, symbol_get_obj (sym)->versioned_name,
+ S_GET_NAME (sym));
+ ignore_rest_of_line ();
+ return;
+ }
+
+ *input_line_pointer = c;
}
demand_empty_rest_of_line ();
to the linker the hierarchy in which a particular table resides. The
syntax is ".vtable_inherit CHILDNAME, PARENTNAME". */
-static void
+struct fix *
obj_elf_vtable_inherit (ignore)
int ignore ATTRIBUTE_UNUSED;
{
{
as_bad ("expected comma after name in .vtable_inherit");
ignore_rest_of_line ();
- return;
+ return NULL;
}
++input_line_pointer;
if (input_line_pointer[0] == '0'
&& (input_line_pointer[1] == '\0'
- || isspace ((unsigned char) input_line_pointer[1])))
+ || ISSPACE (input_line_pointer[1])))
{
psym = section_symbol (absolute_section);
++input_line_pointer;
demand_empty_rest_of_line ();
if (bad)
- return;
+ return NULL;
assert (symbol_get_value_expression (csym)->X_op == O_constant);
- fix_new (symbol_get_frag (csym),
- symbol_get_value_expression (csym)->X_add_number, 0, psym, 0, 0,
- BFD_RELOC_VTABLE_INHERIT);
+ return fix_new (symbol_get_frag (csym),
+ symbol_get_value_expression (csym)->X_add_number,
+ 0, psym, 0, 0, BFD_RELOC_VTABLE_INHERIT);
}
-
+
/* This handles the .vtable_entry pseudo-op, which is used to indicate
to the linker that a vtable slot was used. The syntax is
".vtable_entry tablename, offset". */
-static void
+struct fix *
obj_elf_vtable_entry (ignore)
int ignore ATTRIBUTE_UNUSED;
{
{
as_bad ("expected comma after name in .vtable_entry");
ignore_rest_of_line ();
- return;
+ return NULL;
}
++input_line_pointer;
offset = get_absolute_expression ();
- fix_new (frag_now, frag_now_fix (), 0, sym, offset, 0,
- BFD_RELOC_VTABLE_ENTRY);
-
demand_empty_rest_of_line ();
+
+ return fix_new (frag_now, frag_now_fix (), 0, sym, offset, 0,
+ BFD_RELOC_VTABLE_ENTRY);
}
void
-obj_read_begin_hook ()
+elf_obj_read_begin_hook ()
{
#ifdef NEED_ECOFF_DEBUG
if (ECOFF_DEBUGGING)
}
void
-obj_symbol_new_hook (symbolP)
+elf_obj_symbol_new_hook (symbolP)
symbolS *symbolP;
{
struct elf_obj_sy *sy_obj;
#endif
}
+/* When setting one symbol equal to another, by default we probably
+ want them to have the same "size", whatever it means in the current
+ context. */
+
+void
+elf_copy_symbol_attributes (dest, src)
+ symbolS *dest, *src;
+{
+ struct elf_obj_sy *srcelf = symbol_get_obj (src);
+ struct elf_obj_sy *destelf = symbol_get_obj (dest);
+ if (srcelf->size)
+ {
+ if (destelf->size == NULL)
+ destelf->size =
+ (expressionS *) xmalloc (sizeof (expressionS));
+ *destelf->size = *srcelf->size;
+ }
+ else
+ {
+ if (destelf->size != NULL)
+ free (destelf->size);
+ destelf->size = NULL;
+ }
+ S_SET_SIZE (dest, S_GET_SIZE (src));
+ S_SET_OTHER (dest, S_GET_OTHER (src));
+}
+
void
obj_elf_version (ignore)
int ignore ATTRIBUTE_UNUSED;
SKIP_WHITESPACE ();
if (*input_line_pointer == '\"')
{
- ++input_line_pointer; /* -> 1st char of string. */
+ ++input_line_pointer; /* -> 1st char of string. */
name = input_line_pointer;
while (is_a_char (c = next_char_of_string ()))
sym = symbol_find_or_make (name);
*p = c;
if (exp.X_op == O_constant)
- S_SET_SIZE (sym, exp.X_add_number);
+ {
+ S_SET_SIZE (sym, exp.X_add_number);
+ if (symbol_get_obj (sym)->size)
+ {
+ xfree (symbol_get_obj (sym)->size);
+ symbol_get_obj (sym)->size = NULL;
+ }
+ }
else
{
symbol_get_obj (sym)->size =
}
/* Handle the ELF .type pseudo-op. This sets the type of a symbol.
- There are four syntaxes:
-
+ There are five syntaxes:
+
The first (used on Solaris) is
.type SYM,#function
The second (used on UnixWare) is
.type SYM STT_FUNC
The fourth (used on NetBSD/Arm and Linux/ARM) is
.type SYM,%function
+ The fifth (used on SVR4/860) is
+ .type SYM,"function"
*/
static void
int type;
const char *typename;
symbolS *sym;
+ elf_symbol_type *elfsym;
name = input_line_pointer;
c = get_symbol_end ();
sym = symbol_find_or_make (name);
+ elfsym = (elf_symbol_type *) symbol_get_bfdsym (sym);
*input_line_pointer = c;
SKIP_WHITESPACE ();
SKIP_WHITESPACE ();
if ( *input_line_pointer == '#'
|| *input_line_pointer == '@'
+ || *input_line_pointer == '"'
|| *input_line_pointer == '%')
++input_line_pointer;
else if (strcmp (typename, "object") == 0
|| strcmp (typename, "STT_OBJECT") == 0)
type = BSF_OBJECT;
+#ifdef md_elf_symbol_type
+ else if ((type = md_elf_symbol_type (typename, sym, elfsym)) != -1)
+ ;
+#endif
else
as_bad (_("ignoring unrecognized symbol type \"%s\""), typename);
*input_line_pointer = c;
- symbol_get_bfdsym (sym)->flags |= type;
+ if (*input_line_pointer == '"')
+ ++input_line_pointer;
+
+ elfsym->symbol.flags |= type;
demand_empty_rest_of_line ();
}
segT old_section = now_seg;
int old_subsection = now_subseg;
+#ifdef md_flush_pending_output
+ md_flush_pending_output ();
+#endif
+
if (!comment_section)
{
char *p;
UnixWare ar crashes. */
bfd_set_section_alignment (stdoutput, seg, 2);
- /* Make space for this first symbol. */
+ /* Make space for this first symbol. */
p = frag_more (12);
- /* Zero it out. */
+ /* Zero it out. */
memset (p, 0, 12);
as_where (&file, (unsigned int *) NULL);
stabstr_name = (char *) alloca (strlen (segment_name (seg)) + 4);
/*ARGSUSED*/
static void
elf_set_index (sym, indx)
- asymbol *sym;
- bfd_size_type indx;
+ asymbol *sym ATTRIBUTE_UNUSED;
+ bfd_size_type indx ATTRIBUTE_UNUSED;
{
}
if (sy_obj->versioned_name != NULL)
{
+ char *p;
+
+ p = strchr (sy_obj->versioned_name, ELF_VER_CHR);
+ know (p != NULL);
+
/* This symbol was given a new name with the .symver directive.
If this is an external reference, just rename the symbol to
if (! S_IS_DEFINED (symp))
{
- char *p;
-
/* Verify that the name isn't using the @@ syntax--this is
reserved for definitions of the default version to link
against. */
- p = strchr (sy_obj->versioned_name, ELF_VER_CHR);
- know (p != NULL);
if (p[1] == ELF_VER_CHR)
{
as_bad (_("invalid attempt to declare external version name as default in symbol `%s'"),
}
else
{
- symbolS *symp2;
+ if (p [1] == ELF_VER_CHR && p [2] == ELF_VER_CHR)
+ {
+ size_t l;
- /* FIXME: Creating a new symbol here is risky. We're in the
- final loop over the symbol table. We can get away with
- it only because the symbol goes to the end of the list,
- where the loop will still see it. It would probably be
- better to do this in obj_frob_file_before_adjust. */
+ /* The @@@ syntax is a special case. It renames the
+ symbol name to versioned_name with one `@' removed. */
+ l = strlen (&p[3]) + 1;
+ memmove (&p [2], &p[3], l);
+ S_SET_NAME (symp, sy_obj->versioned_name);
+ }
+ else
+ {
+ symbolS *symp2;
- symp2 = symbol_find_or_make (sy_obj->versioned_name);
+ /* FIXME: Creating a new symbol here is risky. We're
+ in the final loop over the symbol table. We can
+ get away with it only because the symbol goes to
+ the end of the list, where the loop will still see
+ it. It would probably be better to do this in
+ obj_frob_file_before_adjust. */
- /* Now we act as though we saw symp2 = sym. */
+ symp2 = symbol_find_or_make (sy_obj->versioned_name);
- S_SET_SEGMENT (symp2, S_GET_SEGMENT (symp));
+ /* Now we act as though we saw symp2 = sym. */
- /* Subtracting out the frag address here is a hack because
- we are in the middle of the final loop. */
- S_SET_VALUE (symp2,
- (S_GET_VALUE (symp)
- - symbol_get_frag (symp)->fr_address));
+ S_SET_SEGMENT (symp2, S_GET_SEGMENT (symp));
- symbol_set_frag (symp2, symbol_get_frag (symp));
+ /* Subtracting out the frag address here is a hack
+ because we are in the middle of the final loop. */
+ S_SET_VALUE (symp2,
+ (S_GET_VALUE (symp)
+ - symbol_get_frag (symp)->fr_address));
- /* This will copy over the size information. */
- copy_symbol_attributes (symp2, symp);
+ symbol_set_frag (symp2, symbol_get_frag (symp));
- if (S_IS_WEAK (symp))
- S_SET_WEAK (symp2);
+ /* This will copy over the size information. */
+ copy_symbol_attributes (symp2, symp);
- if (S_IS_EXTERNAL (symp))
- S_SET_EXTERNAL (symp2);
+ if (S_IS_WEAK (symp))
+ S_SET_WEAK (symp2);
+
+ if (S_IS_EXTERNAL (symp))
+ S_SET_EXTERNAL (symp2);
+ }
}
}
symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
#endif
-#ifdef TC_PPC
- /* Frob the PowerPC, so that the symbol always has object type
- if it is not some other type. VxWorks needs this. */
+#if 0 /* TC_PPC */
+ /* If TC_PPC is defined, we used to force the type of a symbol to be
+ BSF_OBJECT if it was otherwise unset. This was required by some
+ that this is no longer needed, so it is now commented out. */
if ((symbol_get_bfdsym (symp)->flags
& (BSF_FUNCTION | BSF_FILE | BSF_SECTION_SYM)) == 0
&& S_IS_DEFINED (symp))
#endif
}
+/* It removes any unneeded versioned symbols from the symbol table. */
+
+void
+elf_frob_file_before_adjust ()
+{
+ if (symbol_rootP)
+ {
+ symbolS *symp;
+
+ for (symp = symbol_rootP; symp; symp = symbol_next (symp))
+ if (symbol_get_obj (symp)->versioned_name)
+ {
+ if (!S_IS_DEFINED (symp))
+ {
+ char *p;
+
+ /* The @@@ syntax is a special case. If the symbol is
+ not defined, 2 `@'s will be removed from the
+ versioned_name. */
+
+ p = strchr (symbol_get_obj (symp)->versioned_name,
+ ELF_VER_CHR);
+ know (p != NULL);
+ if (p [1] == ELF_VER_CHR && p [2] == ELF_VER_CHR)
+ {
+ size_t l = strlen (&p[3]) + 1;
+ memmove (&p [1], &p[3], l);
+ }
+ if (symbol_used_p (symp) == 0
+ && symbol_used_in_reloc_p (symp) == 0)
+ symbol_remove (symp, &symbol_rootP, &symbol_lastP);
+ }
+ }
+ }
+}
+
/* It is required that we let write_relocs have the opportunity to
optimize away fixups before output has begun, since it is possible
to eliminate all fixups for a section and thus we never should
this? */
sec->_raw_size = bfd_ecoff_debug_size (stdoutput, &debug, debug_swap);
- if (! bfd_set_section_contents (stdoutput, sec, (PTR) NULL,
+ /* Pass BUF to bfd_set_section_contents because this will
+ eventually become a call to fwrite, and ISO C prohibits
+ passing a NULL pointer to a stdio function even if the
+ pointer will not be used. */
+ if (! bfd_set_section_contents (stdoutput, sec, (PTR) buf,
(file_ptr) 0, (bfd_size_type) 0))
as_fatal (_("Can't start writing .mdebug section: %s"),
bfd_errmsg (bfd_get_error ()));
SCO OpenServer 5 identifies it's ELF modules with a standard ELF
.note section.
- int_32 namesz = 4 ; Name size
- int_32 descsz = 12 ; Descriptive information
- int_32 type = 1 ;
- char name[4] = "SCO" ; Originator name ALWAYS SCO + NULL
+ int_32 namesz = 4 ; Name size
+ int_32 descsz = 12 ; Descriptive information
+ int_32 type = 1 ;
+ char name[4] = "SCO" ; Originator name ALWAYS SCO + NULL
int_32 version = (major ver # << 16) | version of tools ;
int_32 source = (tool_id << 16 ) | 1 ;
int_32 info = 0 ; These are set by the SCO tools, but we
- don't know enough about the source
+ don't know enough about the source
environment to set them. SCO ld currently
ignores them, and recommends we set them
to zero. */
/* process the version string */
- i_note.namesz = 4;
+ i_note.namesz = 4;
i_note.descsz = 12; /* 12 descriptive bytes */
i_note.type = NT_VERSION; /* Contains a version string */
md_number_to_chars (p, (valueT) i_note.type, 4);
p = frag_more (4);
- strcpy (p, "SCO");
+ strcpy (p, "SCO");
/* Note: this is the version number of the ELF we're representing */
p = frag_more (4);
and just set them to zero. */
p = frag_more (4);
md_number_to_chars (p, 0x0000, 4);
-
+
frag_align (2, 0, 0);
/* We probably can't restore the current segment, for there likely
#endif /* SCO_ELF */
+static int
+elf_separate_stab_sections ()
+{
+#ifdef NEED_ECOFF_DEBUG
+ return (!ECOFF_DEBUGGING);
+#else
+ return 1;
+#endif
+}
+
+static void
+elf_init_stab_section (seg)
+ segT seg;
+{
+#ifdef NEED_ECOFF_DEBUG
+ if (!ECOFF_DEBUGGING)
+#endif
+ obj_elf_init_stab_section (seg);
+}
+
const struct format_ops elf_format_ops =
{
bfd_target_elf_flavour,
- 0,
- 1,
+ 0, /* dfl_leading_underscore */
+ 1, /* emit_section_symbols */
+ elf_begin,
+ elf_file_symbol,
elf_frob_symbol,
elf_frob_file,
+ elf_frob_file_before_adjust,
elf_frob_file_after_relocs,
elf_s_get_size, elf_s_set_size,
elf_s_get_align, elf_s_set_align,
+ elf_s_get_other,
+ elf_s_set_other,
+ 0, /* s_get_desc */
+ 0, /* s_set_desc */
+ 0, /* s_get_type */
+ 0, /* s_set_type */
elf_copy_symbol_attributes,
#ifdef NEED_ECOFF_DEBUG
ecoff_generate_asm_lineno,
ecoff_stab,
#else
- 0,
- 0, /* process_stab */
+ 0, /* generate_asm_lineno */
+ 0, /* process_stab */
#endif
+ elf_separate_stab_sections,
+ elf_init_stab_section,
elf_sec_sym_ok_for_reloc,
elf_pop_insert,
#ifdef NEED_ECOFF_DEBUG
elf_ecoff_set_ext,
#else
- 0,
+ 0, /* ecoff_set_ext */
#endif
- obj_read_begin_hook,
- obj_symbol_new_hook,
+ elf_obj_read_begin_hook,
+ elf_obj_symbol_new_hook
};