aboutsummaryrefslogtreecommitdiff
path: root/runtime/GCCLibraries
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-11-17 03:32:33 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-11-17 03:32:33 +0000
commit8b2e1419cf24a33df5a87c99e367528b44dc28cf (patch)
treedfa50da1818a1e9c1d0588c060051c65583821a3 /runtime/GCCLibraries
parentb2b9c20b6121a54a41ee1c583a4bff4389622da2 (diff)
Undo removal of the runtime libraries. While this may have been a bit
premature, these libraries will be going away for the 2.0 release. Other arrangements for profiling, gc, etc. should be made in the next few months. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime/GCCLibraries')
-rw-r--r--runtime/GCCLibraries/Makefile12
-rw-r--r--runtime/GCCLibraries/README.txt7
-rw-r--r--runtime/GCCLibraries/crtend/Exception.cpp54
-rw-r--r--runtime/GCCLibraries/crtend/Exception.h71
-rw-r--r--runtime/GCCLibraries/crtend/Makefile83
-rw-r--r--runtime/GCCLibraries/crtend/README.txt15
-rw-r--r--runtime/GCCLibraries/crtend/SJLJ-Exception.cpp146
-rw-r--r--runtime/GCCLibraries/crtend/SJLJ-Exception.h80
-rw-r--r--runtime/GCCLibraries/crtend/comp_genericeh.lst9
-rw-r--r--runtime/GCCLibraries/crtend/comp_main.lst3
-rw-r--r--runtime/GCCLibraries/crtend/comp_sjljeh.lst7
-rw-r--r--runtime/GCCLibraries/crtend/crtend.c16
-rw-r--r--runtime/GCCLibraries/libc/COPYING.LIB510
-rw-r--r--runtime/GCCLibraries/libc/LICENSE.TXT17
-rw-r--r--runtime/GCCLibraries/libc/LICENSES219
-rw-r--r--runtime/GCCLibraries/libc/Makefile19
-rw-r--r--runtime/GCCLibraries/libc/README.txt4
-rw-r--r--runtime/GCCLibraries/libc/atox.c118
-rw-r--r--runtime/GCCLibraries/libc/io.c18
-rw-r--r--runtime/GCCLibraries/libc/qsort.c261
-rw-r--r--runtime/GCCLibraries/libc/remove.c51
-rw-r--r--runtime/GCCLibraries/libc/string.c172
-rw-r--r--runtime/GCCLibraries/libgcc/Makefile16
-rw-r--r--runtime/GCCLibraries/libgcc/eprintf.c13
-rw-r--r--runtime/GCCLibraries/libm/Makefile16
-rw-r--r--runtime/GCCLibraries/libm/temp.c1
26 files changed, 1938 insertions, 0 deletions
diff --git a/runtime/GCCLibraries/Makefile b/runtime/GCCLibraries/Makefile
new file mode 100644
index 0000000000..b976f1248e
--- /dev/null
+++ b/runtime/GCCLibraries/Makefile
@@ -0,0 +1,12 @@
+##===- runtime/GCCLibraries/Makefile -----------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file was developed by the LLVM research group and is distributed under
+# the University of Illinois Open Source License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL := ../..
+PARALLEL_DIRS := crtend libc libgcc libm
+include $(LEVEL)/Makefile.common
diff --git a/runtime/GCCLibraries/README.txt b/runtime/GCCLibraries/README.txt
new file mode 100644
index 0000000000..24890d2ef1
--- /dev/null
+++ b/runtime/GCCLibraries/README.txt
@@ -0,0 +1,7 @@
+This directory contains libraries which are used when building the GCC
+front-end. For the most part, these are just stub libraries, but some
+of them contain actual code.
+
+In particular, the crtend library contains the runtime code to handle
+static constructors and destructors for C and C++ programs.
+
diff --git a/runtime/GCCLibraries/crtend/Exception.cpp b/runtime/GCCLibraries/crtend/Exception.cpp
new file mode 100644
index 0000000000..d4ac290122
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/Exception.cpp
@@ -0,0 +1,54 @@
+//===- Exception.cpp - Generic language-independent exceptions ------------===//
+//
+// This file defines the the shared data structures used by all language
+// specific exception handling runtime libraries.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Exception.h"
+
+// Thread local state for exception handling. FIXME: This should really be made
+// thread-local!
+
+// UncaughtExceptionStack - The stack of exceptions currently being thrown.
+static llvm_exception *UncaughtExceptionStack = 0;
+
+// __llvm_eh_has_uncaught_exception - This is used to implement
+// std::uncaught_exception.
+//
+bool __llvm_eh_has_uncaught_exception() throw() {
+ return UncaughtExceptionStack != 0;
+}
+
+// __llvm_eh_current_uncaught_exception - This function checks to see if the
+// current uncaught exception is of the specified language type. If so, it
+// returns a pointer to the exception area data.
+//
+void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw() {
+ if (UncaughtExceptionStack->ExceptionType == HandlerType)
+ return UncaughtExceptionStack+1;
+ return 0;
+}
+
+// __llvm_eh_add_uncaught_exception - This adds the specified exception to the
+// top of the uncaught exception stack. The exception should not already be on
+// the stack!
+void __llvm_eh_add_uncaught_exception(llvm_exception *E) throw() {
+ E->Next = UncaughtExceptionStack;
+ UncaughtExceptionStack = E;
+}
+
+
+// __llvm_eh_get_uncaught_exception - Returns the current uncaught exception.
+// There must be an uncaught exception for this to work!
+llvm_exception *__llvm_eh_get_uncaught_exception() throw() {
+ return UncaughtExceptionStack;
+}
+
+// __llvm_eh_pop_from_uncaught_stack - Remove the current uncaught exception
+// from the top of the stack.
+llvm_exception *__llvm_eh_pop_from_uncaught_stack() throw() {
+ llvm_exception *E = __llvm_eh_get_uncaught_exception();
+ UncaughtExceptionStack = E->Next;
+ return E;
+}
diff --git a/runtime/GCCLibraries/crtend/Exception.h b/runtime/GCCLibraries/crtend/Exception.h
new file mode 100644
index 0000000000..dc4d3a5f2c
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/Exception.h
@@ -0,0 +1,71 @@
+//===- Exception.h - Generic language-independent exceptions ----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the the shared data structures used by all language
+// specific exception handling runtime libraries.
+//
+// NOTE NOTE NOTE: A copy of this file lives in llvmgcc/libstdc++-v3/libsupc++/
+// Any modifications to this file must keep it in sync!
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef EXCEPTION_H
+#define EXCEPTION_H
+
+struct llvm_exception {
+ // ExceptionDestructor - This call-back function is used to destroy the
+ // current exception, without requiring the caller to know what the concrete
+ // exception type is.
+ //
+ void (*ExceptionDestructor)(llvm_exception *);
+
+ // ExceptionType - This field identifies what runtime library this exception
+ // came from. Currently defined values are:
+ // 0 - Error
+ // 1 - longjmp exception (see longjmp-exception.c)
+ // 2 - C++ exception (see c++-exception.c)
+ //
+ unsigned ExceptionType;
+
+ // Next - This points to the next exception in the current stack.
+ llvm_exception *Next;
+
+ // HandlerCount - This is a count of the number of handlers which have
+ // currently caught this exception. If the handler is caught and this number
+ // falls to zero, the exception is destroyed.
+ //
+ unsigned HandlerCount;
+
+ // isRethrown - This field is set on an exception if it has been 'throw;'n.
+ // This is needed because the exception might exit through a number of the
+ // end_catch statements matching the number of begin_catch statements that
+ // have been processed. When this happens, the exception should become
+ // uncaught, not dead.
+ //
+ int isRethrown;
+};
+
+enum {
+ ErrorException = 0,
+ SJLJException = 1,
+ CXXException = 2
+};
+
+// Language independent exception handling API...
+//
+extern "C" {
+ bool __llvm_eh_has_uncaught_exception() throw();
+ void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw();
+ void __llvm_eh_add_uncaught_exception(llvm_exception *E) throw();
+
+ llvm_exception *__llvm_eh_get_uncaught_exception() throw();
+ llvm_exception *__llvm_eh_pop_from_uncaught_stack() throw();
+}
+
+#endif
diff --git a/runtime/GCCLibraries/crtend/Makefile b/runtime/GCCLibraries/crtend/Makefile
new file mode 100644
index 0000000000..1fd3167246
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/Makefile
@@ -0,0 +1,83 @@
+##===- runtime/GCCLibraries/crtend/Makefile ----------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file was developed by the LLVM research group and is distributed under
+# the University of Illinois Open Source License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+#
+# This directory contains the C and C++ runtime libraries for the LLVM GCC
+# front-ends. See the README.txt file for more details.
+#
+# Since this archive has strange requirements, we use some custom rules for
+# building it.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../../..
+DONT_BUILD_RELINKED = 1
+LIBRARYNAME = crtend
+BYTECODE_DESTINATION = $(CFERuntimeLibDir)
+
+MainSrc := crtend.c
+GenericEHSrc := Exception.cpp
+SJLJEHSrc := SJLJ-Exception.cpp
+
+EXTRA_DIST := $(MainSrc) $(GenericEHSrc) $(SJLJEHSrc) \
+ comp_main.lst comp_genericeh.lst comp_sjljeh.lst
+
+include $(LEVEL)/Makefile.common
+
+MainObj := $(ObjDir)/crtend.bc
+GenericEHObj := $(ObjDir)/Exception.bc
+SJLJEHObj := $(ObjDir)/SJLJ-Exception.bc
+
+# __main and ctor/dtor support component
+$(ObjDir)/comp_main.bc: $(MainObj)
+ $(Echo) Linking $(notdir $@) component...
+ $(Verb) $(GCCLD) -link-as-library \
+ -internalize-public-api-file=$(PROJ_SRC_DIR)/comp_main.lst \
+ $(MainObj) -o $@
+
+# Generic exception handling support runtime.
+$(ObjDir)/comp_genericeh.bc: $(GenericEHObj)
+ $(Echo) Linking $(notdir $@) component...
+ $(Verb) $(GCCLD) -link-as-library \
+ -internalize-public-api-file=$(PROJ_SRC_DIR)/comp_genericeh.lst \
+ $(GenericEHObj) -o $@
+
+# setjmp/longjmp exception handling support runtime.
+$(ObjDir)/comp_sjljeh.bc: $(SJLJEHObj)
+ $(Echo) Linking $(notdir $@) component...
+ $(Verb) $(GCCLD) -link-as-library \
+ -internalize-public-api-file=$(PROJ_SRC_DIR)/comp_sjljeh.lst \
+ $(SJLJEHObj) -o $@
+
+SYMBOLHACKEDOBJS := $(ObjDir)/comp_main.bc $(ObjDir)/comp_genericeh.bc \
+ $(ObjDir)/comp_sjljeh.bc
+
+all-local:: $(LibName.BCA)
+
+ifdef BYTECODE_DESTINATION
+BytecodeDestDir := $(BYTECODE_DESTINATION)
+else
+BytecodeDestDir := $(PROJ_libdir)
+endif
+
+DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a
+install-bytecode-local:: $(DestBytecodeLib)
+install-local:: $(DestBytecodeLib)
+
+$(LibName.BCA): $(SYMBOLHACKEDOBJS) $(LibDir)/.dir $(LLVMToolDir)/llvm-ar
+ $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@)
+ $(Verb) $(RM) -f $@
+ $(Verb) $(LArchive) $@ $(SYMBOLHACKEDOBJS)
+
+$(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA)
+ $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib)
+ $(Verb) $(DataInstall) $(LibName.BCA) $(DestBytecodeLib)
+
+uninstall-local::
+ $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib)
+ -$(Verb) $(RM) -f $(DestBytecodeLib)
diff --git a/runtime/GCCLibraries/crtend/README.txt b/runtime/GCCLibraries/crtend/README.txt
new file mode 100644
index 0000000000..a763cb26dd
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/README.txt
@@ -0,0 +1,15 @@
+This directory contains the C and C++ runtime libraries for the LLVM GCC
+front-ends. It is composed of four distinct pieces:
+
+1. __main: now dead, but provided for compatibility.
+
+2. Generic EH support routines. This is used by C/C++ programs that use
+ setjmp/longjmp, and by C++ programs that make use of exceptions.
+
+3. setjmp/longjmp EH support. This is used by C/C++ programs that call SJLJ.
+
+4. C++ exception handling runtime support.
+
+These four components are compiled together into an archive file, so that
+applications using a subset of the four do not pull in unnecessary code and
+dependencies.
diff --git a/runtime/GCCLibraries/crtend/SJLJ-Exception.cpp b/runtime/GCCLibraries/crtend/SJLJ-Exception.cpp
new file mode 100644
index 0000000000..6a3e4724ae
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/SJLJ-Exception.cpp
@@ -0,0 +1,146 @@
+//===- SJLJ-Exception.cpp - SetJmp/LongJmp Exception Handling -------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the API used by the Setjmp/Longjmp exception handling
+// runtime library.
+//
+//===----------------------------------------------------------------------===//
+
+#include "SJLJ-Exception.h"
+#include <cstdlib>
+#include <cassert>
+
+// Assert should only be used for debugging the runtime library. Enabling it in
+// CVS will break some platforms!
+#undef assert
+#define assert(X)
+
+// get_sjlj_exception - Adjust the llvm_exception pointer to be an appropriate
+// llvm_sjlj_exception pointer.
+inline llvm_sjlj_exception *get_sjlj_exception(llvm_exception *E) {
+ assert(E->ExceptionType == SJLJException);
+ return (llvm_sjlj_exception*)(E+1) - 1;
+}
+
+// SetJmpMapEntry - One entry in a linked list of setjmps for the current
+// function.
+struct SetJmpMapEntry {
+ void *JmpBuf;
+ unsigned SetJmpID;
+ SetJmpMapEntry *Next;
+};
+
+// SJLJDestructor - This function is used to free the exception when
+// language-indent code needs to destroy the exception without knowing exactly
+// what type it is.
+static void SJLJDestructor(llvm_exception *E) {
+ free(get_sjlj_exception(E));
+}
+
+
+// __llvm_sjljeh_throw_longjmp - This function creates the longjmp exception and
+// returns. It takes care of mapping the longjmp value from 0 -> 1 as
+// appropriate. The caller should immediately call llvm.unwind after this
+// function call.
+void __llvm_sjljeh_throw_longjmp(void *JmpBuffer, int Val) throw() {
+ llvm_sjlj_exception *E =
+ (llvm_sjlj_exception *)malloc(sizeof(llvm_sjlj_exception));
+ E->BaseException.ExceptionDestructor = SJLJDestructor;
+ E->BaseException.ExceptionType = SJLJException;
+ E->BaseException.HandlerCount = 0;
+ E->BaseException.isRethrown = 0;
+ E->JmpBuffer = JmpBuffer;
+ E->LongJmpValue = Val ? Val : 1;
+
+ __llvm_eh_add_uncaught_exception(&E->BaseException);
+}
+
+// __llvm_sjljeh_init_setjmpmap - This funciton initializes the pointer provided
+// to an empty setjmp map, and should be called on entry to a function which
+// calls setjmp.
+void __llvm_sjljeh_init_setjmpmap(void **SetJmpMap) throw() {
+ *SetJmpMap = 0;
+}
+
+// __llvm_sjljeh_destroy_setjmpmap - This function frees all memory associated
+// with the specified setjmpmap structure. It should be called on all exits
+// (returns or unwinds) from the function which calls ...init_setjmpmap.
+void __llvm_sjljeh_destroy_setjmpmap(void **SetJmpMap) throw() {
+ SetJmpMapEntry *Next;
+ for (SetJmpMapEntry *SJE = *(SetJmpMapEntry**)SetJmpMap; SJE; SJE = Next) {
+ Next = SJE->Next;
+ free(SJE);
+ }
+}
+
+// __llvm_sjljeh_add_setjmp_to_map - This function adds or updates an entry to
+// the map, to indicate which setjmp should be returned to if a longjmp happens.
+void __llvm_sjljeh_add_setjmp_to_map(void **SetJmpMap, void *JmpBuf,
+ unsigned SetJmpID) throw() {
+ SetJmpMapEntry **SJE = (SetJmpMapEntry**)SetJmpMap;
+
+ // Scan for a pre-existing entry...
+ for (; *SJE; SJE = &(*SJE)->Next)
+ if ((*SJE)->JmpBuf == JmpBuf) {
+ (*SJE)->SetJmpID = SetJmpID;
+ return;
+ }
+
+ // No prexisting entry found, append to the end of the list...
+ SetJmpMapEntry *New = (SetJmpMapEntry *)malloc(sizeof(SetJmpMapEntry));
+ *SJE = New;
+ New->JmpBuf = JmpBuf;
+ New->SetJmpID = SetJmpID;
+ New->Next = 0;
+}
+
+// __llvm_sjljeh_is_longjmp_exception - This function returns true if the
+// current uncaught exception is a longjmp exception. This is the first step of
+// catching a sjlj exception.
+bool __llvm_sjljeh_is_longjmp_exception() throw() {
+ return __llvm_eh_current_uncaught_exception_type(SJLJException) != 0;
+}
+
+// __llvm_sjljeh_get_longjmp_value - This function returns the value that the
+// setjmp call should "return". This requires that the current uncaught
+// exception be a sjlj exception, though it does not require the exception to be
+// caught by this function.
+int __llvm_sjljeh_get_longjmp_value() throw() {
+ llvm_sjlj_exception *E =
+ get_sjlj_exception(__llvm_eh_get_uncaught_exception());
+ return E->LongJmpValue;
+}
+
+// __llvm_sjljeh_try_catching_longjmp_exception - This function checks to see if
+// the current uncaught longjmp exception matches any of the setjmps collected
+// in the setjmpmap structure. If so, it catches and destroys the exception,
+// returning the index of the setjmp which caught the exception. If not, it
+// leaves the exception uncaught and returns a value of ~0.
+unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **SetJmpMap) throw(){
+ llvm_sjlj_exception *E =
+ get_sjlj_exception(__llvm_eh_get_uncaught_exception());
+
+ // Scan for a matching entry in the SetJmpMap...
+ SetJmpMapEntry *SJE = *(SetJmpMapEntry**)SetJmpMap;
+ for (; SJE; SJE = SJE->Next)
+ if (SJE->JmpBuf == E->JmpBuffer) {
+ // "Catch" and destroy the exception...
+ __llvm_eh_pop_from_uncaught_stack();
+
+ // We know it's a longjmp exception, so we can just free it instead of
+ // calling the destructor.
+ free(E);
+
+ // Return the setjmp ID which we should branch to...
+ return SJE->SetJmpID;
+ }
+
+ // No setjmp in this function catches the exception!
+ return ~0;
+}
diff --git a/runtime/GCCLibraries/crtend/SJLJ-Exception.h b/runtime/GCCLibraries/crtend/SJLJ-Exception.h
new file mode 100644
index 0000000000..ac27cbed7f
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/SJLJ-Exception.h
@@ -0,0 +1,80 @@
+//===- SJLJ-Exception.h - SetJmp/LongJmp Exception Handling -----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the data structures and API used by the Setjmp/Longjmp
+// exception handling runtime library.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SJLJ_EXCEPTION_H
+#define SJLJ_EXCEPTION_H
+
+#include "Exception.h"
+
+struct llvm_sjlj_exception {
+ // JmpBuffer - This is the buffer which was longjmp'd with.
+ //
+ void *JmpBuffer;
+
+ // LongJmpValue - The value passed into longjmp, which the corresponding
+ // setjmp should return. Note that this value will never be equal to 0.
+ //
+ int LongJmpValue;
+
+ // BaseException - The language independent portion of the exception state.
+ // This is at the end of the record so that we can add additional members to
+ // this structure without breaking binary compatibility.
+ //
+ llvm_exception BaseException;
+};
+
+extern "C" {
+ // __llvm_sjljeh_throw_longjmp - This function creates the longjmp exception
+ // and returns. It takes care of mapping the longjmp value from 0 -> 1 as
+ // appropriate. The caller should immediately call llvm.unwind after this
+ // function call.
+ void __llvm_sjljeh_throw_longjmp(void *JmpBuffer, int Val) throw();
+
+ // __llvm_sjljeh_init_setjmpmap - This funciton initializes the pointer
+ // provided to an empty setjmp map, and should be called on entry to a
+ // function which calls setjmp.
+ void __llvm_sjljeh_init_setjmpmap(void **SetJmpMap) throw();
+
+ // __llvm_sjljeh_destroy_setjmpmap - This function frees all memory associated
+ // with the specified setjmpmap structure. It should be called on all exits
+ // (returns or unwinds) from the function which calls ...init_setjmpmap.
+ void __llvm_sjljeh_destroy_setjmpmap(void **SetJmpMap) throw();
+
+ // __llvm_sjljeh_add_setjmp_to_map - This function adds or updates an entry to
+ // the map, to indicate which setjmp should be returned to if a longjmp
+ // happens.
+ void __llvm_sjljeh_add_setjmp_to_map(void **SetJmpMap, void *JmpBuf,
+ unsigned SetJmpID) throw();
+
+ // __llvm_sjljeh_is_longjmp_exception - This function returns true if the
+ // current uncaught exception is a longjmp exception. This is the first step
+ // of catching a sjlj exception.
+ bool __llvm_sjljeh_is_longjmp_exception() throw();
+
+ // __llvm_sjljeh_get_longjmp_value - This function returns the value that the
+ // setjmp call should "return". This requires that the current uncaught
+ // exception be a sjlj exception, though it does not require the exception to
+ // be caught by this function.
+ int __llvm_sjljeh_get_longjmp_value() throw();
+
+ // __llvm_sjljeh_try_catching_longjmp_exception - This function checks to see
+ // if the current uncaught longjmp exception matches any of the setjmps
+ // collected in the setjmpmap structure. If so, it catches and destroys the
+ // exception, returning the index of the setjmp which caught the exception.
+ // If not, it leaves the exception uncaught and returns a value of ~0.
+ unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **SetJmpMap)
+ throw();
+}
+
+#endif
diff --git a/runtime/GCCLibraries/crtend/comp_genericeh.lst b/runtime/GCCLibraries/crtend/comp_genericeh.lst
new file mode 100644
index 0000000000..9270648b03
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/comp_genericeh.lst
@@ -0,0 +1,9 @@
+__main
+llvm.global_ctors
+llvm.global_dtors
+
+__llvm_eh_has_uncaught_exception
+__llvm_eh_current_uncaught_exception_type
+__llvm_eh_add_uncaught_exception
+__llvm_eh_get_uncaught_exception
+__llvm_eh_pop_from_uncaught_stack
diff --git a/runtime/GCCLibraries/crtend/comp_main.lst b/runtime/GCCLibraries/crtend/comp_main.lst
new file mode 100644
index 0000000000..ea953b7f92
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/comp_main.lst
@@ -0,0 +1,3 @@
+__main
+llvm.global_ctors
+llvm.global_dtors
diff --git a/runtime/GCCLibraries/crtend/comp_sjljeh.lst b/runtime/GCCLibraries/crtend/comp_sjljeh.lst
new file mode 100644
index 0000000000..afcaaf0d05
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/comp_sjljeh.lst
@@ -0,0 +1,7 @@
+__llvm_sjljeh_throw_longjmp
+__llvm_sjljeh_init_setjmpmap
+__llvm_sjljeh_destroy_setjmpmap
+__llvm_sjljeh_add_setjmp_to_map
+__llvm_sjljeh_is_longjmp_exception
+__llvm_sjljeh_get_longjmp_value
+__llvm_sjljeh_try_catching_longjmp_exception
diff --git a/runtime/GCCLibraries/crtend/crtend.c b/runtime/GCCLibraries/crtend/crtend.c
new file mode 100644
index 0000000000..561b6fd241
--- /dev/null
+++ b/runtime/GCCLibraries/crtend/crtend.c
@@ -0,0 +1,16 @@
+/*===- crtend.c - Initialization code for programs ------------------------===*\
+ *
+ * The LLVM Compiler Infrastructure
+ *
+ * This file was developed by the LLVM research group and is distributed under
+ * the University of Illinois Open Source License. See LICENSE.TXT for details.
+ *
+ *===----------------------------------------------------------------------===*
+ *
+ * This file defines the __main function, which we preserve for backwards
+ * compatibility.
+ *
+\*===----------------------------------------------------------------------===*/
+
+void __main(void) {
+}
diff --git a/runtime/GCCLibraries/libc/COPYING.LIB b/runtime/GCCLibraries/libc/COPYING.LIB
new file mode 100644
index 0000000000..cf9b6b9972
--- /dev/null
+++ b/runtime/GCCLibraries/libc/COPYING.LIB
@@ -0,0 +1,510 @@
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+^L
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard. To achieve this, non-free programs must
+be allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+^L
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that us