linux内核s文件夹,将S文件添加到Linux内核时的链接问题(Linkage problems when adding S file to Linux kernel)...

将S文件添加到Linux内核时的链接问题(Linkage problems when adding S file to Linux kernel)

在上一个问题得到解答之后: 将.S文件添加到linux内核代码我能够将.S文件添加到Linux内核make文件中。 但是,我的.S文件包含几个替换用C编写的函数的部分。我注释掉了这些函数,并将替换函数声明为全局变量,但是当我尝试链接内核(使用make)时,我收到以下错误:

arch/x86/kernel/vmlinux.lds:XXX: non constant or forward reference address expression for section .YYY

我替换的原始函数使用以下__attribute__ ((unused, __section__("YYY"))) notrace声明: __attribute__ ((unused, __section__("YYY"))) notrace

asm部分使用以下方式声明:

.text

.globl YYY

我也尝试过添加:

.type YYY,@function

我可能在某处遗漏了一些声明,但我不确定在哪里看。

有任何想法吗?

After a previous question got answered: Adding a .S file to the linux kernel code I was able to add a .S file to the Linux kernel make files. However, my .S file includes several sections that replace functions that were written in C. I commented out these functions, and declared the replacement functions as globals, but when I try to link the kernel (using make) I get the following error:

arch/x86/kernel/vmlinux.lds:XXX: non constant or forward reference address expression for section .YYY

The original functions that I replaced were declared using: __attribute__ ((unused, __section__("YYY"))) notrace

The asm sections are declared using:

.text

.globl YYY

I also tried adding:

.type YYY,@function

I probably missed some declaration somewhere, but I'm not sure where to look.

Any ideas?

原文:https://stackoverflow.com/questions/4286429

更新时间:2019-10-14 13:26

最满意答案

如果要将汇编函数放入YYY部分而不是.text ,则需要替换

.text

.section YYY,"ax"

If you want to place assembly functions into section YYY, rather than .text, you need to replace

.text

with

.section YYY,"ax"

2010-11-26

相关问答

问题出自第6步到最后一步(编译内核)。 第5步之后,我们必须执行以下步骤: 6-在我的系统上编译这个内核 为了配置内核,我尝试了下面的命令: # make menuconfig

在上述命令后,出现一个弹出窗口,我确定选择了ext4,然后保存。 然后从新内核创建DEB文件,我们必须: # make -j 5 KDEB_PKGVERSION=1.arbitrary-name deb-pkg

它会在/usr/src/创建一些deb文件。 之后,我们需要安装它们: # dpkg -i linux*.d

...

list API不会动态分配任何内存。 我自己发现这件事有点令人费解。 这里的问题在于,Linux是用C编写的,而不是C ++,但是它以一种完全面向对象的方式实现了事物,但是在C中它看起来像是从头到尾。 它的工作原理如下(这也适用于其他几个Linux API,例如kobj ): 你定义了一些struct ,它应该是列表的成员。 与通常想象的链表相反,通过分配一些不透明的列表项并将指针指向实际对象,这个对象不会被放入列表中,而是使struct list_head成为struct list_head的

...

只需将相应的.o结果添加到某个规则中即可。 .S - > .o翻译有隐式规则。 Just add the corresponding .o result to some rule. There are implicit rules for the .S -> .o translation.

如果要将汇编函数放入YYY部分而不是.text ,则需要替换 .text

同 .section YYY,"ax"

If you want to place assembly functions into section YYY, rather than .text, you need to replace .text

with .section YYY,"ax"

通常情况下,您必须安装与您将在其上执行程序的系统运行的内核版本相对应的那些头文件的版本。 在你想要本地运行的情况下,2.6.9-42。 该消息抱怨“linux / string.h”而不是“string.h”,所以你添加了一个以linux作为子目录的目录。 我对红帽知之甚少,知道如何安装它们(可能是一个rpm命令)以及它们将安装在哪里(使用Debian和衍生工具,你必须使用-I / usr / src / linux- kernel-version /包括”)。 Normally, you hav

...

bcdedit的MSDN页面说明: [N] ew引导加载程序条目不会自动添加到引导菜单中。 您可以按任何顺序放置引导加载程序条目。 必须使用bcdedit /displayorder命令将新条目显式添加到菜单中。 例如: bcdedit /displayorder {current} {1c8a5e74-84ff-11e3-a4da-8050f0e41ed6}

The MSDN page for bcdedit states: [N]ew boot loader entries are not

...

DCE不会使用主机linux内核网络堆栈。 DCE将使用来自独立ns-3模块net-next-sim的特定版本的Linux内核的网络堆栈。 例如,在dce发布的最后一个版本(1.8)中,该模块是从git repo https://github.com/direct-code-execution的“sim-ns3-2.6.36-branch”分支中提取的。 /net-next-sim.git 。 实际上,您不必担心这是从哪里来的,因为如果启用此功能,烘焙会自动为您下载,构建,安装和配置它。 正如手册

...

使用2.6内核,您应该使用内核构建系统。 以下是在内核树之外构建的模块的示例: ifneq ($(KERNELRELEASE),)

# We were called by kbuild

obj-m += target.o

else # We were called from command line

KDIR := /lib/modules/$(shell uname -r)/build

#KDIR := /home/cynove/src/kernel/linux-source-2.6.3

...

您可以将代码构建到内核而不是模块中吗? 这可能会简化调试init()调用。 您还可以在do_one_initcall()设置断点,并查看do_one_initcall() mod->init的地址以获取加载地址。 Can you build your code into the kernel rather than as a module? That might simplify debugging the init() call. You could also set a breakpoint

...

检查makefile,看看make标签是否使用ctags而不是etags。 如果是,您可能需要进行一些编辑才能使用etags。 要生成在Emacs中使用的标记文件,您必须像以前一样启动命令make TAGS而不是make tags 。 也就是说,大写«TAGS»选项将生成etags表。 Check the makefile and see if make tags uses ctags instead of etags. If it does, you may need to do some ed

...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值