aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-04-04 09:05:48 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-04-04 09:06:04 -0700
commita91e1603afb6704545793e967a1a3dfe96b389de (patch)
tree631a0fd733778fbcc14c12f41c4fdb88f3348737 /gas
parentb52920324fabbcad93042f2e17de52696d0dab42 (diff)
downloadgdb-a91e1603afb6704545793e967a1a3dfe96b389de.zip
gdb-a91e1603afb6704545793e967a1a3dfe96b389de.tar.gz
gdb-a91e1603afb6704545793e967a1a3dfe96b389de.tar.bz2
Support ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX
Mark an ALLOC section, which should be placed in special memory area, with SHF_GNU_MBIND. Its sh_info field indicates the special memory type. GNU_MBIND section names start with ".mbind" so that they are placed as orphan sections by linker. All input GNU_MBIND sections with the same sh_type, sh_flags and sh_info are placed in one output GNU_MBIND section. In executable and shared object, create a GNU_MBIND segment for each GNU_MBIND section and its segment type is PT_GNU_MBIND_LO plus the sh_info value. Each GNU_MBIND segment is aligned at page boundary. The assembler syntax: .section .mbind.foo,"adx",%progbits ^ 0: Special memory type. | 'd' for SHF_GNU_MBIND. .section .mbind.foo,"adx",%progbits,0x1 ^ 1: Special memory type. | 'd' for SHF_GNU_MBIND. .section .mbind.bar,"adG",%progbits,.foo_group,comdat,0x2 ^ 2: Special memory type. | 'd' for SHF_GNU_MBIND. bfd/ * elf.c (get_program_header_size): Add a GNU_MBIND segment for each GNU_MBIND section and align GNU_MBIND section to page size. (_bfd_elf_map_sections_to_segments): Create a GNU_MBIND segment for each GNU_MBIND section. (_bfd_elf_init_private_section_data): Copy sh_info from input for GNU_MBIND section. binutils/ * NEWS: Mention support for ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX. * readelf.c (get_segment_type): Handle PT_GNU_MBIND_XXX. (get_elf_section_flags): Handle SHF_GNU_MBIND. (process_section_headers): Likewise. * testsuite/binutils-all/mbind1.s: New file. * testsuite/binutils-all/objcopy.exp: Run readelf test on mbind1.s. gas/ * NEWS: Mention support for ELF SHF_GNU_MBIND. * config/obj-elf.c (section_match): New. (get_section): Match both sh_info and group name. (obj_elf_change_section): Add argument for sh_info. Pass both sh_info and group name to get_section. Issue an error for SHF_GNU_MBIND section without SHF_ALLOC. Set sh_info. (obj_elf_parse_section_letters): Set SHF_GNU_MBIND for 'd'. (obj_elf_section): Support SHF_GNU_MBIND section info. * config/obj-elf.h (obj_elf_change_section): Add argument for sh_info. * config/tc-arm.c (start_unwind_section): Pass 0 as sh_info to obj_elf_change_section. * config/tc-ia64.c (obj_elf_vms_common): Likewise. * config/tc-microblaze.c (microblaze_s_data): Likewise. (microblaze_s_sdata): Likewise. (microblaze_s_rdata): Likewise. (microblaze_s_bss): Likewise. * config/tc-mips.c (s_change_section): Likewise. * config/tc-msp430.c (msp430_profiler): Likewise. * config/tc-rx.c (parse_rx_section): Likewise. * config/tc-tic6x.c (tic6x_start_unwind_section): Likewise. * doc/as.texinfo: Document 'd' for SHF_GNU_MBIND. * testsuite/gas/elf/elf.exp: Run section12a, section12b and section13. * testsuite/gas/elf/section10.d: Updated. * testsuite/gas/elf/section10.s: Likewise. * testsuite/gas/elf/section12.s: New file. * testsuite/gas/elf/section12a.d: Likewise. * testsuite/gas/elf/section12b.d: Likewise. * testsuite/gas/elf/section13.l: Likewise. * testsuite/gas/elf/section13.d: Likewise. * testsuite/gas/elf/section13.s: Likewise. include/ * elf/common.h (PT_GNU_MBIND_NUM): New. (PT_GNU_MBIND_LO): Likewise. (PT_GNU_MBIND_HI): Likewise. (SHF_GNU_MBIND): Likewise. ld/ * NEWS: Mention support for ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX. * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Place input GNU_MBIND sections with the same type, attributes and sh_info field into a single output GNU_MBIND section. * testsuite/ld-elf/elf.exp: Run mbind2a and mbind2b. * testsuite/ld-elf/mbind1.s: New file. * testsuite/ld-elf/mbind1a.d: Likewise. * testsuite/ld-elf/mbind1b.d: Likewise. * testsuite/ld-elf/mbind1c.d: Likewise. * testsuite/ld-elf/mbind2a.s: Likewise. * testsuite/ld-elf/mbind2b.c: Likewise.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog35
-rw-r--r--gas/NEWS2
-rw-r--r--gas/config/obj-elf.c54
-rw-r--r--gas/config/obj-elf.h3
-rw-r--r--gas/config/tc-arm.c3
-rw-r--r--gas/config/tc-ia64.c2
-rw-r--r--gas/config/tc-microblaze.c18
-rw-r--r--gas/config/tc-mips.c2
-rw-r--r--gas/config/tc-msp430.c2
-rw-r--r--gas/config/tc-rx.c4
-rw-r--r--gas/config/tc-tic6x.c3
-rw-r--r--gas/doc/as.texinfo2
-rw-r--r--gas/testsuite/gas/elf/elf.exp3
-rw-r--r--gas/testsuite/gas/elf/section10.d4
-rw-r--r--gas/testsuite/gas/elf/section10.s4
-rw-r--r--gas/testsuite/gas/elf/section12.s33
-rw-r--r--gas/testsuite/gas/elf/section12a.d35
-rw-r--r--gas/testsuite/gas/elf/section12b.d32
-rw-r--r--gas/testsuite/gas/elf/section13.d2
-rw-r--r--gas/testsuite/gas/elf/section13.l2
-rw-r--r--gas/testsuite/gas/elf/section13.s2
21 files changed, 222 insertions, 25 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 557b43c..cc5f349 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,38 @@
+2017-04-04 H.J. Lu <hongjiu.lu@intel.com>
+
+ * NEWS: Mention support for ELF SHF_GNU_MBIND.
+ * config/obj-elf.c (section_match): New.
+ (get_section): Match both sh_info and group name.
+ (obj_elf_change_section): Add argument for sh_info. Pass both
+ sh_info and group name to get_section. Issue an error for
+ SHF_GNU_MBIND section without SHF_ALLOC. Set sh_info.
+ (obj_elf_parse_section_letters): Set SHF_GNU_MBIND for 'd'.
+ (obj_elf_section): Support SHF_GNU_MBIND section info.
+ * config/obj-elf.h (obj_elf_change_section): Add argument for
+ sh_info.
+ * config/tc-arm.c (start_unwind_section): Pass 0 as sh_info to
+ obj_elf_change_section.
+ * config/tc-ia64.c (obj_elf_vms_common): Likewise.
+ * config/tc-microblaze.c (microblaze_s_data): Likewise.
+ (microblaze_s_sdata): Likewise.
+ (microblaze_s_rdata): Likewise.
+ (microblaze_s_bss): Likewise.
+ * config/tc-mips.c (s_change_section): Likewise.
+ * config/tc-msp430.c (msp430_profiler): Likewise.
+ * config/tc-rx.c (parse_rx_section): Likewise.
+ * config/tc-tic6x.c (tic6x_start_unwind_section): Likewise.
+ * doc/as.texinfo: Document 'd' for SHF_GNU_MBIND.
+ * testsuite/gas/elf/elf.exp: Run section12a, section12b and
+ section13.
+ * testsuite/gas/elf/section10.d: Updated.
+ * testsuite/gas/elf/section10.s: Likewise.
+ * testsuite/gas/elf/section12.s: New file.
+ * testsuite/gas/elf/section12a.d: Likewise.
+ * testsuite/gas/elf/section12b.d: Likewise.
+ * testsuite/gas/elf/section13.l: Likewise.
+ * testsuite/gas/elf/section13.d: Likewise.
+ * testsuite/gas/elf/section13.s: Likewise.
+
2017-04-03 Palmer Dabbelt <palmer@dabbelt.com>
* config/tc-riscv.c (riscv_clear_subsets): Cast argument to free to
diff --git a/gas/NEWS b/gas/NEWS
index 46eaff3..2078d29 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -1,5 +1,7 @@
-*- text -*-
+* Add support for ELF SHF_GNU_MBIND.
+
* Add support for the WebAssembly file format and wasm32 ELF conversion.
* PowerPC gas now checks that the correct register class is used in
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 1d59fc0..3696d5e 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -520,16 +520,26 @@ struct section_stack
static struct section_stack *section_stack;
+/* Match both section group name and the sh_info field. */
+struct section_match
+{
+ const char *group_name;
+ unsigned int info;
+};
+
static bfd_boolean
get_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
{
- const char *gname = (const char *) inf;
+ struct section_match *match = (struct section_match *) inf;
+ const char *gname = match->group_name;
const char *group_name = elf_group_name (sec);
+ unsigned int info = elf_section_data (sec)->this_hdr.sh_info;
- return (group_name == gname
- || (group_name != NULL
- && gname != NULL
- && strcmp (group_name, gname) == 0));
+ return (info == match->info
+ && (group_name == gname
+ || (group_name != NULL
+ && gname != NULL
+ && strcmp (group_name, gname) == 0)));
}
/* Handle the .section pseudo-op. This code supports two different
@@ -553,6 +563,7 @@ get_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
void
obj_elf_change_section (const char *name,
unsigned int type,
+ unsigned int info,
bfd_vma attr,
int entsize,
const char *group_name,
@@ -564,6 +575,7 @@ obj_elf_change_section (const char *name,
flagword flags;
const struct elf_backend_data *bed;
const struct bfd_elf_special_section *ssect;
+ struct section_match match;
#ifdef md_flush_pending_output
md_flush_pending_output ();
@@ -584,8 +596,10 @@ obj_elf_change_section (const char *name,
previous_section = now_seg;
previous_subsection = now_subseg;
+ match.group_name = group_name;
+ match.info = info;
old_sec = bfd_get_section_by_name_if (stdoutput, name, get_section,
- (void *) group_name);
+ (void *) &match);
if (old_sec)
{
sec = old_sec;
@@ -695,6 +709,9 @@ obj_elf_change_section (const char *name,
attr |= ssect->attr;
}
+ if ((attr & (SHF_ALLOC | SHF_GNU_MBIND)) == SHF_GNU_MBIND)
+ as_fatal (_("SHF_ALLOC isn't set for GNU_MBIND section: %s"), name);
+
/* Convert ELF type and flags to BFD flags. */
flags = (SEC_RELOC
| ((attr & SHF_WRITE) ? 0 : SEC_READONLY)
@@ -720,6 +737,7 @@ obj_elf_change_section (const char *name,
type = bfd_elf_get_default_section_type (flags);
elf_section_type (sec) = type;
elf_section_flags (sec) = attr;
+ elf_section_data (sec)->this_hdr.sh_info = info;
/* Prevent SEC_HAS_CONTENTS from being inadvertently set. */
if (type == SHT_NOBITS)
@@ -803,6 +821,9 @@ obj_elf_parse_section_letters (char *str, size_t len, bfd_boolean *is_clone)
case 'T':
attr |= SHF_TLS;
break;
+ case 'd':
+ attr |= SHF_GNU_MBIND;
+ break;
case '?':
*is_clone = TRUE;
break;
@@ -996,6 +1017,7 @@ obj_elf_section (int push)
int entsize;
int linkonce;
subsegT new_subsection = -1;
+ unsigned int info = 0;
#ifndef TC_I370
if (flag_mri)
@@ -1159,6 +1181,23 @@ obj_elf_section (int push)
linkonce = (now_seg->flags & SEC_LINK_ONCE) != 0;
}
}
+
+ if ((attr & SHF_GNU_MBIND) != 0 && *input_line_pointer == ',')
+ {
+ ++input_line_pointer;
+ SKIP_WHITESPACE ();
+ if (ISDIGIT (* input_line_pointer))
+ {
+ char *t = input_line_pointer;
+ info = strtoul (input_line_pointer,
+ &input_line_pointer, 0);
+ if (info == (unsigned int) -1)
+ {
+ as_warn (_("unsupported mbind section info: %s"), t);
+ info = 0;
+ }
+ }
+ }
}
else
{
@@ -1189,7 +1228,8 @@ obj_elf_section (int push)
done:
demand_empty_rest_of_line ();
- obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push);
+ obj_elf_change_section (name, type, info, attr, entsize, group_name,
+ linkonce, push);
if (push && new_subsection != -1)
subseg_set (now_seg, new_subsection);
diff --git a/gas/config/obj-elf.h b/gas/config/obj-elf.h
index f6bd216..37d6aee 100644
--- a/gas/config/obj-elf.h
+++ b/gas/config/obj-elf.h
@@ -162,7 +162,8 @@ 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 *, unsigned int, bfd_vma, int, const char *, int, int);
+ (const char *, unsigned int, 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
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index bbfe634..83244b7 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -22113,7 +22113,8 @@ start_unwind_section (const segT text_seg, int idx)
linkonce = 1;
}
- obj_elf_change_section (sec_name, type, flags, 0, group_name, linkonce, 0);
+ obj_elf_change_section (sec_name, type, 0, flags, 0, group_name,
+ linkonce, 0);
/* Set the section link for index tables. */
if (idx)
diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c
index aa01eff..e236dd5 100644
--- a/gas/config/tc-ia64.c
+++ b/gas/config/tc-ia64.c
@@ -1139,7 +1139,7 @@ obj_elf_vms_common (int ignore ATTRIBUTE_UNUSED)
demand_empty_rest_of_line ();
obj_elf_change_section
- (sec_name, SHT_NOBITS,
+ (sec_name, SHT_NOBITS, 0,
SHF_ALLOC | SHF_WRITE | SHF_IA_64_VMS_OVERLAID | SHF_IA_64_VMS_GLOBAL,
0, NULL, 1, 0);
diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index c3b091f..0124422 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -145,7 +145,8 @@ static void
microblaze_s_data (int ignore ATTRIBUTE_UNUSED)
{
#ifdef OBJ_ELF
- obj_elf_change_section (".data", SHT_PROGBITS, SHF_ALLOC+SHF_WRITE, 0, 0, 0, 0);
+ obj_elf_change_section (".data", SHT_PROGBITS, 0, SHF_ALLOC+SHF_WRITE,
+ 0, 0, 0, 0);
#else
s_data (ignore);
#endif
@@ -157,7 +158,8 @@ static void
microblaze_s_sdata (int ignore ATTRIBUTE_UNUSED)
{
#ifdef OBJ_ELF
- obj_elf_change_section (".sdata", SHT_PROGBITS, SHF_ALLOC+SHF_WRITE, 0, 0, 0, 0);
+ obj_elf_change_section (".sdata", SHT_PROGBITS, 0, SHF_ALLOC+SHF_WRITE,
+ 0, 0, 0, 0);
#else
s_data (ignore);
#endif
@@ -275,14 +277,16 @@ microblaze_s_rdata (int localvar)
if (localvar == 0)
{
/* rodata. */
- obj_elf_change_section (".rodata", SHT_PROGBITS, SHF_ALLOC, 0, 0, 0, 0);
+ obj_elf_change_section (".rodata", SHT_PROGBITS, 0, SHF_ALLOC,
+ 0, 0, 0, 0);
if (rodata_segment == 0)
rodata_segment = subseg_new (".rodata", 0);
}
else
{
/* 1 .sdata2. */
- obj_elf_change_section (".sdata2", SHT_PROGBITS, SHF_ALLOC, 0, 0, 0, 0);
+ obj_elf_change_section (".sdata2", SHT_PROGBITS, 0, SHF_ALLOC,
+ 0, 0, 0, 0);
}
#else
s_data (ignore);
@@ -294,11 +298,13 @@ microblaze_s_bss (int localvar)
{
#ifdef OBJ_ELF
if (localvar == 0) /* bss. */
- obj_elf_change_section (".bss", SHT_NOBITS, SHF_ALLOC+SHF_WRITE, 0, 0, 0, 0);
+ obj_elf_change_section (".bss", SHT_NOBITS, 0, SHF_ALLOC+SHF_WRITE,
+ 0, 0, 0, 0);
else if (localvar == 1)
{
/* sbss. */
- obj_elf_change_section (".sbss", SHT_NOBITS, SHF_ALLOC+SHF_WRITE, 0, 0, 0, 0);
+ obj_elf_change_section (".sbss", SHT_NOBITS, 0, SHF_ALLOC+SHF_WRITE,
+ 0, 0, 0, 0);
if (sbss_segment == 0)
sbss_segment = subseg_new (".sbss", 0);
}
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 54b94be..6a98122 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -15879,7 +15879,7 @@ s_change_section (int ignore ATTRIBUTE_UNUSED)
if (section_type == SHT_MIPS_DWARF)
section_type = SHT_PROGBITS;
- obj_elf_change_section (section_name, section_type, section_flag,
+ obj_elf_change_section (section_name, section_type, 0, section_flag,
section_entry_size, 0, 0, 0);
if (now_seg->name != section_name)
diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c
index a24771b..10e5972 100644
--- a/gas/config/tc-msp430.c
+++ b/gas/config/tc-msp430.c
@@ -612,7 +612,7 @@ msp430_profiler (int dummy ATTRIBUTE_UNUSED)
subseg = now_subseg;
/* Now go to .profiler section. */
- obj_elf_change_section (".profiler", SHT_PROGBITS, 0, 0, 0, 0, 0);
+ obj_elf_change_section (".profiler", SHT_PROGBITS, 0, 0, 0, 0, 0, 0);
/* Save flags. */
emit_expr (& exp, 2);
diff --git a/gas/config/tc-rx.c b/gas/config/tc-rx.c
index 05fa4da..ba826c7 100644
--- a/gas/config/tc-rx.c
+++ b/gas/config/tc-rx.c
@@ -486,7 +486,7 @@ parse_rx_section (char * name)
else
type = SHT_NOBITS;
- obj_elf_change_section (name, type, attr, 0, NULL, FALSE, FALSE);
+ obj_elf_change_section (name, type, 0, attr, 0, NULL, FALSE, FALSE);
}
else /* Try not to redefine a section, especially B_1. */
{
@@ -501,7 +501,7 @@ parse_rx_section (char * name)
| ((flags & SEC_STRINGS) ? SHF_STRINGS : 0)
| ((flags & SEC_THREAD_LOCAL) ? SHF_TLS : 0);
- obj_elf_change_section (name, type, attr, 0, NULL, FALSE, FALSE);
+ obj_elf_change_section (name, type, 0, attr, 0, NULL, FALSE, FALSE);
}
bfd_set_section_alignment (stdoutput, now_seg, align);
diff --git a/gas/config/tc-tic6x.c b/gas/config/tc-tic6x.c
index c75fcf6..6958a0e 100644
--- a/gas/config/tc-tic6x.c
+++ b/gas/config/tc-tic6x.c
@@ -4666,7 +4666,8 @@ tic6x_start_unwind_section (const segT text_seg, int idx)
linkonce = 1;
}
- obj_elf_change_section (sec_name, type, flags, 0, group_name, linkonce, 0);
+ obj_elf_change_section (sec_name, type, 0, flags, 0, group_name,
+ linkonce, 0);
/* Set the section link for index tables. */
if (idx)
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index d03d0b6..a5cff3d 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -6525,6 +6525,8 @@ combination of the following characters:
@table @code
@item a
section is allocatable
+@item d
+section is a GNU_MBIND section
@item e
section is excluded from executable and shared library.
@item w
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index e4dd684..2a1bb27 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -209,6 +209,9 @@ if { [is_elf_format] } then {
run_dump_test "section9"
run_dump_test "section10"
run_dump_test "section11"
+ run_dump_test "section12a"
+ run_dump_test "section12b"
+ run_dump_test "section13"
run_dump_test "dwarf2-1"
run_dump_test "dwarf2-2"
run_dump_test "dwarf2-3"
diff --git a/gas/testsuite/gas/elf/section10.d b/gas/testsuite/gas/elf/section10.d
index aa5ca3c..e187263 100644
--- a/gas/testsuite/gas/elf/section10.d
+++ b/gas/testsuite/gas/elf/section10.d
@@ -18,7 +18,7 @@
#...
[ ]*\[.*\][ ]+sec3
[ ]*PROGBITS.*
-[ ]*\[.*ffff030\]: MERGE, STRINGS,.* EXCLUDE, OS \(.*ff00000\), PROC \(.*[347]0000000\), UNKNOWN \(0+0ff000\)
+[ ]*\[.*fefff030\]: MERGE, STRINGS,.* EXCLUDE, OS \(.*ef00000\), PROC \(.*[347]0000000\), UNKNOWN \(0+0ff000\)
#...
[ ]*\[.*\][ ]+sec4
[ ]*LOOS\+0x11[ ].*
@@ -26,7 +26,7 @@
#...
[ ]*\[.*\][ ]+sec5
[ ]*LOUSER\+0x9[ ].*
-[ ]*\[.*fff0000\]:.* EXCLUDE, OS \(.*ff00000\), PROC \(.*[347]0000000\), UNKNOWN \(.*f0000\)
+[ ]*\[.*feff0000\]:.* EXCLUDE, OS \(.*ef00000\), PROC \(.*[347]0000000\), UNKNOWN \(.*f0000\)
[ ]*\[.*\][ ]+.data.foo
[ ]*LOUSER\+0x7f000000[ ].*
[ ]*\[0+003\]: WRITE, ALLOC
diff --git a/gas/testsuite/gas/elf/section10.s b/gas/testsuite/gas/elf/section10.s
index 0576007..29f1184 100644
--- a/gas/testsuite/gas/elf/section10.s
+++ b/gas/testsuite/gas/elf/section10.s
@@ -7,7 +7,7 @@
.word 2
# Make sure that specifying further arguments to .sections is still supported
- .section sec3, "0xfffff000MS", %progbits, 32
+ .section sec3, "0xfefff000MS", %progbits, 32
.word 3
# Make sure that extra flags can be set for well known sections as well.
@@ -19,7 +19,7 @@
.word 5
# Test both together, with a quoted type value.
- .section sec5, "0xffff0000", "0x80000009"
+ .section sec5, "0xfeff0000", "0x80000009"
.word 6
# Test that declaring an extended version of a known special section works.
diff --git a/gas/testsuite/gas/elf/section12.s b/gas/testsuite/gas/elf/section12.s
new file mode 100644
index 0000000..41faad4
--- /dev/null
+++ b/gas/testsuite/gas/elf/section12.s
@@ -0,0 +1,33 @@
+ .section .mbind.data,"adw",%progbits
+ .byte 1
+
+ .section .mbind.data,"adw",%progbits,0x3
+ .byte 2
+
+ .section .mbind.text,"adx",%progbits
+ .byte 3
+
+ .section .mbind.text,"adx",%progbits,0x3
+ .byte 4
+
+ .section .mbind.bss,"adw",%nobits
+ .zero 5
+
+ .section .mbind.bss,"adw",%nobits,0x3
+ .zero 6
+
+ .section .mbind.rodata,"adG",%progbits,.foo_group,comdat,0x2
+ .byte 7
+
+ .section .mbind.data,"adGw",%progbits,.foo_group,comdat
+ .byte 8
+
+ .section .mbind.data,"adGw",%progbits,.foo_group,comdat,0x3
+ .byte 9
+
+ # Check that .pushsection works as well.
+ .pushsection .mbind.text,"adGx",%progbits,.foo_group,comdat,0x3
+ .byte 10
+
+ .popsection
+ .byte 11
diff --git a/gas/testsuite/gas/elf/section12a.d b/gas/testsuite/gas/elf/section12a.d
new file mode 100644
index 0000000..d31a675
--- /dev/null
+++ b/gas/testsuite/gas/elf/section12a.d
@@ -0,0 +1,35 @@
+#source: section12.s
+#as: --no-pad-sections
+#readelf: -Sg --wide
+#name: mbind sections
+# The RX port annoyingly reorders the sections so that they do not match the sequence expected below.
+#skip: rx-*-*
+
+#...
+ \[[ 0-9]+\] \.mbind\.data[ ]+PROGBITS[ ]+0+0 0+[0-9a-f]+ 0+1 00 WAD 0 0 1
+#...
+ \[[ 0-9]+\] \.mbind\.data[ ]+PROGBITS[ ]+0+0 0+[0-9a-f]+ 0+1 00 WAD 0 3 1
+#...
+ \[[ 0-9]+\] \.mbind\.text[ ]+PROGBITS[ ]+0+0 0+[0-9a-f]+ 0+1 00 AXD 0 0 1
+#...
+ \[[ 0-9]+\] \.mbind\.text[ ]+PROGBITS[ ]+0+0 0+[0-9a-f]+ 0+1 00 AXD 0 3 1
+#...
+ \[[ 0-9]+\] \.mbind\.bss[ ]+NOBITS[ ]+0+0 0+[0-9a-f]+ 0+5 00 WAD 0 0 1
+#...
+ \[[ 0-9]+\] \.mbind\.bss[ ]+NOBITS[ ]+0+0 0+[0-9a-f]+ 0+6 00 WAD 0 3 1
+#...
+ \[[ 0-9]+\] \.mbind\.rodata[ ]+PROGBITS[ ]+0+0 0+[0-9a-f]+ 0+1 00 AGD 0 2 1
+#...
+ \[[ 0-9]+\] \.mbind\.data[ ]+PROGBITS[ ]+0+0 0+[0-9a-f]+ 0+1 00 WAGD 0 0 1
+#...
+ \[[ 0-9]+\] \.mbind\.data[ ]+PROGBITS[ ]+0+0 0+[0-9a-f]+ 0+2 00 WAGD 0 3 1
+#...
+ \[[ 0-9]+\] \.mbind\.text[ ]+PROGBITS[ ]+0+0 0+[0-9a-f]+ 0+1 00 AXGD 0 3 1
+#...
+COMDAT group section \[ 1\] `\.group' \[\.foo_group\] contains 4 sections:
+[ ]+\[Index\][ ]+Name
+[ ]+\[[ 0-9]+][ ]+\.mbind\.rodata
+[ ]+\[[ 0-9]+][ ]+\.mbind\.data
+[ ]+\[[ 0-9]+][ ]+\.mbind\.data
+[ ]+\[[ 0-9]+][ ]+\.mbind\.text
+#pass
diff --git a/gas/testsuite/gas/elf/section12b.d b/gas/testsuite/gas/elf/section12b.d
new file mode 100644
index 0000000..717bc1a
--- /dev/null
+++ b/gas/testsuite/gas/elf/section12b.d
@@ -0,0 +1,32 @@
+#source: section12.s
+#as: --no-pad-sections
+#objdump: -s
+#name: mbind section contents
+# The RX port annoyingly reorders the sections so that they do not match the sequence expected below.
+#skip: rx-*-*
+
+#...
+Contents of section .mbind.data:
+ 0000 01 .
+#...
+Contents of section .mbind.data:
+ 0000 02 .
+#...
+Contents of section .mbind.text:
+ 0000 03 .
+#...
+Contents of section .mbind.text:
+ 0000 04 .
+#...
+Contents of section .mbind.rodata:
+ 0000 07 .
+#...
+Contents of section .mbind.data:
+ 0000 08 .
+#...
+Contents of section .mbind.data:
+ 0000 090b ..
+#...
+Contents of section .mbind.text:
+ 0000 0a .
+#pass
diff --git a/gas/testsuite/gas/elf/section13.d b/gas/testsuite/gas/elf/section13.d
new file mode 100644
index 0000000..3ee7c82
--- /dev/null
+++ b/gas/testsuite/gas/elf/section13.d
@@ -0,0 +1,2 @@
+#name: mbind sections without SHF_ALLOC
+#error-output: section13.l
diff --git a/gas/testsuite/gas/elf/section13.l b/gas/testsuite/gas/elf/section13.l
new file mode 100644
index 0000000..c56b5ae
--- /dev/null
+++ b/gas/testsuite/gas/elf/section13.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*:1: Fatal error: SHF_ALLOC isn't set for GNU_MBIND section: .mbind.data
diff --git a/gas/testsuite/gas/elf/section13.s b/gas/testsuite/gas/elf/section13.s
new file mode 100644
index 0000000..6630f35
--- /dev/null
+++ b/gas/testsuite/gas/elf/section13.s
@@ -0,0 +1,2 @@
+ .section .mbind.data,"dw",@nobits
+ .byte 0