-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
347 lines (319 loc) · 21.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Libelf.js</title>
<!-- External stylesheets -->
<link rel='stylesheet' type='text/css' href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
<link rel='stylesheet' type='text/css' href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css"/>
<link rel='stylesheet' type='text/css' href="//cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css"/>
<!-- External fonts -->
<link rel='stylesheet' type='text/css' href='//fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600'>
<link rel='stylesheet' type='text/css' href='//fonts.googleapis.com/css?family=Inconsolata:400,700'>
<!-- Style -->
<style>
body {
font-family: 'Open Sans', sans-serif;
padding-top: 50px;
padding-bottom: 20px;
}
.jumbotron {
background-color: #eeeaf4;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 304 304' width='304' height='304'%3E%3Cpath fill='%23d0c7df' fill-opacity='0.4' d='M44.1 224a5 5 0 1 1 0 2H0v-2h44.1zm160 48a5 5 0 1 1 0 2H82v-2h122.1zm57.8-46a5 5 0 1 1 0-2H304v2h-42.1zm0 16a5 5 0 1 1 0-2H304v2h-42.1zm6.2-114a5 5 0 1 1 0 2h-86.2a5 5 0 1 1 0-2h86.2zm-256-48a5 5 0 1 1 0 2H0v-2h12.1zm185.8 34a5 5 0 1 1 0-2h86.2a5 5 0 1 1 0 2h-86.2zM258 12.1a5 5 0 1 1-2 0V0h2v12.1zm-64 208a5 5 0 1 1-2 0v-54.2a5 5 0 1 1 2 0v54.2zm48-198.2V80h62v2h-64V21.9a5 5 0 1 1 2 0zm16 16V64h46v2h-48V37.9a5 5 0 1 1 2 0zm-128 96V208h16v12.1a5 5 0 1 1-2 0V210h-16v-76.1a5 5 0 1 1 2 0zm-5.9-21.9a5 5 0 1 1 0 2H114v48H85.9a5 5 0 1 1 0-2H112v-48h12.1zm-6.2 130a5 5 0 1 1 0-2H176v-74.1a5 5 0 1 1 2 0V242h-60.1zm-16-64a5 5 0 1 1 0-2H114v48h10.1a5 5 0 1 1 0 2H112v-48h-10.1zM66 284.1a5 5 0 1 1-2 0V274H50v30h-2v-32h18v12.1zM236.1 176a5 5 0 1 1 0 2H226v94h48v32h-2v-30h-48v-98h12.1zm25.8-30a5 5 0 1 1 0-2H274v44.1a5 5 0 1 1-2 0V146h-10.1zm-64 96a5 5 0 1 1 0-2H208v-80h16v-14h-42.1a5 5 0 1 1 0-2H226v18h-16v80h-12.1zm86.2-210a5 5 0 1 1 0 2H272V0h2v32h10.1zM98 101.9V146H53.9a5 5 0 1 1 0-2H96v-42.1a5 5 0 1 1 2 0zM53.9 34a5 5 0 1 1 0-2H80V0h2v34H53.9zm60.1 3.9V66H82v64H69.9a5 5 0 1 1 0-2H80V64h32V37.9a5 5 0 1 1 2 0zM101.9 82a5 5 0 1 1 0-2H128V37.9a5 5 0 1 1 2 0V82h-28.1zm16-64a5 5 0 1 1 0-2H146v44.1a5 5 0 1 1-2 0V18h-26.1zm102.2 270a5 5 0 1 1 0 2H98v14h-2v-16h124.1zM242 149.9V160h16v34h-16v62h48v48h-2v-46h-48v-66h16v-30h-16v-12.1a5 5 0 1 1 2 0zM53.9 18a5 5 0 1 1 0-2H64V2H48V0h18v18H53.9zm112 32a5 5 0 1 1 0-2H192V0h50v2h-48v48h-28.1zm-48-48a5 5 0 0 1-9.8-2h2.07a3 3 0 1 0 5.66 0H178v34h-18V21.9a5 5 0 1 1 2 0V32h14V2h-58.1zm0 96a5 5 0 1 1 0-2H137l32-32h39V21.9a5 5 0 1 1 2 0V66h-40.17l-32 32H117.9zm28.1 90.1a5 5 0 1 1-2 0v-76.51L175.59 80H224V21.9a5 5 0 1 1 2 0V82h-49.59L146 112.41v75.69zm16 32a5 5 0 1 1-2 0v-99.51L184.59 96H300.1a5 5 0 0 1 3.9-3.9v2.07a3 3 0 0 0 0 5.66v2.07a5 5 0 0 1-3.9-3.9H185.41L162 121.41v98.69zm-144-64a5 5 0 1 1-2 0v-3.51l48-48V48h32V0h2v50H66v55.41l-48 48v2.69zM50 53.9v43.51l-48 48V208h26.1a5 5 0 1 1 0 2H0v-65.41l48-48V53.9a5 5 0 1 1 2 0zm-16 16V89.41l-34 34v-2.82l32-32V69.9a5 5 0 1 1 2 0zM12.1 32a5 5 0 1 1 0 2H9.41L0 43.41V40.6L8.59 32h3.51zm265.8 18a5 5 0 1 1 0-2h18.69l7.41-7.41v2.82L297.41 50H277.9zm-16 160a5 5 0 1 1 0-2H288v-71.41l16-16v2.82l-14 14V210h-28.1zm-208 32a5 5 0 1 1 0-2H64v-22.59L40.59 194H21.9a5 5 0 1 1 0-2H41.41L66 216.59V242H53.9zm150.2 14a5 5 0 1 1 0 2H96v-56.6L56.6 162H37.9a5 5 0 1 1 0-2h19.5L98 200.6V256h106.1zm-150.2 2a5 5 0 1 1 0-2H80v-46.59L48.59 178H21.9a5 5 0 1 1 0-2H49.41L82 208.59V258H53.9zM34 39.8v1.61L9.41 66H0v-2h8.59L32 40.59V0h2v39.8zM2 300.1a5 5 0 0 1 3.9 3.9H3.83A3 3 0 0 0 0 302.17V256h18v48h-2v-46H2v42.1zM34 241v63h-2v-62H0v-2h34v1zM17 18H0v-2h16V0h2v18h-1zm273-2h14v2h-16V0h2v16zm-32 273v15h-2v-14h-14v14h-2v-16h18v1zM0 92.1A5.02 5.02 0 0 1 6 97a5 5 0 0 1-6 4.9v-2.07a3 3 0 1 0 0-5.66V92.1zM80 272h2v32h-2v-32zm37.9 32h-2.07a3 3 0 0 0-5.66 0h-2.07a5 5 0 0 1 9.8 0zM5.9 0A5.02 5.02 0 0 1 0 5.9V3.83A3 3 0 0 0 3.83 0H5.9zm294.2 0h2.07A3 3 0 0 0 304 3.83V5.9a5 5 0 0 1-3.9-5.9zm3.9 300.1v2.07a3 3 0 0 0-1.83 1.83h-2.07a5 5 0 0 1 3.9-3.9zM97 100a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-48 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 48a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 96a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-144a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-96 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm96 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-32 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM49 36a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-32 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM33 68a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-48a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 240a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm80-176a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 48a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm112 176a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM17 180a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM17 84a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6z'%3E%3C/path%3E%3C/svg%3E");
margin-bottom: 0px;
color: #444;
}
.monospaced {
font-family: 'Inconsolata';
font-size: 14px;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://alexaltea.github.io/libelf.js/">Libelf.js</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="/~https://github.com/AlexAltea/libelf.js/releases/">Download</a></li>
<li><a href="/~https://github.com/AlexAltea/libelf.js">Github</a></li>
</ul>
</div>
</div>
</nav>
<div class="jumbotron">
<div class="container">
<h1>Libelf.js</h1>
<p>Access ELF objects with libelf, using JavaScript.</p>
<p>
<a class="btn btn-default btn-lg" href="/~https://github.com/AlexAltea/libelf.js/releases/" role="button">Download »</a>
<a class="btn btn-default btn-lg" href="/~https://github.com/AlexAltea/libelf.js" role="button">Github »</a>
<a class="btn btn-default btn-lg" href="http://www.mr511.de/software/english.html" role="button">Libelf »</a>
</p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-6">
<h2>Information</h2>
<p><b>Libelf.js</b> is a port of the <a href="http://www.mr511.de/software/english.html">libelf</a> library for JavaScript, done with <a href="/~https://github.com/kripken/emscripten">Emscripten</a>. It's released as a 500 KB JavaScript file. Follow the <a href="/~https://github.com/AlexAltea/libelf.js/blob/master/README.md">Readme</a> to build Libelf.js manually.</p>
<p>Libelf is a lightweight library originally developed by <a href="http://www.mr511.de/" target="_blank">http://www.mr511.de/</a> and released under LGPLv2.</p>
<h2>Installation</h2>
<p>To use the Libelf.js in your web application, download and include it with:</p>
<p><pre><code><script src="libelf.min.js"></script></code></pre></p>
<p>or install it through the Bower command:</p>
<p><pre><code>bower install libelf</code></pre></p>
<h2>Tutorial</h2>
<p>Please refer to the original libelf documentation for usage information as libelf.js offers the same interface in an object-oriented style.</p>
<p>
<pre><code class="javascript">// var buffer = new Uint8Array([0x7F, 0x45, 0x4C, 0x46, ...]);
var elf = new Elf(buffer);
if (elf.kind() != "elf") {
throw "Not an ELF file";
}
var ehdr = elf.getehdr();
// Handle segments
for (var i = 0; i < ehdr.phnum; i++) {
var phdr = elf.getphdr(i);
}
// Handle sections
for (var i = 0; i < ehdr.shnum; i++) {
var scn = elf.getscn(i);
var shdr = elf.getshdr(scn);
var name = elf.strptr(
ehdr.e_shstrndx.num(),
shdr.sh_name.num());
}</code></pre>
</p>
</div>
<div class="col-md-6">
<h2>Demo</h2>
<p>Demos are worth a thousand words: simply load any ELF file to see Libelf.js in action. Everything will be processed locally.</p>
<p>
<button type="button" id="fileSelectButton" class="btn btn-default btn-lg" onclick="uploadFile()">
<span class="glyphicon glyphicon-upload" aria-hidden="true"></span>
Upload...
</button>
<div style="height:0px; overflow:hidden">
<input type="file" id="fileSelectInput" />
</div>
</p>
<div id="demo">
<div id="elftree" class="monospaced">
</div>
</div>
</div>
</div>
<hr />
<footer class="container">
<p style="color: #666; font-weight: 300">© Libelf.JS 2018. Wrapper made by Alexandro Sánchez Bach.</p>
<p style="color: #666; font-weight: 300">
Libelf.JS uses the libelf library, originally developed by <a href="http://www.mr511.de/" target="_blank">http://www.mr511.de/</a>.<br/>
Check the repository for license details.
</p>
</footer>
</div>
<!-- External scripts -->
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/languages/javascript.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
<!-- LibelfJS -->
<script src="dist/libelf.min.js"></script>
<script>
// Highlight.JS
hljs.initHighlightingOnLoad();
// JSTree
function formatTreeEntry(name, data, extra) {
const paddingName = 16;
const paddingData = 20;
var result = "";
result += `<i>${name}</i>:` + ' '.repeat(paddingName - name.toString().length);
result += `<b>${data}</b> ` + ' '.repeat(paddingData - data.toString().length);
if (extra != null)
result += `<span style="color:#888">= ${extra}</span>`;
return result;
}
function formatTreeNode(name, length) {
var result = "";
result += `<b>${name}</b> `;
if (length != null)
result += `<i>[${length}]</i>`;
return result;
}
$('#elftree').jstree({
'core': {
'themes': {
'icons': false
},
'data': [{
'text': formatTreeNode('ELF'),
'state' : { 'opened' : true },
'children': [{
'text': formatTreeNode('Header'),
'state' : { 'opened' : true },
'children': [
{ 'text': formatTreeEntry('e_type', '???') },
{ 'text': formatTreeEntry('e_machine', '???') },
{ 'text': formatTreeEntry('e_version', '???') },
{ 'text': formatTreeEntry('e_entry', '???') },
{ 'text': formatTreeEntry('e_phoff', '???') },
{ 'text': formatTreeEntry('e_shoff', '???') },
{ 'text': formatTreeEntry('e_flags', '???') },
{ 'text': formatTreeEntry('e_ehsize', '???') },
{ 'text': formatTreeEntry('e_phentsize', '???') },
{ 'text': formatTreeEntry('e_phnum', '???') },
{ 'text': formatTreeEntry('e_shentsize', '???') },
{ 'text': formatTreeEntry('e_shnum', '???') },
{ 'text': formatTreeEntry('e_shstrndx', '???') },
]
}, {
'text': formatTreeNode('Segments', 0),
}, {
'text': formatTreeNode('Sections', 0),
}]
}]
}
});
// File upload
$('#fileSelectInput').change(uploadFile);
$('#fileSelectButton').click(function () {
$('#fileSelectInput').click();
});
function uploadFile(e) {
if (e == null)
return;
// Obtain file
if (typeof e.target !== 'undefined' && typeof e.target.files !== 'undefined') {
var file = e.target.files[0];
} else if (typeof e.dataTransfer !== 'undefined') {
var file = e.dataTransfer.files[0];
} else {
var file = e.originalEvent.dataTransfer.files[0];
}
let name = file.name;
reader = new FileReader();
reader.onloadend = function (e) {
var data = e.target.result;
var elf = new Elf(data);
updateTree(elf, name);
};
reader.readAsArrayBuffer(file);
}
// ELF tree
function genExtraFlags(value, strings) {
var result = [];
for (var i = 0; i < 32; i++) {
let flag = (1 << i);
if (value & flag)
result.push(strings[flag])
}
if (result.length)
return result.join(' | ')
else
return '<i>none</i>';
}
function genTreePhdr(elf, index) {
var phdr = elf.getphdr(index);
var type = p_type_strings[phdr.p_type.num()]
var node = `PHDR[<b>${index}</b>]`
if (type) {
node += '<span style="color:#888">'
node += ' '.repeat(4 - index.toString().length) + `(${type})`;
node += '</span>'
}
return {
'text': node,
'children': [
{ 'text': formatTreeEntry('p_type', phdr.p_type.num(), p_type_strings[phdr.p_type.num()]) },
{ 'text': formatTreeEntry('p_flags', phdr.p_flags.hex(), genExtraFlags(phdr.p_flags, p_flags_strings)) },
{ 'text': formatTreeEntry('p_offset', phdr.p_offset.hex()) },
{ 'text': formatTreeEntry('p_vaddr', phdr.p_vaddr.hex()) },
{ 'text': formatTreeEntry('p_paddr', phdr.p_paddr.hex()) },
{ 'text': formatTreeEntry('p_filesz', phdr.p_filesz.num()) },
{ 'text': formatTreeEntry('p_memsz', phdr.p_memsz.num()) },
{ 'text': formatTreeEntry('p_align', phdr.p_align.num()) },
]
};
}
function genTreeShdr(elf, index) {
var ehdr = elf.getehdr();
var shdr = elf.getshdr(elf.getscn(index));
var name = elf.strptr(ehdr.e_shstrndx.num(), shdr.sh_name.num());
var node = `SHDR[<b>${index}</b>]`
if (name) {
node += '<span style="color:#888">'
node += ' '.repeat(4 - index.toString().length) + `(${name})`;
node += '</span>'
}
return {
'text': node,
'children': [
{ 'text': formatTreeEntry('sh_name', shdr.sh_name.num(), `"${name}"`) },
{ 'text': formatTreeEntry('sh_type', shdr.sh_type.num(), sh_type_strings[shdr.sh_type.num()]) },
{ 'text': formatTreeEntry('sh_flags', shdr.sh_flags.hex(), genExtraFlags(shdr.sh_flags, sh_flags_strings)) },
{ 'text': formatTreeEntry('sh_addr', shdr.sh_addr.hex()) },
{ 'text': formatTreeEntry('sh_offset', shdr.sh_offset.hex()) },
{ 'text': formatTreeEntry('sh_size', shdr.sh_size.num()) },
{ 'text': formatTreeEntry('sh_link', shdr.sh_link.num()) },
{ 'text': formatTreeEntry('sh_info', shdr.sh_info.num()) },
{ 'text': formatTreeEntry('sh_addralign', shdr.sh_addralign.num()) },
{ 'text': formatTreeEntry('sh_entsize', shdr.sh_entsize.num()) },
]
};
}
function genTreeElf(elf, name) {
var ehdr = elf.getehdr();
var phdrs = [];
var shdrs = [];
for (var i = 0; i < ehdr.e_phnum; i++) {
phdrs.push(genTreePhdr(elf, i));
}
for (var i = 0; i < ehdr.e_shnum; i++) {
shdrs.push(genTreeShdr(elf, i));
}
return {
'text': formatTreeNode(`ELF <span style="color:#888">(${name})</span>`),
'state' : { 'opened' : true },
'children': [{
'text': formatTreeNode('Header'),
'state' : { 'opened' : true },
'children': [
{ 'text': formatTreeEntry('e_type', ehdr.e_type.num(), e_type_strings[ehdr.e_type.num()]) },
{ 'text': formatTreeEntry('e_machine', ehdr.e_machine.num(), e_machine_strings[ehdr.e_machine.num()]) },
{ 'text': formatTreeEntry('e_version', ehdr.e_version.num(), e_version_strings[ehdr.e_version.num()]) },
{ 'text': formatTreeEntry('e_entry', ehdr.e_entry.hex()) },
{ 'text': formatTreeEntry('e_phoff', ehdr.e_phoff.hex()) },
{ 'text': formatTreeEntry('e_shoff', ehdr.e_shoff.hex()) },
{ 'text': formatTreeEntry('e_flags', ehdr.e_flags.hex()) },
{ 'text': formatTreeEntry('e_ehsize', ehdr.e_ehsize.num()) },
{ 'text': formatTreeEntry('e_phentsize', ehdr.e_phentsize.num()) },
{ 'text': formatTreeEntry('e_phnum', ehdr.e_phnum.num()) },
{ 'text': formatTreeEntry('e_shentsize', ehdr.e_shentsize.num()) },
{ 'text': formatTreeEntry('e_shnum', ehdr.e_shnum.num()) },
{ 'text': formatTreeEntry('e_shstrndx', ehdr.e_shstrndx.num()) },
]
}, {
'text': formatTreeNode('Segments', ehdr.e_phnum.num()),
'children': phdrs,
}, {
'text': formatTreeNode('Sections', ehdr.e_shnum.num()),
'children': shdrs,
}]
};
}
function updateTree(elf, name) {
$('#elftree').jstree(true).settings.core.data = genTreeElf(elf, name);
$('#elftree').jstree(true).refresh();
}
</script>
</body>
</html>