1/****************************************************************************** 2 * Copyright (c) 2004, 2011 IBM Corporation 3 * All rights reserved. 4 * This program and the accompanying materials 5 * are made available under the terms of the BSD License 6 * which accompanies this distribution, and is available at 7 * http://www.opensource.org/licenses/bsd-license.php 8 * 9 * Contributors: 10 * IBM Corporation - initial implementation 11 *****************************************************************************/ 12 13/* 14 * libelf Forth wrapper 15 */ 16 17#include <libelf.h> 18 19// : elf-load-file ( fileaddr -- entry type ) 20PRIM(ELF_X2d_LOAD_X2d_FILE) 21{ 22 void *file_addr = TOS.a; 23 int type; 24 unsigned long entry; 25 type = elf_load_file(file_addr, &entry, elf_forth_claim, flush_cache); 26 TOS.u = entry; 27 PUSH; TOS.n = type; 28} 29MIRP 30 31// : elf-load-file-to-addr ( fileaddr destaddr -- entry type ) 32PRIM(ELF_X2d_LOAD_X2d_FILE_X2d_TO_X2d_ADDR) 33{ 34 void *dest_addr = TOS.a; POP; 35 void *file_addr = TOS.a; 36 int type; 37 unsigned long entry; 38 type = elf_load_file_to_addr(file_addr, dest_addr, &entry, 39 elf_forth_claim, flush_cache); 40 TOS.u = entry; 41 PUSH; TOS.n = type; 42} 43MIRP 44