assembler i386
Nikola Vladov <[email protected]> 16 Jan 2011 19:30:38 -0000
| Newsgroups | gmane.linux.lib.dietlibc |
|---|---|
| Message-ID | <[email protected]> |
I changed i386/start.S. Now it is 50 bytes (13 bytes shorter) and maybe more readable. The idea is to put envp is %esi and then to use lodsl in WANT_SYSENTER. Bellow are diff and start.S /nv --- i386/start.S.orig 2006-04-09 01:31:18.000000000 +0300 +++ i386/start.S 2011-01-16 21:04:52.000000000 +0200 @@ -6,24 +6,24 @@ _start: #if 1 popl %ecx /* %ecx = argc */ - movl %esp,%esi /* %esi = argv */ + movl %esp,%eax /* %eax = argv */ pushl %ecx #else movl (%esp),%ecx /* %ecx = argc */ - leal 4(%esp),%esi /* %esi = argv */ + leal 4(%esp),%eax /* %eax = argv */ #endif - leal 4(%esi,%ecx,4),%eax /* %eax = envp = (4*ecx)+%esi+4 */ + leal 4(%eax,%ecx,4),%esi /* %esi = envp = (4*ecx)+%eax+4 */ #ifdef WANT_DYNAMIC /* in %edx we have the ld.so dynamic _fini ( register this if non null ) */ push %edx #endif - pushl %eax pushl %esi + pushl %eax pushl %ecx PIC_INIT /* non-PIC: this is an empty line */ - PUT_VAR %eax, environ, %ecx /* non-PIC: movl %eax,environ */ + PUT_VAR %esi, environ, %ecx /* non-PIC: movl %esi,environ */ #ifdef PROFILING pushl $_etext @@ -33,21 +33,18 @@ #endif #ifdef WANT_SYSENTER - movl %eax,%edx - xorl %esi,%esi 1: - add $4,%edx - cmpl %esi,-4(%edx) - jne 1b + lodsl + testl %eax,%eax + jnz 1b 1: - movl (%edx),%edi - test %edi,%edi + lodsl + testl %eax,%eax jz 1f - addl $8,%edx - cmpl $32,%edi + cmpl $32,%eax + lodsl jne 1b - movl -4(%edx),%edi - PUT_VAR %edi, __vsyscall, %edx + PUT_VAR %eax, __vsyscall, %edx 1: #endif ------------------ i386/start.S ------------------ #include "dietfeatures.h" #include "PIC.h" .text .global _start _start: #if 1 popl %ecx /* %ecx = argc */ movl %esp,%eax /* %eax = argv */ pushl %ecx #else movl (%esp),%ecx /* %ecx = argc */ leal 4(%esp),%eax /* %eax = argv */ #endif leal 4(%eax,%ecx,4),%esi /* %esi = envp = (4*ecx)+%eax+4 */ #ifdef WANT_DYNAMIC /* in %edx we have the ld.so dynamic _fini ( register this if non null ) */ push %edx #endif pushl %esi pushl %eax pushl %ecx PIC_INIT /* non-PIC: this is an empty line */ PUT_VAR %esi, environ, %ecx /* non-PIC: movl %esi,environ */ #ifdef PROFILING pushl $_etext pushl $.text call monitor addl $0x8, %esp #endif #ifdef WANT_SYSENTER 1: lodsl testl %eax,%eax jnz 1b 1: lodsl testl %eax,%eax jz 1f cmpl $32,%eax lodsl jne 1b PUT_VAR %eax, __vsyscall, %edx 1: #endif #ifdef WANT_DYNAMIC call _dyn_start #else call CALL_IN_STARTCODE #endif #ifdef PROFILING pushl %eax call _stop_monitor popl %eax #endif pushl %eax call exit hlt /* die now ! will ya ... */ .Lstart: .size _start,.Lstart-_start