1993-05-27 19:42:23 +00:00
|
|
|
/* ELF object file format
|
|
|
|
Copyright (C) 1992, 1993 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
This file is part of GAS, the GNU Assembler.
|
|
|
|
|
|
|
|
GAS is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2,
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
GAS is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
|
|
|
the GNU General Public License for more details.
|
|
|
|
|
|
|
|
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
|
|
|
|
|
|
#include "as.h"
|
1993-07-07 16:40:30 +00:00
|
|
|
#include "subsegs.h"
|
1993-05-27 19:42:23 +00:00
|
|
|
#include "aout/stab_gnu.h"
|
|
|
|
#include "obstack.h"
|
|
|
|
|
|
|
|
static void obj_elf_stab PARAMS ((int what));
|
1993-07-07 16:40:30 +00:00
|
|
|
static void obj_elf_xstab PARAMS ((int what));
|
1993-05-27 19:42:23 +00:00
|
|
|
static void obj_elf_line PARAMS ((void));
|
1993-07-07 16:40:30 +00:00
|
|
|
void obj_elf_desc PARAMS ((void));
|
|
|
|
void obj_elf_version PARAMS ((void));
|
1993-05-27 19:42:23 +00:00
|
|
|
static void obj_elf_section PARAMS ((int));
|
|
|
|
static void obj_elf_size PARAMS ((void));
|
|
|
|
static void obj_elf_type PARAMS ((void));
|
|
|
|
static void obj_elf_ident PARAMS ((void));
|
1993-07-19 19:49:34 +00:00
|
|
|
static void obj_elf_previous PARAMS ((void));
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
const pseudo_typeS obj_pseudo_table[] =
|
|
|
|
{
|
|
|
|
{"ident", obj_elf_ident, 0},
|
1993-07-19 19:49:34 +00:00
|
|
|
{"previous", obj_elf_previous, 0},
|
1993-07-07 16:40:30 +00:00
|
|
|
{"section", obj_elf_section, 0},
|
|
|
|
{"size", obj_elf_size, 0},
|
|
|
|
{"type", obj_elf_type, 0},
|
|
|
|
{"version", obj_elf_version, 0},
|
|
|
|
|
|
|
|
/* These are used for stabs-in-elf configurations. */
|
|
|
|
{"desc", obj_elf_desc, 0},
|
|
|
|
{"line", obj_elf_line, 0},
|
|
|
|
{"stabd", obj_elf_stab, 'd'},
|
|
|
|
{"stabn", obj_elf_stab, 'n'},
|
|
|
|
{"stabs", obj_elf_stab, 's'},
|
|
|
|
/* This is used on Solaris 2.x on SPARC, but not supported yet. */
|
|
|
|
{"xstabs", obj_elf_xstab, 's'},
|
|
|
|
|
1993-07-19 19:49:34 +00:00
|
|
|
/* These are used for dwarf. */
|
|
|
|
{"2byte", cons, 2},
|
|
|
|
{"4byte", cons, 4},
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
{NULL} /* end sentinel */
|
1993-05-27 19:42:23 +00:00
|
|
|
};
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
#include "aout/aout64.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
elf_file_symbol (s)
|
|
|
|
char *s;
|
|
|
|
{
|
|
|
|
symbolS *sym;
|
|
|
|
|
|
|
|
sym = symbol_new (s, absolute_section, (valueT) 0, (struct frag *) 0);
|
|
|
|
sym->sy_frag = &zero_address_frag;
|
|
|
|
sym->bsym->flags |= BSF_FILE;
|
|
|
|
|
|
|
|
if (symbol_rootP != sym)
|
|
|
|
{
|
|
|
|
symbol_remove (sym, &symbol_rootP, &symbol_lastP);
|
|
|
|
symbol_insert (sym, symbol_rootP, &symbol_rootP, &symbol_lastP);
|
|
|
|
#ifdef DEBUG
|
|
|
|
verify_symbol_chain (symbol_rootP, symbol_lastP);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1993-07-19 19:49:34 +00:00
|
|
|
static segT previous_section;
|
|
|
|
static int previous_subsection;
|
|
|
|
|
1993-05-27 19:42:23 +00:00
|
|
|
static void
|
|
|
|
obj_elf_section (xxx)
|
|
|
|
int xxx;
|
|
|
|
{
|
|
|
|
char *string;
|
|
|
|
asection *sec;
|
|
|
|
|
|
|
|
/* Initialize this with inclusive-or of all flags that can be cleared
|
|
|
|
by attributes, but not set by them. Also include flags that won't
|
|
|
|
get set properly in the assembler, but which the user/compiler
|
|
|
|
shouldn't be expected to set. */
|
|
|
|
flagword flags = SEC_READONLY | SEC_ALLOC | SEC_RELOC;
|
|
|
|
/* Initialize this with the default flags to be used if none are
|
|
|
|
specified. */
|
1993-07-19 19:49:34 +00:00
|
|
|
flagword default_flags = 0;
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-19 19:49:34 +00:00
|
|
|
SKIP_WHITESPACE ();
|
|
|
|
if (*input_line_pointer == '"')
|
|
|
|
string = demand_copy_C_string (&xxx);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *p = input_line_pointer;
|
|
|
|
char c;
|
|
|
|
while (0 == strchr ("\n\t,; ", *p))
|
|
|
|
p++;
|
|
|
|
c = *p;
|
|
|
|
*p = 0;
|
|
|
|
string = xmalloc (p - input_line_pointer + 1);
|
|
|
|
strcpy (string, input_line_pointer);
|
|
|
|
*p = c;
|
|
|
|
input_line_pointer = p;
|
|
|
|
}
|
|
|
|
if (!strcmp (string, ".rodata"))
|
|
|
|
default_flags = SEC_ALLOC | SEC_READONLY | SEC_RELOC;
|
1993-05-27 19:42:23 +00:00
|
|
|
SKIP_WHITESPACE ();
|
|
|
|
if (*input_line_pointer != ',')
|
|
|
|
flags = default_flags;
|
|
|
|
while (*input_line_pointer == ',')
|
|
|
|
{
|
|
|
|
flagword bit;
|
|
|
|
int len, inv;
|
|
|
|
char *p, oldp;
|
|
|
|
|
|
|
|
input_line_pointer++;
|
1993-07-12 15:17:10 +00:00
|
|
|
if (*input_line_pointer != '#' && *input_line_pointer != '@')
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
|
|
|
as_bad ("unrecognized syntax in .section command");
|
|
|
|
ignore_rest_of_line ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
input_line_pointer++;
|
|
|
|
|
|
|
|
#define CHECK(X,BIT,NEG) \
|
|
|
|
if (!strncmp(X,input_line_pointer,len = sizeof(X) - 1)) { \
|
|
|
|
bit = BIT; inv = NEG; goto match; }
|
|
|
|
|
|
|
|
CHECK ("write", SEC_READONLY, 1);
|
|
|
|
CHECK ("alloc", SEC_ALLOC, 0);
|
1993-07-12 15:17:10 +00:00
|
|
|
CHECK ("execinstr", SEC_CODE, 1);
|
1993-05-27 19:42:23 +00:00
|
|
|
#undef CHECK
|
|
|
|
|
|
|
|
p = input_line_pointer;
|
|
|
|
while (!is_end_of_line[*p] && *p != 0 && *p != ',')
|
|
|
|
p++;
|
|
|
|
*p = 0;
|
|
|
|
oldp = *p;
|
|
|
|
as_bad ("unrecognized section attribute `%s' ignored",
|
|
|
|
input_line_pointer);
|
|
|
|
*p = oldp;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
match:
|
|
|
|
if (inv)
|
|
|
|
flags &= ~bit;
|
|
|
|
else
|
|
|
|
flags |= bit;
|
|
|
|
input_line_pointer += len;
|
|
|
|
}
|
|
|
|
demand_empty_rest_of_line ();
|
|
|
|
|
1993-07-19 19:49:34 +00:00
|
|
|
/* If the C string wasn't valid, `string' could be null. */
|
|
|
|
if (!string)
|
|
|
|
return;
|
|
|
|
|
1993-05-27 19:42:23 +00:00
|
|
|
sec = bfd_get_section_by_name (stdoutput, string);
|
|
|
|
if (sec == 0)
|
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
sec = subseg_new (string, 0);
|
|
|
|
bfd_set_section_flags (stdoutput, sec, flags);
|
1993-05-27 19:42:23 +00:00
|
|
|
sec->output_section = sec;
|
|
|
|
}
|
1993-07-19 19:49:34 +00:00
|
|
|
previous_section = now_seg;
|
|
|
|
previous_subsection = now_subseg;
|
1993-07-07 16:40:30 +00:00
|
|
|
subseg_set (sec, 0);
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
1993-07-19 19:49:34 +00:00
|
|
|
static void
|
|
|
|
obj_elf_previous ()
|
|
|
|
{
|
|
|
|
if (previous_section == 0)
|
|
|
|
{
|
|
|
|
as_bad (".previous without corresponding .section; ignored");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
subseg_set (previous_section, previous_subsection);
|
|
|
|
previous_section = 0;
|
|
|
|
}
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
int
|
|
|
|
obj_elf_write_symbol_p (sym)
|
|
|
|
symbolS *sym;
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
/* If this is a local symbol, are there any relocations for which
|
|
|
|
need this symbol? */
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
/* To find this out, we examine all relocations in all bfd sections
|
|
|
|
that have relocations. If there is one that references this
|
|
|
|
symbol, we need to keep this symbol. In this case, we return a
|
|
|
|
true status. In all other cases, we return a false status. */
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
if (S_IS_LOCAL (sym))
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
asymbol *bsym = sym->bsym;
|
|
|
|
bfd *abfd = bsym->the_bfd;
|
|
|
|
asection *bsec;
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
for (bsec = abfd->sections; bsec; bsec = bsec->next)
|
|
|
|
{
|
|
|
|
struct reloc_cache_entry **rlocs = bsec->orelocation;
|
|
|
|
int rcnt = bsec->reloc_count;
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
if (rlocs)
|
|
|
|
{
|
|
|
|
int i;
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
for (i = 0; i < rcnt; i++)
|
|
|
|
if (rlocs[i]->sym_ptr_ptr
|
|
|
|
&& rlocs[i]->sym_ptr_ptr[0] == bsym)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* No relocations for this section. Check the seg_info
|
|
|
|
structure to see if there are any fixups for this
|
|
|
|
section. */
|
|
|
|
segment_info_type *seginfo = seg_info (bsec);
|
|
|
|
fixS *fixp;
|
|
|
|
|
|
|
|
for (fixp = seginfo->fix_root; fixp; fixp = fixp->fx_next)
|
|
|
|
if ((fixp->fx_addsy && fixp->fx_addsy->bsym == bsym)
|
|
|
|
|| (fixp->fx_subsy && fixp->fx_subsy->bsym == bsym))
|
|
|
|
return 1;
|
|
|
|
}
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
}
|
1993-07-07 16:40:30 +00:00
|
|
|
return 0;
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
int
|
|
|
|
obj_elf_write_symbol (sym)
|
|
|
|
symbolS *sym;
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
return /* obj_elf_write_symbol_p (sym) || */ !S_IS_LOCAL (sym);
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
obj_elf_frob_symbol (sym, punt)
|
|
|
|
symbolS *sym;
|
|
|
|
int *punt;
|
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
return obj_elf_write_symbol_p (sym);
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
static void
|
|
|
|
obj_elf_line ()
|
|
|
|
{
|
|
|
|
/* Assume delimiter is part of expression. BSD4.2 as fails with
|
|
|
|
delightful bug, so we are not being incompatible here. */
|
|
|
|
new_logical_line ((char *) NULL, (int) (get_absolute_expression ()));
|
|
|
|
demand_empty_rest_of_line ();
|
|
|
|
}
|
1993-05-27 19:42:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* stab()
|
|
|
|
*
|
|
|
|
* Handle .stabX directives, which used to be open-coded.
|
|
|
|
* So much creeping featurism overloaded the semantics that we decided
|
|
|
|
* to put all .stabX thinking in one place. Here.
|
|
|
|
*
|
|
|
|
* We try to make any .stabX directive legal. Other people's AS will often
|
|
|
|
* do assembly-time consistency checks: eg assigning meaning to n_type bits
|
|
|
|
* and "protecting" you from setting them to certain values. (They also zero
|
|
|
|
* certain bits before emitting symbols. Tut tut.)
|
|
|
|
*
|
|
|
|
* If an expression is not absolute we either gripe or use the relocation
|
|
|
|
* information. Other people's assemblers silently forget information they
|
|
|
|
* don't need and invent information they need that you didn't supply.
|
|
|
|
*
|
|
|
|
* .stabX directives always make a symbol table entry. It may be junk if
|
|
|
|
* the rest of your .stabX directive is malformed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1993-07-07 16:40:30 +00:00
|
|
|
* elf_stab_symbol_string()
|
1993-05-27 19:42:23 +00:00
|
|
|
*
|
|
|
|
* Build a string dictionary entry for a .stabX symbol.
|
|
|
|
* The symbol is added to the .stabstr section.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static unsigned int
|
1993-07-07 16:40:30 +00:00
|
|
|
elf_stab_symbol_string (string, secname)
|
|
|
|
char *string, *secname;
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
|
|
|
asection *save_seg;
|
|
|
|
asection *seg;
|
|
|
|
subsegT save_subseg;
|
|
|
|
unsigned int length;
|
|
|
|
unsigned int old_gdb_string_index;
|
|
|
|
char *clengthP;
|
|
|
|
int i;
|
|
|
|
char c;
|
1993-07-07 16:40:30 +00:00
|
|
|
/* @@FIXME -- there should be no static data here!
|
|
|
|
This also has the effect of making all stab string tables large enough
|
|
|
|
to contain all the contents written to any of them. This only matters
|
|
|
|
with the Solaris native compiler for the moment, but it should be fixed
|
|
|
|
anyways. */
|
|
|
|
static unsigned int gdb_string_index = 0;
|
1993-05-27 19:42:23 +00:00
|
|
|
|
|
|
|
old_gdb_string_index = 0;
|
1993-07-07 16:40:30 +00:00
|
|
|
length = strlen (string);
|
|
|
|
clengthP = (char *) &length;
|
|
|
|
if (length > 0)
|
|
|
|
{ /* Ordinary case. */
|
|
|
|
save_seg = now_seg;
|
|
|
|
save_subseg = now_subseg;
|
|
|
|
|
|
|
|
/* Create the stab sections, if they are not already created. */
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
char *newsecname = xmalloc (strlen (secname) + 4);
|
|
|
|
strcpy (newsecname, secname);
|
|
|
|
strcat (newsecname, "str");
|
|
|
|
seg = bfd_get_section_by_name (stdoutput, newsecname);
|
|
|
|
if (seg == 0)
|
|
|
|
{
|
|
|
|
seg = bfd_make_section_old_way (stdoutput, newsecname);
|
|
|
|
bfd_set_section_flags (stdoutput, seg, SEC_READONLY | SEC_ALLOC);
|
|
|
|
}
|
|
|
|
/* free (newsecname);*/
|
|
|
|
}
|
|
|
|
subseg_new ((char *) seg->name, save_subseg);
|
|
|
|
old_gdb_string_index = gdb_string_index;
|
|
|
|
i = 0;
|
|
|
|
while ((c = *string++))
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
gdb_string_index++;
|
|
|
|
FRAG_APPEND_1_CHAR (c);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
FRAG_APPEND_1_CHAR ((char) 0);
|
1993-05-27 19:42:23 +00:00
|
|
|
i++;
|
1993-07-07 16:40:30 +00:00
|
|
|
gdb_string_index++;
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
1993-07-07 16:40:30 +00:00
|
|
|
while (i % 4 != 0)
|
|
|
|
{
|
|
|
|
FRAG_APPEND_1_CHAR ((char) 0);
|
|
|
|
i++;
|
|
|
|
gdb_string_index++;
|
|
|
|
}
|
|
|
|
subseg_new ((char *) save_seg->name, save_subseg);
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return old_gdb_string_index;
|
|
|
|
}
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
static void
|
|
|
|
DEFUN (elf_stab_symbol, (symbolP, stab_type),
|
|
|
|
symbolS *symbolP AND
|
|
|
|
int stab_type)
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
|
|
|
char *toP;
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
toP = frag_more (8);
|
1993-05-27 19:42:23 +00:00
|
|
|
/* the string index portion of the stab */
|
1993-07-07 16:40:30 +00:00
|
|
|
md_number_to_chars (toP, (valueT) symbolP->sy_name_offset, 4);
|
|
|
|
md_number_to_chars (toP + 4, (valueT) S_GET_TYPE (symbolP), 1);
|
|
|
|
md_number_to_chars (toP + 5, (valueT) S_GET_OTHER (symbolP), 1);
|
|
|
|
md_number_to_chars (toP + 6, (valueT) S_GET_DESC (symbolP), 2);
|
|
|
|
/* The n_value field doesn't get written here, it gets done below. It
|
|
|
|
may be an expression needing relocating. */
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
static void
|
|
|
|
obj_elf_stab_generic (what, secname)
|
1993-05-27 19:42:23 +00:00
|
|
|
int what;
|
1993-07-07 16:40:30 +00:00
|
|
|
char *secname;
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
|
|
|
extern int listing;
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
symbolS *symbolP = 0;
|
|
|
|
char *string;
|
1993-05-27 19:42:23 +00:00
|
|
|
int saved_type = 0;
|
|
|
|
int length;
|
|
|
|
int goof = 0;
|
|
|
|
long longint;
|
|
|
|
asection *saved_seg = now_seg;
|
|
|
|
asection *seg;
|
|
|
|
subsegT subseg = now_subseg;
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
#if 1
|
|
|
|
/* This function doesn't work yet.
|
|
|
|
|
|
|
|
Actually, this function is okay, but some finalizations are needed
|
|
|
|
before writing the object file; that's not done yet, and the Solaris
|
|
|
|
linker chokes without it.
|
|
|
|
|
|
|
|
In any case, this should effectively disable it for now. */
|
|
|
|
if (what == 's')
|
|
|
|
demand_copy_C_string (&length);
|
|
|
|
s_ignore (69);
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
seg = bfd_get_section_by_name (stdoutput, secname);
|
|
|
|
if (seg == 0)
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
seg = subseg_new (secname, 0);
|
|
|
|
bfd_set_section_flags (stdoutput, seg,
|
|
|
|
SEC_READONLY | SEC_ALLOC | SEC_RELOC);
|
|
|
|
subseg_set (saved_seg, subseg);
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enter with input_line_pointer pointing past .stabX and any following
|
|
|
|
* whitespace.
|
|
|
|
*/
|
1993-07-07 16:40:30 +00:00
|
|
|
if (what == 's')
|
|
|
|
{
|
|
|
|
string = demand_copy_C_string (&length);
|
|
|
|
SKIP_WHITESPACE ();
|
|
|
|
if (*input_line_pointer == ',')
|
|
|
|
input_line_pointer++;
|
1993-05-27 19:42:23 +00:00
|
|
|
else
|
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
as_bad ("I need a comma after symbol's name");
|
1993-05-27 19:42:23 +00:00
|
|
|
goof = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
string = "";
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Input_line_pointer->after ','. String->symbol name.
|
|
|
|
*/
|
1993-07-07 16:40:30 +00:00
|
|
|
if (!goof)
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
symbolP = symbol_new (string, &bfd_und_section, (valueT) 0, (struct frag *) 0);
|
1993-05-27 19:42:23 +00:00
|
|
|
|
|
|
|
/* enter the string in the .stab string table (section .stabstr) */
|
1993-07-07 16:40:30 +00:00
|
|
|
symbolP->sy_name_offset = elf_stab_symbol_string (string, secname);
|
1993-05-27 19:42:23 +00:00
|
|
|
|
|
|
|
switch (what)
|
|
|
|
{
|
|
|
|
case 'd':
|
1993-07-07 16:40:30 +00:00
|
|
|
S_SET_NAME (symbolP, NULL); /* .stabd feature. */
|
|
|
|
S_SET_VALUE (symbolP,
|
|
|
|
(valueT) ((char*) obstack_next_free (&frags) - frag_now->fr_literal));
|
|
|
|
S_SET_SEGMENT (symbolP, now_seg);
|
1993-05-27 19:42:23 +00:00
|
|
|
symbolP->sy_frag = frag_now;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'n':
|
|
|
|
symbolP->sy_frag = &zero_address_frag;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 's':
|
1993-07-07 16:40:30 +00:00
|
|
|
symbolP->sy_frag = &zero_address_frag;
|
1993-05-27 19:42:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1993-07-07 16:40:30 +00:00
|
|
|
BAD_CASE (what);
|
1993-05-27 19:42:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
if (get_absolute_expression_and_terminator (&longint) == ',')
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
|
|
|
saved_type = longint;
|
|
|
|
S_SET_TYPE (symbolP, saved_type);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
as_bad ("I want a comma after the n_type expression");
|
1993-05-27 19:42:23 +00:00
|
|
|
goof = 1;
|
1993-07-07 16:40:30 +00:00
|
|
|
input_line_pointer--; /* Backup over a non-',' char. */
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!goof)
|
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
if (get_absolute_expression_and_terminator (&longint) == ',')
|
|
|
|
S_SET_OTHER (symbolP, longint);
|
1993-05-27 19:42:23 +00:00
|
|
|
else
|
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
as_bad ("I want a comma after the n_other expression");
|
1993-05-27 19:42:23 +00:00
|
|
|
goof = 1;
|
1993-07-07 16:40:30 +00:00
|
|
|
input_line_pointer--; /* Backup over a non-',' char. */
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!goof)
|
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
S_SET_DESC (symbolP, get_absolute_expression ());
|
1993-05-27 19:42:23 +00:00
|
|
|
if (what == 's' || what == 'n')
|
|
|
|
{
|
|
|
|
if (*input_line_pointer != ',')
|
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
as_bad ("I want a comma after the n_desc expression");
|
1993-05-27 19:42:23 +00:00
|
|
|
goof = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
input_line_pointer++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
if (!goof)
|
|
|
|
{
|
|
|
|
subseg_new ((char *) seg->name, subseg);
|
|
|
|
|
|
|
|
/* Emit the stab symbol. */
|
|
|
|
elf_stab_symbol (symbolP, what);
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
if (what == 's' || what == 'n')
|
|
|
|
{
|
|
|
|
cons (4);
|
|
|
|
input_line_pointer--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *p = frag_more (4);
|
|
|
|
md_number_to_chars (p, 0, 0);
|
|
|
|
}
|
|
|
|
subseg_new ((char *) saved_seg->name, subseg);
|
|
|
|
|
|
|
|
if ((what == 's' || what == 'n')
|
* Extensive changes to permit symbols to contain any expression
type and to delay the computation of the expression until the
value is actually needed. This permits setting symbols to values
calculated based on object code size. Expressions were changed to
no longer be in a section, to stop the overloading of segment and
expression type that previously occurred.
* as.c (big_section, pass1_section, diff_section, absent_section):
Removed.
(expr_section): Added (used for dummy symbols which hold
intermediate expression values).
(perform_an_assembly_pass): Create expr_section, do not create the
sections now removed.
* as.h (segT): Removed SEG_ABSENT, SEG_PASS1, SEG_BIG, and
SEG_DIFFERENCE. Added SEG_EXPR.
(SEG_NORMAL): Corresponding changes.
* subsegs.c (seg_name, subsegs_begin): Changed accordingly.
* write.c (write_object_file): Ditto.
* config/obj-aout.c (seg_N_TYPE): Ditto.
* config/obj-bout.c (seg_N_TYPE): Ditto.
* config/obj-coff.c (seg_N_TYPE): Ditto.
* config/obj-coffbfd.c (seg_N_TYPE): Ditto.
* config/obj-vms.c (seg_N_TYPE): Ditto.
* expr.h (operatorT): Moved in from expr.c, added some values.
(expressionS): Added X_op field, removed X_seg field; renamed
X_subtract_symbol to X_op_symbol.
* expr.c: Extensive changes to assign expression types rather than
sections and to simplify the parsing.
* write.c (fix_new_internal): New static function.
(fix_new): Removed sub_symbol argument.
(fix_new_exp): New function, takes expression argument.
* write.h: Prototype changes for fix_new and fix_new_exp.
* cond.c (s_if): Changed accordingly.
* read.c (s_lsym, pseudo_set, emit_expr, parse_bitfield_cons,
parse_repeat_cons, get_segmented_expression,
get_known_segmented_expression, get_absolute_expression): Ditto.
* symbols.c (resolve_symbol_value, S_GET_VALUE, S_SET_VALUE):
Ditto.
* write.c (write_object_file): Ditto.
* config/obj-coff.c (obj_coff_def, obj_coff_val): Ditto.
* config/obj-coffbfd.c (obj_coff_def, obj_coff_val,
obj_coff_endef, yank_symbols): Ditto.
* config/obj-elf.c (obj_elf_stab_generic, obj_elf_size): Ditto.
* config/tc-a29k.c (md_assemble, parse_operand, machine_ip,
print_insn, md_operand): Ditto.
* config/tc-h8300.c (parse_exp, colonmod24, check_operand,
do_a_fix_imm, build_bytes): Ditto.
* config/tc-h8500.c (parse_exp, skip_colonthing, parse_reglist,
get_specific, check, insert, md_convert_frag): Ditto.
* config/tc-hppa.c (the_insn, fix_new_hppa, cons_fix_new_hppa,
md_assemble, pa_ip, getExpression, getAbsoluteExpression,
evaluateAbsolute, pa_build_unwind_subspace, pa_entry,
process_exit): Ditto.
* config/tc-hppa.h (STAB_FIXUP, is_DP_relative, is_PC_relative,
is_complex): Ditto.
* config/tc-i386.c (pe, md_assemble, i386_operand,
md_estimate_size_before_relax, md_create_long_jump): Ditto.
* config/tc-i860.c (md_assemble, getExpression, print_insn):
Ditto.
* config/tc-i960.c (parse_expr, subs, segs, md_convert_frag,
get_cdisp, mem_fmt, parse_ldconst, relax_cobr, s_sysproc,
i960_handle_align): Ditto.
* config/tc-m68k.c (struct m68k_exp, struct m68k_it, seg, op,
subs, add_fix, isvar, m68k_ip, md_assemble, md_convert_frag_1,
md_estimate_size_before_relax, md_create_long_jump, get_num):
Ditto.
* config/tc-m88k.c (md_assemble, get_imm16, get_pcr,
md_create_short_jump, md_create_long_jump): Ditto.
* config/tc-mips.c (md_assemble, append_insn, gp_reference,
macro_build, macro, my_getExpression): Ditto. Also removed
get_optional_absolute_expression; just use get_absolute_expression
instead.
* config/tc-ns32k.c (get_addr_mode, evaluate_expr, convert_iif,
fix_new_ns32k, fix_new_ns32k_exp, cons_fix_new_ns32k): Ditto.
* config/tc-ns32k.h (fix_new_ns32k prototype): Ditto.
* config/tc-sh.c (parse_exp, check, insert, md_convert_frag):
Ditto.
* config/tc-sparc.c (md_assemble, sparc_ip, getExpression,
print_insn): Ditto.
* config/tc-tahoe.c (struct top, md_estimate_size_before_relax,
tip_op, md_assemble): Ditto.
* config/tc-vax.c (seg_of_operand, md_assemble,
md_estimate_size_before_relax, md_create_long_jump): Ditto.
* config/tc-z8k.c (parse_exp, check_operand, newfix): Ditto.
1993-07-21 00:41:42 +00:00
|
|
|
&& symbolP->sy_value.X_op == O_constant)
|
1993-07-07 16:40:30 +00:00
|
|
|
{
|
|
|
|
/* symbol is not needed in the regular symbol table */
|
|
|
|
symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
1993-05-27 19:42:23 +00:00
|
|
|
|
|
|
|
#ifndef NO_LISTING
|
|
|
|
if (listing && !goof)
|
|
|
|
switch (S_GET_TYPE (symbolP))
|
|
|
|
{
|
|
|
|
case N_SLINE:
|
|
|
|
listing_source_line (S_GET_DESC (symbolP));
|
|
|
|
break;
|
|
|
|
case N_SO:
|
|
|
|
case N_SOL:
|
|
|
|
listing_source_file (string);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (goof)
|
1993-07-07 16:40:30 +00:00
|
|
|
ignore_rest_of_line ();
|
1993-05-27 19:42:23 +00:00
|
|
|
else
|
|
|
|
demand_empty_rest_of_line ();
|
1993-07-07 16:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
obj_elf_stab (what)
|
|
|
|
int what;
|
|
|
|
{
|
|
|
|
obj_elf_stab_generic (what, ".stab");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
obj_elf_xstab (what)
|
|
|
|
int what;
|
|
|
|
{
|
|
|
|
int length;
|
|
|
|
char *secname;
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
secname = demand_copy_C_string (&length);
|
|
|
|
SKIP_WHITESPACE ();
|
|
|
|
if (*input_line_pointer == ',')
|
|
|
|
input_line_pointer++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
as_bad ("comma missing in .xstabs");
|
|
|
|
ignore_rest_of_line ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
obj_elf_stab_generic (what, secname);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
obj_elf_desc ()
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
char c;
|
|
|
|
char *p;
|
|
|
|
symbolS *symbolP;
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
/* Frob invented at RMS' request. Set the n_desc of a symbol. */
|
|
|
|
name = input_line_pointer;
|
|
|
|
c = get_symbol_end ();
|
|
|
|
p = input_line_pointer;
|
|
|
|
*p = c;
|
|
|
|
SKIP_WHITESPACE ();
|
|
|
|
if (*input_line_pointer != ',')
|
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
as_bad ("Expected comma after name \"%s\"", name);
|
|
|
|
*p = c;
|
|
|
|
ignore_rest_of_line ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
input_line_pointer++;
|
|
|
|
temp = get_absolute_expression ();
|
|
|
|
*p = 0;
|
|
|
|
symbolP = symbol_find_or_make (name);
|
|
|
|
*p = c;
|
|
|
|
S_SET_DESC (symbolP, temp);
|
|
|
|
}
|
|
|
|
demand_empty_rest_of_line ();
|
|
|
|
} /* obj_elf_desc() */
|
|
|
|
|
|
|
|
void
|
|
|
|
obj_read_begin_hook ()
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
void
|
|
|
|
obj_symbol_new_hook (symbolP)
|
|
|
|
symbolS *symbolP;
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
#if 0 /* BFD already takes care of this */
|
|
|
|
elf32_symbol_type *esym = (elf32_symbol_type *) symbolP;
|
1993-05-27 19:42:23 +00:00
|
|
|
|
|
|
|
/* There is an Elf_Internal_Sym and an Elf_External_Sym. For now,
|
|
|
|
just zero them out. */
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
bzero ((char *) &esym->internal_elf_sym, sizeof (esym->internal_elf_sym));
|
|
|
|
bzero ((char *) &esym->native_elf_sym, sizeof (esym->native_elf_sym));
|
|
|
|
bzero ((char *) &esym->tc_data, sizeof (esym->tc_data));
|
|
|
|
#endif
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
void
|
|
|
|
obj_elf_version ()
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
char *name;
|
|
|
|
unsigned int c;
|
|
|
|
char ch;
|
|
|
|
char *p;
|
|
|
|
asection *seg = now_seg;
|
|
|
|
subsegT subseg = now_subseg;
|
|
|
|
Elf_Internal_Note i_note;
|
|
|
|
Elf_External_Note e_note;
|
|
|
|
asection *note_secp = (asection *) NULL;
|
|
|
|
int i, len;
|
|
|
|
|
|
|
|
SKIP_WHITESPACE ();
|
|
|
|
if (*input_line_pointer == '\"')
|
|
|
|
{
|
|
|
|
++input_line_pointer; /* -> 1st char of string. */
|
1993-05-27 19:42:23 +00:00
|
|
|
name = input_line_pointer;
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
while (is_a_char (c = next_char_of_string ()))
|
|
|
|
;
|
1993-05-27 19:42:23 +00:00
|
|
|
c = *input_line_pointer;
|
|
|
|
*input_line_pointer = '\0';
|
1993-07-07 16:40:30 +00:00
|
|
|
*(input_line_pointer - 1) = '\0';
|
1993-05-27 19:42:23 +00:00
|
|
|
*input_line_pointer = c;
|
|
|
|
|
|
|
|
/* create the .note section if this is the first version string */
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
note_secp = bfd_get_section_by_name (stdoutput, ".note");
|
|
|
|
if (note_secp == (asection *) NULL)
|
|
|
|
{
|
|
|
|
note_secp = bfd_make_section_old_way (stdoutput, ".note");
|
|
|
|
bfd_set_section_flags (stdoutput,
|
|
|
|
note_secp,
|
|
|
|
SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS);
|
|
|
|
}
|
1993-05-27 19:42:23 +00:00
|
|
|
|
|
|
|
/* process the version string */
|
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
subseg_new ((char *) note_secp->name, 0);
|
|
|
|
len = strlen (name);
|
|
|
|
|
|
|
|
i_note.namesz = ((len + 1) + 3) & ~3; /* round this to word boundary */
|
|
|
|
i_note.descsz = 0; /* no description */
|
|
|
|
i_note.type = NT_VERSION;
|
|
|
|
p = frag_more (sizeof (e_note.namesz));
|
|
|
|
md_number_to_chars (p, (valueT) i_note.namesz, 4);
|
|
|
|
p = frag_more (sizeof (e_note.descsz));
|
|
|
|
md_number_to_chars (p, (valueT) i_note.descsz, 4);
|
|
|
|
p = frag_more (sizeof (e_note.type));
|
|
|
|
md_number_to_chars (p, (valueT) i_note.type, 4);
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
ch = *(name + i);
|
|
|
|
{
|
|
|
|
FRAG_APPEND_1_CHAR (ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
frag_align (2, 0);
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
subseg_new ((char *) seg->name, subseg);
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
1993-07-07 16:40:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
as_bad ("Expected \"-ed string");
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
1993-07-07 16:40:30 +00:00
|
|
|
demand_empty_rest_of_line ();
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
obj_elf_size ()
|
|
|
|
{
|
|
|
|
char *name = input_line_pointer;
|
|
|
|
char c = get_symbol_end ();
|
|
|
|
char *p;
|
|
|
|
expressionS exp;
|
|
|
|
symbolS *sym;
|
|
|
|
|
|
|
|
p = input_line_pointer;
|
|
|
|
*p = c;
|
|
|
|
SKIP_WHITESPACE ();
|
|
|
|
if (*input_line_pointer != ',')
|
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
as_bad ("expected comma after name `%s' in .size directive", name);
|
|
|
|
*p = c;
|
|
|
|
ignore_rest_of_line ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
input_line_pointer++;
|
* Extensive changes to permit symbols to contain any expression
type and to delay the computation of the expression until the
value is actually needed. This permits setting symbols to values
calculated based on object code size. Expressions were changed to
no longer be in a section, to stop the overloading of segment and
expression type that previously occurred.
* as.c (big_section, pass1_section, diff_section, absent_section):
Removed.
(expr_section): Added (used for dummy symbols which hold
intermediate expression values).
(perform_an_assembly_pass): Create expr_section, do not create the
sections now removed.
* as.h (segT): Removed SEG_ABSENT, SEG_PASS1, SEG_BIG, and
SEG_DIFFERENCE. Added SEG_EXPR.
(SEG_NORMAL): Corresponding changes.
* subsegs.c (seg_name, subsegs_begin): Changed accordingly.
* write.c (write_object_file): Ditto.
* config/obj-aout.c (seg_N_TYPE): Ditto.
* config/obj-bout.c (seg_N_TYPE): Ditto.
* config/obj-coff.c (seg_N_TYPE): Ditto.
* config/obj-coffbfd.c (seg_N_TYPE): Ditto.
* config/obj-vms.c (seg_N_TYPE): Ditto.
* expr.h (operatorT): Moved in from expr.c, added some values.
(expressionS): Added X_op field, removed X_seg field; renamed
X_subtract_symbol to X_op_symbol.
* expr.c: Extensive changes to assign expression types rather than
sections and to simplify the parsing.
* write.c (fix_new_internal): New static function.
(fix_new): Removed sub_symbol argument.
(fix_new_exp): New function, takes expression argument.
* write.h: Prototype changes for fix_new and fix_new_exp.
* cond.c (s_if): Changed accordingly.
* read.c (s_lsym, pseudo_set, emit_expr, parse_bitfield_cons,
parse_repeat_cons, get_segmented_expression,
get_known_segmented_expression, get_absolute_expression): Ditto.
* symbols.c (resolve_symbol_value, S_GET_VALUE, S_SET_VALUE):
Ditto.
* write.c (write_object_file): Ditto.
* config/obj-coff.c (obj_coff_def, obj_coff_val): Ditto.
* config/obj-coffbfd.c (obj_coff_def, obj_coff_val,
obj_coff_endef, yank_symbols): Ditto.
* config/obj-elf.c (obj_elf_stab_generic, obj_elf_size): Ditto.
* config/tc-a29k.c (md_assemble, parse_operand, machine_ip,
print_insn, md_operand): Ditto.
* config/tc-h8300.c (parse_exp, colonmod24, check_operand,
do_a_fix_imm, build_bytes): Ditto.
* config/tc-h8500.c (parse_exp, skip_colonthing, parse_reglist,
get_specific, check, insert, md_convert_frag): Ditto.
* config/tc-hppa.c (the_insn, fix_new_hppa, cons_fix_new_hppa,
md_assemble, pa_ip, getExpression, getAbsoluteExpression,
evaluateAbsolute, pa_build_unwind_subspace, pa_entry,
process_exit): Ditto.
* config/tc-hppa.h (STAB_FIXUP, is_DP_relative, is_PC_relative,
is_complex): Ditto.
* config/tc-i386.c (pe, md_assemble, i386_operand,
md_estimate_size_before_relax, md_create_long_jump): Ditto.
* config/tc-i860.c (md_assemble, getExpression, print_insn):
Ditto.
* config/tc-i960.c (parse_expr, subs, segs, md_convert_frag,
get_cdisp, mem_fmt, parse_ldconst, relax_cobr, s_sysproc,
i960_handle_align): Ditto.
* config/tc-m68k.c (struct m68k_exp, struct m68k_it, seg, op,
subs, add_fix, isvar, m68k_ip, md_assemble, md_convert_frag_1,
md_estimate_size_before_relax, md_create_long_jump, get_num):
Ditto.
* config/tc-m88k.c (md_assemble, get_imm16, get_pcr,
md_create_short_jump, md_create_long_jump): Ditto.
* config/tc-mips.c (md_assemble, append_insn, gp_reference,
macro_build, macro, my_getExpression): Ditto. Also removed
get_optional_absolute_expression; just use get_absolute_expression
instead.
* config/tc-ns32k.c (get_addr_mode, evaluate_expr, convert_iif,
fix_new_ns32k, fix_new_ns32k_exp, cons_fix_new_ns32k): Ditto.
* config/tc-ns32k.h (fix_new_ns32k prototype): Ditto.
* config/tc-sh.c (parse_exp, check, insert, md_convert_frag):
Ditto.
* config/tc-sparc.c (md_assemble, sparc_ip, getExpression,
print_insn): Ditto.
* config/tc-tahoe.c (struct top, md_estimate_size_before_relax,
tip_op, md_assemble): Ditto.
* config/tc-vax.c (seg_of_operand, md_assemble,
md_estimate_size_before_relax, md_create_long_jump): Ditto.
* config/tc-z8k.c (parse_exp, check_operand, newfix): Ditto.
1993-07-21 00:41:42 +00:00
|
|
|
expression (&exp);
|
|
|
|
if (exp.X_op == O_absent)
|
1993-05-27 19:42:23 +00:00
|
|
|
{
|
|
|
|
as_bad ("missing expression in .size directive");
|
* Extensive changes to permit symbols to contain any expression
type and to delay the computation of the expression until the
value is actually needed. This permits setting symbols to values
calculated based on object code size. Expressions were changed to
no longer be in a section, to stop the overloading of segment and
expression type that previously occurred.
* as.c (big_section, pass1_section, diff_section, absent_section):
Removed.
(expr_section): Added (used for dummy symbols which hold
intermediate expression values).
(perform_an_assembly_pass): Create expr_section, do not create the
sections now removed.
* as.h (segT): Removed SEG_ABSENT, SEG_PASS1, SEG_BIG, and
SEG_DIFFERENCE. Added SEG_EXPR.
(SEG_NORMAL): Corresponding changes.
* subsegs.c (seg_name, subsegs_begin): Changed accordingly.
* write.c (write_object_file): Ditto.
* config/obj-aout.c (seg_N_TYPE): Ditto.
* config/obj-bout.c (seg_N_TYPE): Ditto.
* config/obj-coff.c (seg_N_TYPE): Ditto.
* config/obj-coffbfd.c (seg_N_TYPE): Ditto.
* config/obj-vms.c (seg_N_TYPE): Ditto.
* expr.h (operatorT): Moved in from expr.c, added some values.
(expressionS): Added X_op field, removed X_seg field; renamed
X_subtract_symbol to X_op_symbol.
* expr.c: Extensive changes to assign expression types rather than
sections and to simplify the parsing.
* write.c (fix_new_internal): New static function.
(fix_new): Removed sub_symbol argument.
(fix_new_exp): New function, takes expression argument.
* write.h: Prototype changes for fix_new and fix_new_exp.
* cond.c (s_if): Changed accordingly.
* read.c (s_lsym, pseudo_set, emit_expr, parse_bitfield_cons,
parse_repeat_cons, get_segmented_expression,
get_known_segmented_expression, get_absolute_expression): Ditto.
* symbols.c (resolve_symbol_value, S_GET_VALUE, S_SET_VALUE):
Ditto.
* write.c (write_object_file): Ditto.
* config/obj-coff.c (obj_coff_def, obj_coff_val): Ditto.
* config/obj-coffbfd.c (obj_coff_def, obj_coff_val,
obj_coff_endef, yank_symbols): Ditto.
* config/obj-elf.c (obj_elf_stab_generic, obj_elf_size): Ditto.
* config/tc-a29k.c (md_assemble, parse_operand, machine_ip,
print_insn, md_operand): Ditto.
* config/tc-h8300.c (parse_exp, colonmod24, check_operand,
do_a_fix_imm, build_bytes): Ditto.
* config/tc-h8500.c (parse_exp, skip_colonthing, parse_reglist,
get_specific, check, insert, md_convert_frag): Ditto.
* config/tc-hppa.c (the_insn, fix_new_hppa, cons_fix_new_hppa,
md_assemble, pa_ip, getExpression, getAbsoluteExpression,
evaluateAbsolute, pa_build_unwind_subspace, pa_entry,
process_exit): Ditto.
* config/tc-hppa.h (STAB_FIXUP, is_DP_relative, is_PC_relative,
is_complex): Ditto.
* config/tc-i386.c (pe, md_assemble, i386_operand,
md_estimate_size_before_relax, md_create_long_jump): Ditto.
* config/tc-i860.c (md_assemble, getExpression, print_insn):
Ditto.
* config/tc-i960.c (parse_expr, subs, segs, md_convert_frag,
get_cdisp, mem_fmt, parse_ldconst, relax_cobr, s_sysproc,
i960_handle_align): Ditto.
* config/tc-m68k.c (struct m68k_exp, struct m68k_it, seg, op,
subs, add_fix, isvar, m68k_ip, md_assemble, md_convert_frag_1,
md_estimate_size_before_relax, md_create_long_jump, get_num):
Ditto.
* config/tc-m88k.c (md_assemble, get_imm16, get_pcr,
md_create_short_jump, md_create_long_jump): Ditto.
* config/tc-mips.c (md_assemble, append_insn, gp_reference,
macro_build, macro, my_getExpression): Ditto. Also removed
get_optional_absolute_expression; just use get_absolute_expression
instead.
* config/tc-ns32k.c (get_addr_mode, evaluate_expr, convert_iif,
fix_new_ns32k, fix_new_ns32k_exp, cons_fix_new_ns32k): Ditto.
* config/tc-ns32k.h (fix_new_ns32k prototype): Ditto.
* config/tc-sh.c (parse_exp, check, insert, md_convert_frag):
Ditto.
* config/tc-sparc.c (md_assemble, sparc_ip, getExpression,
print_insn): Ditto.
* config/tc-tahoe.c (struct top, md_estimate_size_before_relax,
tip_op, md_assemble): Ditto.
* config/tc-vax.c (seg_of_operand, md_assemble,
md_estimate_size_before_relax, md_create_long_jump): Ditto.
* config/tc-z8k.c (parse_exp, check_operand, newfix): Ditto.
1993-07-21 00:41:42 +00:00
|
|
|
exp.X_op = O_constant;
|
1993-05-27 19:42:23 +00:00
|
|
|
exp.X_add_number = 0;
|
|
|
|
}
|
|
|
|
*p = 0;
|
|
|
|
sym = symbol_find_or_make (name);
|
|
|
|
*p = c;
|
* Extensive changes to permit symbols to contain any expression
type and to delay the computation of the expression until the
value is actually needed. This permits setting symbols to values
calculated based on object code size. Expressions were changed to
no longer be in a section, to stop the overloading of segment and
expression type that previously occurred.
* as.c (big_section, pass1_section, diff_section, absent_section):
Removed.
(expr_section): Added (used for dummy symbols which hold
intermediate expression values).
(perform_an_assembly_pass): Create expr_section, do not create the
sections now removed.
* as.h (segT): Removed SEG_ABSENT, SEG_PASS1, SEG_BIG, and
SEG_DIFFERENCE. Added SEG_EXPR.
(SEG_NORMAL): Corresponding changes.
* subsegs.c (seg_name, subsegs_begin): Changed accordingly.
* write.c (write_object_file): Ditto.
* config/obj-aout.c (seg_N_TYPE): Ditto.
* config/obj-bout.c (seg_N_TYPE): Ditto.
* config/obj-coff.c (seg_N_TYPE): Ditto.
* config/obj-coffbfd.c (seg_N_TYPE): Ditto.
* config/obj-vms.c (seg_N_TYPE): Ditto.
* expr.h (operatorT): Moved in from expr.c, added some values.
(expressionS): Added X_op field, removed X_seg field; renamed
X_subtract_symbol to X_op_symbol.
* expr.c: Extensive changes to assign expression types rather than
sections and to simplify the parsing.
* write.c (fix_new_internal): New static function.
(fix_new): Removed sub_symbol argument.
(fix_new_exp): New function, takes expression argument.
* write.h: Prototype changes for fix_new and fix_new_exp.
* cond.c (s_if): Changed accordingly.
* read.c (s_lsym, pseudo_set, emit_expr, parse_bitfield_cons,
parse_repeat_cons, get_segmented_expression,
get_known_segmented_expression, get_absolute_expression): Ditto.
* symbols.c (resolve_symbol_value, S_GET_VALUE, S_SET_VALUE):
Ditto.
* write.c (write_object_file): Ditto.
* config/obj-coff.c (obj_coff_def, obj_coff_val): Ditto.
* config/obj-coffbfd.c (obj_coff_def, obj_coff_val,
obj_coff_endef, yank_symbols): Ditto.
* config/obj-elf.c (obj_elf_stab_generic, obj_elf_size): Ditto.
* config/tc-a29k.c (md_assemble, parse_operand, machine_ip,
print_insn, md_operand): Ditto.
* config/tc-h8300.c (parse_exp, colonmod24, check_operand,
do_a_fix_imm, build_bytes): Ditto.
* config/tc-h8500.c (parse_exp, skip_colonthing, parse_reglist,
get_specific, check, insert, md_convert_frag): Ditto.
* config/tc-hppa.c (the_insn, fix_new_hppa, cons_fix_new_hppa,
md_assemble, pa_ip, getExpression, getAbsoluteExpression,
evaluateAbsolute, pa_build_unwind_subspace, pa_entry,
process_exit): Ditto.
* config/tc-hppa.h (STAB_FIXUP, is_DP_relative, is_PC_relative,
is_complex): Ditto.
* config/tc-i386.c (pe, md_assemble, i386_operand,
md_estimate_size_before_relax, md_create_long_jump): Ditto.
* config/tc-i860.c (md_assemble, getExpression, print_insn):
Ditto.
* config/tc-i960.c (parse_expr, subs, segs, md_convert_frag,
get_cdisp, mem_fmt, parse_ldconst, relax_cobr, s_sysproc,
i960_handle_align): Ditto.
* config/tc-m68k.c (struct m68k_exp, struct m68k_it, seg, op,
subs, add_fix, isvar, m68k_ip, md_assemble, md_convert_frag_1,
md_estimate_size_before_relax, md_create_long_jump, get_num):
Ditto.
* config/tc-m88k.c (md_assemble, get_imm16, get_pcr,
md_create_short_jump, md_create_long_jump): Ditto.
* config/tc-mips.c (md_assemble, append_insn, gp_reference,
macro_build, macro, my_getExpression): Ditto. Also removed
get_optional_absolute_expression; just use get_absolute_expression
instead.
* config/tc-ns32k.c (get_addr_mode, evaluate_expr, convert_iif,
fix_new_ns32k, fix_new_ns32k_exp, cons_fix_new_ns32k): Ditto.
* config/tc-ns32k.h (fix_new_ns32k prototype): Ditto.
* config/tc-sh.c (parse_exp, check, insert, md_convert_frag):
Ditto.
* config/tc-sparc.c (md_assemble, sparc_ip, getExpression,
print_insn): Ditto.
* config/tc-tahoe.c (struct top, md_estimate_size_before_relax,
tip_op, md_assemble): Ditto.
* config/tc-vax.c (seg_of_operand, md_assemble,
md_estimate_size_before_relax, md_create_long_jump): Ditto.
* config/tc-z8k.c (parse_exp, check_operand, newfix): Ditto.
1993-07-21 00:41:42 +00:00
|
|
|
if (exp.X_op == O_constant)
|
1993-05-27 19:42:23 +00:00
|
|
|
S_SET_SIZE (sym, exp.X_add_number);
|
|
|
|
else
|
1993-07-07 16:40:30 +00:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
static int warned;
|
|
|
|
if (!warned)
|
|
|
|
{
|
|
|
|
as_tsktsk (".size expressions not yet supported, ignored");
|
|
|
|
warned++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
1993-05-27 19:42:23 +00:00
|
|
|
demand_empty_rest_of_line ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
obj_elf_type ()
|
|
|
|
{
|
|
|
|
char *name = input_line_pointer;
|
|
|
|
char c = get_symbol_end ();
|
|
|
|
char *p;
|
1993-07-07 16:40:30 +00:00
|
|
|
int type = 0;
|
1993-05-27 19:42:23 +00:00
|
|
|
symbolS *sym;
|
|
|
|
|
|
|
|
p = input_line_pointer;
|
|
|
|
*p = c;
|
|
|
|
SKIP_WHITESPACE ();
|
|
|
|
if (*input_line_pointer != ',')
|
|
|
|
{
|
|
|
|
as_bad ("expected comma after name in .type directive");
|
|
|
|
egress:
|
|
|
|
ignore_rest_of_line ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
input_line_pointer++;
|
|
|
|
SKIP_WHITESPACE ();
|
|
|
|
if (*input_line_pointer != '#')
|
|
|
|
{
|
|
|
|
as_bad ("expected `#' after comma in .type directive");
|
|
|
|
goto egress;
|
|
|
|
}
|
|
|
|
input_line_pointer++;
|
|
|
|
if (!strncmp ("function", input_line_pointer, sizeof ("function") - 1))
|
|
|
|
{
|
|
|
|
type = BSF_FUNCTION;
|
|
|
|
input_line_pointer += sizeof ("function") - 1;
|
|
|
|
}
|
1993-07-07 16:40:30 +00:00
|
|
|
else if (!strncmp ("object", input_line_pointer, sizeof ("object") - 1))
|
|
|
|
{
|
|
|
|
input_line_pointer += sizeof ("object") - 1;
|
|
|
|
}
|
1993-05-27 19:42:23 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
as_bad ("unrecognized symbol type, ignored");
|
|
|
|
goto egress;
|
|
|
|
}
|
|
|
|
demand_empty_rest_of_line ();
|
|
|
|
*p = 0;
|
|
|
|
sym = symbol_find_or_make (name);
|
1993-07-07 16:40:30 +00:00
|
|
|
sym->bsym->flags |= type;
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
obj_elf_ident ()
|
|
|
|
{
|
1993-07-07 16:40:30 +00:00
|
|
|
static segT comment_section;
|
|
|
|
segT old_section = now_seg;
|
|
|
|
int old_subsection = now_subseg;
|
1993-05-27 19:42:23 +00:00
|
|
|
|
1993-07-07 16:40:30 +00:00
|
|
|
if (!comment_section)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
comment_section = subseg_new (".comment", 0);
|
|
|
|
bfd_set_section_flags (stdoutput, comment_section, SEC_HAS_CONTENTS);
|
|
|
|
p = frag_more (1);
|
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
subseg_set (comment_section, 0);
|
|
|
|
stringer (1);
|
|
|
|
subseg_set (old_section, old_subsection);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
elf_frob_file ()
|
|
|
|
{
|
|
|
|
#ifdef elf_tc_symbol
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < stdoutput->symcount; i++)
|
|
|
|
elf_tc_symbol (stdoutput, (elf_symbol_type *) (stdoutput->outsymbols[i]), i + 1);
|
|
|
|
#endif
|
|
|
|
#ifdef elf_tc_final_processing
|
|
|
|
elf_tc_final_processing_hook ();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Finally, we must make any target-specific sections. */
|
|
|
|
|
|
|
|
#ifdef elf_tc_make_sections
|
|
|
|
elf_tc_make_sections (stdoutput, NULL);
|
|
|
|
#endif
|
1993-05-27 19:42:23 +00:00
|
|
|
}
|