The Smallest Sync

The smallest you can make an ELF binary under Linux is 45 bytes. You only have eight bytes for code, but it can be done. Fortunately Rob’s version can be squeezed into that. So here it is (ported from nasm to gas):

.data
.code32

ehdr:
	.byte     0x7F, 'E', 'L', 'F'
	.int	  1
	.int	  0
	.int	  0x1000
	.hword	  2
	.hword	  3
	.int      filesize
	.int      _start + 0x1000
	.int      4
_start:
	movb	  $36, %al
	int       $0x80
	movb      $1, %al
	int       $0x80
	.hword    0x34
	.hword    0x20
	.byte     1

filesize = .

To compile:

as sync.s -o sync.o
ld -pie -s --oformat binary sync.o -o sync

When I run it my disk drive light illuminates. That is all I can accurately say about this code.


Posted

in

by

Tags: