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

Side by Side Diff: tools/relocation_packer/src/elf_traits.h

Issue 404553003: Create builds configured for ARM and AARCH64. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Purge unused includes. Created 6 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Target-specific ELF type traits.
6
7 #ifndef TOOLS_RELOCATION_PACKER_SRC_ELF_TRAITS_H_
8 #define TOOLS_RELOCATION_PACKER_SRC_ELF_TRAITS_H_
9
10 #include "elf.h"
11 #include "libelf.h"
12
13 // The TARGET_ macro controls which Elf types we expect and handle.
14 // Either TARGET_ARM or TARGET_AARCH must be defined, but not both.
rmcilroy 2014/07/18 14:05:17 TARGET_AARCH64
simonb (inactive) 2014/07/21 12:15:49 Done. Switched to TARGET_ARM and TARGET_ARM64 for
15
16 #if !defined(TARGET_ARM) && !defined(TARGET_AARCH64)
17 #error "Unsupported target, define one of TARGET_ARM or TARGET_AARCH64"
18 #elif defined(TARGET_ARM) && defined(TARGET_AARCH64)
19 #error "Define one of TARGET_ARM or TARGET_AARCH64, but not both"
20 #endif
21
22 // ELF is a traits structure used to provide convenient aliases for
23 // 32/64 bit Elf types and functions, depending on the target specified.
24
25 #if defined(TARGET_ARM)
26 struct ELF {
27 typedef Elf32_Addr Addr;
28 typedef Elf32_Dyn Dyn;
29 typedef Elf32_Ehdr Ehdr;
30 typedef Elf32_Off Off;
31 typedef Elf32_Phdr Phdr;
32 typedef Elf32_Rel Rel;
33 typedef Elf32_Shdr Shdr;
34 typedef Elf32_Sword Sword;
35 typedef Elf32_Sxword Sxword;
36 typedef Elf32_Sym Sym;
37 typedef Elf32_Word Word;
38 typedef Elf32_Xword Xword;
39
40 static inline Ehdr* getehdr(Elf* elf) { return elf32_getehdr(elf); }
41 static inline Phdr* getphdr(Elf* elf) { return elf32_getphdr(elf); }
42 static inline Shdr* getshdr(Elf_Scn* scn) { return elf32_getshdr(scn); }
43
44 enum { kMachine = EM_ARM };
45 enum { kFileClass = ELFCLASS32 };
46 enum { kArmRelativeRelocationCode = R_ARM_RELATIVE };
47 enum { kArmNoRelocationCode = R_ARM_NONE };
rmcilroy 2014/07/18 14:05:17 Remove "Arm" from both of these variable names, ju
simonb (inactive) 2014/07/21 12:15:49 Done.
48
49 static inline const char* Machine() { return "ARM"; }
50
51 #define ELF_R_SYM(val) ELF32_R_SYM(val)
52 #define ELF_R_TYPE(val) ELF32_R_TYPE(val)
53 #define ELF_R_INFO(sym, type) ELF32_R_INFO(sym, type)
54 #define ELF_ST_TYPE(val) ELF32_ST_TYPE(val)
55 };
56 #endif // TARGET_ARM
rmcilroy 2014/07/18 14:05:17 #elif defined(TARGET_AARCH64)
simonb (inactive) 2014/07/21 12:15:49 Done.
57
58 #if defined(TARGET_AARCH64)
59 struct ELF {
60 typedef Elf64_Addr Addr;
61 typedef Elf64_Dyn Dyn;
62 typedef Elf64_Ehdr Ehdr;
63 typedef Elf64_Off Off;
64 typedef Elf64_Phdr Phdr;
65 typedef Elf64_Rel Rel;
66 typedef Elf64_Shdr Shdr;
67 typedef Elf64_Sword Sword;
68 typedef Elf64_Sxword Sxword;
69 typedef Elf64_Sym Sym;
70 typedef Elf64_Word Word;
71 typedef Elf64_Xword Xword;
72
73 static inline Ehdr* getehdr(Elf* elf) { return elf64_getehdr(elf); }
74 static inline Phdr* getphdr(Elf* elf) { return elf64_getphdr(elf); }
75 static inline Shdr* getshdr(Elf_Scn* scn) { return elf64_getshdr(scn); }
76
77 // TODO(simonb): Eliminate these once AARCH64 appears reliably in elf.h.
78 #ifndef EM_AARCH64
79 #define EM_AARCH64 183
80 #endif
81 #ifndef R_AARCH64_RELATIVE
82 #define R_AARCH64_RELATIVE 1027
83 #endif
84 #ifndef R_AARCH64_NONE
85 #define R_AARCH64_NONE 0
86 #endif
87
88 enum { kMachine = EM_AARCH64 };
89 enum { kFileClass = ELFCLASS64 };
90 enum { kArmRelativeRelocationCode = R_AARCH64_RELATIVE };
91 enum { kArmNoRelocationCode = R_AARCH64_NONE };
92
93 static inline const char* Machine() { return "AARCH64"; }
94
95 #define ELF_R_SYM(val) ELF64_R_SYM(val)
96 #define ELF_R_TYPE(val) ELF64_R_TYPE(val)
97 #define ELF_R_INFO(sym, type) ELF64_R_INFO(sym, type)
98 #define ELF_ST_TYPE(val) ELF64_ST_TYPE(val)
99 };
100 #endif // TARGET_AARCH64
101
102 #endif // TOOLS_RELOCATION_PACKER_SRC_ELF_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698