I'm not the biggest expert in shared libraries, so I'm probably wrong!
If I can guess what you are trying to do, just connect your shared lib with libc.so. You do not need an extra copy of sscanf built into your library.
I answered your questions before I understood what you came to, in case you are interested in the answers.
Is there a way to tell ld to allow only certain characters when creating a shared library?
only in extern, and not in static, functions and variables are included in the symbol table of the shared library.
When you create your shared library, any characters not found in the objects on the linker command line remain unresolved. If the linker complains about this, you probably need to link your shared library to the shared libc. You can have shared libraries that depend on other shared libraries, and ld.so can work with dependency chains.
If I had more reputation, I would ask this as a comment: Do you have a customized version of sprintf / sscanf, or would it be nice if your shared library used the implementation in -lc? If -lc ββis ok, then my answer probably solves your problem. If not, then you need to create your shared library from objects that have only the functions you need. those. do not associate it with /usr/lib/libc.a.
Maybe I am embarrassed by your
libc.a (not really the "real" libc) line. /usr/lib/libc.a is really glibc (on linux). This is a statically linked copy of the same code in libc.so. If you are not talking about your own libc.a (which I thought about first) ...
Include libc.a in the shared library? You probably can, but not like that, because it probably doesn't compile as position-independent code, so many ld.so moves will be required at runtime.
Extract sscanf from libc.a and indicate what's on the linker line?
Maybe. ar t / usr / lib / libc.a to display content. (ar args are like tar. tar was ar for tapes .... The old Unix school is here.) This is probably not that simple, because sscanf is probably dependent on the characters in other .o files in .a.