Introduce symbol_visibility.h with macros to define hidden functions
These were used in function_remapper.cpp but can be used elsewhere too, so move them to a private header. Also use them for the stack protector hidden function definition (probably not so useful since gcc2 doesn't support using the stack protector anyway?). The gcc2 way to make a symbol hidden is to manually generate the .hidden directive in the assembler output. This is not perfect: it is hard to use for C++ functions and methods (manual mangling of the name is needed), and inline assembler can only be inserted inside functions. But the alternative is patching gcc2 to add support for the function attribute, and I don't want to dig into that today.
This commit is contained in:
parent
cfa6534031
commit
857c79a6b8
@ -82,6 +82,7 @@
|
||||
#define _PACKED __attribute__((packed))
|
||||
#define _PRINTFLIKE(_format_, _args_) \
|
||||
__attribute__((format(__printf__, _format_, _args_)))
|
||||
|
||||
#if __GNUC__ >= 4
|
||||
# define _EXPORT __attribute__((visibility("default")))
|
||||
# define B_ALWAYS_INLINE __attribute__((always_inline)) inline
|
||||
|
19
headers/private/system/symbol_visibility.h
Normal file
19
headers/private/system/symbol_visibility.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef SYMBOL_VISIBILITY_H
|
||||
#define SYMBOL_VISIBILITY_H
|
||||
|
||||
|
||||
#if __GNUC__ >= 4
|
||||
# define HIDDEN_FUNCTION(function) do {} while (0)
|
||||
# define HIDDEN_FUNCTION_ATTRIBUTE __attribute__((visibility("hidden")))
|
||||
#else
|
||||
# define HIDDEN_FUNCTION(function) asm volatile(".hidden " #function)
|
||||
# define HIDDEN_FUNCTION_ATTRIBUTE
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* !SYMBOL_VISIBILITY_H */
|
@ -10,6 +10,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers build os storage ] : true ;
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) headers build os support ] : true ;
|
||||
|
||||
UsePrivateBuildHeaders kernel libroot system ;
|
||||
UsePrivateHeaders system ;
|
||||
|
||||
{
|
||||
local defines = [ FDefines
|
||||
|
@ -7,18 +7,11 @@
|
||||
#include <stdarg.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "symbol_visibility.h"
|
||||
|
||||
#include "remapped_functions.h"
|
||||
|
||||
|
||||
#if __GNUC__ >= 4
|
||||
# define HIDDEN_FUNCTION(function) do {} while (0)
|
||||
# define HIDDEN_FUNCTION_ATTRIBUTE __attribute__((visibility("hidden")))
|
||||
#else
|
||||
# define HIDDEN_FUNCTION(function) asm volatile(".hidden " #function)
|
||||
# define HIDDEN_FUNCTION_ATTRIBUTE
|
||||
#endif
|
||||
|
||||
|
||||
extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fchmod(int fd, mode_t mode)
|
||||
{
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include "private/system/symbol_visibility.h"
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
@ -41,6 +43,7 @@ __init_stack_protector()
|
||||
void
|
||||
__stack_chk_fail()
|
||||
{
|
||||
HIDDEN_FUNCTION(__stack_chk_fail_local);
|
||||
sigset_t mask;
|
||||
sigfillset(&mask);
|
||||
sigdelset(&mask, SIGABRT);
|
||||
@ -51,8 +54,5 @@ __stack_chk_fail()
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if __GNUC__ >= 4
|
||||
extern "C" void __stack_chk_fail_local() __attribute__((visibility("hidden")));
|
||||
extern "C" void __stack_chk_fail_local() HIDDEN_FUNCTION_ATTRIBUTE;
|
||||
__weak_reference(__stack_chk_fail, __stack_chk_fail_local);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user