gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / bfd / elf64-bpf.c
index 3e11f089ecb7f0adda32a5eb1ab4a6f3d355e164..641caa1f058e07a99c3cdb94086fb3586b417d88 100644 (file)
@@ -1,5 +1,5 @@
 /* Linux bpf specific support for 64-bit ELF
 /* Linux bpf specific support for 64-bit ELF
-   Copyright (C) 2019 Free Software Foundation, Inc.
+   Copyright (C) 2019-2020 Free Software Foundation, Inc.
    Contributed by Oracle Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
    Contributed by Oracle Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -64,7 +64,7 @@ static reloc_howto_type bpf_elf_howto_table [] =
         MINUS_ONE,             /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
         MINUS_ONE,             /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
-  /* 32-immediate in LDDW instruction.  */
+  /* 32-immediate in many instructions. Note: handled manually.  */
   HOWTO (R_BPF_INSN_32,                /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
   HOWTO (R_BPF_INSN_32,                /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
@@ -407,7 +407,7 @@ bpf_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
 
          name = bfd_elf_string_from_elf_section
            (input_bfd, symtab_hdr->sh_link, sym->st_name);
-         name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
+         name = name == NULL ? bfd_section_name (sec) : name;
        }
       else
        {
        }
       else
        {
@@ -460,6 +460,31 @@ bpf_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
             r = bfd_reloc_ok;
             break;
           }
             r = bfd_reloc_ok;
             break;
           }
+        case R_BPF_INSN_32:
+          {
+            /*  Write relocated value */
+            bfd_put (howto->bitsize, input_bfd, relocation,
+                     contents + rel->r_offset + 4);
+
+            r = bfd_reloc_ok;
+            break;
+          }
+        case R_BPF_INSN_64:
+          {
+            /*
+                LDDW instructions are 128 bits long, with a 64-bit immediate.
+                The lower 32 bits of the immediate are in the same position
+                as the imm32 field of other instructions.
+                The upper 32 bits of the immediate are stored at the end of
+                the instruction.
+             */
+            bfd_put (32, input_bfd, (relocation & 0xFFFFFFFF),
+                     contents + rel->r_offset + 4);
+            bfd_put (32, input_bfd, (relocation >> 32),
+                     contents + rel->r_offset + 12);
+            r = bfd_reloc_ok;
+            break;
+          }
         default:
           r = _bfd_final_link_relocate (howto, input_bfd, input_section,
                                         contents, rel->r_offset, relocation,
         default:
           r = _bfd_final_link_relocate (howto, input_bfd, input_section,
                                         contents, rel->r_offset, relocation,
This page took 0.02435 seconds and 4 git commands to generate.