~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/System/SearchForAddressOfSpecialSymbol.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//===- SearchForAddressOfSpecialSymbol.cpp - Function addresses -*- C++ -*-===//
2
 
//
3
 
//                     The LLVM Compiler Infrastructure
4
 
//
5
 
// This file is distributed under the University of Illinois Open Source
6
 
// License. See LICENSE.TXT for details.
7
 
//
8
 
//===----------------------------------------------------------------------===//
9
 
//
10
 
//  This file pulls the addresses of certain symbols out of the linker.  It must
11
 
//  include as few header files as possible because it declares the symbols as
12
 
//  void*, which would conflict with the actual symbol type if any header
13
 
//  declared it.
14
 
//
15
 
//===----------------------------------------------------------------------===//
16
 
 
17
 
#include <string.h>
18
 
 
19
 
// Must declare the symbols in the global namespace.
20
 
static void *DoSearch(const char* symbolName) {
21
 
#define EXPLICIT_SYMBOL(SYM) \
22
 
   extern void *SYM; if (!strcmp(symbolName, #SYM)) return &SYM
23
 
 
24
 
  // If this is darwin, it has some funky issues, try to solve them here.  Some
25
 
  // important symbols are marked 'private external' which doesn't allow
26
 
  // SearchForAddressOfSymbol to find them.  As such, we special case them here,
27
 
  // there is only a small handful of them.
28
 
 
29
 
#ifdef __APPLE__
30
 
  {
31
 
    EXPLICIT_SYMBOL(__ashldi3);
32
 
    EXPLICIT_SYMBOL(__ashrdi3);
33
 
    EXPLICIT_SYMBOL(__cmpdi2);
34
 
    EXPLICIT_SYMBOL(__divdi3);
35
 
    EXPLICIT_SYMBOL(__eprintf);
36
 
    EXPLICIT_SYMBOL(__fixdfdi);
37
 
    EXPLICIT_SYMBOL(__fixsfdi);
38
 
    EXPLICIT_SYMBOL(__fixunsdfdi);
39
 
    EXPLICIT_SYMBOL(__fixunssfdi);
40
 
    EXPLICIT_SYMBOL(__floatdidf);
41
 
    EXPLICIT_SYMBOL(__floatdisf);
42
 
    EXPLICIT_SYMBOL(__lshrdi3);
43
 
    EXPLICIT_SYMBOL(__moddi3);
44
 
    EXPLICIT_SYMBOL(__udivdi3);
45
 
    EXPLICIT_SYMBOL(__umoddi3);
46
 
  }
47
 
#endif
48
 
 
49
 
#ifdef __CYGWIN__
50
 
  {
51
 
    EXPLICIT_SYMBOL(_alloca);
52
 
    EXPLICIT_SYMBOL(__main);
53
 
  }
54
 
#endif
55
 
 
56
 
#undef EXPLICIT_SYMBOL
57
 
  return 0;
58
 
}
59
 
 
60
 
namespace llvm {
61
 
void *SearchForAddressOfSpecialSymbol(const char* symbolName) {
62
 
  return DoSearch(symbolName);
63
 
}
64
 
}  // namespace llvm