1 | #include "../include/Segment.h" |
---|
2 | #include "../../Common/include/Debug.h" |
---|
3 | |
---|
4 | namespace environment { |
---|
5 | namespace data { |
---|
6 | |
---|
7 | bool Segment::init (const char * filename,const char ** sections) |
---|
8 | { |
---|
9 | void * ptab; |
---|
10 | int size = this->size; |
---|
11 | // int size = 0; |
---|
12 | int offset = 0; |
---|
13 | |
---|
14 | loadexec(&ptab,&size,&offset,filename,sections); |
---|
15 | |
---|
16 | // std::cout << " - name : " << name << std::endl; |
---|
17 | // std::cout << " - size : " << size << std::endl; |
---|
18 | // std::cout << " - size : " << this->size << std::endl; |
---|
19 | // std::cout << " - offset : " << offset << std::endl; |
---|
20 | |
---|
21 | if (size > (int)this->size) |
---|
22 | { |
---|
23 | std::cerr << "<segment.init> : segment \"" << name << "\" is to small : size is " << this->size << " and requiert is " << size << std::endl; |
---|
24 | return false; |
---|
25 | } |
---|
26 | |
---|
27 | memcpy(data, ptab, size); |
---|
28 | |
---|
29 | free (ptab); |
---|
30 | |
---|
31 | // { |
---|
32 | // _cout(DATA,"Segment Init\n"); |
---|
33 | // _cout(DATA," * size : %d\n",size); |
---|
34 | // _cout(DATA," * size : %d\n",this->size); |
---|
35 | // _cout(DATA,"%s\n",print(0).c_str()); |
---|
36 | |
---|
37 | // uint32_t addr = base; |
---|
38 | // uint32_t step1 = 4; |
---|
39 | // uint32_t step2 = step1*8; |
---|
40 | |
---|
41 | // for (int32_t i=0; i<size; ++i) |
---|
42 | // { |
---|
43 | // if ((i%step1) == 0) |
---|
44 | // _cout(DATA," "); |
---|
45 | // if ((i%step2) ==0) |
---|
46 | // { |
---|
47 | // _cout(DATA,"\n%.8x : ",addr); |
---|
48 | // addr += step2; |
---|
49 | // } |
---|
50 | // _cout(DATA,"%.2x",0xff&static_cast<uint32_t>(data[i])); |
---|
51 | // } |
---|
52 | // _cout(DATA,"\n"); |
---|
53 | // } |
---|
54 | |
---|
55 | return true; |
---|
56 | } |
---|
57 | |
---|
58 | }; |
---|
59 | }; |
---|