-Og warning fixes
authorAlan Modra <amodra@gmail.com>
Sat, 2 Sep 2017 01:30:02 +0000 (11:00 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 2 Sep 2017 01:30:02 +0000 (11:00 +0930)
Found when building with gcc 4.9.4 using -Og.

bfd/
* elf-eh-frame.c (offset_adjust): Avoid false positive gcc warning.
* elflink.c (bfd_elf_size_dynsym_hash_dynstr): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
ld/
* emultempl/msp430.em (eval_upper_either_sections): Make base_sec_name
a const char*.
(eval_lower_either_sections): Likewise.
(msp430_elf_after_allocation): Likewise, and don't needlessly concat
and free.  Warning fix.

bfd/ChangeLog
bfd/elf-eh-frame.c
bfd/elflink.c
bfd/elfnn-aarch64.c
ld/ChangeLog
ld/emultempl/msp430.em

index 1b3276c45d48ca3d0ccf637ba225f0fec82b8a98..5dde137405db6092cd61a80bee399eec1b459f5f 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-02  Alan Modra  <amodra@gmail.com>
+
+       * elf-eh-frame.c (offset_adjust): Avoid false positive gcc warning.
+       * elflink.c (bfd_elf_size_dynsym_hash_dynstr): Likewise.
+       * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
+
 2017-09-01  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf32-i386.c (elf_i386_gc_mark_hook): Removed.
index f0ede2d6f7cf9c9ed8153f97b5cd9b8bce03b792..cd81b608d35befeeb10b1bd7a3ff03092a9eca24 100644 (file)
@@ -1335,7 +1335,7 @@ offset_adjust (bfd_vma offset, const asection *sec)
   struct eh_frame_sec_info *sec_info
     = (struct eh_frame_sec_info *) elf_section_data (sec)->sec_info;
   unsigned int lo, hi, mid;
-  struct eh_cie_fde *ent;
+  struct eh_cie_fde *ent = NULL;
   bfd_signed_vma delta;
 
   lo = 0;
index 6008915fed3cb8374ea264a1097a399dba385681..58fb83b4b2783d0918fba65a9f5e393040225702 100644 (file)
@@ -6855,7 +6855,7 @@ bfd_elf_size_dynsym_hash_dynstr (bfd *output_bfd, struct bfd_link_info *info)
 {
   const struct elf_backend_data *bed;
   unsigned long section_sym_count;
-  bfd_size_type dynsymcount;
+  bfd_size_type dynsymcount = 0;
 
   if (!is_elf_hash_table (info->hash))
     return TRUE;
index 796fe1f17678d694e33671cca5162f579f431022..92970561eedb5d1abd8a19f1eb2eb411bad132b8 100644 (file)
@@ -4944,7 +4944,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
     = elfNN_aarch64_bfd_reloc_from_howto (howto);
   unsigned long r_symndx;
   bfd_byte *hit_data = contents + rel->r_offset;
-  bfd_vma place, off, got_entry_addr;
+  bfd_vma place, off, got_entry_addr = 0;
   bfd_signed_vma signed_addend;
   struct elf_aarch64_link_hash_table *globals;
   bfd_boolean weak_undef_p;
index b0029ea2cad171a50182578329748bf75403f719..4a45000813d323be89685a082257cbfa34936662 100644 (file)
@@ -1,3 +1,11 @@
+2017-09-02  Alan Modra  <amodra@gmail.com>
+
+       * emultempl/msp430.em (eval_upper_either_sections): Make base_sec_name
+       a const char*.
+       (eval_lower_either_sections): Likewise.
+       (msp430_elf_after_allocation): Likewise, and don't needlessly concat
+       and free.  Warning fix.
+
 2017-09-01  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/22061
index f1bbc858514807c7c9efe49eb4072f7613f22688..a956a2fb9ad4b46d5a4fcbb5d5abc94d1b100f59 100644 (file)
@@ -557,7 +557,7 @@ gld${EMULATION_NAME}_handle_option (int optc)
 static void
 eval_upper_either_sections (bfd *abfd, asection *s, void *data)
 {
-  char * base_sec_name;
+  const char * base_sec_name;
   const char * curr_name;
   char * either_name;
   int curr_region;
@@ -576,7 +576,7 @@ eval_upper_either_sections (bfd *abfd, asection *s, void *data)
   if (bfd_link_relocatable (&link_info))
     return;
 
-  base_sec_name = (char *) data;
+  base_sec_name = (const char *) data;
   curr_name = bfd_get_section_name (abfd, s);
 
   /* Only concerned with .either input sections in the upper output section.  */
@@ -639,7 +639,7 @@ eval_upper_either_sections (bfd *abfd, asection *s, void *data)
 static void
 eval_lower_either_sections (bfd *abfd, asection *s, void *data)
 {
-  char * base_sec_name;
+  const char * base_sec_name;
   const char * curr_name;
   char * either_name;
   int curr_region;
@@ -656,7 +656,7 @@ eval_lower_either_sections (bfd *abfd, asection *s, void *data)
   if (bfd_link_relocatable (&link_info))
     return;
 
-  base_sec_name = (char *) data;
+  base_sec_name = (const char *) data;
   curr_name = bfd_get_section_name (abfd, s);
 
   /* Only concerned with .either input sections in the lower or "default"
@@ -758,29 +758,30 @@ static void
 msp430_elf_after_allocation (void)
 {
   int relax_count = 0;
-  int i;
+  unsigned int i;
   /* Go over each section twice, once to place either sections that don't fit
      in lower into upper, and then again to move any sections in upper that
      fit in lower into lower.  */
   for (i = 0; i < 8; i++)
     {
       int placement_stage = (i < 4) ? LOWER_TO_UPPER : UPPER_TO_LOWER;
-      char * base_sec_name;
+      const char * base_sec_name;
       lang_output_section_statement_type * upper;
 
       switch (i % 4)
        {
+       default:
        case 0:
-         base_sec_name = concat (".text", NULL);
+         base_sec_name = ".text";
          break;
        case 1:
-         base_sec_name = concat (".data", NULL);
+         base_sec_name = ".data";
          break;
        case 2:
-         base_sec_name = concat (".bss", NULL);
+         base_sec_name = ".bss";
          break;
        case 3:
-         base_sec_name = concat (".rodata", NULL);
+         base_sec_name = ".rodata";
          break;
        }
       upper = lang_output_section_find (concat (".upper", base_sec_name, NULL));
@@ -806,7 +807,7 @@ msp430_elf_after_allocation (void)
                   abfd = abfd->link.next)
                {
                  bfd_map_over_sections (abfd, eval_lower_either_sections,
-                                        base_sec_name);
+                                        (void *) base_sec_name);
                }
            }
          else if (placement_stage == UPPER_TO_LOWER)
@@ -821,12 +822,11 @@ msp430_elf_after_allocation (void)
                   abfd = abfd->link.next)
                {
                  bfd_map_over_sections (abfd, eval_upper_either_sections,
-                                        base_sec_name);
+                                        (void *) base_sec_name);
                }
            }
 
        }
-      free (base_sec_name);
     }
   gld${EMULATION_NAME}_after_allocation ();
 }
This page took 0.04641 seconds and 4 git commands to generate.