Add x1 experiments

This commit is contained in:
Takumi Sueda
2021-03-04 02:15:40 +09:00
parent fd655b4839
commit c997a68459
7 changed files with 324 additions and 0 deletions

10
x1/Makefile Normal file
View File

@@ -0,0 +1,10 @@
CROSS_COMPILE:=arm-linux-gnueabi-
AS:=$(CROSS_COMPILE)as
.PHONY:
all: return.bin mrc.bin
%.bin: %.S
@$(AS) $<
@./extract.py a.out $@
@rm -f a.out

16
x1/README.md Normal file
View File

@@ -0,0 +1,16 @@
#### Code
- `mrc.S` Read SCTLR (MMU etc.) and return
- `return.S` Return immediately
- `extract.py` Extract .text
#### Build
```sh
pip3 install pyelftools
make all
```
#### Run
- Create a directory `/path/to/sd/APP/foo`
- Create index.din `touch /path/to/sd/APP/foo/index.din`
- Copy and rename the raw executable `cp foo.bin /path/to/sd/APP/foo/AppMain.bin`

27
x1/extract.py Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env python3
import sys
from elftools.elf.elffile import ELFFile # pip install pyelftools
def main():
if len(sys.argv) < 3:
print(f'Usage: {sys.argv[0]} in.elf out.bin')
sys.exit(1)
with open(sys.argv[1], 'rb') as f:
extract(ELFFile(f))
def extract(elf):
text = elf.get_section_by_name('.text')
if text is None:
print('Input ELF has no .text section', file=sys.stderr)
with open(sys.argv[2], 'wb') as f:
f.write(text.data())
print(f'Successfully extracted the .text section to "{sys.argv[2]}"')
main()

7
x1/mrc.S Normal file
View File

@@ -0,0 +1,7 @@
.text
.align 2
.global _start
_start:
mrc p15, 0, r10, c1, c0, 0
mov pc, lr

6
x1/return.S Normal file
View File

@@ -0,0 +1,6 @@
.text
.align 2
.global _start
_start:
mov pc, lr