Root/
Source at commit 444 created 13 years 10 months ago. By zef, Fixed calling getBootVolumeDescription() with properly adjusted strMaxLen values. Removed broken optionKey setting. Now using strncat() for adding proper NULL termination in destination strings. | |
---|---|
1 | /*␊ |
2 | * Symbols.c␊ |
3 | * ␊ |
4 | * Module loader support module. This module is the first module to ever be loaded.␊ |
5 | * It contains a copy of each symbol inside ov the current version of chameleon as well ␊ |
6 | * as a strcmp function. Chameleon calls lookup_symbol to resolve internal symbols␊ |
7 | * when they are requested by a module. This module does *not* depend on any intenrla␊ |
8 | * symbols, as such it can be loaded without a symbol table initialized.␊ |
9 | *␊ |
10 | * Copyright (c) 2009 Evan Lojewski. All rights reserved.␊ |
11 | */␊ |
12 | ␊ |
13 | #include "Symbols.h"␊ |
14 | ␊ |
15 | static int strcmp(const char * s1, const char * s2);␊ |
16 | ␊ |
17 | void Symbols_start()␊ |
18 | {␊ |
19 | ␉// load_dependency("Symbols", 300);␊ |
20 | }␊ |
21 | ␊ |
22 | unsigned int lookup_symbol(const char* symbol)␊ |
23 | {␊ |
24 | ␉int upperLimit = sizeof(symbolList) / sizeof(symbolList[0]) - 1;␉␉␊ |
25 | ␉int lowerLimit = 0;␊ |
26 | ␉int compareIndex = (upperLimit - lowerLimit) >> 1; // Midpoint␊ |
27 | ␉int result;␊ |
28 | ␉␊ |
29 | ␉while((result = strcmp(symbol, symbolList[compareIndex].symbol)) != 0)␊ |
30 | ␉{␊ |
31 | ␉␉if(result > 0)␉// We need to search a HIGHER index␊ |
32 | ␉␉{␊ |
33 | ␉␉␉if(compareIndex != lowerLimit)␊ |
34 | ␉␉␉{␊ |
35 | ␉␉␉␉lowerLimit = compareIndex;␊ |
36 | ␉␉␉}␊ |
37 | ␉␉␉else␊ |
38 | ␉␉␉{␊ |
39 | ␉␉␉␉return 0xFFFFFFFF;␉// Symbol not found␊ |
40 | ␉␉␉}␊ |
41 | ␉␉␉compareIndex = (upperLimit + lowerLimit + 1) >> 1;␉// Midpoint, round up␊ |
42 | ␉␉}␊ |
43 | ␉␉else // We Need to search a LOWER index␊ |
44 | ␉␉{␊ |
45 | ␉␉␉if(compareIndex != upperLimit)␊ |
46 | ␉␉␉{␊ |
47 | ␉␉␉␉upperLimit = compareIndex;␊ |
48 | ␉␉␉}␊ |
49 | ␉␉␉else␊ |
50 | ␉␉␉{␊ |
51 | ␉␉␉␉return 0xFFFFFFFF;␉// Symbol not found␊ |
52 | ␉␉␉}␊ |
53 | ␉␉␉compareIndex = (upperLimit + lowerLimit) >> 1;␉// Midpoint, round down␊ |
54 | ␉␉}␊ |
55 | ␉}␊ |
56 | ␉return symbolList[compareIndex].addr;␊ |
57 | }␊ |
58 | ␊ |
59 | /*␊ |
60 | * strcmp - Copied from libsa/string.c due to symbols not able to be resolved at this point␊ |
61 | */␊ |
62 | static int strcmp(const char * s1, const char * s2)␊ |
63 | {␊ |
64 | ␉while (*s1 && (*s1 == *s2)) {␊ |
65 | ␉␉s1++;␊ |
66 | ␉␉s2++;␊ |
67 | ␉}␊ |
68 | ␉return (*s1 - *s2);␊ |
69 | }␊ |
70 | ␊ |
71 | ␊ |
72 | ␊ |
73 |