RISC-V: Fix build failures for -Werror=sign-compare.
authorNelson Chu <nelson@rivosinc.com>
Thu, 27 Oct 2022 01:39:13 +0000 (09:39 +0800)
committerNelson Chu <nelson@rivosinc.com>
Thu, 27 Oct 2022 08:45:43 +0000 (16:45 +0800)
elfnn-riscv.c: In function ‘riscv_relax_resolve_delete_relocs’:
elfnn-riscv.c:4256:30: error: operand of ‘?:’ changes signedness from ‘int’ to ‘unsigned int’ due to unsignedness of other operand [-Werror=sign-compare]

So make the operands unsigned could resolve problem.

bfd/
    * elfnn-riscv.c (riscv_relax_resolve_delete_relocs): Fixed build
    failures for -Werror=sign-compare.

bfd/elfnn-riscv.c

index cf852636c9ccc50ac4de7587f4871672785d581d..0570a971b5aa086e7c57f328ec0f0fb149d25b77 100644 (file)
@@ -4239,7 +4239,10 @@ riscv_relax_resolve_delete_relocs (bfd *abfd,
          rel_next = relocs + i;
          if (ELFNN_R_TYPE ((rel_next)->r_info) == R_RISCV_DELETE
              && (rel_next)->r_offset > rel->r_offset)
-           break;
+           {
+             BFD_ASSERT (rel_next - rel > 0);
+             break;
+           }
          else
            rel_next = NULL;
        }
@@ -4253,7 +4256,8 @@ riscv_relax_resolve_delete_relocs (bfd *abfd,
       rel->r_info = ELFNN_R_INFO (0, R_RISCV_NONE);
 
       /* Skip ahead to the next delete reloc.  */
-      i = rel_next != NULL ? rel_next - relocs - 1 : sec->reloc_count;
+      i = rel_next != NULL ? (unsigned int) (rel_next - relocs - 1)
+                          : sec->reloc_count;
     }
 
   return true;