]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Return error status from bfd_elf_discard_info.
authorAlan Modra <amodra@gmail.com>
Mon, 18 Aug 2014 00:03:35 +0000 (09:33 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 18 Aug 2014 00:03:35 +0000 (09:33 +0930)
bfd/
* elflink.c (bfd_elf_discard_info): Return int error status.
* stabs.c (_bfd_discard_section_stabs): Comment typo fix.
* bfd-in.h (bfd_elf_discard_info): Updata prototype.
* bfd-in2.h: Regenerate.
ld/
* emultempl/aarch64elf.em (gld${EMULATION_NAME}_after_allocation):
Handle error status from bfd_elf_discard_info.
* emultempl/armelf.em: Likewise.
* emultempl/elf32.em: Likewise.
* emultempl/hppaelf.em: Likewise.
* emultempl/metagelf.em: Likewise.
* emultempl/nios2elf.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
* emultempl/tic6xdsbt.em: Likewise.
* emultempl/vms.em: Likewise.

15 files changed:
bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/elflink.c
bfd/stabs.c
ld/ChangeLog
ld/emultempl/aarch64elf.em
ld/emultempl/armelf.em
ld/emultempl/elf32.em
ld/emultempl/hppaelf.em
ld/emultempl/metagelf.em
ld/emultempl/nios2elf.em
ld/emultempl/ppc64elf.em
ld/emultempl/tic6xdsbt.em
ld/emultempl/vms.em

index a23a2c3b8f3f032a8a5d0881f8beea1067773d79..508a20a2a9c9aa149f08ca668b9942e60789432a 100644 (file)
@@ -1,3 +1,10 @@
+2014-08-18  Alan Modra  <amodra@gmail.com>
+
+       * elflink.c (bfd_elf_discard_info): Return int error status.
+       * stabs.c (_bfd_discard_section_stabs): Comment typo fix.
+       * bfd-in.h (bfd_elf_discard_info): Updata prototype.
+       * bfd-in2.h: Regenerate.
+
 2014-08-14  Alan Modra  <amodra@gmail.com>
 
        * peXXigen.c (pe_print_reloc): Protect against access past end
index 83f125bd8e5c12cbbed91b62650679311b289865..bcb9fdc5f93b025d40d8e50c0f79d288a6a3a614 100644 (file)
@@ -658,7 +658,7 @@ extern int bfd_elf_get_dyn_lib_class
   (bfd *);
 extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
   (bfd *, struct bfd_link_info *);
-extern bfd_boolean bfd_elf_discard_info
+extern int bfd_elf_discard_info
   (bfd *, struct bfd_link_info *);
 extern unsigned int _bfd_elf_default_action_discarded
   (struct bfd_section *);
index 8c77c813093d7b7c13ba3582a15ad73e19675a00..27fc3fea2ebda45696fffa081fb34d5cf9cbfcf7 100644 (file)
@@ -665,7 +665,7 @@ extern int bfd_elf_get_dyn_lib_class
   (bfd *);
 extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
   (bfd *, struct bfd_link_info *);
-extern bfd_boolean bfd_elf_discard_info
+extern int bfd_elf_discard_info
   (bfd *, struct bfd_link_info *);
 extern unsigned int _bfd_elf_default_action_discarded
   (struct bfd_section *);
index 5e5af3265fedc60890d65e1206007f39bc62dc0a..d20f357e2cc6c1a41c48abd65eba35bcf2eddabf 100644 (file)
@@ -12629,21 +12629,21 @@ bfd_elf_reloc_symbol_deleted_p (bfd_vma offset, void *cookie)
 }
 
 /* Discard unneeded references to discarded sections.
-   Returns TRUE if any section's size was changed.  */
-/* This function assumes that the relocations are in sorted order,
-   which is true for all known assemblers.  */
+   Returns -1 on error, 1 if any section's size was changed, 0 if
+   nothing changed.  This function assumes that the relocations are in
+   sorted order, which is true for all known assemblers.  */
 
-bfd_boolean
+int
 bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
 {
   struct elf_reloc_cookie cookie;
   asection *o;
   bfd *abfd;
-  bfd_boolean ret = FALSE;
+  int changed = 0;
 
   if (info->traditional_format
       || !is_elf_hash_table (info->hash))
-    return FALSE;
+    return 0;
 
   o = bfd_get_section_by_name (output_bfd, ".stab");
   if (o != NULL)
@@ -12662,13 +12662,13 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
            continue;
 
          if (!init_reloc_cookie_for_section (&cookie, info, i))
-           return FALSE;
+           return -1;
 
          if (_bfd_discard_section_stabs (abfd, i,
                                          elf_section_data (i)->sec_info,
                                          bfd_elf_reloc_symbol_deleted_p,
                                          &cookie))
-           ret = TRUE;
+           changed = 1;
 
          fini_reloc_cookie_for_section (&cookie, i);
        }
@@ -12692,13 +12692,13 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
            continue;
 
          if (!init_reloc_cookie_for_section (&cookie, info, i))
-           return FALSE;
+           return -1;
 
          _bfd_elf_parse_eh_frame (abfd, info, i, &cookie);
          if (_bfd_elf_discard_section_eh_frame (abfd, info, i,
                                                 bfd_elf_reloc_symbol_deleted_p,
                                                 &cookie))
-           ret = TRUE;
+           changed = 1;
 
          fini_reloc_cookie_for_section (&cookie, i);
        }
@@ -12717,10 +12717,10 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
       if (bed->elf_backend_discard_info != NULL)
        {
          if (!init_reloc_cookie (&cookie, info, abfd))
-           return FALSE;
+           return -1;
 
          if ((*bed->elf_backend_discard_info) (abfd, &cookie, info))
-           ret = TRUE;
+           changed = 1;
 
          fini_reloc_cookie (&cookie, abfd);
        }
@@ -12729,9 +12729,9 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
   if (info->eh_frame_hdr
       && !info->relocatable
       && _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info))
-    ret = TRUE;
+    changed = 1;
 
-  return ret;
+  return changed;
 }
 
 bfd_boolean
index 784eb977e19778971e2cbb376d41e3243d4052e4..e6526c5148b902ab7b81d52043138ef36bd5d4b6 100644 (file)
@@ -536,7 +536,7 @@ _bfd_discard_section_stabs (bfd *abfd,
        link, so we should just ignore them.  */
     return FALSE;
 
-  /* We should have initialized our data in _bfd_link_stab_sections.
+  /* We should have initialized our data in _bfd_link_section_stabs.
      If there was some bizarre error reading the string sections, though,
      we might not have.  Bail rather than asserting.  */
   if (psecinfo == NULL)
index 773afba9b2477e1db641b8260de9952b842ead07..2c1ec6af9c541e59309fd8ad6ce2800d13be83d8 100644 (file)
@@ -1,3 +1,16 @@
+2014-08-18  Alan Modra  <amodra@gmail.com>
+
+       * emultempl/aarch64elf.em (gld${EMULATION_NAME}_after_allocation):
+       Handle error status from bfd_elf_discard_info.
+       * emultempl/armelf.em: Likewise.
+       * emultempl/elf32.em: Likewise.
+       * emultempl/hppaelf.em: Likewise.
+       * emultempl/metagelf.em: Likewise.
+       * emultempl/nios2elf.em: Likewise.
+       * emultempl/ppc64elf.em: Likewise.
+       * emultempl/tic6xdsbt.em: Likewise.
+       * emultempl/vms.em: Likewise.
+
 2014-08-14  Alan Modra  <amodra@gmail.com>
 
        PR 16563
index 6134855409ddfbc015cb5b773ea3617e15b1a3da..bb589012061ed3da268887bc290d5cb874a84ab6 100644 (file)
@@ -219,20 +219,27 @@ build_section_lists (lang_statement_union_type *statement)
 static void
 gld${EMULATION_NAME}_after_allocation (void)
 {
+  int ret;
+
   /* bfd_elf32_discard_info just plays with debugging sections,
      ie. doesn't affect any code, so we can delay resizing the
      sections.  It's likely we'll resize everything in the process of
      adding stubs.  */
-  if (bfd_elf_discard_info (link_info.output_bfd, & link_info))
+  ret = bfd_elf_discard_info (link_info.output_bfd, & link_info);
+  if (ret < 0)
+    {
+      einfo ("%X%P: .eh_frame/.stab edit: %E\n");
+      return;
+    }
+  else if (ret > 0)
     need_laying_out = 1;
 
   /* If generating a relocatable output file, then we don't
      have to examine the relocs.  */
   if (stub_file != NULL && !link_info.relocatable)
     {
-      int ret = elf${ELFSIZE}_aarch64_setup_section_lists (link_info.output_bfd,
-                                                  & link_info);
-
+      ret = elf${ELFSIZE}_aarch64_setup_section_lists (link_info.output_bfd,
+                                                      &link_info);
       if (ret != 0)
        {
          if (ret < 0)
index 34028eefac49ff7232f7f5b1406d8e1fb0e3dabe..371b440cecb7479270c577c98a57cd45a1958adc 100644 (file)
@@ -271,6 +271,8 @@ compare_output_sec_vma (const void *a, const void *b)
 static void
 gld${EMULATION_NAME}_after_allocation (void)
 {
+  int ret;
+
   if (!link_info.relocatable)
     {
       /* Build a sorted list of input text sections, then use that to process
@@ -325,15 +327,20 @@ gld${EMULATION_NAME}_after_allocation (void)
      ie. doesn't affect any code, so we can delay resizing the
      sections.  It's likely we'll resize everything in the process of
      adding stubs.  */
-  if (bfd_elf_discard_info (link_info.output_bfd, & link_info))
+  ret = bfd_elf_discard_info (link_info.output_bfd, & link_info);
+  if (ret < 0)
+    {
+      einfo ("%X%P: .eh_frame/.stab edit: %E\n");
+      return;
+    }
+  else if (ret > 0)
     need_laying_out = 1;
 
   /* If generating a relocatable output file, then we don't
      have to examine the relocs.  */
   if (stub_file != NULL && !link_info.relocatable)
     {
-      int  ret = elf32_arm_setup_section_lists (link_info.output_bfd, & link_info);
-
+      ret = elf32_arm_setup_section_lists (link_info.output_bfd, &link_info);
       if (ret != 0)
        {
          if (ret < 0)
index 39b4ccd4f171824501a1fd48d11c88cb99e614de..67c437daca4ae9b0a2eaa83649fd6007558d6516 100644 (file)
@@ -1942,9 +1942,12 @@ fragment <<EOF
 static void
 gld${EMULATION_NAME}_after_allocation (void)
 {
-  bfd_boolean need_layout = bfd_elf_discard_info (link_info.output_bfd,
-                                                 &link_info);
-  gld${EMULATION_NAME}_map_segments (need_layout);
+  int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info);
+
+  if (need_layout < 0)
+    einfo ("%X%P: .eh_frame/.stab edit: %E\n");
+  else
+    gld${EMULATION_NAME}_map_segments (need_layout);
 }
 EOF
 fi
index 7cb4537b6fa8c8e6803d144eab79cb3db7b25a33..695579650f5b3f0ba5f5e2a3755dcc833cd6ac00 100644 (file)
@@ -242,20 +242,26 @@ build_section_lists (lang_statement_union_type *statement)
 static void
 gld${EMULATION_NAME}_after_allocation (void)
 {
+  int ret;
+
   /* bfd_elf_discard_info just plays with data and debugging sections,
      ie. doesn't affect code size, so we can delay resizing the
      sections.  It's likely we'll resize everything in the process of
      adding stubs.  */
-  if (bfd_elf_discard_info (link_info.output_bfd, &link_info))
+  ret = bfd_elf_discard_info (link_info.output_bfd, &link_info);
+  if (ret < 0)
+    {
+      einfo ("%X%P: .eh_frame/.stab edit: %E\n");
+      return;
+    }
+  else if (ret > 0)
     need_laying_out = 1;
 
   /* If generating a relocatable output file, then we don't
      have to examine the relocs.  */
   if (stub_file != NULL && !link_info.relocatable)
     {
-      int ret = elf32_hppa_setup_section_lists (link_info.output_bfd,
-                                               &link_info);
-
+      ret = elf32_hppa_setup_section_lists (link_info.output_bfd, &link_info);
       if (ret != 0)
        {
          if (ret < 0)
index 1f77ecd0a274efec76ac5d6b374f3dac8b281f19..97739dc710d005e49c2d899d33f53a4040759e63 100644 (file)
@@ -219,20 +219,26 @@ build_section_lists (lang_statement_union_type *statement)
 static void
 gld${EMULATION_NAME}_after_allocation (void)
 {
+  int ret;
+
   /* bfd_elf_discard_info just plays with data and debugging sections,
      ie. doesn't affect code size, so we can delay resizing the
      sections.  It's likely we'll resize everything in the process of
      adding stubs.  */
-  if (bfd_elf_discard_info (link_info.output_bfd, &link_info))
+  ret = bfd_elf_discard_info (link_info.output_bfd, &link_info);
+  if (ret < 0)
+    {
+      einfo ("%X%P: .eh_frame/.stab edit: %E\n");
+      return;
+    }
+  else if (ret > 0)
     need_laying_out = 1;
 
   /* If generating a relocatable output file, then we don't
      have to examine the relocs.  */
   if (stub_file != NULL && !link_info.relocatable)
     {
-      int ret = elf_metag_setup_section_lists (link_info.output_bfd,
-                                              &link_info);
-
+      ret = elf_metag_setup_section_lists (link_info.output_bfd, &link_info);
       if (ret != 0)
        {
          if (ret < 0)
index 991a11b9f2f897abc7b0ee2354d143b60095be10..bdf54a3e03ff426f7027751e0004461f80bf9617 100644 (file)
@@ -236,20 +236,26 @@ build_section_lists (lang_statement_union_type *statement)
 static void
 gld${EMULATION_NAME}_after_allocation (void)
 {
+  int ret;
+
   /* bfd_elf_discard_info just plays with data and debugging sections,
      ie. doesn't affect code size, so we can delay resizing the
      sections.  It's likely we'll resize everything in the process of
      adding stubs.  */
-  if (bfd_elf_discard_info (link_info.output_bfd, &link_info))
+  ret = bfd_elf_discard_info (link_info.output_bfd, &link_info);
+  if (ret < 0)
+    {
+      einfo ("%X%P: .eh_frame/.stab edit: %E\n");
+      return;
+    }
+  else if (ret > 0)
     need_laying_out = 1;
 
   /* If generating a relocatable output file, then we don't
      have to examine the relocs.  */
   if (stub_file != NULL && !link_info.relocatable && RELAXATION_ENABLED)
     {
-      int ret = nios2_elf32_setup_section_lists (link_info.output_bfd,
-                                                &link_info);
-
+      ret = nios2_elf32_setup_section_lists (link_info.output_bfd, &link_info);
       if (ret != 0)
        {
          if (ret < 0)
index d45fdacf2da55628e82b5bf197dab64302809978..3e316af975169c9d67a7ef64d749e68654ef83cf 100644 (file)
@@ -458,18 +458,26 @@ build_section_lists (lang_statement_union_type *statement)
 static void
 gld${EMULATION_NAME}_after_allocation (void)
 {
+  int ret;
+
   /* bfd_elf_discard_info just plays with data and debugging sections,
      ie. doesn't affect code size, so we can delay resizing the
      sections.  It's likely we'll resize everything in the process of
      adding stubs.  */
-  if (bfd_elf_discard_info (link_info.output_bfd, &link_info))
+  ret = bfd_elf_discard_info (link_info.output_bfd, &link_info);
+  if (ret < 0)
+    {
+      einfo ("%X%P: .eh_frame/.stab edit: %E\n");
+      return;
+    }
+  else if (ret > 0)
     need_laying_out = 1;
 
   /* If generating a relocatable output file, then we don't have any
      stubs.  */
   if (stub_file != NULL && !link_info.relocatable)
     {
-      int ret = ppc64_elf_setup_section_lists (&link_info);
+      ret = ppc64_elf_setup_section_lists (&link_info);
       if (ret < 0)
        einfo ("%X%P: can not size stub section: %E\n");
       else if (ret > 0)
index ca957c4bcfeeb026d0483e5159c39267cbdd4056..ff591f13eadd915564f25422bcc5618f845be085 100644 (file)
@@ -95,6 +95,7 @@ static void
 gld${EMULATION_NAME}_after_allocation (void)
 {
   int layout_changed = 0;
+  int ret;
 
   if (!link_info.relocatable)
     {
@@ -149,7 +150,13 @@ gld${EMULATION_NAME}_after_allocation (void)
   /* bfd_elf32_discard_info just plays with debugging sections,
      ie. doesn't affect any code, so we can delay resizing the
      sections.  */
-  if (bfd_elf_discard_info (link_info.output_bfd, & link_info))
+  ret = bfd_elf_discard_info (link_info.output_bfd, & link_info);
+  if (ret < 0)
+    {
+      einfo ("%X%P: .eh_frame/.stab edit: %E\n");
+      return;
+    }
+  else if (ret > 0)
     layout_changed = 1;
 
   gld${EMULATION_NAME}_map_segments (layout_changed);
index b1f61d5b3b0665aca4796311d237c0e2f4573d5e..40be66d8f1349344e82c6ab320377526d247525d 100644 (file)
@@ -207,9 +207,12 @@ gld${EMULATION_NAME}_before_allocation (void)
 static void
 gld${EMULATION_NAME}_after_allocation (void)
 {
-  bfd_boolean need_layout = bfd_elf_discard_info (link_info.output_bfd,
-                                                 &link_info);
-  gld${EMULATION_NAME}_map_segments (need_layout);
+  int need_layout = bfd_elf_discard_info (link_info.output_bfd, &link_info);
+
+  if (need_layout < 0)
+    einfo ("%X%P: .eh_frame/.stab edit: %E\n");
+  else
+    gld${EMULATION_NAME}_map_segments (need_layout);
 }
 
 static void