]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: Skip __[start|stop]_SECNAME for --gc-sections -z start-stop-gc
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 1 Dec 2021 12:55:24 +0000 (04:55 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 2 Dec 2021 11:55:10 +0000 (03:55 -0800)
Don't convert memory load to immediate load on __start_SECNAME and
__stop_SECNAME for --gc-sections -z start-stop-gc if all SECNAME
sections been garbage collected.

bfd/

PR ld/27491
* elf32-i386.c (elf_i386_convert_load_reloc): Skip __start_SECNAME
and __stop_SECNAME for --gc-sections -z start-stop-gc if the input
section been garbage collected.
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise.
* elfxx-x86.h (elf_x86_start_stop_gc_p): New function.

ld/
PR ld/27491
* testsuite/ld-i386/i386.exp: Run PR ld/27491 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr27491-1.s: New file.
* testsuite/ld-i386/pr27491-1a.d: Likewise.
* testsuite/ld-i386/pr27491-1b.d: Likewise.
* testsuite/ld-i386/pr27491-1c.d: Likewise.
* testsuite/ld-i386/pr27491-2.d: Likewise.
* testsuite/ld-i386/pr27491-2.s: Likewise.
* testsuite/ld-i386/pr27491-3.d: Likewise.
* testsuite/ld-i386/pr27491-3.s: Likewise.
* testsuite/ld-i386/pr27491-4.d: Likewise.
* testsuite/ld-i386/pr27491-4a.s: Likewise.
* testsuite/ld-i386/pr27491-4b.s: Likewise.
* testsuite/ld-x86-64/pr27491-1.s: Likewise.
* testsuite/ld-x86-64/pr27491-1a.d: Likewise.
* testsuite/ld-x86-64/pr27491-1b.d: Likewise.
* testsuite/ld-x86-64/pr27491-1c.d: Likewise.
* testsuite/ld-x86-64/pr27491-2.d: Likewise.
* testsuite/ld-x86-64/pr27491-2.s: Likewise.
* testsuite/ld-x86-64/pr27491-3.d: Likewise.
* testsuite/ld-x86-64/pr27491-3.s: Likewise.
* testsuite/ld-x86-64/pr27491-4.d: Likewise.
* testsuite/ld-x86-64/pr27491-4a.s: Likewise.
* testsuite/ld-x86-64/pr27491-4b.s: Likewise.

27 files changed:
bfd/elf32-i386.c
bfd/elf64-x86-64.c
bfd/elfxx-x86.h
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/pr27491-1.s [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-1a.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-1b.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-1c.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-2.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-2.s [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-3.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-3.s [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-4.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-4a.s [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-4b.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-1.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-1a.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-1b.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-1c.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-2.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-2.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-3.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-3.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-4.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-4a.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-4b.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index 0d7f29097e4bd271c8ab16dad4c66e5fe62051e1..db6d1accdbc7e0143757206fea53cddfd709315b 100644 (file)
@@ -1393,6 +1393,11 @@ elf_i386_convert_load_reloc (bfd *abfd, Elf_Internal_Shdr *symtab_hdr,
               || h->root.type == bfd_link_hash_defweak)
              && local_ref))
        {
+         /* Skip __start_SECNAME/__stop_SECNAME when --gc-sections
+            -z start-stop-gc are used.  */
+         if (elf_x86_start_stop_gc_p (link_info, h))
+           return true;
+
        convert_load:
          if (opcode == 0x8b)
            {
index 25e2bb156e8105e234e199238ab38eb540255638..bb6df798d7b04db28756f9d4cad49325c6c18d26 100644 (file)
@@ -1643,6 +1643,11 @@ elf_x86_64_convert_load_reloc (bfd *abfd,
                           || h->root.type == bfd_link_hash_defweak)
                          && h->root.u.def.section == bfd_und_section_ptr))))
            {
+             /* Skip __start_SECNAME/__stop_SECNAME when --gc-sections
+                -z start-stop-gc are used.  */
+             if (elf_x86_start_stop_gc_p (link_info, h))
+               return true;
+
              /* Skip since R_X86_64_32/R_X86_64_32S may overflow.  */
              if (no_overflow)
                return true;
index 8251f641a77b6f1dada208882df4a09b33732df6..aab641ab751db9873cca55cfbbc23d67c430baad 100644 (file)
@@ -731,3 +731,36 @@ extern void _bfd_x86_elf_link_report_relative_reloc
   _bfd_x86_elf_merge_gnu_properties
 #define elf_backend_fixup_gnu_properties \
   _bfd_x86_elf_link_fixup_gnu_properties
+
+/* Return true if H is a __start_SECNAME/__stop_SECNAME symbol for the
+   SECNAME section which has been garbage collected by --gc-sections
+   -z start-stop-gc.  */
+
+static inline bool
+elf_x86_start_stop_gc_p (struct bfd_link_info *link_info,
+                        struct elf_link_hash_entry *h)
+{
+  if (h->start_stop
+      && link_info->gc_sections
+      && link_info->start_stop_gc)
+    {
+      asection *s = h->root.u.def.section;
+
+      do
+       {
+         /* Return false if any SECNAME section is kept.  */
+         if (s->gc_mark)
+           return false;
+         s = bfd_get_next_section_by_name (s->owner, s);
+       }
+      while (s != NULL);
+
+      /* Return true only if all SECNAME sections have been garbage
+        collected.  */
+      return true;
+    }
+
+  /* Return false if H isn't a __start_SECNAME/__stop_SECNAME symbol or
+     --gc-sections or -z start-stop-gc isn't used.  */
+  return false;
+}
index ceb60002d130f4f025f2a0161754f1f8faa4a884..23ab8544c79e81cea768075b2e6d54e77b984acc 100644 (file)
@@ -493,6 +493,12 @@ run_dump_test "property-x86-isa3"
 run_dump_test "property-x86-isa4"
 run_dump_test "pr26869"
 run_dump_test "code16"
+run_dump_test "pr27491-1a"
+run_dump_test "pr27491-1b"
+run_dump_test "pr27491-1c"
+run_dump_test "pr27491-2"
+run_dump_test "pr27491-3"
+run_dump_test "pr27491-4"
 
 if { !([istarget "i?86-*-linux*"]
        || [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-i386/pr27491-1.s b/ld/testsuite/ld-i386/pr27491-1.s
new file mode 100644 (file)
index 0000000..89155ae
--- /dev/null
@@ -0,0 +1,14 @@
+       .weak __start_xx
+       .weak __stop_xx
+
+       .text
+       .global foo
+foo:
+       movl    __start_xx@got(%ebx), %eax
+       movl    __stop_xx@got(%ebx), %eax
+
+       .section xx,"a",unique,0
+       .byte 0
+
+       .section xx,"a",unique,1
+       .byte 1
diff --git a/ld/testsuite/ld-i386/pr27491-1a.d b/ld/testsuite/ld-i386/pr27491-1a.d
new file mode 100644 (file)
index 0000000..006c176
--- /dev/null
@@ -0,0 +1,14 @@
+#source: pr27491-1.s
+#as: --32
+#ld: --gc-sections -melf_i386 -z start-stop-gc -shared
+#objdump: -dw
+
+.*: +file format elf32-i386
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <foo>:
+ +[a-f0-9]+:   8b 83 ([0-9a-f]{2} ){4}[ \t]+mov +-0x[a-f0-9]+\(%ebx\),%eax
+ +[a-f0-9]+:   8b 83 ([0-9a-f]{2} ){4}[ \t]+mov +-0x[a-f0-9]+\(%ebx\),%eax
+#pass
diff --git a/ld/testsuite/ld-i386/pr27491-1b.d b/ld/testsuite/ld-i386/pr27491-1b.d
new file mode 100644 (file)
index 0000000..69b9ac3
--- /dev/null
@@ -0,0 +1,11 @@
+#source: pr27491-1.s
+#as: --32
+#ld: --gc-sections -melf_i386 -z start-stop-gc -shared
+#nm: -n
+
+#failif
+#...
+[a-f0-9]+ R __start_xx
+#...
+[a-f0-9]+ R __stop_xx
+#...
diff --git a/ld/testsuite/ld-i386/pr27491-1c.d b/ld/testsuite/ld-i386/pr27491-1c.d
new file mode 100644 (file)
index 0000000..730e975
--- /dev/null
@@ -0,0 +1,14 @@
+#source: pr27491-1.s
+#as: --32
+#ld: --gc-sections -melf_i386 -shared
+#objdump: -dw
+
+.*: +file format elf32-i386
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <foo>:
+ +[a-f0-9]+:   8d 83 ([0-9a-f]{2} ){4}[ \t]+lea +-0x[a-f0-9]+\(%ebx\),%eax
+ +[a-f0-9]+:   8d 83 ([0-9a-f]{2} ){4}[ \t]+lea +-0x[a-f0-9]+\(%ebx\),%eax
+#pass
diff --git a/ld/testsuite/ld-i386/pr27491-2.d b/ld/testsuite/ld-i386/pr27491-2.d
new file mode 100644 (file)
index 0000000..02b310a
--- /dev/null
@@ -0,0 +1,22 @@
+#as: --32
+#ld: --gc-sections -melf_i386 -z start-stop-gc -shared
+#objdump: --syms -dw
+
+.*: +file format elf32-i386
+
+
+SYMBOL TABLE:
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __stop_xx
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __start_xx
+#...
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <foo>:
+ +[a-f0-9]+:   8d 83 ([0-9a-f]{2} ){4}[ \t]+lea +-0x[a-f0-9]+\(%ebx\),%eax
+ +[a-f0-9]+:   8d 83 ([0-9a-f]{2} ){4}[ \t]+lea +-0x[a-f0-9]+\(%ebx\),%eax
+ +[a-f0-9]+:   8d 83 ([0-9a-f]{2} ){4}[ \t]+lea +-0x[a-f0-9]+\(%ebx\),%eax
+#pass
diff --git a/ld/testsuite/ld-i386/pr27491-2.s b/ld/testsuite/ld-i386/pr27491-2.s
new file mode 100644 (file)
index 0000000..17871dd
--- /dev/null
@@ -0,0 +1,16 @@
+       .weak __start_xx
+       .weak __stop_xx
+
+       .text
+       .global foo
+foo:
+       movl    __start_xx@got(%ebx), %eax
+       movl    __stop_xx@got(%ebx), %eax
+       leal    bar1@got(%ebx), %eax
+
+       .section xx,"a",unique,0
+bar1:
+       .byte 0
+
+       .section xx,"a",unique,1
+       .byte 1
diff --git a/ld/testsuite/ld-i386/pr27491-3.d b/ld/testsuite/ld-i386/pr27491-3.d
new file mode 100644 (file)
index 0000000..7749570
--- /dev/null
@@ -0,0 +1,21 @@
+#as: --32
+#ld: --gc-sections -melf_i386 -z start-stop-gc -shared
+#objdump: --syms -dw
+
+.*: +file format elf32-i386
+
+
+SYMBOL TABLE:
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __stop_xx
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __start_xx
+#...
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <foo>:
+ +[a-f0-9]+:   8d 83 ([0-9a-f]{2} ){4}[ \t]+lea +-0x[a-f0-9]+\(%ebx\),%eax
+ +[a-f0-9]+:   8d 83 ([0-9a-f]{2} ){4}[ \t]+lea +-0x[a-f0-9]+\(%ebx\),%eax
+#pass
diff --git a/ld/testsuite/ld-i386/pr27491-3.s b/ld/testsuite/ld-i386/pr27491-3.s
new file mode 100644 (file)
index 0000000..85fc3dd
--- /dev/null
@@ -0,0 +1,14 @@
+       .weak __start_xx
+       .weak __stop_xx
+
+       .text
+       .global foo
+foo:
+       movl    __start_xx@got(%ebx), %eax
+       movl    __stop_xx@got(%ebx), %eax
+
+       .section xx,"a",unique,0
+       .byte 0
+
+       .section xx,"aR",unique,1
+       .byte 1
diff --git a/ld/testsuite/ld-i386/pr27491-4.d b/ld/testsuite/ld-i386/pr27491-4.d
new file mode 100644 (file)
index 0000000..4a305da
--- /dev/null
@@ -0,0 +1,23 @@
+#source: pr27491-4a.s
+#source: pr27491-4b.s
+#as: --32
+#ld: --gc-sections -melf_i386 -z start-stop-gc -shared
+#objdump: --syms -dw
+
+.*: +file format elf32-i386
+
+
+SYMBOL TABLE:
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __stop_xx
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __start_xx
+#...
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <foo>:
+ +[a-f0-9]+:   8d 83 ([0-9a-f]{2} ){4}[ \t]+lea +-0x[a-f0-9]+\(%ebx\),%eax
+ +[a-f0-9]+:   8d 83 ([0-9a-f]{2} ){4}[ \t]+lea +-0x[a-f0-9]+\(%ebx\),%eax
+#pass
diff --git a/ld/testsuite/ld-i386/pr27491-4a.s b/ld/testsuite/ld-i386/pr27491-4a.s
new file mode 100644 (file)
index 0000000..a183b2f
--- /dev/null
@@ -0,0 +1,11 @@
+       .weak __start_xx
+       .weak __stop_xx
+
+       .text
+       .global foo
+foo:
+       movl    __start_xx@got(%ebx), %eax
+       movl    __stop_xx@got(%ebx), %eax
+
+       .section xx,"a",unique,0
+       .byte 0
diff --git a/ld/testsuite/ld-i386/pr27491-4b.s b/ld/testsuite/ld-i386/pr27491-4b.s
new file mode 100644 (file)
index 0000000..d0b83e9
--- /dev/null
@@ -0,0 +1,2 @@
+       .section xx,"aR",unique,1
+       .byte 1
diff --git a/ld/testsuite/ld-x86-64/pr27491-1.s b/ld/testsuite/ld-x86-64/pr27491-1.s
new file mode 100644 (file)
index 0000000..0d5b771
--- /dev/null
@@ -0,0 +1,14 @@
+       .weak __start_xx
+       .weak __stop_xx
+
+       .text
+       .global foo
+foo:
+       movq    __start_xx@gotpcrel(%rip), %rax
+       movq    __stop_xx@gotpcrel(%rip), %rax
+
+       .section xx,"a",unique,0
+       .byte 0
+
+       .section xx,"a",unique,1
+       .byte 1
diff --git a/ld/testsuite/ld-x86-64/pr27491-1a.d b/ld/testsuite/ld-x86-64/pr27491-1a.d
new file mode 100644 (file)
index 0000000..ade5c6f
--- /dev/null
@@ -0,0 +1,14 @@
+#source: pr27491-1.s
+#as: --64
+#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared
+#objdump: -dw
+
+.*: +file format elf64-x86-64
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <foo>:
+ +[a-f0-9]+:   48 8b 05 ([0-9a-f]{2} ){4}[ \t]+mov +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
+ +[a-f0-9]+:   48 8b 05 ([0-9a-f]{2} ){4}[ \t]+mov +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr27491-1b.d b/ld/testsuite/ld-x86-64/pr27491-1b.d
new file mode 100644 (file)
index 0000000..a6e21da
--- /dev/null
@@ -0,0 +1,11 @@
+#source: pr27491-1.s
+#as: --64
+#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared
+#nm: -n
+
+#failif
+#...
+[a-f0-9]+ R __start_xx
+#...
+[a-f0-9]+ R __stop_xx
+#...
diff --git a/ld/testsuite/ld-x86-64/pr27491-1c.d b/ld/testsuite/ld-x86-64/pr27491-1c.d
new file mode 100644 (file)
index 0000000..1288361
--- /dev/null
@@ -0,0 +1,21 @@
+#source: pr27491-1.s
+#as: --64
+#ld: --gc-sections -melf_x86_64 -shared
+#objdump: --syms -dw
+
+.*: +file format elf64-x86-64
+
+SYMBOL TABLE:
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __stop_xx
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __start_xx
+#...
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <foo>:
+ +[a-f0-9]+:   48 8d 05 ([0-9a-f]{2} ){4}[ \t]+lea +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <__start_xx>
+ +[a-f0-9]+:   48 8d 05 ([0-9a-f]{2} ){4}[ \t]+lea +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <__stop_xx>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr27491-2.d b/ld/testsuite/ld-x86-64/pr27491-2.d
new file mode 100644 (file)
index 0000000..753ebb6
--- /dev/null
@@ -0,0 +1,23 @@
+#as: --64
+#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared
+#objdump: --syms -dw
+
+.*: +file format elf64-x86-64
+
+
+SYMBOL TABLE:
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __stop_xx
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __start_xx
+#...
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <foo>:
+ +[a-f0-9]+:   48 8d 05 ([0-9a-f]{2} ){4}[ \t]+lea +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <__start_xx>
+ +[a-f0-9]+:   48 8d 05 ([0-9a-f]{2} ){4}[ \t]+lea +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <__stop_xx>
+ +[a-f0-9]+:   48 8d 05 ([0-9a-f]{2} ){4}[ \t]+lea +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <bar1>
+ +[a-f0-9]+:   48 8d 05 ([0-9a-f]{2} ){4}[ \t]+lea +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <bar2>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr27491-2.s b/ld/testsuite/ld-x86-64/pr27491-2.s
new file mode 100644 (file)
index 0000000..a0975ff
--- /dev/null
@@ -0,0 +1,20 @@
+       .weak __start_xx
+       .weak __stop_xx
+
+       .text
+       .global foo
+foo:
+       movq    __start_xx@gotpcrel(%rip), %rax
+       movq    __stop_xx@gotpcrel(%rip), %rax
+       leaq    bar1(%rip), %rax
+       leaq    bar2(%rip), %rax
+
+       .section xx,"a",unique,0
+       .byte 0
+bar1:
+       .byte 0
+bar2:
+       .byte 0
+
+       .section xx,"a",unique,1
+       .byte 1
diff --git a/ld/testsuite/ld-x86-64/pr27491-3.d b/ld/testsuite/ld-x86-64/pr27491-3.d
new file mode 100644 (file)
index 0000000..6dda542
--- /dev/null
@@ -0,0 +1,21 @@
+#as: --64
+#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared
+#objdump: --syms -dw
+
+.*: +file format elf64-x86-64
+
+
+SYMBOL TABLE:
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __stop_xx
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __start_xx
+#...
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <foo>:
+ +[a-f0-9]+:   48 8d 05 ([0-9a-f]{2} ){4}[ \t]+lea +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <__start_xx>
+ +[a-f0-9]+:   48 8d 05 ([0-9a-f]{2} ){4}[ \t]+lea +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <__stop_xx>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr27491-3.s b/ld/testsuite/ld-x86-64/pr27491-3.s
new file mode 100644 (file)
index 0000000..efdcba4
--- /dev/null
@@ -0,0 +1,14 @@
+       .weak __start_xx
+       .weak __stop_xx
+
+       .text
+       .global foo
+foo:
+       movq    __start_xx@gotpcrel(%rip), %rax
+       movq    __stop_xx@gotpcrel(%rip), %rax
+
+       .section xx,"a",unique,1
+       .byte 0
+
+       .section xx,"aR",unique,0
+       .byte 1
diff --git a/ld/testsuite/ld-x86-64/pr27491-4.d b/ld/testsuite/ld-x86-64/pr27491-4.d
new file mode 100644 (file)
index 0000000..54542fd
--- /dev/null
@@ -0,0 +1,23 @@
+#source: pr27491-4a.s
+#source: pr27491-4b.s
+#as: --64
+#ld: --gc-sections -melf_x86_64 -z start-stop-gc -shared
+#objdump: --syms -dw
+
+.*: +file format elf64-x86-64
+
+
+SYMBOL TABLE:
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __stop_xx
+#...
+[a-f0-9]+ g       xx   [a-f0-9]+ \.protected __start_xx
+#...
+
+
+Disassembly of section .text:
+
+[a-f0-9]+ <foo>:
+ +[a-f0-9]+:   48 8d 05 ([0-9a-f]{2} ){4}[ \t]+lea +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <__start_xx>
+ +[a-f0-9]+:   48 8d 05 ([0-9a-f]{2} ){4}[ \t]+lea +0x[a-f0-9]+\(%rip\),%rax[ \t]+# [a-f0-9]+ <__stop_xx>
+#pass
diff --git a/ld/testsuite/ld-x86-64/pr27491-4a.s b/ld/testsuite/ld-x86-64/pr27491-4a.s
new file mode 100644 (file)
index 0000000..3b17a81
--- /dev/null
@@ -0,0 +1,11 @@
+       .weak __start_xx
+       .weak __stop_xx
+
+       .text
+       .global foo
+foo:
+       movq    __start_xx@gotpcrel(%rip), %rax
+       movq    __stop_xx@gotpcrel(%rip), %rax
+
+       .section xx,"a",unique,1
+       .byte 0
diff --git a/ld/testsuite/ld-x86-64/pr27491-4b.s b/ld/testsuite/ld-x86-64/pr27491-4b.s
new file mode 100644 (file)
index 0000000..2b46b21
--- /dev/null
@@ -0,0 +1,2 @@
+       .section xx,"aR",unique,0
+       .byte 1
index 064438a3f915571537cf0650ae6460828b55eb13..ba065c0fe7f3a409a1a21ed9cce49625d0887d8a 100644 (file)
@@ -480,6 +480,12 @@ run_dump_test "property-x86-isa3-x32"
 run_dump_test "property-x86-isa4"
 run_dump_test "property-x86-isa4-x32"
 run_dump_test "code16"
+run_dump_test "pr27491-1a"
+run_dump_test "pr27491-1b"
+run_dump_test "pr27491-1c"
+run_dump_test "pr27491-2"
+run_dump_test "pr27491-3"
+run_dump_test "pr27491-4"
 
 if ![istarget "x86_64-*-linux*"] {
     return