+2020-02-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/25381
+       * bfd-in2.h: Regenerated.
+       * elflink.c (_bfd_elf_gc_mark_extra_sections): Call mark_hook
+       on section if gc_mark of any of its linked-to sections is set
+       and don't set gc_mark again.
+       * section.c (asection): Add linked_to_symbol_name to map_head
+       union.
+
 2020-02-06  Maciej W. Rozycki  <macro@wdc.com>
 
        * elf32-v850.c (v850_elf_relax_section): Fix the index used for
 
   /* Early in the link process, map_head and map_tail are used to build
      a list of input sections attached to an output section.  Later,
      output sections use these fields for a list of bfd_link_order
-     structs.  */
+     structs.  The linked_to_symbol_name field is for ELF assembler
+     internal use.  */
   union {
     struct bfd_link_order *link_order;
     struct bfd_section *s;
+    const char *linked_to_symbol_name;
   } map_head, map_tail;
 } asection;
 
 
 
 bfd_boolean
 _bfd_elf_gc_mark_extra_sections (struct bfd_link_info *info,
-                                elf_gc_mark_hook_fn mark_hook ATTRIBUTE_UNUSED)
+                                elf_gc_mark_hook_fn mark_hook)
 {
   bfd *ibfd;
 
                   && (isec->flags & SEC_ALLOC) != 0
                   && elf_section_type (isec) != SHT_NOTE)
            some_kept = TRUE;
+         else
+           {
+             /* Since all sections, except for backend specific ones,
+                have been garbage collected, call mark_hook on this
+                section if any of its linked-to sections is marked.  */
+             asection *linked_to_sec = elf_linked_to_section (isec);
+             for (; linked_to_sec != NULL;
+                  linked_to_sec = elf_linked_to_section (linked_to_sec))
+               if (linked_to_sec->gc_mark)
+                 {
+                   if (!_bfd_elf_gc_mark (info, isec, mark_hook))
+                     return FALSE;
+                   break;
+                 }
+           }
 
          if (!debug_frag_seen
              && (isec->flags & SEC_DEBUGGING)
 
       /* Keep debug and special sections like .comment when they are
         not part of a group.  Also keep section groups that contain
-        just debug sections or special sections.  */
+        just debug sections or special sections.  NB: Sections with
+        linked-to section has been handled above.  */
       for (isec = ibfd->sections; isec != NULL; isec = isec->next)
        {
          if ((isec->flags & SEC_GROUP) != 0)
            _bfd_elf_gc_mark_debug_special_section_group (isec);
          else if (((isec->flags & SEC_DEBUGGING) != 0
                    || (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0)
-                  && elf_next_in_group (isec) == NULL)
+                  && elf_next_in_group (isec) == NULL
+                  && elf_linked_to_section (isec) == NULL)
            isec->gc_mark = 1;
          if (isec->gc_mark && (isec->flags & SEC_DEBUGGING) != 0)
            has_kept_debug_info = TRUE;
 
 .  {* Early in the link process, map_head and map_tail are used to build
 .     a list of input sections attached to an output section.  Later,
 .     output sections use these fields for a list of bfd_link_order
-.     structs.  *}
+.     structs.  The linked_to_symbol_name field is for ELF assembler
+.     internal use.  *}
 .  union {
 .    struct bfd_link_order *link_order;
 .    struct bfd_section *s;
+.    const char *linked_to_symbol_name;
 .  } map_head, map_tail;
 .} asection;
 .
 
+2020-02-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/25381
+       * config/obj-elf.c (get_section): Also check
+       linked_to_symbol_name.
+       (obj_elf_change_section): Also set map_head.linked_to_symbol_name.
+       (obj_elf_parse_section_letters): Handle the 'o' flag.
+       (build_group_lists): Renamed to ...
+       (build_additional_section_info): This.  Set elf_linked_to_section
+       from map_head.linked_to_symbol_name.
+       (elf_adjust_symtab): Updated.
+       * config/obj-elf.h (elf_section_match): Add linked_to_symbol_name.
+       * doc/as.texi: Document the 'o' flag.
+       * testsuite/gas/elf/elf.exp: Run PR gas/25381 tests.
+       * testsuite/gas/elf/section18.d: New file.
+       * testsuite/gas/elf/section18.s: Likewise.
+       * testsuite/gas/elf/section19.d: Likewise.
+       * testsuite/gas/elf/section19.s: Likewise.
+       * testsuite/gas/elf/section20.d: Likewise.
+       * testsuite/gas/elf/section20.s: Likewise.
+       * testsuite/gas/elf/section21.d: Likewise.
+       * testsuite/gas/elf/section21.l: Likewise.
+       * testsuite/gas/elf/section21.s: Likewise.
+
 2020-02-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        * NEWS: Mention x86 assembler options to align branches for
 
   struct elf_section_match *match = (struct elf_section_match *) inf;
   const char *gname = match->group_name;
   const char *group_name = elf_group_name (sec);
+  const char *linked_to_symbol_name
+    = sec->map_head.linked_to_symbol_name;
   unsigned int info = elf_section_data (sec)->this_hdr.sh_info;
 
   return (info == match->info
          && (group_name == gname
              || (group_name != NULL
                  && gname != NULL
-                 && strcmp (group_name, gname) == 0)));
+                 && strcmp (group_name, gname) == 0))
+         && (linked_to_symbol_name == match->linked_to_symbol_name
+             || (linked_to_symbol_name != NULL
+                 && match->linked_to_symbol_name != NULL
+                 && strcmp (linked_to_symbol_name,
+                            match->linked_to_symbol_name) == 0)));
 }
 
 /* Handle the .section pseudo-op.  This code supports two different
       sec->section_id = match_p->section_id;
       flags |= match_p->flags;
 
+      /* Set the linked-to symbol name.  */
+      sec->map_head.linked_to_symbol_name
+       = match_p->linked_to_symbol_name;
+
       bfd_set_section_flags (sec, flags);
       if (flags & SEC_MERGE)
        sec->entsize = entsize;
        case 'e':
          attr |= SHF_EXCLUDE;
          break;
+       case 'o':
+         attr |= SHF_LINK_ORDER;
+         break;
        case 'w':
          attr |= SHF_WRITE;
          break;
        default:
          {
            const char *bad_msg = _("unrecognized .section attribute:"
-                                   " want a,e,w,x,M,S,G,T or number");
+                                   " want a,e,o,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 &= ~SHF_MERGE;
            }
 
+         if ((attr & SHF_LINK_ORDER) != 0 && *input_line_pointer == ',')
+           {
+             char c;
+             unsigned int length;
+             ++input_line_pointer;
+             SKIP_WHITESPACE ();
+             c = get_symbol_name (& beg);
+             (void) restore_line_pointer (c);
+             length = input_line_pointer - beg;
+             if (length)
+               match.linked_to_symbol_name = xmemdup0 (beg, length);
+           }
+
          if ((attr & SHF_GROUP) != 0 && is_clone)
            {
              as_warn (_("? section flag ignored with G present"));
 /* Called via bfd_map_over_sections.  If SEC is a member of a group,
    add it to a list of sections belonging to the group.  INF is a
    pointer to a struct group_list, which is where we store the head of
-   each list.  */
+   each list.  If its link_to_symbol_name isn't NULL, set up its
+   linked-to section.  */
 
 static void
-build_group_lists (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
+build_additional_section_info (bfd *abfd ATTRIBUTE_UNUSED,
+                                 asection *sec, void *inf)
 {
   struct group_list *list = (struct group_list *) inf;
   const char *group_name = elf_group_name (sec);
   unsigned int *elem_idx;
   unsigned int *idx_ptr;
 
+  if (sec->map_head.linked_to_symbol_name)
+    {
+      symbolS *linked_to_sym;
+      linked_to_sym = symbol_find (sec->map_head.linked_to_symbol_name);
+      if (!linked_to_sym || !S_IS_DEFINED (linked_to_sym))
+       as_bad (_("undefined linked-to symbol `%s' on section `%s'"),
+               sec->map_head.linked_to_symbol_name,
+               bfd_section_name (sec));
+      else
+       elf_linked_to_section (sec) = S_GET_SEGMENT (linked_to_sym);
+    }
+
   if (group_name == NULL)
     return;
 
   groups.num_group = 0;
   groups.head = NULL;
   groups.indexes = hash_new ();
-  bfd_map_over_sections (stdoutput, build_group_lists, &groups);
+  bfd_map_over_sections (stdoutput, build_additional_section_info,
+                        &groups);
 
   /* Make the SHT_GROUP sections that describe each section group.  We
      can't set up the section contents here yet, because elf section
 
 struct elf_section_match
 {
   const char *group_name;
+  const char *linked_to_symbol_name;
   unsigned int info;
   unsigned int section_id;
   flagword flags;
 
 section is a GNU_MBIND section
 @item e
 section is excluded from executable and shared library.
+@item o
+section references a symbol defined in another section (the linked-to
+section) in the same file.
 @item w
 section is writable
 @item x
 @code{"def"} will be merged with @code{"abcdef"};  A reference to the first
 @code{"def"} will be changed to a reference to @code{"abcdef"+3}.
 
+If @var{flags} contains the @code{o} flag, then the @var{type} argument
+must be present along with an additional field like this:
+
+@smallexample
+.section @var{name},"@var{flags}"o,@@@var{type},@var{SymbolName}
+@end smallexample
+
+The @var{SymbolName} field specifies the symbol name which the section
+references.
+
+Note: If both the @var{M} and @var{o} flags are present, then the fields
+for the Merge flag should come first, like this:
+
+@smallexample
+.section @var{name},"@var{flags}"Mo,@@@var{type},@var{entsize},@var{SymbolName}
+@end smallexample
+
 If @var{flags} contains the @code{G} symbol then the @var{type} argument must
 be present along with an additional field like this:
 
 .section @var{name} , "@var{flags}"MG, @@@var{type}, @var{entsize}, @var{GroupName}[, @var{linkage}]
 @end smallexample
 
+If both @code{o} flag and @code{G} flag are present, then the
+@var{SymbolName} field for @code{o} comes first, like this:
+
+@smallexample
+.section @var{name},"@var{flags}"oG,@@@var{type},@var{SymbolName},@var{GroupName}[,@var{linkage}]
+@end smallexample
+
 If @var{flags} contains the @code{?} symbol then it may not also contain the
 @code{G} symbol and the @var{GroupName} or @var{linkage} fields should not be
 present.  Instead, @code{?} says to consider the section that's current before
 
     run_dump_test "section16a"
     run_dump_test "section16b"
     run_dump_test "section17"
+    run_dump_test "section18"
+    run_dump_test "section19"
+    run_dump_test "section20"
+    run_dump_test "section21"
     run_dump_test "dwarf2-1" $dump_opts
     run_dump_test "dwarf2-2" $dump_opts
     run_dump_test "dwarf2-3" $dump_opts
 
--- /dev/null
+#readelf: -SW
+#name: linked-to section 1
+
+#...
+ +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WAL +.*
+#...
+ +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WAL +.*
+#pass
 
--- /dev/null
+       .text
+foo:
+       .section __patchable_function_entries,"awo",%progbits,foo
+       .dc.a   .LPFE1
+       .text
+.LPFE1:
+       .byte 0
+       .section __patchable_function_entries,"awo",%progbits,bar
+       .dc.a   .LPFE2
+       .text
+bar:
+.LPFE2:
+       .byte 0
 
--- /dev/null
+#readelf: -SW
+#name: linked-to section 2
+
+#...
+ +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WAL +.*
+#...
+ +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WAL +.*
+#pass
 
--- /dev/null
+       .section .text,"ax",%progbits,unique,20
+foo:
+       .section __patchable_function_entries,"awo",%progbits,foo,unique,2
+       .dc.a   .LPFE1
+       .section .text,"ax",%progbits,unique,20
+.LPFE1:
+       .byte 0
+       .section __patchable_function_entries,"awo",%progbits,bar,unique,102
+       .dc.a   .LPFE2
+       .section .text,"ax",%progbits,unique,2
+bar:
+.LPFE2:
+       .byte 0
 
--- /dev/null
+#readelf: -SWg
+#name: linked-to section 3
+
+#...
+ +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WALG +.*
+#...
+ +\[ *[0-9]+\] +__patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+[248] +00 +WALG +.*
+#...
+COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains [0-9]+ sections:
+   \[Index\]    Name
+#...
+   \[[ 0-9]+\]   __patchable_function_entries
+#...
+COMDAT group section \[[ 0-9]+\] `.group' \[bar\] contains [0-9]+ sections:
+#...
+   \[[ 0-9]+\]   __patchable_function_entries
+#pass
 
--- /dev/null
+       .section .text,"axG",%progbits,foo,comdat
+foo:
+       .section __patchable_function_entries,"awoG",%progbits,foo,foo,comdat
+       .dc.a   .LPFE1
+       .section .text,"axG",%progbits,foo,comdat
+.LPFE1:
+       .byte 0
+       .section __patchable_function_entries,"awoG",%progbits,bar,bar,comdat,unique,4
+       .dc.a   .LPFE2
+       .section .text,"axG",%progbits,bar,comdat,unique,24
+bar:
+.LPFE2:
+       .byte 0
 
--- /dev/null
+#name: incorrect linked-to symbols
+#error_output: section21.l
 
--- /dev/null
+[^:]*: Assembler messages:
+[^:]*:11: Error: junk at end of line, first unrecognized character is `1'
+#...
+[^:]*: Error: undefined linked-to symbol `bar' on section `__patchable_function_entries'
+[^:]*: Error: undefined linked-to symbol `foo' on section `__patchable_function_entries'
 
--- /dev/null
+       .section __patchable_function_entries,"awo",%progbits,bar
+       .dc.a   .LPFE1
+       .text
+.LPFE1:
+       .byte 0
+       .section __patchable_function_entries,"awo",%progbits,foo
+       .dc.a   .LPFE2
+       .text
+.LPFE2:
+       .dc.a foo
+       .section __patchable_function_entries,"awo",%progbits,1foo
+       .dc.a   .LPFE3
+       .text
+.LPFE3:
+       .byte 0
 
-2020-02-07  H.J. Lu  <hongjiu.lu@intel.com>
+2020-02-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/24526
+       PR ld/25021
+       PR ld/25490
+       * testsuite/ld-elf/elf.exp: Run PR ld/25490 tests.
+       * testsuite/ld-elf/pr24526.d: New file.
+       * testsuite/ld-elf/pr24526.s: Likewise.
+       * testsuite/ld-elf/pr25021.d: Likewise.
+       * testsuite/ld-elf/pr25021.s: Likewise.
+       * testsuite/ld-elf/pr25490-2-16.rd: Likewise.
+       * testsuite/ld-elf/pr25490-2-32.rd: Likewise.
+       * testsuite/ld-elf/pr25490-2-64.rd: Likewise.
+       * testsuite/ld-elf/pr25490-2.s: Likewise.
+       * testsuite/ld-elf/pr25490-3-16.rd: Likewise.
+       * testsuite/ld-elf/pr25490-3-32.rd: Likewise.
+       * testsuite/ld-elf/pr25490-3-64.rd: Likewise.
+       * testsuite/ld-elf/pr25490-3.s: Likewise.
+       * testsuite/ld-elf/pr25490-4-16.rd: Likewise.
+       * testsuite/ld-elf/pr25490-4-32.rd: Likewise.
+       * testsuite/ld-elf/pr25490-4-64.rd: Likewise.
+       * testsuite/ld-elf/pr25490-4.s: Likewise.
+       * testsuite/ld-elf/pr25490-5-16.rd: Likewise.
+       * testsuite/ld-elf/pr25490-5-32.rd: Likewise.
+       * testsuite/ld-elf/pr25490-5-64.rd: Likewise.
+       * testsuite/ld-elf/pr25490-5.s: Likewise.
+       * testsuite/ld-elf/pr25490-6-16.rd: Likewise.
+       * testsuite/ld-elf/pr25490-6-32.rd: Likewise.
+       * testsuite/ld-elf/pr25490-6-64.rd: Likewise.
+       * testsuite/ld-elf/pr25490-6.s: Likewise.
+
+2020-02-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        * testsuite/lib/ld-lib.exp (check_gc_sections_available): Mark
        z80 as not supported.
 
 if [is_elf64 tmpdir/symbol3w.a] {
     set ASFLAGS "$ASFLAGS --defsym ALIGN=3"
     set pr23900_1_exp "pr23900-1-64.rd"
+    set pr25490_2_exp "pr25490-2-64.rd"
+    set pr25490_3_exp "pr25490-3-64.rd"
+    set pr25490_4_exp "pr25490-4-64.rd"
+    set pr25490_5_exp "pr25490-5-64.rd"
+    set pr25490_6_exp "pr25490-6-64.rd"
 } else {
     set ASFLAGS "$ASFLAGS --defsym ALIGN=2"
     set pr23900_1_exp "pr23900-1-32.rd"
+    if {    [istarget avr-*-*]
+        || [istarget h8300-*-*]
+        || [istarget ip2k-*-*]
+        || [istarget m68hc11-*]
+        || [istarget "xc16x-*"]
+        || [istarget "z80-*-*"] } {
+       set pr25490_2_exp "pr25490-2-16.rd"
+       set pr25490_3_exp "pr25490-3-16.rd"
+       set pr25490_4_exp "pr25490-4-16.rd"
+       set pr25490_5_exp "pr25490-5-16.rd"
+       set pr25490_6_exp "pr25490-6-16.rd"
+    } else {
+       set pr25490_2_exp "pr25490-2-32.rd"
+       set pr25490_3_exp "pr25490-3-32.rd"
+       set pr25490_4_exp "pr25490-4-32.rd"
+       set pr25490_5_exp "pr25490-5-32.rd"
+       set pr25490_6_exp "pr25490-6-32.rd"
+    }
 }
 
 
        ]
 }
 
+if [check_gc_sections_available] {
+    run_ld_link_tests [list \
+       [list "__patchable_function_entries section 2" \
+           "--gc-sections -e _start" \
+           "" \
+           "" \
+           {pr25490-2.s} \
+           [list [list "readelf" {-SW} $pr25490_2_exp]] \
+           "pr25490-2.exe"] \
+       [list "__patchable_function_entries section 3" \
+           "--gc-sections -e _start" \
+           "" \
+           "" \
+           {pr25490-3.s} \
+           [list [list "readelf" {-SW} $pr25490_3_exp]] \
+           "pr25490-3.exe"] \
+       [list "__patchable_function_entries section 4" \
+           "--gc-sections -e _start" \
+           "" \
+           "" \
+           {pr25490-4.s} \
+           [list [list "readelf" {-SW} $pr25490_4_exp]] \
+           "pr25490-4.exe"] \
+       [list "__patchable_function_entries section 5" \
+           "--gc-sections -e _start" \
+           "" \
+           "" \
+           {pr25490-5.s} \
+           [list [list "readelf" {-SW} $pr25490_5_exp]] \
+           "pr25490-5.exe"] \
+       [list "__patchable_function_entries section 6" \
+           "--gc-sections -e _start" \
+           "" \
+           "" \
+           {pr25490-6.s} \
+           [list [list "readelf" {-SW} $pr25490_6_exp]] \
+           "pr25490-6.exe"] \
+       ]
+}
+
 set LDFLAGS $old_ldflags
 set ASFLAGS $old_asflags
 
 
--- /dev/null
+#ld: --gc-sections -e _start
+#target: [check_gc_sections_available]
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] \.bar +PROGBITS +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +00 +AL .*
+#...
+ +\[ *[0-9]+\] \.zed +PROGBITS +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +00 +AL .*
+#pass
 
--- /dev/null
+       .text
+       .globl _start
+_start:
+       .byte 0
+       .section .note,"",%note
+       .dc.a .foo
+
+       .section .foo,"a"
+       .dc.a   0
+       .section .bar,"ao",%progbits,.foo
+       .dc.a   0
+       .section .zed,"ao",%progbits,.foo
+       .dc.a   0
 
--- /dev/null
+#ld: --gc-sections -e _start
+#target: [check_gc_sections_available]
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] \.stack_sizes +PROGBITS +0+ +[0-9a-f]+ 0+1 +00 +L +[0-9] .*
+#pass
 
--- /dev/null
+       .section .text.live,"ax",%progbits
+       .globl live
+live:
+       .byte 0
+
+       .section .stack_sizes,"o",%progbits,.text.live,unique,0
+       .byte 1
+
+       .section .text.dead,"ax",%progbits
+       .globl dead
+dead:
+       .byte 1
+
+       .section .stack_sizes,"o",%progbits,.text.dead,unique,1
+       .byte 2
+
+       .section .text.main,"ax",%progbits
+       .globl _start
+_start:
+       .byte 0
+       .section .note,"",%note
+       .dc.a live
 
--- /dev/null
+#source: pr25490-2.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+2 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+#source: pr25490-2.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+4 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+#source: pr25490-2.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+       .text
+       .globl  _start
+       .type   _start, %function
+_start:
+       .section __patchable_function_entries,"awo",%progbits,_start
+       .dc.a   .LPFE1
+       .text
+.LPFE1:
+       .byte 0
 
--- /dev/null
+#source: pr25490-3.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+2 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+#source: pr25490-3.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+4 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+#source: pr25490-3.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+       .section        .text.bar,"ax",%progbits
+       .globl  bar
+       .type   bar, %function
+bar:
+       .section __patchable_function_entries,"awo",%progbits,bar
+       .dc.a   .LPFE1
+       .section        .text.bar,"ax",%progbits
+.LPFE1:
+       .byte 0
+       .section        .text._start,"ax",%progbits
+       .globl  _start
+       .type   _start, %function
+_start:
+       .section __patchable_function_entries,"awo",%progbits,_start
+       .dc.a   .LPFE2
+       .section        .text._start,"ax",%progbits
+.LPFE2:
+       .byte 0
 
--- /dev/null
+#source: pr25490-4.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+4 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+#source: pr25490-4.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+#source: pr25490-4.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+10 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+       .section        .text.bar,"ax",%progbits
+       .globl  bar
+       .type   bar, %function
+bar:
+       .section __patchable_function_entries,"awo",%progbits,bar
+       .dc.a   .LPFE1
+       .section        .text.bar,"ax",%progbits
+.LPFE1:
+       .byte 0
+       .section        .text._start,"ax",%progbits
+       .globl  _start
+       .type   _start, %function
+_start:
+       .section __patchable_function_entries,"awo",%progbits,_start
+       .dc.a   .LPFE2
+       .section        .text._start,"ax",%progbits
+.LPFE2:
+       .byte 0
+       .section .note,"",%note
+       .dc.a   bar
 
--- /dev/null
+#source: pr25490-5.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+4 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+#source: pr25490-5.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+8 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+#source: pr25490-5.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+10 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+       .text
+       .type   bar, %function
+bar:
+       .section __patchable_function_entries,"awo",%progbits,bar
+       .dc.a   .LPFE1
+       .text
+.LPFE1:
+       .byte 0
+       .text
+       .globl  _start
+       .type   _start, %function
+_start:
+       .section __patchable_function_entries,"awo",%progbits,_start
+       .dc.a   .LPFE2
+       .text
+.LPFE2:
+       .byte   0
 
--- /dev/null
+#source: pr25490-6.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+6 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+#source: pr25490-6.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+c +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+#source: pr25490-6.s
+#ld: --gc-sections -e _start
+#readelf: -SW
+
+#...
+ +\[ *[0-9]+\] __patchable_function_entries +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+18 +00 +WAL +[0-9] +0 +[1248]
+#pass
 
--- /dev/null
+       .section .text,"axG",%progbits,bar,comdat
+       .globl  bar
+       .type   bar, %function
+bar:
+       .section __patchable_function_entries,"awo",%progbits,bar
+       .dc.a   .LPFE1
+       .section .text,"axG",%progbits,bar,comdat
+.LPFE1:
+       .byte 0
+       .section .text,"axG",%progbits,foo,comdat
+       .globl  foo
+       .type   foo, %function
+foo:
+       .section __patchable_function_entries,"awo",%progbits,foo,unique,0
+       .dc.a   .LPFE2
+       .section .text,"axG",%progbits,foo,comdat
+.LPFE2:
+       .byte 0
+       .section .text,"axG",%progbits,_start,comdat,unique,1
+       .globl  _start
+       .type   _start, %function
+_start:
+       .section __patchable_function_entries,"awoG",%progbits,_start,_start,comdat,unique,3
+       .dc.a   .LPFE3
+       .section .text,"axG",%progbits,_start,comdat,unique,1
+.LPFE3:
+       .byte 0
+       .section .note,"",%note
+       .dc.a   foo
+       .dc.a   bar