gdb: resume ongoing step after handling fork or vfork
[deliverable/binutils-gdb.git] / ld / ldelfgen.c
index df3dae0abe8c45b08086257531a48f582df8705a..c456d4751e166b55ee59004130bdfe672a9a7a6e 100644 (file)
@@ -52,7 +52,7 @@ struct os_sections
 
 /* Add IS to data kept for OS.  */
 
-static bfd_boolean
+static bool
 add_link_order_input_section (lang_input_section_type *is,
                              lang_output_section_statement_type *os)
 {
@@ -83,18 +83,18 @@ add_link_order_input_section (lang_input_section_type *is,
       && (s->flags & SEC_LINKER_CREATED) == 0
       && elf_linked_to_section (s) != NULL)
     os_info->ordered++;
-  return FALSE;
+  return false;
 }
 
 /* Run over the linker's statement list, extracting info about input
    sections attached to each output section.  */
 
-static bfd_boolean
+static bool
 link_order_scan (lang_statement_union_type *u,
                 lang_output_section_statement_type *os)
 {
   asection *s;
-  bfd_boolean ret = FALSE;
+  bool ret = false;
 
   for (; u != NULL; u = u->header.next)
     {
@@ -102,21 +102,21 @@ link_order_scan (lang_statement_union_type *u,
        {
        case lang_wild_statement_enum:
          if (link_order_scan (u->wild_statement.children.head, os))
-           ret = TRUE;
+           ret = true;
          break;
        case lang_constructors_statement_enum:
          if (link_order_scan (constructor_list.head, os))
-           ret = TRUE;
+           ret = true;
          break;
        case lang_output_section_statement_enum:
          if (u->output_section_statement.constraint != -1
              && link_order_scan (u->output_section_statement.children.head,
                                  &u->output_section_statement))
-           ret = TRUE;
+           ret = true;
          break;
        case lang_group_statement_enum:
          if (link_order_scan (u->group_statement.children.head, os))
-           ret = TRUE;
+           ret = true;
          break;
        case lang_input_section_enum:
          s = u->input_section.section;
@@ -127,7 +127,7 @@ link_order_scan (lang_statement_union_type *u,
                  || ((s->output_section->flags & (SEC_LOAD | SEC_THREAD_LOCAL))
                      == (SEC_LOAD | SEC_THREAD_LOCAL))))
            if (add_link_order_input_section (&u->input_section, os))
-             ret = TRUE;
+             ret = true;
          break;
        default:
          break;
@@ -171,12 +171,15 @@ compare_link_order (const void *a, const void *b)
   else if (apos > bpos)
     return 1;
 
-  /* The only way we should get matching LMAs is when the first of two
-     sections has zero size.  */
-  if (asec->size < bsec->size)
-    return -1;
-  else if (asec->size > bsec->size)
-    return 1;
+  if (! bfd_link_relocatable (&link_info))
+    {
+      /* The only way we should get matching LMAs is when
+        the first of the two sections has zero size.  */
+      if (asec->size < bsec->size)
+       return -1;
+      else if (asec->size > bsec->size)
+       return 1;
+    }
 
   /* If they are both zero size then they almost certainly have the same
      VMA and thus are not ordered with respect to each other.  Test VMA
@@ -195,7 +198,7 @@ compare_link_order (const void *a, const void *b)
 /* Rearrange sections with SHF_LINK_ORDER into the same order as their
    linked sections.  */
 
-static bfd_boolean
+static bool
 fixup_link_order (lang_output_section_statement_type *os)
 {
   struct os_sections *os_info = os->data;
@@ -223,7 +226,7 @@ fixup_link_order (lang_output_section_statement_type *os)
     if (os_info->isec[i].idx != i)
       break;
   if (i == os_info->count)
-    return FALSE;
+    return false;
 
   /* Now reorder the linker input section statements to reflect the
      proper sorting.  The is done by rewriting the existing statements
@@ -247,19 +250,19 @@ fixup_link_order (lang_output_section_statement_type *os)
       }
   free (save_s);
   free (orig_is);
-  return TRUE;
+  return true;
 }
 
 void
-ldelf_map_segments (bfd_boolean need_layout)
+ldelf_map_segments (bool need_layout)
 {
   int tries = 10;
-  static bfd_boolean done_link_order_scan = FALSE;
+  static bool done_link_order_scan = false;
 
   do
     {
       lang_relax_sections (need_layout);
-      need_layout = FALSE;
+      need_layout = false;
 
       if (bfd_get_flavour (link_info.output_bfd) == bfd_target_elf_flavour)
        {
@@ -267,7 +270,7 @@ ldelf_map_segments (bfd_boolean need_layout)
          if (!done_link_order_scan)
            {
              link_order_scan (statement_list.head, NULL);
-             done_link_order_scan = TRUE;
+             done_link_order_scan = true;
            }
          for (os = (void *) lang_os_list.head; os != NULL; os = os->next)
            {
@@ -284,7 +287,7 @@ ldelf_map_segments (bfd_boolean need_layout)
                    }
                  if (os_info->count > 1
                      && fixup_link_order (os))
-                   need_layout = TRUE;
+                   need_layout = true;
                }
            }
        }
@@ -308,11 +311,11 @@ ldelf_map_segments (bfd_boolean need_layout)
              if (tries > 6)
                /* The first few times we allow any change to
                   phdr_size .  */
-               need_layout = TRUE;
+               need_layout = true;
              else if (phdr_size
                       < elf_program_header_size (link_info.output_bfd))
                /* After that we only allow the size to grow.  */
-               need_layout = TRUE;
+               need_layout = true;
              else
                elf_program_header_size (link_info.output_bfd) = phdr_size;
            }
@@ -375,13 +378,20 @@ ldelf_ctf_strtab_iter_cb (uint32_t *offset, void *arg_)
   if (arg->next_i == 0)
     arg->next_i = 1;
 
-  if (arg->next_i >= _bfd_elf_strtab_len (arg->strtab))
+  /* Hunt through strings until we fall off the end or find one with
+     a nonzero refcount.  */
+  do
     {
-      arg->next_i = 0;
-      return NULL;
+      if (arg->next_i >= _bfd_elf_strtab_len (arg->strtab))
+       {
+         arg->next_i = 0;
+         return NULL;
+       }
+
+      ret = _bfd_elf_strtab_str (arg->strtab, arg->next_i++, &off);
     }
+  while (ret == NULL);
 
-  ret = _bfd_elf_strtab_str (arg->strtab, arg->next_i++, &off);
   *offset = off;
 
   /* If we've overflowed, we cannot share any further strings: the CTF
This page took 0.027497 seconds and 4 git commands to generate.