Work on restricting symbol visibility.

llvm-svn: 149633
This commit is contained in:
Howard Hinnant 2012-02-02 20:47:28 +00:00
parent 90ef25c05e
commit eaa65afc7b
9 changed files with 85 additions and 56 deletions

View File

@ -12,6 +12,8 @@
#include <cxxabi.h>
#pragma GCC visibility push(hidden)
namespace __cxxabiv1
{
@ -159,4 +161,7 @@ __demangle(const char*, char*, size_t);
} // __libcxxabi
} // __cxxabiv1
#pragma GCC visibility pop
#endif // _CXA_DEMANGLE_H

View File

@ -12,6 +12,8 @@
#include <stdarg.h>
#include "abort_message.h"
#pragma GCC visibility push(hidden)
#if __APPLE__
# if defined(__has_include) && __has_include(<CrashReporterClient.h>)
# define HAVE_CRASHREPORTERCLIENT_H 1
@ -54,3 +56,5 @@ void abort_message(const char* format, ...)
abort();
}
#pragma GCC visibility pop

View File

@ -12,6 +12,8 @@
#include <stdio.h>
#pragma GCC visibility push(hidden)
#ifdef __cplusplus
extern "C" {
#endif
@ -25,6 +27,7 @@ __attribute__((visibility("hidden"), noreturn))
}
#endif
#pragma GCC visibility pop
#endif

View File

@ -10692,9 +10692,6 @@ __demangle_tree::__parse()
}
}
#pragma GCC visibility pop
#pragma GCC visibility push(default)
__demangle_tree
__demangle(const char* mangled_name, char* buf, size_t bs)
{
@ -10772,6 +10769,9 @@ printf("\n");
} // __libcxxabi
#pragma GCC visibility pop
#pragma GCC visibility push(default)
extern "C"
{

View File

@ -34,6 +34,8 @@
namespace __cxxabiv1 {
#pragma GCC visibility push(default)
// Utility routines
static
inline
@ -615,4 +617,6 @@ __cxa_uncaught_exception() throw()
} // extern "C"
#pragma GCC visibility pop
} // abi

View File

@ -17,6 +17,8 @@
namespace __cxxabiv1 {
#pragma GCC visibility push(hidden)
static const uint64_t kOurExceptionClass = 0x434C4E47432B2B00; // CLNGC++\0
static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC++\1
static const uint64_t get_vendor_and_language = 0xFFFFFFFFFFFFFF00; // mask for CLNGC++
@ -103,10 +105,14 @@ static const uint64_t get_vendor_and_language = 0xFFFFFFFFFFFFFF00; // mask
#endif
};
#pragma GCC visibility pop
#pragma GCC visibility push(default)
extern "C" __cxa_eh_globals * __cxa_get_globals ();
extern "C" __cxa_eh_globals * __cxa_get_globals_fast ();
extern "C" void * __cxa_allocate_dependent_exception ();
extern "C" void __cxa_free_dependent_exception (void * dependent_exception);
#pragma GCC visibility pop
}

View File

@ -12,7 +12,7 @@
namespace __cxxabiv1
{
//#pragma GCC visibility push(hidden)
#pragma GCC visibility push(hidden)
// __shim_type_info
@ -84,8 +84,6 @@ __pointer_to_member_type_info::~__pointer_to_member_type_info()
{
}
#pragma GCC visibility push(hidden)
// can_catch
// A handler is a match for an exception object of type E if
@ -318,7 +316,7 @@ __pointer_type_info::can_catch(const __shim_type_info* thrown_type,
return false;
}
//#pragma GCC visibility pop
#pragma GCC visibility pop
#pragma GCC visibility push(default)
// __dynamic_cast
@ -398,9 +396,9 @@ __pointer_type_info::can_catch(const __shim_type_info* thrown_type,
extern "C"
void*
__dynamic_cast(const void* static_ptr,
const __class_type_info* static_type,
const __class_type_info* dst_type,
std::ptrdiff_t src2dst_offset)
const __class_type_info* static_type,
const __class_type_info* dst_type,
std::ptrdiff_t src2dst_offset)
{
// Possible future optimization: Take advantage of src2dst_offset
// Currently clang always sets src2dst_offset to -1 (no hint).

View File

@ -16,9 +16,9 @@
namespace __cxxabiv1
{
//#pragma GCC visibility push(hidden)
#pragma GCC visibility push(hidden)
class __shim_type_info
class __attribute__ ((__visibility__("hidden"))) __shim_type_info
: public std::type_info
{
public:
@ -27,36 +27,36 @@ public:
virtual bool can_catch(const __shim_type_info* thrown_type, void*& adjustedPtr) const = 0;
};
class __fundamental_type_info
class __attribute__ ((__visibility__("default"))) __fundamental_type_info
: public __shim_type_info
{
public:
virtual ~__fundamental_type_info();
virtual bool can_catch(const __shim_type_info*, void*&) const;
__attribute__ ((__visibility__("hidden"))) virtual ~__fundamental_type_info();
__attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
};
class __array_type_info
class __attribute__ ((__visibility__("default"))) __array_type_info
: public __shim_type_info
{
public:
virtual ~__array_type_info();
virtual bool can_catch(const __shim_type_info*, void*&) const;
__attribute__ ((__visibility__("hidden"))) virtual ~__array_type_info();
__attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
};
class __function_type_info
class __attribute__ ((__visibility__("default"))) __function_type_info
: public __shim_type_info
{
public:
virtual ~__function_type_info();
virtual bool can_catch(const __shim_type_info*, void*&) const;
__attribute__ ((__visibility__("hidden"))) virtual ~__function_type_info();
__attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
};
class __enum_type_info
class __attribute__ ((__visibility__("default"))) __enum_type_info
: public __shim_type_info
{
public:
virtual ~__enum_type_info();
virtual bool can_catch(const __shim_type_info*, void*&) const;
__attribute__ ((__visibility__("hidden"))) virtual ~__enum_type_info();
__attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
};
enum
@ -118,33 +118,43 @@ struct __dynamic_cast_info
};
// Has no base class
class __class_type_info
class __attribute__ ((__visibility__("default"))) __class_type_info
: public __shim_type_info
{
public:
virtual ~__class_type_info();
__attribute__ ((__visibility__("hidden"))) virtual ~__class_type_info();
void process_static_type_above_dst(__dynamic_cast_info*, const void*, const void*, int) const;
void process_static_type_below_dst(__dynamic_cast_info*, const void*, int) const;
void process_found_base_class(__dynamic_cast_info*, void*, int) const;
virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int) const;
virtual void search_below_dst(__dynamic_cast_info*, const void*, int) const;
virtual bool can_catch(const __shim_type_info*, void*&) const;
virtual void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
__attribute__ ((__visibility__("hidden")))
void process_static_type_above_dst(__dynamic_cast_info*, const void*, const void*, int) const;
__attribute__ ((__visibility__("hidden")))
void process_static_type_below_dst(__dynamic_cast_info*, const void*, int) const;
__attribute__ ((__visibility__("hidden")))
void process_found_base_class(__dynamic_cast_info*, void*, int) const;
__attribute__ ((__visibility__("hidden")))
virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int) const;
__attribute__ ((__visibility__("hidden")))
virtual void search_below_dst(__dynamic_cast_info*, const void*, int) const;
__attribute__ ((__visibility__("hidden")))
virtual bool can_catch(const __shim_type_info*, void*&) const;
__attribute__ ((__visibility__("hidden")))
virtual void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
};
// Has one non-virtual public base class at offset zero
class __si_class_type_info
class __attribute__ ((__visibility__("default"))) __si_class_type_info
: public __class_type_info
{
public:
const __class_type_info* __base_type;
virtual ~__si_class_type_info();
__attribute__ ((__visibility__("hidden"))) virtual ~__si_class_type_info();
virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int) const;
virtual void search_below_dst(__dynamic_cast_info*, const void*, int) const;
virtual void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
__attribute__ ((__visibility__("hidden")))
virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int) const;
__attribute__ ((__visibility__("hidden")))
virtual void search_below_dst(__dynamic_cast_info*, const void*, int) const;
__attribute__ ((__visibility__("hidden")))
virtual void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
};
struct __base_class_type_info
@ -166,7 +176,7 @@ public:
};
// Has one or more base classes
class __vmi_class_type_info
class __attribute__ ((__visibility__("default"))) __vmi_class_type_info
: public __class_type_info
{
public:
@ -182,14 +192,17 @@ public:
// more derived objects
};
virtual ~__vmi_class_type_info();
__attribute__ ((__visibility__("hidden"))) virtual ~__vmi_class_type_info();
virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int) const;
virtual void search_below_dst(__dynamic_cast_info*, const void*, int) const;
virtual void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
__attribute__ ((__visibility__("hidden")))
virtual void search_above_dst(__dynamic_cast_info*, const void*, const void*, int) const;
__attribute__ ((__visibility__("hidden")))
virtual void search_below_dst(__dynamic_cast_info*, const void*, int) const;
__attribute__ ((__visibility__("hidden")))
virtual void has_unambiguous_public_base(__dynamic_cast_info*, void*, int) const;
};
class __pbase_type_info
class __attribute__ ((__visibility__("default"))) __pbase_type_info
: public __shim_type_info
{
public:
@ -205,28 +218,28 @@ public:
__incomplete_class_mask = 0x10
};
virtual ~__pbase_type_info();
virtual bool can_catch(const __shim_type_info*, void*&) const;
__attribute__ ((__visibility__("hidden"))) virtual ~__pbase_type_info();
__attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
};
class __pointer_type_info
class __attribute__ ((__visibility__("default"))) __pointer_type_info
: public __pbase_type_info
{
public:
virtual ~__pointer_type_info();
virtual bool can_catch(const __shim_type_info*, void*&) const;
__attribute__ ((__visibility__("hidden"))) virtual ~__pointer_type_info();
__attribute__ ((__visibility__("hidden"))) virtual bool can_catch(const __shim_type_info*, void*&) const;
};
class __pointer_to_member_type_info
class __attribute__ ((__visibility__("default"))) __pointer_to_member_type_info
: public __pbase_type_info
{
public:
const __class_type_info* __context;
virtual ~__pointer_to_member_type_info();
__attribute__ ((__visibility__("hidden"))) virtual ~__pointer_to_member_type_info();
};
//#pragma GCC visibility pop
#pragma GCC visibility pop
} // __cxxabiv1

View File

@ -9,8 +9,6 @@
#include <typeinfo>
#pragma GCC visibility push(default)
namespace std
{
@ -53,5 +51,3 @@ bad_typeid::what() const _NOEXCEPT
}
} // std
#pragma GCC visibility pop