GNU Binutils with patches for OS216
Revisión | 12adf8053ba0b241d3973b46109842a1cbfa60de (tree) |
---|---|
Tiempo | 2020-05-29 04:54:46 |
Autor | David Faust <david.faust@orac...> |
Commiter | Jose E. Marchesi |
bfd: fix handling of R_BPF_INSN_{32,64} relocations.
2020-05-28 David Faust <david.faust@oracle.com>
* elf64-bpf.c (bpf_elf_relocate_section): Fix handling of
R_BPF_INSN_{32,64} relocations.
@@ -1,3 +1,8 @@ | ||
1 | +2020-05-28 David Faust <david.faust@oracle.com> | |
2 | + | |
3 | + * elf64-bpf.c (bpf_elf_relocate_section): Fix handling of | |
4 | + R_BPF_INSN_{32,64} relocations. | |
5 | + | |
1 | 6 | 2020-05-28 Stephen Casner <casner@acm.org> |
2 | 7 | |
3 | 8 | * pdp11.c: Implement BRD_RELOC_32 to relocate the low 16 bits of |
@@ -64,7 +64,7 @@ static reloc_howto_type bpf_elf_howto_table [] = | ||
64 | 64 | MINUS_ONE, /* dst_mask */ |
65 | 65 | TRUE), /* pcrel_offset */ |
66 | 66 | |
67 | - /* 32-immediate in LDDW instruction. */ | |
67 | + /* 32-immediate in many instructions. Note: handled manually. */ | |
68 | 68 | HOWTO (R_BPF_INSN_32, /* type */ |
69 | 69 | 0, /* rightshift */ |
70 | 70 | 2, /* size (0 = byte, 1 = short, 2 = long) */ |
@@ -460,6 +460,31 @@ bpf_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, | ||
460 | 460 | r = bfd_reloc_ok; |
461 | 461 | break; |
462 | 462 | } |
463 | + case R_BPF_INSN_32: | |
464 | + { | |
465 | + /* Write relocated value */ | |
466 | + bfd_put (howto->bitsize, input_bfd, relocation, | |
467 | + contents + rel->r_offset + 4); | |
468 | + | |
469 | + r = bfd_reloc_ok; | |
470 | + break; | |
471 | + } | |
472 | + case R_BPF_INSN_64: | |
473 | + { | |
474 | + /* | |
475 | + LDDW instructions are 128 bits long, with a 64-bit immediate. | |
476 | + The lower 32 bits of the immediate are in the same position | |
477 | + as the imm32 field of other instructions. | |
478 | + The upper 32 bits of the immediate are stored at the end of | |
479 | + the instruction. | |
480 | + */ | |
481 | + bfd_put (32, input_bfd, (relocation & 0xFFFFFFFF), | |
482 | + contents + rel->r_offset + 4); | |
483 | + bfd_put (32, input_bfd, (relocation >> 32), | |
484 | + contents + rel->r_offset + 12); | |
485 | + r = bfd_reloc_ok; | |
486 | + break; | |
487 | + } | |
463 | 488 | default: |
464 | 489 | r = _bfd_final_link_relocate (howto, input_bfd, input_section, |
465 | 490 | contents, rel->r_offset, relocation, |