Haiku: Enable CMake builtin ELF editor

Co-Author: Brad King <brad.king@kitware.com>
This commit is contained in:
Adrien Destugues 2014-03-03 15:47:08 +01:00 committed by Brad King
parent 0f79dab48b
commit 84603d804c
2 changed files with 38 additions and 0 deletions

View File

@ -18,6 +18,23 @@ else()
endif()
if(HAVE_ELF_H)
set(CMAKE_USE_ELF_PARSER 1)
elseif(HAIKU)
# On Haiku, we need to include elf32.h from the private headers
set(CMake_HAIKU_INCLUDE_DIRS
/boot/system/develop/headers/private/system
/boot/system/develop/headers/private/system/arch/x86
)
set(CMAKE_REQUIRED_INCLUDES ${CMake_HAIKU_INCLUDE_DIRS})
CHECK_INCLUDE_FILE("elf32.h" HAVE_ELF32_H)
unset(CMAKE_REQUIRED_INCLUDES)
if(HAVE_ELF32_H)
set(CMAKE_USE_ELF_PARSER 1)
else()
unset(CMake_HAIKU_INCLUDE_DIRS)
set(CMAKE_USE_ELF_PARSER)
endif()
else()
set(CMAKE_USE_ELF_PARSER)
endif()
@ -57,6 +74,7 @@ include_directories(
${CMAKE_EXPAT_INCLUDES}
${CMAKE_TAR_INCLUDES}
${CMAKE_COMPRESS_INCLUDES}
${CMake_HAIKU_INCLUDE_DIRS}
)
# let cmake know it is supposed to use it

View File

@ -23,6 +23,26 @@
#if defined(__OpenBSD__)
# include <stdint.h>
# include <elf_abi.h>
#elif defined(__HAIKU__)
# include <elf32.h>
# include <elf64.h>
typedef struct Elf32_Ehdr Elf32_Ehdr;
typedef struct Elf32_Shdr Elf32_Shdr;
typedef struct Elf32_Sym Elf32_Sym;
typedef struct Elf32_Rel Elf32_Rel;
typedef struct Elf32_Rela Elf32_Rela;
# define ELFMAG0 0x7F
# define ELFMAG1 'E'
# define ELFMAG2 'L'
# define ELFMAG3 'F'
# define ET_NONE 0
# define ET_REL 1
# define ET_EXEC 2
# define ET_DYN 3
# define ET_CORE 4
# define EM_386 3
# define EM_SPARC 2
# define EM_PPC 20
#else
# include <elf.h>
#endif