喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 喜悦证交所 | 帮助

RSS 订阅当前论坛  

$5.95 Web Hosting     

上一主题 下一主题
     
标题: 在2.4内核编译安装通过,可是在2.2.19环境下却有如下符号不能解析,这是为什么?  
 
hidave (hidave)
注册会员
Rank: 2
中级会员



UID 9172
精华 3
积分 88
帖子 28
金钱 58 喜悦币
威望 30
人脉 0
阅读权限 20
注册 2001-8-14
来自 重庆
状态 离线
[广告]: Enom域名自助付费 自助注册 自助PUSH 主流域名COM等一律57.99元年
在2.4内核编译安装通过,可是在2.2.19环境下却有如下符号不能解析,这是为什么?

vc.o: unresolved symbol __constant_memcpy
vc.o: unresolved symbol __constant_c_memset
vc.o: unresolved symbol __memcpy
vc.o: unresolved symbol brelse
vc.o: unresolved symbol __constant_c_and_count_memset
vc.o: unresolved symbol wait_on_buffer
vc.o: unresolved symbol __constant_test_bit
vc.o: unresolved symbol __test_bit
vc.o: unresolved symbol __memset_generic
2002-11-27 02:38 PM#1
查看资料  发短消息  ICQ 状态  顶部
 
hidave (hidave)
注册会员
Rank: 2
中级会员



UID 9172
精华 3
积分 88
帖子 28
金钱 58 喜悦币
威望 30
人脉 0
阅读权限 20
注册 2001-8-14
来自 重庆
状态 离线
[广告]: Enom域名自助付费 自助注册 自助PUSH 主流域名COM等一律57.99元年
解决了,是忘记加 -O2了.
2002-11-28 03:09 PM#2
查看资料  发短消息  ICQ 状态  顶部
 
hotfire (hotfire)
高级会员
Rank: 4
版主



UID 2737
精华 17
积分 595
帖子 255
金钱 425 喜悦币
威望 170
人脉 0
阅读权限 50
注册 2000-7-10
状态 离线
good, 但这应该和-O2无关的, -O2只是一个优化选项
2002-11-30 02:10 AM#3
查看资料  发短消息  ICQ 状态  Yahoo!  顶部
 
hidave (hidave)
注册会员
Rank: 2
中级会员



UID 9172
精华 3
积分 88
帖子 28
金钱 58 喜悦币
威望 30
人脉 0
阅读权限 20
注册 2001-8-14
来自 重庆
状态 离线
应该是有关系的吧!
我曾经在GOOGLE看到这样的解释:
It sounds really strange. Unresolved symbols in modules come from 4 sources:

1. the programmer forgot to define __KERNEL__ and MODULE.
   These symbols are used by a lot of header files to insert kernel specific stuff
2. the programmer forgot to give the gcc the commandline switch -O2
   The gcc starts inlining at this tuning level. Inlining is needed to eleminate some
   unused symbols in the code
3. the user try to insmod a module for a another kernel then the module was compiled for.
4. the programmer forget to define some symbols which she declared before

似乎-O2编译优化后可以使用一些声明为inline的函数,否则insmod的时候就会有一些不能解析的符号.
2002-11-30 01:20 PM#4
查看资料  发短消息  ICQ 状态  顶部
 
hidave (hidave)
注册会员
Rank: 2
中级会员



UID 9172
精华 3
积分 88
帖子 28
金钱 58 喜悦币
威望 30
人脉 0
阅读权限 20
注册 2001-8-14
来自 重庆
状态 离线
关于inline函数我还不太明白,以下是从dict.org查到的解释,谁的英文好能解释一下:[/url]
  inline
  
      (Or "unfold") To replace a function call with
     an instance of the function's body.  Actual argument
     expressions are substituted for formal parameters as in
     beta reduction.  Inlining is usually done as a
     compile-time transformation.
  
     If done recklessly (e.g. attempting to inline a recursive
     function) the compiler will fail to terminate.  If done
     over-enthusiastically the code size may increase
     exponentially, e.g. if function f calls g twice, and g calls h
     twice and h is inlined in g which is inlined in f (in either
     order) then there will be four copies of h's body in f.
  
     See also linear argument, unfold/fold.
  
     (1994-11-03)
2002-11-30 01:29 PM#5
查看资料  发短消息  ICQ 状态  顶部
 
hidave (hidave)
注册会员
Rank: 2
中级会员



UID 9172
精华 3
积分 88
帖子 28
金钱 58 喜悦币
威望 30
人脉 0
阅读权限 20
注册 2001-8-14
来自 重庆
状态 离线
明白了,有头文件里把一些函数比如__memcoy声明为一段static inline的汇编代码,只有当GCC 优化选项达到O2的时候才能把他们INLINE到模块代码中,就是这么回事.
2002-11-30 05:08 PM#6
查看资料  发短消息  ICQ 状态  顶部
 
hotfire (hotfire)
高级会员
Rank: 4
版主



UID 2737
精华 17
积分 595
帖子 255
金钱 425 喜悦币
威望 170
人脉 0
阅读权限 50
注册 2000-7-10
状态 离线
好象不是这么回事
-O2
Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. The compiler does not perform loop unrolling or function inlining when you specify -O2. As compared to -O, this option increases both compilation time and the performance of the generated code.
-O2 turns on all optional optimizations except for loop unrolling, function inlining, and register renaming. It also turns on the -fforce-mem option on all machines and frame pointer elimination on machines where doing so does not interfere with debugging.

Please note the warning under -fgcse about invoking -O2 on programs that use computed gotos.
2002-11-30 05:24 PM#7
查看资料  发短消息  ICQ 状态  Yahoo!  顶部
 
hidave (hidave)
注册会员
Rank: 2
中级会员



UID 9172
精华 3
积分 88
帖子 28
金钱 58 喜悦币
威望 30
人脉 0
阅读权限 20
注册 2001-8-14
来自 重庆
状态 离线
奇怪啊,ROBINI的LINUX DEVICE DRIVER, 2nd Edition里是这么写的:
A module writer must also specify the /-O/flag to the compiler,
    because many functions are declared as inline in the header files.
    /gcc/ doesn't expand inline functions unless optimization is
    enabled, but it can accept both the /-g/ and /-O/options, allowing
    you to debug code that uses inline functions.[9] Because the kernel
    makes extensive use of inline functions, it is important that they
    be expanded properly.

        [9] Note, however, that using any optimization greater than
        /-O2/ is risky, because the compiler might inline functions that
        are not declared as inline in the source. This may be a problem
        with kernel code, because some functions expect to find a
        standard stack layout when they are called.
2002-11-30 07:00 PM#8
查看资料  发短消息  ICQ 状态  顶部
 
hidave (hidave)
注册会员
Rank: 2
中级会员



UID 9172
精华 3
积分 88
帖子 28
金钱 58 喜悦币
威望 30
人脉 0
阅读权限 20
注册 2001-8-14
来自 重庆
状态 离线
我想是不是这个意思:
就是说当我们优化到O2的时候就inlining 那些声明为iniline的函数,而当优化到O3的时候就inlining 所有可以被优化的函数.
gcc 手册关于O3:
Optimize  yet  more.  This  turns on everything -O2              does, along with  also  turning  on   -finline-functions
2002-11-30 07:12 PM#9
查看资料  发短消息  ICQ 状态  顶部
 
hotfire (hotfire)
高级会员
Rank: 4
版主



UID 2737
精华 17
积分 595
帖子 255
金钱 425 喜悦币
威望 170
人脉 0
阅读权限 50
注册 2000-7-10
状态 离线
yes. you are right.

test.c

#include <stdio.h>
#include <stdlib.h>

static inline int funa(int i)
{
        return i++;
}

main()
{
        int i=1;
        i = funa(i);
}
gcc -S test.c

        .file        "test.c"
        .version        "01.01"
gcc2_compiled.:
.text
        .align 16
.globl main
        .type         main,@function
main:
        pushl        %ebp
        movl        %esp, %ebp
        subl        $8, %esp
        movl        $1, -4(%ebp)
        subl        $12, %esp
        pushl        -4(%ebp)
        call        funa
        addl        $16, %esp
        movl        %eax, %eax
        movl        %eax, -4(%ebp)
        movl        %ebp, %esp
        popl        %ebp
        ret
.Lfe1:
        .size         main,.Lfe1-main
        .align 16
        .type         funa,@function
funa:
        pushl        %ebp
        movl        %esp, %ebp
        movl        8(%ebp), %eax
        movl        %eax, %edx
        incl        %eax
        movl        %edx, %eax
        popl        %ebp
        ret
.Lfe2:
        .size         funa,.Lfe2-funa
        .ident        "GCC: (GNU) 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)"
gcc -S -O2 test.c

        .file        "test.c"
        .version        "01.01"
gcc2_compiled.:
.text
        .align 16
.globl main
        .type         main,@function
main:
        pushl        %ebp
        movl        %esp, %ebp
        popl        %ebp
        ret
.Lfe1:
        .size         main,.Lfe1-main
        .ident        "GCC: (GNU) 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)"
2002-11-30 09:04 PM#10
查看资料  发短消息  ICQ 状态  Yahoo!  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.025125 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP