运行动态link的程序会被kill 的 bug 基本解决
2006/4/26 19:58:30
bug 暂时解决了,不过没有得到高手的认可:), 既然高手认为我的想法有问题,我还得花时间去仔细看看
why does the code like this?
关于此主题的全部 4 个帖子 - 树式浏览
发件人: konggangg...@163.com - 查看个人资料
日期: 2006年4月24日(星期一) 下午9时40分
尚未评分
显示选项
hi, guys, when I run initramfs with klibc on mips platform, my
program always be killed , I found that it is because of the code
below:
unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
unsigned long len, unsigned long prot,
unsigned long flags, unsigned long pgoff)
{
....
if (!len)
return -EINVAL;
/* Careful about overflows.. */
len = PAGE_ALIGN(len);
if (!len || len > TASK_SIZE)
return -ENOMEM;
.......
}
I'm wondering why return error when len == 0?
I think the correct code should be:
unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
unsigned long len, unsigned long prot,
unsigned long flags, unsigned long pgoff)
{
....
if (!len)
return addr;
/* Careful about overflows.. */
len = PAGE_ALIGN(len);
if(!len)
return addr;
if (len > TASK_SIZE)
return -ENOMEM;
.......
}
have any idea?
thanks in advance!
kong gang
回复
发件人: Pete Zaitcev - 查看个人资料
日期: 2006年4月25日(星期二) 上午3时07分
尚未评分
显示选项
On Mon, 24 Apr 2006 06:40:53 -0700, kongganggang wrote:
> /* Careful about overflows.. */
> len = PAGE_ALIGN(len);
> if (!len || len > TASK_SIZE)
> return -ENOMEM;
> .......
> }
> I'm wondering why return error when len == 0?
Because it's not. You passed -1 to len, most likely.
> I think the correct code should be:
No, it's not correct.
You better find out what's wrong with len. Consult with Peter if you
think it's klibc's problem.
-- Pete
回复 为此帖评分:
发件人: konggangg...@163.com - 查看个人资料
日期: 2006年4月25日(星期二) 上午8时23分
尚未评分
显示选项
>Because it's not. You passed -1 to len, most likely.
do_mmap_pgoff return error because the length of the data section of
my program is 0.
mips-linux-readelf -S mkdir
There are 11 section headers, starting at offset 0x10dc:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg
Lk Inf Al
[ 0] NULL 00000000 000000 000000 00
0 0 0
[ 1] .interp PROGBITS 004000d4 0000d4 00002a 00 A
0 0 1
[ 2] .reginfo MIPS_REGINFO 00400100 000100 000018 18 A
0 0 4
[ 3] .text PROGBITS 00400120 000120 000660 00 AX
0 0 16
[ 4] .rodata PROGBITS 00400780 000780 0000f0 00 A
0 0 16
[ 5] .data PROGBITS 10000000 001000 000000 00 WA
0 0 16
[ 6] .sbss NOBITS 10000000 001000 000004 00 WAp
0 0 4
[ 7] .bss NOBITS 10000010 00100c 000010 00 WA
0 0 16
[ 8] .pdr PROGBITS 00000000 00100c 000080 00
0 0 4
[ 9] .mdebug.abi32 PROGBITS 00000000 00108c 000000 00
0 0 1
[10] .shstrtab STRTAB 00000000 00108c 00004e 00
0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor
specific)
after I modified the code , it runs normally.
回复
发件人: konggangg...@163.com - 查看个人资料
日期: 2006年4月25日(星期二) 上午8时56分
尚未评分
显示选项
i modified my kernel like this, it runs normally:
unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
unsigned long len, unsigned long prot,
unsigned long flags, unsigned long pgoff)
{
....
if (!len)
return addr;
/* Careful about overflows.. */
len = PAGE_ALIGN(len);
if (!len || len > TASK_SIZE)
return -ENOMEM;
.......
- 显示引用的文字 -
回复