]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: Update fr_literal access in frag for GCC 10
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 25 May 2020 11:50:56 +0000 (04:50 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 25 May 2020 11:51:17 +0000 (04:51 -0700)
When access fr_literal in

struct frag {
  ...
  /* Data begins here.  */
  char fr_literal[1];
};

with

char *buf = fragp->fr_fix + fragp->fr_literal;

GCC 10 gave

gas/config/tc-csky.c: In function ‘md_convert_frag’:
gas/config/tc-csky.c:4507:9: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
 4507 |  buf[1] = BYTE_1 (CSKYV1_INST_SUBI | (7 << 4));
      |         ^

Change

  char *buf = fragp->fr_fix + fragp->fr_literal;

to

  char *buf = fragp->fr_fix + &fragp->fr_literal[0];

to silence GCC 10 warning.

* config/tc-csky.c (md_convert_frag): Replace fragp->fr_literal
with &fragp->fr_literal[0].
* config/tc-microblaze.c (md_apply_fix): Likewise.
* config/tc-sh.c (md_convert_frag): Likewise.

gas/ChangeLog
gas/config/tc-csky.c
gas/config/tc-microblaze.c
gas/config/tc-sh.c

index e3da87381eae5dfea641d783ab69b02d5715f9a6..1b0ec36dec2117fb3d187aef2593ee44ecd1845b 100644 (file)
@@ -1,3 +1,10 @@
+2020-05-25  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * config/tc-csky.c (md_convert_frag): Replace fragp->fr_literal
+       with &fragp->fr_literal[0].
+       * config/tc-microblaze.c (md_apply_fix): Likewise.
+       * config/tc-sh.c (md_convert_frag): Likewise.
+
 2020-05-24  Jim Wilson  <jimw@sifive.com>
 
        PR 26025
index 83fca2af73db63f4b81b82590f34164dda2f9465..be54afbd679cc7e8ab207de47268faf14f3f3ed5 100644 (file)
@@ -4196,7 +4196,7 @@ void
 md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec,  fragS *fragp)
 {
   offsetT disp;
-  char *buf = fragp->fr_fix + fragp->fr_literal;
+  char *buf = fragp->fr_fix + &fragp->fr_literal[0];
 
   gas_assert (fragp->fr_symbol);
   if (IS_EXTERNAL_SYM (fragp->fr_symbol, asec))
index 24ea35824473c5b059ada7fb8190ca66a12c0adf..ae5d36dc9c3585a95195a8cdfbd5aa354100d87f 100644 (file)
@@ -1983,7 +1983,7 @@ md_apply_fix (fixS *   fixP,
              valueT * valp,
              segT     segment)
 {
-  char *       buf  = fixP->fx_where + fixP->fx_frag->fr_literal;
+  char *       buf  = fixP->fx_where + &fixP->fx_frag->fr_literal[0];
   const char *       file = fixP->fx_file ? fixP->fx_file : _("unknown");
   const char * symname;
   /* Note: use offsetT because it is signed, valueT is unsigned.  */
index d06cc5e9b8bc70cf51ea6318b64a9c7d2df6d1f8..42f7417c6e3795aaa5a885999cb75e50a161f0d3 100644 (file)
@@ -3081,7 +3081,7 @@ md_convert_frag (bfd *headers ATTRIBUTE_UNUSED, segT seg, fragS *fragP)
         differently from ones without delay slots.  */
       {
        unsigned char *buffer =
-         (unsigned char *) (fragP->fr_fix + fragP->fr_literal);
+         (unsigned char *) (fragP->fr_fix + &fragP->fr_literal[0]);
        int highbyte = target_big_endian ? 0 : 1;
        int lowbyte = target_big_endian ? 1 : 0;
        int delay = fragP->fr_subtype == C (COND_JUMP_DELAY, COND12);