【发布时间】:2020-05-26 16:06:48
【问题描述】:
我想检查正在调查的库是用什么标志和选项构建的?
我正在尝试使用带有选项 -frecord-gcc-switches 的 gcc 编译器来理解我的简单共享库,但没有运气。
以下是构成共享库的一段代码:
#include "shared.h"
unsigned int add(unsigned int a, unsigned int b)
{
printf("\n Inside add()\n");
return (a+b);
}
shared.h 看起来像:
#include<stdio.h>
extern unsigned int add(unsigned int a, unsigned int b);
我运行以下命令来创建一个共享库:
gcc -c -Wall -Werror -fPIC -frecord-gcc-switches shared.c
gcc -shared -frecord-gcc-switches -o libshared.so shared.o
readelf -n libshared.so 给了我
Displaying notes found in: .note.gnu.build-id
Owner Data size Description
GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring)
Build ID: 8466741f5849aac95570ec68d172f9077f175f89
如何检查使用了哪些选项/标志或其他库来构建生成的库?
顺便说一句,我使用
$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
【问题讨论】:
标签: linux gcc dynamic-library