1 /* 2 * Copyright 2019, Adrien Destugues <pulkomandy@pulkomandy.tk> 3 * Copyright 2010, Ithamar R. Adema <ithamar.adema@team-embedded.nl> 4 * Copyright 2009, Johannes Wischert, johanneswi@gmail.com. 5 * Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 6 * Copyright 2002, Travis Geiselbrecht. All rights reserved. 7 * Distributed under the terms of the MIT License. 8 */ 9 10 11 #include <KernelExport.h> 12 13 #include <elf_priv.h> 14 #include <arch/elf.h> 15 16 17 //#define TRACE_ARCH_ELF 18 #ifdef TRACE_ARCH_ELF 19 # define TRACE(x) dprintf x 20 # define CHATTY 1 21 #else 22 # define TRACE(x) ; 23 # define CHATTY 0 24 #endif 25 26 27 #ifndef _BOOT_MODE 28 static bool 29 is_in_image(struct elf_image_info *image, addr_t address) 30 { 31 return (address >= image->text_region.start 32 && address < image->text_region.start + image->text_region.size) 33 || (address >= image->data_region.start 34 && address < image->data_region.start + image->data_region.size); 35 } 36 #endif // !_BOOT_MODE 37 38 39 int 40 arch_elf_relocate_rel(struct elf_image_info *image, 41 struct elf_image_info *resolve_image, Elf64_Rel *rel, int rel_len) 42 { 43 // there are no rel entries in M68K elf 44 return B_NO_ERROR; 45 } 46 47 48 static inline void 49 write_32(addr_t P, Elf32_Word value) 50 { 51 *(Elf32_Word*)P = value; 52 } 53 54 55 static inline void 56 write_16(addr_t P, Elf32_Word value) 57 { 58 // bits 16:29 59 *(Elf32_Half*)P = (Elf32_Half)value; 60 } 61 62 63 static inline bool 64 write_16_check(addr_t P, Elf32_Word value) 65 { 66 // bits 15:0 67 if ((value & 0xffff0000) && (~value & 0xffff8000)) 68 return false; 69 *(Elf32_Half*)P = (Elf32_Half)value; 70 return true; 71 } 72 73 74 static inline bool 75 write_8(addr_t P, Elf32_Word value) 76 { 77 // bits 7:0 78 *(uint8 *)P = (uint8)value; 79 return true; 80 } 81 82 83 static inline bool 84 write_8_check(addr_t P, Elf32_Word value) 85 { 86 // bits 7:0 87 if ((value & 0xffffff00) && (~value & 0xffffff80)) 88 return false; 89 *(uint8 *)P = (uint8)value; 90 return true; 91 } 92 93 94 int 95 arch_elf_relocate_rela(struct elf_image_info *image, 96 struct elf_image_info *resolve_image, Elf64_Rela *rel, int rel_len) 97 { 98 return B_OK; 99 } 100