Changeset ,96

Show
Ignore:
Timestamp:
10/31/2008 09:29:09 PM (2 months ago)
Author:
Berkus <berkus@madfire.net>
branch-nick:
bzr
Message:

More naming cleanup.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • vesper/src/ELF.h

    r94 r96  
    55// (See file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt) 
    66// 
    7 /* 
    8  *  ELF file format structures definitions 
    9  *  According to Portable Formats Specification, version 1.1 
    10  *  (FIXME: update to 1.2) 
    11  * 
    12  *  Typed in by Stanislav Karchebny <berkus+os@madfire.net>, 2001 
    13  *  This file is in Public Domain. 
    14  */ 
    15  
     7// 
     8//  ELF file format structure definitions. 
     9//  According to Portable Formats Specification, version 1.1 
     10//  (FIXME: update to 1.2) 
     11// 
    1612#pragma once 
    1713 
     
    2218 * ELF data types 
    2319 */ 
    24 typedef uint32_t  Elf32_Addr;  /* 4 bytes/4 align/unsigned */ 
    25 typedef uint16_t  Elf32_Half;  /* 2 bytes/2 align/unsigned */ 
    26 typedef uint32_t  Elf32_Off;   /* 4 bytes/4 align/unsigned */ 
    27 typedef  int32_t  Elf32_Sword; /* 4 bytes/4 align/signed   */ 
    28 typedef uint32_t  Elf32_Word;  /* 4 bytes/4 align/unsigned */ 
    29 typedef  uint8_t  Elf32_Byte;  /* 1 byte /1 align/unsigned */ 
     20typedef uint32_t  elf32_addr_t;  /* 4 bytes/4 align/unsigned */ 
     21typedef uint16_t  elf32_half_t;  /* 2 bytes/2 align/unsigned */ 
     22typedef uint32_t  elf32_off_t;   /* 4 bytes/4 align/unsigned */ 
     23typedef  int32_t  elf32_sword_t; /* 4 bytes/4 align/signed   */ 
     24typedef uint32_t  elf32_word_t;  /* 4 bytes/4 align/unsigned */ 
     25typedef  uint8_t  elf32_byte_t;  /* 1 byte /1 align/unsigned */ 
    3026 
    3127 
     
    3329 * ELF structures: ELF file Header 
    3430 */ 
    35 struct Elf32Header 
    36 { 
    37        Elf32_Word e_magic; 
    38        Elf32_Byte e_class; 
    39        Elf32_Byte e_data; 
    40        Elf32_Byte e_hdrversion; 
    41        Elf32_Byte e_padding[9]; 
    42        Elf32_Half e_type;           /**< Identifies object file type */ 
    43        Elf32_Half e_machine;        /**< Specifies required architecture */ 
    44        Elf32_Word e_version;        /**< Identifies object file version */ 
    45        Elf32_Addr e_entry;          /**< Entry point virtual address */ 
    46        Elf32_Off  e_phoff;          /**< Program header table file offset */ 
    47        Elf32_Off  e_shoff;          /**< Section header table file offset */ 
    48        Elf32_Word e_flags;          /**< Processor-specific flags */ 
    49        Elf32_Half e_ehsize;         /**< ELF header size in bytes */ 
    50        Elf32_Half e_phentsize;      /**< Program header table entry size */ 
    51        Elf32_Half e_phnum;          /**< Program header table entry count */ 
    52        Elf32_Half e_shentsize;      /**< Section header table entry size */ 
    53        Elf32_Half e_shnum;          /**< Section header table entry count */ 
    54        Elf32_Half e_shstrndx;       /**< Section header string table index */ 
     31struct elf32_header 
     32{ 
     33    elf32_word_t e_magic; 
     34    elf32_byte_t e_class; 
     35    elf32_byte_t e_data; 
     36    elf32_byte_t e_hdrversion; 
     37    elf32_byte_t e_padding[9]; 
     38    elf32_half_t e_type;           /**< Identifies object file type */ 
     39    elf32_half_t e_machine;        /**< Specifies required architecture */ 
     40    elf32_word_t e_version;        /**< Identifies object file version */ 
     41    elf32_addr_t e_entry;          /**< Entry point virtual address */ 
     42    elf32_off_t  e_phoff;          /**< Program header table file offset */ 
     43    elf32_off_t  e_shoff;          /**< Section header table file offset */ 
     44    elf32_word_t e_flags;          /**< Processor-specific flags */ 
     45    elf32_half_t e_ehsize;         /**< ELF header size in bytes */ 
     46    elf32_half_t e_phentsize;      /**< Program header table entry size */ 
     47    elf32_half_t e_phnum;          /**< Program header table entry count */ 
     48    elf32_half_t e_shentsize;      /**< Section header table entry size */ 
     49    elf32_half_t e_shnum;          /**< Section header table entry count */ 
     50    elf32_half_t e_shstrndx;       /**< Section header string table index */ 
    5551} PACKED; 
    5652 
    57 /* Elf32Header.e_magic */ 
     53/* elf32_header.e_magic */ 
    5854#define ELF_MAGIC  0x464c457f    /* ASCII "ELF",0x7F */ 
    5955 
    60 /* Elf32Header.e_class */ 
     56/* elf32_header.e_class */ 
    6157#define ELF_CLASS_NONE 0x00      /**< Invalid class  */ 
    6258#define ELF_CLASS_32   0x01      /**< 32 bit objects */ 
    6359#define ELF_CLASS_64   0x02      /**< 64 bit objects */ 
    6460 
    65 /* Elf32Header.e_data */ 
     61/* elf32_header.e_data */ 
    6662#define ELF_DATA_NONE  0x00      /**< Invalid data encoding   */ 
    6763#define ELF_DATA_2LSB  0x01      /**< LSB (Intel) encoding    */ 
    6864#define ELF_DATA_2MSB  0x02      /**< MSB (Motorola) encoding */ 
    6965 
    70 /* Elf32Header.e_type */ 
     66/* elf32_header.e_type */ 
    7167#define ET_NONE    0x0000        /* No type     */ 
    7268#define ET_REL     0x0001        /* Relocatable */ 
     
    7470#define ET_DYN     0x0003        /* Shared      */ 
    7571#define ET_CORE    0x0004        /* Core        */ 
    76 #define ET_LOPROC  0xff00 
     72#define ET_LOPROC  0xff00        /* Processor-specific */ 
    7773#define ET_HIPROC  0xffff 
    7874 
    79 /* Elf32Header.e_machine */ 
     75/* elf32_header.e_machine */ 
    8076#define EM_NONE  0x0000          /* No machine     */ 
    8177#define EM_M32   0x0001          /* AT&T WE32100   */ 
     
    8783#define EM_MIPS  0x0008          /* MIPS RS3000    */ 
    8884 
    89 /* Elf32Header.e_version */ 
     85/* elf32_header.e_version */ 
    9086#define EV_NONE        0         /* Invalid version */ 
    9187#define EV_CURRENT     1         /* Current version */ 
     
    9591 * ELF structures: Section header 
    9692 */ 
    97 struct Elf32SectionHeader 
    98 { 
    99        Elf32_Word sh_name;          /**< Section name, index in string table */ 
    100        Elf32_Word sh_type;          /**< Type of section */ 
    101        Elf32_Word sh_flags;         /**< Miscellaneous section attributes */ 
    102        Elf32_Addr sh_addr;          /**< Section virtual addr at execution */ 
    103        Elf32_Off  sh_offset;        /**< Section file offset */ 
    104        Elf32_Word sh_size;          /**< Size of section in bytes */ 
    105        Elf32_Word sh_link;          /**< Index of another section */ 
    106        Elf32_Word sh_info;          /**< Additional section information */ 
    107        Elf32_Word sh_addralign;     /**< Section alignment */ 
    108        Elf32_Word sh_entsize;       /**< Entry size if section holds table */ 
     93struct elf32_section_header 
     94{ 
     95    elf32_word_t sh_name;          /**< Section name, index in string table */ 
     96    elf32_word_t sh_type;          /**< Type of section */ 
     97    elf32_word_t sh_flags;         /**< Miscellaneous section attributes */ 
     98    elf32_addr_t sh_addr;          /**< Section virtual addr at execution */ 
     99    elf32_off_t  sh_offset;        /**< Section file offset */ 
     100    elf32_word_t sh_size;          /**< Size of section in bytes */ 
     101    elf32_word_t sh_link;          /**< Index of another section */ 
     102    elf32_word_t sh_info;          /**< Additional section information */ 
     103    elf32_word_t sh_addralign;     /**< Section alignment */ 
     104    elf32_word_t sh_entsize;       /**< Entry size if section holds table */ 
    109105} PACKED; 
    110106 
     
    118114#define SHN_HIRESERVE 0xffff 
    119115 
    120 /* Elf32SectionHeader.sh_type */ 
     116/* elf32_section_header.sh_type */ 
    121117#define SHT_NULL      0x00000000 
    122118#define SHT_PROGBITS  0x00000001 /* The data is contained in program file */ 
     
    141137 
    142138 
    143 /* Elf32SectionHeader.sh_flags */ 
     139/* elf32_section_header.sh_flags */ 
    144140#define SHF_WRITE     0x00000001 
    145141#define SHF_ALLOC     0x00000002 
     
    151147 * ELF structures: Symbol Table 
    152148 */ 
    153 struct Elf32Symbol 
    154 { 
    155        Elf32_Word st_name;          /**< Symbol name, index into string table */ 
    156        Elf32_Addr st_value;         /**< Symbol value */ 
    157        Elf32_Word st_size;          /**< Size occupied by this symbol */ 
    158        Elf32_Byte st_info;          /**< Symbol type and binding */ 
    159        Elf32_Byte st_other; 
    160        Elf32_Half st_shndx;         /**< Section index this symbol belongs to */ 
     149struct elf32_symbol 
     150{ 
     151    elf32_word_t st_name;          /**< Symbol name, index into string table */ 
     152    elf32_addr_t st_value;         /**< Symbol value */ 
     153    elf32_word_t st_size;          /**< Size occupied by this symbol */ 
     154    elf32_byte_t st_info;          /**< Symbol type and binding */ 
     155    elf32_byte_t st_other; 
     156    elf32_half_t st_shndx;         /**< Section index this symbol belongs to */ 
    161157} PACKED; 
    162158 
     
    164160#define STN_UNDEF 0x0000 
    165161 
    166 /* Elf32Symbol.st_info manipulation macros */ 
     162/* elf32_symbol.st_info manipulation macros */ 
    167163#define ELF32_ST_BIND(i)    ((i) >> 4) 
    168164#define ELF32_ST_TYPE(i)    ((i) & 0xf) 
    169165#define ELF32_ST_INFO(b,t)  ((b) << 4 + ((t) & 0xf)) 
    170166 
    171 /* ELF32_ST_BIND(Elf32Symbol.st_info) values */ 
     167/* ELF32_ST_BIND(elf32_symbol.st_info) values */ 
    172168#define STB_LOCAL  0x0 
    173169#define STB_GLOBAL 0x1 
     
    176172#define STB_HIPROC 0xf 
    177173 
    178 /* ELF32_ST_TYPE(Elf32Symbol.st_info) values */ 
     174/* ELF32_ST_TYPE(elf32_symbol.st_info) values */ 
    179175#define STT_NOTYPE  0x0 
    180176#define STT_OBJECT  0x1 
     
    189185 * ELF structures: Dynamic linking info 
    190186 */ 
    191 struct Elf32Dyn 
    192 { 
    193        Elf32_Sword d_tag; 
    194        union 
    195        
    196                Elf32_Word d_val; 
    197                Elf32_Addr d_ptr; 
    198        } d_un; 
     187struct elf32_dyn 
     188{ 
     189    elf32_sword_t d_tag; 
     190    union 
     191   
     192        elf32_word_t d_val; 
     193        elf32_addr_t d_ptr; 
     194    } d_un; 
    199195}; 
    200196 
    201 /* Elf32Dyn.d_tag */ 
     197/* elf32_dyn.d_tag */ 
    202198#define DT_NULL     0x00000000 
    203199#define DT_NEEDED   0x00000001 
     
    231227 * ELF structures: Relocation Entries 
    232228 */ 
    233 struct Elf32_Rel 
    234 { 
    235        Elf32_Addr r_offset; 
    236        Elf32_Word r_info; 
     229struct elf32_rel 
     230{ 
     231    elf32_addr_t r_offset; 
     232    elf32_word_t r_info; 
    237233}; 
    238234 
    239 struct Elf32_Rela 
    240 { 
    241        Elf32_Addr  r_offset; 
    242        Elf32_Word  r_info; 
    243        Elf32_Sword r_addend; 
     235struct elf32_rela 
     236{ 
     237    elf32_addr_t  r_offset; 
     238    elf32_word_t  r_info; 
     239    elf32_sword_t r_addend; 
    244240}; 
    245241 
    246 /* Elf32_Rel|a.r_info manipulation macros */ 
     242/* elf32_rel|a.r_info manipulation macros */ 
    247243#define ELF32_R_SYM(i)     ((i) >> 8) 
    248244#define ELF32_R_TYPE(i)    ((i) & 0xff) 
    249245#define ELF32_R_INFO(s,t)  ((s) << 8 + (t) & 0xff) 
    250246 
    251 /* ELF32_R_TYPE(Elf32_Rel|a.r_info) values */ 
     247/* ELF32_R_TYPE(elf32_rel|a.r_info) values */ 
    252248#define R_386_NONE      0x00 
    253249#define R_386_32        0x01 
     
    266262 * ELF structures: Program Header 
    267263 */ 
    268 struct Elf32ProgramHeader 
    269 { 
    270        Elf32_Word p_type;           /**< Program section type */ 
    271        Elf32_Off  p_offset;         /**< File offset */ 
    272        Elf32_Addr p_vaddr;          /**< Execution virtual address */ 
    273        Elf32_Addr p_paddr;          /**< Execution physical address */ 
    274        Elf32_Word p_filesz;         /**< Size in file */ 
    275        Elf32_Word p_memsz;          /**< Size in memory */ 
    276        Elf32_Word p_flags;          /**< Section flags */ 
    277        Elf32_Word p_align;          /**< Section alignment */ 
     264struct elf32_program_header 
     265{ 
     266    elf32_word_t p_type;           /**< Program section type */ 
     267    elf32_off_t  p_offset;         /**< File offset */ 
     268    elf32_addr_t p_vaddr;          /**< Execution virtual address */ 
     269    elf32_addr_t p_paddr;          /**< Execution physical address */ 
     270    elf32_word_t p_filesz;         /**< Size in file */ 
     271    elf32_word_t p_memsz;          /**< Size in memory */ 
     272    elf32_word_t p_flags;          /**< Section flags */ 
     273    elf32_word_t p_align;          /**< Section alignment */ 
    278274}; 
    279275 
    280 /* Elf32ProgramHeader.p_type */ 
     276/* elf32_program_header.p_type */ 
    281277#define PT_NULL     0 
    282278#define PT_LOAD     1 
     
    289285#define PT_HIPROC   0x7fffffff 
    290286 
    291 /* Elf32ProgramHeader.p_flags */ 
     287/* elf32_program_header.p_flags */ 
    292288#define PF_X        0x1 
    293289#define PF_W        0x2 
     
    300296elf_hash(const unsigned char *name) 
    301297{ 
    302        unsigned long h = 0, g; 
    303        while (*name) 
    304        
    305                h = (h << 4) + *name++; 
    306                if ((g = h & 0xf0000000)) 
    307                        h ^= g >> 24; 
    308                h &= ~g; 
    309        
    310        return h; 
     298    unsigned long h = 0, g; 
     299    while (*name) 
     300   
     301        h = (h << 4) + *name++; 
     302        if ((g = h & 0xf0000000)) 
     303            h ^= g >> 24; 
     304        h &= ~g; 
     305   
     306    return h; 
    311307} 
    312308 
  • vesper/src/ElfParser.cpp

    r94 r96  
    1111elf_parser::elf_parser() 
    1212{ 
    13         header             = NULL; 
    14         sectionHeaders     = NULL; 
    15         symbolTable        = NULL; 
    16         stringTable        = NULL; 
    17         gotTable           = NULL; 
    18         filename           = NULL; 
     13        header              = NULL; 
     14        section_headers     = NULL; 
     15        symbol_table        = NULL; 
     16        string_table        = NULL; 
     17        got_table           = NULL; 
     18        filename            = NULL; 
    1919} 
    2020 
     
    2222{ 
    2323        delete header; 
    24         delete sectionHeaders; 
     24        delete section_headers; 
    2525        delete [] filename; 
    2626} 
    2727 
    28 void elf_parser::loadKernel(Elf32SectionHeader* symtab, 
    29                             Elf32SectionHeader* strtab) 
     28void elf_parser::load_kernel(elf32_section_header* symtab, 
     29                            elf32_section_header* strtab) 
    3030{ 
    31         symbolTable = symtab; 
    32         stringTable = strtab; 
     31        symbol_table = symtab; 
     32        string_table = strtab; 
    3333} 
    3434 
    35 char* elf_parser::findSymbol(address_t addr, address_t *symbolStart) 
     35char* elf_parser::find_symbol(address_t addr, address_t *symbol_start) 
    3636{ 
    3737        address_t max = 0; 
    38         Elf32Symbol *fallbackSymbol = 0; 
    39         for (unsigned int i = 0; i < symbolTable->sh_size / symbolTable->sh_entsize; i++) 
     38        elf32_symbol *fallback_symbol = 0; 
     39        for (unsigned int i = 0; i < symbol_table->sh_size / 
     40         symbol_table->sh_entsize; i++) 
    4041        { 
    41                 Elf32Symbol *symbol = (Elf32Symbol *)(symbolTable->sh_addr + i * symbolTable->sh_entsize); 
     42                elf32_symbol *symbol = (elf32_symbol *)(symbol_table->sh_addr 
     43                                + i * symbol_table->sh_entsize); 
    4244 
    4345                if ((addr >= symbol->st_value) && 
    4446                        (addr <  symbol->st_value + symbol->st_size) ) 
    4547                { 
    46                         char *c = (char *)(symbol->st_name) + stringTable->sh_addr; 
     48                        char *c = (char *)(symbol->st_name) + string_table->sh_addr; 
    4749 
    48                         if (symbolStart) 
     50                        if (symbol_start) 
    4951                        { 
    50                                 *symbolStart = symbol->st_value; 
     52                                *symbol_start = symbol->st_value; 
    5153                        } 
    5254                        return c; 
     
    5658                { 
    5759                        max = symbol->st_value; 
    58                         fallbackSymbol = symbol; 
     60                        fallback_symbol = symbol; 
    5961                } 
    6062        } 
     
    6264        // Search for symbol with size failed, now take a wild guess. 
    6365        // Use a biggest symbol value less than addr (if found). 
    64         if (fallbackSymbol) 
     66        if (fallback_symbol) 
    6567        { 
    66                 char *c = (char *)(fallbackSymbol->st_name) + stringTable->sh_addr; 
     68                char *c = (char *)(fallback_symbol->st_name) + string_table->sh_addr; 
    6769 
    68                 if (symbolStart) 
     70                if (symbol_start) 
    6971                { 
    70                         *symbolStart = fallbackSymbol->st_value; 
     72                        *symbol_start = fallback_symbol->st_value; 
    7173                } 
    7274                return c; 
    7375        } 
    7476 
    75         if (symbolStart) 
    76                 *symbolStart = 0; 
     77        if (symbol_start) 
     78                *symbol_start = 0; 
    7779        return NULL; 
    7880} 
  • vesper/src/ElfParser.h

    r94 r96  
    3636     * Writes all section information to the virtual memory image. 
    3737     */ 
    38     void writeAllSections(); 
     38    void write_all_sections(); 
    3939 
    4040    /** 
    4141     * Returns the address of the last byte to be loaded in. 
    4242     */ 
    43     address_t getLastAddress(); 
     43    address_t get_last_address(); 
    4444 
    4545    /** 
    4646     * Loads the symbol table for the kernel from the specified location. 
    4747     */ 
    48     void loadKernel(Elf32SectionHeader *symtab, Elf32SectionHeader *strtab); 
     48    void load_kernel(elf32_section_header* symtab, 
     49                     elf32_section_header* strtab); 
    4950 
    5051    /** 
     
    5253     * of that symbol in startAddr if startAddr != NULL. 
    5354     */ 
    54     char* findSymbol(address_t addr, address_t *symbolStart = NULL); 
     55    char* find_symbol(address_t addr, address_t *symbol_start = NULL); 
    5556 
    5657    /** 
     
    5960     * using the hashtable sections in ELF. 
    6061     */ 
    61     address_t findSymbol(char* str); 
     62    address_t find_symbol(char* str); 
    6263 
    6364    /** 
     
    6566     * relocation symbol table. 
    6667     */ 
    67     address_t findDynamicSymbolLocation(address_t o); 
     68    address_t find_dynamic_symbol_location(address_t o); 
    6869 
    6970    /** 
     
    7172     * the symbol at offset o in the relocation symbol table. 
    7273     */ 
    73     char *findDynamicSymbolName(address_t o); 
     74    char *find_dynamic_symbol_name(address_t o); 
    7475 
    7576    /** 
    7677     * Gets the address of the global offset table. 
    7778     */ 
    78     address_t getGlobalOffsetTable(); 
     79    address_t get_global_offset_table(); 
    7980 
    8081    /** 
    8182     * Returns the entry point of the executable. 
    8283     */ 
    83     address_t getEntryPoint() 
     84    address_t get_entry_point() 
    8485    { 
    8586        return (address_t)header->e_entry; 
     
    8990     * Returns true if the parser loaded correctly. 
    9091     */ 
    91     bool isValid() 
     92    bool is_valid() 
    9293    { 
    93         return (filename!=0); 
     94        return (filename != 0); 
    9495    } 
    9596 
    9697private: 
    97     Elf32Header        *header; 
    98     Elf32SectionHeader *symbolTable; 
    99     Elf32SectionHeader *stringTable; 
    100     Elf32SectionHeader *gotTable; // Global offset table. 
    101     Elf32SectionHeader *relTable; 
    102     Elf32SectionHeader *sectionHeaders; 
    103     const char         *filename; 
     98    elf32_header*         header; 
     99    elf32_section_header* symbol_table; 
     100    elf32_section_header* string_table; 
     101    elf32_section_header* got_table; // Global offset table. 
     102    elf32_section_header* rel_table; 
     103    elf32_section_header* section_headers; 
     104    const char*           filename; 
    104105}; 
    105106 
  • vesper/src/Globals.cpp

    r94 r96  
    1616/* Global objects FIXME: use singletons instead? */ 
    1717class kernel kernel; 
    18 multiboot_t multiboot; 
     18class multiboot multiboot; 
    1919elf_parser kernelElfParser; 
    2020MemoryManager memoryManager; 
     
    2222 
    2323/* This entry point is called from loader */ 
    24 void kernel_entry(multiboot_header_t *multiboot_header) 
     24void kernel_entry(multiboot_header *multiboot_header) 
    2525{ 
    2626        kconsole.clear(); 
    27         multiboot = multiboot_t(multiboot_header); 
     27        multiboot = multiboot::multiboot(multiboot_header); 
    2828        kernel.run(); /* does not return */ 
    2929} 
  • vesper/src/Globals.h

    r94 r96  
    1212 
    1313extern class kernel kernel; 
    14 extern class multiboot_t multiboot; 
     14extern class multiboot multiboot; 
    1515extern class elf_parser kernelElfParser; 
    1616extern class MemoryManager memoryManager; 
    1717extern class InterruptDescriptorTable interruptsTable; 
    1818 
    19 extern "C" void kernel_entry(class multiboot_header_t *mh) NORETURN; 
     19extern "C" void kernel_entry(class multiboot_header *mh) NORETURN; 
    2020 
    2121void *operator new(size_t size); 
  • vesper/src/Kernel.cpp

    r94 r96  
    2828        relocate_placement_address(); 
    2929 
    30         kernelElfParser.loadKernel(multiboot.symtab_start(), multiboot.strtab_start()); 
     30        kernelElfParser.load_kernel(multiboot.symtab_start(), 
     31                                multiboot.strtab_start()); 
    3132 
    3233        GlobalDescriptorTable::init(); 
     
    155156                ebp = backtrace(ebp, eip); 
    156157                unsigned int offset; 
    157                 char *symbol = kernelElfParser.findSymbol(eip, &offset); 
     158                char *symbol = kernelElfParser.find_symbol(eip, &offset); 
    158159                offset = eip - offset; 
    159160                kconsole.print("| %08x <%s+0x%x>\n", eip, symbol ? symbol : "UNRESOLVED", offset); 
  • vesper/src/boot/Multiboot.cpp

    r95 r96  
    1010#include "ELF.h" 
    1111 
    12 multiboot_t::multiboot_t(multiboot_header_t *h) 
     12multiboot::multiboot(multiboot_header *h) 
    1313{ 
    1414        header = h; 
     
    1818 
    1919        // try and find the symtab/strtab 
    20         if (is_elf()) 
    21         { 
    22                 Elf32SectionHeader *shstrtab = (Elf32SectionHeader *)(header->addr + header->shndx * header->size); 
    23                 // loop through the section headers, try to find the symbol table. 
    24                 for(uint32_t i = 0; i < header->num; i++) 
    25                 { 
    26                         Elf32SectionHeader *sh = (Elf32SectionHeader *)(header->addr + i * header->size); 
     20        if (!is_elf()) 
     21        return; 
    2722 
    28                         if (sh->sh_type == SHT_SYMTAB) 
    29                         { 
    30                                 symtab = sh; 
    31                         } 
    32                         else if (sh->sh_type == SHT_STRTAB) 
    33                         { 
    34                                 char *c = (char *)shstrtab->sh_addr + sh->sh_name; 
    35                                 if (string::equals(c, ".strtab")) 
    36                                 { 
    37                                         strtab = sh; 
    38                                 } 
    39                         } 
    40                 } 
    41         } 
     23    elf32_section_header* shstrtab = (elf32_section_header*)(header->addr + 
     24                                      header->shndx * header->size); 
     25    // loop through the section headers, try to find the symbol table. 
     26    for(uint32_t i = 0; i < header->num; i++) 
     27    { 
     28        elf32_section_header* sh = (elf32_section_header*)(header->addr + i * 
     29                                    header->size); 
     30 
     31        if (sh->sh_type == SHT_SYMTAB) 
     32        { 
     33            symtab = sh; 
     34        } 
     35        else if (sh->sh_type == SHT_STRTAB) 
     36        { 
     37            char *c = (char *)shstrtab->sh_addr + sh->sh_name; 
     38            if (string::equals(c, ".strtab")) 
     39            { 
     40                strtab = sh; 
     41            } 
     42        } 
     43    } 
    4244} 
    4345 
  • vesper/src/boot/Multiboot.h

    r94 r96  
    2727 * Boot information passed in by multiboot loader. 
    2828 */ 
    29 struct multiboot_header_t 
     29struct multiboot_header 
    3030{ 
    3131        uint32_t flags; 
     
    7070 * Defines an interface to the multiboot header 
    7171 */ 
    72 class multiboot_t 
     72class multiboot 
    7373{ 
    7474public: 
    75         multiboot_t() : header(NULL) {} 
    76         multiboot_t(multiboot_header_t *h); 
     75        multiboot() : header(NULL) {} 
     76        multiboot(multiboot_header *h); 
    7777 
    7878        INLINE uint32_t lower_mem()   { return header->mem_lower; } 
     
    129129                } 
    130130        } 
    131         INLINE Elf32SectionHeader *symtab_start() 
     131        INLINE elf32_section_header* symtab_start() 
    132132        { 
    133133                if (symtab) 
    134134                { 
    135                         return (Elf32SectionHeader *)symtab; 
     135                        return (elf32_section_header*)symtab; 
    136136                } 
    137137                else 
     
    140140                } 
    141141        } 
    142        INLINE Elf32SectionHeader *strtab_start() 
     142    INLINE elf32_section_header* strtab_start() 
    143143        { 
    144144                if (strtab) 
    145145                { 
    146                        return (Elf32SectionHeader *)strtab; 
     146            return (elf32_section_header*)strtab; 
    147147                } 
    148148                else 
     
    156156 
    157157private: 
    158         multiboot_header_t *header; 
    159        Elf32SectionHeader *strtab; 
    160        Elf32SectionHeader *symtab; 
     158        multiboot_header*     header; 
     159    elf32_section_header* strtab; 
     160    elf32_section_header* symtab; 
    161161}; 
    162162