tools/nolibc: move exported functions to their own section
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Feb 2022 16:23:44 +0000 (17:23 +0100)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 21 Apr 2022 00:05:45 +0000 (17:05 -0700)
Some functions like raise() and memcpy() are permanently exported because
they're needed by libgcc on certain platforms. However most of the time
they are not needed and needlessly take space.

Let's move them to their own sub-section, called .text.nolibc_<function>.
This allows ld to get rid of them if unused when passed --gc-sections.

Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/include/nolibc/stdlib.h
tools/include/nolibc/string.h

index 4cc1fdf6791e0ecb1ce51cd4e89d0fd5b703bd59..da08ff30c15aa3fff7e0c0a377872af796f1e5fc 100644 (file)
@@ -314,7 +314,7 @@ int msleep(unsigned int msecs)
 }
 
 /* This one is not marked static as it's needed by libgcc for divide by zero */
-__attribute__((weak,unused))
+__attribute__((weak,unused,section(".text.nolibc_raise")))
 int raise(int signal)
 {
        return sys_kill(sys_getpid(), signal);
index c550c9ba8f4c7c5582713dc13ac9920f5223983d..c1661589cb3c6eb7b3e903bb1292400ad0934b97 100644 (file)
@@ -69,7 +69,7 @@ void *memmove(void *dst, const void *src, size_t len)
 }
 
 /* must be exported, as it's used by libgcc on ARM */
-__attribute__((weak,unused))
+__attribute__((weak,unused,section(".text.nolibc_memcpy")))
 void *memcpy(void *dst, const void *src, size_t len)
 {
        return _nolibc_memcpy_up(dst, src, len);