├── Makefile └── README.md /Makefile: -------------------------------------------------------------------------------- 1 | TARGET = sample 2 | SRC = main.c 3 | OBJS = main.o 4 | 5 | LIBS = -lc 6 | 7 | 8 | PREFIX = armv6-freebsd 9 | CC = clang -v 10 | #LD = $PREFIX-ld -v 11 | CFLAGS = -march=armv7-a -mfloat-abi=hard -ccc-host-triple arm-elf -integrated-as --sysroot /usr/armv6-freebsd -static 12 | ASFLAGS = $(CFLAGS) 13 | 14 | all: $(TARGET).elf 15 | 16 | $(TARGET).elf: $(OBJS) 17 | $(CC) $(CFLAGS) $(SRC) $(LIBS) -o $@ 18 | $(PREFIX)-strip $@ 19 | 20 | clean: 21 | @rm -rf $(TARGET).elf $(OBJS) 22 | 23 | 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # eapdev 2 | Experimental toolchain freebsd 9 for arm cortex-a8 3 | 4 | Brief History 5 | =================== 6 | PlayStation 4 is based on Freebsd 9, source reference is from September 10, 2011 named release 900044. 7 | 8 | Main processor is AMD based but there is an infamous chip from Marvell that also use Freebsd but based on ARM 9 | 10 | Some people have been working in arm-eabi branch in freebsd since a few years ago, adding a armv6 target with support for some arm boards but the main work is in freebsd 10.x so i have been backporting some of their patches to freebsd 9. 11 | 12 | What does this do? 13 | =================== 14 | This is a experimental patch to let compile arm contex-a8 eabi V code in freebsd 9 for educational purposes only 15 | 16 | What do i need? 17 | =================== 18 | A virtual machine with Freebsd 9.0 Release installed from: 19 | http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/amd64/ISO-IMAGES/9.0/FreeBSD-9.0-RELEASE-amd64-dvd1.iso 20 | 21 | 1) Install it with virtualbox 22 | 23 | You must choose install src, you will need it to patch after install. Create a non root user and add to wheel group 24 | 25 | 2) Login with your created non root user 26 | 27 | 3) Install sudo port 28 | 29 | ``` 30 | $ su - 31 | eapjutsu# cd /usr/ports/security/sudo 32 | eapjutsu# make install 33 | ``` 34 | 35 | uncomment group wheel to let use sudo to our user 36 | ``` 37 | eapjutsu# vi /usr/local/etc/sudoers 38 | ``` 39 | 4) Install gmake port 40 | 41 | ``` 42 | eapjutsu# cd /usr/ports/devel/gmake 43 | eapjutsu# make install 44 | eapjutsu# exit 45 | ``` 46 | 47 | 5) Download repository 48 | 49 | 6) Copy local sources to our working directory 50 | ``` 51 | $ cd 52 | $ mkdir work 53 | $ 54 | $ cd /usr 55 | $ tar cvf /home/bigboss/work/src.tar ./src 56 | $ cd 57 | $ cd work 58 | $ tar xf src.tar 59 | $ cd src 60 | $ patch -p1 < ../eapjutsu_patch.txt 61 | ``` 62 | 7) Compile cross toolchain for armv6 target 63 | ``` 64 | $ sudo make XDEV=arm XDEV_ARCH=armv6 xdev 65 | ``` 66 | 8) Native clang is invoking /usr/bin/ld change to use our generated ld 67 | ``` 68 | $ cd /usr/bin 69 | $ sudo cp ld ld.orig 70 | $ sudo rm ld 71 | $ sudo ln -s armv6-freebsd-ld ld 72 | ``` 73 | 9) Use Makefile included with your main.c 74 | ``` 75 | $ make 76 | clang -v -march=armv7-a -mfloat-abi=hard -ccc-host-triple arm-elf -integrated-as --sysroot /usr/armv6-freebsd -static -c main.c 77 | FreeBSD clang version 3.0 (branches/release_30 142614) 20111021 78 | Target: arm-elf- 79 | Thread model: posix 80 | "/usr/bin/clang" -cc1 -triple armv7-elf- -emit-obj -mrelax-all -disable-free -main-file-name main.c -static-define -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-abi apcs-gnu -target-cpu cortex-a8 -mfloat-abi hard -momit-leaf-frame-pointer -v -coverage-file main.o -resource-dir /usr/bin/../lib/clang/3.0 -isysroot /usr/armv6-freebsd -fmodule-cache-path /var/tmp/clang-module-cache -ferror-limit 19 -fmessage-length 80 -fno-signed-char -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fdiagnostics-show-option -fcolor-diagnostics -o main.o -x c main.c 81 | clang -cc1 version 3.0 based upon llvm 3.0 hosted on x86_64-unknown-freebsd9.0 82 | ignoring nonexistent directory "/usr/armv6-freebsd/usr/local/include" 83 | ignoring nonexistent directory "/usr/bin/../lib/clang/3.0/include" 84 | #include "..." search starts here: 85 | #include <...> search starts here: 86 | /usr/armv6-freebsd/usr/include 87 | End of search list. 88 | clang -v -march=armv7-a -mfloat-abi=hard -ccc-host-triple arm-elf -integrated-as --sysroot /usr/armv6-freebsd -static main.c -lc -o sample.elf 89 | FreeBSD clang version 3.0 (branches/release_30 142614) 20111021 90 | Target: arm-elf- 91 | Thread model: posix 92 | "/usr/bin/clang" -cc1 -triple armv7-elf- -emit-obj -mrelax-all -disable-free -main-file-name main.c -static-define -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-abi apcs-gnu -target-cpu cortex-a8 -mfloat-abi hard -momit-leaf-frame-pointer -v -resource-dir /usr/bin/../lib/clang/3.0 -isysroot /usr/armv6-freebsd -fmodule-cache-path /var/tmp/clang-module-cache -ferror-limit 19 -fmessage-length 80 -fno-signed-char -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-9GeDkO.o -x c main.c 93 | clang -cc1 version 3.0 based upon llvm 3.0 hosted on x86_64-unknown-freebsd9.0 94 | ignoring nonexistent directory "/usr/armv6-freebsd/usr/local/include" 95 | ignoring nonexistent directory "/usr/bin/../lib/clang/3.0/include" 96 | #include "..." search starts here: 97 | #include <...> search starts here: 98 | /usr/armv6-freebsd/usr/include 99 | End of search list. 100 | "/usr/bin/gcc" -v -march=armv7-a -mfloat-abi=hard --sysroot=/usr/armv6-freebsd -static -o sample.elf /tmp/main-9GeDkO.o -lc 101 | Using built-in specs. 102 | Target: amd64-undermydesk-freebsd 103 | Configured with: FreeBSD/amd64 system compiler 104 | Thread model: posix 105 | gcc version 4.2.1 20070831 patched [FreeBSD] 106 | /usr/bin/ld --sysroot=/usr/armv6-freebsd -V -Bstatic -o sample.elf /usr/armv6-freebsd/usr/lib/crt1.o /usr/armv6-freebsd/usr/lib/crti.o /usr/armv6-freebsd/usr/lib/crtbeginT.o -L/usr/armv6-freebsd/usr/lib -L/usr/armv6-freebsd/usr/lib /tmp/main-9GeDkO.o -lc -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/armv6-freebsd/usr/lib/crtend.o /usr/armv6-freebsd/usr/lib/crtn.o 107 | GNU ld 2.17.50 [FreeBSD] 2007-07-03 108 | Supported emulations: 109 | armelf_fbsd 110 | armv6-freebsd-strip sample.elf 111 | ``` 112 | 10) Checks 113 | ``` 114 | $ readelf -h sample.elf 115 | ELF Header: 116 | Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 117 | Class: ELF32 118 | Data: 2's complement, little endian 119 | Version: 1 (current) 120 | OS/ABI: UNIX - System V 121 | ABI Version: 0 122 | Type: EXEC (Executable file) 123 | Machine: ARM 124 | Version: 0x1 125 | Entry point address: 0x8100 126 | Start of program headers: 52 (bytes into file) 127 | Start of section headers: 119964 (bytes into file) 128 | Flags: 0x5000202, has entry point, Version5 EABI, 129 | Size of this header: 52 (bytes) 130 | Size of program headers: 32 (bytes) 131 | Number of program headers: 3 132 | Size of section headers: 40 (bytes) 133 | Number of section headers: 15 134 | Section header string table index: 14 135 | $ readelf -A sample.elf 136 | Attribute Section: aeabi 137 | File Attributes 138 | Tag_CPU_name: "CORTEX-A8" 139 | Tag_CPU_arch: v7 140 | Tag_CPU_arch_profile: Application 141 | Tag_ARM_ISA_use: Yes 142 | Tag_THUMB_ISA_use: Thumb-2 143 | Tag_VFP_arch: VFPv3 144 | Tag_NEON_arch: NEONv1 145 | Tag_ABI_FP_denormal: Needed 146 | Tag_ABI_FP_exceptions: Needed 147 | Tag_ABI_FP_number_model: IEEE 754 148 | Tag_ABI_align8_needed: Yes 149 | Tag_ABI_align8_preserved: Yes, except leaf SP 150 | ``` 151 | 152 | 153 | --------------------------------------------------------------------------------