如何评估模块版本校验和? [英] How is module version checksum evaluated?

查看:187
本文介绍了如何评估模块版本校验和?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个Linux内核代码副本(相同版本:3.0.1),一个是原始代码,另一个是经过一些修改的.在使用相同的配置文件编译它们之后(未修改的代码提示在make期间进行有关驱动程序的一些其他配置),它们输出的Module.symvers文件略有不同,这是合理的.然后,我使用awk仅列出它们的前2个字段,以更好地比较符号校验和.大多数符号校验和是相同的,但是某些符号的校验和是不同的.根据该 lwn.net的文章:

I have 2 copies of Linux kernel code (same version: 3.0.1), one is vanilla source code and the other with some modifications. After compiling both of them with the same config file (the unmodified code prompts for some additional configurations about drivers during make), they output slightly different Module.symvers file, which is reasonable. I then use awk to only list the first 2 fields of them to better comparing the symbol checksums. Most of the symbol checksums are the same, but some of the symbols' checksums are different. According to this article from lwn.net:

校验和是从符号的原型或声明中计算出来的.

the checksum is calculated from the prototype or declaration of the symbol.

那些不同的应该具有不同的原型或声明.但是我发现这是不正确的.我选择了其中两个(函数)并比较了源代码,其中一个在定义上有所不同(即函数主体),而另一个函数在两个源代码中完全相同. (我使用vimdiff进行比较,并且间距是相同的).这两个功能具有相同的原型.

those different ones should have different prototype or declaration. But I find that this is not true. I picked two of them (functions) and comparing the source code, one of them differ in the definition (i.e. function body) and the other function is exactly the same in two source code. (I used vimdiff to compare and the spacing is identical). Both of the functions have the same prototype.

所以事情可能已经改变了?究竟是什么导致当今的校验和不同(对于我来说,在3.0.1之后).我不想知道如何计算校验和的详细信息,我只是想简要了解一下在这里有什么不同.

So things may have changed? What exactly is causing the checksums different nowadays (In my case after 3.0.1). I don't want to know the details of how the checksum are calculated, I just want to get a brief idea about what is making a difference here.

推荐答案

计算导出函数的校验和时,不仅要从字面上评估函数原型中的每种类型(参数的类型或返回值的类型), >,也可以按定义进行.如果类型是复杂的(例如,结构),则其字段也会被检查. (也就是说,过程是递归).

When checksum of exported function is calculated, every type in function's prototype (parameter's type or type of returning value) is evaluated not only literally, but also by definition. If a type is complex(e.g., structure), its fields are checked too. (That is, process is recursive).

类型的定义.

例如,下面的函数声明将具有不同的校验和:

E.g., functions declarations below will have different checksums:

内核1 :

struct a
{
    int i;
};

void f(struct a* arg);

内核2 :

struct a
{
    int i;
    char c;
};

void f(struct a* arg);

这篇关于如何评估模块版本校验和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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