haiku/headers/private/system/symbol_visibility.h
Adrien Destugues 857c79a6b8 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.
2021-10-09 15:03:36 +02:00

20 lines
469 B
C

/*
* 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 */