First milestone - mikpe/pdp10-tools GitHub Wiki
First milestone
Today the pdp10-elf project reached its first milestone: linking and executing a simple but not entirely trivial program:
> cat test-pdp10/crt0.s
.text
.globl _start
.type _start,@function
_start:
# AC1 = argc
# AC2 = argv
# AC3 = envp
# c.f. sim_core:run/6
pushj 017,main
pushj 017,_exit # _exit(main())
.size _start,.-_start
> cat test-pdp10/exit.s
.text
.globl _exit
.type _exit,@function
_exit: # AC1 = exit status
jsys 0136 # __NR_exit_group
halt 0
.size _exit,.-_exit
> cat test-pdp10/main.s
.text
.globl main
.type main,@function
main:
movei 1,42 # return 42
popj 017,
.size main,.-main
> _build/default/bin/as -o crt0.o test-pdp10/crt0.s
> _build/default/bin/as -o exit.o test-pdp10/exit.s
> _build/default/bin/ar ruv libc.a crt0.o exit.o
a - crt0.o
a - exit.o
> _build/default/bin/as -o main.o test-pdp10/main.s
> _build/default/bin/ld main.o libc.a
> _build/default/bin/readelf -a --disassemble a.out
ELF Header:
Magic: 7f 45 4c 46 24 02 01 00 00 00 00 00 00 00 00 00
Class: 36 (ELF36)
Data: 2 (2's complement, big endian)
Version: 1 (current)
OS/ABI: 0 (Generic)
ABI Version: 0
Type: 2 (Executable file)
Machine: 64 (Digital Equipment Corp. PDP-10)
Version: 1 (current)
Entry point address: 0x201008
Start of program headers: 52
Start of section headers: 0
Flags: 0x0
Size of this header: 52
Size of program headers: 32
Number of program headers: 1
Size of section headers: 40
Number of section headers: 0
Section header string table index: 0
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), Z (compressed)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required), o (OS specific), p (processor specific)
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000001000 0x000201000 0x000000000 0x000000018 0x000000018 R E 0x1000
Disassembly of segment nr 0:
0x201000: 0201040000052 movei 1,42
0x201004: 0263740000000 popj 15,0
0x201008: 0260740002000 pushj 15,1024
0x20100c: 0260740002004 pushj 15,1028
0x201010: 0104000000136 jsys 0,94
0x201014: 0254200000000 halt 0
> _build/default/bin/sim a.out && echo $?
42
(The addresses are actually correct, they only look strange due to the mix of hex and octal. I'll have to stick with octal I think.)
Now on to adapting XKL's GCC port for these "binutils".