Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Unified Diff: third_party/android_crazy_linker/src/src/elf_traits.h

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/android_crazy_linker/src/src/elf_traits.h
diff --git a/third_party/android_crazy_linker/src/src/elf_traits.h b/third_party/android_crazy_linker/src/src/elf_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..6c6e552a6acc8e30271599882755fd736c73d57e
--- /dev/null
+++ b/third_party/android_crazy_linker/src/src/elf_traits.h
@@ -0,0 +1,96 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef _ELF_TRAITS_H_
+#define _ELF_TRAITS_H_
+
+// NOTE: <stdint.h> is required here before <elf.h>. This is a NDK header bug.
+#include <stdint.h>
+#include <elf.h>
+
+// ELF is a traits structure used to provide convenient aliases for
+// 32/64 bit Elf types, depending on the target CPU bitness.
+#if __SIZEOF_POINTER__ == 4
+struct ELF {
+ typedef Elf32_Ehdr Ehdr;
+ typedef Elf32_Phdr Phdr;
+ typedef Elf32_Word Word;
+ typedef Elf32_Sword Sword;
+ // TODO(simonb): Elf32_Sxword missing from the NDK.
+ typedef int64_t Sxword;
+ typedef Elf32_Addr Addr;
+ typedef Elf32_Dyn Dyn;
+ typedef Elf32_Sym Sym;
+ typedef Elf32_Rel Rel;
+ typedef Elf32_Rela Rela;
+ typedef Elf32_auxv_t auxv_t;
+
+ enum { kElfClass = ELFCLASS32 };
+ enum { kElfBits = 32 };
+
+# ifndef ELF_R_TYPE
+# define ELF_R_TYPE ELF32_R_TYPE
+# endif
+
+# ifndef ELF_R_SYM
+# define ELF_R_SYM ELF32_R_SYM
+# endif
+
+# ifndef ELF_R_INFO
+# define ELF_R_INFO ELF32_R_INFO
+# endif
+};
+#elif __SIZEOF_POINTER__ == 8
+struct ELF {
+ typedef Elf64_Ehdr Ehdr;
+ typedef Elf64_Phdr Phdr;
+ typedef Elf64_Word Word;
+ typedef Elf64_Sword Sword;
+ typedef Elf64_Sxword Sxword;
+ typedef Elf64_Addr Addr;
+ typedef Elf64_Dyn Dyn;
+ typedef Elf64_Sym Sym;
+ typedef Elf64_Rel Rel;
+ typedef Elf64_Rela Rela;
+ typedef Elf64_auxv_t auxv_t;
+
+ enum { kElfClass = ELFCLASS64 };
+ enum { kElfBits = 64 };
+
+# ifndef ELF_R_TYPE
+# define ELF_R_TYPE ELF64_R_TYPE
+# endif
+
+# ifndef ELF_R_SYM
+# define ELF_R_SYM ELF64_R_SYM
+# endif
+
+// TODO(simonb): ELF64_R_INFO missing from the NDK.
+# ifndef ELF64_R_INFO
+# define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
+# endif
+
+# ifndef ELF_R_INFO
+# define ELF_R_INFO ELF64_R_INFO
+# endif
+};
+#else
+#error "Unsupported target CPU bitness"
+#endif
+
+#ifdef __arm__
+#define ELF_MACHINE EM_ARM
+#elif defined(__i386__)
+#define ELF_MACHINE EM_386
+#elif defined(__x86_64__)
+#define ELF_MACHINE EM_X86_64
+#elif defined(__mips__) && !defined(__LP64__) // mips64el defines __mips__ too
+#define ELF_MACHINE EM_MIPS
+#elif defined(__aarch64__)
+#define ELF_MACHINE EM_AARCH64
+#else
+#error "Unsupported target CPU architecture"
+#endif
+
+#endif // _ELF_TRAITS_H_
« no previous file with comments | « third_party/android_crazy_linker/src/src/crazy_linker_zip.cpp ('k') | third_party/android_crazy_linker/src/src/linker_phdr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698