/* coff object file format
- Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
- Free Software Foundation, Inc.
+ Copyright (C) 1989-2015 Free Software Foundation, Inc.
This file is part of GAS.
#define OBJ_HEADER "obj-coff.h"
#include "as.h"
-#include "obstack.h"
+#include "safe-ctype.h"
#include "subsegs.h"
+#include "struc-symbol.h"
#ifdef TE_PE
#include "coff/pe.h"
#endif
+#ifdef OBJ_XCOFF
+#include "coff/xcoff.h"
+#endif
+
#define streq(a,b) (strcmp ((a), (b)) == 0)
#define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
static const char weak_altprefix[] = ".weak.";
#endif /* TE_PE */
+#include "obj-coff-seh.c"
+
typedef struct
{
unsigned long chunk_size;
}
/* Emit a string. Note no NUL-termination. */
- pfxlen = strlen (" -aligncomm:") + strlen (S_GET_NAME (symbolP)) + 1;
+ pfxlen = strlen (" -aligncomm:") + 2 + strlen (S_GET_NAME (symbolP)) + 1;
numlen = snprintf (numbuff, sizeof (numbuff), "%d", (int) align);
frag = frag_more (pfxlen + numlen);
- (void) sprintf (frag, " -aligncomm:%s,", S_GET_NAME (symbolP));
+ (void) sprintf (frag, " -aligncomm:\"%s\",", S_GET_NAME (symbolP));
memcpy (frag + pfxlen, numbuff, numlen);
/* Restore original subseg. */
subseg_set (current_seg, current_subseg);
const asymbol *s;
s = bfd_make_debug_symbol (stdoutput, NULL, 0);
- assert (s != 0);
+ gas_assert (s != 0);
debug_section = s->section;
}
return debug_section;
memset (s, 0, sz);
coffsymbol (symbol_get_bfdsym (symbolP))->native = (combined_entry_type *) s;
+ coffsymbol (symbol_get_bfdsym (symbolP))->native->is_sym = TRUE;
S_SET_DATA_TYPE (symbolP, T_NULL);
S_SET_STORAGE_CLASS (symbolP, 0);
demand_empty_rest_of_line ();
}
-unsigned int dim_index;
-
static void
obj_coff_endef (int ignore ATTRIBUTE_UNUSED)
{
symbolS *symbolP = NULL;
- dim_index = 0;
if (def_symbol_in_progress == NULL)
{
as_warn (_(".endef pseudo-op used outside of .def/.endef: ignored."));
static void
obj_coff_dim (int ignore ATTRIBUTE_UNUSED)
{
- int dim_index;
+ int d_index;
if (def_symbol_in_progress == NULL)
{
S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
- for (dim_index = 0; dim_index < DIMNUM; dim_index++)
+ for (d_index = 0; d_index < DIMNUM; d_index++)
{
SKIP_WHITESPACES ();
- SA_SET_SYM_DIMEN (def_symbol_in_progress, dim_index,
+ SA_SET_SYM_DIMEN (def_symbol_in_progress, d_index,
get_absolute_expression ());
switch (*input_line_pointer)
/* Fall through. */
case '\n':
case ';':
- dim_index = DIMNUM;
+ d_index = DIMNUM;
break;
}
}
static const char *
weak_altname2name (const char * name)
{
- char * weak_name;
- char * dot;
-
- assert (weak_is_altname (name));
-
- weak_name = xstrdup (name + 6);
- if ((dot = strchr (weak_name, '.')))
- *dot = 0;
- return weak_name;
+ gas_assert (weak_is_altname (name));
+ return xstrdup (name + 6);
}
/* Make a weak symbol name unique by
char *ret;
const char * unique = "";
-#ifdef USE_UNIQUE
+#ifdef TE_PE
if (an_external_name != NULL)
unique = an_external_name;
#endif
- assert (weak_is_altname (name));
-
- if (strchr (name + sizeof (weak_altprefix), '.'))
- return name;
+ gas_assert (weak_is_altname (name));
ret = xmalloc (strlen (name) + strlen (unique) + 2);
strcpy (ret, name);
symbolS *weakp = symbol_find_noref (weak_altname2name
(S_GET_NAME (symp)), 1);
- assert (weakp);
- assert (S_GET_NUMBER_AUXILIARY (weakp) == 1);
+ gas_assert (weakp);
+ gas_assert (S_GET_NUMBER_AUXILIARY (weakp) == 1);
if (! S_IS_WEAK (weakp))
{
if (!S_IS_DEFINED (symp) && !SF_GET_LOCAL (symp))
{
- assert (S_GET_VALUE (symp) == 0);
+ gas_assert (S_GET_VALUE (symp) == 0);
if (S_IS_WEAKREFD (symp))
*punt = 1;
else
}
}
- if (coff_last_function == 0 && SF_GET_FUNCTION (symp))
+ if (coff_last_function == 0 && SF_GET_FUNCTION (symp)
+ && S_IS_DEFINED (symp))
{
union internal_auxent *auxp;
sizeof (auxp->x_sym.x_fcnary.x_ary.x_dimen));
}
- if (S_GET_STORAGE_CLASS (symp) == C_EFCN)
+ if (S_GET_STORAGE_CLASS (symp) == C_EFCN
+ && S_IS_DEFINED (symp))
{
if (coff_last_function == 0)
as_fatal (_("C_EFCN symbol for %s out of scope"),
if (next_set_end != NULL)
{
if (set_end != NULL)
- as_warn ("Warning: internal error: forgetting to set endndx of %s",
+ as_warn (_("Warning: internal error: forgetting to set endndx of %s"),
S_GET_NAME (set_end));
set_end = next_set_end;
}
'o' for over
'w' for data
'd' (apparently m88k for data)
+ 'e' for exclude
'x' for text
'r' for read-only data
's' for shared data (PE)
'y' for noread
+ '0' - '9' for power-of-two alignment (GNU extension).
But if the argument is not a quoted string, treat it as a
subsegment number.
/* Strip out the section name. */
char *section_name;
char c;
+ int alignment = -1;
char *name;
unsigned int exp;
flagword flags, oldflags;
attr != '"'
&& ! is_end_of_line[attr])
{
+ if (ISDIGIT (attr))
+ {
+ alignment = attr - '0';
+ continue;
+ }
switch (attr)
{
+ case 'e':
+ /* Exclude section from linking. */
+ flags |= SEC_EXCLUDE;
+ break;
+
case 'b':
/* Uninitialised data section. */
flags |= SEC_ALLOC;
sec = subseg_new (name, (subsegT) exp);
+ if (alignment >= 0)
+ sec->alignment_power = alignment;
+
oldflags = bfd_get_section_flags (stdoutput, sec);
if (oldflags == SEC_NO_FLAGS)
{
segT strsec;
char *p;
fragS *fragp;
- bfd_vma size, n_entries, mask;
- bfd_vma align_power = (bfd_vma)sec->alignment_power + OCTETS_PER_BYTE_POWER;
+ bfd_vma n_entries;
/* The COFF back end in BFD requires that all section sizes be
rounded up to multiples of the corresponding section alignments,
supposedly because standard COFF has no other way of encoding alignment
for sections. If your COFF flavor has a different way of encoding
section alignment, then skip this step, as TICOFF does. */
- size = bfd_get_section_size (sec);
- mask = ((bfd_vma) 1 << align_power) - 1;
+ bfd_vma size = bfd_get_section_size (sec);
#if !defined(TICOFF)
+ bfd_vma align_power = (bfd_vma) sec->alignment_power + OCTETS_PER_BYTE_POWER;
+ bfd_vma mask = ((bfd_vma) 1 << align_power) - 1;
+
if (size & mask)
{
bfd_vma new_size;
#endif
{
symbolS *secsym = section_symbol (sec);
+ unsigned char sclass = C_STAT;
- S_SET_STORAGE_CLASS (secsym, C_STAT);
+#ifdef OBJ_XCOFF
+ if (bfd_get_section_flags (stdoutput, sec) & SEC_DEBUGGING)
+ sclass = C_DWARF;
+#endif
+ S_SET_STORAGE_CLASS (secsym, sclass);
S_SET_NUMBER_AUXILIARY (secsym, 1);
SF_SET_STATICS (secsym);
SA_SET_SCN_SCNLEN (secsym, size);
}
-
/* FIXME: These should be in a "stabs.h" file, or maybe as.h. */
#ifndef STAB_SECTION_NAME
#define STAB_SECTION_NAME ".stab"
fragp = seg_info (sec)->frchainP->frch_root;
while (fragp && fragp->fr_fix == 0)
fragp = fragp->fr_next;
- assert (fragp != 0 && fragp->fr_fix >= 12);
+ gas_assert (fragp != 0 && fragp->fr_fix >= 12);
/* Store the values. */
p = fragp->fr_literal;
}
#ifdef DEBUG
+const char * s_get_name (symbolS *);
+
const char *
s_get_name (symbolS *s)
{
return ((s == NULL) ? "(NULL)" : S_GET_NAME (s));
}
+void symbol_dump (void);
+
void
symbol_dump (void)
{
#if defined TC_TIC4X
/* The tic4x uses sdef instead of def. */
{"sdef", obj_coff_def, 0},
+#endif
+#if defined(SEH_CMDS)
+ SEH_CMDS
#endif
{NULL, NULL, 0}
};
coff_pop_insert,
0, /* ecoff_set_ext */
coff_obj_read_begin_hook,
- coff_obj_symbol_new_hook
+ coff_obj_symbol_new_hook,
+ coff_obj_symbol_clone_hook,
+ coff_adjust_symtab
};