170658Sobrien/*- 270658Sobrien * Copyright (c) 2006,2008 Joseph Koshy 385595Sobrien * All rights reserved. 485595Sobrien * 570658Sobrien * Redistribution and use in source and binary forms, with or without 670658Sobrien * modification, are permitted provided that the following conditions 7200038Skib * are met: 8204757Suqs * 1. Redistributions of source code must retain the above copyright 9234596Sdim * notice, this list of conditions and the following disclaimer. 1070658Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1196516Sru * notice, this list of conditions and the following disclaimer in the 1270658Sobrien * documentation and/or other materials provided with the distribution. 1396530Sru * 14217375Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1596530Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16217375Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17217375Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1870658Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19217375Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20217375Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21232832Skib * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22200038Skib * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23217375Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24234502Sdim * SUCH DAMAGE. 25217375Sdim */ 26217375Sdim 27217375Sdim#include <libelf.h> 28232832Skib 29217375Sdim#include "_libelf.h" 30217375Sdim 31234502SdimELFTC_VCSID("$Id: elf_memory.c,v 1.1 2019/02/01 05:27:37 jsg Exp $"); 32217375Sdim 33217375SdimElf * 34217375Sdimelf_memory(char *image, size_t sz) 35232832Skib{ 36217375Sdim if (LIBELF_PRIVATE(version) == EV_NONE) { 37217375Sdim LIBELF_SET_ERROR(SEQUENCE, 0); 38234502Sdim return (NULL); 39217375Sdim } 4070658Sobrien 41100872Sru if (image == NULL || sz == 0) { 4296516Sru LIBELF_SET_ERROR(ARGUMENT, 0); 4370658Sobrien return (NULL); 4470658Sobrien } 45 46 return (_libelf_memory((unsigned char *) image, sz, 1)); 47} 48