X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gas%2Fconfig%2Fobj-elf.c;h=21fd0fa22411c5d5676eaec1db264a992f0feb1c;hb=52ccafd0351e92cb9afa9c96de6fecdad94bb4e4;hp=c20c3d459c5938525c309a90e857bf495dbe2dbe;hpb=623356292c94e0a7bfb8e055db1c9fdf14d799b7;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index c20c3d459c..21fd0fa224 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -1,5 +1,6 @@ /* ELF object file format - Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -45,6 +46,10 @@ #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 *)); @@ -65,19 +70,17 @@ static void obj_elf_type PARAMS ((int)); 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_common PARAMS ((int)); +static void obj_elf_visibility PARAMS ((int)); 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_data PARAMS ((int)); -static void obj_elf_text PARAMS ((int)); static void obj_elf_subsection PARAMS ((int)); static void obj_elf_popsection PARAMS ((int)); static const pseudo_typeS elf_pseudo_table[] = { {"comm", obj_elf_common, 0}, - {"common", obj_elf_common, 0}, + {"common", obj_elf_common, 1}, {"ident", obj_elf_ident, 0}, {"local", obj_elf_local, 0}, {"previous", obj_elf_previous, 0}, @@ -92,6 +95,11 @@ static const pseudo_typeS elf_pseudo_table[] = {"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}, @@ -115,7 +123,7 @@ static const pseudo_typeS elf_pseudo_table[] = {"text", obj_elf_text, 0}, /* End sentinel. */ - {NULL}, + {NULL, NULL, 0}, }; static const pseudo_typeS ecoff_debug_pseudo_table[] = @@ -160,7 +168,7 @@ static const pseudo_typeS ecoff_debug_pseudo_table[] = { "vreg", s_ignore, 0 }, #endif - {NULL} /* end sentinel */ + {NULL, NULL, 0} /* end sentinel */ }; #undef NO_RELOC @@ -218,6 +226,13 @@ elf_s_set_align (sym, align) 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; @@ -256,9 +271,9 @@ elf_file_symbol (s) #endif } -static void -obj_elf_common (ignore) - int ignore; +void +obj_elf_common (is_common) + int is_common; { char *name; char c; @@ -267,6 +282,12 @@ obj_elf_common (ignore) symbolS *symbolP; int have_align; + if (flag_mri && is_common) + { + s_mri_common (0); + return; + } + name = input_line_pointer; c = get_symbol_end (); /* just after name is now '\0' */ @@ -298,7 +319,7 @@ obj_elf_common (ignore) } if (S_GET_VALUE (symbolP) != 0) { - if (S_GET_VALUE (symbolP) != size) + if (S_GET_VALUE (symbolP) != (valueT) size) { as_warn (_("Length of .comm \"%s\" is already %ld. Not changed to %d."), S_GET_NAME (symbolP), (long) S_GET_VALUE (symbolP), size); @@ -415,7 +436,7 @@ obj_elf_common (ignore) static void obj_elf_local (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; int c; @@ -444,7 +465,7 @@ obj_elf_local (ignore) static void obj_elf_weak (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; int c; @@ -471,6 +492,48 @@ obj_elf_weak (ignore) 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; @@ -668,7 +731,7 @@ obj_elf_parse_section_letters (str, len) else #endif { - as_warn (bad_msg); + as_warn ("%s", bad_msg); attr = -1; } } @@ -733,6 +796,7 @@ obj_elf_section (push) char *name, *beg, *end; int type, attr, dummy; +#ifndef TC_I370 if (flag_mri) { char mri_type; @@ -752,6 +816,7 @@ obj_elf_section (push) return; } +#endif /* ! defined (TC_I370) */ /* Get name of section. */ SKIP_WHITESPACE (); @@ -775,7 +840,7 @@ obj_elf_section (push) 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'; @@ -861,7 +926,7 @@ obj_elf_section (push) /* Change to the .data section. */ -static void +void obj_elf_data (i) int i; { @@ -880,7 +945,7 @@ obj_elf_data (i) /* Change to the .text section. */ -static void +void obj_elf_text (i) int i; { @@ -899,7 +964,7 @@ obj_elf_text (i) static void obj_elf_subsection (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { register int temp; @@ -931,7 +996,7 @@ obj_elf_section_change_hook () void obj_elf_previous (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { segT new_section; int new_subsection; @@ -959,7 +1024,7 @@ obj_elf_previous (ignore) static void obj_elf_popsection (xxx) - int xxx; + int xxx ATTRIBUTE_UNUSED; { struct section_stack *top = section_stack; @@ -986,7 +1051,7 @@ obj_elf_popsection (xxx) static void obj_elf_line (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { /* Assume delimiter is part of expression. BSD4.2 as fails with delightful bug, so we are not being incompatible here. */ @@ -1002,7 +1067,7 @@ obj_elf_line (ignore) static void obj_elf_symver (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; char c; @@ -1062,6 +1127,7 @@ obj_elf_symver (ignore) static void obj_elf_vtable_inherit (ignore) + int ignore ATTRIBUTE_UNUSED; { char *cname, *pname; symbolS *csym, *psym; @@ -1126,13 +1192,14 @@ obj_elf_vtable_inherit (ignore) 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 obj_elf_vtable_entry (ignore) + int ignore ATTRIBUTE_UNUSED; { char *name; symbolS *sym; @@ -1168,7 +1235,7 @@ obj_elf_vtable_entry (ignore) } void -obj_read_begin_hook () +elf_obj_read_begin_hook () { #ifdef NEED_ECOFF_DEBUG if (ECOFF_DEBUGGING) @@ -1177,7 +1244,7 @@ obj_read_begin_hook () } void -obj_symbol_new_hook (symbolP) +elf_obj_symbol_new_hook (symbolP) symbolS *symbolP; { struct elf_obj_sy *sy_obj; @@ -1194,7 +1261,7 @@ obj_symbol_new_hook (symbolP) void obj_elf_version (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; unsigned int c; @@ -1261,7 +1328,7 @@ obj_elf_version (ignore) static void obj_elf_size (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name = input_line_pointer; char c = get_symbol_end (); @@ -1304,7 +1371,7 @@ obj_elf_size (ignore) /* Handle the ELF .type pseudo-op. This sets the type of a symbol. There are four syntaxes: - + The first (used on Solaris) is .type SYM,#function The second (used on UnixWare) is @@ -1317,7 +1384,7 @@ obj_elf_size (ignore) static void obj_elf_type (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; char c; @@ -1362,12 +1429,16 @@ obj_elf_type (ignore) static void obj_elf_ident (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { static segT comment_section; 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; @@ -1422,7 +1493,7 @@ static void adjust_stab_sections (abfd, sec, xxx) bfd *abfd; asection *sec; - PTR xxx; + PTR xxx ATTRIBUTE_UNUSED; { char *name; asection *strsec; @@ -1488,8 +1559,8 @@ elf_get_extr (sym, ext) /*ARGSUSED*/ static void elf_set_index (sym, indx) - asymbol *sym; - bfd_size_type indx; + asymbol *sym ATTRIBUTE_UNUSED; + bfd_size_type indx ATTRIBUTE_UNUSED; { } @@ -1622,9 +1693,11 @@ elf_frob_symbol (symp, puntp) 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 + version of VxWorks. Thomas de Lellis says + 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)) @@ -1700,7 +1773,11 @@ elf_frob_file_after_relocs () 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 ())); @@ -1731,14 +1808,14 @@ elf_frob_file_after_relocs () 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. */ @@ -1770,7 +1847,7 @@ sco_id () /* 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 */ @@ -1784,7 +1861,7 @@ sco_id () 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); @@ -1801,7 +1878,7 @@ sco_id () 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 @@ -1816,28 +1893,30 @@ sco_id () const struct format_ops elf_format_ops = { bfd_target_elf_flavour, - 0, - 1, + 0, /* dfl_leading_underscore */ + 1, /* emit_section_symbols */ elf_frob_symbol, elf_frob_file, 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, + 0, /* s_get_desc */ 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_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, };