[
Date Prev
][
Date Next
] [
Thread Prev
][
Thread Next
] [
Date Index
] [
Thread Index
]
Re: 应用程度能否绕过 glibc ?
To
: Plain_Text <
resation@gmail.com
>
Cc
:
debian-chinese-gb@lists.debian.org
Subject
: Re: 应用程度能否绕过 glibc ?
From
: Dongsheng Song <
dongsheng.song@gmail.com
>
Date
: Wed, 7 Mar 2012 11:04:21 +0800
Message-id
: <
[🔎]
CAE8XmWoy7n4PhxCEmDPHVUr=UU5oJA0+x=9KMJuxt7WBr2naNg@mail.gmail.com
>
In-reply-to
: <
[🔎]
2487907272200410245@unknownmsgid
>
References
: <18016610.29797.1331076568859.JavaMail.mobile-sync@ieqz1> <
[🔎]
2487907272200410245@unknownmsgid
>
主函数必须是汇编语言,其它C函数只要不调用libc即可。
给你个最小的例子:
root@vc:~# gcc -m32 -s -nostdlib tiny.s
root@vc:~# ls -la a.out
-rwxr-xr-x 1 root root
356
Mar 7 02:59 a.out
root@vc:~# ./a.out
root@vc:~# gcc -m64 -s -nostdlib tiny.s
root@vc:~# ls -la a.out
-rwxr-xr-x 1 root root
512
Mar 7 02:59 a.out
root@vc:~# ./a.out
root@vc:~# cat tiny.s
.global _start
.text
_start:
xorl %eax, %eax
incl %eax
movb $42, %bl
int $0x80
2012/3/7 晓磊任 <
julyclyde@gmail.com
>:
> main函数的入口地位是由标准库决定的
>
> --
> 冷静认真,稳定运行;随时候命,宠辱不惊
>
> 在 2012年3月7日,7:25,Plain_Text <
resation@gmail.com
> 写道:
>
>>
>>
>> glibc 并不仅仅是一套库,似乎跟系统结合得非常紧密。有无办法让应用程序
>> 绕过它?当然这并没有多大的实际意义,只是想通过这个问题稍微深入了解一下系
>> 统。比如下面简单的示例程序:
>>
>> int main(void)
>> {
>> return 0;
>> }
>>
>> 并不使用任何的 C 库函数和变量,按理来说不需要使用到 glibc. 如果不加
>> 任何编译选项直接编译,用 ldd 发现它依赖 glibc. 但用编译选项 -nostartfiles
>> -nodefaultlibs -nostdlib 试过,根本就编译不过。
>>
>>
>>
>>
>> --
>> To UNSUBSCRIBE, email to
debian-chinese-gb-REQUEST@lists.debian.org
>> with a subject of "unsubscribe". Trouble? Contact
listmaster@lists.debian.org
>> Archive:
[🔎]
20120306232524.GA2678@localhost.localdomain
">http://lists.debian.org/
[🔎]
20120306232524.GA2678@localhost.localdomain
>>
Reply to:
debian-chinese-gb@lists.debian.org
Dongsheng Song (on-list)
Dongsheng Song (off-list)
References
:
Re: 应用程度能否绕过 glibc ?
From:
晓磊任 <julyclyde@gmail.com>
Prev by Date:
Re: 64位机上编译32位程序
Next by Date:
Re: 应用程度能否绕过 glibc ?
Previous by thread:
Re: 应用程度能否绕过 glibc ?
Next by thread:
64位机上编译32位程序
Index(es):
Date
Thread