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 simonsouth, 9 years ago)

Haiku: Build using public and private ELF header files

  • 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  
    66#define _KERNEL_ARCH_ELF_H
    77
    88
    9 #include <elf_common.h>
     9#include <elf_private.h>
    1010
    1111
    1212struct 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  
    1313/* ELF support */
    1414
    1515extern status_t boot_arch_elf_relocate_rel(preloaded_elf32_image* image,
    16     struct Elf32_Rel* rel, int rel_len);
     16    Elf32_Rel* rel, int rel_len);
    1717extern status_t boot_arch_elf_relocate_rel(preloaded_elf64_image* image,
    18     struct Elf64_Rel* rel, int rel_len);
     18    Elf64_Rel* rel, int rel_len);
    1919extern status_t boot_arch_elf_relocate_rela(preloaded_elf32_image* image,
    20     struct Elf32_Rela* rel, int rel_len);
     20    Elf32_Rela* rel, int rel_len);
    2121extern status_t boot_arch_elf_relocate_rela(preloaded_elf64_image* image,
    22     struct Elf64_Rela* rel, int rel_len);
     22    Elf64_Rela* rel, int rel_len);
    2323
    2424
    2525#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;  
    8787
    8888#ifdef _BOOT_MODE
    8989extern status_t boot_elf_resolve_symbol(preloaded_elf32_image* image,
    90     struct Elf32_Sym* symbol, Elf32_Addr* symbolAddress);
     90    Elf32_Sym* symbol, Elf32_Addr* symbolAddress);
    9191extern status_t boot_elf_resolve_symbol(preloaded_elf64_image* image,
    92     struct Elf64_Sym* symbol, Elf64_Addr* symbolAddress);
     92    Elf64_Sym* symbol, Elf64_Addr* symbolAddress);
    9393extern void boot_elf64_set_relocation(Elf64_Addr resolveAddress,
    9494    Elf64_Addr finalAddress);
    9595#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  
    99#define _KERNEL_ELF_H
    1010
    1111
    12 #include <elf_common.h>
     12#include <elf_private.h>
    1313#include <thread.h>
    1414#include <image.h>
    1515
  • 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  
    99#define _KERNEL_ELF_PRIV_H
    1010
    1111
    12 #include <elf32.h>
    13 #include <elf64.h>
     12#include <elf_private.h>
     13
    1414#include <image.h>
    1515
    1616
  • 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  
    1111#ifndef _RUNTIME_LOADER_H
    1212#define _RUNTIME_LOADER_H
    1313
     14
    1415#include <image.h>
    1516#include <OS.h>
    1617
    17 #include <elf32.h>
    18 #include <elf64.h>
     18#include <elf_private.h>
    1919
    2020
    2121// #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_H
    9 #define _ELF32_H
    10 
    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 __cplusplus
    42     bool IsHostEndian() const;
    43 #endif
    44 };
    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 __cplusplus
    76     bool IsReadWrite() const;
    77     bool IsExecutable() const;
    78 #endif
    79 };
    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 __cplusplus
    90     uint8 Bind() const;
    91     uint8 Type() const;
    92     void SetInfo(uint8 bind, uint8 type);
    93 #endif
    94 };
    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 __cplusplus
    105     uint8 SymbolIndex() const;
    106     uint8 Type() const;
    107 #endif
    108 };
    109 
    110 #ifdef __cplusplus
    111 struct Elf32_Rela : public Elf32_Rel {
    112 #else
    113 struct Elf32_Rela {
    114     Elf32_Addr r_offset;
    115     Elf32_Word r_info;
    116 #endif
    117     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 the
    139                                    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 dependency
    151                                    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 this
    162                                    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 symbol
    174                                    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 __cplusplus
    183 
    184 inline bool
    185 Elf32_Ehdr::IsHostEndian() const
    186 {
    187 #if B_HOST_IS_LENDIAN
    188     return e_ident[EI_DATA] == ELFDATA2LSB;
    189 #elif B_HOST_IS_BENDIAN
    190     return e_ident[EI_DATA] == ELFDATA2MSB;
    191 #endif
    192 }
    193 
    194 
    195 inline bool
    196 Elf32_Phdr::IsReadWrite() const
    197 {
    198     return !(~p_flags & (PF_READ | PF_WRITE));
    199 }
    200 
    201 
    202 inline bool
    203 Elf32_Phdr::IsExecutable() const
    204 {
    205     return (p_flags & PF_EXECUTE) != 0;
    206 }
    207 
    208 
    209 inline uint8
    210 Elf32_Sym::Bind() const
    211 {
    212     return ELF32_ST_BIND(st_info);
    213 }
    214 
    215 
    216 inline uint8
    217 Elf32_Sym::Type() const
    218 {
    219     return ELF32_ST_TYPE(st_info);
    220 }
    221 
    222 inline void
    223 Elf32_Sym::SetInfo(uint8 bind, uint8 type)
    224 {
    225     st_info = ELF32_ST_INFO(bind, type);
    226 }
    227 
    228 inline uint8
    229 Elf32_Rel::SymbolIndex() const
    230 {
    231     return ELF32_R_SYM(r_info);
    232 }
    233 
    234 
    235 inline uint8
    236 Elf32_Rel::Type() const
    237 {
    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_H
    9 #define _ELF64_H
    10 
    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 __cplusplus
    44     bool IsHostEndian() const;
    45 #endif
    46 };
    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 __cplusplus
    78     bool IsReadWrite() const;
    79     bool IsExecutable() const;
    80 #endif
    81 };
    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 __cplusplus
    92     uint8 Bind() const;
    93     uint8 Type() const;
    94     void SetInfo(uint8 bind, uint8 type);
    95 #endif
    96 };
    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 __cplusplus
    107     uint8 SymbolIndex() const;
    108     uint8 Type() const;
    109 #endif
    110 };
    111 
    112 #ifdef __cplusplus
    113 struct Elf64_Rela : public Elf64_Rel {
    114 #else
    115 struct Elf64_Rela {
    116     Elf64_Addr      r_offset;
    117     Elf64_Xword     r_info;
    118 #endif
    119     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 the
    141                                    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 dependency
    153                                    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 this
    164                                    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 symbol
    176                                    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 __cplusplus
    185 
    186 inline bool
    187 Elf64_Ehdr::IsHostEndian() const
    188 {
    189 #if B_HOST_IS_LENDIAN
    190     return e_ident[EI_DATA] == ELFDATA2LSB;
    191 #elif B_HOST_IS_BENDIAN
    192     return e_ident[EI_DATA] == ELFDATA2MSB;
    193 #endif
    194 }
    195 
    196 
    197 inline bool
    198 Elf64_Phdr::IsReadWrite() const
    199 {
    200     return !(~p_flags & (PF_READ | PF_WRITE));
    201 }
    202 
    203 
    204 inline bool
    205 Elf64_Phdr::IsExecutable() const
    206 {
    207     return (p_flags & PF_EXECUTE) != 0;
    208 }
    209 
    210 
    211 inline uint8
    212 Elf64_Sym::Bind() const
    213 {
    214     return ELF64_ST_BIND(st_info);
    215 }
    216 
    217 
    218 inline uint8
    219 Elf64_Sym::Type() const
    220 {
    221     return ELF64_ST_TYPE(st_info);
    222 }
    223 
    224 
    225 inline void
    226 Elf64_Sym::SetInfo(uint8 bind, uint8 type)
    227 {
    228     st_info = ELF64_ST_INFO(bind, type);
    229 }
    230 
    231 
    232 inline uint8
    233 Elf64_Rel::SymbolIndex() const
    234 {
    235     return ELF64_R_SYM(r_info);
    236 }
    237 
    238 
    239 inline uint8
    240 Elf64_Rel::Type() const
    241 {
    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_H
    9 #define _ELF_COMMON_H
    10 
    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   16
    21 
    22 #define ELF_MAGIC   "\x7f""ELF"
    23 
    24 // e_ident[] indices
    25 #define EI_MAG0     0
    26 #define EI_MAG1     1
    27 #define EI_MAG2     2
    28 #define EI_MAG3     3
    29 #define EI_CLASS    4
    30 #define EI_DATA     5
    31 #define EI_VERSION  6
    32 #define EI_PAD      7
    33 
    34 // e_type (Object file type)
    35 #define ET_NONE         0 // No file type
    36 #define ET_REL          1 // Relocatable file
    37 #define ET_EXEC         2 // Executable file
    38 #define ET_DYN          3 // Shared object file
    39 #define ET_CORE         4 // Core file
    40 #define ET_LOOS         0xfe00 // OS-specific range start
    41 #define ET_HIOS         0xfeff // OS-specific range end
    42 #define ET_LOPROC       0xff00 // Processor-specific range start
    43 #define ET_HIPROC       0xffff // Processor-specific range end
    44 
    45 // e_machine (Architecture)
    46 #define EM_NONE         0 // No machine
    47 #define EM_M32          1 // AT&T WE 32100
    48 #define EM_SPARC        2 // Sparc
    49 #define EM_386          3 // Intel 80386
    50 #define EM_68K          4 // Motorola m68k family
    51 #define EM_88K          5 // Motorola m88k family
    52 #define EM_486          6 // Intel 80486, Reserved for future use
    53 #define EM_860          7 // Intel 80860
    54 #define EM_MIPS         8 // MIPS R3000 (officially, big-endian only)
    55 #define EM_S370         9 // IBM System/370
    56 #define EM_MIPS_RS3_LE  10 // MIPS R3000 little-endian, Deprecated
    57 #define EM_PARISC       15 // HPPA
    58 #define EM_VPP550       17 // Fujitsu VPP500
    59 #define EM_SPARC32PLUS  18 // Sun "v8plus"
    60 #define EM_960          19 // Intel 80960
    61 #define EM_PPC          20 // PowerPC
    62 #define EM_PPC64        21 // 64-bit PowerPC
    63 #define EM_S390         22 // IBM S/390
    64 #define EM_V800         36 // NEC V800 series
    65 #define EM_FR20         37 // Fujitsu FR20
    66 #define EM_RH32         38 // TRW RH32
    67 #define EM_MCORE        39 // Motorola M*Core
    68 #define EM_RCE          39 // Old name for MCore
    69 #define EM_ARM          40 // ARM
    70 #define EM_OLD_ALPHA    41 // Digital Alpha
    71 #define EM_SH           42 // Renesas / SuperH SH
    72 #define EM_SPARCV9      43 // SPARC v9 64-bit
    73 #define EM_TRICORE      44 // Siemens Tricore embedded processor
    74 #define EM_ARC          45 // ARC Cores
    75 #define EM_H8_300       46 // Renesas H8/300
    76 #define EM_H8_300H      47 // Renesas H8/300H
    77 #define EM_H8S          48 // Renesas H8S
    78 #define EM_H8_500       49 // Renesas H8/500
    79 #define EM_IA_64        50 // Intel IA-64 Processor
    80 #define EM_MIPS_X       51 // Stanford MIPS-X
    81 #define EM_COLDFIRE     52 // Motorola Coldfire
    82 #define EM_68HC12       53 // Motorola M68HC12
    83 #define EM_MMA          54 // Fujitsu Multimedia Accelerator
    84 #define EM_PCP          55 // Siemens PCP
    85 #define EM_NCPU         56 // Sony nCPU embedded RISC processor
    86 #define EM_NDR1         57 // Denso NDR1 microprocesspr
    87 #define EM_STARCORE     58 // Motorola Star*Core processor
    88 #define EM_ME16         59 // Toyota ME16 processor
    89 #define EM_ST100        60 // STMicroelectronics ST100 processor
    90 #define EM_TINYJ        61 // Advanced Logic Corp. TinyJ embedded processor
    91 #define EM_X86_64       62 // Advanced Micro Devices X86-64 processor
    92 
    93 // architecture class (EI_CLASS)
    94 #define ELFCLASS32  1
    95 #define ELFCLASS64  2
    96 // endian (EI_DATA)
    97 #define ELFDATA2LSB 1   /* little endian */
    98 #define ELFDATA2MSB 2   /* big endian */
    99 
    100 
    101 /*** section header ***/
    102 
    103 // special section indices
    104 #define SHN_UNDEF       0
    105 #define SHN_LORESERVE   0xff00
    106 #define SHN_LOPROC      0xff00
    107 #define SHN_HIPROC      0xff1f
    108 #define SHN_ABS         0xfff1
    109 #define SHN_COMMON      0xfff2
    110 #define SHN_HIRESERVE   0xffff
    111 
    112 // section header type
    113 #define SHT_NULL        0
    114 #define SHT_PROGBITS    1
    115 #define SHT_SYMTAB      2
    116 #define SHT_STRTAB      3
    117 #define SHT_RELA        4
    118 #define SHT_HASH        5
    119 #define SHT_DYNAMIC     6
    120 #define SHT_NOTE        7
    121 #define SHT_NOBITS      8
    122 #define SHT_REL         9
    123 #define SHT_SHLIB       10
    124 #define SHT_DYNSYM      11
    125 
    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      0x70000000
    131 #define SHT_HIPROC      0x7fffffff
    132 #define SHT_LOUSER      0x80000000
    133 #define SHT_HIUSER      0xffffffff
    134 
    135 // section header flags
    136 #define SHF_WRITE       1
    137 #define SHF_ALLOC       2
    138 #define SHF_EXECINSTR   4
    139 
    140 #define SHF_MASKPROC    0xf0000000
    141 
    142 
    143 /*** program header ***/
    144 
    145 // program header segment types
    146 #define PT_NULL         0
    147 #define PT_LOAD         1
    148 #define PT_DYNAMIC      2
    149 #define PT_INTERP       3
    150 #define PT_NOTE         4
    151 #define PT_SHLIB        5
    152 #define PT_PHDR         6
    153 #define PT_TLS          7
    154 #define PT_STACK        0x6474e551
    155 #define PT_RELRO        0x6474e552
    156 
    157 #define PT_LOPROC       0x70000000
    158 #define PT_ARM_UNWIND   0x70000001
    159 #define PT_HIPROC       0x7fffffff
    160 
    161 
    162 // program header segment flags
    163 #define PF_EXECUTE  0x1
    164 #define PF_WRITE    0x2
    165 #define PF_READ     0x4
    166 #define PF_PROTECTION_MASK (PF_EXECUTE | PF_WRITE | PF_READ)
    167 
    168 #define PF_MASKPROC 0xf0000000
    169 
    170 #define STT_NOTYPE 0
    171 #define STT_OBJECT 1
    172 #define STT_FUNC 2
    173 #define STT_SECTION 3
    174 #define STT_FILE 4
    175 #define STT_TLS     6
    176 #define STT_LOPROC 13
    177 #define STT_HIPROC 15
    178 
    179 #define STB_LOCAL 0
    180 #define STB_GLOBAL 1
    181 #define STB_WEAK 2
    182 #define STB_LOPROC 13
    183 #define STB_HIPROC 15
    184 
    185 #define STN_UNDEF 0
    186 
    187 
    188 #define DT_NULL             0
    189 #define DT_NEEDED           1
    190 #define DT_PLTRELSZ         2
    191 #define DT_PLTGOT           3
    192 #define DT_HASH             4
    193 #define DT_STRTAB           5
    194 #define DT_SYMTAB           6
    195 #define DT_RELA             7
    196 #define DT_RELASZ           8
    197 #define DT_RELAENT          9
    198 #define DT_STRSZ            10
    199 #define DT_SYMENT           11
    200 #define DT_INIT             12
    201 #define DT_FINI             13
    202 #define DT_SONAME           14
    203 #define DT_RPATH            15
    204 #define DT_SYMBOLIC         16
    205 #define DT_REL              17
    206 #define DT_RELSZ            18
    207 #define DT_RELENT           19
    208 #define DT_PLTREL           20
    209 #define DT_DEBUG            21
    210 #define DT_TEXTREL          22
    211 #define DT_JMPREL           23
    212 #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         32
    220 #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       0x70000000
    230 #define DT_HIPROC       0x7fffffff
    231 
    232 
    233 /* DT_FLAGS values */
    234 #define DF_ORIGIN       0x01
    235 #define DF_SYMBOLIC     0x02
    236 #define DF_TEXTREL      0x04
    237 #define DF_BIND_NOW     0x08
    238 #define DF_STATIC_TLS   0x10
    239 
    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 given
    256                                        to symbols when a library becomes
    257                                        versioned; handled by the linker (and
    258                                        runtime loader) similar to
    259                                        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 architecture
    283 
    284 #if B_HAIKU_64_BIT
    285 #   define _ELF_TYPE(type)  Elf64_##type
    286 #else
    287 #   define _ELF_TYPE(type)  Elf32_##type
    288 #endif
    289 #define DEFINE_ELF_TYPE(type, name) \
    290     struct _ELF_TYPE(type); \
    291     typedef struct _ELF_TYPE(type) name
    292 
    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_TYPE
    306 #undef _ELF_TYPE
    307 
    308 typedef uint16 elf_versym;
    309 
    310 #if B_HAIKU_64_BIT
    311 #   define ELF_CLASS    ELFCLASS64
    312 #else
    313 #   define ELF_CLASS    ELFCLASS32
    314 #endif
    315 
    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
     29DEFINE_ELF_TYPE(Ehdr, elf_ehdr);
     30DEFINE_ELF_TYPE(Phdr, elf_phdr);
     31DEFINE_ELF_TYPE(Shdr, elf_shdr);
     32DEFINE_ELF_TYPE(Sym, elf_sym);
     33DEFINE_ELF_TYPE(Dyn, elf_dyn);
     34DEFINE_ELF_TYPE(Rel, elf_rel);
     35DEFINE_ELF_TYPE(Rela, elf_rela);
     36DEFINE_ELF_TYPE(Verdef, elf_verdef);
     37DEFINE_ELF_TYPE(Verdaux, elf_verdaux);
     38DEFINE_ELF_TYPE(Verneed, elf_verneed);
     39DEFINE_ELF_TYPE(Vernaux, elf_vernaux);
     40
     41#undef DEFINE_ELF_TYPE
     42#undef _ELF_TYPE
     43
     44typedef 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  
    88
    99#include <arch_config.h>
    1010#include <DiskDeviceDefs.h>
    11 #include <elf_common.h>
     11#include <elf_private.h>
    1212#include <image.h>
    1313#include <OS.h>
    1414
  • 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)  
    356356        && elfHeader.e_ident[4] == ELFCLASS32
    357357        && elfHeader.e_shoff > 0
    358358        && elfHeader.e_shnum > 0
    359         && elfHeader.e_shentsize >= sizeof(struct Elf32_Shdr)
     359        && elfHeader.e_shentsize >= sizeof(Elf32_Shdr)
    360360        && elfHeader.e_shstrndx != SHN_UNDEF
    361361        && elfHeader.e_shstrndx < elfHeader.e_shnum
    362362        && elfHeader.e_phoff > 0
    363363        && elfHeader.e_phnum > 0
    364         && elfHeader.e_phentsize >= sizeof(struct Elf32_Phdr);
     364        && elfHeader.e_phentsize >= sizeof(Elf32_Phdr);
    365365}
    366366
    367367
    ElfFile::_CheckElfHeader(Elf64_Ehdr& elfHeader)  
    372372        && elfHeader.e_ident[4] == ELFCLASS64
    373373        && elfHeader.e_shoff > 0
    374374        && elfHeader.e_shnum > 0
    375         && elfHeader.e_shentsize >= sizeof(struct Elf64_Shdr)
     375        && elfHeader.e_shentsize >= sizeof(Elf64_Shdr)
    376376        && elfHeader.e_shstrndx != SHN_UNDEF
    377377        && elfHeader.e_shstrndx < elfHeader.e_shnum
    378378        && elfHeader.e_phoff > 0
    379379        && elfHeader.e_phnum > 0
    380         && elfHeader.e_phentsize >= sizeof(struct Elf64_Phdr);
     380        && elfHeader.e_phentsize >= sizeof(Elf64_Phdr);
    381381}
  • 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  
    99
    1010#include <SupportDefs.h>
    1111
    12 #include <elf32.h>
    13 #include <elf64.h>
     12#include <elf_private.h>
    1413#include <util/DoublyLinkedList.h>
    1514
    1615#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  
    88
    99#include <stdio.h>
    1010
    11 #include <elf_common.h>
     11#include <elf_private.h>
    1212#include <image.h>
    1313#include <OS.h>
    1414
  • 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  
    1111#include <boot/platform.h>
    1212#include <boot/stage2.h>
    1313#include <driver_settings.h>
    14 #include <elf32.h>
     14#include <elf_private.h>
    1515#include <kernel.h>
    1616#include <SupportDefs.h>
    1717
    elf_relocate_image(preloaded_image* image)  
    710710
    711711
    712712status_t
    713 boot_elf_resolve_symbol(preloaded_elf32_image* image, struct Elf32_Sym* symbol,
     713boot_elf_resolve_symbol(preloaded_elf32_image* image, Elf32_Sym* symbol,
    714714    Elf32_Addr* symbolAddress)
    715715{
    716716    return ELF32Loader::Resolve(image, symbol, symbolAddress);
    boot_elf_resolve_symbol(preloaded_elf32_image* image, struct Elf32_Sym* symbol,  
    719719
    720720#ifdef BOOT_SUPPORT_ELF64
    721721status_t
    722 boot_elf_resolve_symbol(preloaded_elf64_image* image, struct Elf64_Sym* symbol,
     722boot_elf_resolve_symbol(preloaded_elf64_image* image, Elf64_Sym* symbol,
    723723    Elf64_Addr* symbolAddress)
    724724{
    725725    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)  
    164164
    165165#ifdef _BOOT_MODE
    166166status_t
    167 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image,
    168     struct Elf32_Rel *rel, int relLength)
     167boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, Elf32_Rel *rel,
     168    int relLength)
    169169#else
    170170int
    171171arch_elf_relocate_rel(struct elf_image_info *image,
    172     struct elf_image_info *resolveImage, struct Elf32_Rel *rel, int relLength)
     172    struct elf_image_info *resolveImage, Elf32_Rel *rel, int relLength)
    173173#endif
    174174{
    175175    addr_t S;
    arch_elf_relocate_rel(struct elf_image_info *image,  
    181181
    182182    S = A = P = 0;
    183183
    184     for (i = 0; i * (int)sizeof(struct Elf32_Rel) < relLength; i++) {
     184    for (i = 0; i * (int)sizeof(Elf32_Rel) < relLength; i++) {
    185185        TRACE(("looking at rel type %s, offset 0x%lx\n",
    186186            kRelocations[ELF32_R_TYPE(rel[i].r_info)], rel[i].r_offset));
    187187
    arch_elf_relocate_rel(struct elf_image_info *image,  
    191191            case R_ARM_GLOB_DAT:
    192192            case R_ARM_ABS32:
    193193            {
    194                 struct Elf32_Sym *symbol;
     194                Elf32_Sym *symbol;
    195195                status_t status;
    196196
    197197                symbol = SYMBOL(image, ELF32_R_SYM(rel[i].r_info));
    write_8_check(addr_t P, Elf32_Word value)  
    309309#ifdef _BOOT_MODE
    310310status_t
    311311boot_arch_elf_relocate_rela(struct preloaded_elf32_image *image,
    312     struct Elf32_Rela *rel, int rel_len)
     312    Elf32_Rela *rel, int rel_len)
    313313#else
    314314int
    315315arch_elf_relocate_rela(struct elf_image_info *image,
    316     struct elf_image_info *resolve_image, struct Elf32_Rela *rel, int rel_len)
     316    struct elf_image_info *resolve_image, Elf32_Rela *rel, int rel_len)
    317317#endif
    318318{
    319319    int i;
    320     struct Elf32_Sym *sym;
     320    Elf32_Sym *sym;
    321321    int vlErr;
    322322    addr_t S = 0;   // symbol address
    323323    addr_t R = 0;   // section relative symbol address
    arch_elf_relocate_rela(struct elf_image_info *image,  
    345345        return B_ERROR; \
    346346    }
    347347
    348     for (i = 0; i * (int)sizeof(struct Elf32_Rela) < rel_len; i++) {
     348    for (i = 0; i * (int)sizeof(Elf32_Rela) < rel_len; i++) {
    349349        #if CHATTY
    350350        dprintf("looking at rel type %d, offset 0x%lx, "
    351351        "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[] = {  
    7676
    7777#ifdef _BOOT_MODE
    7878status_t
    79 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image,
    80     struct Elf32_Rel *rel, int rel_len)
     79boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, Elf32_Rel *rel,
     80    int rel_len)
    8181#else
    8282int
    8383arch_elf_relocate_rel(struct elf_image_info *image,
    84     struct elf_image_info *resolve_image, struct Elf32_Rel *rel, int rel_len)
     84    struct elf_image_info *resolve_image, Elf32_Rel *rel, int rel_len)
    8585#endif
    8686{
    8787    // there are no rel entries in M68K elf
    write_8_check(addr_t P, Elf32_Word value)  
    138138#ifdef _BOOT_MODE
    139139status_t
    140140boot_arch_elf_relocate_rela(struct preloaded_elf32_image *image,
    141     struct Elf32_Rela *rel, int rel_len)
     141    Elf32_Rela *rel, int rel_len)
    142142#else
    143143int
    144144arch_elf_relocate_rela(struct elf_image_info *image,
    145     struct elf_image_info *resolve_image, struct Elf32_Rela *rel, int rel_len)
     145    struct elf_image_info *resolve_image, Elf32_Rela *rel, int rel_len)
    146146#endif
    147147{
    148148    int i;
    149     struct Elf32_Sym *sym;
     149    Elf32_Sym *sym;
    150150    int vlErr;
    151151    addr_t S = 0;   // symbol address
    152152    addr_t R = 0;   // section relative symbol address
    arch_elf_relocate_rela(struct elf_image_info *image,  
    172172            return B_ERROR; \
    173173        }
    174174
    175     for (i = 0; i * (int)sizeof(struct Elf32_Rela) < rel_len; i++) {
     175    for (i = 0; i * (int)sizeof(Elf32_Rela) < rel_len; i++) {
    176176#if CHATTY
    177177        dprintf("looking at rel type %d, offset 0x%lx, sym 0x%lx, addend 0x%lx\n",
    178178            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  
    2121
    2222#ifdef _BOOT_MODE
    2323status_t
    24 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image,
    25     struct Elf32_Rel *rel, int rel_len)
     24boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, Elf32_Rel *rel,
     25    int rel_len)
    2626#else
    2727int
    2828arch_elf_relocate_rel(struct elf_image_info *image,
    29     struct elf_image_info *resolve_image, struct Elf32_Rel *rel, int rel_len)
     29    struct elf_image_info *resolve_image, Elf32_Rel *rel, int rel_len)
    3030#endif
    3131{
    3232    // there are no rel entries in PPC elf
    ha(Elf32_Word value)  
    116116#ifdef _BOOT_MODE
    117117status_t
    118118boot_arch_elf_relocate_rela(struct preloaded_elf32_image *image,
    119     struct Elf32_Rela *rel, int rel_len)
     119    Elf32_Rela *rel, int rel_len)
    120120#else
    121121int
    122122arch_elf_relocate_rela(struct elf_image_info *image,
    123     struct elf_image_info *resolve_image, struct Elf32_Rela *rel, int rel_len)
     123    struct elf_image_info *resolve_image, Elf32_Rela *rel, int rel_len)
    124124#endif
    125125{
    126126    int i;
    127     struct Elf32_Sym *sym;
     127    Elf32_Sym *sym;
    128128    int vlErr;
    129129    addr_t S = 0;   // symbol address
    130130    addr_t R = 0;   // section relative symbol address
    arch_elf_relocate_rela(struct elf_image_info *image,  
    150150            return B_ERROR; \
    151151        }
    152152
    153     for (i = 0; i * (int)sizeof(struct Elf32_Rela) < rel_len; i++) {
     153    for (i = 0; i * (int)sizeof(Elf32_Rela) < rel_len; i++) {
    154154#if CHATTY
    155155        dprintf("looking at rel type %d, offset 0x%lx, sym 0x%lx, addend 0x%lx\n",
    156156            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[] = {  
    5959
    6060#ifdef _BOOT_MODE
    6161status_t
    62 boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image,
    63     struct Elf32_Rel *rel, int relLength)
     62boot_arch_elf_relocate_rel(struct preloaded_elf32_image *image, Elf32_Rel *rel,
     63    int relLength)
    6464#else
    6565int
    6666arch_elf_relocate_rel(struct elf_image_info *image,
    67     struct elf_image_info *resolveImage, struct Elf32_Rel *rel, int relLength)
     67    struct elf_image_info *resolveImage, Elf32_Rel *rel, int relLength)
    6868#endif
    6969{
    7070    addr_t S;
    arch_elf_relocate_rel(struct elf_image_info *image,  
    7676
    7777    S = A = P = 0;
    7878
    79     for (i = 0; i * (int)sizeof(struct Elf32_Rel) < relLength; i++) {
     79    for (i = 0; i * (int)sizeof(Elf32_Rel) < relLength; i++) {
    8080        TRACE(("looking at rel type %s, offset 0x%lx\n",
    8181            kRelocations[ELF32_R_TYPE(rel[i].r_info)], rel[i].r_offset));
    8282
    arch_elf_relocate_rel(struct elf_image_info *image,  
    8888            case R_386_JMP_SLOT:
    8989            case R_386_GOTOFF:
    9090            {
    91                 struct Elf32_Sym *symbol;
     91                Elf32_Sym *symbol;
    9292                status_t status;
    9393
    9494                symbol = SYMBOL(image, ELF32_R_SYM(rel[i].r_info));
    arch_elf_relocate_rel(struct elf_image_info *image,  
    171171#ifdef _BOOT_MODE
    172172status_t
    173173boot_arch_elf_relocate_rela(struct preloaded_elf32_image *image,
    174     struct Elf32_Rela *rel, int relLength)
     174    Elf32_Rela *rel, int relLength)
    175175#else
    176176int
    177177arch_elf_relocate_rela(struct elf_image_info *image,
    178     struct elf_image_info *resolveImage, struct Elf32_Rela *rel, int relLength)
     178    struct elf_image_info *resolveImage, Elf32_Rela *rel, int relLength)
    179179#endif
    180180{
    181181    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)  
    7272
    7373
    7474static int
    75 relocate_rela(image_t *rootImage, image_t *image, struct Elf32_Rela *rel,
    76     int rel_len, SymbolLookupCache* cache)
     75relocate_rela(image_t *rootImage, image_t *image, Elf32_Rela *rel, int rel_len,
     76    SymbolLookupCache* cache)
    7777{
    7878    int i;
    7979    addr_t S;
    relocate_rela(image_t *rootImage, image_t *image, struct Elf32_Rela *rel,  
    8484#define A   ((addr_t)rel[i].r_addend)
    8585# define B  (image->regions[0].delta)
    8686
    87     for (i = 0; i * (int)sizeof(struct Elf32_Rel) < rel_len; i++) {
     87    for (i = 0; i * (int)sizeof(Elf32_Rel) < rel_len; i++) {
    8888        unsigned type = ELF32_R_TYPE(rel[i].r_info);
    8989
    9090        switch (type) {
    relocate_rela(image_t *rootImage, image_t *image, struct Elf32_Rela *rel,  
    9797            case R_68K_GLOB_DAT:
    9898            case R_68K_JMP_SLOT:
    9999            {
    100                 struct Elf32_Sym *sym;
     100                Elf32_Sym *sym;
    101101                status_t status;
    102102                sym = SYMBOL(image, ELF32_R_SYM(rel[i].r_info));
    103103
    arch_relocate_image(image_t *rootImage, image_t *image,  
    303303        //TRACE(("RELA relocations not supported\n"));
    304304        //return EOPNOTSUPP;
    305305
    306         //for (i = 1; i * (int)sizeof(struct Elf32_Rela) < image->rela_len; i++) {
     306        //for (i = 1; i * (int)sizeof(Elf32_Rela) < image->rela_len; i++) {
    307307        //  printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info));
    308308        //}
    309309    }
  • 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  
    2121
    2222
    2323static int
    24 relocate_rel(image_t *rootImage, image_t *image, struct Elf32_Rel *rel,
    25     int rel_len, SymbolLookupCache* cache)
     24relocate_rel(image_t *rootImage, image_t *image, Elf32_Rel *rel, int rel_len,
     25    SymbolLookupCache* cache)
    2626{
    2727    // ToDo: implement me!
    2828
    arch_relocate_image(image_t *rootImage, image_t *image,  
    5656        printf("RELA relocations not supported\n");
    5757        return EOPNOTSUPP;
    5858
    59         //for (i = 1; i * (int)sizeof(struct Elf32_Rela) < image->rela_len; i++) {
     59        //for (i = 1; i * (int)sizeof(Elf32_Rela) < image->rela_len; i++) {
    6060        //  printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info));
    6161        //}
    6262    }
  • 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  
    1818
    1919
    2020static int
    21 relocate_rel(image_t *rootImage, image_t *image, struct Elf32_Rel *rel,
    22     int rel_len, SymbolLookupCache* cache)
     21relocate_rel(image_t *rootImage, image_t *image, Elf32_Rel *rel, int rel_len,
     22    SymbolLookupCache* cache)
    2323{
    2424    int i;
    2525    addr_t S;
    relocate_rel(image_t *rootImage, image_t *image, struct Elf32_Rel *rel,  
    2929# define A  (*(P))
    3030# define B  (image->regions[0].delta)
    3131
    32     for (i = 0; i * (int)sizeof(struct Elf32_Rel) < rel_len; i++) {
     32    for (i = 0; i * (int)sizeof(Elf32_Rel) < rel_len; i++) {
    3333        unsigned type = ELF32_R_TYPE(rel[i].r_info);
    3434        unsigned symbolIndex = ELF32_R_SYM(rel[i].r_info);
    3535
    arch_relocate_image(image_t* rootImage, image_t* image,  
    133133        TRACE(("RELA relocations not supported\n"));
    134134        return EOPNOTSUPP;
    135135
    136         //for (i = 1; i * (int)sizeof(struct Elf32_Rela) < image->rela_len; i++) {
     136        //for (i = 1; i * (int)sizeof(Elf32_Rela) < image->rela_len; i++) {
    137137        //  printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info));
    138138        //}
    139139    }
  • 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)  
    4040
    4141
    4242extern "C" status_t
    43 boot_arch_elf_relocate_rel(struct preloaded_image *image,
    44     struct Elf32_Rel *rel, int rel_len)
     43boot_arch_elf_relocate_rel(struct preloaded_image *image, Elf32_Rel *rel,
     44    int rel_len)
    4545{
    4646    return B_ERROR;
    4747}
    4848
    4949
    5050extern "C" status_t
    51 boot_arch_elf_relocate_rela(struct preloaded_image *image,
    52     struct Elf32_Rela *rel, int rel_len)
     51boot_arch_elf_relocate_rela(struct preloaded_image *image, Elf32_Rela *rel,
     52    int rel_len)
    5353{
    5454    return B_ERROR;
    5555}