1 /*
2 * Copyright 2011, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef ELF_HEADER_HXX
18 #define ELF_HEADER_HXX
19
20 #include "utils/raw_ostream.h"
21
22 #include <llvm/Support/raw_ostream.h>
23 #include <llvm/Support/Format.h>
24
25 template <unsigned Bitwidth>
print()26 void ELFHeader<Bitwidth>::print() {
27 using namespace llvm;
28
29 out() << fillformat('=', 79) << '\n';
30 out().changeColor(raw_ostream::WHITE, true);
31 out() << "ELF Header\n";
32 out().resetColor();
33 out() << fillformat('-', 79) << '\n';
34
35 #define PRINT_LINT(title, value) \
36 out() << format(" %-32s : ", (char const *)(title)) << (value) << '\n'
37 PRINT_LINT("Class", getClassStr(getClass()));
38 PRINT_LINT("Endianness", getEndiannessStr(getEndianness()));
39 PRINT_LINT("Header Version", (unsigned)getVersion());
40 PRINT_LINT("OS ABI", getOSABIStr(getOSABI()));
41 PRINT_LINT("ABI Version", (unsigned)getABIVersion());
42 PRINT_LINT("Object Type", getObjectTypeStr(getObjectType()));
43 PRINT_LINT("Machine", getMachineStr(getMachine()));
44 PRINT_LINT("Version", getVersionStr(getVersion()));
45 PRINT_LINT("Entry Address", getEntryAddress());
46 PRINT_LINT("Program Header Offset", getProgramHeaderTableOffset());
47 PRINT_LINT("Section Header Offset", getSectionHeaderTableOffset());
48 PRINT_LINT("Flags", getFlags());
49 PRINT_LINT("ELF Header Size", getELFHeaderSize());
50 PRINT_LINT("Program Header Size", getProgramHeaderEntrySize());
51 PRINT_LINT("Program Header Num", getProgramHeaderNum());
52 PRINT_LINT("Section Header Size", getSectionHeaderEntrySize());
53 PRINT_LINT("Section Header Num", getSectionHeaderNum());
54 PRINT_LINT("String Section Index", getStringSectionIndex());
55 #undef PRINT_LINT
56
57 out() << fillformat('=', 79) << "\n\n";
58 }
59
60 #endif // ELF_HEADER_HXX
61