Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to gitignore, Makefile, README, STATS. Cleaned up
t/
for `-…
…ansi -Wall -pedantic`. Added `_end` & friends segment pointers, and tests for `_end` & a basic implementation of `sys_brk`, `sbrk` and `brk` as a test (malloc should be a snap to write now)
- Loading branch information
Showing
16 changed files
with
386 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,5 @@ | |
*.pid | ||
*.tmp | ||
*.footprint | ||
*.log | ||
*.d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,46 @@ | ||
# rt0 library & binary sizes | ||
|
||
| Binary | Arch | Size | Purpose | Compile Args | | ||
-------------:|:-------|-----:|:-------------------------|:--------------------------------------| | ||
| librt0.a | i386 | 3502 | Startup code+syscall | -Os -nostdlib -fomit-frame-pointer | | ||
| librt0.a | x86_64 | 4798 | Startup code+syscall | -Os -nostdlib -fomit-frame-pointer | | ||
| t/hello.exe | i386 | 1140 | Hello World\n | -Os -s -nostdlib -fomit-frame-pointer | | ||
| t/hello.exe | x86_64 | 1328 | Hello World\n | -Os -s -nostdlib -fomit-frame-pointer | | ||
| hello.exe | i386 | 5532 | Hello World\n with glibc | -Os -s -fomit-frame-pointer | | ||
| hello.exe | x86_64 | 6240 | Hello World\n with glibc | -Os -s -fomit-frame-pointer | | ||
| t/null.exe | i386 | 1044 | Empty main | -Os -s -nostdlib -fomit-frame-pointer | | ||
| t/null.exe | x86_64 | 1272 | Empty main | -Os -s -nostdlib -fomit-frame-pointer | | ||
| null.exe | i386 | 5528 | Empty main | -Os -s -fomit-frame-pointer | | ||
| null.exe | x86_64 | 6232 | Empty main | -Os -s -fomit-frame-pointer | | ||
| ... | ... | ... | ... | With `__RT0_WITH_FASTER_SYSCALL__` | | ||
| librt0.a | i386 | 4168 | Startup code+syscall | -Os -nostdlib -fomit-frame-pointer | | ||
| librt0.a | x86_64 | 5660 | Startup code+syscall | -Os -nostdlib -fomit-frame-pointer | | ||
| t/hello.exe | i386 | 1440 | Hello World\n | -Os -s -nostdlib -fomit-frame-pointer | | ||
| t/hello.exe | x86_64 | 1600 | Hello World\n | -Os -s -nostdlib -fomit-frame-pointer | | ||
| t/null.exe | i386 | 1368 | Empty main | -Os -s -nostdlib -fomit-frame-pointer | | ||
| t/null.exe | x86_64 | 1560 | Empty main | -Os -s -nostdlib -fomit-frame-pointer | | ||
| Binary | Arch | Size | Purpose | | ||
-------------:|:-------|-----:|:-----------------------------------| | ||
| librt0.a | i386 | 2810 | Startup code+syscall | | ||
| librt0.a | x86_64 | 3974 | Startup code+syscall | | ||
| t/hello.exe | i386 | 624 | Hello World\n | | ||
| t/hello.exe | x86_64 | 824 | Hello World\n | | ||
| hello.exe | i386 | 2988 | Hello World\n with glibc | | ||
| hello.exe | x86_64 | 4200 | Hello World\n with glibc | | ||
| t/null.exe | i386 | 560 | Empty main | | ||
| t/null.exe | x86_64 | 768 | Empty main | | ||
| null.exe | i386 | 2888 | Empty main with glibc | | ||
| null.exe | x86_64 | 2988 | Empty main with glibc | | ||
| ... | ... | ... | With `__RT0_WITH_FASTER_SYSCALL__` | | ||
| librt0.a | i386 | 3980 | Startup code+syscall | | ||
| librt0.a | x86_64 | 5604 | Startup code+syscall | | ||
| t/hello.exe | i386 | 608 | Hello World\n | | ||
| t/hello.exe | x86_64 | 792 | Hello World\n | | ||
| t/null.exe | i386 | 552 | Empty main | | ||
| t/null.exe | x86_64 | 752 | Empty main | | ||
|
||
Compiler: GCC 4.8.2, gold linker 1.11 (binutils 2.24) OS: Ubuntu 14.04.2, Source: Author | ||
Compiler: GCC 4.8.4, gold linker 1.11, ld/binutils 2.24, OS: Ubuntu 14.04.3, Source: Author | ||
Compile Flags: `-Os -nostdlib -fomit-frame-pointer -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops -fmerge-all-constants -fno-ident -mfpmath=387 -mfancy-math-387 -ffunction-sections -fdata-sections Wl,--gc-sections` | ||
Link Flags: `-s -nostdlib -z norelro --hash-style=sysv --build-id=none --gc-sections` | ||
|
||
`HelloWorld` & `null` compiled with flags above but without `-nostdlib`. | ||
|
||
`HelloWorld.glibc.c` | ||
``` | ||
#include <unistd.h> | ||
int main( int argc, char** argv, char** envp ) | ||
{ | ||
int ret = write( 1, "Hello World!\n", 13 ); | ||
return( 0 ); | ||
} | ||
``` | ||
|
||
`null.glibc.c` | ||
``` | ||
int main( int argc, char** argv, char** envp ) | ||
{ | ||
return( 0 ); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Temporary files | ||
*.pid | ||
*.tmp | ||
*.footprint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <rt0/syscall.h> | ||
|
||
int write( int f, const char* d, int l ) | ||
{ | ||
int ret = syscall3( SYS_write, f, ( long )( d ), l ); | ||
|
||
return( ret ); | ||
} | ||
|
||
int str_len( const char *string ) | ||
{ | ||
int length = 0; | ||
while( *string ) { string++; length++; } | ||
return length; | ||
} | ||
|
||
void print( const char* string ) | ||
{ | ||
write( 1, string, str_len( string ) ); | ||
} | ||
|
||
void printLongHex( long i ) | ||
{ | ||
char* nums = "0123456789ABCDEF"; | ||
long d = 1, | ||
r; | ||
|
||
if( i < 0 ) | ||
{ | ||
print( "-" ); | ||
|
||
printLongHex( -i ); | ||
|
||
return; | ||
} | ||
|
||
d = i / 16; | ||
r = i % 16; | ||
|
||
if( d != 0 ) | ||
{ | ||
printLongHex( d ); | ||
} | ||
|
||
write( 1, &( nums[ r ] ), 1 ); | ||
} | ||
|
||
int main( int argc, char **argv, char **envp ) | ||
{ | ||
long addr; | ||
|
||
addr = ( long )( &__executable_start ); | ||
print( "Address of __executable_start: " ); | ||
printLongHex( addr ); | ||
print( "\n" ); | ||
|
||
addr = ( long )( &_etext ); | ||
print( "Address of _etext: " ); | ||
printLongHex( addr ); | ||
print( "\n" ); | ||
|
||
addr = ( long )( &_edata ); | ||
print( "Address of _edata: " ); | ||
printLongHex( addr ); | ||
print( "\n" ); | ||
|
||
addr = ( long )( &_end ); | ||
print( "Address of _end: " ); | ||
printLongHex( addr ); | ||
print( "\n" ); | ||
|
||
return( 0 ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.