diff --git a/.gitignore b/.gitignore index 605fa76b6..b08542a6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ config.log config.status autom4te.cache +Makefile +*.pcap diff --git a/Makefile.in b/Makefile.in index c0426cfe8..454208642 100644 --- a/Makefile.in +++ b/Makefile.in @@ -16,7 +16,13 @@ test: @echo "Nothing to test" qemu: - $(QEMU) -smp 10 -kernel linux/arch/x86/boot/bzImage -initrd config/initrd.cpio -append "root=/dev/ram0 rootfstype=ramfs init=init console=ttyS0" -net nic,model=rtl8139 -net user -net dump -nographic -monitor telnet:127.0.0.1:1234,server,nowait -m 8G -numa node,nodeid=0,cpus=0-4 -numa node,nodeid=1,cpus=5-9 -cdrom hermit/tools/proxy-image.iso + $(QEMU) -smp 10 -m 8G -numa node,nodeid=0,cpus=0-4 -numa node,nodeid=1,cpus=5-9 \ + -kernel linux/arch/x86/boot/bzImage -initrd config/initrd.cpio \ + -append "root=/dev/ram0 rootfstype=ramfs init=init console=ttyS0" \ + -net nic,model=rtl8139 -net user -net dump \ + -nographic -monitor telnet:127.0.0.1:1234,server,nowait \ + -fsdev local,security_model=passthrough,id=fsdev0,path=$(shell realpath hermit) \ + -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hermit clean: make -C hermit clean diff --git a/README.md b/README.md index 0d0c1a130..6805343e6 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ The project has just initiated. Further information will be published shortly. * Netwide Assembler (NASM) * GNU Make, GNU Binutils * Tools and libraries to build *linux*, *binutils* and *gcc* (e.g. flex, bison, MPFR library, GMP library, MPC library, ISL library) -* genisoimage * texinfo * Qemu @@ -20,6 +19,7 @@ The project has just initiated. Further information will be published shortly. 5. Afterwards, a small Linux system should run, which already includes the patches for HermitCore. For each NUMA node (= HermitCore isle) is in `/sys/hermit` a directory `isleX` created, where `X` represents the number of the NUMA node. The demo applications are located in the directory `/hermit` and possess the file extension `_proxy`. These applications are Linux proxies, in which the HermitCore binaries are embedded. By starting the Linux proxies, the embedded HermitCore binaries will be automatically started on isle 0 with cpu 1. To change the default behavior, the environment variable `HERMIT_ISLE` is used to specify the (memory) location of the isle, while the environment variable `HERMIT_CPUS` is used to specify the cores. For instance, `HERMIT_ISLE=1 HERMIT_CPUS="3-5" /hermit/hello_proxy` starts a HelloWorld demo on the HermitCore isle 1, which used the cores 3 to 5. The output messages are forwarded to the Linux proxy and printed on the Linux system. 6. HermitCore's kernel messages of `isleX` are available via `cat /sys/hermit/isleX/log`, where `X` represents the isle. 7. It exists an virtual IP devices between HermitCore isles and the Linux system (see output of `ifconfig`). Per default, the Linux system has the IP address `192.168.28.1`. The HermitCore isles starts with the IP address `192.168.28.2` for isle 0 and is increased by one for every isle. +8. Hermit applications are available at `/hermit/usr/{tests,benchmarks}` which is a shared directory between the host and QEmu. ## Building and testing HermitCore on a real machine @@ -37,4 +37,6 @@ NETMASK=255.255.255.0 IPADDR=192.168.28.1 NM_CONTROLLED=yes ``` -Finally, boot your system with the new Linux kernel and follow the above tutorial (*Building and testing HermitCore within a virtual machine*) from point 5. The demo applications are stored in the subdirectory `hermit/tools/iso` of the directory, which contains this *README*. +Finally, boot your system with the new Linux kernel and follow the above tutorial (*Building and testing HermitCore within a virtual machine*) from point 5. + +The demo applications are stored in their subdirectories `hermit/usr/{tests,benchmarks}` of the directory, which contains this *README*. diff --git a/config/initrd.cpio b/config/initrd.cpio index 00915df43..9244a04d8 100644 Binary files a/config/initrd.cpio and b/config/initrd.cpio differ diff --git a/config/linux_config b/config/linux_config index 93aefe55a..94099ffd7 100644 --- a/config/linux_config +++ b/config/linux_config @@ -544,7 +544,7 @@ CONFIG_AMD_NB=y CONFIG_BINFMT_ELF=y CONFIG_BINFMT_SCRIPT=y # CONFIG_HAVE_AOUT is not set -# CONFIG_BINFMT_MISC is not set +CONFIG_BINFMT_MISC=y # CONFIG_COREDUMP is not set # CONFIG_IA32_EMULATION is not set CONFIG_X86_DEV_DMA_OPS=y @@ -643,7 +643,9 @@ CONFIG_NET_FLOW_LIMIT=y # CONFIG_WIRELESS is not set # CONFIG_WIMAX is not set # CONFIG_RFKILL is not set -# CONFIG_NET_9P is not set +CONFIG_NET_9P=y +CONFIG_NET_9P_VIRTIO=y +# CONFIG_NET_9P_DEBUG is not set # CONFIG_CAIF is not set # CONFIG_CEPH_LIB is not set # CONFIG_NFC is not set @@ -700,6 +702,7 @@ CONFIG_BLK_DEV=y # CONFIG_BLK_DEV_RAM is not set # CONFIG_CDROM_PKTCDVD is not set # CONFIG_ATA_OVER_ETH is not set +# CONFIG_VIRTIO_BLK is not set # CONFIG_BLK_DEV_HD is not set # CONFIG_BLK_DEV_RBD is not set # CONFIG_BLK_DEV_RSXX is not set @@ -843,6 +846,7 @@ CONFIG_SCSI_LOWLEVEL=y # CONFIG_SCSI_DEBUG is not set # CONFIG_SCSI_PMCRAID is not set # CONFIG_SCSI_PM8001 is not set +# CONFIG_SCSI_VIRTIO is not set # CONFIG_SCSI_DH is not set # CONFIG_SCSI_OSD_INITIATOR is not set CONFIG_ATA=y @@ -962,6 +966,7 @@ CONFIG_NET_CORE=y # CONFIG_TUN is not set # CONFIG_TUN_VNET_CROSS_LE is not set # CONFIG_VETH is not set +# CONFIG_VIRTIO_NET is not set # CONFIG_NLMON is not set # CONFIG_ARCNET is not set @@ -1146,6 +1151,7 @@ CONFIG_SERIAL_CORE_CONSOLE=y # CONFIG_SERIAL_RP2 is not set # CONFIG_SERIAL_FSL_LPUART is not set CONFIG_TTY_PRINTK=y +# CONFIG_VIRTIO_CONSOLE is not set # CONFIG_IPMI_HANDLER is not set # CONFIG_HW_RANDOM is not set # CONFIG_NVRAM is not set @@ -1361,11 +1367,15 @@ CONFIG_RTC_LIB=y # CONFIG_AUXDISPLAY is not set # CONFIG_UIO is not set # CONFIG_VIRT_DRIVERS is not set +CONFIG_VIRTIO=y # # Virtio drivers # -# CONFIG_VIRTIO_PCI is not set +CONFIG_VIRTIO_PCI=y +CONFIG_VIRTIO_PCI_LEGACY=y +# CONFIG_VIRTIO_BALLOON is not set +# CONFIG_VIRTIO_INPUT is not set # CONFIG_VIRTIO_MMIO is not set # @@ -1468,7 +1478,7 @@ CONFIG_EXT2_FS=y # CONFIG_NILFS2_FS is not set # CONFIG_F2FS_FS is not set # CONFIG_FS_DAX is not set -# CONFIG_FS_POSIX_ACL is not set +CONFIG_FS_POSIX_ACL=y # CONFIG_FILE_LOCKING is not set # CONFIG_FSNOTIFY is not set # CONFIG_DNOTIFY is not set @@ -1488,11 +1498,8 @@ CONFIG_EXT2_FS=y # # CD-ROM/DVD Filesystems # -CONFIG_ISO9660_FS=y -CONFIG_JOLIET=y -# CONFIG_ZISOFS is not set -CONFIG_UDF_FS=y -CONFIG_UDF_NLS=y +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set # # DOS/FAT/NT Filesystems @@ -1515,7 +1522,15 @@ CONFIG_HUGETLBFS=y CONFIG_HUGETLB_PAGE=y # CONFIG_CONFIGFS_FS is not set # CONFIG_MISC_FILESYSTEMS is not set -# CONFIG_NETWORK_FILESYSTEMS is not set +CONFIG_NETWORK_FILESYSTEMS=y +# CONFIG_CEPH_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set +CONFIG_9P_FS=y +CONFIG_9P_FS_POSIX_ACL=y +# CONFIG_9P_FS_SECURITY is not set CONFIG_NLS=y CONFIG_NLS_DEFAULT="iso8859-1" # CONFIG_NLS_CODEPAGE_437 is not set diff --git a/hermit/.gitignore b/hermit/.gitignore index 1c4e51946..6de7dfc4d 100644 --- a/hermit/.gitignore +++ b/hermit/.gitignore @@ -10,9 +10,7 @@ qemu-vlan0.pcap autom4te.cache documentation/html/ include/hermit/config.inc -tools/*.img -tools/*_proxy -tools/*iso +tools/proxy tools/init.h usr/tests/hello usr/tests/hello++ diff --git a/hermit/tools/Makefile b/hermit/tools/Makefile index 63980ae0b..e4ec4d55b 100644 --- a/hermit/tools/Makefile +++ b/hermit/tools/Makefile @@ -4,8 +4,7 @@ NASMFLAGS = -fbin CC = gcc CFLAGS = -O2 -Wall HEXDUMP = hexdump -LDFLGAS = -PROXYFILES = $(shell find ../usr/tests -name '*.bin') $(shell find ../usr/benchmarks -name '*.bin') $(shell find ../usr/openmpbench -name '*.bin') +PROXYFILES = proxy init.sh $(shell find ../usr/tests ../usr/benchmarks ../usr/openmpbench -type f -executable) # Prettify output V = 0 @@ -19,9 +18,11 @@ endif @echo [CC] $@ $Q$(CC) -c $(CFLAGS) -o $@ $< -default: all - -all: init.h +all: init.h proxy + +proxy: proxy.o + @echo [LD] $@ + $Q$(CC) $(CFLAGS) -o $@ $< -lelf init.bin: init.asm @echo [NASM] $@ @@ -33,15 +34,6 @@ init.h: init.bin $Q$(HEXDUMP) -v -e '"0x" 1/1 "%02X" ", "' $< >> $@ $Q@echo "};" >> $@ -iso: - mkdir iso - -proxy: iso $(PROXYFILES) - @echo [PROXY] Create proxy files - $Q./create_proxy.sh $(foreach FILE, $(PROXYFILES), $(FILE)) - $Qmv *_proxy iso/ - $Qgenisoimage -R -J -input-charset utf8 -o proxy-image.iso iso - clean: @echo Cleaning tools $Q$(RM) -rf *.o *~ *.bin *.obj *.h diff --git a/hermit/tools/create_proxy.sh b/hermit/tools/create_proxy.sh deleted file mode 100755 index b10485a1a..000000000 --- a/hermit/tools/create_proxy.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -while [[ $# > 0 ]] -do - fname=$(basename "$1") - fname_new="${fname//.bin}"_proxy - - echo "Create proxy for $fname" - echo ".section .rodata" > inc.S - echo ".global hermit_app" >> inc.S - echo ".type hermit_app, @object" >> inc.S - echo ".align 4" >> inc.S - echo "hermit_app:" >> inc.S - echo .incbin \""$1"\" >> inc.S - echo ".global app_size" >> inc.S - echo ".type app_size, @object" >> inc.S - echo ".align 4" >> inc.S - echo "app_size:" >> inc.S - echo ".int app_size - hermit_app" >> inc.S - - cc -O2 -Wall -o $fname_new proxy.c inc.S - rm -rf inc.S - - shift -done diff --git a/hermit/tools/init.sh b/hermit/tools/init.sh new file mode 100755 index 000000000..18f4a422b --- /dev/null +++ b/hermit/tools/init.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +PROXY=/hermit/tools/proxy + +ELF_OSABI_OFFSET=7 +ELF_OSABI="\\x42" + +# Network +/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 up +/sbin/ifconfig eth0 up 10.0.2.15 netmask 255.255.255.0 up +/sbin/ifconfig mmnif up 192.168.28.1 netmask 255.255.255.0 up +/sbin/route add default gw 10.0.2.2 +/bin/hostname -F /etc/hostname +echo "Network setup completed" + +# Load binfmt_misc kernel module and mount pseudo FS +test -d /lib/modules && modprobe binfmt_misc +grep binfmt_misc /proc/mounts || mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc + +# Register new format +echo ":hermit:M:$ELF_OSABI_OFFSET:$ELF_OSABI::$PROXY:" > /proc/sys/fs/binfmt_misc/register + +# Startup completed +sleep 1 && echo -e '\n\nWelcome to HermitCore (http://www.hermitcore.org/)!' + +/bin/sh diff --git a/hermit/tools/proxy.c b/hermit/tools/proxy.c index 5ad8d1539..6d8d6aba5 100644 --- a/hermit/tools/proxy.c +++ b/hermit/tools/proxy.c @@ -33,15 +33,21 @@ #include #include #include +#include #include #include +#include #include #include #include -#define HERMIT_PORT 0x494E -#define HERMIT_MAGIC 0x7E317 #define MAX_PATH 255 +#define INADDR(a, b, c, d) (struct in_addr) { .s_addr = ((((((d) << 8) | (c)) << 8) | (b)) << 8) | (a) } + +#define HERMIT_PORT 0x494E +#define HERMIT_IP(isle) INADDR(192, 168, 28, isle + 2) +#define HERMIT_MAGIC 0x7E317 +#define HERMIT_ELFOSABI 0x42 #define __HERMIT_exit 0 #define __HERMIT_write 1 @@ -50,13 +56,10 @@ #define __HERMIT_read 4 #define __HERMIT_lseek 5 -static char saddr[16]; static int sobufsize = 131072; static unsigned int isle_nr = 0; static char fname[] = "/tmp/hermitXXXXXX"; -extern char hermit_app[]; -extern unsigned app_size; extern char **environ; static void stop_hermit(void); @@ -74,9 +77,102 @@ static void exit_handler(int sig) exit(0); } -static int init_env(void) +static int load_elf(int dest_fd, int elf_fd) +{ + Elf *elf; + GElf_Ehdr ehdr; + GElf_Phdr phdr ; + + size_t n; + int ret; + int i; + + if (elf_version(EV_CURRENT) == EV_NONE) + return -1; + + elf = elf_begin(elf_fd, ELF_C_READ, NULL); + if (!elf) + return -1; + + if (elf_kind(elf) != ELF_K_ELF) + goto out; + + if (gelf_getehdr(elf, &ehdr) != &ehdr) + goto out; + + if (ehdr.e_ident[EI_OSABI] != HERMIT_ELFOSABI) + goto out; + + if (elf_getphdrnum(elf , &n) != 0) + goto out; + + for (i = 0; i < n ; i ++) { + ssize_t ret; + off_t offset; + + if (gelf_getphdr(elf, i, &phdr) != & phdr ) + continue; + + if (phdr.p_type != PT_LOAD) + continue; + offset = phdr.p_offset; + ret = sendfile(dest_fd, elf_fd, &offset, phdr.p_filesz); + if (ret != phdr.p_filesz || offset != phdr.p_offset + phdr.p_filesz) + goto out; + } + + ret = 0; + +out: elf_end(elf); + + return ret; +} + +static int load_bin(const char *app) +{ + int tmp_fd, elf_fd, ret; + FILE *file; + + mkstemp(fname); + + // register function to delete temporary files + atexit(fini_env); + + tmp_fd = open(fname, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO); + if (tmp_fd < 0) { + perror("open"); + exit(1); + } + + // get text section from elf binary + elf_fd = open(app, O_RDONLY, 0); + if (elf_fd < 0) { + perror("open"); + exit(1); + } + + ret = load_elf(tmp_fd, elf_fd); + if (ret) + goto out; + + // set path to temporary file + file = fopen("/sys/hermit/path", "w"); + if (!file) { + perror("fopen"); + exit(1); + } + + fprintf(file, "%s", fname); + fclose(file); + +out: close(tmp_fd); + close(elf_fd); + + return ret; +} + +static int init_env(const char *path) { - int j, fd; int ret; char* str; FILE* file; @@ -84,7 +180,7 @@ static int init_env(void) char* result; struct sigaction sINT, sTERM; - /* define action for SIGINT */ + // define action for SIGINT sINT.sa_handler = exit_handler; sINT.sa_flags = 0; if (sigaction(SIGINT, &sINT, NULL) < 0) @@ -93,7 +189,7 @@ static int init_env(void) exit(1); } - /* define action for SIGTERM */ + // define action for SIGTERM sTERM.sa_handler = exit_handler; sTERM.sa_flags = 0; if (sigaction(SIGTERM, &sTERM, NULL) < 0) @@ -110,45 +206,13 @@ static int init_env(void) isle_nr = 0; } - snprintf(saddr, 16, "192.168.28.%u", isle_nr+2); - - mkstemp(fname); - - // register function to delete temporary files - atexit(fini_env); - - fd = open(fname, O_CREAT|O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO); - if (fd < 0) { - perror("open"); + // load application + ret = load_bin(path); + if (ret) { + perror("Failed to load binary"); exit(1); } - // write binary to tmpfs - j = 0; - while(j < app_size) - { - ret = write(fd, hermit_app+j, app_size-j); - if (ret < 0) { - perror("write"); - close(fd); - exit(1); - } - j += ret; - } - - close(fd); - - // set path to temporary file - file = fopen("/sys/hermit/path", "w"); - if (!file) { - perror("fopen"); - exit(1); - } - - fprintf(file, "%s", fname); - - fclose(file); - // start application snprintf(isle_path, MAX_PATH, "/sys/hermit/isle%d/cpus", isle_nr); file = fopen(isle_path, "w"); @@ -440,7 +504,7 @@ int main(int argc, char **argv) int32_t magic = HERMIT_MAGIC; struct sockaddr_in serv_name; - init_env(); + init_env(argv[1]); /* create a socket */ s = socket(PF_INET, SOCK_STREAM, 0); @@ -451,7 +515,7 @@ int main(int argc, char **argv) } setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sobufsize, sizeof(sobufsize)); - setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sobufsize, sizeof(sobufsize)); + setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sobufsize, sizeof(sobufsize)); i = 1; setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &i, sizeof(i)); i = 0; @@ -460,7 +524,7 @@ int main(int argc, char **argv) /* server address */ memset((char *) &serv_name, 0x00, sizeof(serv_name)); serv_name.sin_family = AF_INET; - serv_name.sin_addr.s_addr = inet_addr(saddr); + serv_name.sin_addr = HERMIT_IP(isle_nr); serv_name.sin_port = htons(HERMIT_PORT); i = 0; @@ -482,7 +546,12 @@ retry: if (ret < 0) goto out; - // froward program arguments to HermitCore + // forward program arguments to HermitCore + // argv[0] is path of this proxy so we strip it + + argv++; + argc--; + ret = write(s, &argc, sizeof(argc)); if (ret < 0) goto out; diff --git a/hermit/usr/Makefile b/hermit/usr/Makefile index 921b66574..bb125923c 100644 --- a/hermit/usr/Makefile +++ b/hermit/usr/Makefile @@ -10,7 +10,7 @@ NEWLIB = $(TOPDIR)/$(ARCH)/$(TARGET) RM = rm -rf CD = cd CP = cp -MKDIR = mkdir +MKDIR = mkdir -p TMP = $(TOPDIR)/tmp OPT = --disable-shared --disable-multilib --enable-lto --enable-newlib-hw-fp --enable-newlib-io-c99-formats --enable-newlib-multithread #--enable-newlib-reent-small diff --git a/hermit/usr/benchmarks/Makefile b/hermit/usr/benchmarks/Makefile index 44a5113e3..cfb1115bf 100644 --- a/hermit/usr/benchmarks/Makefile +++ b/hermit/usr/benchmarks/Makefile @@ -5,6 +5,10 @@ override STRIP_DEBUG = --strip-debug #--strip-unneeded KEEP_DEBUG = --only-keep-debug OBJCOPY_FLAGS = -j .mboot -j .ktext -j .kdata -j .kbss -j .tbss -j .tdata -j .fini -j .init -j .ctors -j .dtors -j .text -j .data -j .rodata -j .bss -j .percore -j .eh_frame -j .jcr -j .got.plt -j .preinit_array -j .init_array -j .fini_array -j .gcc_except_table -O binary +# We patch the ELF header with a custom OSABI to be recognized by binfmt_misc +ELF_OSABI_OFFSET = 7 +ELF_OSABI = "\\x42" + # Set your own cross compiler tool chain prefix here CROSSCOMPREFIX = x86_64-hermit- @@ -59,6 +63,7 @@ stream: stream.o $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -fopenmp -o $@ $< $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym RCCE_pingping: RCCE_pingping.o @@ -66,6 +71,7 @@ RCCE_pingping: RCCE_pingping.o $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< -lircce $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym RCCE_pingpong: RCCE_pingpong.o @@ -73,6 +79,7 @@ RCCE_pingpong: RCCE_pingpong.o $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< -lircce $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym netio.o: netio.c @@ -84,6 +91,7 @@ netio: netio.o $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym hg: hg.o hist.o rdtsc.o run.o init.o opt.o report.o setup.o @@ -91,6 +99,7 @@ hg: hg.o hist.o rdtsc.o run.o init.o opt.o report.o setup.o $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< hist.o rdtsc.o run.o init.o opt.o report.o setup.o $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym clean: diff --git a/hermit/usr/openmpbench/Makefile b/hermit/usr/openmpbench/Makefile index e88ff3218..fb5959145 100644 --- a/hermit/usr/openmpbench/Makefile +++ b/hermit/usr/openmpbench/Makefile @@ -1,5 +1,9 @@ include Makefile.defs +# We patch the ELF header with a custom OSABI to be recognized by binfmt_misc +ELF_OSABI_OFFSET = 7 +ELF_OSABI = "\\x42" + # If CFLAGS_CRAY is empty set it to CFLAGS ifeq ($(CFLAGS_CRAY),) CFLAGS_CRAY = ${CFLAGS} @@ -23,6 +27,7 @@ prog: arraybench_$(IDA) syncbench: $(SYNCOBJS) $(CC) -o syncbench $(LDFLAGS) $(SYNCOBJS) $(CLOCKOBJS) $(LIBS) -lm + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null # Rule to ensure the lower optimisation level is picked up for common.c # with the Cray compiler @@ -35,7 +40,8 @@ common_sched.o: ${CC} ${CFLAGS_CRAY} $(SCHEDFLAGS) $(OMPFLAG) -o common_sched.o -c common.c schedbench: $(SCHEDOBJS) - $(CC) -o schedbench $(LDFLAGS) $(SCHEDOBJS) $(CLOCKOBJS) $(LIBS) -lm + $(CC) -o schedbench $(LDFLAGS) $(SCHEDOBJS) $(CLOCKOBJS) $(LIBS) -lm + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null # Multiple header files due to multiple array sizes, makes header file arraybench_*.h arraybench_$(IDA).h: arraybench.h @@ -51,6 +57,7 @@ arraybench_$(IDA): $(ARRAYOBJS) $(CLOCKOBJS) arraybench.c taskbench: $(TASKOBJS) $(CC) -o taskbench $(LDFLAGS) $(OMPFLAG) $(TASKOBJS) $(CLOCKOBJS) $(LIBS) -lm + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null clean: -rm -rf *.o syncbench schedbench arraybench_* taskbench diff --git a/hermit/usr/tests/Makefile b/hermit/usr/tests/Makefile index dc806ccb6..9dbffaa63 100644 --- a/hermit/usr/tests/Makefile +++ b/hermit/usr/tests/Makefile @@ -5,6 +5,10 @@ override STRIP_DEBUG = --strip-debug #--strip-unneeded KEEP_DEBUG = --only-keep-debug OBJCOPY_FLAGS = -j .mboot -j .ktext -j .kdata -j .kbss -j .tbss -j .tdata -j .fini -j .init -j .ctors -j .dtors -j .text -j .data -j .rodata -j .bss -j .percore -j .eh_frame -j .jcr -j .got.plt -j .preinit_array -j .init_array -j .fini_array -j .gcc_except_table -O binary +# We patch the ELF header with a custom OSABI to be recognized by binfmt_misc +ELF_OSABI_OFFSET = 7 +ELF_OSABI = "\\x42" + # Set your own cross compiler tool chain prefix here CROSSCOMPREFIX = x86_64-hermit- @@ -55,6 +59,7 @@ hello++: hello++.o $Q$(CXX_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CXXFLAGS_FOR_TARGET) -o $@ $< $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym hello: hello.o @@ -62,6 +67,7 @@ hello: hello.o $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym hellof: hellof.o @@ -69,6 +75,7 @@ hellof: hellof.o $Q$(FC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(FFLAGS_FOR_TARGET) -o $@ $< $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym jacobi: jacobi.o @@ -76,6 +83,7 @@ jacobi: jacobi.o $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< -lm $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym thr_hello.o: thr_hello.c @@ -87,6 +95,7 @@ thr_hello: thr_hello.o $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< -pthread $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym RCCE_minimum: RCCE_minimum.o @@ -94,6 +103,7 @@ RCCE_minimum: RCCE_minimum.o $Q$(CC_FOR_TARGET) $(LDFLAGS_FOR_TARGET) $(CFLAGS_FOR_TARGET) -o $@ $< -lircce $Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym $Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + $Qprintf $(ELF_OSABI) | dd of=$@ bs=1 seek=$(ELF_OSABI_OFFSET) count=1 conv=notrunc 2>/dev/null $Qchmod a-x $@.sym clean: diff --git a/hermit/usr/tests/hello.c b/hermit/usr/tests/hello.c index 8a2b245b6..ff87dfb80 100644 --- a/hermit/usr/tests/hello.c +++ b/hermit/usr/tests/hello.c @@ -39,8 +39,8 @@ int main(int argc, char** argv) FILE* file; printf("Hello World!!!\n"); - for(i=0; environ[i]; i++) - printf("environ[%d] = %s\n", i, environ[i]); + //for(i=0; environ[i]; i++) + // printf("environ[%d] = %s\n", i, environ[i]); for(i=0; i