[v2] gas: Allow SHF_GNU_RETAIN on .note/.rodata.str sections

Message ID CAMe9rOoRfgiAwvqUBujpFCW6dZ7V4Oh7QBFrvVZv1p33KRxNSw@mail.gmail.com
State New
Headers show
Series
  • [v2] gas: Allow SHF_GNU_RETAIN on .note/.rodata.str sections
Related show

Commit Message

Alan Modra via Binutils Feb. 16, 2021, 2:20 a.m.
On Mon, Feb 15, 2021 at 3:28 PM Alan Modra <amodra@gmail.com> wrote:
>

> On Mon, Feb 15, 2021 at 07:43:39AM -0800, H.J. Lu wrote:

> > On Sat, Feb 13, 2021 at 7:25 AM H.J. Lu <hjl.tools@gmail.com> wrote:

> > >

> > > Since SHF_GNU_RETAIN is allowed on SHT_NOTE section, strip SHF_GNU_RETAIN

> > > when checking incorrect section attributes on SHT_NOTE section.

> > >

> > >         PR gas/27412

> > >         * config/obj-elf.c (obj_elf_change_section): Strip SHF_GNU_RETAIN.

> > >         * testsuite/gas/elf/elf.exp: Run section28.

> > >         * testsuite/gas/elf/section28.d: New file.

> > >         * testsuite/gas/elf/section28.s: Likewise.

> > > ---

> > >  gas/config/obj-elf.c              |  8 +++++++-

> > >  gas/testsuite/gas/elf/elf.exp     |  1 +

> > >  gas/testsuite/gas/elf/section28.d | 15 +++++++++++++++

> > >  gas/testsuite/gas/elf/section28.s | 11 +++++++++++

> > >  4 files changed, 34 insertions(+), 1 deletion(-)

> > >  create mode 100644 gas/testsuite/gas/elf/section28.d

> > >  create mode 100644 gas/testsuite/gas/elf/section28.s

> > >

> > > diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c

> > > index f52dc69f0c3..13f54b10857 100644

> > > --- a/gas/config/obj-elf.c

> > > +++ b/gas/config/obj-elf.c

> > > @@ -667,12 +667,18 @@ obj_elf_change_section (const char *name,

> > >                                         | SHF_MASKPROC))

> > >                               & ~ssect->attr) != 0)

> > >         {

> > > +         /* Strip SHF_GNU_RETAIN.  */

> > > +         bfd_vma generic_attr = attr;

> > > +         if (elf_tdata (stdoutput)->has_gnu_osabi)

> > > +           generic_attr &= ~SHF_GNU_RETAIN;

> > > +

> > >           /* As a GNU extension, we permit a .note section to be

> > >              allocatable.  If the linker sees an allocatable .note

> > >              section, it will create a PT_NOTE segment in the output

> > >              file.  We also allow "x" for .note.GNU-stack.  */

> > >           if (ssect->type == SHT_NOTE

> > > -             && (attr == SHF_ALLOC || attr == SHF_EXECINSTR))

> > > +             && (generic_attr == SHF_ALLOC

> > > +                 || generic_attr == SHF_EXECINSTR))

> > >             ;

> > >           /* Allow different SHF_MERGE and SHF_STRINGS if we have

> > >              something like .rodata.str.  */

>

> Should you be using generic_attr in later tests in this block?  If we

> allow .rodata.str with a differing SHF_MERGE flag then it seems

> reasonable to also allow SHF_GNU_RETAIN to differ.

>


Like this?

-- 
H.J.

Comments

Alan Modra via Binutils Feb. 16, 2021, 3:04 a.m. | #1
On Mon, Feb 15, 2021 at 06:20:19PM -0800, H.J. Lu wrote:
> On Mon, Feb 15, 2021 at 3:28 PM Alan Modra <amodra@gmail.com> wrote:

> >

> > On Mon, Feb 15, 2021 at 07:43:39AM -0800, H.J. Lu wrote:

> > > On Sat, Feb 13, 2021 at 7:25 AM H.J. Lu <hjl.tools@gmail.com> wrote:

> > > >

> > > > Since SHF_GNU_RETAIN is allowed on SHT_NOTE section, strip SHF_GNU_RETAIN

> > > > when checking incorrect section attributes on SHT_NOTE section.

> > > >

> > > >         PR gas/27412

> > > >         * config/obj-elf.c (obj_elf_change_section): Strip SHF_GNU_RETAIN.

> > > >         * testsuite/gas/elf/elf.exp: Run section28.

> > > >         * testsuite/gas/elf/section28.d: New file.

> > > >         * testsuite/gas/elf/section28.s: Likewise.

> > > > ---

> > > >  gas/config/obj-elf.c              |  8 +++++++-

> > > >  gas/testsuite/gas/elf/elf.exp     |  1 +

> > > >  gas/testsuite/gas/elf/section28.d | 15 +++++++++++++++

> > > >  gas/testsuite/gas/elf/section28.s | 11 +++++++++++

> > > >  4 files changed, 34 insertions(+), 1 deletion(-)

> > > >  create mode 100644 gas/testsuite/gas/elf/section28.d

> > > >  create mode 100644 gas/testsuite/gas/elf/section28.s

> > > >

> > > > diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c

> > > > index f52dc69f0c3..13f54b10857 100644

> > > > --- a/gas/config/obj-elf.c

> > > > +++ b/gas/config/obj-elf.c

> > > > @@ -667,12 +667,18 @@ obj_elf_change_section (const char *name,

> > > >                                         | SHF_MASKPROC))

> > > >                               & ~ssect->attr) != 0)

> > > >         {

> > > > +         /* Strip SHF_GNU_RETAIN.  */

> > > > +         bfd_vma generic_attr = attr;

> > > > +         if (elf_tdata (stdoutput)->has_gnu_osabi)

> > > > +           generic_attr &= ~SHF_GNU_RETAIN;

> > > > +

> > > >           /* As a GNU extension, we permit a .note section to be

> > > >              allocatable.  If the linker sees an allocatable .note

> > > >              section, it will create a PT_NOTE segment in the output

> > > >              file.  We also allow "x" for .note.GNU-stack.  */

> > > >           if (ssect->type == SHT_NOTE

> > > > -             && (attr == SHF_ALLOC || attr == SHF_EXECINSTR))

> > > > +             && (generic_attr == SHF_ALLOC

> > > > +                 || generic_attr == SHF_EXECINSTR))

> > > >             ;

> > > >           /* Allow different SHF_MERGE and SHF_STRINGS if we have

> > > >              something like .rodata.str.  */

> >

> > Should you be using generic_attr in later tests in this block?  If we

> > allow .rodata.str with a differing SHF_MERGE flag then it seems

> > reasonable to also allow SHF_GNU_RETAIN to differ.

> >

> 

> Like this?


Why not use generic_attr in *all* of the tests in this block?  I think
that would be better.  OK with that change.

-- 
Alan Modra
Australia Development Lab, IBM
Alan Modra via Binutils Feb. 16, 2021, 12:54 p.m. | #2
On Mon, Feb 15, 2021 at 7:04 PM Alan Modra <amodra@gmail.com> wrote:
>

> On Mon, Feb 15, 2021 at 06:20:19PM -0800, H.J. Lu wrote:

> > On Mon, Feb 15, 2021 at 3:28 PM Alan Modra <amodra@gmail.com> wrote:

> > >

> > > On Mon, Feb 15, 2021 at 07:43:39AM -0800, H.J. Lu wrote:

> > > > On Sat, Feb 13, 2021 at 7:25 AM H.J. Lu <hjl.tools@gmail.com> wrote:

> > > > >

> > > > > Since SHF_GNU_RETAIN is allowed on SHT_NOTE section, strip SHF_GNU_RETAIN

> > > > > when checking incorrect section attributes on SHT_NOTE section.

> > > > >

> > > > >         PR gas/27412

> > > > >         * config/obj-elf.c (obj_elf_change_section): Strip SHF_GNU_RETAIN.

> > > > >         * testsuite/gas/elf/elf.exp: Run section28.

> > > > >         * testsuite/gas/elf/section28.d: New file.

> > > > >         * testsuite/gas/elf/section28.s: Likewise.

> > > > > ---

> > > > >  gas/config/obj-elf.c              |  8 +++++++-

> > > > >  gas/testsuite/gas/elf/elf.exp     |  1 +

> > > > >  gas/testsuite/gas/elf/section28.d | 15 +++++++++++++++

> > > > >  gas/testsuite/gas/elf/section28.s | 11 +++++++++++

> > > > >  4 files changed, 34 insertions(+), 1 deletion(-)

> > > > >  create mode 100644 gas/testsuite/gas/elf/section28.d

> > > > >  create mode 100644 gas/testsuite/gas/elf/section28.s

> > > > >

> > > > > diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c

> > > > > index f52dc69f0c3..13f54b10857 100644

> > > > > --- a/gas/config/obj-elf.c

> > > > > +++ b/gas/config/obj-elf.c

> > > > > @@ -667,12 +667,18 @@ obj_elf_change_section (const char *name,

> > > > >                                         | SHF_MASKPROC))

> > > > >                               & ~ssect->attr) != 0)

> > > > >         {

> > > > > +         /* Strip SHF_GNU_RETAIN.  */

> > > > > +         bfd_vma generic_attr = attr;

> > > > > +         if (elf_tdata (stdoutput)->has_gnu_osabi)

> > > > > +           generic_attr &= ~SHF_GNU_RETAIN;

> > > > > +

> > > > >           /* As a GNU extension, we permit a .note section to be

> > > > >              allocatable.  If the linker sees an allocatable .note

> > > > >              section, it will create a PT_NOTE segment in the output

> > > > >              file.  We also allow "x" for .note.GNU-stack.  */

> > > > >           if (ssect->type == SHT_NOTE

> > > > > -             && (attr == SHF_ALLOC || attr == SHF_EXECINSTR))

> > > > > +             && (generic_attr == SHF_ALLOC

> > > > > +                 || generic_attr == SHF_EXECINSTR))

> > > > >             ;

> > > > >           /* Allow different SHF_MERGE and SHF_STRINGS if we have

> > > > >              something like .rodata.str.  */

> > >

> > > Should you be using generic_attr in later tests in this block?  If we

> > > allow .rodata.str with a differing SHF_MERGE flag then it seems

> > > reasonable to also allow SHF_GNU_RETAIN to differ.

> > >

> >

> > Like this?

>

> Why not use generic_attr in *all* of the tests in this block?  I think

> that would be better.  OK with that change.

>


This is the patch I am checking in.

-- 
H.J.
From 5ac6bc3775a59d537a50663e1044947915bac81e Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 13 Feb 2021 07:21:14 -0800
Subject: [PATCH v3] gas: Allow SHF_GNU_RETAIN on all sections

Since SHF_GNU_RETAIN is allowed on all sections, strip SHF_GNU_RETAIN
when checking incorrect section attributes.

	PR gas/27412
	* config/obj-elf.c (obj_elf_change_section): Strip SHF_GNU_RETAIN
	when checking incorrect section attributes.
	* testsuite/gas/elf/elf.exp: Run section28 and section29.
	* testsuite/gas/elf/section28.d: New file.
	* testsuite/gas/elf/section28.s: Likewise.
	* testsuite/gas/elf/section29.d: Likewise.
	* testsuite/gas/elf/section29.s: Likewise.
---
 gas/config/obj-elf.c              | 18 ++++++++++++------
 gas/testsuite/gas/elf/elf.exp     |  2 ++
 gas/testsuite/gas/elf/section28.d | 15 +++++++++++++++
 gas/testsuite/gas/elf/section28.s | 11 +++++++++++
 gas/testsuite/gas/elf/section29.d | 11 +++++++++++
 gas/testsuite/gas/elf/section29.s |  4 ++++
 6 files changed, 55 insertions(+), 6 deletions(-)
 create mode 100644 gas/testsuite/gas/elf/section28.d
 create mode 100644 gas/testsuite/gas/elf/section28.s
 create mode 100644 gas/testsuite/gas/elf/section29.d
 create mode 100644 gas/testsuite/gas/elf/section29.s

diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index f52dc69f0c3..2fb8ccda48b 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -667,39 +667,45 @@ obj_elf_change_section (const char *name,
 					| SHF_MASKPROC))
 			      & ~ssect->attr) != 0)
 	{
+	  /* Strip SHF_GNU_RETAIN.  */
+	  bfd_vma generic_attr = attr;
+	  if (elf_tdata (stdoutput)->has_gnu_osabi)
+	    generic_attr &= ~SHF_GNU_RETAIN;
+
 	  /* As a GNU extension, we permit a .note section to be
 	     allocatable.  If the linker sees an allocatable .note
 	     section, it will create a PT_NOTE segment in the output
 	     file.  We also allow "x" for .note.GNU-stack.  */
 	  if (ssect->type == SHT_NOTE
-	      && (attr == SHF_ALLOC || attr == SHF_EXECINSTR))
+	      && (generic_attr == SHF_ALLOC
+		  || generic_attr == SHF_EXECINSTR))
 	    ;
 	  /* Allow different SHF_MERGE and SHF_STRINGS if we have
 	     something like .rodata.str.  */
 	  else if (ssect->suffix_length == -2
 		   && name[ssect->prefix_length] == '.'
-		   && (attr
+		   && (generic_attr
 		       & ~ssect->attr
 		       & ~SHF_MERGE
 		       & ~SHF_STRINGS) == 0)
 	    ;
 	  /* .interp, .strtab and .symtab can have SHF_ALLOC.  */
-	  else if (attr == SHF_ALLOC
+	  else if (generic_attr == SHF_ALLOC
 		   && (strcmp (name, ".interp") == 0
 		       || strcmp (name, ".strtab") == 0
 		       || strcmp (name, ".symtab") == 0))
 	    override = TRUE;
 	  /* .note.GNU-stack can have SHF_EXECINSTR.  */
-	  else if (attr == SHF_EXECINSTR
+	  else if (generic_attr == SHF_EXECINSTR
 		   && strcmp (name, ".note.GNU-stack") == 0)
 	    override = TRUE;
 #ifdef TC_ALPHA
 	  /* A section on Alpha may have SHF_ALPHA_GPREL.  */
-	  else if ((attr & ~ssect->attr) == SHF_ALPHA_GPREL)
+	  else if ((generic_attr & ~ssect->attr) == SHF_ALPHA_GPREL)
 	    override = TRUE;
 #endif
 #ifdef TC_RX
-	  else if (attr == (SHF_EXECINSTR | SHF_WRITE | SHF_ALLOC)
+	  else if (generic_attr == (SHF_EXECINSTR | SHF_WRITE | SHF_ALLOC)
 		   && (ssect->type == SHT_INIT_ARRAY
 		       || ssect->type == SHT_FINI_ARRAY
 		       || ssect->type == SHT_PREINIT_ARRAY))
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index 2917ea9fe5b..525f47c0023 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -273,6 +273,8 @@ if { [is_elf_format] } then {
     run_dump_test "section25"
     run_dump_test "section26"
     run_dump_test "section27"
+    run_dump_test "section28"
+    run_dump_test "section29"
     run_dump_test "sh-link-zero"
     run_dump_test "dwarf2-1" $dump_opts
     run_dump_test "dwarf2-2" $dump_opts
diff --git a/gas/testsuite/gas/elf/section28.d b/gas/testsuite/gas/elf/section28.d
new file mode 100644
index 00000000000..a1fd65b0a65
--- /dev/null
+++ b/gas/testsuite/gas/elf/section28.d
@@ -0,0 +1,15 @@
+#readelf: -h -S --wide
+#name: SHF_GNU_RETAIN sections 28
+#notarget: ![supports_gnu_osabi]
+
+#...
+ +OS/ABI: +UNIX - (GNU|FreeBSD)
+#...
+  \[..\] \.note\.Linux +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +A +0.*
+#...
+  \[..\] \.note\.Linux +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +AR +0.*
+#...
+  \[..\] \.note\.foo +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +0 +.*
+#...
+  \[..\] \.note\.foo +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +R +0 +.*
+#pass
diff --git a/gas/testsuite/gas/elf/section28.s b/gas/testsuite/gas/elf/section28.s
new file mode 100644
index 00000000000..ebcf42c2e24
--- /dev/null
+++ b/gas/testsuite/gas/elf/section28.s
@@ -0,0 +1,11 @@
+	.section	.note.Linux,"a"
+	.word	1
+
+	.section	.note.Linux,"aR"
+	.word	1
+
+	.section	.note.foo
+	.word	1
+
+	.section	.note.foo,"R"
+	.word	1
diff --git a/gas/testsuite/gas/elf/section29.d b/gas/testsuite/gas/elf/section29.d
new file mode 100644
index 00000000000..7e1b48273cb
--- /dev/null
+++ b/gas/testsuite/gas/elf/section29.d
@@ -0,0 +1,11 @@
+#readelf: -h -S --wide
+#name: SHF_GNU_RETAIN sections 29
+#notarget: ![supports_gnu_osabi]
+
+#...
+ +OS/ABI: +UNIX - (GNU|FreeBSD)
+#...
+  \[..\] \.rodata\.str1\.1 +PROGBITS +[0-9a-f]+ [0-9a-f]+ 0+4 +01 +AMS +0 +0 +1
+#...
+  \[..\] \.rodata\.str1\.1 +PROGBITS +[0-9a-f]+ [0-9a-f]+ 0+4 +01 +AMSR +0 +0 +1
+#pass
diff --git a/gas/testsuite/gas/elf/section29.s b/gas/testsuite/gas/elf/section29.s
new file mode 100644
index 00000000000..772031e565f
--- /dev/null
+++ b/gas/testsuite/gas/elf/section29.s
@@ -0,0 +1,4 @@
+	.section	.rodata.str1.1,"aMS",%progbits,1
+	.asciz "foo"
+	.section	.rodata.str1.1,"aMSR",%progbits,1
+	.asciz "bar"

Patch

From 8af62f5f1409d1810544402b238dc335a13e1360 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 13 Feb 2021 07:21:14 -0800
Subject: [PATCH v2] gas: Allow SHF_GNU_RETAIN on .note/.rodata.str sections

Since SHF_GNU_RETAIN is allowed on .note and .rodata.str sections, strip
SHF_GNU_RETAIN when checking incorrect section attributes on them.

	PR gas/27412
	* config/obj-elf.c (obj_elf_change_section): Strip SHF_GNU_RETAIN
	on SHT_NOTE and .rodata.str sections.
	* testsuite/gas/elf/elf.exp: Run section28 and section29.
	* testsuite/gas/elf/section28.d: New file.
	* testsuite/gas/elf/section28.s: Likewise.
	* testsuite/gas/elf/section29.d: Likewise.
	* testsuite/gas/elf/section29.s: Likewise.
---
 gas/config/obj-elf.c              | 10 ++++++++--
 gas/testsuite/gas/elf/elf.exp     |  2 ++
 gas/testsuite/gas/elf/section28.d | 15 +++++++++++++++
 gas/testsuite/gas/elf/section28.s | 11 +++++++++++
 gas/testsuite/gas/elf/section29.d | 11 +++++++++++
 gas/testsuite/gas/elf/section29.s |  4 ++++
 6 files changed, 51 insertions(+), 2 deletions(-)
 create mode 100644 gas/testsuite/gas/elf/section28.d
 create mode 100644 gas/testsuite/gas/elf/section28.s
 create mode 100644 gas/testsuite/gas/elf/section29.d
 create mode 100644 gas/testsuite/gas/elf/section29.s

diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index f52dc69f0c3..646dfb7c7b6 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -667,18 +667,24 @@  obj_elf_change_section (const char *name,
 					| SHF_MASKPROC))
 			      & ~ssect->attr) != 0)
 	{
+	  /* Strip SHF_GNU_RETAIN.  */
+	  bfd_vma generic_attr = attr;
+	  if (elf_tdata (stdoutput)->has_gnu_osabi)
+	    generic_attr &= ~SHF_GNU_RETAIN;
+
 	  /* As a GNU extension, we permit a .note section to be
 	     allocatable.  If the linker sees an allocatable .note
 	     section, it will create a PT_NOTE segment in the output
 	     file.  We also allow "x" for .note.GNU-stack.  */
 	  if (ssect->type == SHT_NOTE
-	      && (attr == SHF_ALLOC || attr == SHF_EXECINSTR))
+	      && (generic_attr == SHF_ALLOC
+		  || generic_attr == SHF_EXECINSTR))
 	    ;
 	  /* Allow different SHF_MERGE and SHF_STRINGS if we have
 	     something like .rodata.str.  */
 	  else if (ssect->suffix_length == -2
 		   && name[ssect->prefix_length] == '.'
-		   && (attr
+		   && (generic_attr
 		       & ~ssect->attr
 		       & ~SHF_MERGE
 		       & ~SHF_STRINGS) == 0)
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index 2917ea9fe5b..525f47c0023 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -273,6 +273,8 @@  if { [is_elf_format] } then {
     run_dump_test "section25"
     run_dump_test "section26"
     run_dump_test "section27"
+    run_dump_test "section28"
+    run_dump_test "section29"
     run_dump_test "sh-link-zero"
     run_dump_test "dwarf2-1" $dump_opts
     run_dump_test "dwarf2-2" $dump_opts
diff --git a/gas/testsuite/gas/elf/section28.d b/gas/testsuite/gas/elf/section28.d
new file mode 100644
index 00000000000..a1fd65b0a65
--- /dev/null
+++ b/gas/testsuite/gas/elf/section28.d
@@ -0,0 +1,15 @@ 
+#readelf: -h -S --wide
+#name: SHF_GNU_RETAIN sections 28
+#notarget: ![supports_gnu_osabi]
+
+#...
+ +OS/ABI: +UNIX - (GNU|FreeBSD)
+#...
+  \[..\] \.note\.Linux +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +A +0.*
+#...
+  \[..\] \.note\.Linux +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +AR +0.*
+#...
+  \[..\] \.note\.foo +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +0 +.*
+#...
+  \[..\] \.note\.foo +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +R +0 +.*
+#pass
diff --git a/gas/testsuite/gas/elf/section28.s b/gas/testsuite/gas/elf/section28.s
new file mode 100644
index 00000000000..ebcf42c2e24
--- /dev/null
+++ b/gas/testsuite/gas/elf/section28.s
@@ -0,0 +1,11 @@ 
+	.section	.note.Linux,"a"
+	.word	1
+
+	.section	.note.Linux,"aR"
+	.word	1
+
+	.section	.note.foo
+	.word	1
+
+	.section	.note.foo,"R"
+	.word	1
diff --git a/gas/testsuite/gas/elf/section29.d b/gas/testsuite/gas/elf/section29.d
new file mode 100644
index 00000000000..7e1b48273cb
--- /dev/null
+++ b/gas/testsuite/gas/elf/section29.d
@@ -0,0 +1,11 @@ 
+#readelf: -h -S --wide
+#name: SHF_GNU_RETAIN sections 29
+#notarget: ![supports_gnu_osabi]
+
+#...
+ +OS/ABI: +UNIX - (GNU|FreeBSD)
+#...
+  \[..\] \.rodata\.str1\.1 +PROGBITS +[0-9a-f]+ [0-9a-f]+ 0+4 +01 +AMS +0 +0 +1
+#...
+  \[..\] \.rodata\.str1\.1 +PROGBITS +[0-9a-f]+ [0-9a-f]+ 0+4 +01 +AMSR +0 +0 +1
+#pass
diff --git a/gas/testsuite/gas/elf/section29.s b/gas/testsuite/gas/elf/section29.s
new file mode 100644
index 00000000000..772031e565f
--- /dev/null
+++ b/gas/testsuite/gas/elf/section29.s
@@ -0,0 +1,4 @@ 
+	.section	.rodata.str1.1,"aMS",%progbits,1
+	.asciz "foo"
+	.section	.rodata.str1.1,"aMSR",%progbits,1
+	.asciz "bar"
-- 
2.29.2