[PATCH] [nolibc] Add a test case for Linux/x86_64.

Peter Collingbourne peter at pcc.me.uk
Mon May 27 14:16:06 PDT 2013


Hi kcc,

http://llvm-reviews.chandlerc.com/D873

Files:
  lib/sanitizer_common/tests/CMakeLists.txt
  lib/sanitizer_common/tests/sanitizer_nolibc_test.cc

Index: lib/sanitizer_common/tests/CMakeLists.txt
===================================================================
--- lib/sanitizer_common/tests/CMakeLists.txt
+++ lib/sanitizer_common/tests/CMakeLists.txt
@@ -86,6 +86,21 @@
                        DEPS ${SANITIZER_TEST_OBJECTS} ${SANITIZER_COMMON_LIB}
                        LINK_FLAGS ${SANITIZER_TEST_LINK_FLAGS_COMMON}
                                   -lpthread ${TARGET_FLAGS})
+
+   if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND "${arch}" STREQUAL "x86_64")
+     clang_compile(sanitizer_nolibc_test.${arch}.o sanitizer_nolibc_test.cc
+                   CFLAGS ${SANITIZER_TEST_CFLAGS_COMMON} ${TARGET_FLAGS}
+                   DEPS ${SANITIZER_RUNTIME_LIBRARIES}
+                   ${SANITIZER_TEST_HEADERS})
+     add_compiler_rt_test(SanitizerUnitTests "Sanitizer-${arch}-Nolibc-Test"
+                          OBJECTS sanitizer_nolibc_test.${arch}.o
+                          -Wl,-whole-archive
+                          libRTSanitizerCommon.test.nolibc.${arch}.a
+                          -Wl,-no-whole-archive
+                          DEPS sanitizer_nolibc_test.${arch}.o
+                               RTSanitizerCommon.test.nolibc.${arch}
+                          LINK_FLAGS -nostdlib)
+   endif()
 endmacro()
 
 if(COMPILER_RT_CAN_EXECUTE_TESTS)
@@ -99,6 +114,8 @@
       add_sanitizer_common_lib("RTSanitizerCommon.test.x86_64"
                                $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
                                $<TARGET_OBJECTS:RTSanitizerCommonLibc.x86_64>)
+      add_sanitizer_common_lib("RTSanitizerCommon.test.nolibc.x86_64"
+                               $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>)
     endif()
     if(CAN_TARGET_i386)
       add_sanitizer_common_lib("RTSanitizerCommon.test.i386"
Index: lib/sanitizer_common/tests/sanitizer_nolibc_test.cc
===================================================================
--- /dev/null
+++ lib/sanitizer_common/tests/sanitizer_nolibc_test.cc
@@ -0,0 +1,9 @@
+#include <sanitizer_common/sanitizer_libc.h>
+
+// TODO(pcc): Remove these once the allocator dependency is gone.
+extern "C" void *__libc_malloc() { return 0; }
+extern "C" void __libc_free(void *p) {}
+
+extern "C" void _start() {
+  internal__exit(0);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D873.1.patch
Type: text/x-patch
Size: 2288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130527/647211e9/attachment.bin>


More information about the llvm-commits mailing list