/* 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.
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 == '%')
{
++input_line_pointer;
- c = get_symbol_name (& beg);
- (void) restore_line_pointer (c);
- type = obj_elf_section_type (beg, input_line_pointer - beg, TRUE);
+
+ 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;
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");