aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md26
1 files changed, 15 insertions, 11 deletions
diff --git a/README.md b/README.md
index df398e3..2282091 100644
--- a/README.md
+++ b/README.md
@@ -59,7 +59,11 @@ Due to lack of `stderr` access in FALSE, syntax errors are emitted as `%fatal` N
### I/O Buffering
-Paradox currently does not buffer I/O (using syscalls directly) but will do so in the future. B/ß are no-ops.
+Paradox implements buffered I/O. It uses a fixed buffer size of 8192. To change this, you can use `sed -i 's/8192/YOUR_BUFSIZE_HERE/g' paradox.false`. To find out an appropriate buffer size for your system, you can use the following command, if you have a C compiler installed:
+
+```
+echo '#include <stdio.h>\nBUFSIZ' | cpp | tail -n1
+```
### Inline assembly
@@ -93,20 +97,20 @@ Variables and lambdas are pointers.
#### String pointers
-`["my_stringy"]$12+;$@21+;+\[$@$@>][1-$;,\]#%%10,` will print my_stringy in reverse (ygnirts_ym). This works with any string. This is due to the binary layout of lambdas containing a single string (consisting of just a syscall to print out the string):
+`["my_stringy"]$2+;$@11+;+\[$@$@>][1-$;,\]#%%10,` will print my_stringy in reverse (ygnirts_ym). This works with any string. This is due to the binary layout of lambdas containing a single string (consisting of just a call to write with the necessary parameters):
```
0000000000401002 <fun_1>:
- 401002: b8 01 00 00 00 mov eax,0x1
- 401007: bf 01 00 00 00 mov edi,0x1
- 40100c: 48 be 1e 10 40 00 00 movabs rsi,0x40101e
- 401013: 00 00 00
- 401016: ba 0a 00 00 00 mov edx,0xa
- 40101b: 0f 05 syscall
- 40101d: c3 ret
+ 401002: 48 be 00 20 40 00 00 movabs rsi,0x402000
+ 401009: 00 00 00
+ 40100c: b9 09 00 00 00 mov ecx,0x9
+ 401011: e8 86 00 00 00 call 40109c <write>
+ 401016: c3 ret
```
-A pointer to the string is stored at offset 12, and the length is stored at offset 21.
+(generated by `objdump -D -M intel some_binary_here`)
+
+A pointer to the string (0x402000) is stored at offset 2, and the length of the string (0x9) is stored at offset 11.
Strings are stored in the data section, so it is possible to write to them.
@@ -116,7 +120,7 @@ It is possible to make memory allocations using strings by compiling your progra
(echo "[\"$(head -c YOUR_ALLOCATION_SIZE /dev/zero)\"]" && cat your_source_file.false) | ./paradox
```
-In the program, you can then use `12+;` at the beginning of the file to extract a pointer to your allocation.
+In the program, you can then use `2+;` at the beginning of the file to extract a pointer to your allocation.
Since all operations fetch 64-bits, it is recommended to set the allocation size to 7 bytes higher than desired (if you wish to fetch/write the last few bytes of the allocation individually).