gas: avoid GCC 10 warning stringop-overflow in tc-bpf.c
authorJose E. Marchesi <jose.marchesi@oracle.com>
Fri, 5 Jun 2020 14:23:30 +0000 (16:23 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Fri, 5 Jun 2020 14:23:30 +0000 (16:23 +0200)
The GAS struct frag ends with a field `fr_literal' whose purpose is to
mark the begining of the frag's data:

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

The code in gas/config/tc-bpf.c recently committed:

where = fixP->fx_frag->fr_literal + fixP->fx_where;
where[1] = target_big_endian ? 0x01 : 0x10;

triggers the stringop-overflow warning in GCC 10+, since the compiler
assumes the size of the modified buffer is 1 byte.  This patch
slightly modifies the code to make tc-bpf.c buildable with GCC 10+.

2020-06-05  Jose E. Marchesi  <jose.marchesi@oracle.com>

* config/tc-bpf.c (md_apply_fix): Avoid GCC 10 warning
stringop-overflow.

gas/ChangeLog
gas/config/tc-bpf.c

index 14d10799f0b9aa199bdc7a061eff523a7a05b6a7..3ef92ad961d4f44ea4188f73bc02b3f786812df7 100644 (file)
@@ -1,3 +1,8 @@
+2020-06-05  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+       * config/tc-bpf.c (md_apply_fix): Avoid GCC 10 warning
+       stringop-overflow.
+
 2020-06-05  Nelson Chu  <nelson.chu@sifive.com>
 
        * config/tc-riscv.c (explicit_csr): New static boolean.
index aa48108748b197aac177875a89d0cd467895111b..026a631280deddbed87876e47790bbf0a91917ca 100644 (file)
@@ -324,8 +324,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg)
 
              Note that the CALL instruction has only one operand, so
              this code is executed only once per instruction.  */
-          where = fixP->fx_frag->fr_literal + fixP->fx_where;
-          where[1] = target_big_endian ? 0x01 : 0x10;
+          where = fixP->fx_frag->fr_literal + fixP->fx_where + 1;
+          where[0] = target_big_endian ? 0x01 : 0x10;
           /* Fallthrough.  */
         case BPF_OPERAND_DISP16:
           /* The PC-relative displacement fields in jump instructions
This page took 0.036061 seconds and 4 git commands to generate.