Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
775 views
in Technique[技术] by (71.8m points)

linker - gcc/ld - create a new libc.so with __isoc99_sscanf@@GLIBC_2.7 symbol from glibc.2.6

I have an application, which does a error when I try to run it:

/lib/libc.so.6: version `GLIBC_2.7' not found

But the only symbol it needs from glibc 2.7 is

__isoc99_sscanf@@GLIBC_2.7 

I want to write a small single function "library" with this symbol as alias to __sscanf()

How can I do this with gcc/ld?

My variant is not accepted because "@@" symbols

 int __isoc99_sscanf@@GLIBC_2.7(const char *, const char *, ...) __attribute__((alias("__sscanf")));

second my variant is

#include <stdarg.h>
int __isoc99_sscanf1(const char *a, const char *b, va_list args)
{
   int i;
   va_list ap;
   va_copy(ap,args);
   i=sscanf(a,b,ap);
   va_end(ap);
   return i;
}

   // __asm__(".symver __isoc99_sscanf,__isoc99_sscanf@@GLIBC_2.7");
    __asm__(".symver __isoc99_sscanf1,__isoc99_sscanf@@GLIBC_2.7");

but it ends with "version node not found for symbol __isoc99_sscanf@@GLIBC_2.7" error from linker.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your second version works with this script:

GLIBC_2.7 {
 global: __isoc99_sscanf;
 local: *;
};

Using -Wl,--version-script=script.txt, however, I don't know how to access the original sscanf@GLIBC_2.4.

Anyway, perhaps you would want to use -D_GNU_SOURCE instead; to avoid __isoc99_sscanf altogether.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...