Debian Codegraph @

libdrgn/arch_i386.c

raw
1 // Copyright (c) Meta Platforms, Inc. and affiliates.
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3
4 #include <elf.h>
5
6 #include "platform.h" // IWYU pragma: associated
7
8 static struct drgn_error *
9 apply_elf_reloc_i386(const struct drgn_relocating_section *relocating,
10 uint64_t r_offset, uint32_t r_type,
11 const int64_t *r_addend, uint64_t sym_value)
12 {
13 switch (r_type) {
14 case R_386_NONE:
15 return NULL;
16 case R_386_32:
17 return drgn_reloc_add32(relocating, r_offset, r_addend,
18 sym_value);
19 case R_386_PC32:
20 return drgn_reloc_add32(relocating, r_offset, r_addend,
21 sym_value
22 - (relocating->addr + r_offset));
23 default:
24 return DRGN_UNKNOWN_RELOCATION_TYPE(r_type);
25 }
26 }
27
28 const struct drgn_architecture_info arch_info_i386 = {
29 .name = "i386",
30 .arch = DRGN_ARCH_I386,
31 .default_flags = DRGN_PLATFORM_IS_LITTLE_ENDIAN,
32 .scalar_alignment = { 1, 2, 4, 4, 16 },
33 .register_by_name = drgn_register_by_name_unknown,
34 .apply_elf_reloc = apply_elf_reloc_i386,
35 };