Include standard library functions in a specific memory section

557 views Asked by At

In C, we can force the linker to put a specific function in a specific section from the source code, using something like the following example.

Here, the function my_function is tagged with the preprocessor macro PUT_IN_USER_SECTION in order to tell the linker to put it in the section .user_section.

#define PUT_IN_USER_SECTION  __attribute__((__section__(".user_section"))) __attribute__ ((noinline))

double PUT_IN_USER_SECTION my_function(double a, double b)
{
    // Function content
}

Now, what I'd like to know is, when we use standard functions (for example log functions from the math.h library) from the GLIBC, MUSL, ... and we perform static linking: is it possible to put those functions in specific sections? and how to that?

1

There are 1 answers

0
ralf htp On