]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas md_apply_fix bad casts
authorAlan Modra <amodra@gmail.com>
Mon, 9 Jun 2025 05:30:30 +0000 (15:00 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 10 Jun 2025 22:15:18 +0000 (07:45 +0930)
ns32k and z8k cast a valueT pointer to a long pointer when loading
md_apply_fix's value.  That's quite wrong if the types have different
sizes, as they may eg. on a 32-bit host with 64-bit bfd support.
sparc also loads the value via a cast pointer, but at least in that
case the cast is to the same size pointer.  None of these casts are
needed.  Get rid of them.

gas/config/tc-ns32k.c
gas/config/tc-sparc.c
gas/config/tc-z8k.c

index ad2c1f4d09c0e7c8194b5e02108837c071c98eb3..13907f26ad367d3f31e6554ca25fa200de86c3ca 100644 (file)
@@ -1966,7 +1966,7 @@ md_fix_pcrel_adjust (fixS *fixP)
 void
 md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
 {
-  long val = * (long *) valP;
+  long val = *valP;
   char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
 
   if (fix_bit_fixP (fixP))
index 358042cb36ae7749ab21db53129ca633d41da209..6db848181e16e8d117ebffbbb5896e98b389c333 100644 (file)
@@ -3460,7 +3460,7 @@ void
 md_apply_fix (fixS *fixP, valueT *valP, segT segment ATTRIBUTE_UNUSED)
 {
   char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
-  offsetT val = * (offsetT *) valP;
+  offsetT val = *valP;
   long insn;
 
   gas_assert (fixP->fx_r_type < BFD_RELOC_UNUSED);
index aa8fc5f92aee2faf902df4fdcab9500f39a4a1de..9947fe1e1fc33218ca47959882bbd265e9dd966b 100644 (file)
@@ -1407,7 +1407,7 @@ md_section_align (segT seg, valueT size)
 void
 md_apply_fix (fixS *fixP, valueT *valP, segT segment ATTRIBUTE_UNUSED)
 {
-  long val = * (long *) valP;
+  offsetT val = *valP;
   char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
 
   switch (fixP->fx_r_type)