aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-02-15 11:11:46 +0000
committerNick Clifton <nickc@redhat.com>2016-02-15 11:11:46 +0000
commit9fb71ee49fc37163697e4f34e16097928eb83d66 (patch)
tree059842e2b43a163ceae1867632b98dc00014d133 /gas/config
parent2b63aca39c2b0abbb410f7a5a60124ac5abf7438 (diff)
downloadgdb-9fb71ee49fc37163697e4f34e16097928eb83d66.zip
gdb-9fb71ee49fc37163697e4f34e16097928eb83d66.tar.gz
gdb-9fb71ee49fc37163697e4f34e16097928eb83d66.tar.bz2
Enhance GAS's .section directive so that it can take numeric values for the flags and type fields. (ELF only)
gas * doc/as.texinfo (.section): Document that numeric values can now be used for the flags and type fields of the ELF target's .section directive. Add notes about the restrictions on setting flags and types. * config/obj-elf.c (obj_elf_change_section): Allow known sections to be given processor specific section types. Allow processor and application specific flags of a section to be set after definition. (obj_elf_parse_section_letters): Handle parsing numeric values. (obj_elf_section_type): Handle parsing numeric values. (obj_elf_section): Allow numeric type values. * config/obj-elf.h (obj_elf_change_section): Update prototype. * testsuite/gas/elf/section10.d: New test. * testsuite/gas/elf/section10.s: Source file for new test. * testsuite/gas/elf/elf.exp: Run the new test. * testsuite/gas/i386/ilp32/x86-64-unwind.d: Remove dependency upon the description of the flags produced by readelf. * testsuite/gas/tic6x/scomm-directive-4.d: Likewise. * NEWS: Mention the new feature. bfd * elf-bfd.h (struct bfd_elf_special_section): Use unsigned values for length and type fields. Use a signed value for the suffix_length field. binutils* readelf.c (get_section_type_name): Add hex prefix to offsets printed for LOPROC and LOOS values. Ensure that a result is always returned for the V850 target, even when an unrecognised processor specific value is encountered. (process_section_headers): Display key values in the order in which they appear to the user. Add the "C (compressed)" value to the list. ld * testsuite/ld-i386/pr12718.d: Remove dependency upon the description of the flags produced by readelf. * testsuite/ld-i386/pr12921.d: Likewise. * testsuite/ld-i386/tlsbin-nacl.rd: Likewise. * testsuite/ld-i386/tlsbin.rd: Likewise. * testsuite/ld-i386/tlsbindesc-nacl.rd: Likewise. * testsuite/ld-i386/tlsbindesc.rd: Likewise. * testsuite/ld-i386/tlsdesc-nacl.rd: Likewise. * testsuite/ld-i386/tlsdesc.rd: Likewise. * testsuite/ld-i386/tlsgdesc-nacl.rd: Likewise. * testsuite/ld-i386/tlsgdesc.rd: Likewise. * testsuite/ld-i386/tlsnopic-nacl.rd: Likewise. * testsuite/ld-i386/tlsnopic.rd: Likewise. * testsuite/ld-i386/tlspic-nacl.rd: Likewise. * testsuite/ld-i386/tlspic.rd: Likewise. * testsuite/ld-s390/tlsbin.rd: Likewise. * testsuite/ld-s390/tlsbin_64.rd: Likewise. * testsuite/ld-s390/tlspic.rd: Likewise. * testsuite/ld-s390/tlspic_64.rd: Likewise. * testsuite/ld-sh/tlsbin-2.d: Likewise. * testsuite/ld-sh/tlspic-2.d: Likewise. * testsuite/ld-tic6x/common.d: Likewise. * testsuite/ld-tic6x/shlib-1.rd: Likewise. * testsuite/ld-tic6x/shlib-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-noindex.rd: Likewise. * testsuite/ld-tic6x/static-app-1.rd: Likewise. * testsuite/ld-tic6x/static-app-1b.rd: Likewise. * testsuite/ld-tic6x/static-app-1r.rd: Likewise. * testsuite/ld-tic6x/static-app-1rb.rd: Likewise. * testsuite/ld-x86-64/ilp32-4-nacl.d: Likewise. * testsuite/ld-x86-64/ilp32-4.d: Likewise. * testsuite/ld-x86-64/pr12718.d: Likewise. * testsuite/ld-x86-64/pr12921.d: Likewise. * testsuite/ld-x86-64/split-by-file-nacl.rd: Likewise. * testsuite/ld-x86-64/split-by-file.rd: Likewise. * testsuite/ld-x86-64/tlsbin-nacl.rd: Likewise. * testsuite/ld-x86-64/tlsbin.rd: Likewise. * testsuite/ld-x86-64/tlsbindesc-nacl.rd: Likewise. * testsuite/ld-x86-64/tlsbindesc.rd: Likewise. * testsuite/ld-x86-64/tlsdesc-nacl.rd: Likewise. * testsuite/ld-x86-64/tlsdesc.rd: Likewise. * testsuite/ld-x86-64/tlsgdesc-nacl.rd: Likewise. * testsuite/ld-x86-64/tlsgdesc.rd: Likewise. * testsuite/ld-x86-64/tlspic-nacl.rd: Likewise. * testsuite/ld-x86-64/tlspic.rd: Likewise. * testsuite/ld-xtensa/tlsbin.rd: Likewise. * testsuite/ld-xtensa/tlspic.rd: Likewise.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/obj-elf.c56
-rw-r--r--gas/config/obj-elf.h2
2 files changed, 49 insertions, 9 deletions
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index f4726ff..9af349c 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -547,7 +547,7 @@ get_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
void
obj_elf_change_section (const char *name,
- int type,
+ unsigned int type,
bfd_vma attr,
int entsize,
const char *group_name,
@@ -621,7 +621,9 @@ obj_elf_change_section (const char *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);
}
@@ -633,7 +635,8 @@ obj_elf_change_section (const char *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
@@ -682,6 +685,7 @@ obj_elf_change_section (const char *name,
override = TRUE;
}
}
+
if (!override && old_sec == NULL)
attr |= ssect->attr;
}
@@ -745,6 +749,11 @@ obj_elf_change_section (const char *name,
| 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);
}
@@ -806,14 +815,26 @@ obj_elf_parse_section_letters (char *str, size_t len, bfd_boolean *is_clone)
}
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;
}
@@ -847,6 +868,17 @@ obj_elf_section_type (char *str, size_t len, bfd_boolean warn)
}
#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;
@@ -1046,9 +1078,17 @@ obj_elf_section (int push)
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;
diff --git a/gas/config/obj-elf.h b/gas/config/obj-elf.h
index f3424a5..257d877 100644
--- a/gas/config/obj-elf.h
+++ b/gas/config/obj-elf.h
@@ -162,7 +162,7 @@ extern void obj_elf_common (int);
extern void obj_elf_data (int);
extern void obj_elf_text (int);
extern void obj_elf_change_section
- (const char *, int, bfd_vma, int, const char *, int, int);
+ (const char *, unsigned int, bfd_vma, int, const char *, int, int);
extern struct fix *obj_elf_vtable_inherit (int);
extern struct fix *obj_elf_vtable_entry (int);
extern bfd_boolean obj_elf_seen_attribute