https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95353

            Bug ID: 95353
           Summary: [10/11 Regression] GCC can't build binutils
           Product: gcc
           Version: 10.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: msebor at gcc dot gnu.org
  Target Milestone: ---

Assembler in binutils has

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

and fr_literal is accessed as

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
[-Wer
ror=stringop-overflow=]
 4507 |  buf[1] = BYTE_1 (CSKYV1_INST_SUBI | (7 << 4));
      |         ^

I checked in this:

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

as a workaround.  But it doesn't solve the problem in existing binutils
sources and some future version of gcc might see through the obfuscation
of the source, rendering this work-around ineffective.  is there a solution
which is future proof?

Reply via email to