diff options
Diffstat (limited to 'sys/arch/macppc/stand/boot.mac')
-rw-r--r-- | sys/arch/macppc/stand/boot.mac/Makefile | 36 | ||||
-rw-r--r-- | sys/arch/macppc/stand/boot.mac/hack-coff.c | 29 | ||||
-rw-r--r-- | sys/arch/macppc/stand/boot.mac/ld.script | 68 |
3 files changed, 133 insertions, 0 deletions
diff --git a/sys/arch/macppc/stand/boot.mac/Makefile b/sys/arch/macppc/stand/boot.mac/Makefile new file mode 100644 index 00000000000..4c360f79f45 --- /dev/null +++ b/sys/arch/macppc/stand/boot.mac/Makefile @@ -0,0 +1,36 @@ +# $OpenBSD: Makefile,v 1.1 2001/09/01 15:36:37 drahn Exp $ +# $NetBSD: Makefile,v 1.1 1996/09/30 16:35:05 ws Exp $ + +R= .. +.PATH: $(.CURDIR)/$(R) +RELOC= 6c0000 +ENTRY= _entry +PROG= boot.mac +SRCS= Locore.c boot.c ofdev.c net.c netif_of.c alloc.c cache.c hfs.c +CFLAGS+= -DDEBUG -DNETIF_DEBUG +NOMAN= +INSTALL_STRIP= +BINDIR= /usr/mdec +OBJCOPY?= objcopy +OBJCOPY_ARGS= -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment +LDFLAGS= -X -Ttext ${RELOC} -e $(ENTRY) -T ${.CURDIR}/ld.script + +CPPFLAGS+= -I. -I${.CURDIR}/../../.. -I${.CURDIR}/../../../.. +CPPFLAGS+= -DRELOC=0x${RELOC} +CPPFLAGS+= -DFIRMWORKSBUGS +CPPFLAGS+= -DPOWERPC_BOOT_ELF +CPPFLAGS+= -DXCOFF_GLUE # for booting PCI Powermacs + + +LIBS!= cd $(.CURDIR)/$(R); $(MAKE) libdep +CLEANFILES= hack-coff + +$(PROG): $(OBJS) $(LIBS) hack-coff + $(LD) $(LDFLAGS) $(OBJS) $(LIBS) -o ${.TARGET} + ${OBJCOPY} ${OBJCOPY_ARGS} ${.TARGET} + ${.OBJDIR}/hack-coff ${.TARGET} + +hack-coff: hack-coff.c + ${HOSTCC} -I${.CURDIR} -o hack-coff ${.CURDIR}/hack-coff.c + +.include <bsd.prog.mk> diff --git a/sys/arch/macppc/stand/boot.mac/hack-coff.c b/sys/arch/macppc/stand/boot.mac/hack-coff.c new file mode 100644 index 00000000000..4a01d40a70b --- /dev/null +++ b/sys/arch/macppc/stand/boot.mac/hack-coff.c @@ -0,0 +1,29 @@ +/* $OpenBSD: hack-coff.c,v 1.1 2001/09/01 15:36:37 drahn Exp $ */ + +#include <stdio.h> + +char magic[2] = { 1, 0xb }; +char snos[12] = { 0, 1, 0, 1, 0, 2, 0, 0, 0, 0, 0, 3 }; + +main(int ac, char **av) +{ + int fd; + + if (ac != 2) { + fprintf(stderr, "Usage: hack-coff coff-file\n"); + exit(1); + } + if ((fd = open(av[1], 2)) == -1) { + perror(av[2]); + exit(1); + } + if (lseek(fd, (long) 0x14, 0) == -1 + || write(fd, magic, sizeof(magic)) != sizeof(magic) + || lseek(fd, (long) 0x34, 0) == -1 + || write(fd, snos, sizeof(snos)) != sizeof(snos)) { + fprintf(stderr, "%s: write error\n", av[1]); + exit(1); + } + close(fd); + exit(0); +} diff --git a/sys/arch/macppc/stand/boot.mac/ld.script b/sys/arch/macppc/stand/boot.mac/ld.script new file mode 100644 index 00000000000..2469ed65dcb --- /dev/null +++ b/sys/arch/macppc/stand/boot.mac/ld.script @@ -0,0 +1,68 @@ +OUTPUT_ARCH(powerpc) +SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib); +/* Do we need any of these for elf? + __DYNAMIC = 0; */ +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = + SIZEOF_HEADERS; + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rel.text : { *(.rel.text) } + .rela.text : { *(.rela.text) } + .rel.data : { *(.rel.data) } + .rela.data : { *(.rela.data) } + .rel.rodata : { *(.rel.rodata) } + .rela.rodata : { *(.rela.rodata) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : { *(.init) } =0 + .plt : { *(.plt) } + .text : + { + *(.text) + *(.rodata) + *(.rodata1) + *(.got1) + } + .fini : { *(.fini) } =0 + .ctors : { *(.ctors) } + .dtors : { *(.dtors) } + _etext = .; + PROVIDE (etext = .); + /* Read-write section, merged into data segment: */ + . = (. + 0x0FFF) & 0xFFFFF000; + .data : + { + *(.data) + *(.data1) + *(.sdata) + *(.sdata2) + *(.got.plt) *(.got) + *(.dynamic) + CONSTRUCTORS + } + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + .bss : + { + *(.sbss) *(.scommon) + *(.dynbss) + *(.bss) + *(COMMON) + } + _end = . ; + PROVIDE (end = .); +} + |