aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2025-01-01 22:49:04 +1030
committerAlan Modra <amodra@gmail.com>2025-01-01 22:49:04 +1030
commit3fb6f5457e5b53fdb73a98a24b3764e821e8ccc5 (patch)
treef8fa539f09b64ca324a933dd7d0119e19b86bd59
parent443101612dddb5af7332dde5da1845c4321b2e39 (diff)
downloadgdb-3fb6f5457e5b53fdb73a98a24b3764e821e8ccc5.zip
gdb-3fb6f5457e5b53fdb73a98a24b3764e821e8ccc5.tar.gz
gdb-3fb6f5457e5b53fdb73a98a24b3764e821e8ccc5.tar.bz2
gas tc_gen_reloc memory leaks
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.
-rw-r--r--gas/cgen.c9
-rw-r--r--gas/config/tc-aarch64.c5
-rw-r--r--gas/config/tc-alpha.c6
-rw-r--r--gas/config/tc-arc.c4
-rw-r--r--gas/config/tc-arm.c5
-rw-r--r--gas/config/tc-avr.c5
-rw-r--r--gas/config/tc-bfin.c9
-rw-r--r--gas/config/tc-bpf.c9
-rw-r--r--gas/config/tc-cr16.c6
-rw-r--r--gas/config/tc-cris.c5
-rw-r--r--gas/config/tc-crx.c6
-rw-r--r--gas/config/tc-csky.c6
-rw-r--r--gas/config/tc-d10v.c4
-rw-r--r--gas/config/tc-d30v.c4
-rw-r--r--gas/config/tc-dlx.c8
-rw-r--r--gas/config/tc-ft32.c5
-rw-r--r--gas/config/tc-h8300.c4
-rw-r--r--gas/config/tc-hppa.c32
-rw-r--r--gas/config/tc-i386.c4
-rw-r--r--gas/config/tc-ia64.c5
-rw-r--r--gas/config/tc-kvx.c5
-rw-r--r--gas/config/tc-loongarch.c5
-rw-r--r--gas/config/tc-m32c.c7
-rw-r--r--gas/config/tc-m32r.c7
-rw-r--r--gas/config/tc-m68hc11.c4
-rw-r--r--gas/config/tc-m68k.c4
-rw-r--r--gas/config/tc-mcore.c4
-rw-r--r--gas/config/tc-metag.c9
-rw-r--r--gas/config/tc-microblaze.c4
-rw-r--r--gas/config/tc-mips.c7
-rw-r--r--gas/config/tc-mmix.c5
-rw-r--r--gas/config/tc-mn10200.c7
-rw-r--r--gas/config/tc-mn10300.c16
-rw-r--r--gas/config/tc-moxie.c4
-rw-r--r--gas/config/tc-msp430.c27
-rw-r--r--gas/config/tc-nds32.c5
-rw-r--r--gas/config/tc-ns32k.c4
-rw-r--r--gas/config/tc-or1k.c5
-rw-r--r--gas/config/tc-pdp11.c5
-rw-r--r--gas/config/tc-pj.c4
-rw-r--r--gas/config/tc-ppc.c19
-rw-r--r--gas/config/tc-pru.c7
-rw-r--r--gas/config/tc-riscv.c5
-rw-r--r--gas/config/tc-rl78.c24
-rw-r--r--gas/config/tc-rx.c172
-rw-r--r--gas/config/tc-s12z.c6
-rw-r--r--gas/config/tc-s390.c4
-rw-r--r--gas/config/tc-score.c10
-rw-r--r--gas/config/tc-score7.c10
-rw-r--r--gas/config/tc-sh.c4
-rw-r--r--gas/config/tc-sparc.c13
-rw-r--r--gas/config/tc-spu.c6
-rw-r--r--gas/config/tc-tic30.c5
-rw-r--r--gas/config/tc-tic4x.c5
-rw-r--r--gas/config/tc-tic54x.c4
-rw-r--r--gas/config/tc-tic6x.c4
-rw-r--r--gas/config/tc-tilegx.c4
-rw-r--r--gas/config/tc-tilepro.c4
-rw-r--r--gas/config/tc-v850.c9
-rw-r--r--gas/config/tc-vax.c4
-rw-r--r--gas/config/tc-visium.c5
-rw-r--r--gas/config/tc-wasm32.c4
-rw-r--r--gas/config/tc-xgate.c4
-rw-r--r--gas/config/tc-xtensa.c6
-rw-r--r--gas/config/tc-z80.c10
-rw-r--r--gas/config/tc-z8k.c4
-rw-r--r--gas/write.c2
67 files changed, 288 insertions, 345 deletions
diff --git a/gas/cgen.c b/gas/cgen.c
index bdadf32..030c2f0 100644
--- a/gas/cgen.c
+++ b/gas/cgen.c
@@ -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)
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index bf594e7..3046d3d 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -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;
diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c
index 8d27f75..4f5897b 100644
--- a/gas/config/tc-alpha.c
+++ b/gas/config/tc-alpha.c
@@ -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;
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index d62e0a1..8b69ca6 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -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;
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index f977117..c2173b7 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -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;
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index 61398e6..5976e58 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -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;
diff --git a/gas/config/tc-bfin.c b/gas/config/tc-bfin.c
index 44c3661..d91ca5f 100644
--- a/gas/config/tc-bfin.c
+++ b/gas/config/tc-bfin.c
@@ -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;
}
diff --git a/gas/config/tc-bpf.c b/gas/config/tc-bpf.c
index a292335..91ef7b3 100644
--- a/gas/config/tc-bpf.c
+++ b/gas/config/tc-bpf.c
@@ -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)
diff --git a/gas/config/tc-cr16.c b/gas/config/tc-cr16.c
index 4f2ef2c..4bc6a14 100644
--- a/gas/config/tc-cr16.c
+++ b/gas/config/tc-cr16.c
@@ -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;
}
}
diff --git a/gas/config/tc-cris.c b/gas/config/tc-cris.c
index 302e7d0..2c00284 100644
--- a/gas/config/tc-cris.c
+++ b/gas/config/tc-cris.c
@@ -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;
diff --git a/gas/config/tc-crx.c b/gas/config/tc-crx.c
index 0561a07..7a8db73 100644
--- a/gas/config/tc-crx.c
+++ b/gas/config/tc-crx.c
@@ -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;
}
}
diff --git a/gas/config/tc-csky.c b/gas/config/tc-csky.c
index 90bc411..df98c88 100644
--- a/gas/config/tc-csky.c
+++ b/gas/config/tc-csky.c
@@ -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;
diff --git a/gas/config/tc-d10v.c b/gas/config/tc-d10v.c
index eeaf8bc..d6c2a47 100644
--- a/gas/config/tc-d10v.c
+++ b/gas/config/tc-d10v.c
@@ -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);
diff --git a/gas/config/tc-d30v.c b/gas/config/tc-d30v.c
index 1971e92..d465b2a 100644
--- a/gas/config/tc-d30v.c
+++ b/gas/config/tc-d30v.c
@@ -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);
diff --git a/gas/config/tc-dlx.c b/gas/config/tc-dlx.c
index d77a36b..a392271 100644
--- a/gas/config/tc-dlx.c
+++ b/gas/config/tc-dlx.c
@@ -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)
diff --git a/gas/config/tc-ft32.c b/gas/config/tc-ft32.c
index 8468df1..4c177e0 100644
--- a/gas/config/tc-ft32.c
+++ b/gas/config/tc-ft32.c
@@ -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;
diff --git a/gas/config/tc-h8300.c b/gas/config/tc-h8300.c
index f1dd69e..f8e5406 100644
--- a/gas/config/tc-h8300.c
+++ b/gas/config/tc-h8300.c
@@ -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;
diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c
index 9124e41..80a142f 100644
--- a/gas/config/tc-hppa.c
+++ b/gas/config/tc-hppa.c
@@ -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;
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index cd57972..09c0d21 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -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;
diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c
index 5b714cc..b508232 100644
--- a/gas/config/tc-ia64.c
+++ b/gas/config/tc-ia64.c
@@ -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;
diff --git a/gas/config/tc-kvx.c b/gas/config/tc-kvx.c
index 3f641db..0288745 100644
--- a/gas/config/tc-kvx.c
+++ b/gas/config/tc-kvx.c
@@ -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;
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index 3ddb7bc..b0bcdeb 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -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;
diff --git a/gas/config/tc-m32c.c b/gas/config/tc-m32c.c
index c46162b..b5887b1 100644
--- a/gas/config/tc-m32c.c
+++ b/gas/config/tc-m32c.c
@@ -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);
diff --git a/gas/config/tc-m32r.c b/gas/config/tc-m32r.c
index 4baa5df..aa0acea 100644
--- a/gas/config/tc-m32r.c
+++ b/gas/config/tc-m32r.c
@@ -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')"),
diff --git a/gas/config/tc-m68hc11.c b/gas/config/tc-m68hc11.c
index cc6e86a..8c8035c 100644
--- a/gas/config/tc-m68hc11.c
+++ b/gas/config/tc-m68hc11.c
@@ -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)
diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c
index 4b24b16..1f8f9a8 100644
--- a/gas/config/tc-m68k.c
+++ b/gas/config/tc-m68k.c
@@ -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)
diff --git a/gas/config/tc-mcore.c b/gas/config/tc-mcore.c
index b02f96e..1264577 100644
--- a/gas/config/tc-mcore.c
+++ b/gas/config/tc-mcore.c
@@ -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! */
diff --git a/gas/config/tc-metag.c b/gas/config/tc-metag.c
index 4d4c212..bf084f7 100644
--- a/gas/config/tc-metag.c
+++ b/gas/config/tc-metag.c
@@ -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;
}
diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index 97ffe23..5774eea 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -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);
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 7024744..3c33834 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -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;
diff --git a/gas/config/tc-mmix.c b/gas/config/tc-mmix.c
index 50f17eb..a43774d 100644
--- a/gas/config/tc-mmix.c
+++ b/gas/config/tc-mmix.c
@@ -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;
diff --git a/gas/config/tc-mn10200.c b/gas/config/tc-mn10200.c
index 8ce261b..d630929 100644
--- a/gas/config/tc-mn10200.c
+++ b/gas/config/tc-mn10200.c
@@ -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;
}
diff --git a/gas/config/tc-mn10300.c b/gas/config/tc-mn10300.c
index e6e0593..08f6a1c 100644
--- a/gas/config/tc-mn10300.c
+++ b/gas/config/tc-mn10300.c
@@ -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;
}
diff --git a/gas/config/tc-moxie.c b/gas/config/tc-moxie.c
index e4ab416..28bed87 100644
--- a/gas/config/tc-moxie.c
+++ b/gas/config/tc-moxie.c
@@ -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;
diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c
index 69159b2..f5c864e 100644
--- a/gas/config/tc-msp430.c
+++ b/gas/config/tc-msp430.c
@@ -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;
diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c
index 41a0739..3de27fd 100644
--- a/gas/config/tc-nds32.c
+++ b/gas/config/tc-nds32.c
@@ -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;
diff --git a/gas/config/tc-ns32k.c b/gas/config/tc-ns32k.c
index 8a417ef..ba30e24 100644
--- a/gas/config/tc-ns32k.c
+++ b/gas/config/tc-ns32k.c
@@ -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)
diff --git a/gas/config/tc-or1k.c b/gas/config/tc-or1k.c
index 1ff5a60..5b3e013 100644
--- a/gas/config/tc-or1k.c
+++ b/gas/config/tc-or1k.c
@@ -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;
diff --git a/gas/config/tc-pdp11.c b/gas/config/tc-pdp11.c
index 1168b35..2ae6710 100644
--- a/gas/config/tc-pdp11.c
+++ b/gas/config/tc-pdp11.c
@@ -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;
diff --git a/gas/config/tc-pj.c b/gas/config/tc-pj.c
index 7a8164e..c124372 100644
--- a/gas/config/tc-pj.c
+++ b/gas/config/tc-pj.c
@@ -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;
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 9c8b157..1ff1175 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -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;
}
diff --git a/gas/config/tc-pru.c b/gas/config/tc-pru.c
index ea49d55..abf7870 100644
--- a/gas/config/tc-pru.c
+++ b/gas/config/tc-pru.c
@@ -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; */
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index e747308..a915c8b 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -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;
diff --git a/gas/config/tc-rl78.c b/gas/config/tc-rl78.c
index 89f4bb9..bcdc873 100644
--- a/gas/config/tc-rl78.c
+++ b/gas/config/tc-rl78.c
@@ -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)
diff --git a/gas/config/tc-rx.c b/gas/config/tc-rx.c
index 9927874..7a426d2 100644
--- a/gas/config/tc-rx.c
+++ b/gas/config/tc-rx.c
@@ -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;
diff --git a/gas/config/tc-s12z.c b/gas/config/tc-s12z.c
index 468410e..3e07ea7 100644
--- a/gas/config/tc-s12z.c
+++ b/gas/config/tc-s12z.c
@@ -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);
diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c
index 9b1c994..e7a7e7e 100644
--- a/gas/config/tc-s390.c
+++ b/gas/config/tc-s390.c
@@ -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);
diff --git a/gas/config/tc-score.c b/gas/config/tc-score.c
index c47308a..62bd9ab 100644
--- a/gas/config/tc-score.c
+++ b/gas/config/tc-score.c
@@ -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));
diff --git a/gas/config/tc-score7.c b/gas/config/tc-score7.c
index 38082a3..0717795 100644
--- a/gas/config/tc-score7.c
+++ b/gas/config/tc-score7.c
@@ -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));
diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c
index e974a38..fe720e7 100644
--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -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;
diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c
index 484746b..c6f8026 100644
--- a/gas/config/tc-sparc.c
+++ b/gas/config/tc-sparc.c
@@ -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;
diff --git a/gas/config/tc-spu.c b/gas/config/tc-spu.c
index 3748465..8dba224 100644
--- a/gas/config/tc-spu.c
+++ b/gas/config/tc-spu.c
@@ -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;
diff --git a/gas/config/tc-tic30.c b/gas/config/tc-tic30.c
index 8e3b1a0..21efe8a 100644
--- a/gas/config/tc-tic30.c
+++ b/gas/config/tc-tic30.c
@@ -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;
diff --git a/gas/config/tc-tic4x.c b/gas/config/tc-tic4x.c
index 93cbd66..c8afd16 100644
--- a/gas/config/tc-tic4x.c
+++ b/gas/config/tc-tic4x.c
@@ -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;
diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c
index b0d98f1..ee95eb2 100644
--- a/gas/config/tc-tic54x.c
+++ b/gas/config/tc-tic54x.c
@@ -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;
diff --git a/gas/config/tc-tic6x.c b/gas/config/tc-tic6x.c
index c5256bf..b256ddf 100644
--- a/gas/config/tc-tic6x.c
+++ b/gas/config/tc-tic6x.c
@@ -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;
diff --git a/gas/config/tc-tilegx.c b/gas/config/tc-tilegx.c
index 2f468a6..b63567b 100644
--- a/gas/config/tc-tilegx.c
+++ b/gas/config/tc-tilegx.c
@@ -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;
diff --git a/gas/config/tc-tilepro.c b/gas/config/tc-tilepro.c
index 43371d8..38666ad 100644
--- a/gas/config/tc-tilepro.c
+++ b/gas/config/tc-tilepro.c
@@ -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;
diff --git a/gas/config/tc-v850.c b/gas/config/tc-v850.c
index 688ec1e..d907211 100644
--- a/gas/config/tc-v850.c
+++ b/gas/config/tc-v850.c
@@ -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;
}
diff --git a/gas/config/tc-vax.c b/gas/config/tc-vax.c
index e67dac4..d6d5569 100644
--- a/gas/config/tc-vax.c
+++ b/gas/config/tc-vax.c
@@ -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
diff --git a/gas/config/tc-visium.c b/gas/config/tc-visium.c
index ae3dbda..975a0c8 100644
--- a/gas/config/tc-visium.c
+++ b/gas/config/tc-visium.c
@@ -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;
diff --git a/gas/config/tc-wasm32.c b/gas/config/tc-wasm32.c
index 5a6a264..e7db729 100644
--- a/gas/config/tc-wasm32.c
+++ b/gas/config/tc-wasm32.c
@@ -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;
diff --git a/gas/config/tc-xgate.c b/gas/config/tc-xgate.c
index eaf8202..1c98f2d 100644
--- a/gas/config/tc-xgate.c
+++ b/gas/config/tc-xgate.c
@@ -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;
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 11032c9..25599f8 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -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;
}
diff --git a/gas/config/tc-z80.c b/gas/config/tc-z80.c
index 767faa4..3805e32 100644
--- a/gas/config/tc-z80.c
+++ b/gas/config/tc-z80.c
@@ -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,
diff --git a/gas/config/tc-z8k.c b/gas/config/tc-z8k.c
index 8f2d62c..75fbabb0 100644
--- a/gas/config/tc-z8k.c
+++ b/gas/config/tc-z8k.c
@@ -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;
diff --git a/gas/write.c b/gas/write.c
index cde6041..d96d8c2 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -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;