我正在尝试将使用GNU工具链编译的C程序移植到OS X,但是它的默认ld程序不支持--wrapGNU中存在的标志ld.这是来自GNU的手册页ld:
--wrap symbol
Use a wrapper function for symbol. Any undefined reference to sym-
bol will be resolved to "__wrap_symbol". Any undefined reference
to "__real_symbol" will be resolved to symbol.
This can be used to provide a wrapper for a system function. The
wrapper function should be called "__wrap_symbol". If it wishes to
call the system function, it should call "__real_symbol".
Here is a trivial example:
void *
__wrap_malloc (size_t c) …Run Code Online (Sandbox Code Playgroud) aws-cli我正在尝试运行 AWS Batch 作业,但在调用将数据从 s3 复制到容器中时失败。错误信息如下:
fatal error: Unable to locate credentials
Run Code Online (Sandbox Code Playgroud)
我的作业定义具有执行角色,具有两个托管策略:AmazonS3FullAccess和AmazonECSTaskExecutionRolePolicy。容器映像是根据默认ubuntu:22.04映像构建的,并且具有类似于以下内容的入口点文件:
fatal error: Unable to locate credentials
Run Code Online (Sandbox Code Playgroud)
我还一直在阅读以下问题:ECS Fargate task not apply role,它指出容器应该有一个变量AWS_CONTAINER_CREDENTIALS_RELATIVE_URI,但我没有。我在入口点添加了 a declare -x,这是我执行批处理作业时的输出:
declare -x AWS_BATCH_CE_NAME="MyCluster"
declare -x AWS_BATCH_JOB_ATTEMPT="1"
declare -x AWS_BATCH_JOB_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
declare -x AWS_BATCH_JQ_NAME="MyQueue"
declare -x AWS_DEFAULT_REGION="us-west-2"
declare -x AWS_EXECUTION_ENV="AWS_ECS_FARGATE"
declare -x AWS_REGION="us-west-2"
declare -x DEBIAN_FRONTEND="noninteractive"
declare -x ECS_CONTAINER_METADATA_URI="http://111.111.111.1/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxx"
declare -x ECS_CONTAINER_METADATA_URI_V4="http://111.111.111.1/v4/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxx"
declare -x HOME="/root"
declare -x HOSTNAME="ip-111-11-1-111.us-west-2.compute.internal"
declare -x OLDPWD
declare …Run Code Online (Sandbox Code Playgroud) 考虑下面列出的两个文件:
文件 a.c
extern int foovar;
int foobarize() {
return foovar * foovar;
}
Run Code Online (Sandbox Code Playgroud)
和文件 b.c
int foovar = 10;
Run Code Online (Sandbox Code Playgroud)
我编译静态库liba.a和共享库libb.so如下:
# liba.a
gcc -fPIC -c a.c -o a.o
ar cr liba.a a.o
ranlib liba.a
# libb.so
gcc -fPIC -c b.c -o b.o
gcc -fPIC -shared -Wl,-soname,libb.so -o libb.so b.o liba.a
Run Code Online (Sandbox Code Playgroud)
请注意该函数foobarize的定义a.c 是存在的liba.a,但它不存在libb.so。我可以通过发布nm程序来保证:
$ nm liba.a
a.o:
0000000000000000 T foobarize
U foovar
U _GLOBAL_OFFSET_TABLE_ …Run Code Online (Sandbox Code Playgroud)