elf_rawfile.c revision 4484
11689SN/A/*- 213590Srekai.gonzalezalberquilla@arm.com * Copyright (c) 2006 Joseph Koshy 310239Sbinhpham@cs.rutgers.edu * All rights reserved. 47598Sminkyu.jeong@arm.com * 57598Sminkyu.jeong@arm.com * Redistribution and use in source and binary forms, with or without 67598Sminkyu.jeong@arm.com * modification, are permitted provided that the following conditions 77598Sminkyu.jeong@arm.com * are met: 87598Sminkyu.jeong@arm.com * 1. Redistributions of source code must retain the above copyright 97598Sminkyu.jeong@arm.com * notice, this list of conditions and the following disclaimer. 107598Sminkyu.jeong@arm.com * 2. Redistributions in binary form must reproduce the above copyright 117598Sminkyu.jeong@arm.com * notice, this list of conditions and the following disclaimer in the 127598Sminkyu.jeong@arm.com * documentation and/or other materials provided with the distribution. 137598Sminkyu.jeong@arm.com * 147598Sminkyu.jeong@arm.com * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 152326SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 161689SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 171689SN/A * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 181689SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 191689SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 201689SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 211689SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 221689SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 231689SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 241689SN/A * SUCH DAMAGE. 251689SN/A */ 261689SN/A 271689SN/A 281689SN/A#include "libelf.h" 291689SN/A 301689SN/A#include "_libelf.h" 311689SN/A 321689SN/Achar * 331689SN/Aelf_rawfile(Elf *e, size_t *sz) 341689SN/A{ 351689SN/A char *ptr; 361689SN/A size_t size; 371689SN/A 381689SN/A size = e ? e->e_rawsize : 0; 391689SN/A ptr = NULL; 402665Ssaidi@eecs.umich.edu 412665Ssaidi@eecs.umich.edu if (e == NULL) 421689SN/A LIBELF_SET_ERROR(ARGUMENT, 0); 431689SN/A else if ((ptr = e->e_rawfile) == NULL && e->e_cmd == ELF_C_WRITE) 449944Smatt.horsnell@ARM.com LIBELF_SET_ERROR(SEQUENCE, 0); 459944Smatt.horsnell@ARM.com 469944Smatt.horsnell@ARM.com if (sz) 471060SN/A *sz = size; 481060SN/A 491689SN/A return (ptr); 501060SN/A} 511060SN/A