Ticket #12444: 0002-system-Build-using-public-elf.h-header.patch
File 0002-system-Build-using-public-elf.h-header.patch, 41.7 KB (added by , 9 years ago) |
---|
-
headers/private/kernel/arch/elf.h
From ee22f05482bee641bb78c24d53b2638fe4982eeb Mon Sep 17 00:00:00 2001 From: Simon South <ssouth@simonsouth.com> Date: Mon, 26 Oct 2015 13:43:44 -0400 Subject: [PATCH 2/2] system: Build using public elf.h header Reduce duplication of code by * Removing from elf_common.h definitions available in os/kernel/elf.h * Deleting elf32.h and elf64.h * Renaming elf_common.h to elf_private.h * Updating source to build using public and private ELF header files together --- headers/private/kernel/arch/elf.h | 2 +- headers/private/kernel/boot/arch.h | 8 +- headers/private/kernel/boot/elf.h | 4 +- headers/private/kernel/elf.h | 2 +- headers/private/kernel/elf_priv.h | 4 +- headers/private/runtime_loader/runtime_loader.h | 4 +- headers/private/system/elf32.h | 243 ---------------- headers/private/system/elf64.h | 247 ---------------- headers/private/system/elf_common.h | 317 --------------------- headers/private/system/elf_private.h | 53 ++++ headers/private/system/syscalls.h | 2 +- src/apps/debugger/elf/ElfFile.cpp | 8 +- src/apps/debugger/elf/ElfFile.h | 3 +- src/kits/debug/Image.h | 2 +- src/system/boot/loader/elf.cpp | 6 +- src/system/kernel/arch/arm/arch_elf.cpp | 18 +- src/system/kernel/arch/m68k/arch_elf.cpp | 14 +- src/system/kernel/arch/ppc/arch_elf.cpp | 14 +- src/system/kernel/arch/x86/arch_elf.cpp | 14 +- .../runtime_loader/arch/m68k/arch_relocate.cpp | 10 +- .../runtime_loader/arch/ppc/arch_relocate.cpp | 6 +- .../runtime_loader/arch/x86/arch_relocate.cpp | 8 +- src/tests/system/boot/loader/platform_misc.cpp | 8 +- 23 files changed, 121 insertions(+), 876 deletions(-) delete mode 100644 headers/private/system/elf32.h delete mode 100644 headers/private/system/elf64.h delete mode 100644 headers/private/system/elf_common.h create mode 100644 headers/private/system/elf_private.h diff --git a/headers/private/kernel/arch/elf.h b/headers/private/kernel/arch/elf.h index d2dc5d8..d2b10f4 100644
a b 6 6 #define _KERNEL_ARCH_ELF_H 7 7 8 8 9 #include <elf_ common.h>9 #include <elf_private.h> 10 10 11 11 12 12 struct elf_image_info; -
headers/private/kernel/boot/arch.h
diff --git a/headers/private/kernel/boot/arch.h b/headers/private/kernel/boot/arch.h index 2f4be42..41a8502 100644
a b 13 13 /* ELF support */ 14 14 15 15 extern status_t boot_arch_elf_relocate_rel(preloaded_elf32_image* image, 16 structElf32_Rel* rel, int rel_len);16 Elf32_Rel* rel, int rel_len); 17 17 extern status_t boot_arch_elf_relocate_rel(preloaded_elf64_image* image, 18 structElf64_Rel* rel, int rel_len);18 Elf64_Rel* rel, int rel_len); 19 19 extern status_t boot_arch_elf_relocate_rela(preloaded_elf32_image* image, 20 structElf32_Rela* rel, int rel_len);20 Elf32_Rela* rel, int rel_len); 21 21 extern status_t boot_arch_elf_relocate_rela(preloaded_elf64_image* image, 22 structElf64_Rela* rel, int rel_len);22 Elf64_Rela* rel, int rel_len); 23 23 24 24 25 25 #endif /* KERNEL_BOOT_ARCH_H */ -
headers/private/kernel/boot/elf.h
diff --git a/headers/private/kernel/boot/elf.h b/headers/private/kernel/boot/elf.h index 2f38836..97d15d5 100644
a b typedef preloaded_elf32_image preloaded_elf_image; 87 87 88 88 #ifdef _BOOT_MODE 89 89 extern status_t boot_elf_resolve_symbol(preloaded_elf32_image* image, 90 structElf32_Sym* symbol, Elf32_Addr* symbolAddress);90 Elf32_Sym* symbol, Elf32_Addr* symbolAddress); 91 91 extern status_t boot_elf_resolve_symbol(preloaded_elf64_image* image, 92 structElf64_Sym* symbol, Elf64_Addr* symbolAddress);92 Elf64_Sym* symbol, Elf64_Addr* symbolAddress); 93 93 extern void boot_elf64_set_relocation(Elf64_Addr resolveAddress, 94 94 Elf64_Addr finalAddress); 95 95 #endif -
headers/private/kernel/elf.h
diff --git a/headers/private/kernel/elf.h b/headers/private/kernel/elf.h index 3851504..8922336 100644
a b 9 9 #define _KERNEL_ELF_H 10 10 11 11 12 #include <elf_ common.h>12 #include <elf_private.h> 13 13 #include <thread.h> 14 14 #include <image.h> 15 15 -
headers/private/kernel/elf_priv.h
diff --git a/headers/private/kernel/elf_priv.h b/headers/private/kernel/elf_priv.h index 0b6341f..69e675f 100644
a b 9 9 #define _KERNEL_ELF_PRIV_H 10 10 11 11 12 #include <elf 32.h>13 #include <elf64.h> 12 #include <elf_private.h> 13 14 14 #include <image.h> 15 15 16 16 -
headers/private/runtime_loader/runtime_loader.h
diff --git a/headers/private/runtime_loader/runtime_loader.h b/headers/private/runtime_loader/runtime_loader.h index ab4c3b2..6a754f2 100644
a b 11 11 #ifndef _RUNTIME_LOADER_H 12 12 #define _RUNTIME_LOADER_H 13 13 14 14 15 #include <image.h> 15 16 #include <OS.h> 16 17 17 #include <elf32.h> 18 #include <elf64.h> 18 #include <elf_private.h> 19 19 20 20 21 21 // #pragma mark - runtime loader libroot interface -
deleted file headers/private/system/elf32.h
diff --git a/headers/private/system/elf32.h b/headers/private/system/elf32.h deleted file mode 100644 index c1bf7e2..0000000
+ - 1 /*2 * Copyright 2001, Travis Geiselbrecht. All rights reserved.3 * Distributed under the terms of the NewOS License.4 *5 * Copyright 2002-2011, Haiku Inc. All Rights Reserved.6 * Distributed under the terms of the MIT license.7 */8 #ifndef _ELF32_H9 #define _ELF32_H10 11 12 #include <elf_common.h>13 14 15 typedef uint32 Elf32_Addr;16 typedef uint16 Elf32_Half;17 typedef uint32 Elf32_Off;18 typedef int32 Elf32_Sword;19 typedef uint32 Elf32_Word;20 21 typedef Elf32_Half Elf32_Versym;22 23 /*** ELF header ***/24 25 struct Elf32_Ehdr {26 uint8 e_ident[EI_NIDENT];27 Elf32_Half e_type;28 Elf32_Half e_machine;29 Elf32_Word e_version;30 Elf32_Addr e_entry;31 Elf32_Off e_phoff;32 Elf32_Off e_shoff;33 Elf32_Word e_flags;34 Elf32_Half e_ehsize;35 Elf32_Half e_phentsize;36 Elf32_Half e_phnum;37 Elf32_Half e_shentsize;38 Elf32_Half e_shnum;39 Elf32_Half e_shstrndx;40 41 #ifdef __cplusplus42 bool IsHostEndian() const;43 #endif44 };45 46 47 /*** section header ***/48 49 struct Elf32_Shdr {50 Elf32_Word sh_name;51 Elf32_Word sh_type;52 Elf32_Word sh_flags;53 Elf32_Addr sh_addr;54 Elf32_Off sh_offset;55 Elf32_Word sh_size;56 Elf32_Word sh_link;57 Elf32_Word sh_info;58 Elf32_Word sh_addralign;59 Elf32_Word sh_entsize;60 };61 62 63 /*** program header ***/64 65 struct Elf32_Phdr {66 Elf32_Word p_type;67 Elf32_Off p_offset; /* offset from the beginning of the file of the segment */68 Elf32_Addr p_vaddr; /* virtual address for the segment in memory */69 Elf32_Addr p_paddr;70 Elf32_Word p_filesz; /* the size of the segment in the file */71 Elf32_Word p_memsz; /* the size of the segment in memory */72 Elf32_Word p_flags;73 Elf32_Word p_align;74 75 #ifdef __cplusplus76 bool IsReadWrite() const;77 bool IsExecutable() const;78 #endif79 };80 81 struct Elf32_Sym {82 Elf32_Word st_name;83 Elf32_Addr st_value;84 Elf32_Word st_size;85 uint8 st_info;86 uint8 st_other;87 Elf32_Half st_shndx;88 89 #ifdef __cplusplus90 uint8 Bind() const;91 uint8 Type() const;92 void SetInfo(uint8 bind, uint8 type);93 #endif94 };95 96 #define ELF32_ST_BIND(i) ((i) >> 4)97 #define ELF32_ST_TYPE(i) ((i) & 0xf)98 #define ELF32_ST_INFO(b, t) (((b) << 4) + ((t) & 0xf))99 100 struct Elf32_Rel {101 Elf32_Addr r_offset;102 Elf32_Word r_info;103 104 #ifdef __cplusplus105 uint8 SymbolIndex() const;106 uint8 Type() const;107 #endif108 };109 110 #ifdef __cplusplus111 struct Elf32_Rela : public Elf32_Rel {112 #else113 struct Elf32_Rela {114 Elf32_Addr r_offset;115 Elf32_Word r_info;116 #endif117 Elf32_Sword r_addend;118 };119 120 #define ELF32_R_SYM(i) ((i) >> 8)121 #define ELF32_R_TYPE(i) ((unsigned char)(i))122 #define ELF32_R_INFO(s, t) (((s) << 8) + (unsigned char)(t))123 124 struct Elf32_Dyn {125 Elf32_Sword d_tag;126 union {127 Elf32_Word d_val;128 Elf32_Addr d_ptr;129 } d_un;130 };131 132 133 /* version definition section */134 135 struct Elf32_Verdef {136 Elf32_Half vd_version; /* version revision */137 Elf32_Half vd_flags; /* version information flags */138 Elf32_Half vd_ndx; /* version index as specified in the139 symbol version table */140 Elf32_Half vd_cnt; /* number of associated verdaux entries */141 Elf32_Word vd_hash; /* version name hash value */142 Elf32_Word vd_aux; /* byte offset to verdaux array */143 Elf32_Word vd_next; /* byte offset to next verdef entry */144 };145 146 147 /* auxiliary version information */148 149 struct Elf32_Verdaux {150 Elf32_Word vda_name; /* string table offset to version or dependency151 name */152 Elf32_Word vda_next; /* byte offset to next verdaux entry */153 };154 155 156 /* version dependency section */157 158 struct Elf32_Verneed {159 Elf32_Half vn_version; /* version of structure */160 Elf32_Half vn_cnt; /* number of associated vernaux entries */161 Elf32_Word vn_file; /* byte offset to file name for this162 dependency */163 Elf32_Word vn_aux; /* byte offset to vernaux array */164 Elf32_Word vn_next; /* byte offset to next verneed entry */165 };166 167 168 /* auxiliary needed version information */169 170 struct Elf32_Vernaux {171 Elf32_Word vna_hash; /* dependency name hash value */172 Elf32_Half vna_flags; /* dependency specific information flags */173 Elf32_Half vna_other; /* version index as specified in the symbol174 version table */175 Elf32_Word vna_name; /* string table offset to dependency name */176 Elf32_Word vna_next; /* byte offset to next vernaux entry */177 };178 179 180 /*** inline functions ***/181 182 #ifdef __cplusplus183 184 inline bool185 Elf32_Ehdr::IsHostEndian() const186 {187 #if B_HOST_IS_LENDIAN188 return e_ident[EI_DATA] == ELFDATA2LSB;189 #elif B_HOST_IS_BENDIAN190 return e_ident[EI_DATA] == ELFDATA2MSB;191 #endif192 }193 194 195 inline bool196 Elf32_Phdr::IsReadWrite() const197 {198 return !(~p_flags & (PF_READ | PF_WRITE));199 }200 201 202 inline bool203 Elf32_Phdr::IsExecutable() const204 {205 return (p_flags & PF_EXECUTE) != 0;206 }207 208 209 inline uint8210 Elf32_Sym::Bind() const211 {212 return ELF32_ST_BIND(st_info);213 }214 215 216 inline uint8217 Elf32_Sym::Type() const218 {219 return ELF32_ST_TYPE(st_info);220 }221 222 inline void223 Elf32_Sym::SetInfo(uint8 bind, uint8 type)224 {225 st_info = ELF32_ST_INFO(bind, type);226 }227 228 inline uint8229 Elf32_Rel::SymbolIndex() const230 {231 return ELF32_R_SYM(r_info);232 }233 234 235 inline uint8236 Elf32_Rel::Type() const237 {238 return ELF32_R_TYPE(r_info);239 }240 241 #endif /* __cplusplus */242 243 #endif /* _ELF32_H_ */ -
deleted file headers/private/system/elf64.h
diff --git a/headers/private/system/elf64.h b/headers/private/system/elf64.h deleted file mode 100644 index 3efd48b..0000000
+ - 1 /*2 * Copyright 2001, Travis Geiselbrecht. All rights reserved.3 * Distributed under the terms of the NewOS License.4 *5 * Copyright 2002-2011, Haiku Inc. All Rights Reserved.6 * Distributed under the terms of the MIT license.7 */8 #ifndef _ELF64_H9 #define _ELF64_H10 11 12 #include <elf_common.h>13 14 15 typedef uint64 Elf64_Addr;16 typedef uint64 Elf64_Off;17 typedef uint16 Elf64_Half;18 typedef uint32 Elf64_Word;19 typedef int32 Elf64_Sword;20 typedef uint64 Elf64_Xword;21 typedef int64 Elf64_Sxword;22 23 typedef Elf64_Half Elf64_Versym;24 25 /*** ELF header ***/26 27 struct Elf64_Ehdr {28 uint8 e_ident[EI_NIDENT];29 Elf64_Half e_type;30 Elf64_Half e_machine;31 Elf64_Word e_version;32 Elf64_Addr e_entry;33 Elf64_Off e_phoff;34 Elf64_Off e_shoff;35 Elf64_Word e_flags;36 Elf64_Half e_ehsize;37 Elf64_Half e_phentsize;38 Elf64_Half e_phnum;39 Elf64_Half e_shentsize;40 Elf64_Half e_shnum;41 Elf64_Half e_shstrndx;42 43 #ifdef __cplusplus44 bool IsHostEndian() const;45 #endif46 };47 48 49 /*** section header ***/50 51 struct Elf64_Shdr {52 Elf64_Word sh_name;53 Elf64_Word sh_type;54 Elf64_Xword sh_flags;55 Elf64_Addr sh_addr;56 Elf64_Off sh_offset;57 Elf64_Xword sh_size;58 Elf64_Word sh_link;59 Elf64_Word sh_info;60 Elf64_Xword sh_addralign;61 Elf64_Xword sh_entsize;62 };63 64 65 /*** program header ***/66 67 struct Elf64_Phdr {68 Elf64_Word p_type;69 Elf64_Word p_flags;70 Elf64_Off p_offset; /* offset from the beginning of the file of the segment */71 Elf64_Addr p_vaddr; /* virtual address for the segment in memory */72 Elf64_Addr p_paddr;73 Elf64_Xword p_filesz; /* the size of the segment in the file */74 Elf64_Xword p_memsz; /* the size of the segment in memory */75 Elf64_Xword p_align;76 77 #ifdef __cplusplus78 bool IsReadWrite() const;79 bool IsExecutable() const;80 #endif81 };82 83 struct Elf64_Sym {84 Elf64_Word st_name;85 uint8 st_info;86 uint8 st_other;87 Elf64_Half st_shndx;88 Elf64_Addr st_value;89 Elf64_Xword st_size;90 91 #ifdef __cplusplus92 uint8 Bind() const;93 uint8 Type() const;94 void SetInfo(uint8 bind, uint8 type);95 #endif96 };97 98 #define ELF64_ST_BIND(i) ((i) >> 4)99 #define ELF64_ST_TYPE(i) ((i) & 0xf)100 #define ELF64_ST_INFO(b, t) (((b) << 4) + ((t) & 0xf))101 102 struct Elf64_Rel {103 Elf64_Addr r_offset;104 Elf64_Xword r_info;105 106 #ifdef __cplusplus107 uint8 SymbolIndex() const;108 uint8 Type() const;109 #endif110 };111 112 #ifdef __cplusplus113 struct Elf64_Rela : public Elf64_Rel {114 #else115 struct Elf64_Rela {116 Elf64_Addr r_offset;117 Elf64_Xword r_info;118 #endif119 Elf64_Sxword r_addend;120 };121 122 #define ELF64_R_SYM(i) ((i) >> 32)123 #define ELF64_R_TYPE(i) ((i) & 0xffffffffL)124 #define ELF64_R_INFO(s, t) ((((Elf64_Xword)(s)) << 32) + ((t) & 0xffffffffL))125 126 struct Elf64_Dyn {127 Elf64_Sxword d_tag;128 union {129 Elf64_Xword d_val;130 Elf64_Addr d_ptr;131 } d_un;132 };133 134 135 /* version definition section */136 137 struct Elf64_Verdef {138 Elf64_Half vd_version; /* version revision */139 Elf64_Half vd_flags; /* version information flags */140 Elf64_Half vd_ndx; /* version index as specified in the141 symbol version table */142 Elf64_Half vd_cnt; /* number of associated verdaux entries */143 Elf64_Word vd_hash; /* version name hash value */144 Elf64_Word vd_aux; /* byte offset to verdaux array */145 Elf64_Word vd_next; /* byte offset to next verdef entry */146 };147 148 149 /* auxiliary version information */150 151 struct Elf64_Verdaux {152 Elf64_Word vda_name; /* string table offset to version or dependency153 name */154 Elf64_Word vda_next; /* byte offset to next verdaux entry */155 };156 157 158 /* version dependency section */159 160 struct Elf64_Verneed {161 Elf64_Half vn_version; /* version of structure */162 Elf64_Half vn_cnt; /* number of associated vernaux entries */163 Elf64_Word vn_file; /* byte offset to file name for this164 dependency */165 Elf64_Word vn_aux; /* byte offset to vernaux array */166 Elf64_Word vn_next; /* byte offset to next verneed entry */167 };168 169 170 /* auxiliary needed version information */171 172 struct Elf64_Vernaux {173 Elf64_Word vna_hash; /* dependency name hash value */174 Elf64_Half vna_flags; /* dependency specific information flags */175 Elf64_Half vna_other; /* version index as specified in the symbol176 version table */177 Elf64_Word vna_name; /* string table offset to dependency name */178 Elf64_Word vna_next; /* byte offset to next vernaux entry */179 };180 181 182 /*** inline functions ***/183 184 #ifdef __cplusplus185 186 inline bool187 Elf64_Ehdr::IsHostEndian() const188 {189 #if B_HOST_IS_LENDIAN190 return e_ident[EI_DATA] == ELFDATA2LSB;191 #elif B_HOST_IS_BENDIAN192 return e_ident[EI_DATA] == ELFDATA2MSB;193 #endif194 }195 196 197 inline bool198 Elf64_Phdr::IsReadWrite() const199 {200 return !(~p_flags & (PF_READ | PF_WRITE));201 }202 203 204 inline bool205 Elf64_Phdr::IsExecutable() const206 {207 return (p_flags & PF_EXECUTE) != 0;208 }209 210 211 inline uint8212 Elf64_Sym::Bind() const213 {214 return ELF64_ST_BIND(st_info);215 }216 217 218 inline uint8219 Elf64_Sym::Type() const220 {221 return ELF64_ST_TYPE(st_info);222 }223 224 225 inline void226 Elf64_Sym::SetInfo(uint8 bind, uint8 type)227 {228 st_info = ELF64_ST_INFO(bind, type);229 }230 231 232 inline uint8233 Elf64_Rel::SymbolIndex() const234 {235 return ELF64_R_SYM(r_info);236 }237 238 239 inline uint8240 Elf64_Rel::Type() const241 {242 return ELF64_R_TYPE(r_info);243 }244 245 #endif /* __cplusplus */246 247 #endif /* _ELF64_H_ */ -
deleted file headers/private/system/elf_common.h
diff --git a/headers/private/system/elf_common.h b/headers/private/system/elf_common.h deleted file mode 100644 index 23ab555..0000000
+ - 1 /*2 * Copyright 2001, Travis Geiselbrecht. All rights reserved.3 * Distributed under the terms of the NewOS License.4 *5 * Copyright 2002-2011, Haiku Inc. All Rights Reserved.6 * Distributed under the terms of the MIT license.7 */8 #ifndef _ELF_COMMON_H9 #define _ELF_COMMON_H10 11 12 #include <SupportDefs.h>13 #include <ByteOrder.h>14 15 #include <arch_elf.h>16 17 18 /*** ELF header ***/19 20 #define EI_NIDENT 1621 22 #define ELF_MAGIC "\x7f""ELF"23 24 // e_ident[] indices25 #define EI_MAG0 026 #define EI_MAG1 127 #define EI_MAG2 228 #define EI_MAG3 329 #define EI_CLASS 430 #define EI_DATA 531 #define EI_VERSION 632 #define EI_PAD 733 34 // e_type (Object file type)35 #define ET_NONE 0 // No file type36 #define ET_REL 1 // Relocatable file37 #define ET_EXEC 2 // Executable file38 #define ET_DYN 3 // Shared object file39 #define ET_CORE 4 // Core file40 #define ET_LOOS 0xfe00 // OS-specific range start41 #define ET_HIOS 0xfeff // OS-specific range end42 #define ET_LOPROC 0xff00 // Processor-specific range start43 #define ET_HIPROC 0xffff // Processor-specific range end44 45 // e_machine (Architecture)46 #define EM_NONE 0 // No machine47 #define EM_M32 1 // AT&T WE 3210048 #define EM_SPARC 2 // Sparc49 #define EM_386 3 // Intel 8038650 #define EM_68K 4 // Motorola m68k family51 #define EM_88K 5 // Motorola m88k family52 #define EM_486 6 // Intel 80486, Reserved for future use53 #define EM_860 7 // Intel 8086054 #define EM_MIPS 8 // MIPS R3000 (officially, big-endian only)55 #define EM_S370 9 // IBM System/37056 #define EM_MIPS_RS3_LE 10 // MIPS R3000 little-endian, Deprecated57 #define EM_PARISC 15 // HPPA58 #define EM_VPP550 17 // Fujitsu VPP50059 #define EM_SPARC32PLUS 18 // Sun "v8plus"60 #define EM_960 19 // Intel 8096061 #define EM_PPC 20 // PowerPC62 #define EM_PPC64 21 // 64-bit PowerPC63 #define EM_S390 22 // IBM S/39064 #define EM_V800 36 // NEC V800 series65 #define EM_FR20 37 // Fujitsu FR2066 #define EM_RH32 38 // TRW RH3267 #define EM_MCORE 39 // Motorola M*Core68 #define EM_RCE 39 // Old name for MCore69 #define EM_ARM 40 // ARM70 #define EM_OLD_ALPHA 41 // Digital Alpha71 #define EM_SH 42 // Renesas / SuperH SH72 #define EM_SPARCV9 43 // SPARC v9 64-bit73 #define EM_TRICORE 44 // Siemens Tricore embedded processor74 #define EM_ARC 45 // ARC Cores75 #define EM_H8_300 46 // Renesas H8/30076 #define EM_H8_300H 47 // Renesas H8/300H77 #define EM_H8S 48 // Renesas H8S78 #define EM_H8_500 49 // Renesas H8/50079 #define EM_IA_64 50 // Intel IA-64 Processor80 #define EM_MIPS_X 51 // Stanford MIPS-X81 #define EM_COLDFIRE 52 // Motorola Coldfire82 #define EM_68HC12 53 // Motorola M68HC1283 #define EM_MMA 54 // Fujitsu Multimedia Accelerator84 #define EM_PCP 55 // Siemens PCP85 #define EM_NCPU 56 // Sony nCPU embedded RISC processor86 #define EM_NDR1 57 // Denso NDR1 microprocesspr87 #define EM_STARCORE 58 // Motorola Star*Core processor88 #define EM_ME16 59 // Toyota ME16 processor89 #define EM_ST100 60 // STMicroelectronics ST100 processor90 #define EM_TINYJ 61 // Advanced Logic Corp. TinyJ embedded processor91 #define EM_X86_64 62 // Advanced Micro Devices X86-64 processor92 93 // architecture class (EI_CLASS)94 #define ELFCLASS32 195 #define ELFCLASS64 296 // endian (EI_DATA)97 #define ELFDATA2LSB 1 /* little endian */98 #define ELFDATA2MSB 2 /* big endian */99 100 101 /*** section header ***/102 103 // special section indices104 #define SHN_UNDEF 0105 #define SHN_LORESERVE 0xff00106 #define SHN_LOPROC 0xff00107 #define SHN_HIPROC 0xff1f108 #define SHN_ABS 0xfff1109 #define SHN_COMMON 0xfff2110 #define SHN_HIRESERVE 0xffff111 112 // section header type113 #define SHT_NULL 0114 #define SHT_PROGBITS 1115 #define SHT_SYMTAB 2116 #define SHT_STRTAB 3117 #define SHT_RELA 4118 #define SHT_HASH 5119 #define SHT_DYNAMIC 6120 #define SHT_NOTE 7121 #define SHT_NOBITS 8122 #define SHT_REL 9123 #define SHT_SHLIB 10124 #define SHT_DYNSYM 11125 126 #define SHT_GNU_verdef 0x6ffffffd /* version definition section */127 #define SHT_GNU_verneed 0x6ffffffe /* version needs section */128 #define SHT_GNU_versym 0x6fffffff /* version symbol table */129 130 #define SHT_LOPROC 0x70000000131 #define SHT_HIPROC 0x7fffffff132 #define SHT_LOUSER 0x80000000133 #define SHT_HIUSER 0xffffffff134 135 // section header flags136 #define SHF_WRITE 1137 #define SHF_ALLOC 2138 #define SHF_EXECINSTR 4139 140 #define SHF_MASKPROC 0xf0000000141 142 143 /*** program header ***/144 145 // program header segment types146 #define PT_NULL 0147 #define PT_LOAD 1148 #define PT_DYNAMIC 2149 #define PT_INTERP 3150 #define PT_NOTE 4151 #define PT_SHLIB 5152 #define PT_PHDR 6153 #define PT_TLS 7154 #define PT_STACK 0x6474e551155 #define PT_RELRO 0x6474e552156 157 #define PT_LOPROC 0x70000000158 #define PT_ARM_UNWIND 0x70000001159 #define PT_HIPROC 0x7fffffff160 161 162 // program header segment flags163 #define PF_EXECUTE 0x1164 #define PF_WRITE 0x2165 #define PF_READ 0x4166 #define PF_PROTECTION_MASK (PF_EXECUTE | PF_WRITE | PF_READ)167 168 #define PF_MASKPROC 0xf0000000169 170 #define STT_NOTYPE 0171 #define STT_OBJECT 1172 #define STT_FUNC 2173 #define STT_SECTION 3174 #define STT_FILE 4175 #define STT_TLS 6176 #define STT_LOPROC 13177 #define STT_HIPROC 15178 179 #define STB_LOCAL 0180 #define STB_GLOBAL 1181 #define STB_WEAK 2182 #define STB_LOPROC 13183 #define STB_HIPROC 15184 185 #define STN_UNDEF 0186 187 188 #define DT_NULL 0189 #define DT_NEEDED 1190 #define DT_PLTRELSZ 2191 #define DT_PLTGOT 3192 #define DT_HASH 4193 #define DT_STRTAB 5194 #define DT_SYMTAB 6195 #define DT_RELA 7196 #define DT_RELASZ 8197 #define DT_RELAENT 9198 #define DT_STRSZ 10199 #define DT_SYMENT 11200 #define DT_INIT 12201 #define DT_FINI 13202 #define DT_SONAME 14203 #define DT_RPATH 15204 #define DT_SYMBOLIC 16205 #define DT_REL 17206 #define DT_RELSZ 18207 #define DT_RELENT 19208 #define DT_PLTREL 20209 #define DT_DEBUG 21210 #define DT_TEXTREL 22211 #define DT_JMPREL 23212 #define DT_BIND_NOW 24 /* no lazy binding */213 #define DT_INIT_ARRAY 25 /* init function array */214 #define DT_FINI_ARRAY 26 /* termination function array */215 #define DT_INIT_ARRAYSZ 27 /* init function array size */216 #define DT_FINI_ARRAYSZ 28 /* termination function array size */217 #define DT_RUNPATH 29 /* library search path (supersedes DT_RPATH) */218 #define DT_FLAGS 30 /* flags (see below) */219 #define DT_ENCODING 32220 #define DT_PREINIT_ARRAY 32 /* preinitialization array */221 #define DT_PREINIT_ARRAYSZ 33 /* preinitialization array size */222 223 #define DT_VERSYM 0x6ffffff0 /* symbol version table */224 #define DT_VERDEF 0x6ffffffc /* version definition table */225 #define DT_VERDEFNUM 0x6ffffffd /* number of version definitions */226 #define DT_VERNEED 0x6ffffffe /* table with needed versions */227 #define DT_VERNEEDNUM 0x6fffffff /* number of needed versions */228 229 #define DT_LOPROC 0x70000000230 #define DT_HIPROC 0x7fffffff231 232 233 /* DT_FLAGS values */234 #define DF_ORIGIN 0x01235 #define DF_SYMBOLIC 0x02236 #define DF_TEXTREL 0x04237 #define DF_BIND_NOW 0x08238 #define DF_STATIC_TLS 0x10239 240 241 /* version definition section */242 243 /* values for vd_version (version revision) */244 #define VER_DEF_NONE 0 /* no version */245 #define VER_DEF_CURRENT 1 /* current version */246 #define VER_DEF_NUM 2 /* given version number */247 248 /* values for vd_flags (version information flags) */249 #define VER_FLG_BASE 0x1 /* version definition of file itself */250 #define VER_FLG_WEAK 0x2 /* weak version identifier */251 252 /* values for versym symbol index */253 #define VER_NDX_LOCAL 0 /* symbol is local */254 #define VER_NDX_GLOBAL 1 /* symbol is global/unversioned */255 #define VER_NDX_INITIAL 2 /* initial version -- that's the one given256 to symbols when a library becomes257 versioned; handled by the linker (and258 runtime loader) similar to259 VER_NDX_GLOBAL */260 #define VER_NDX_LORESERVE 0xff00 /* beginning of reserved entries */261 #define VER_NDX_ELIMINATE 0xff01 /* symbol is to be eliminated */262 263 #define VER_NDX_FLAG_HIDDEN 0x8000 /* flag: version is hidden */264 #define VER_NDX_MASK 0x7fff /* mask to get the actual version index */265 #define VER_NDX(x) ((x) & VER_NDX_MASK)266 267 268 /* version dependency section */269 270 /* values for vn_version (version revision) */271 #define VER_NEED_NONE 0 /* no version */272 #define VER_NEED_CURRENT 1 /* current version */273 #define VER_NEED_NUM 2 /* given version number */274 275 276 /* auxiliary needed version information */277 278 /* values for vna_flags */279 #define VER_FLG_WEAK 0x2 /* weak version identifier */280 281 282 // Determine the correct ELF types to use for the architecture283 284 #if B_HAIKU_64_BIT285 # define _ELF_TYPE(type) Elf64_##type286 #else287 # define _ELF_TYPE(type) Elf32_##type288 #endif289 #define DEFINE_ELF_TYPE(type, name) \290 struct _ELF_TYPE(type); \291 typedef struct _ELF_TYPE(type) name292 293 DEFINE_ELF_TYPE(Ehdr, elf_ehdr);294 DEFINE_ELF_TYPE(Phdr, elf_phdr);295 DEFINE_ELF_TYPE(Shdr, elf_shdr);296 DEFINE_ELF_TYPE(Sym, elf_sym);297 DEFINE_ELF_TYPE(Dyn, elf_dyn);298 DEFINE_ELF_TYPE(Rel, elf_rel);299 DEFINE_ELF_TYPE(Rela, elf_rela);300 DEFINE_ELF_TYPE(Verdef, elf_verdef);301 DEFINE_ELF_TYPE(Verdaux, elf_verdaux);302 DEFINE_ELF_TYPE(Verneed, elf_verneed);303 DEFINE_ELF_TYPE(Vernaux, elf_vernaux);304 305 #undef DEFINE_ELF_TYPE306 #undef _ELF_TYPE307 308 typedef uint16 elf_versym;309 310 #if B_HAIKU_64_BIT311 # define ELF_CLASS ELFCLASS64312 #else313 # define ELF_CLASS ELFCLASS32314 #endif315 316 317 #endif /* _ELF_COMMON_H_ */ -
new file headers/private/system/elf_private.h
diff --git a/headers/private/system/elf_private.h b/headers/private/system/elf_private.h new file mode 100644 index 0000000..5e9d79b
- + 1 /* 2 * Copyright 2002-2015 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Copyright 2001 Travis Geiselbrecht. All rights reserved. 6 * Distributed under the terms of the NewOS License. 7 */ 8 #ifndef _ELF_COMMON_H 9 #define _ELF_COMMON_H 10 11 12 #include <os/kernel/elf.h> 13 14 #include <SupportDefs.h> 15 16 #include <arch_elf.h> 17 18 19 // Determine the correct ELF types to use for the architecture 20 21 #if B_HAIKU_64_BIT 22 # define _ELF_TYPE(type) Elf64_##type 23 #else 24 # define _ELF_TYPE(type) Elf32_##type 25 #endif 26 #define DEFINE_ELF_TYPE(type, name) \ 27 typedef _ELF_TYPE(type) name 28 29 DEFINE_ELF_TYPE(Ehdr, elf_ehdr); 30 DEFINE_ELF_TYPE(Phdr, elf_phdr); 31 DEFINE_ELF_TYPE(Shdr, elf_shdr); 32 DEFINE_ELF_TYPE(Sym, elf_sym); 33 DEFINE_ELF_TYPE(Dyn, elf_dyn); 34 DEFINE_ELF_TYPE(Rel, elf_rel); 35 DEFINE_ELF_TYPE(Rela, elf_rela); 36 DEFINE_ELF_TYPE(Verdef, elf_verdef); 37 DEFINE_ELF_TYPE(Verdaux, elf_verdaux); 38 DEFINE_ELF_TYPE(Verneed, elf_verneed); 39 DEFINE_ELF_TYPE(Vernaux, elf_vernaux); 40 41 #undef DEFINE_ELF_TYPE 42 #undef _ELF_TYPE 43 44 typedef uint16 elf_versym; 45 46 #if B_HAIKU_64_BIT 47 # define ELF_CLASS ELFCLASS64 48 #else 49 # define ELF_CLASS ELFCLASS32 50 #endif 51 52 53 #endif /* _ELF_COMMON_H_ */ -
headers/private/system/syscalls.h
diff --git a/headers/private/system/syscalls.h b/headers/private/system/syscalls.h index d89dff7..f71fb3d 100644
a b 8 8 9 9 #include <arch_config.h> 10 10 #include <DiskDeviceDefs.h> 11 #include <elf_ common.h>11 #include <elf_private.h> 12 12 #include <image.h> 13 13 #include <OS.h> 14 14 -
src/apps/debugger/elf/ElfFile.cpp
diff --git a/src/apps/debugger/elf/ElfFile.cpp b/src/apps/debugger/elf/ElfFile.cpp index bbe6d1c..d950f45 100644
a b ElfFile::_CheckElfHeader(Elf32_Ehdr& elfHeader) 356 356 && elfHeader.e_ident[4] == ELFCLASS32 357 357 && elfHeader.e_shoff > 0 358 358 && elfHeader.e_shnum > 0 359 && elfHeader.e_shentsize >= sizeof( structElf32_Shdr)359 && elfHeader.e_shentsize >= sizeof(Elf32_Shdr) 360 360 && elfHeader.e_shstrndx != SHN_UNDEF 361 361 && elfHeader.e_shstrndx < elfHeader.e_shnum 362 362 && elfHeader.e_phoff > 0 363 363 && elfHeader.e_phnum > 0 364 && elfHeader.e_phentsize >= sizeof( structElf32_Phdr);364 && elfHeader.e_phentsize >= sizeof(Elf32_Phdr); 365 365 } 366 366 367 367 … … ElfFile::_CheckElfHeader(Elf64_Ehdr& elfHeader) 372 372 && elfHeader.e_ident[4] == ELFCLASS64 373 373 && elfHeader.e_shoff > 0 374 374 && elfHeader.e_shnum > 0 375 && elfHeader.e_shentsize >= sizeof( structElf64_Shdr)375 && elfHeader.e_shentsize >= sizeof(Elf64_Shdr) 376 376 && elfHeader.e_shstrndx != SHN_UNDEF 377 377 && elfHeader.e_shstrndx < elfHeader.e_shnum 378 378 && elfHeader.e_phoff > 0 379 379 && elfHeader.e_phnum > 0 380 && elfHeader.e_phentsize >= sizeof( structElf64_Phdr);380 && elfHeader.e_phentsize >= sizeof(Elf64_Phdr); 381 381 } -
src/apps/debugger/elf/ElfFile.h
diff --git a/src/apps/debugger/elf/ElfFile.h b/src/apps/debugger/elf/ElfFile.h index b506943..e4c6ab0 100644
a b 9 9 10 10 #include <SupportDefs.h> 11 11 12 #include <elf32.h> 13 #include <elf64.h> 12 #include <elf_private.h> 14 13 #include <util/DoublyLinkedList.h> 15 14 16 15 #include "Types.h" -
src/kits/debug/Image.h
diff --git a/src/kits/debug/Image.h b/src/kits/debug/Image.h index 2d5cbbe..1472bcb 100644
a b 8 8 9 9 #include <stdio.h> 10 10 11 #include <elf_ common.h>11 #include <elf_private.h> 12 12 #include <image.h> 13 13 #include <OS.h> 14 14 -
src/system/boot/loader/elf.cpp
diff --git a/src/system/boot/loader/elf.cpp b/src/system/boot/loader/elf.cpp index 266fec8..f77ebe2 100644
a b 11 11 #include <boot/platform.h> 12 12 #include <boot/stage2.h> 13 13 #include <driver_settings.h> 14 #include <elf 32.h>14 #include <elf_private.h> 15 15 #include <kernel.h> 16 16 #include <SupportDefs.h> 17 17 … … elf_relocate_image(preloaded_image* image) 710 710 711 711 712 712 status_t 713 boot_elf_resolve_symbol(preloaded_elf32_image* image, structElf32_Sym* symbol,713 boot_elf_resolve_symbol(preloaded_elf32_image* image, Elf32_Sym* symbol, 714 714 Elf32_Addr* symbolAddress) 715 715 { 716 716 return ELF32Loader::Resolve(image, symbol, symbolAddress); … … boot_elf_resolve_symbol(preloaded_elf32_image* image, struct Elf32_Sym* symbol, 719 719 720 720 #ifdef BOOT_SUPPORT_ELF64 721 721 status_t 722 boot_elf_resolve_symbol(preloaded_elf64_image* image, structElf64_Sym* symbol,722 boot_elf_resolve_symbol(preloaded_elf64_image* image, Elf64_Sym* symbol, 723 723 Elf64_Addr* symbolAddress) 724 724 { 725 725 return ELF64Loader::Resolve(image, symbol, symbolAddress); -
src/system/kernel/arch/arm/arch_elf.cpp
diff --git a/src/system/kernel/arch/arm/arch_elf.cpp b/src/system/kernel/arch/arm/arch_elf.cpp index 62fc17e..f19ab0e 100644
a b is_in_image(struct elf_image_info *image, addr_t address) 164 164 165 165 #ifdef _BOOT_MODE 166 166 status_t 167 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, 168 struct Elf32_Rel *rel,int relLength)167 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, Elf32_Rel *rel, 168 int relLength) 169 169 #else 170 170 int 171 171 arch_elf_relocate_rel(struct elf_image_info *image, 172 struct elf_image_info *resolveImage, structElf32_Rel *rel, int relLength)172 struct elf_image_info *resolveImage, Elf32_Rel *rel, int relLength) 173 173 #endif 174 174 { 175 175 addr_t S; … … arch_elf_relocate_rel(struct elf_image_info *image, 181 181 182 182 S = A = P = 0; 183 183 184 for (i = 0; i * (int)sizeof( structElf32_Rel) < relLength; i++) {184 for (i = 0; i * (int)sizeof(Elf32_Rel) < relLength; i++) { 185 185 TRACE(("looking at rel type %s, offset 0x%lx\n", 186 186 kRelocations[ELF32_R_TYPE(rel[i].r_info)], rel[i].r_offset)); 187 187 … … arch_elf_relocate_rel(struct elf_image_info *image, 191 191 case R_ARM_GLOB_DAT: 192 192 case R_ARM_ABS32: 193 193 { 194 structElf32_Sym *symbol;194 Elf32_Sym *symbol; 195 195 status_t status; 196 196 197 197 symbol = SYMBOL(image, ELF32_R_SYM(rel[i].r_info)); … … write_8_check(addr_t P, Elf32_Word value) 309 309 #ifdef _BOOT_MODE 310 310 status_t 311 311 boot_arch_elf_relocate_rela(struct preloaded_elf32_image *image, 312 structElf32_Rela *rel, int rel_len)312 Elf32_Rela *rel, int rel_len) 313 313 #else 314 314 int 315 315 arch_elf_relocate_rela(struct elf_image_info *image, 316 struct elf_image_info *resolve_image, structElf32_Rela *rel, int rel_len)316 struct elf_image_info *resolve_image, Elf32_Rela *rel, int rel_len) 317 317 #endif 318 318 { 319 319 int i; 320 structElf32_Sym *sym;320 Elf32_Sym *sym; 321 321 int vlErr; 322 322 addr_t S = 0; // symbol address 323 323 addr_t R = 0; // section relative symbol address … … arch_elf_relocate_rela(struct elf_image_info *image, 345 345 return B_ERROR; \ 346 346 } 347 347 348 for (i = 0; i * (int)sizeof( structElf32_Rela) < rel_len; i++) {348 for (i = 0; i * (int)sizeof(Elf32_Rela) < rel_len; i++) { 349 349 #if CHATTY 350 350 dprintf("looking at rel type %d, offset 0x%lx, " 351 351 "sym 0x%lx, addend 0x%lx\n", ELF32_R_TYPE(rel[i].r_info), -
src/system/kernel/arch/m68k/arch_elf.cpp
diff --git a/src/system/kernel/arch/m68k/arch_elf.cpp b/src/system/kernel/arch/m68k/arch_elf.cpp index 2251f03..2a53554 100644
a b static const char *kRelocations[] = { 76 76 77 77 #ifdef _BOOT_MODE 78 78 status_t 79 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, 80 struct Elf32_Rel *rel,int rel_len)79 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, Elf32_Rel *rel, 80 int rel_len) 81 81 #else 82 82 int 83 83 arch_elf_relocate_rel(struct elf_image_info *image, 84 struct elf_image_info *resolve_image, structElf32_Rel *rel, int rel_len)84 struct elf_image_info *resolve_image, Elf32_Rel *rel, int rel_len) 85 85 #endif 86 86 { 87 87 // there are no rel entries in M68K elf … … write_8_check(addr_t P, Elf32_Word value) 138 138 #ifdef _BOOT_MODE 139 139 status_t 140 140 boot_arch_elf_relocate_rela(struct preloaded_elf32_image *image, 141 structElf32_Rela *rel, int rel_len)141 Elf32_Rela *rel, int rel_len) 142 142 #else 143 143 int 144 144 arch_elf_relocate_rela(struct elf_image_info *image, 145 struct elf_image_info *resolve_image, structElf32_Rela *rel, int rel_len)145 struct elf_image_info *resolve_image, Elf32_Rela *rel, int rel_len) 146 146 #endif 147 147 { 148 148 int i; 149 structElf32_Sym *sym;149 Elf32_Sym *sym; 150 150 int vlErr; 151 151 addr_t S = 0; // symbol address 152 152 addr_t R = 0; // section relative symbol address … … arch_elf_relocate_rela(struct elf_image_info *image, 172 172 return B_ERROR; \ 173 173 } 174 174 175 for (i = 0; i * (int)sizeof( structElf32_Rela) < rel_len; i++) {175 for (i = 0; i * (int)sizeof(Elf32_Rela) < rel_len; i++) { 176 176 #if CHATTY 177 177 dprintf("looking at rel type %d, offset 0x%lx, sym 0x%lx, addend 0x%lx\n", 178 178 ELF32_R_TYPE(rel[i].r_info), rel[i].r_offset, ELF32_R_SYM(rel[i].r_info), rel[i].r_addend); -
src/system/kernel/arch/ppc/arch_elf.cpp
diff --git a/src/system/kernel/arch/ppc/arch_elf.cpp b/src/system/kernel/arch/ppc/arch_elf.cpp index 75f6728..47c25a2 100644
a b 21 21 22 22 #ifdef _BOOT_MODE 23 23 status_t 24 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, 25 struct Elf32_Rel *rel,int rel_len)24 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, Elf32_Rel *rel, 25 int rel_len) 26 26 #else 27 27 int 28 28 arch_elf_relocate_rel(struct elf_image_info *image, 29 struct elf_image_info *resolve_image, structElf32_Rel *rel, int rel_len)29 struct elf_image_info *resolve_image, Elf32_Rel *rel, int rel_len) 30 30 #endif 31 31 { 32 32 // there are no rel entries in PPC elf … … ha(Elf32_Word value) 116 116 #ifdef _BOOT_MODE 117 117 status_t 118 118 boot_arch_elf_relocate_rela(struct preloaded_elf32_image *image, 119 structElf32_Rela *rel, int rel_len)119 Elf32_Rela *rel, int rel_len) 120 120 #else 121 121 int 122 122 arch_elf_relocate_rela(struct elf_image_info *image, 123 struct elf_image_info *resolve_image, structElf32_Rela *rel, int rel_len)123 struct elf_image_info *resolve_image, Elf32_Rela *rel, int rel_len) 124 124 #endif 125 125 { 126 126 int i; 127 structElf32_Sym *sym;127 Elf32_Sym *sym; 128 128 int vlErr; 129 129 addr_t S = 0; // symbol address 130 130 addr_t R = 0; // section relative symbol address … … arch_elf_relocate_rela(struct elf_image_info *image, 150 150 return B_ERROR; \ 151 151 } 152 152 153 for (i = 0; i * (int)sizeof( structElf32_Rela) < rel_len; i++) {153 for (i = 0; i * (int)sizeof(Elf32_Rela) < rel_len; i++) { 154 154 #if CHATTY 155 155 dprintf("looking at rel type %d, offset 0x%lx, sym 0x%lx, addend 0x%lx\n", 156 156 ELF32_R_TYPE(rel[i].r_info), rel[i].r_offset, ELF32_R_SYM(rel[i].r_info), rel[i].r_addend); -
src/system/kernel/arch/x86/arch_elf.cpp
diff --git a/src/system/kernel/arch/x86/arch_elf.cpp b/src/system/kernel/arch/x86/arch_elf.cpp index 111329a..eef0c8c 100644
a b static const char *kRelocations[] = { 59 59 60 60 #ifdef _BOOT_MODE 61 61 status_t 62 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, 63 struct Elf32_Rel *rel,int relLength)62 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, Elf32_Rel *rel, 63 int relLength) 64 64 #else 65 65 int 66 66 arch_elf_relocate_rel(struct elf_image_info *image, 67 struct elf_image_info *resolveImage, structElf32_Rel *rel, int relLength)67 struct elf_image_info *resolveImage, Elf32_Rel *rel, int relLength) 68 68 #endif 69 69 { 70 70 addr_t S; … … arch_elf_relocate_rel(struct elf_image_info *image, 76 76 77 77 S = A = P = 0; 78 78 79 for (i = 0; i * (int)sizeof( structElf32_Rel) < relLength; i++) {79 for (i = 0; i * (int)sizeof(Elf32_Rel) < relLength; i++) { 80 80 TRACE(("looking at rel type %s, offset 0x%lx\n", 81 81 kRelocations[ELF32_R_TYPE(rel[i].r_info)], rel[i].r_offset)); 82 82 … … arch_elf_relocate_rel(struct elf_image_info *image, 88 88 case R_386_JMP_SLOT: 89 89 case R_386_GOTOFF: 90 90 { 91 structElf32_Sym *symbol;91 Elf32_Sym *symbol; 92 92 status_t status; 93 93 94 94 symbol = SYMBOL(image, ELF32_R_SYM(rel[i].r_info)); … … arch_elf_relocate_rel(struct elf_image_info *image, 171 171 #ifdef _BOOT_MODE 172 172 status_t 173 173 boot_arch_elf_relocate_rela(struct preloaded_elf32_image *image, 174 structElf32_Rela *rel, int relLength)174 Elf32_Rela *rel, int relLength) 175 175 #else 176 176 int 177 177 arch_elf_relocate_rela(struct elf_image_info *image, 178 struct elf_image_info *resolveImage, structElf32_Rela *rel, int relLength)178 struct elf_image_info *resolveImage, Elf32_Rela *rel, int relLength) 179 179 #endif 180 180 { 181 181 dprintf("arch_elf_relocate_rela: not supported on x86\n"); -
src/system/runtime_loader/arch/m68k/arch_relocate.cpp
diff --git a/src/system/runtime_loader/arch/m68k/arch_relocate.cpp b/src/system/runtime_loader/arch/m68k/arch_relocate.cpp index 7b24c6d..ae8510e 100644
a b write_8_check(addr_t *P, Elf32_Word value) 72 72 73 73 74 74 static int 75 relocate_rela(image_t *rootImage, image_t *image, struct Elf32_Rela *rel,76 int rel_len,SymbolLookupCache* cache)75 relocate_rela(image_t *rootImage, image_t *image, Elf32_Rela *rel, int rel_len, 76 SymbolLookupCache* cache) 77 77 { 78 78 int i; 79 79 addr_t S; … … relocate_rela(image_t *rootImage, image_t *image, struct Elf32_Rela *rel, 84 84 #define A ((addr_t)rel[i].r_addend) 85 85 # define B (image->regions[0].delta) 86 86 87 for (i = 0; i * (int)sizeof( structElf32_Rel) < rel_len; i++) {87 for (i = 0; i * (int)sizeof(Elf32_Rel) < rel_len; i++) { 88 88 unsigned type = ELF32_R_TYPE(rel[i].r_info); 89 89 90 90 switch (type) { … … relocate_rela(image_t *rootImage, image_t *image, struct Elf32_Rela *rel, 97 97 case R_68K_GLOB_DAT: 98 98 case R_68K_JMP_SLOT: 99 99 { 100 structElf32_Sym *sym;100 Elf32_Sym *sym; 101 101 status_t status; 102 102 sym = SYMBOL(image, ELF32_R_SYM(rel[i].r_info)); 103 103 … … arch_relocate_image(image_t *rootImage, image_t *image, 303 303 //TRACE(("RELA relocations not supported\n")); 304 304 //return EOPNOTSUPP; 305 305 306 //for (i = 1; i * (int)sizeof( structElf32_Rela) < image->rela_len; i++) {306 //for (i = 1; i * (int)sizeof(Elf32_Rela) < image->rela_len; i++) { 307 307 // printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info)); 308 308 //} 309 309 } -
src/system/runtime_loader/arch/ppc/arch_relocate.cpp
diff --git a/src/system/runtime_loader/arch/ppc/arch_relocate.cpp b/src/system/runtime_loader/arch/ppc/arch_relocate.cpp index 6803697..c6cf798 100644
a b 21 21 22 22 23 23 static int 24 relocate_rel(image_t *rootImage, image_t *image, struct Elf32_Rel *rel,25 int rel_len,SymbolLookupCache* cache)24 relocate_rel(image_t *rootImage, image_t *image, Elf32_Rel *rel, int rel_len, 25 SymbolLookupCache* cache) 26 26 { 27 27 // ToDo: implement me! 28 28 … … arch_relocate_image(image_t *rootImage, image_t *image, 56 56 printf("RELA relocations not supported\n"); 57 57 return EOPNOTSUPP; 58 58 59 //for (i = 1; i * (int)sizeof( structElf32_Rela) < image->rela_len; i++) {59 //for (i = 1; i * (int)sizeof(Elf32_Rela) < image->rela_len; i++) { 60 60 // printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info)); 61 61 //} 62 62 } -
src/system/runtime_loader/arch/x86/arch_relocate.cpp
diff --git a/src/system/runtime_loader/arch/x86/arch_relocate.cpp b/src/system/runtime_loader/arch/x86/arch_relocate.cpp index d47f3af..1e6ac1f 100644
a b 18 18 19 19 20 20 static int 21 relocate_rel(image_t *rootImage, image_t *image, struct Elf32_Rel *rel,22 int rel_len,SymbolLookupCache* cache)21 relocate_rel(image_t *rootImage, image_t *image, Elf32_Rel *rel, int rel_len, 22 SymbolLookupCache* cache) 23 23 { 24 24 int i; 25 25 addr_t S; … … relocate_rel(image_t *rootImage, image_t *image, struct Elf32_Rel *rel, 29 29 # define A (*(P)) 30 30 # define B (image->regions[0].delta) 31 31 32 for (i = 0; i * (int)sizeof( structElf32_Rel) < rel_len; i++) {32 for (i = 0; i * (int)sizeof(Elf32_Rel) < rel_len; i++) { 33 33 unsigned type = ELF32_R_TYPE(rel[i].r_info); 34 34 unsigned symbolIndex = ELF32_R_SYM(rel[i].r_info); 35 35 … … arch_relocate_image(image_t* rootImage, image_t* image, 133 133 TRACE(("RELA relocations not supported\n")); 134 134 return EOPNOTSUPP; 135 135 136 //for (i = 1; i * (int)sizeof( structElf32_Rela) < image->rela_len; i++) {136 //for (i = 1; i * (int)sizeof(Elf32_Rela) < image->rela_len; i++) { 137 137 // printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info)); 138 138 //} 139 139 } -
src/tests/system/boot/loader/platform_misc.cpp
diff --git a/src/tests/system/boot/loader/platform_misc.cpp b/src/tests/system/boot/loader/platform_misc.cpp index d4b6699..7a48116 100644
a b platform_switch_to_text_mode(void) 40 40 41 41 42 42 extern "C" status_t 43 boot_arch_elf_relocate_rel(struct preloaded_image *image, 44 struct Elf32_Rel *rel,int rel_len)43 boot_arch_elf_relocate_rel(struct preloaded_image *image, Elf32_Rel *rel, 44 int rel_len) 45 45 { 46 46 return B_ERROR; 47 47 } 48 48 49 49 50 50 extern "C" status_t 51 boot_arch_elf_relocate_rela(struct preloaded_image *image, 52 struct Elf32_Rela *rel,int rel_len)51 boot_arch_elf_relocate_rela(struct preloaded_image *image, Elf32_Rela *rel, 52 int rel_len) 53 53 { 54 54 return B_ERROR; 55 55 }