]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas tc_gen_reloc memory leaks
authorAlan Modra <amodra@gmail.com>
Wed, 1 Jan 2025 12:19:04 +0000 (22:49 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 1 Jan 2025 12:19:04 +0000 (22:49 +1030)
This makes all the tc_gen_reloc functions and the associated array in
write.c:write_relocs use notes_alloc rather than malloc.  tc-hppa.c
tc_gen_reloc gets a few more changes, deleting some dead code, and
tidying code that duplicates prior initialisation.

67 files changed:
gas/cgen.c
gas/config/tc-aarch64.c
gas/config/tc-alpha.c
gas/config/tc-arc.c
gas/config/tc-arm.c
gas/config/tc-avr.c
gas/config/tc-bfin.c
gas/config/tc-bpf.c
gas/config/tc-cr16.c
gas/config/tc-cris.c
gas/config/tc-crx.c
gas/config/tc-csky.c
gas/config/tc-d10v.c
gas/config/tc-d30v.c
gas/config/tc-dlx.c
gas/config/tc-ft32.c
gas/config/tc-h8300.c
gas/config/tc-hppa.c
gas/config/tc-i386.c
gas/config/tc-ia64.c
gas/config/tc-kvx.c
gas/config/tc-loongarch.c
gas/config/tc-m32c.c
gas/config/tc-m32r.c
gas/config/tc-m68hc11.c
gas/config/tc-m68k.c
gas/config/tc-mcore.c
gas/config/tc-metag.c
gas/config/tc-microblaze.c
gas/config/tc-mips.c
gas/config/tc-mmix.c
gas/config/tc-mn10200.c
gas/config/tc-mn10300.c
gas/config/tc-moxie.c
gas/config/tc-msp430.c
gas/config/tc-nds32.c
gas/config/tc-ns32k.c
gas/config/tc-or1k.c
gas/config/tc-pdp11.c
gas/config/tc-pj.c
gas/config/tc-ppc.c
gas/config/tc-pru.c
gas/config/tc-riscv.c
gas/config/tc-rl78.c
gas/config/tc-rx.c
gas/config/tc-s12z.c
gas/config/tc-s390.c
gas/config/tc-score.c
gas/config/tc-score7.c
gas/config/tc-sh.c
gas/config/tc-sparc.c
gas/config/tc-spu.c
gas/config/tc-tic30.c
gas/config/tc-tic4x.c
gas/config/tc-tic54x.c
gas/config/tc-tic6x.c
gas/config/tc-tilegx.c
gas/config/tc-tilepro.c
gas/config/tc-v850.c
gas/config/tc-vax.c
gas/config/tc-visium.c
gas/config/tc-wasm32.c
gas/config/tc-xgate.c
gas/config/tc-xtensa.c
gas/config/tc-z80.c
gas/config/tc-z8k.c
gas/write.c

index bdadf32430e9f085ed42b8a13ca5f098912ff5f5..030c2f0bebde30965163c74862de63a4ba8d1135 100644 (file)
@@ -1023,7 +1023,9 @@ gas_cgen_tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
   bfd_reloc_code_real_type r_type = fixP->fx_r_type;
   arelent *reloc;
 
-  reloc = XNEW (arelent);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
 
 #ifdef GAS_CGEN_PCREL_R_TYPE
   if (fixP->fx_pcrel)
@@ -1031,7 +1033,7 @@ gas_cgen_tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
 #endif
   reloc->howto = bfd_reloc_type_lookup (stdoutput, r_type);
 
-  if (reloc->howto == (reloc_howto_type *) NULL)
+  if (reloc->howto == NULL)
     {
       as_bad_where (fixP->fx_file, fixP->fx_line,
                    _("relocation is not supported"));
@@ -1040,9 +1042,6 @@ gas_cgen_tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
 
   gas_assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
 
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
-  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
-
   /* Use fx_offset for these cases.  */
   if (fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY
       || fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT)
index bf594e70960e8dab7f35fc7a4ddc6fff95033463..3046d3d8b5e216bf621a96d5f23fdb0cb1562a8d 100644 (file)
@@ -9984,9 +9984,8 @@ tc_gen_reloc (asection * section, fixS * fixp)
   arelent *reloc;
   bfd_reloc_code_real_type code;
 
-  reloc = XNEW (arelent);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 8d27f7585bee3f495bbb4d4f2e8fe7d2a1e872e7..4f5897bd58e74b2ddc4c88866d13239ea7f51b92 100644 (file)
@@ -6224,8 +6224,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED,
 {
   arelent *reloc;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
@@ -6300,7 +6300,7 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED,
          pname = symbol_get_bfdsym (sym)->name;
        }
 
-      udata = XNEW (struct evax_private_udata_struct);
+      udata = notes_alloc (sizeof (*udata));
       udata->enbsym = symbol_get_bfdsym (fixp->fx_addsy);
       udata->bsym = symbol_get_bfdsym (fixp->tc_fix_data.info->psym);
       udata->origname = (char *)pname;
index d62e0a19693574845cf1ff1df54c277783d62d56..8b69ca6d1f7bae44727b4f4908a1606e454034a7 100644 (file)
@@ -3251,8 +3251,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
   arelent *reloc;
   bfd_reloc_code_real_type code;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
 
index f977117500ca0c1f2db5bc144f6cae0b3a5f811d..c2173b730ed31c4672063b612163d1b3e622ba10 100644 (file)
@@ -29358,9 +29358,8 @@ tc_gen_reloc (asection *section, fixS *fixp)
   arelent * reloc;
   bfd_reloc_code_real_type code;
 
-  reloc = XNEW (arelent);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 61398e6823e1fe9826f3da4684a50a30caecf977..5976e58dd3353a7ccfbb58872b30e41e8526f0e8 100644 (file)
@@ -1838,9 +1838,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED,
       return NULL;
     }
 
-  reloc = XNEW (arelent);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
 
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
index 44c3661bd9d3fb2f912cf795962101a1249b3272..d91ca5fa0830559a326036810b5b447882b771d9 100644 (file)
@@ -798,10 +798,10 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
-  reloc                      = XNEW (arelent);
-  reloc->sym_ptr_ptr  = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
-  reloc->address      = fixp->fx_frag->fr_address + fixp->fx_where;
+  reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
   reloc->addend = fixp->fx_offset;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
@@ -812,9 +812,6 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
                    /* xgettext:c-format.  */
                    _("reloc %d not supported by object file format"),
                    (int) fixp->fx_r_type);
-
-      xfree (reloc);
-
       return NULL;
     }
 
index a2923354219eb392953507b9dc700f2ea8c508a0..91ef7b3a49c1474c80414080313c151922219f8e 100644 (file)
@@ -346,7 +346,9 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixP)
   bfd_reloc_code_real_type r_type = fixP->fx_r_type;
   arelent *reloc;
 
-  reloc = XNEW (arelent);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
 
   if (fixP->fx_pcrel)
    {
@@ -367,11 +369,6 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixP)
       return NULL;
     }
 
-  //XXX  gas_assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
-  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
-
   /* Use fx_offset for these cases.  */
   if (fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY
       || fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT)
index 4f2ef2c1501ffa0a2263951a0c2578dfa4be56d1..4bc6a14187ee07c88fda7fd1251b86f8f614a80d 100644 (file)
@@ -537,8 +537,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
           && (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)))
     return NULL;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr  = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
   reloc->addend = fixP->fx_offset;
@@ -574,8 +574,6 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
        {
          /* We only resolve difference expressions in the same section.  */
          as_bad_subtract (fixP);
-         free (reloc->sym_ptr_ptr);
-         free (reloc);
          return NULL;
        }
     }
index 302e7d06be61ac76c18fbd7fedeb3ae76a900120..2c002845bcc4012b28afaf0ea87d718c509feee2 100644 (file)
@@ -3953,9 +3953,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
       return 0;
     }
 
-  relP = XNEW (arelent);
-  gas_assert (relP != 0);
-  relP->sym_ptr_ptr = XNEW (asymbol *);
+  relP = notes_alloc (sizeof (arelent));
+  relP->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *relP->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
 
index 0561a07c184f9b2efce82055afbbe33d60ff6672..7a8db73bb0e3a98be358cc1af629da728d9dc93d 100644 (file)
@@ -284,8 +284,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
 {
   arelent * reloc;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr  = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
   reloc->addend = fixP->fx_offset;
@@ -318,8 +318,6 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
        {
          /* We only resolve difference expressions in the same section.  */
          as_bad_subtract (fixP);
-         free (reloc->sym_ptr_ptr);
-         free (reloc);
          return NULL;
        }
     }
index 90bc411f7929d62e6fbca6333394be2b163ba11f..df98c88459c10df5d267841034b9f1da20eacb52 100644 (file)
@@ -5655,10 +5655,10 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
 
   if (fixP->fx_pcrel
       && fixP->fx_r_type == BFD_RELOC_CKCORE_ADDR32)
-      fixP->fx_r_type = BFD_RELOC_CKCORE_PCREL32;
+    fixP->fx_r_type = BFD_RELOC_CKCORE_PCREL32;
 
-  rel = xmalloc (sizeof (arelent));
-  rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+  rel = notes_alloc (sizeof (arelent));
+  rel->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *rel->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   rel->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type);
   rel->addend = fixP->fx_offset;
index eeaf8bcd1bd37ad2e492e8fe626c49fad1ccaeb1..d6c2a47a0b5d82f48f92b27f4d554f54ebf72ca6 100644 (file)
@@ -1450,8 +1450,8 @@ arelent *
 tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
index 1971e9227fb717ecbfbc43e780210aab866e3a65..d465b2a2214915538e46e5fd00c5f57bbc4d4bff 100644 (file)
@@ -1757,8 +1757,8 @@ arelent *
 tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
index d77a36b19b47fd1297e40c266c8974fb6a3d567c..a3922710a8b4116bea24562a3ca725fe8a1b3918 100644 (file)
@@ -1169,9 +1169,11 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
 {
   arelent * reloc;
 
-  reloc = XNEW (arelent);
-  reloc->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
 
+  reloc->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type);
   if (reloc->howto == NULL)
     {
       as_bad_where (fixP->fx_file, fixP->fx_line,
@@ -1183,8 +1185,6 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
 
   gas_assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
 
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
-  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
 
   if (fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
index 8468df198af118f7a324ff828849523a618fd60c..4c177e0b2c60774be9a2b1e84a80d314ef1a23cd 100644 (file)
@@ -690,9 +690,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
       return NULL;
     }
 
-  relP = XNEW (arelent);
-  gas_assert (relP != 0);
-  relP->sym_ptr_ptr = XNEW (asymbol *);
+  relP = notes_alloc (sizeof (arelent));
+  relP->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *relP->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
 
index f1dd69edf256872dcdd1eb6b07e54a70300a464a..f8e5406416611dc53d9987e9a6bb90ab29fc494f 100644 (file)
@@ -2300,8 +2300,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
        }
     }
 
-  rel = XNEW (arelent);
-  rel->sym_ptr_ptr = XNEW (asymbol *);
+  rel = notes_alloc (sizeof (arelent));
+  rel->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
   rel->addend = fixp->fx_offset;
index 9124e41fcd7f02104457c5619f6d2b2a14ad15b1..80a142fa4667b6175698036d803853c12db7d9c1 100644 (file)
@@ -1348,18 +1348,13 @@ tc_gen_reloc (asection *section, fixS *fixp)
   int n_relocs;
   int i;
 
-  hppa_fixp = (struct hppa_fix_struct *) fixp->tc_fix_data;
   if (fixp->fx_addsy == 0)
     return &no_relocs;
 
+  hppa_fixp = (struct hppa_fix_struct *) fixp->tc_fix_data;
   gas_assert (hppa_fixp != 0);
   gas_assert (section != 0);
 
-  reloc = XNEW (arelent);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
-  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
-
   /* Allow fixup_segment to recognize hand-written pc-relative relocations.
      When we went through cons_fix_new_hppa, we classified them as complex.  */
   /* ??? It might be better to hide this +8 stuff in tc_cfi_emit_pcrel_expr,
@@ -1388,11 +1383,10 @@ tc_gen_reloc (asection *section, fixS *fixp)
   for (n_relocs = 0; codes[n_relocs]; n_relocs++)
     ;
 
-  relocs = XNEWVEC (arelent *, n_relocs + 1);
-  reloc = XNEWVEC (arelent, n_relocs);
+  relocs = notes_alloc (sizeof (*relocs) * (n_relocs + 1));
+  reloc = notes_alloc (sizeof (*reloc) * n_relocs);
   for (i = 0; i < n_relocs; i++)
     relocs[i] = &reloc[i];
-
   relocs[n_relocs] = NULL;
 
 #ifdef OBJ_ELF
@@ -1447,7 +1441,7 @@ tc_gen_reloc (asection *section, fixS *fixp)
          break;
        }
 
-      reloc->sym_ptr_ptr = XNEW (asymbol *);
+      reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
       *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
       reloc->howto = bfd_reloc_type_lookup (stdoutput,
                                            (bfd_reloc_code_real_type) code);
@@ -1463,7 +1457,7 @@ tc_gen_reloc (asection *section, fixS *fixp)
     {
       code = *codes[i];
 
-      relocs[i]->sym_ptr_ptr = XNEW (asymbol *);
+      relocs[i]->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
       *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
       relocs[i]->howto =
        bfd_reloc_type_lookup (stdoutput,
@@ -1477,20 +1471,12 @@ tc_gen_reloc (asection *section, fixS *fixp)
             of two symbols.  With that in mind we fill in all four
             relocs now and break out of the loop.  */
          gas_assert (i == 1);
+         /* relocs[0] and relocs[1] have been initialised above.  We can
+            use relocs[0]->sym_ptr_ptr allocation for relocs[2].  */
+         relocs[2]->sym_ptr_ptr = relocs[0]->sym_ptr_ptr;
          relocs[0]->sym_ptr_ptr = &bfd_abs_section_ptr->symbol;
-         relocs[0]->howto
-           = bfd_reloc_type_lookup (stdoutput,
-                                    (bfd_reloc_code_real_type) *codes[0]);
-         relocs[0]->address = fixp->fx_frag->fr_address + fixp->fx_where;
          relocs[0]->addend = 0;
-         relocs[1]->sym_ptr_ptr = XNEW (asymbol *);
-         *relocs[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
-         relocs[1]->howto
-           = bfd_reloc_type_lookup (stdoutput,
-                                    (bfd_reloc_code_real_type) *codes[1]);
-         relocs[1]->address = fixp->fx_frag->fr_address + fixp->fx_where;
          relocs[1]->addend = 0;
-         relocs[2]->sym_ptr_ptr = XNEW (asymbol *);
          *relocs[2]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
          relocs[2]->howto
            = bfd_reloc_type_lookup (stdoutput,
@@ -1543,7 +1529,6 @@ tc_gen_reloc (asection *section, fixS *fixp)
        case R_N0SEL:
        case R_N1SEL:
          /* There is no symbol or addend associated with these fixups.  */
-         relocs[i]->sym_ptr_ptr = XNEW (asymbol *);
          *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol);
          relocs[i]->addend = 0;
          break;
@@ -1552,7 +1537,6 @@ tc_gen_reloc (asection *section, fixS *fixp)
        case R_ENTRY:
        case R_EXIT:
          /* There is no symbol associated with these fixups.  */
-         relocs[i]->sym_ptr_ptr = XNEW (asymbol *);
          *relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol);
          relocs[i]->addend = fixp->fx_offset;
          break;
index cd57972086c832be58b7433589c1ea2a070ef341..09c0d2154e112dc9e52df57e0d7f4413e7441926 100644 (file)
@@ -18169,8 +18169,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
       code = BFD_RELOC_X86_64_GOTPC64;
     }
 
-  rel = XNEW (arelent);
-  rel->sym_ptr_ptr = XNEW (asymbol *);
+  rel = notes_alloc (sizeof (arelent));
+  rel->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
 
   rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
index 5b714ccefdbc7a9c501a7bd9e645a6ad35ebd076..b50823270aa635f604de00cfacfb3e85d6be1f8c 100644 (file)
@@ -11515,8 +11515,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->addend = fixp->fx_offset;
@@ -11527,7 +11527,6 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixp)
       as_bad_where (fixp->fx_file, fixp->fx_line,
                    _("Cannot represent %s relocation in object file"),
                    bfd_get_reloc_code_name (fixp->fx_r_type));
-      free (reloc);
       return NULL;
     }
   return reloc;
index 3f641dbff8100907a63b52ed63245c50bfbf834f..02887453b4219a65b58f8f06d5266a7d6ee8f601 100644 (file)
@@ -1914,9 +1914,8 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
   arelent *reloc;
   bfd_reloc_code_real_type code;
 
-  reloc = (arelent *) xmalloc (sizeof (arelent));
-
-  reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 3ddb7bcf7a759ba22179f9f285ec672721be702b..b0bcdebdd105a314111f2fbef4a95892289015b6 100644 (file)
@@ -1879,9 +1879,10 @@ md_estimate_size_before_relax (fragS *fragp, asection *sec)
 arelent *
 tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 {
-  arelent *reloc = (arelent *) xmalloc (sizeof (arelent));
+  arelent *reloc;
 
-  reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->addend = fixp->fx_offset;
index c46162b5c26f12edfc64d983d9936c401632c077..b5887b1c6b313cf7fda35460381b1897d2162710 100644 (file)
@@ -1032,11 +1032,10 @@ tc_gen_reloc (asection *sec, fixS *fx)
       || fx->fx_r_type == BFD_RELOC_M32C_RL_1ADDR
       || fx->fx_r_type == BFD_RELOC_M32C_RL_2ADDR)
     {
-      arelent * reloc;
+      arelent *reloc;
 
-      reloc = XNEW (arelent);
-
-      reloc->sym_ptr_ptr = XNEW (asymbol *);
+      reloc = notes_alloc (sizeof (arelent));
+      reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
       *reloc->sym_ptr_ptr = symbol_get_bfdsym (fx->fx_addsy);
       reloc->address = fx->fx_frag->fr_address + fx->fx_where;
       reloc->howto = bfd_reloc_type_lookup (stdoutput, fx->fx_r_type);
index 4baa5dfd4480da107774f102bd00f0b8be2abcaf..aa0acea77431b73e36ae8ade124d72faf2217ae3 100644 (file)
@@ -2193,9 +2193,8 @@ tc_gen_reloc (asection * section, fixS * fixP)
   arelent * reloc;
   bfd_reloc_code_real_type code;
 
-  reloc = XNEW (arelent);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
 
@@ -2268,7 +2267,7 @@ printf(" => %s",bfd_get_reloc_code_name(code));
 printf(" => %s\n",reloc->howto->name);
 #endif
 
- if (reloc->howto == (reloc_howto_type *) NULL)
+ if (reloc->howto == NULL)
     {
       as_bad_where (fixP->fx_file, fixP->fx_line,
             _("internal error: can't export reloc type %d (`%s')"),
index cc6e86aba07d3f58f58e9710c4ae3fd8ed0b1061..8c8035ce59465672ab671fc1a60fbad2c1cc99a7 100644 (file)
@@ -3830,8 +3830,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   if (fixp->fx_r_type == 0)
index 4b24b162bad18dc63b37312080962a465314a7f6..1f8f9a8f3c73d3aedf2de0914782c2a689465729 100644 (file)
@@ -1282,8 +1282,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 #undef F
 #undef MAP
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   if (!fixp->fx_pcrel)
index b02f96ed08698ce80db6f08bce58a077399ec637..1264577b3615fac47bedc1ccbce9bd49028026c9 100644 (file)
@@ -2193,8 +2193,8 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
       break;
   }
 
-  rel = XNEW (arelent);
-  rel->sym_ptr_ptr = XNEW (asymbol *);
+  rel = notes_alloc (sizeof (arelent));
+  rel->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
   /* Always pass the addend along!  */
index 4d4c212020f824b9d580999bc86587a0fca2f05c..bf084f7df1374f6b6dafe30b272d8946b87c4521 100644 (file)
@@ -7001,10 +7001,10 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
-  reloc                      = XNEW (arelent);
-  reloc->sym_ptr_ptr  = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
-  reloc->address      = fixp->fx_frag->fr_address + fixp->fx_where;
+  reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
   reloc->addend = fixp->fx_offset;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
@@ -7015,9 +7015,6 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
                    /* xgettext:c-format.  */
                    _("reloc %d not supported by object file format"),
                    (int) fixp->fx_r_type);
-
-      xfree (reloc);
-
       return NULL;
     }
 
index 97ffe23e3a5341ac420467b864d9de091b30de43..5774eeaefb8a5786a38a883d3e231efe86d313b1 100644 (file)
@@ -2533,8 +2533,8 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
       break;
     }
 
-  rel = XNEW (arelent);
-  rel->sym_ptr_ptr = XNEW (asymbol *);
+  rel = notes_alloc (sizeof (arelent));
+  rel->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
 
   if (code == BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM)
     *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
index 7024744167bd251ad734d8566a426b24a342af06..3c3383436115625734745ff16e9e7aa65b6ef51c 100644 (file)
@@ -18381,9 +18381,10 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
   arelent *reloc;
   bfd_reloc_code_real_type code;
 
-  memset (retval, 0, sizeof(retval));
-  reloc = retval[0] = XCNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  memset (retval, 0, sizeof (retval));
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  retval[0] = reloc;
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 50f17eb44fc6d498a25b42bab39d4cb3652fd47e..a43774d755c0e6188fb01c35651acfb14d3cab52 100644 (file)
@@ -2878,9 +2878,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
       return NULL;
     }
 
-  relP = XNEW (arelent);
-  gas_assert (relP != 0);
-  relP->sym_ptr_ptr = XNEW (asymbol *);
+  relP = notes_alloc (sizeof (arelent));
+  relP->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *relP->sym_ptr_ptr = baddsy;
   relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
 
index 8ce261b1e5c09b87c28dcd21b7db9175c56bd0f1..d630929f8c651e29f4c2052e0bb25fb7fe8914e5 100644 (file)
@@ -748,7 +748,10 @@ arelent *
 tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
-  reloc = XNEW (arelent);
+
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
 
   if (fixp->fx_subsy != NULL)
     {
@@ -774,8 +777,6 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
       return NULL;
     }
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
-  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->addend = fixp->fx_offset;
   return reloc;
 }
index e6e0593e05cf19c96f3236904407a4ba4c592318..08f6a1c6aefdaf93fc03757c2d00eca4b74d6920 100644 (file)
@@ -2169,7 +2169,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
   static arelent * relocs[MAX_RELOC_EXPANSION + 1];
   arelent *reloc;
 
-  reloc = XNEW (arelent);
+  reloc = notes_alloc (sizeof (arelent));
 
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
   if (reloc->howto == NULL)
@@ -2177,8 +2177,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
       as_bad_where (fixp->fx_file, fixp->fx_line,
                    _("reloc %d not supported by object file format"),
                    (int) fixp->fx_r_type);
-      free (reloc);
-      return & no_relocs;
+      return &no_relocs;
     }
 
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
@@ -2205,7 +2204,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
         even local symbols defined in the same section.  */
       if (ssec != absolute_section || asec != absolute_section)
        {
-         arelent * reloc2 = XNEW (arelent);
+         arelent *reloc2 = notes_alloc (sizeof (arelent));
 
          relocs[0] = reloc2;
          relocs[1] = reloc;
@@ -2213,7 +2212,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
          reloc2->address = reloc->address;
          reloc2->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_MN10300_SYM_DIFF);
          reloc2->addend = - S_GET_VALUE (fixp->fx_subsy);
-         reloc2->sym_ptr_ptr = XNEW (asymbol *);
+         reloc2->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
          *reloc2->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
 
          reloc->addend = fixp->fx_offset;
@@ -2224,7 +2223,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
            }
          else
            {
-             reloc->sym_ptr_ptr = XNEW (asymbol *);
+             reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
              *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
            }
 
@@ -2262,13 +2261,12 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
              return relocs;
            }
 
-         free (reloc);
-         return & no_relocs;
+         return &no_relocs;
        }
     }
   else
     {
-      reloc->sym_ptr_ptr = XNEW (asymbol *);
+      reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
       *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
       reloc->addend = fixp->fx_offset;
     }
index e4ab416ecd8188fde19445444914dc0c58b8fb75..28bed87536cb7b4af4c07be70ee3c473bb3d33fb 100644 (file)
@@ -777,8 +777,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
       return 0;
     }
 
-  relP = XNEW (arelent);
-  relP->sym_ptr_ptr = XNEW (asymbol *);
+  relP = notes_alloc (sizeof (arelent));
+  relP->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *relP->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
 
index 69159b219c79fb45dcedae8dbc30525fdcb86282..f5c864e401641e50a9a005ad801758d7ee231565 100644 (file)
@@ -4629,23 +4629,22 @@ S_IS_GAS_LOCAL (symbolS * s)
    then it is done here.  */
 
 arelent **
-tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
+tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
-  static arelent * no_relocs = NULL;
-  static arelent * relocs[MAX_RELOC_EXPANSION + 1];
+  static arelent *no_relocs = NULL;
+  static arelent *relocs[MAX_RELOC_EXPANSION + 1];
   arelent *reloc;
 
-  reloc = XNEW (arelent);
+  reloc = notes_alloc (sizeof (arelent));
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
 
-  if (reloc->howto == (reloc_howto_type *) NULL)
+  if (reloc->howto == NULL)
     {
       as_bad_where (fixp->fx_file, fixp->fx_line,
                    _("reloc %d not supported by object file format"),
                    (int) fixp->fx_r_type);
-      free (reloc);
-      return & no_relocs;
+      return &no_relocs;
     }
 
   relocs[0] = reloc;
@@ -4686,7 +4685,7 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
          && ! S_IS_GAS_LOCAL (fixp->fx_addsy)
          && ! S_IS_GAS_LOCAL (fixp->fx_subsy))
        {
-         arelent * reloc2 = XNEW (arelent);
+         arelent *reloc2 = notes_alloc (sizeof (arelent));
 
          relocs[0] = reloc2;
          relocs[1] = reloc;
@@ -4700,7 +4699,7 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
            reloc2->sym_ptr_ptr = &bfd_abs_section_ptr->symbol;
          else
            {
-             reloc2->sym_ptr_ptr = XNEW (asymbol *);
+             reloc2->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
              *reloc2->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
            }
 
@@ -4712,7 +4711,7 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
            }
          else
            {
-             reloc->sym_ptr_ptr = XNEW (asymbol *);
+             reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
              *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
            }
 
@@ -4750,8 +4749,7 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
              return relocs;
            }
 
-         free (reloc);
-         return & no_relocs;
+         return &no_relocs;
        }
     }
   else
@@ -4764,11 +4762,10 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
          char *fixpos = fixp->fx_where + fixp->fx_frag->fr_literal;
 
          md_number_to_chars (fixpos, amount, 2);
-         free (reloc);
-         return & no_relocs;
+         return &no_relocs;
        }
 #endif
-      reloc->sym_ptr_ptr = XNEW (asymbol *);
+      reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
       *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
       reloc->addend = fixp->fx_offset;
 
index 41a0739cf2184a837855ddb8bcee14e0c13d6a80..3de27fdcea999331af18c22ffa61d45a909842cd 100644 (file)
@@ -7826,9 +7826,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
   arelent *reloc;
   bfd_reloc_code_real_type code;
 
-  reloc = XNEW (arelent);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
 
index 8a417ef8d98c6212a31eca03b75c00d20ec0784b..ba30e247dc1080c699d560ddd75befc1f5566788 100644 (file)
@@ -2226,8 +2226,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 
   code = reloc (fixp->fx_size, fixp->fx_pcrel, fix_im_disp (fixp));
 
-  rel = XNEW (arelent);
-  rel->sym_ptr_ptr = XNEW (asymbol *);
+  rel = notes_alloc (sizeof (arelent));
+  rel->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
   if (fixp->fx_pcrel)
index 1ff5a60659d7eb75adbfeef4026089b9d832f132..5b3e0130628ade75efe33a4eff42a1fbdc26bde0 100644 (file)
@@ -298,9 +298,8 @@ tc_gen_reloc (asection * section, fixS * fixp)
   arelent *reloc;
   bfd_reloc_code_real_type code;
 
-  reloc = XNEW (arelent);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 1168b35957ccae16849fe63b9e3907278629455d..2ae671082ecc740cdde7d1a48da308a2008c03e1 100644 (file)
@@ -1430,9 +1430,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
   arelent *reloc;
   bfd_reloc_code_real_type code;
 
-  reloc = XNEW (arelent);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 7a8164eaec8d36d6ce4e5843f40e52859dc86371..c12437283013b680ed326cee08cb09f9839749e9 100644 (file)
@@ -473,8 +473,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
   arelent *rel;
   bfd_reloc_code_real_type r_type;
 
-  rel = XNEW (arelent);
-  rel->sym_ptr_ptr = XNEW (asymbol *);
+  rel = notes_alloc (sizeof (arelent));
+  rel->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 9c8b15700d4854fc730dbcf6049748cb10c94109..1ff1175d02a6321b93b167f95a429bec5b3520d0 100644 (file)
@@ -7747,17 +7747,17 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
   static arelent *relocs[3];
   arelent *reloc;
 
-  relocs[0] = reloc = XNEW (arelent);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  relocs[0] = reloc;
   relocs[1] = NULL;
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   /* BFD_RELOC_PPC64_TLS_PCREL generates R_PPC64_TLS with an odd r_offset.  */
   if (fixp->fx_r_type == BFD_RELOC_PPC64_TLS_PCREL)
     reloc->address++;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
-  if (reloc->howto == (reloc_howto_type *) NULL)
+  if (reloc->howto == NULL)
     {
       as_bad_where (fixp->fx_file, fixp->fx_line,
                    _("reloc %d not supported by object file format"),
@@ -7768,10 +7768,10 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 
   if (fixp->fx_subsy != NULL)
     {
-      relocs[1] = reloc = XNEW (arelent);
+      reloc = notes_alloc (sizeof (arelent));
+      reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+      relocs[1] = reloc;
       relocs[2] = NULL;
-
-      reloc->sym_ptr_ptr = XNEW (asymbol *);
       *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
       reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
@@ -7781,15 +7781,10 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
       if (reloc->howto == (reloc_howto_type *) NULL)
         {
          as_bad_subtract (fixp);
-         free (relocs[1]->sym_ptr_ptr);
-         free (relocs[1]);
-         free (relocs[0]->sym_ptr_ptr);
-         free (relocs[0]);
          relocs[0] = NULL;
         }
     }
 
-
   return relocs;
 }
 
index ea49d55eee8db913d50e6d982b6c00065d270763..abf7870bdb012b13819148077ee9f1b6bbaa4b87 100644 (file)
@@ -1766,10 +1766,11 @@ pru_fix_adjustable (fixS *fixp)
 arelent *
 tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 {
-  arelent *reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
-  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
+  arelent *reloc;
 
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->addend = fixp->fx_offset;  /* fixp->fx_addnumber; */
 
index e7473082c2c17e2f624b8cd8b0d61584578a39c1..a915c8b4995bfa8eab47a42a1ed53b50585ba176 100644 (file)
@@ -5200,9 +5200,10 @@ md_estimate_size_before_relax (fragS *fragp, asection *segtype)
 arelent *
 tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 {
-  arelent *reloc = (arelent *) xmalloc (sizeof (arelent));
+  arelent *reloc;
 
-  reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->addend = fixp->fx_addnumber;
index 89f4bb99666156f4fb9d53c1532b9a66579dace6..bcdc87399d341352947b26ec1c568634a2bed567 100644 (file)
@@ -1257,11 +1257,11 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
       fixp->fx_subsy = NULL;
     }
 
-  reloc[0]               = XNEW (arelent);
-  reloc[0]->sym_ptr_ptr   = XNEW (asymbol *);
-  * reloc[0]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
-  reloc[0]->address       = fixp->fx_frag->fr_address + fixp->fx_where;
-  reloc[0]->addend        = fixp->fx_offset;
+  reloc[0] = notes_alloc (sizeof (arelent));
+  reloc[0]->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  *reloc[0]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
+  reloc[0]->address = fixp->fx_frag->fr_address + fixp->fx_where;
+  reloc[0]->addend = fixp->fx_offset;
 
   if (fixp->fx_r_type == BFD_RELOC_RL78_32_OP
       && fixp->fx_subsy)
@@ -1269,13 +1269,13 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
       fixp->fx_r_type = BFD_RELOC_RL78_DIFF;
     }
 
-#define OPX(REL,SYM,ADD)                                                       \
-  reloc[rp]               = XNEW (arelent);            \
-  reloc[rp]->sym_ptr_ptr   = XNEW (asymbol *);         \
-  reloc[rp]->howto         = bfd_reloc_type_lookup (stdoutput, REL);           \
-  reloc[rp]->addend        = ADD;                                              \
-  * reloc[rp]->sym_ptr_ptr = SYM;                                              \
-  reloc[rp]->address       = fixp->fx_frag->fr_address + fixp->fx_where;       \
+#define OPX(REL,SYM,ADD)                                               \
+  reloc[rp] = notes_alloc (sizeof (arelent));                          \
+  reloc[rp]->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));           \
+  reloc[rp]->howto = bfd_reloc_type_lookup (stdoutput, REL);           \
+  reloc[rp]->addend = ADD;                                             \
+  *reloc[rp]->sym_ptr_ptr = SYM;                                       \
+  reloc[rp]->address = fixp->fx_frag->fr_address + fixp->fx_where;     \
   reloc[++rp] = NULL
 #define OPSYM(SYM) OPX(BFD_RELOC_RL78_SYM, SYM, 0)
 
index 9927874c6786dec6e3d5f47756b2d78fdbc54661..7a426d281dfa4183a5cd5b66a3b526cffe9adce4 100644 (file)
@@ -2466,11 +2466,11 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
       fixp->fx_subsy = NULL;
     }
 
-  reloc[0]               = XNEW (arelent);
-  reloc[0]->sym_ptr_ptr   = XNEW (asymbol *);
-  * reloc[0]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
-  reloc[0]->address       = fixp->fx_frag->fr_address + fixp->fx_where;
-  reloc[0]->addend        = fixp->fx_offset;
+  reloc[0] = notes_alloc (sizeof (arelent));
+  reloc[0]->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  *reloc[0]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
+  reloc[0]->address = fixp->fx_frag->fr_address + fixp->fx_where;
+  reloc[0]->addend = fixp->fx_offset;
 
   if (fixp->fx_r_type == BFD_RELOC_RX_32_OP
       && fixp->fx_subsy)
@@ -2487,54 +2487,54 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
   switch (fixp->fx_r_type)
     {
     case BFD_RELOC_RX_DIFF:
-      reloc[0]->howto         = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
-
-      reloc[1]               = XNEW (arelent);
-      reloc[1]->sym_ptr_ptr   = XNEW (asymbol *);
-      * reloc[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
-      reloc[1]->address       = fixp->fx_frag->fr_address + fixp->fx_where;
-      reloc[1]->addend        = 0;
-      reloc[1]->howto         = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
-
-      reloc[2]               = XNEW (arelent);
-      reloc[2]->howto         = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
-      reloc[2]->addend        = 0;
-      reloc[2]->sym_ptr_ptr   = reloc[1]->sym_ptr_ptr;
-      reloc[2]->address       = fixp->fx_frag->fr_address + fixp->fx_where;
-
-      reloc[3]               = XNEW (arelent);
+      reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
+
+      reloc[1] = notes_alloc (sizeof (arelent));
+      reloc[1]->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+      *reloc[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
+      reloc[1]->address = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[1]->addend = 0;
+      reloc[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
+
+      reloc[2] = notes_alloc (sizeof (arelent));
+      reloc[2]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
+      reloc[2]->addend = 0;
+      reloc[2]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
+      reloc[2]->address = fixp->fx_frag->fr_address + fixp->fx_where;
+
+      reloc[3] = notes_alloc (sizeof (arelent));
       switch (fixp->fx_size)
        {
        case 1:
-         reloc[3]->howto   = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS8);
+         reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS8);
          break;
        case 2:
          if (!is_opcode && target_big_endian)
-           reloc[3]->howto   = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16_REV);
+           reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16_REV);
          else if (is_opcode)
-           reloc[3]->howto   = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16UL);
+           reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16UL);
          else
-           reloc[3]->howto   = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16);
+           reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16);
          break;
        case 4:
          if (!is_opcode && target_big_endian)
-           reloc[3]->howto   = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS32_REV);
+           reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS32_REV);
          else
-           reloc[3]->howto   = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS32);
+           reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS32);
          break;
        }
-      reloc[3]->addend      = 0;
+      reloc[3]->addend = 0;
       reloc[3]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
-      reloc[3]->address     = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[3]->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
       reloc[4] = NULL;
       break;
 
     case BFD_RELOC_RX_GPRELL:
-      reloc[0]->howto         = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
+      reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
 
-      reloc[1]               = XNEW (arelent);
-      reloc[1]->sym_ptr_ptr   = XNEW (asymbol *);
+      reloc[1] = notes_alloc (sizeof (arelent));
+      reloc[1]->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
       if (gp_symbol == NULL)
        {
          if (symbol_table_frozen)
@@ -2550,31 +2550,31 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
          else
            gp_symbol = symbol_get_bfdsym (symbol_find_or_make ("__gp"));
        }
-      * reloc[1]->sym_ptr_ptr = gp_symbol;
-      reloc[1]->address       = fixp->fx_frag->fr_address + fixp->fx_where;
-      reloc[1]->addend        = 0;
-      reloc[1]->howto         = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
-
-      reloc[2]             = XNEW (arelent);
-      reloc[2]->howto       = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
-      reloc[2]->addend      = 0;
+      *reloc[1]->sym_ptr_ptr = gp_symbol;
+      reloc[1]->address = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[1]->addend = 0;
+      reloc[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
+
+      reloc[2] = notes_alloc (sizeof (arelent));
+      reloc[2]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
+      reloc[2]->addend = 0;
       reloc[2]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
-      reloc[2]->address     = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[2]->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
-      reloc[3]             = XNEW (arelent);
-      reloc[3]->howto       = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16UL);
-      reloc[3]->addend      = 0;
+      reloc[3] = notes_alloc (sizeof (arelent));
+      reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16UL);
+      reloc[3]->addend = 0;
       reloc[3]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
-      reloc[3]->address     = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[3]->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
       reloc[4] = NULL;
       break;
 
     case BFD_RELOC_RX_GPRELW:
-      reloc[0]->howto         = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
+      reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
 
-      reloc[1]               = XNEW (arelent);
-      reloc[1]->sym_ptr_ptr   = XNEW (asymbol *);
+      reloc[1] = notes_alloc (sizeof (arelent));
+      reloc[1]->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
       if (gp_symbol == NULL)
        {
          if (symbol_table_frozen)
@@ -2590,31 +2590,31 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
          else
            gp_symbol = symbol_get_bfdsym (symbol_find_or_make ("__gp"));
        }
-      * reloc[1]->sym_ptr_ptr = gp_symbol;
-      reloc[1]->address       = fixp->fx_frag->fr_address + fixp->fx_where;
-      reloc[1]->addend        = 0;
-      reloc[1]->howto         = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
-
-      reloc[2]             = XNEW (arelent);
-      reloc[2]->howto       = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
-      reloc[2]->addend      = 0;
+      *reloc[1]->sym_ptr_ptr = gp_symbol;
+      reloc[1]->address = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[1]->addend = 0;
+      reloc[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
+
+      reloc[2] = notes_alloc (sizeof (arelent));
+      reloc[2]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
+      reloc[2]->addend = 0;
       reloc[2]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
-      reloc[2]->address     = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[2]->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
-      reloc[3]             = XNEW (arelent);
-      reloc[3]->howto       = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16UW);
-      reloc[3]->addend      = 0;
+      reloc[3] = notes_alloc (sizeof (arelent));
+      reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16UW);
+      reloc[3]->addend = 0;
       reloc[3]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
-      reloc[3]->address     = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[3]->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
       reloc[4] = NULL;
       break;
 
     case BFD_RELOC_RX_GPRELB:
-      reloc[0]->howto         = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
+      reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
 
-      reloc[1]               = XNEW (arelent);
-      reloc[1]->sym_ptr_ptr   = XNEW (asymbol *);
+      reloc[1] = notes_alloc (sizeof (arelent));
+      reloc[1]->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
       if (gp_symbol == NULL)
        {
          if (symbol_table_frozen)
@@ -2630,40 +2630,40 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
          else
            gp_symbol = symbol_get_bfdsym (symbol_find_or_make ("__gp"));
        }
-      * reloc[1]->sym_ptr_ptr = gp_symbol;
-      reloc[1]->address       = fixp->fx_frag->fr_address + fixp->fx_where;
-      reloc[1]->addend        = 0;
-      reloc[1]->howto         = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
-
-      reloc[2]             = XNEW (arelent);
-      reloc[2]->howto       = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
-      reloc[2]->addend      = 0;
+      *reloc[1]->sym_ptr_ptr = gp_symbol;
+      reloc[1]->address = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[1]->addend = 0;
+      reloc[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
+
+      reloc[2] = notes_alloc (sizeof (arelent));
+      reloc[2]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
+      reloc[2]->addend = 0;
       reloc[2]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
-      reloc[2]->address     = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[2]->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
-      reloc[3]             = XNEW (arelent);
-      reloc[3]->howto       = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16U);
-      reloc[3]->addend      = 0;
+      reloc[3] = notes_alloc (sizeof (arelent));
+      reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16U);
+      reloc[3]->addend = 0;
       reloc[3]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
-      reloc[3]->address     = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[3]->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
       reloc[4] = NULL;
       break;
 
     case BFD_RELOC_RX_NEG32:
-      reloc[0]->howto         = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
+      reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
 
-      reloc[1]             = XNEW (arelent);
-      reloc[1]->howto       = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_NEG);
-      reloc[1]->addend      = 0;
+      reloc[1] = notes_alloc (sizeof (arelent));
+      reloc[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_NEG);
+      reloc[1]->addend = 0;
       reloc[1]->sym_ptr_ptr = reloc[0]->sym_ptr_ptr;
-      reloc[1]->address     = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[1]->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
-      reloc[2]             = XNEW (arelent);
-      reloc[2]->howto       = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS32);
-      reloc[2]->addend      = 0;
+      reloc[2] = notes_alloc (sizeof (arelent));
+      reloc[2]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS32);
+      reloc[2]->addend = 0;
       reloc[2]->sym_ptr_ptr = reloc[0]->sym_ptr_ptr;
-      reloc[2]->address     = fixp->fx_frag->fr_address + fixp->fx_where;
+      reloc[2]->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
       reloc[3] = NULL;
       break;
index 468410e10ae789941a73513fc09bbff25f7f52f2..3e07ea7c7a789f81a49d922abc04b8af93fb3c53 100644 (file)
@@ -3884,8 +3884,10 @@ md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED, asection *segment
 arelent *
 tc_gen_reloc (asection *section, fixS *fixp)
 {
-  arelent *reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  arelent *reloc;
+
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
index 9b1c9947bd18ae6966ac7d3e2ac54a7f64da907c..e7a7e7e04f1f32e5ef2d0eec335f75f1e60a7446 100644 (file)
@@ -2824,8 +2824,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
        code = BFD_RELOC_390_GOTPCDBL;
     }
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
index c47308af3ced59591d73d67418a7ab0af773fcc2..62bd9ab4a1fb6cf2fc81ed3df46001f924619648 100644 (file)
@@ -7311,10 +7311,10 @@ s3_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
   bfd_reloc_code_real_type code;
   const char *type;
 
-  reloc = retval[0] = XNEW (arelent);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  retval[0] = reloc;
   retval[1] = NULL;
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->addend = fixp->fx_offset;
@@ -7342,9 +7342,9 @@ s3_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
       newval |= (((off >> 14) & 0x3) << 16);
       s3_md_number_to_chars (buf, newval, s3_INSN_SIZE);
 
-      retval[1] = XNEW (arelent);
+      retval[1] = notes_alloc (sizeof (arelent));
+      retval[1]->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
       retval[2] = NULL;
-      retval[1]->sym_ptr_ptr = XNEW (asymbol *);
       *retval[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
       retval[1]->address = (reloc->address + s3_RELAX_RELOC2 (fixp->fx_frag->fr_subtype));
 
index 38082a35e0d6089efb72cc1294bf3ccaa28dc343..07177954e5b5aa48d759e739b55883bf505fb499 100644 (file)
@@ -6813,10 +6813,10 @@ s7_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
   bfd_reloc_code_real_type code;
   const char *type;
 
-  reloc = retval[0] = XNEW (arelent);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  retval[0] = reloc;
   retval[1] = NULL;
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->addend = fixp->fx_offset;
@@ -6844,9 +6844,9 @@ s7_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
       newval |= (((off >> 14) & 0x3) << 16);
       s7_number_to_chars (buf, newval, s7_INSN_SIZE);
 
-      retval[1] = XNEW (arelent);
+      retval[1] = notes_alloc (sizeof (arelent));
+      retval[2]->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
       retval[2] = NULL;
-      retval[1]->sym_ptr_ptr = XNEW (asymbol *);
       *retval[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
       retval[1]->address = (reloc->address + s7_RELAX_RELOC2 (fixp->fx_frag->fr_subtype));
 
index e974a38d1a553729531a366d31465f22978d03ed..fe720e7eae9631a53a18736cdfd15d0e3320174f 100644 (file)
@@ -3838,8 +3838,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
   arelent *rel;
   bfd_reloc_code_real_type r_type;
 
-  rel = XNEW (arelent);
-  rel->sym_ptr_ptr = XNEW (asymbol *);
+  rel = notes_alloc (sizeof (arelent));
+  rel->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 484746b9528d743bc8290416a995022c33b4e888..c6f8026e5c1d4ace678536623bc169973450d407 100644 (file)
@@ -3834,10 +3834,10 @@ tc_gen_reloc (asection *section, fixS *fixp)
   arelent *reloc;
   bfd_reloc_code_real_type code;
 
-  relocs[0] = reloc = XNEW (arelent);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+  relocs[0] = reloc;
   relocs[1] = NULL;
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
@@ -4014,7 +4014,6 @@ tc_gen_reloc (asection *section, fixS *fixp)
       as_bad_where (fixp->fx_file, fixp->fx_line,
                    _("internal error: can't export reloc type %d (`%s')"),
                    fixp->fx_r_type, bfd_get_reloc_code_name (code));
-      xfree (reloc);
       relocs[0] = NULL;
       return relocs;
     }
@@ -4040,10 +4039,10 @@ tc_gen_reloc (asection *section, fixS *fixp)
      on the same location.  */
   if (code == BFD_RELOC_SPARC_OLO10)
     {
-      relocs[1] = reloc = XNEW (arelent);
+      reloc = notes_alloc (sizeof (arelent));
+      reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
+      relocs[1] = reloc;
       relocs[2] = NULL;
-
-      reloc->sym_ptr_ptr = XNEW (asymbol *);
       *reloc->sym_ptr_ptr
        = symbol_get_bfdsym (section_symbol (absolute_section));
       reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
index 37484651357a6ddf3f0296256e25cba759639565..8dba224a9529abbf313db6450d64c4c2d49baa2e 100644 (file)
@@ -867,8 +867,8 @@ arelent *
 tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
@@ -877,8 +877,6 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
       as_bad_where (fixp->fx_file, fixp->fx_line,
                    _("reloc %d not supported by object file format"),
                    (int) fixp->fx_r_type);
-      free (reloc->sym_ptr_ptr);
-      free (reloc);
       return NULL;
     }
   reloc->addend = fixp->fx_addnumber;
index 8e3b1a0ad746c71565e8f6ae92be97f4b257d1af..21efe8a6d50d6a99d081f8bde22a6ab19ca1e321 100644 (file)
@@ -1367,9 +1367,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
 #undef MAP
 #undef F
 
-  rel = XNEW (arelent);
-  gas_assert (rel != 0);
-  rel->sym_ptr_ptr = XNEW (asymbol *);
+  rel = notes_alloc (sizeof (arelent));
+  rel->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *rel->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   rel->address = fixP->fx_frag->fr_address + fixP->fx_where;
   rel->addend = 0;
index 93cbd660b001851179928eb62dc1844b22220e87..c8afd1638a1f9470b5239b01ad595927502c116c 100644 (file)
@@ -2998,9 +2998,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixP)
 {
   arelent *reloc;
 
-  reloc = XNEW (arelent);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
   reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
   reloc->address /= OCTETS_PER_BYTE;
index b0d98f1ab4a00d35df2e22dd47ba67fa9358f634..ee95eb222a8645c6b85df05b5492c7dbf79d6aec 100644 (file)
@@ -5095,8 +5095,8 @@ tc_gen_reloc (asection *section, fixS *fixP)
   bfd_reloc_code_real_type code = fixP->fx_r_type;
   asymbol *sym = symbol_get_bfdsym (fixP->fx_addsy);
 
-  rel = XNEW (arelent);
-  rel->sym_ptr_ptr = XNEW (asymbol *);
+  rel = notes_alloc (sizeof (arelent));
+  rel->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *rel->sym_ptr_ptr = sym;
   /* We assume that all rel->address are host byte offsets.  */
   rel->address = fixP->fx_frag->fr_address + fixP->fx_where;
index c5256bf9f0d76a728f932b7cbc9a31ae7bef65bb..b256ddf34dfb6cc850c470c6fed04d80c0343b56 100644 (file)
@@ -4500,8 +4500,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
   asymbol *symbol;
   bfd_reloc_code_real_type r_type;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   symbol = symbol_get_bfdsym (fixp->fx_addsy);
   *reloc->sym_ptr_ptr = symbol;
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
index 2f468a6181b5f619bd25781eb9c1c350b49bdfd2..b63567ba0f7845ca87c426fcbe8ec2168d2efa29 100644 (file)
@@ -1729,8 +1729,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 43371d8d6fde4cc1df008eba7ed9fbade4ccd407..38666adc028ca00be955a0d4adbe2bd8c35f4eed 100644 (file)
@@ -1506,8 +1506,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 688ec1e98938165e4608fdbee55f1f9321ab56c0..d907211ce185a4eb36f4d7981c2ecac47e8d8541 100644 (file)
@@ -3329,10 +3329,10 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
-  reloc                      = XNEW (arelent);
-  reloc->sym_ptr_ptr  = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
-  reloc->address      = fixp->fx_frag->fr_address + fixp->fx_where;
+  reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
   if (   fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY
       || fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT
@@ -3359,9 +3359,6 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
                    /* xgettext:c-format  */
                    _("reloc %d not supported by object file format"),
                    (int) fixp->fx_r_type);
-
-      xfree (reloc);
-
       return NULL;
     }
 
index e67dac40a7002fd35ed59940ed6edbd2510f673c..d6d5569105d0dc321c4c12a0ddfbdb43e48b5e08 100644 (file)
@@ -2345,8 +2345,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 #undef F
 #undef MAP
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 #ifndef OBJ_ELF
index ae3dbdae03e7e09201efda74043da85cf248705f..975a0c848d4eb9792a4b42a9b56adc50396907c3 100644 (file)
@@ -111,9 +111,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
   arelent *reloc;
   bfd_reloc_code_real_type code;
 
-  reloc = XNEW (arelent);
-
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 5a6a264d0b204750e6d87cb5bee330507de06a86..e7db729c5f36206fe48247abdf47b6447e7d15d0 100644 (file)
@@ -797,8 +797,8 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
 {
   arelent *reloc;
 
-  reloc = (arelent *) xmalloc (sizeof (*reloc));
-  reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index eaf8202c34889eead27d526fb518b9875e254ef9..1c98f2dffb6f659513206963fff9e39294945a06 100644 (file)
@@ -614,8 +614,8 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
 {
   arelent * reloc;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
index 11032c9b5f578668683b17580f89545c969e77f8..25599f8eb3c31cebcd68cb1fc8cd3119219cec59 100644 (file)
@@ -6158,8 +6158,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
 
@@ -6175,8 +6175,6 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
       as_bad_where (fixp->fx_file, fixp->fx_line,
                    _("cannot represent `%s' relocation in object file"),
                    bfd_get_reloc_code_name (fixp->fx_r_type));
-      free (reloc->sym_ptr_ptr);
-      free (reloc);
       return NULL;
     }
 
index 767faa4bd952229c069f8493fa6d41d421901714..3805e32b15ad44fb40d055313eb9d280fdeed38d 100644 (file)
@@ -3859,12 +3859,12 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED , fixS *fixp)
       return NULL;
     }
 
-  reloc               = XNEW (arelent);
-  reloc->sym_ptr_ptr  = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
-  reloc->address      = fixp->fx_frag->fr_address + fixp->fx_where;
-  reloc->addend       = fixp->fx_offset;
-  reloc->howto        = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
+  reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
+  reloc->addend = fixp->fx_offset;
+  reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
   if (reloc->howto == NULL)
     {
       as_bad_where (fixp->fx_file, fixp->fx_line,
index 8f2d62c067ffc78d7bb2c474b284c25b43a59e67..75fbabb09f5c30a50f62fb4aceff3c9cae30b2ca 100644 (file)
@@ -1375,8 +1375,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
 {
   arelent *reloc;
 
-  reloc = XNEW (arelent);
-  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  reloc = notes_alloc (sizeof (arelent));
+  reloc->sym_ptr_ptr = notes_alloc (sizeof (asymbol *));
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   reloc->addend = fixp->fx_offset;
index cde6041536aa8af64a836af78accd8024b149a5e..d96d8c20dbd232bd19c56caa9159d57641483d09 100644 (file)
@@ -1294,7 +1294,7 @@ write_relocs (bfd *abfd ATTRIBUTE_UNUSED, asection *sec,
        rp = &r->next;
     }
 
-  relocs = XCNEWVEC (arelent *, n);
+  relocs = notes_alloc (n * sizeof (arelent *));
 
   n = 0;
   r = my_reloc_list;