|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "elf_section_header.h" |
|
17 |
|
18 |
|
19 namespace elf |
|
20 { |
|
21 Section_header::Section_header(const char* p1, const char* p2) |
|
22 : m_data( reinterpret_cast<const Elf32_Shdr*>(p1) ) |
|
23 { |
|
24 // This could be useful for future error checking. |
|
25 (void) p2; |
|
26 |
|
27 //--if (m_data->sh_type != SHT_NOBITS) |
|
28 //--{ |
|
29 //-- if (m_data->sh_offset + m_data->sh_size > a_mem.get_size() ) |
|
30 //-- { |
|
31 //-- throw std::runtime_error("file is too small"); |
|
32 //-- } |
|
33 //--} |
|
34 |
|
35 //--if (m_data->sh_addralign > 1) |
|
36 //--{ |
|
37 //-- if (m_data->sh_addr % m_data->sh_addralign != 0) |
|
38 //-- { |
|
39 //-- throw std::runtime_error("incorrect alignment"); |
|
40 //-- } |
|
41 //--} |
|
42 } |
|
43 |
|
44 uint32_t Section_header::get_name() |
|
45 { |
|
46 return m_data->sh_name; |
|
47 } |
|
48 |
|
49 bool Section_header::is_type_null() const |
|
50 { |
|
51 return (m_data->sh_type == SHT_NULL); |
|
52 } |
|
53 |
|
54 bool Section_header::is_type_progbits() const |
|
55 { |
|
56 return (m_data->sh_type == SHT_PROGBITS); |
|
57 } |
|
58 |
|
59 bool Section_header::is_type_symtab() const |
|
60 { |
|
61 return (m_data->sh_type == SHT_SYMTAB); |
|
62 } |
|
63 |
|
64 bool Section_header::is_type_dynsym() const |
|
65 { |
|
66 return (m_data->sh_type == SHT_DYNSYM); |
|
67 } |
|
68 |
|
69 bool Section_header::is_type_strtab() const |
|
70 { |
|
71 return (m_data->sh_type == SHT_STRTAB); |
|
72 } |
|
73 |
|
74 bool Section_header::is_type_rela() const |
|
75 { |
|
76 return (m_data->sh_type == SHT_RELA); |
|
77 } |
|
78 |
|
79 bool Section_header::is_type_nobits() const |
|
80 { |
|
81 return (m_data->sh_type == SHT_NOBITS); |
|
82 } |
|
83 |
|
84 bool Section_header::is_type_rel() const |
|
85 { |
|
86 return (m_data->sh_type == SHT_REL); |
|
87 } |
|
88 |
|
89 bool Section_header::is_flags_write() const |
|
90 { |
|
91 return (m_data->sh_flags & SHF_WRITE) != 0; |
|
92 } |
|
93 bool Section_header::is_flags_alloc() const |
|
94 { |
|
95 return (m_data->sh_flags & SHF_ALLOC) != 0; |
|
96 } |
|
97 bool Section_header::is_flags_execinstr() const |
|
98 { |
|
99 return (m_data->sh_flags & SHF_EXECINSTR) != 0; |
|
100 } |
|
101 |
|
102 uint32_t Section_header::get_addr() |
|
103 { |
|
104 return m_data->sh_addr; |
|
105 } |
|
106 |
|
107 uint32_t Section_header::get_offset() const |
|
108 { |
|
109 return m_data->sh_offset; |
|
110 } |
|
111 |
|
112 uint32_t Section_header::get_size() const |
|
113 { |
|
114 return m_data->sh_size; |
|
115 } |
|
116 |
|
117 uint32_t Section_header::get_link() |
|
118 { |
|
119 return m_data->sh_link; |
|
120 } |
|
121 |
|
122 uint32_t Section_header::get_info() |
|
123 { |
|
124 return m_data->sh_info; |
|
125 } |
|
126 |
|
127 uint32_t Section_header::get_addralign() |
|
128 { |
|
129 return m_data->sh_addralign; |
|
130 } |
|
131 |
|
132 uint32_t Section_header::get_entsize() const |
|
133 { |
|
134 return m_data->sh_entsize; |
|
135 } |
|
136 |
|
137 } // namespace elf |
|
138 |