/* ELF object file format
- Copyright (C) 1992-2015 Free Software Foundation, Inc.
+ Copyright (C) 1992-2016 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
symbol_get_bfdsym (sym)->flags |= BSF_FILE;
- if (symbol_rootP != sym)
+ if (symbol_rootP != sym
+ && (symbol_rootP->bsym == NULL
+ || !(symbol_rootP->bsym->flags & BSF_FILE)))
{
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);
+ verify_symbol_chain (symbol_rootP, symbol_lastP);
#endif
- }
}
#ifdef NEED_ECOFF_DEBUG
char c;
symbolS *sym;
- name = input_line_pointer;
- c = get_symbol_end ();
+ c = get_symbol_name (& name);
sym = symbol_find_or_make (name);
*input_line_pointer = c;
- SKIP_WHITESPACE ();
+ SKIP_WHITESPACE_AFTER_NAME ();
/* There is no symbol name if input_line_pointer has not moved. */
if (name == input_line_pointer)
void
obj_elf_change_section (const char *name,
- int type,
+ unsigned int type,
bfd_vma attr,
int entsize,
const char *group_name,
&& ssect->type != SHT_PREINIT_ARRAY)
{
/* We allow to specify any type for a .note section. */
- if (ssect->type != SHT_NOTE)
+ if (ssect->type != SHT_NOTE
+ /* Processor and application defined types are allowed too. */
+ && type < SHT_LOPROC)
as_warn (_("setting incorrect section type for %s"),
name);
}
}
}
- if (old_sec == NULL && (attr & ~ssect->attr) != 0)
+ if (old_sec == NULL && ((attr & ~(SHF_MASKOS | SHF_MASKPROC))
+ & ~ssect->attr) != 0)
{
/* As a GNU extension, we permit a .note section to be
allocatable. If the linker sees an allocatable .note
override = TRUE;
}
}
+
if (!override && old_sec == NULL)
attr |= ssect->attr;
}
| SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD
| SEC_THREAD_LOCAL)))
as_warn (_("ignoring changed section attributes for %s"), name);
+ else
+ /* FIXME: Maybe we should consider removing a previously set
+ processor or application specific attribute as suspicious ? */
+ elf_section_flags (sec) = attr;
+
if ((flags & SEC_MERGE) && old_sec->entsize != (unsigned) entsize)
as_warn (_("ignoring changed section entity size for %s"), name);
}
}
default:
{
- char *bad_msg = _("unrecognized .section attribute: want a,e,w,x,M,S,G,T");
+ char *bad_msg = _("unrecognized .section attribute: want a,e,w,x,M,S,G,T or number");
#ifdef md_elf_section_letter
bfd_vma md_attr = md_elf_section_letter (*str, &bad_msg);
if (md_attr != (bfd_vma) -1)
attr |= md_attr;
else
#endif
- as_fatal ("%s", bad_msg);
+ if (ISDIGIT (*str))
+ {
+ char * end;
+
+ attr |= strtoul (str, & end, 0);
+ /* Update str and len, allowing for the fact that
+ we will execute str++ and len-- below. */
+ end --;
+ len -= (end - str);
+ str = end;
+ }
+ else
+ as_fatal ("%s", bad_msg);
}
break;
}
}
#endif
+ if (ISDIGIT (*str))
+ {
+ char * end;
+ int type = strtoul (str, & end, 0);
+
+ if (warn && (size_t) (end - str) != len)
+ as_warn (_("extraneous characters at end of numeric section type"));
+
+ return type;
+ }
+
if (warn)
as_warn (_("unrecognized section type"));
return 0;
}
else if (c == '@' || c == '%')
{
- beg = ++input_line_pointer;
- c = get_symbol_end ();
- *input_line_pointer = c;
- type = obj_elf_section_type (beg, input_line_pointer - beg, TRUE);
+ ++input_line_pointer;
+
+ if (ISDIGIT (* input_line_pointer))
+ {
+ type = strtoul (input_line_pointer, & input_line_pointer, 0);
+ }
+ else
+ {
+ c = get_symbol_name (& beg);
+ (void) restore_line_pointer (c);
+ type = obj_elf_section_type (beg, input_line_pointer - beg, TRUE);
+ }
}
else
input_line_pointer = save;
ignore_rest_of_line ();
return;
}
- beg = ++input_line_pointer;
- c = get_symbol_end ();
- *input_line_pointer = c;
+ ++input_line_pointer;
+ c = get_symbol_name (& beg);
+ (void) restore_line_pointer (c);
attr |= obj_elf_section_word (beg, input_line_pointer - beg, & type);
++input_line_pointer;
SKIP_WHITESPACE ();
- name = input_line_pointer;
/* Temporarily include '@' in symbol names. */
old_lexat = lex_type[(unsigned char) '@'];
lex_type[(unsigned char) '@'] |= LEX_NAME;
- c = get_symbol_end ();
+ c = get_symbol_name (& name);
lex_type[(unsigned char) '@'] = old_lexat;
if (symbol_get_obj (sym)->versioned_name == NULL)
{
symbol_get_obj (sym)->versioned_name = xstrdup (name);
- *input_line_pointer = c;
+ (void) restore_line_pointer (c);
if (strchr (symbol_get_obj (sym)->versioned_name,
ELF_VER_CHR) == NULL)
return;
}
- *input_line_pointer = c;
+ (void) restore_line_pointer (c);
}
demand_empty_rest_of_line ();
if (*input_line_pointer == '#')
++input_line_pointer;
- cname = input_line_pointer;
- c = get_symbol_end ();
+ c = get_symbol_name (& cname);
csym = symbol_find (cname);
/* GCFIXME: should check that we don't have two .vtable_inherits for
*input_line_pointer = c;
- SKIP_WHITESPACE ();
+ SKIP_WHITESPACE_AFTER_NAME ();
if (*input_line_pointer != ',')
{
as_bad (_("expected comma after name in .vtable_inherit"));
}
else
{
- pname = input_line_pointer;
- c = get_symbol_end ();
+ c = get_symbol_name (& pname);
psym = symbol_find_or_make (pname);
- *input_line_pointer = c;
+ restore_line_pointer (c);
}
demand_empty_rest_of_line ();
static void
obj_elf_size (int ignore ATTRIBUTE_UNUSED)
{
- char *name = input_line_pointer;
- char c = get_symbol_end ();
+ char *name;
+ char c = get_symbol_name (&name);
char *p;
expressionS exp;
symbolS *sym;
p = input_line_pointer;
*p = c;
- SKIP_WHITESPACE ();
+ SKIP_WHITESPACE_AFTER_NAME ();
if (*input_line_pointer != ',')
{
*p = 0;
*input_line_pointer = '\0';
}
else
- *cp = get_symbol_end ();
+ *cp = get_symbol_name (&p);
return p;
}
void
obj_elf_init_stab_section (segT seg)
{
- char *file;
+ const char *file;
char *p;
char *stabstr_name;
unsigned int stroff;
p = frag_more (12);
/* Zero it out. */
memset (p, 0, 12);
- as_where (&file, NULL);
+ file = as_where (NULL);
stabstr_name = (char *) xmalloc (strlen (segment_name (seg)) + 4);
strcpy (stabstr_name, segment_name (seg));
strcat (stabstr_name, "str");