else if ((flags & SEC_LOAD) != 0)
flags |= SEC_DATA;
if ((hdr->sh_flags & SHF_MERGE) != 0)
- {
- flags |= SEC_MERGE;
- newsect->entsize = hdr->sh_entsize;
- }
+ flags |= SEC_MERGE;
if ((hdr->sh_flags & SHF_STRINGS) != 0)
- {
- flags |= SEC_STRINGS;
- newsect->entsize = hdr->sh_entsize;
- }
+ flags |= SEC_STRINGS;
if ((hdr->sh_flags & SHF_TLS) != 0)
flags |= SEC_THREAD_LOCAL;
if ((hdr->sh_flags & SHF_EXCLUDE) != 0)
flags |= SEC_EXCLUDE;
+ newsect->entsize = hdr->sh_entsize;
+
switch (elf_elfheader (abfd)->e_ident[EI_OSABI])
{
/* FIXME: We should not recognize SHF_GNU_MBIND for ELFOSABI_NONE,
if ((asect->flags & (SEC_GROUP | SEC_EXCLUDE)) == SEC_EXCLUDE)
this_hdr->sh_flags |= SHF_EXCLUDE;
+ if (this_hdr->sh_entsize == 0)
+ this_hdr->sh_entsize = asect->entsize;
+
/* If the section has relocs, set up a section header for the
SHT_REL[A] section. If two relocation sections are required for
this section, it is up to the processor-specific back-end to
= match_p->linked_to_symbol_name;
bfd_set_section_flags (sec, flags);
- if (flags & (SEC_MERGE | SEC_STRINGS))
+ if (entsize != 0)
sec->entsize = entsize;
elf_group_name (sec) = match_p->group_name;
processor or application specific attribute as suspicious? */
elf_section_flags (sec) = attr;
- if ((flags & (SEC_MERGE | SEC_STRINGS))
+ if (entsize != 0
&& old_sec->entsize != (unsigned) entsize)
as_bad (_("changed section entity size for %s"), name);
}
static bfd_vma
obj_elf_parse_section_letters (char *str, size_t len, bool push,
- bool *is_clone, int *inherit, bfd_vma *gnu_attr)
+ bool *is_clone, int *inherit, bfd_vma *gnu_attr,
+ bool *has_entsize)
{
bfd_vma attr = 0;
case 'x':
attr |= SHF_EXECINSTR;
break;
+ case 'E':
+ *has_entsize = true;
+ break;
case 'G':
attr |= SHF_GROUP;
break;
{
as_bad (_("unrecognized .%ssection attribute: want %s%s%s,? or number"),
push ? "push" : "",
- gnu_attr != NULL ? "a,d,e,o,w,x,G,M,R,S,T"
- : "a,e,o,w,x,G,M,S,T",
+ gnu_attr != NULL ? "a,d,e,o,w,x,E,G,M,R,S,T"
+ : "a,e,o,w,x,E,G,M,S,T",
md_extra != NULL ? "," : "", md_extra);
return attr;
}
bfd_vma attr;
bfd_vma gnu_attr;
int entsize;
- bool linkonce;
+ bool linkonce, has_entsize;
subsegT new_subsection = 0;
struct elf_section_match match;
unsigned long linked_to_section_index = -1UL;
attr = 0;
gnu_attr = 0;
entsize = 0;
+ has_entsize = false;
linkonce = 0;
if (*input_line_pointer == ',')
== ELFOSABI_GNU)
|| (bed->elf_osabi
== ELFOSABI_FREEBSD)
- ? &gnu_attr : NULL);
+ ? &gnu_attr : NULL,
+ &has_entsize);
if (inherit > 0)
attr |= elf_section_flags (now_seg);
if (inherit)
type = elf_section_type (now_seg);
+ if ((attr & (SHF_MERGE | SHF_STRINGS)) != 0)
+ has_entsize = true;
+
SKIP_WHITESPACE ();
if (*input_line_pointer == ',')
{
}
SKIP_WHITESPACE ();
- if ((attr & (SHF_MERGE | SHF_STRINGS)) != 0
- && *input_line_pointer == ',')
+ if (has_entsize && *input_line_pointer == ',')
{
++input_line_pointer;
SKIP_WHITESPACE ();
if (inherit && *input_line_pointer == ','
+ && ((bfd_section_flags (now_seg)
+ & (SEC_MERGE | SEC_STRINGS)) != 0
+ || now_seg->entsize))
+ goto fetch_entsize;
+ if (is_end_of_stmt (*input_line_pointer)
&& (bfd_section_flags (now_seg)
& (SEC_MERGE | SEC_STRINGS)) != 0)
- goto fetch_entsize;
- if (is_end_of_stmt (*input_line_pointer))
{
/* ??? This is here for older versions of gcc that
test for gas string merge support with
Unfortunately '@' begins a comment on arm.
This isn't as_warn because gcc tests with
--fatal-warnings. */
- as_tsktsk (_("missing merge / string entity size, 1 assumed"));
+ as_tsktsk (_("missing section entity size, 1 assumed"));
entsize = 1;
}
else
SKIP_WHITESPACE ();
if (entsize <= 0)
{
- as_warn (_("invalid merge / string entity size"));
+ as_warn (_("invalid section entity size"));
attr &= ~(SHF_MERGE | SHF_STRINGS);
+ has_entsize = false;
entsize = 0;
}
}
}
- else if ((attr & (SHF_MERGE | SHF_STRINGS)) != 0 && inherit
- && (bfd_section_flags (now_seg)
- & (SEC_MERGE | SEC_STRINGS)) != 0)
+ else if (has_entsize && inherit
+ && ((bfd_section_flags (now_seg)
+ & (SEC_MERGE | SEC_STRINGS)) != 0
+ || now_seg->entsize))
{
fetch_entsize:
entsize = now_seg->entsize;
entsize must be specified if SHF_MERGE is set. */
as_warn (_("entity size for SHF_MERGE not specified"));
attr &= ~(SHF_MERGE | SHF_STRINGS);
+ has_entsize = false;
}
else if ((attr & SHF_STRINGS) != 0)
{
compatibility. */
entsize = 1;
}
+ else if (has_entsize)
+ {
+ as_warn (_("entity size not specified"));
+ has_entsize = false;
+ }
if ((attr & (SHF_MERGE | SHF_STRINGS)) != 0 && type == SHT_NOBITS)
as_warn (_("bogus SHF_MERGE / SHF_STRINGS for SHT_NOBITS section"));
section is writable
@item x
section is executable
+@item E
+section has a (non-zero) element/entry size
+@item G
+section is a member of a section group
@item M
section is mergeable
@item S
section contains zero terminated strings
-@item G
-section is a member of a section group
@item T
section is used for thread-local-storage
@item ?
time, but the facility is provided for testing purposes. An index of zero is
allowed. It indicates that the linked-to section has already been discarded.
-Note: If both one of @var{M} or @var{S} and @var{o} flags are present, then the
-fields for the Merge/String flag should come first, like this:
+Note: If both one of @var{M}, @var{S}, or @var{E} and @var{o} flags are present,
+then the type and entry size fields should come first, like this:
@smallexample
.section @var{name},"@var{flags}"Mo,@@@var{type},@var{entsize},@var{SymbolName}
an alias for comdat
@end table
-Note: Uf both one of @var{M} or @var{S} and @var{G} flags are present then the
-fields for the Merge/String flag should come first, like this:
+Note: If both one of @var{M}, @var{S}, or @var{E} and @var{G} flags are present
+then the type and entry size fields should come first, like this:
@smallexample
.section @var{name} , "@var{flags}"MG, @@@var{type}, @var{entsize}, @var{GroupName}[, @var{linkage}]