I am working on some inline code that comes as a static library. We would like to remove all internal characters from the library and save only API characters.
Here is an example of what we want to do: imagine that you have a file called internal.c and one called api.c that looks like this:
int fibonacci(int n) { } #include "internal.h" #include <stdio.h> void print_fibonacci(n) { printf("Fibonacci(%d): %d\n", n, fibonacci(n)); }
The user should have access only to the print_fibonacci function, and all internal characters, such as the fibonacci function, must be allowed before sending. This means that the user should be able to define his own function called fibonacci , without worrying about conflicts with the library.
We have already tried intercom using ld --relocatable , but we cannot apparently remove characters after using objcopy. Is this even possible?
Thanks for the help!
Edit: A custom fibonacci function should not replace a library-specific function, it should just be able to coexist. I am mainly looking for a solution to resolving name conflicts.
c linker binaryfiles static-libraries
Olivier desenfans
source share