使用链接描述文件重命名符号 [英] rename a symbol using a linker script

查看:184
本文介绍了使用链接描述文件重命名符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用链接描述文件或映射文件重命名符号? 我正在尝试修改用C ++和Fortran混合编写的一些代码,以便它可以在Linux上与多个Fortran编译器一起使用.目前,它是为Solaris Studio编译器编写的,并且启用了区分大小写的选项.我想自动处理Fortran符号名称更改的变体(例如来自Makefile).

Is it possible to use a linker script or mapfile to rename a symbol? I'm trying to adapt some code written in a mix of C++ and Fortran so that it will work with more than one Fortran compiler - on Linux. It is currently written for the Solaris Studio compiler with the option for case-sensitivity enabled. I'd like to handle variations in Fortran symbol name mangling automatically (such as from the Makefile).

似乎可以创建别名,因此,包含以下内容的链接描述文件:

It does appear to be possible to create aliases so, a linker script containing:

C_Function_ = c_function;

将进行排序.不幸的是,添加-T选项以引用此脚本会导致其他行为更改,并且由于找不到libdl.so.2/librt.so.1而出现错误.我需要包含某种默认的链接描述文件吗?我已经尝试过在Linux上使用bfd和gold链接器.

will sort-of work. Unfortunately, adding the -T option to reference this script causes some other change in behaviour and I get errors due to libdl.so.2/librt.so.1 not being found. Is there some sort of default linker script that I need to include or something? I've tried with both bfd and gold linkers on Linux.

推荐答案

您不能真正重命名符号,但是可以为现有符号定义别名,如

You cannot really rename symbols, but you can define aliases to existing symbols like

PROVIDE(c_function = C_function_);
...

在链接描述文件中.

如果将此链接器脚本的-T选项传递给ld,它将替换原始(默认)链接器脚本.如果您想让链接脚本默认为 extend ,则在不使用-T选项的情况下传递它(就像使用其他目标文件一样).

If you pass this linker script with the -T option to ld, it will replace the original (default) linker script. If you rather want to have the linker script extend the default, pass it without the -T option (just like you would with an additional object file).

这样,一切都会按预期进行.

This way, everything should work as expected.

这篇关于使用链接描述文件重命名符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆