summaryrefslogtreecommitdiffstats
path: root/tools/creative.c
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-26 19:38:52 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-26 19:38:52 +0000
commit0f047836bb6113bf2bd021522b7b6c4bd87a5e24 (patch)
tree0ee01cd571b830473a2499d47eb7635bbe0ea01e /tools/creative.c
parentbea2ab2398ca116a5cb3c62901769a1031b7d359 (diff)
downloadrockbox-0f047836bb6113bf2bd021522b7b6c4bd87a5e24.tar.gz
rockbox-0f047836bb6113bf2bd021522b7b6c4bd87a5e24.tar.bz2
rockbox-0f047836bb6113bf2bd021522b7b6c4bd87a5e24.zip
Fix compiling on *BSD targets (and probably others too)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18346 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/creative.c')
-rw-r--r--tools/creative.c103
1 files changed, 97 insertions, 6 deletions
diff --git a/tools/creative.c b/tools/creative.c
index 1698f58930..5c4a236a52 100644
--- a/tools/creative.c
+++ b/tools/creative.c
@@ -23,14 +23,105 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
-#if !defined(__APPLE__)
-#include <elf.h>
-#else
-#include "mac-elf.h" /* Mac OS X doesn't distribuate elf.h... */
-#endif
-
#include "creative.h"
#include "hmac-sha1.h"
+/*
+ ---------------------------------------------------------------------------
+ Shamelessly taken from elf.h (for compatibility reasons included)
+ ---------------------------------------------------------------------------
+
+ This file defines standard ELF types, structures, and macros.
+ Copyright (C) 1995-2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+*/
+
+#include <stdint.h>
+
+/* Type for a 16-bit quantity. */
+typedef uint16_t Elf32_Half;
+
+/* Types for signed and unsigned 32-bit quantities. */
+typedef uint32_t Elf32_Word;
+typedef int32_t Elf32_Sword;
+
+/* Types for signed and unsigned 64-bit quantities. */
+typedef uint64_t Elf32_Xword;
+typedef int64_t Elf32_Sxword;
+
+/* Type of addresses. */
+typedef uint32_t Elf32_Addr;
+
+/* Type of file offsets. */
+typedef uint32_t Elf32_Off;
+
+/* Type for section indices, which are 16-bit quantities. */
+typedef uint16_t Elf32_Section;
+
+#define EI_NIDENT (16)
+
+typedef struct
+{
+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
+ Elf32_Half e_type; /* Object file type */
+ Elf32_Half e_machine; /* Architecture */
+ Elf32_Word e_version; /* Object file version */
+ Elf32_Addr e_entry; /* Entry point virtual address */
+ Elf32_Off e_phoff; /* Program header table file offset */
+ Elf32_Off e_shoff; /* Section header table file offset */
+ Elf32_Word e_flags; /* Processor-specific flags */
+ Elf32_Half e_ehsize; /* ELF header size in bytes */
+ Elf32_Half e_phentsize; /* Program header table entry size */
+ Elf32_Half e_phnum; /* Program header table entry count */
+ Elf32_Half e_shentsize; /* Section header table entry size */
+ Elf32_Half e_shnum; /* Section header table entry count */
+ Elf32_Half e_shstrndx; /* Section header string table index */
+} Elf32_Ehdr;
+
+typedef struct
+{
+ Elf32_Word sh_name; /* Section name (string tbl index) */
+ Elf32_Word sh_type; /* Section type */
+ Elf32_Word sh_flags; /* Section flags */
+ Elf32_Addr sh_addr; /* Section virtual addr at execution */
+ Elf32_Off sh_offset; /* Section file offset */
+ Elf32_Word sh_size; /* Section size in bytes */
+ Elf32_Word sh_link; /* Link to another section */
+ Elf32_Word sh_info; /* Additional section information */
+ Elf32_Word sh_addralign; /* Section alignment */
+ Elf32_Word sh_entsize; /* Entry size if section holds table */
+} Elf32_Shdr;
+
+#define ELFMAG0 0x7f /* Magic number byte 0 */
+#define ELFMAG1 'E' /* Magic number byte 1 */
+#define ELFMAG2 'L' /* Magic number byte 2 */
+#define ELFMAG3 'F' /* Magic number byte 3 */
+
+#define SHF_WRITE (1 << 0) /* Writable */
+#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
+#define SHF_EXECINSTR (1 << 2) /* Executable */
+
+#define SHT_NOBITS 8 /* Program space with no data (bss) */
+
+/*
+ ---------------------------------------------------------------------------
+ End of elf.h
+ ---------------------------------------------------------------------------
+*/
static const char null_key_v1[] = "CTL:N0MAD|PDE0.SIGN.";
static const char null_key_v2[] = "CTL:N0MAD|PDE0.DPMP.";