| Age | Commit message (Collapse) | Author | Files | Lines |
|
A few modifications are made for code size:
- Move write before read, to avoid unconditional jump
- Set stack pointer out in _start (runtime optimization)
- Don't explicitly zero uninitialized registers
Signed-off-by: Matt Hunter <m@lfurio.us>
|
|
exit is now only called from one place, so move the syscall to that
location to avoid the extra unconditional jump. There is now no longer
an exit label.
mov al, 1 is replaced with inc eax, as this overall saves 1 byte.
Since lace's exit status is no longer defined, drop the instruction to
zero ebx before exiting. Now that explicit error checking is removed,
there is no need to use this value for anything.
Signed-off-by: Matt Hunter <m@lfurio.us>
|
|
Instead of opening and reading a sockaddr_in struct from an external
file at runtime, define this data in the executable with constants.
Furthermore, arrange to store this data in a yet unused portion of the
main ELF header so it effectively consumes no additional space. It
overlaps the ELF "shoff" and "flags", and the program header "align"
fields.
The full size of struct sockaddr_in is actually 16 bytes, but the last 8
bytes are padding, and failing to zero them out appears to have no
adverse effect on behavior. So this padding area will just be populated
by the next few fields in the ELF header, interpreted as garbage.
In the program code, remove the initial syscalls for open() and read()
and their associated error checking.
Also remove the error check after connect(), as the program will
properly exit without performing any IO without it. Going forward, we
make no guarantees about lace's exit status.
Signed-off-by: Matt Hunter <m@lfurio.us>
|
|
Subtracting esp to allocate space on the stack is only necessary to
preserve data that is already lower on the stack. By the time we use
either the sockaddr struct or the temporary io buffer, we are finished
accessing older stack values, so they can be overwritten. This saves 2
unnecessary instructions from the program.
Signed-off-by: Malfurious <m@lfurio.us>
|
|
The previous version breaks if stdin is directed from a file, such as
/dev/null.
Signed-off-by: Malfurious <m@lfurio.us>
|
|
Signed-off-by: Malfurious <m@lfurio.us>
|
|
Zero is a valid return value, so don't jmp to exit if the fd is equal to
it. However, we would never expect zero to be returned as stdin is not
closed.
Signed-off-by: Malfurious <m@lfurio.us>
|
|
If an error condition is met during the pipe IO syscalls, eax will be
filled with a negative value. We need to then zero the rest of the
register before attempting to exit, so we don't continue on to execute
garbage.
Signed-off-by: Malfurious <m@lfurio.us>
|
|
Removes an unnecessary instruction.
Signed-off-by: Malfurious <m@lfurio.us>
|
|
Signed-off-by: Malfurious <m@lfurio.us>
|