Revisão | f52fb009085e63da25eeacd39990ac6243ffed76 (tree) |
---|---|
Hora | 2022-10-27 17:45:43 |
Autor | Nelson Chu <nelson@rivo...> |
Commiter | Nelson Chu |
RISC-V: Fix build failures for -Werror=sign-compare.
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/
@@ -4239,7 +4239,10 @@ riscv_relax_resolve_delete_relocs (bfd *abfd, | ||
4239 | 4239 | rel_next = relocs + i; |
4240 | 4240 | if (ELFNN_R_TYPE ((rel_next)->r_info) == R_RISCV_DELETE |
4241 | 4241 | && (rel_next)->r_offset > rel->r_offset) |
4242 | - break; | |
4242 | + { | |
4243 | + BFD_ASSERT (rel_next - rel > 0); | |
4244 | + break; | |
4245 | + } | |
4243 | 4246 | else |
4244 | 4247 | rel_next = NULL; |
4245 | 4248 | } |
@@ -4253,7 +4256,8 @@ riscv_relax_resolve_delete_relocs (bfd *abfd, | ||
4253 | 4256 | rel->r_info = ELFNN_R_INFO (0, R_RISCV_NONE); |
4254 | 4257 | |
4255 | 4258 | /* Skip ahead to the next delete reloc. */ |
4256 | - i = rel_next != NULL ? rel_next - relocs - 1 : sec->reloc_count; | |
4259 | + i = rel_next != NULL ? (unsigned int) (rel_next - relocs - 1) | |
4260 | + : sec->reloc_count; | |
4257 | 4261 | } |
4258 | 4262 | |
4259 | 4263 | return true; |