[RFC,3/6] sys/cdefs.h: Define __TEXT_STARTUP & __TEXT_EXIT
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
redhat-pt-bot/TryBot-still_applies |
warning
|
Patch no longer applies to master
|
Commit Message
GCC already tries to place functions that it knows will only be called
at startup (constructors and main ()) into .text.startup, and those that
will only be called at exit (destructors) into .text.exit, to improve
cache locality. These contents of these sections then get grouped
together during linking.
What GCC does not know is that glibc contains a lot of code that is not
ELF constructors or destructors (nor main ()), but that is also only
executed on startup or exit. To help GCC and the linker group such code
together, we can mark it up explicitly.
To that end, this patch introduces __TEXT_STARTUP and __TEXT_EXIT macros
that can be applied to functions to mark them as startup-only or
exit-only, respectively.
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
include/sys/cdefs.h | 3 +++
1 file changed, 3 insertions(+)
@@ -43,6 +43,9 @@ rtld_hidden_proto (__chk_fail)
#endif
+#define __TEXT_STARTUP __attribute__ ((section (".text.startup")))
+#define __TEXT_EXIT __attribute__ ((section (".text.exit")))
+
#endif /* !defined _ISOMAC */
#endif