ldrELF.cpp revision c58f1213e628a545081c70e26c6b67a841cff880
/* $Id$ */
/** @file
* IPRT - Binary Image Loader, Executable and Linker Format (ELF).
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP RTLOGGROUP_LDR
#include "internal/ldrELF32.h"
#include "internal/ldrELF64.h"
#include "internal/ldrELFi386.h"
#include "internal/ldrELFAmd64.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** Finds an ELF string. */
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
#ifdef LOG_ENABLED
#endif
/* Select ELF mode and include the template. */
#define ELF_MODE 32
#include "ldrELFRelocatable.cpp.h"
#define ELF_MODE 64
#include "ldrELFRelocatable.cpp.h"
#ifdef LOG_ENABLED
/**
* Gets the section type.
*
* @returns Pointer to read only string.
* @param iType The section type index.
*/
{
switch (iType)
{
case SHT_NULL: return "SHT_NULL";
case SHT_PROGBITS: return "SHT_PROGBITS";
case SHT_SYMTAB: return "SHT_SYMTAB";
case SHT_STRTAB: return "SHT_STRTAB";
case SHT_RELA: return "SHT_RELA";
case SHT_HASH: return "SHT_HASH";
case SHT_DYNAMIC: return "SHT_DYNAMIC";
case SHT_NOTE: return "SHT_NOTE";
case SHT_NOBITS: return "SHT_NOBITS";
case SHT_REL: return "SHT_REL";
case SHT_SHLIB: return "SHT_SHLIB";
case SHT_DYNSYM: return "SHT_DYNSYM";
default:
return "";
}
}
#endif
/**
* Open an ELF image.
*
* @returns iprt status code.
* @param pReader The loader reader instance which will provide the raw image bits.
* @param fFlags Reserved, MBZ.
* @param enmArch Architecture specifier.
* @param phLdrMod Where to store the handle.
*/
{
/*
* Read the ident to decide if this is 32-bit or 64-bit
* and worth dealing with.
*/
if (RT_FAILURE(rc))
return rc;
)
{
return VERR_BAD_EXE_FORMAT;
}
{
return VERR_LDRELF_ODD_ENDIAN;
}
else
return rc;
}