Documentation for memory tagging remote packets
[deliverable/binutils-gdb.git] / ld / ldelf.c
index 5cfddef39b3d22aff90fac9e9c0acbbad4930024..94d775db5cd98b5bb7b7b933f69afc007dd6c0bb 100644 (file)
@@ -1,5 +1,5 @@
 /* ELF emulation code for targets using elf.em.
-   Copyright (C) 1991-2020 Free Software Foundation, Inc.
+   Copyright (C) 1991-2021 Free Software Foundation, Inc.
 
    This file is part of the GNU Binutils.
 
@@ -321,7 +321,7 @@ ldelf_try_needed (struct dt_needed *needed, int force, int is_linux)
              struct bfd_link_needed_list *l;
 
              for (l = needs; l != NULL; l = l->next)
-               if (CONST_STRNEQ (l->name, "libc.so"))
+               if (startswith (l->name, "libc.so"))
                  break;
              if (l == NULL)
                {
@@ -837,7 +837,7 @@ ldelf_parse_ld_so_conf (struct ldelf_ld_so_conf *info, const char *filename)
       if (p[0] == '\0')
        continue;
 
-      if (CONST_STRNEQ (p, "include") && (p[7] == ' ' || p[7] == '\t'))
+      if (startswith (p, "include") && (p[7] == ' ' || p[7] == '\t'))
        {
          char *dir, c;
          p += 8;
@@ -1089,7 +1089,7 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd,
 
              if (bfd_is_abs_section (s->output_section))
                continue;
-             if (CONST_STRNEQ (name, ".eh_frame_entry"))
+             if (startswith (name, ".eh_frame_entry"))
                type = COMPACT_EH_HDR;
              else if (strcmp (name, ".eh_frame") == 0 && s->size > 8)
                type = DWARF2_EH_HDR;
@@ -1820,7 +1820,7 @@ output_rel_find (int isdyn, int rela)
        lookup = lookup->next)
     {
       if (lookup->constraint >= 0
-         && CONST_STRNEQ (lookup->name, ".rel"))
+         && startswith (lookup->name, ".rel"))
        {
          int lookrela = lookup->name[4] == 'a';
 
@@ -1971,7 +1971,7 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint)
          default:
            break;
          }
-      else if (CONST_STRNEQ (secname, ".rel"))
+      else if (startswith (secname, ".rel"))
        {
          secname = secname[4] == 'a' ? ".rela.dyn" : ".rel.dyn";
          isdyn = 1;
@@ -2006,7 +2006,7 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint)
            && (elf_section_data (os->bfd_section)->this_hdr.sh_info
                == elf_section_data (s)->this_hdr.sh_info))
            {
-             lang_add_section (&os->children, s, NULL, os);
+             lang_add_section (&os->children, s, NULL, NULL, os);
              return os;
            }
 
@@ -2049,7 +2049,7 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint)
                        || !elfoutput
                        || elf_orphan_compatible (s, os->bfd_section)))))
          {
-           lang_add_section (&os->children, s, NULL, os);
+           lang_add_section (&os->children, s, NULL, NULL, os);
            return os;
          }
 
@@ -2063,7 +2063,7 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint)
      unused one and use that.  */
   if (match_by_name)
     {
-      lang_add_section (&match_by_name->children, s, NULL, match_by_name);
+      lang_add_section (&match_by_name->children, s, NULL, NULL, match_by_name);
       return match_by_name;
     }
 
@@ -2084,11 +2084,11 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint)
   /* If this is a final link, then always put .gnu.warning.SYMBOL
      sections into the .text section to get them out of the way.  */
   if (bfd_link_executable (&link_info)
-      && CONST_STRNEQ (s->name, ".gnu.warning.")
+      && startswith (s->name, ".gnu.warning.")
       && hold[orphan_text].os != NULL)
     {
       os = hold[orphan_text].os;
-      lang_add_section (&os->children, s, NULL, os);
+      lang_add_section (&os->children, s, NULL, NULL, os);
       return os;
     }
 
@@ -2124,7 +2124,7 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint)
   else if ((flags & SEC_LOAD) != 0
           && (elfinput
               ? sh_type == SHT_NOTE
-              : CONST_STRNEQ (secname, ".note")))
+              : startswith (secname, ".note")))
     place = &hold[orphan_interp];
   else if ((flags & (SEC_LOAD | SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) == 0)
     place = &hold[orphan_bss];
@@ -2137,7 +2137,7 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint)
   else if ((flags & SEC_LOAD) != 0
           && (elfinput
               ? sh_type == SHT_RELA || sh_type == SHT_REL
-              : CONST_STRNEQ (secname, ".rel")))
+              : startswith (secname, ".rel")))
     place = &hold[orphan_rel];
   else if ((flags & SEC_CODE) == 0)
     place = &hold[orphan_rodata];
@@ -2188,14 +2188,29 @@ ldelf_before_place_orphans (void)
               been discarded.  */
            asection *linked_to_sec;
            for (linked_to_sec = elf_linked_to_section (isec);
-                linked_to_sec != NULL;
+                linked_to_sec != NULL && !linked_to_sec->linker_mark;
                 linked_to_sec = elf_linked_to_section (linked_to_sec))
-             if (discarded_section (linked_to_sec))
-               {
-                 isec->output_section = bfd_abs_section_ptr;
-                 isec->flags |= SEC_EXCLUDE;
-                 break;
-               }
+             {
+               if (discarded_section (linked_to_sec))
+                 {
+                   isec->output_section = bfd_abs_section_ptr;
+                   isec->flags |= SEC_EXCLUDE;
+                   break;
+                 }
+               linked_to_sec->linker_mark = 1;
+             }
+           for (linked_to_sec = elf_linked_to_section (isec);
+                linked_to_sec != NULL && linked_to_sec->linker_mark;
+                linked_to_sec = elf_linked_to_section (linked_to_sec))
+             linked_to_sec->linker_mark = 0;
          }
       }
 }
+
+void
+ldelf_set_output_arch (void)
+{
+  set_output_arch_default ();
+  if (link_info.output_bfd->xvec->flavour == bfd_target_elf_flavour)
+    elf_link_info (link_info.output_bfd) = &link_info;
+}
This page took 0.027257 seconds and 4 git commands to generate.