Identifying which Linux system library contains a function

前端 未结 6 740
误落风尘
误落风尘 2020-12-20 14:30

I am using a dev system where I have to specify the lib name when accessing a function inside it.

I\'ve used functions like open() before, and somehow found out that

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-20 15:02

    Try this:

    $ cat ./foobar.c
    #include 
    #include 
    #include 
    int main(void)
    {
        struct stat buf;
        return lstat(".", &buf);
    }
    
    
    $ LD_DEBUG=bindings ./foobar 2>&1   | grep stat
    31000:  binding file ./foobar [0] to /lib/x86_64-linux-gnu/libc.so.6 [0]: \
    normal symbol `__lxstat' [GLIBC_2.2.5]
    

提交回复
热议问题