mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2026-11-18 10:05:43 +00:00
Compare commits
1379
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc50b77de0 | ||
|
|
7a3d3b0013 | ||
|
|
35e10d950c | ||
|
|
286a28f5d4 | ||
|
|
2bf9eca380 | ||
|
|
6811bc3b0f | ||
|
|
4d79865f69 | ||
|
|
7281ca62c4 | ||
|
|
8385a5132e | ||
|
|
43182c19bf | ||
|
|
eb01bdebd0 | ||
|
|
a9f311ba84 | ||
|
|
d4aeff190e | ||
|
|
22d5a9a7d3 | ||
|
|
ad00133ca3 | ||
|
|
5e98e96112 | ||
|
|
953ed0d6dc | ||
|
|
fd746c306d | ||
|
|
3e15c5c884 | ||
|
|
9a49850ccf | ||
|
|
1d21101504 | ||
|
|
c77e7b7199 | ||
|
|
ab829ff198 | ||
|
|
f262921d16 | ||
|
|
d32c587511 | ||
|
|
b79d8b1cfb | ||
|
|
33e99be6c2 | ||
|
|
72f04e3a0b | ||
|
|
fcaa2da6de | ||
|
|
d12f28b22f | ||
|
|
274112181e | ||
|
|
23b0d1df50 | ||
|
|
b0f30e13d5 | ||
|
|
565681e683 | ||
|
|
5e88db6650 | ||
|
|
a463580945 | ||
|
|
dd7ee6507b | ||
|
|
9c3fd061a7 | ||
|
|
e9bf58c1cf | ||
|
|
51ff73286c | ||
|
|
6a6534cfad | ||
|
|
4a8125a817 | ||
|
|
6a286a90b2 | ||
|
|
27d0aebbbe | ||
|
|
34b031f3d7 | ||
|
|
4bcf963c88 | ||
|
|
26ef3f553b | ||
|
|
47a7b5f2b6 | ||
|
|
620d03cbfc | ||
|
|
3f52fcce58 | ||
|
|
5b46537df2 | ||
|
|
554c72cab4 | ||
|
|
059fbf3f47 | ||
|
|
9ac840041b | ||
|
|
37cb2ad56c | ||
|
|
2bfcdee899 | ||
|
|
ece76fba59 | ||
|
|
7ed063bfa4 | ||
|
|
e1ce7be101 | ||
|
|
b3ee7ad686 | ||
|
|
6927e1aa06 | ||
|
|
10e2e34afb | ||
|
|
f8723855af | ||
|
|
8a67ccd56e | ||
|
|
062bdd7c33 | ||
|
|
72a6c54196 | ||
|
|
22db0384e6 | ||
|
|
d6786d29b3 | ||
|
|
a7d90e58da | ||
|
|
ce4deb2ec0 | ||
|
|
10e5e4468e | ||
|
|
a94e7b1325 | ||
|
|
de02ef96ee | ||
|
|
2d3095d3d4 | ||
|
|
bdb38b388a | ||
|
|
1238faae24 | ||
|
|
efb2a1e457 | ||
|
|
3a23a71d25 | ||
|
|
70979b7030 | ||
|
|
26153f62f2 | ||
|
|
60099b1694 | ||
|
|
44abc2201d | ||
|
|
88ba0ea077 | ||
|
|
ad6d60a105 | ||
|
|
c1469e5135 | ||
|
|
608b9677c0 | ||
|
|
71b6c3439a | ||
|
|
f7c2be435b | ||
|
|
5815a76df8 | ||
|
|
4860f8c6e2 | ||
|
|
ccaf9e9549 | ||
|
|
0013a990fa | ||
|
|
3f9c9ba793 | ||
|
|
a0b06973de | ||
|
|
fcc716e1a7 | ||
|
|
48c365e31c | ||
|
|
61a5a5e7ff | ||
|
|
1d3025f52a | ||
|
|
6da2f461d5 | ||
|
|
cd14f1f2f5 | ||
|
|
e88899e0a2 | ||
|
|
7248d0ad5e | ||
|
|
4822833ce4 | ||
|
|
71e437432f | ||
|
|
24e7130492 | ||
|
|
45fecdcb66 | ||
|
|
e969c07d29 | ||
|
|
ec173a7e86 | ||
|
|
40057a9a3e | ||
|
|
37598799e0 | ||
|
|
6c3b6244bd | ||
|
|
1dd10477dc | ||
|
|
c70575685f | ||
|
|
a3c9671526 | ||
|
|
18fa1ca9e3 | ||
|
|
788fa8fd91 | ||
|
|
36fba15f84 | ||
|
|
8d3e69c32a | ||
|
|
bb48be1ac0 | ||
|
|
81a6464d53 | ||
|
|
436146192f | ||
|
|
1217699413 | ||
|
|
8a9b965f81 | ||
|
|
f78b8fd1d6 | ||
|
|
0e3c81caf7 | ||
|
|
5bc8bfa2f7 | ||
|
|
34afe5c3b2 | ||
|
|
d8a6460700 | ||
|
|
5c2c6eaa88 | ||
|
|
10b017bc77 | ||
|
|
f545728ce2 | ||
|
|
66783c88a0 | ||
|
|
575e71a6bf | ||
|
|
cf6a0ae974 | ||
|
|
7b43620402 | ||
|
|
b9093f88dc | ||
|
|
fa5af4dda8 | ||
|
|
8df394ce07 | ||
|
|
8113ad8a87 | ||
|
|
a74dbff9a4 | ||
|
|
ecdcb85222 | ||
|
|
ba380bd67a | ||
|
|
41607055a6 | ||
|
|
38e6a4061f | ||
|
|
ee1948b53f | ||
|
|
03c8160964 | ||
|
|
50bdae2938 | ||
|
|
1a2cb8370c | ||
|
|
becc8e9eea | ||
|
|
5c30babbdc | ||
|
|
8dcc336e04 | ||
|
|
0fe50d77de | ||
|
|
c28f96597a | ||
|
|
7999eaa25a | ||
|
|
52c59fade2 | ||
|
|
adfea4623d | ||
|
|
d58a2d96f0 | ||
|
|
d46b1ba752 | ||
|
|
b1c64fbe92 | ||
|
|
9b9af4bc68 | ||
|
|
66e2a16c9c | ||
|
|
f7cc3ff662 | ||
|
|
0dbb1ab2f0 | ||
|
|
e7fadbee3c | ||
|
|
2c3e0e3596 | ||
|
|
a71bcc8a2c | ||
|
|
404ded3db6 | ||
|
|
b6fd404109 | ||
|
|
774c46b860 | ||
|
|
b46a86284d | ||
|
|
3dc4496761 | ||
|
|
bd260fe2a4 | ||
|
|
2424db9b17 | ||
|
|
06fea06d57 | ||
|
|
0e259ebe3a | ||
|
|
f4c94d08be | ||
|
|
a8b4b59e82 | ||
|
|
c049e794dc | ||
|
|
6818690c26 | ||
|
|
bb47c0e310 | ||
|
|
c394dfb841 | ||
|
|
9094b060a0 | ||
|
|
8ffb78dc2a | ||
|
|
a87d7d7249 | ||
|
|
0e9b1c2898 | ||
|
|
bded1af4c7 | ||
|
|
897bf03884 | ||
|
|
24ef76bffd | ||
|
|
68b2b5ced6 | ||
|
|
faf274134b | ||
|
|
3f50b9dfcc | ||
|
|
1b89c590dc | ||
|
|
d292c1a394 | ||
|
|
2c443f466f | ||
|
|
ce2836fa98 | ||
|
|
f9267a5bb3 | ||
|
|
7023e2345c | ||
|
|
05bff44a6e | ||
|
|
a8888ec385 | ||
|
|
aee84229c5 | ||
|
|
c7903a4153 | ||
|
|
e7c450c7e1 | ||
|
|
9957d541f2 | ||
|
|
ea4b124e92 | ||
|
|
65a7c7daca | ||
|
|
97ca8c2e5d | ||
|
|
b22d8a5dcd | ||
|
|
7e10c77ff3 | ||
|
|
a3f00b0b75 | ||
|
|
57715255b4 | ||
|
|
bbc0e35dfe | ||
|
|
5d95ada0e1 | ||
|
|
8a8efb3f1d | ||
|
|
27389d23bf | ||
|
|
a4196a12b5 | ||
|
|
61b3035c3d | ||
|
|
065a878a46 | ||
|
|
f3e332ceba | ||
|
|
97a55c36e2 | ||
|
|
bbf9488bf6 | ||
|
|
b0e0c3683b | ||
|
|
016c452d92 | ||
|
|
ba8b2ebb53 | ||
|
|
3fcf8a6067 | ||
|
|
038807958e | ||
|
|
8daa7cecd4 | ||
|
|
52b06ab995 | ||
|
|
bc52ef2cf5 | ||
|
|
2f00bdcac5 | ||
|
|
5eca827eb3 | ||
|
|
ad15b61b0b | ||
|
|
d3934de629 | ||
|
|
ce90fe7b74 | ||
|
|
8426fe578c | ||
|
|
6341b31c6a | ||
|
|
008865a6f7 | ||
|
|
12de7132f3 | ||
|
|
b835ec2d6e | ||
|
|
24eb12d3f5 | ||
|
|
a678239bb0 | ||
|
|
dd9d49e890 | ||
|
|
d6459a2382 | ||
|
|
886f05982b | ||
|
|
2ca1323540 | ||
|
|
453761106e | ||
|
|
cc0f65e60e | ||
|
|
2d503ce900 | ||
|
|
481a5d0b42 | ||
|
|
ec5ea1e863 | ||
|
|
54c0c173df | ||
|
|
9e321a0ead | ||
|
|
6cee055fa6 | ||
|
|
85c663617b | ||
|
|
65892fa344 | ||
|
|
a305ac0143 | ||
|
|
4a1d97ff2a | ||
|
|
b538ca9636 | ||
|
|
d8f4ea7ad6 | ||
|
|
e087b21200 | ||
|
|
4698866283 | ||
|
|
e95ffee0c2 | ||
|
|
7cefa401b4 | ||
|
|
3f3ba207da | ||
|
|
eee1ae3973 | ||
|
|
0e18b3fb3d | ||
|
|
fc7b83a267 | ||
|
|
b1eab6f93c | ||
|
|
d46b2e880c | ||
|
|
a9e1e819c1 | ||
|
|
ec6278b5a8 | ||
|
|
c8d3302128 | ||
|
|
0e59564519 | ||
|
|
e5b9551631 | ||
|
|
22158cd03a | ||
|
|
a2ab9c6039 | ||
|
|
779538b9af | ||
|
|
ff0edb786a | ||
|
|
3067b2c8de | ||
|
|
9c6c6d2f59 | ||
|
|
7e1778019a | ||
|
|
7cc2b783a3 | ||
|
|
d753dc6905 | ||
|
|
12ff2d6a20 | ||
|
|
8b4c54e37f | ||
|
|
d61242c19c | ||
|
|
f949c94465 | ||
|
|
0d9c0c5e9e | ||
|
|
fc58b5286b | ||
|
|
a29fc23148 | ||
|
|
57b5e76065 | ||
|
|
fc709f2a84 | ||
|
|
a6f4aac8b1 | ||
|
|
2a3ecd0672 | ||
|
|
31618cb6df | ||
|
|
9ad7888bc0 | ||
|
|
a8c3a0973a | ||
|
|
825c570746 | ||
|
|
f33873b1ba | ||
|
|
a4dbfc95fa | ||
|
|
707e6634c1 | ||
|
|
c65baa766a | ||
|
|
8d6f310736 | ||
|
|
1b8fc9897d | ||
|
|
17cc9e7d05 | ||
|
|
ac8b2858ad | ||
|
|
ef0ee7525f | ||
|
|
3cb37fffbe | ||
|
|
076e03472f | ||
|
|
9dc65f6008 | ||
|
|
05fd0beac1 | ||
|
|
1f7b134420 | ||
|
|
7f9f0633cd | ||
|
|
3024312901 | ||
|
|
707ddd2de9 | ||
|
|
97357595b6 | ||
|
|
de55b22e86 | ||
|
|
4e0801803f | ||
|
|
d8ad0fdb28 | ||
|
|
fa86937e91 | ||
|
|
fca08c90ab | ||
|
|
180c000565 | ||
|
|
a1349681e1 | ||
|
|
8d9a00ddc5 | ||
|
|
66b46eb591 | ||
|
|
ed3033e396 | ||
|
|
3fabed6ea5 | ||
|
|
8fdf4d4071 | ||
|
|
52e3323b6e | ||
|
|
8af36ef451 | ||
|
|
c03387fcb1 | ||
|
|
3e93f3d037 | ||
|
|
ae88486420 | ||
|
|
911791686c | ||
|
|
787a623715 | ||
|
|
7a9f682332 | ||
|
|
086b4c329e | ||
|
|
08639363fa | ||
|
|
60efc31839 | ||
|
|
4485f9807b | ||
|
|
76f5411741 | ||
|
|
f0f3c5cba3 | ||
|
|
967c691e47 | ||
|
|
07c102e412 | ||
|
|
dc38f7ca18 | ||
|
|
3fbb7642d2 | ||
|
|
90e4a54e12 | ||
|
|
374cc8f212 | ||
|
|
0dd5684041 | ||
|
|
80dd0439a8 | ||
|
|
98d2f6fff8 | ||
|
|
ee8a3b1f4d | ||
|
|
f5318109f0 | ||
|
|
67060801c2 | ||
|
|
9704aaeb74 | ||
|
|
9f0aeb90e2 | ||
|
|
b62408923b | ||
|
|
ab52c9e972 | ||
|
|
032704bd95 | ||
|
|
069fb58779 | ||
|
|
85484034bf | ||
|
|
db63109616 | ||
|
|
37fb2aaa83 | ||
|
|
0d502e5e40 | ||
|
|
33a7e91b0e | ||
|
|
7c585f1b2d | ||
|
|
00aad29d96 | ||
|
|
01359e24bb | ||
|
|
b5bef35538 | ||
|
|
76dce38725 | ||
|
|
61e17bd4f9 | ||
|
|
84fbaaa6b9 | ||
|
|
6eb5833d43 | ||
|
|
5779185677 | ||
|
|
3fa6e9f8ca | ||
|
|
fbb0effb7d | ||
|
|
475b5ce3c4 | ||
|
|
8131767a34 | ||
|
|
f5e8183f30 | ||
|
|
ee3483eadf | ||
|
|
d31d9a1563 | ||
|
|
ff577a6fed | ||
|
|
2f9a27cd3f | ||
|
|
751b96182c | ||
|
|
a2a8927d8f | ||
|
|
824d7c5178 | ||
|
|
0f8e5057d5 | ||
|
|
a86aff7232 | ||
|
|
cfe513363f | ||
|
|
38e72e4b99 | ||
|
|
6047bf5569 | ||
|
|
097ca1468f | ||
|
|
d342905ecb | ||
|
|
4976fcf88e | ||
|
|
fbb740ffdf | ||
|
|
fc92d9810d | ||
|
|
12c2affe92 | ||
|
|
f47483fd66 | ||
|
|
8ce3040691 | ||
|
|
9ccde79fde | ||
|
|
1c7843a191 | ||
|
|
b897f9624c | ||
|
|
9c25498021 | ||
|
|
87da0d461f | ||
|
|
cb4d616c42 | ||
|
|
a3ad8b0e98 | ||
|
|
8a5c0972ab | ||
|
|
e20b95a8b0 | ||
|
|
0f518dba3d | ||
|
|
bb3584db75 | ||
|
|
9f923bd4f6 | ||
|
|
dfb2335b07 | ||
|
|
d486dddebe | ||
|
|
8f1dee63cd | ||
|
|
0efb404152 | ||
|
|
7eef860eb1 | ||
|
|
63673b066c | ||
|
|
941b2cd4d0 | ||
|
|
44c650220a | ||
|
|
b71fb55405 | ||
|
|
8f807bd402 | ||
|
|
a8e82b7e49 | ||
|
|
95a42e16d5 | ||
|
|
92952f3693 | ||
|
|
2f1176438b | ||
|
|
21983f7863 | ||
|
|
7066df403c | ||
|
|
a4c8ac47bb | ||
|
|
405765b59a | ||
|
|
90e4cd8ad1 | ||
|
|
dfce94e701 | ||
|
|
b183c4cae7 | ||
|
|
a059a059c8 | ||
|
|
caf9bd0d97 | ||
|
|
6fc26ab3c6 | ||
|
|
185a54d5aa | ||
|
|
e31e284adb | ||
|
|
780f2410fa | ||
|
|
0a1f0ad778 | ||
|
|
b7c70ab98c | ||
|
|
14b1f57a8d | ||
|
|
d39d171985 | ||
|
|
275bf5a149 | ||
|
|
b177acae71 | ||
|
|
763f49b4fa | ||
|
|
3d2c1401cb | ||
|
|
6dff35135d | ||
|
|
43bd052abf | ||
|
|
be5fe6bf70 | ||
|
|
581e93da6a | ||
|
|
6431eece98 | ||
|
|
3a44cb66ef | ||
|
|
4ef2350350 | ||
|
|
317351e8df | ||
|
|
5a6a357c8f | ||
|
|
c8f5bc0114 | ||
|
|
4d1b585507 | ||
|
|
45ca03eae2 | ||
|
|
233dd09921 | ||
|
|
b27eda81ac | ||
|
|
57b91dbe63 | ||
|
|
e1d8d6a5e2 | ||
|
|
8ffc1b85b0 | ||
|
|
c66ea27716 | ||
|
|
7313b4348e | ||
|
|
fc589638df | ||
|
|
4c25eee0a5 | ||
|
|
d1db544c8b | ||
|
|
1cebcc9b55 | ||
|
|
292af077d4 | ||
|
|
fbbd81be9a | ||
|
|
73dce57ce0 | ||
|
|
358961e07e | ||
|
|
a403b4372a | ||
|
|
ae7aa30dc9 | ||
|
|
686d01b04d | ||
|
|
f4078c9183 | ||
|
|
52d61845d9 | ||
|
|
fcce4d2de3 | ||
|
|
d7c246d112 | ||
|
|
f474ab0425 | ||
|
|
9c728bff1a | ||
|
|
1e65f77173 | ||
|
|
20a65eeeb8 | ||
|
|
59010a4b6f | ||
|
|
6faf7bad31 | ||
|
|
d699f2bbd5 | ||
|
|
c1d1c99753 | ||
|
|
c891cb15c8 | ||
|
|
0ae1b3957e | ||
|
|
83fa6c7934 | ||
|
|
1c4db09770 | ||
|
|
53accbe2cf | ||
|
|
ffe9655966 | ||
|
|
c33c2db3ad | ||
|
|
aeed04049b | ||
|
|
4a81bd08e2 | ||
|
|
b75ab66c85 | ||
|
|
db26deb038 | ||
|
|
88dd40ce2d | ||
|
|
0868141967 | ||
|
|
cd5a2a9a47 | ||
|
|
46715b4296 | ||
|
|
24e0a12960 | ||
|
|
f94da91610 | ||
|
|
0d8f1889ab | ||
|
|
ff687cd21c | ||
|
|
1c96f227e8 | ||
|
|
1429550f8e | ||
|
|
3e2e779436 | ||
|
|
c879205c05 | ||
|
|
814ff25d79 | ||
|
|
d5023fbd6d | ||
|
|
92b8065a02 | ||
|
|
5279d55b9e | ||
|
|
b827263faa | ||
|
|
5dceef2b5c | ||
|
|
5c17edc5a9 | ||
|
|
2b1245d00f | ||
|
|
05bf2b8042 | ||
|
|
d10c930a25 | ||
|
|
6a17d2ca34 | ||
|
|
4b515d005c | ||
|
|
ad8b6a45da | ||
|
|
9829add3ca | ||
|
|
e43899b909 | ||
|
|
31a5578201 | ||
|
|
d73178474f | ||
|
|
67769dcccf | ||
|
|
f1ed77afc2 | ||
|
|
f20836f698 | ||
|
|
626ff0dd8b | ||
|
|
bfc1d53b3e | ||
|
|
d94ec4f39f | ||
|
|
32ceebe537 | ||
|
|
17b3ea17b5 | ||
|
|
31b4ffcca7 | ||
|
|
9e02e561fa | ||
|
|
3e7897371a | ||
|
|
7d1ea872cd | ||
|
|
63eb9668fd | ||
|
|
fd1c9b4910 | ||
|
|
d89999417e | ||
|
|
3f8491d3d6 | ||
|
|
1b4ba95e3c | ||
|
|
e984f82979 | ||
|
|
d1f8ac6638 | ||
|
|
6a771ddb9b | ||
|
|
ee73e2e873 | ||
|
|
a13dec9e18 | ||
|
|
14121a5d51 | ||
|
|
ad623c3e7b | ||
|
|
4d174e8165 | ||
|
|
2dbc1647ad | ||
|
|
93245b144f | ||
|
|
e59cded5cb | ||
|
|
1008b85c79 | ||
|
|
dedc0c3d70 | ||
|
|
42c2863662 | ||
|
|
39653cb958 | ||
|
|
e6eb325ad9 | ||
|
|
1ae58775b8 | ||
|
|
ad86a0c421 | ||
|
|
933b26e875 | ||
|
|
25bf5bcb37 | ||
|
|
6f4fe97cca | ||
|
|
8ab13f94d5 | ||
|
|
c85c54cffb | ||
|
|
261086971e | ||
|
|
15bce663b9 | ||
|
|
9e56293d62 | ||
|
|
e8f77d42e4 | ||
|
|
701fc20977 | ||
|
|
328314aae3 | ||
|
|
bfa9f07aa2 | ||
|
|
839dd39eeb | ||
|
|
fa7829bcd7 | ||
|
|
5b51a2fdcb | ||
|
|
58f7e0f2ab | ||
|
|
0d527175b0 | ||
|
|
7f797a9d16 | ||
|
|
162f815820 | ||
|
|
9837547418 | ||
|
|
4f753c3bd8 | ||
|
|
fb7a640d75 | ||
|
|
4f8176e67f | ||
|
|
a13d67fae9 | ||
|
|
ae704584a1 | ||
|
|
ba64ab5840 | ||
|
|
990e35fb76 | ||
|
|
88bc983e34 | ||
|
|
53720166dd | ||
|
|
b34a183267 | ||
|
|
b770fc170e | ||
|
|
735371e9ba | ||
|
|
366db1ab6e | ||
|
|
e3e7711e29 | ||
|
|
52321cc73e | ||
|
|
be3f603c3d | ||
|
|
68e0d577df | ||
|
|
bc875c1e35 | ||
|
|
17b9ad4f64 | ||
|
|
4a5715d348 | ||
|
|
8d5144558b | ||
|
|
7588085eee | ||
|
|
0cd7038965 | ||
|
|
e248e5fab8 | ||
|
|
e41d85664d | ||
|
|
79f953d86d | ||
|
|
7905986046 | ||
|
|
d694c1ff5d | ||
|
|
4efcddea7f | ||
|
|
7d961bad86 | ||
|
|
c6430d4574 | ||
|
|
76782e4838 | ||
|
|
81faade20a | ||
|
|
1c20a074e3 | ||
|
|
4f4b1bce93 | ||
|
|
3815878ed1 | ||
|
|
82ae3b3eda | ||
|
|
c4e691500c | ||
|
|
5dcd1c8d8f | ||
|
|
e7618c8372 | ||
|
|
6850642ff6 | ||
|
|
b92116d17a | ||
|
|
13edd1c5b6 | ||
|
|
d42173f65b | ||
|
|
6c78084ff9 | ||
|
|
dffa4b7f5a | ||
|
|
6904c732f4 | ||
|
|
fb4637904f | ||
|
|
3a3f9f2e44 | ||
|
|
b1b618b907 | ||
|
|
df637ee942 | ||
|
|
b1f7fa0353 | ||
|
|
50ef8a71b3 | ||
|
|
a37bbfab57 | ||
|
|
e7808ca80f | ||
|
|
15fc8af421 | ||
|
|
0b81ac2661 | ||
|
|
f55a48ea3b | ||
|
|
361943769e | ||
|
|
7f910d3be0 | ||
|
|
95cdd4dcb4 | ||
|
|
95200e0522 | ||
|
|
48d2691469 | ||
|
|
da0f0105bb | ||
|
|
8b391a8150 | ||
|
|
a2b4d753da | ||
|
|
68a527ade6 | ||
|
|
56783f0ac2 | ||
|
|
7d70684811 | ||
|
|
2b6a3f7614 | ||
|
|
d8ad5577eb | ||
|
|
0c8bd41a10 | ||
|
|
6a54d14f43 | ||
|
|
3d024b2a67 | ||
|
|
5b57948a0d | ||
|
|
916359ccf0 | ||
|
|
3a69fb7f64 | ||
|
|
762a1ffcee | ||
|
|
085b645442 | ||
|
|
22bf998615 | ||
|
|
967f380da4 | ||
|
|
2105f5f844 | ||
|
|
eb27298b5d | ||
|
|
962494cb56 | ||
|
|
be94329a8e | ||
|
|
c3d9d97ee1 | ||
|
|
cf45cb52ab | ||
|
|
898ba4bb79 | ||
|
|
fd7f906990 | ||
|
|
da508ed7db | ||
|
|
a60fc98584 | ||
|
|
036bfc95b5 | ||
|
|
7ca9fac139 | ||
|
|
058a51a416 | ||
|
|
effa0a16cd | ||
|
|
4b25f0b685 | ||
|
|
dbdea5a979 | ||
|
|
6b4270e2d8 | ||
|
|
7d0d997877 | ||
|
|
914e2ed3ec | ||
|
|
9b19452848 | ||
|
|
1af6247869 | ||
|
|
afe3356b9c | ||
|
|
06235497a7 | ||
|
|
00bed106a4 | ||
|
|
817a1ce552 | ||
|
|
7c7ba6733e | ||
|
|
3f8e4dfe8c | ||
|
|
07c1079415 | ||
|
|
1cae809b9b | ||
|
|
2c6b2309d5 | ||
|
|
dfdd8c0ea5 | ||
|
|
b991041fe3 | ||
|
|
ebad612f9a | ||
|
|
065eaa9bda | ||
|
|
159be5f675 | ||
|
|
cb7646c7b6 | ||
|
|
1ad3f961f1 | ||
|
|
857c1ba558 | ||
|
|
2fc6741f06 | ||
|
|
8f04e0fd1c | ||
|
|
6dad64ee01 | ||
|
|
ff1fcf6c5d | ||
|
|
6523398ca8 | ||
|
|
26e8bc656a | ||
|
|
97e45d71bb | ||
|
|
4652c6428a | ||
|
|
ee0dcf32bc | ||
|
|
863e3f6c92 | ||
|
|
dd48976e55 | ||
|
|
b4807ef7da | ||
|
|
5b53108e63 | ||
|
|
6cd309f1c0 | ||
|
|
4beee5ff79 | ||
|
|
31fa98b708 | ||
|
|
8bd117dccf | ||
|
|
aef8e953ab | ||
|
|
4bbd40415d | ||
|
|
134947dc7f | ||
|
|
098a6c6bea | ||
|
|
8ed8377442 | ||
|
|
46e0286657 | ||
|
|
80d0bb3ee7 | ||
|
|
c0b3f461fd | ||
|
|
351f329ec8 | ||
|
|
f330e73b79 | ||
|
|
7d601905e4 | ||
|
|
8749d4562f | ||
|
|
1ef6c7ab77 | ||
|
|
a304b7e0e3 | ||
|
|
8f24c5b181 | ||
|
|
c35b4481dc | ||
|
|
0e4819c0e7 | ||
|
|
2f798223d1 | ||
|
|
c41831dd90 | ||
|
|
cc389a88b8 | ||
|
|
319d25efc4 | ||
|
|
bed6aab084 | ||
|
|
cbb96b1401 | ||
|
|
46d9258164 | ||
|
|
9f0947a175 | ||
|
|
d7de263402 | ||
|
|
ad3fa869ee | ||
|
|
b4985ede59 | ||
|
|
2f73c4686e | ||
|
|
4b7ab88b5a | ||
|
|
8b44b1e37a | ||
|
|
4a7c985015 | ||
|
|
cc44c564f8 | ||
|
|
d18c50d0b1 | ||
|
|
e114f6666b | ||
|
|
333be851b9 | ||
|
|
8ebe96ee2b | ||
|
|
92cbfc744a | ||
|
|
17d4c26550 | ||
|
|
e95efe278b | ||
|
|
ee36ee5ab5 | ||
|
|
9579e8e77a | ||
|
|
a4aa054d00 | ||
|
|
a7014c1b56 | ||
|
|
abe6b26950 | ||
|
|
57e0ac23b3 | ||
|
|
a850fd8c9e | ||
|
|
b03ee73923 | ||
|
|
f8796c29cc | ||
|
|
26952bf8f0 | ||
|
|
013ba1f836 | ||
|
|
859f22e83d | ||
|
|
0a6752bc65 | ||
|
|
83b162593f | ||
|
|
00b6640aa1 | ||
|
|
76e21b8509 | ||
|
|
07735be08b | ||
|
|
d2d9651dcd | ||
|
|
3a4ec709ff | ||
|
|
fd71b3e437 | ||
|
|
cdbd7d4cf0 | ||
|
|
10cadfa710 | ||
|
|
fb795d21f9 | ||
|
|
e97524fa3b | ||
|
|
cb1b724b06 | ||
|
|
0b05af1165 | ||
|
|
ed68a1ea69 | ||
|
|
8bd00931ce | ||
|
|
0a555b3e8f | ||
|
|
3df4c5f888 | ||
|
|
ecbd4465e0 | ||
|
|
73d625568c | ||
|
|
c7ecf58258 | ||
|
|
5bfadb405d | ||
|
|
80bd4a0b1c | ||
|
|
b4b3e1d5b8 | ||
|
|
bfb042c7bc | ||
|
|
94e7fb19b0 | ||
|
|
cba30c304f | ||
|
|
4a17dbdd2a | ||
|
|
88691dc964 | ||
|
|
501918258b | ||
|
|
a46bb51df6 | ||
|
|
929ec8459a | ||
|
|
4edf8969b8 | ||
|
|
643b642fd8 | ||
|
|
1d808ef96e | ||
|
|
2e0fa0c3e2 | ||
|
|
f1a731bac2 | ||
|
|
e04281104f | ||
|
|
bad9959d3f | ||
|
|
4f0adfb6c1 | ||
|
|
42fbb1a9e5 | ||
|
|
e0569f3a29 | ||
|
|
4222bfe99a | ||
|
|
e22621d57f | ||
|
|
e9b535423e | ||
|
|
b6a0b21a18 | ||
|
|
05139aa2d0 | ||
|
|
34ac0831eb | ||
|
|
56d038560c | ||
|
|
2864bd0eb5 | ||
|
|
9b2be8e3fb | ||
|
|
4d465fe0ac | ||
|
|
39ecfefa7d | ||
|
|
0970c1295e | ||
|
|
b03c1ffadc | ||
|
|
024ef322d7 | ||
|
|
b08245bd37 | ||
|
|
f5b91da5ae | ||
|
|
ebdce5f3ef | ||
|
|
ae31b7ed90 | ||
|
|
bc7143a03d | ||
|
|
855376ba00 | ||
|
|
6f06530404 | ||
|
|
a37080cc24 | ||
|
|
de6c2f4369 | ||
|
|
90f6772cb0 | ||
|
|
c3f6c7e21c | ||
|
|
57adc8e8ef | ||
|
|
ddcb75e230 | ||
|
|
8c6acad6e0 | ||
|
|
c1bd17edb2 | ||
|
|
7cc29c373c | ||
|
|
d0bd1ae69f | ||
|
|
eadc4af2e0 | ||
|
|
108793bc7a | ||
|
|
655094b681 | ||
|
|
e42fc67bac | ||
|
|
2f424ba099 | ||
|
|
dc63f94428 | ||
|
|
f2cf2650da | ||
|
|
a3fe61cb2a | ||
|
|
458ffc455a | ||
|
|
d219669126 | ||
|
|
f2705574ae | ||
|
|
d4fc57ffc2 | ||
|
|
089d072920 | ||
|
|
7c7d635bb9 | ||
|
|
748e28b266 | ||
|
|
1675bc3d1c | ||
|
|
d1a771ed78 | ||
|
|
9a1fdca704 | ||
|
|
dc2038e767 | ||
|
|
973dd33e71 | ||
|
|
df1fcbe978 | ||
|
|
461e72b5ab | ||
|
|
da5c930411 | ||
|
|
cbaf6103aa | ||
|
|
811dd7d614 | ||
|
|
af52c74def | ||
|
|
5564934a4e | ||
|
|
214b2ee0e7 | ||
|
|
d84fe7af5e | ||
|
|
22c2d13caf | ||
|
|
d6caf49dd0 | ||
|
|
63638e9911 | ||
|
|
818aafe4fc | ||
|
|
0599a70fd1 | ||
|
|
778a066640 | ||
|
|
dfbfb64e5f | ||
|
|
d189a174ee | ||
|
|
21a6c44ee3 | ||
|
|
33ddbca757 | ||
|
|
0a4e0579fd | ||
|
|
bebf722c6f | ||
|
|
5412d0598d | ||
|
|
e4eef98513 | ||
|
|
9344e7bfd3 | ||
|
|
df27d4e06a | ||
|
|
d53e6d7b25 | ||
|
|
6463d120dc | ||
|
|
e76a806902 | ||
|
|
39b6c1c012 | ||
|
|
d5464326e3 | ||
|
|
f259d22ac7 | ||
|
|
396649622e | ||
|
|
4241ea4ed3 | ||
|
|
8d662ad9cc | ||
|
|
5fb877f403 | ||
|
|
204bdeb080 | ||
|
|
d1f0e2c6df | ||
|
|
5584068a89 | ||
|
|
67e5c92ce9 | ||
|
|
2ed9f462d2 | ||
|
|
98aad0c62a | ||
|
|
461ffc9d80 | ||
|
|
041f08d972 | ||
|
|
f96a7a09c1 | ||
|
|
61f6a06038 | ||
|
|
8ae17ae42a | ||
|
|
cc09dd7878 | ||
|
|
cf046b8f9d | ||
|
|
29310a6f20 | ||
|
|
f3c545ffc3 | ||
|
|
88da9ed79e | ||
|
|
2b42f59641 | ||
|
|
0f725dd0b0 | ||
|
|
20f3be439c | ||
|
|
89e890aacd | ||
|
|
4bd79b2880 | ||
|
|
a43322176d | ||
|
|
82854b3ec2 | ||
|
|
eed121e91f | ||
|
|
6773b66a8d | ||
|
|
ce1835ded4 | ||
|
|
c844bd1236 | ||
|
|
301eaff2d6 | ||
|
|
4c60d60f86 | ||
|
|
aa61cc4b61 | ||
|
|
888273589d | ||
|
|
2d236ed812 | ||
|
|
efc820b82d | ||
|
|
9049b590bd | ||
|
|
57c42005c6 | ||
|
|
2bf1b6b9f4 | ||
|
|
ce34239c67 | ||
|
|
09d754b9fd | ||
|
|
3b22cb93c0 | ||
|
|
9f765f7456 | ||
|
|
2beb8a519e | ||
|
|
c37cefab01 | ||
|
|
e457898255 | ||
|
|
060f870bfe | ||
|
|
eeb81df4ff | ||
|
|
cac225a77b | ||
|
|
69aff1ca91 | ||
|
|
6ba0f493b4 | ||
|
|
d2825e00fd | ||
|
|
e44b866716 | ||
|
|
f827a94c0f | ||
|
|
bc4ae31394 | ||
|
|
bfa4540470 | ||
|
|
549f513be8 | ||
|
|
c2ff04d554 | ||
|
|
9839579e66 | ||
|
|
6a9cf16c41 | ||
|
|
b49dc8f645 | ||
|
|
1041ecd45e | ||
|
|
5a7b9e59b6 | ||
|
|
7d693ef797 | ||
|
|
b5f3b84182 | ||
|
|
5316702400 | ||
|
|
b0d0be4c49 | ||
|
|
1fbeeac508 | ||
|
|
107c46ff81 | ||
|
|
69ccf1d626 | ||
|
|
747d7f4fd7 | ||
|
|
3428a9985f | ||
|
|
bbc5d1e0c3 | ||
|
|
e4f8608da4 | ||
|
|
789333011b | ||
|
|
b5909a4070 | ||
|
|
a592e4a31a | ||
|
|
3db30bb90e | ||
|
|
7d5c5b7ad9 | ||
|
|
dca800c146 | ||
|
|
7a19068063 | ||
|
|
1a15a59355 | ||
|
|
5b3bcb893e | ||
|
|
bcb78e8e05 | ||
|
|
10272c5a55 | ||
|
|
37bc41346d | ||
|
|
7e6fb03903 | ||
|
|
f5194eba5b | ||
|
|
d9b35f1987 | ||
|
|
07c3b68841 | ||
|
|
3f54c9771b | ||
|
|
7f67edcce0 | ||
|
|
b26c4652fc | ||
|
|
40b0fc58cc | ||
|
|
518ff9d2f8 | ||
|
|
75f5527937 | ||
|
|
dc9fa44109 | ||
|
|
16f7e3ea94 | ||
|
|
01752e0056 | ||
|
|
db1a46c6ee | ||
|
|
34c5ee9f0d | ||
|
|
11b56cf88b | ||
|
|
a3e1f50cf1 | ||
|
|
3ee1be5529 | ||
|
|
94dfac9f86 | ||
|
|
3ca6a5d76e | ||
|
|
16c2efd6e3 | ||
|
|
21341c082f | ||
|
|
4c77350f24 | ||
|
|
4b8db9e76e | ||
|
|
93f2a54036 | ||
|
|
1fe6d367ce | ||
|
|
5d3329f79d | ||
|
|
089c6ea144 | ||
|
|
3b93f3920e | ||
|
|
2a725d152f | ||
|
|
ffc34dd86e | ||
|
|
b8f99c725b | ||
|
|
523f7549d3 | ||
|
|
2558e732e8 | ||
|
|
cdd82f5dfc | ||
|
|
c5d2aafb12 | ||
|
|
885d915a1c | ||
|
|
9dd5e43b20 | ||
|
|
d1f15ade2c | ||
|
|
5026307072 | ||
|
|
700b407baf | ||
|
|
8e75250c16 | ||
|
|
b2f688dad9 | ||
|
|
a8b0ee3820 | ||
|
|
a461b38c4a | ||
|
|
ee43f2f071 | ||
|
|
db673fe09d | ||
|
|
e77c593a0d | ||
|
|
55b2a88358 | ||
|
|
f3b606d616 | ||
|
|
c6046e01ff | ||
|
|
b1c4bb0b9c | ||
|
|
b37b9b2cc9 | ||
|
|
d890ae5341 | ||
|
|
50e6ec49ae | ||
|
|
e1c2db2ab1 | ||
|
|
385b2bb179 | ||
|
|
5367eaf675 | ||
|
|
3827320f15 | ||
|
|
10a26677f8 | ||
|
|
25116822c0 | ||
|
|
4df01a2189 | ||
|
|
b8e9e89d07 | ||
|
|
0b71c0672c | ||
|
|
a7075e8d21 | ||
|
|
dd38310828 | ||
|
|
776104ea0c | ||
|
|
cc1bb36860 | ||
|
|
1de16c56ed | ||
|
|
d3b2337564 | ||
|
|
51a3d56245 | ||
|
|
b5c352760a | ||
|
|
1ec1c1c2ea | ||
|
|
386f8f19db | ||
|
|
1abe56733f | ||
|
|
076d753607 | ||
|
|
c9a242e254 | ||
|
|
e09ce4ec22 | ||
|
|
e105eb00cb | ||
|
|
1015d6ab46 | ||
|
|
6183fc22a2 | ||
|
|
eecf43999d | ||
|
|
c5df201221 | ||
|
|
e341f7d3ec | ||
|
|
d6287689c1 | ||
|
|
5bf7290268 | ||
|
|
c79d3c75b0 | ||
|
|
806ceac840 | ||
|
|
b1106ed404 | ||
|
|
3f6564ba98 | ||
|
|
a16b1d35c0 | ||
|
|
945358b4b3 | ||
|
|
ae435210a1 | ||
|
|
d62232cf63 | ||
|
|
be7339ca94 | ||
|
|
3817b01d8d | ||
|
|
11dbf68e70 | ||
|
|
a44054650f | ||
|
|
5280d185be | ||
|
|
ffb2be1eda | ||
|
|
1149aadc4d | ||
|
|
d91cf80277 | ||
|
|
98d1f804ae | ||
|
|
a3905bf471 | ||
|
|
fa3d83df02 | ||
|
|
7007ab14ba | ||
|
|
d1d76f9e9c | ||
|
|
897f2afd5b | ||
|
|
0030c32d74 | ||
|
|
fa68be629f | ||
|
|
9c960703c1 | ||
|
|
c46f496541 | ||
|
|
e5d13ed1ba | ||
|
|
2bfb32f8a8 | ||
|
|
299e6aa6ad | ||
|
|
23aee9f8da | ||
|
|
c6bc161763 | ||
|
|
2a30421f7e | ||
|
|
6ee4dd48d9 | ||
|
|
6189880dd5 | ||
|
|
d7f8d90dc9 | ||
|
|
7bbc788792 | ||
|
|
5e3a9fc279 | ||
|
|
706e030907 | ||
|
|
eaa8c4444d | ||
|
|
3a85c3c92a | ||
|
|
19c7e69151 | ||
|
|
0a1bdbc522 | ||
|
|
58f2a417cb | ||
|
|
ae3f4e852f | ||
|
|
147c27da52 | ||
|
|
616581c5a0 | ||
|
|
746f6f4421 | ||
|
|
95bc42484d | ||
|
|
1169f44b94 | ||
|
|
8622e09820 | ||
|
|
edd634c6f6 | ||
|
|
e5b19b5a1a | ||
|
|
1d9430bfb0 | ||
|
|
ee96643119 | ||
|
|
e87bd8db17 | ||
|
|
f2658adc56 | ||
|
|
1633627f12 | ||
|
|
b128964e9b | ||
|
|
60439e8414 | ||
|
|
d49018d1ce | ||
|
|
18daec6875 | ||
|
|
01eb71651c | ||
|
|
bdb0406f13 | ||
|
|
92294a3b65 | ||
|
|
1b9666eff4 | ||
|
|
8e68ced235 | ||
|
|
68636562e5 | ||
|
|
b935a32263 | ||
|
|
fef132199c | ||
|
|
9cfd6c654c | ||
|
|
6d5ebff60a | ||
|
|
02aa33e2a4 | ||
|
|
43417206df | ||
|
|
86dbad54c5 | ||
|
|
6e9bdf2a6e | ||
|
|
21c0c54028 | ||
|
|
b52d86ae9d | ||
|
|
5a65e71d37 | ||
|
|
afbb106145 | ||
|
|
174397969c | ||
|
|
e1d8ea7bee | ||
|
|
ebb01521aa | ||
|
|
91497f7ae8 | ||
|
|
4f9b61168c | ||
|
|
5a60659d9e | ||
|
|
e6c66498fa | ||
|
|
b03e04dfe1 | ||
|
|
b0528bfef4 | ||
|
|
c8da7420c9 | ||
|
|
b8c21b8b21 | ||
|
|
1176102f51 | ||
|
|
bcfb4da94e | ||
|
|
da3b460be6 | ||
|
|
bc8d778632 | ||
|
|
55d01ba7a7 | ||
|
|
d0a60ef253 | ||
|
|
5736f5d766 | ||
|
|
9f269cbd53 | ||
|
|
993a534701 | ||
|
|
4e6841bc13 | ||
|
|
7ffdbbc12a | ||
|
|
f505f78f8a | ||
|
|
aac7d66784 | ||
|
|
e2894fea5a | ||
|
|
f2009d4849 | ||
|
|
46c28924d0 | ||
|
|
8ddff90eae | ||
|
|
aaf66b0dd7 | ||
|
|
71a9aae9a6 | ||
|
|
1ff068469e | ||
|
|
4e1e3d01aa | ||
|
|
66d2a710db | ||
|
|
2c3d88da51 | ||
|
|
574bbe7dd2 | ||
|
|
6b29e029b6 | ||
|
|
61ab2bc318 | ||
|
|
131cd12d10 | ||
|
|
1164e56da4 | ||
|
|
64052dd5c8 | ||
|
|
2c01281231 | ||
|
|
1de68cabfb | ||
|
|
2367f41d5f | ||
|
|
36d980ee58 | ||
|
|
5c554ef79d | ||
|
|
a629cb7f3d | ||
|
|
36195d4655 | ||
|
|
2b6a365392 | ||
|
|
e32706cfb7 | ||
|
|
3f4325b0ce | ||
|
|
a5961a7694 | ||
|
|
770e3b55c2 | ||
|
|
9de52d215d | ||
|
|
05efe2725a | ||
|
|
eb7359e45d | ||
|
|
92c0e99aa4 | ||
|
|
02a19ab687 | ||
|
|
7b9806b163 | ||
|
|
0ebe08f247 | ||
|
|
9e73540ea9 | ||
|
|
ef7e3586c8 | ||
|
|
38f0dd7a4d | ||
|
|
1997cc5188 | ||
|
|
c5d9b556ea | ||
|
|
dca2176204 | ||
|
|
a6f8bc8e20 | ||
|
|
0d58d31f3a | ||
|
|
0ac9932d83 | ||
|
|
d098cce80a | ||
|
|
546e18c753 | ||
|
|
3176513162 | ||
|
|
6e82f6ee9c | ||
|
|
1201b3321b | ||
|
|
e018acd263 | ||
|
|
0a043de4ba | ||
|
|
72453cd1f2 | ||
|
|
218aa808d2 | ||
|
|
2c651eb7bf | ||
|
|
4cfc877c63 | ||
|
|
0982a48111 | ||
|
|
54e7ce88d3 | ||
|
|
8a0ef7ebf9 | ||
|
|
b7c08f5901 | ||
|
|
f983234f46 | ||
|
|
c1bcfe53a7 | ||
|
|
4339967b19 | ||
|
|
354cd80b4a | ||
|
|
3bc132470d | ||
|
|
9bb4ed7d28 | ||
|
|
992ffd6758 | ||
|
|
b2c1b19017 | ||
|
|
e722fbc587 | ||
|
|
b3cc1535b6 | ||
|
|
da6e6490a4 | ||
|
|
580ff186eb | ||
|
|
2d09c5b0aa | ||
|
|
7561e319a1 | ||
|
|
c381334d8b | ||
|
|
1d33dc00ba | ||
|
|
4f818a067b | ||
|
|
4aa81bac9b | ||
|
|
4a3a651831 | ||
|
|
015a25707b | ||
|
|
fbc9157eac | ||
|
|
232fc1e546 | ||
|
|
88dd9b39cd | ||
|
|
df87a2838a | ||
|
|
11d711787c | ||
|
|
0ccee37dc2 | ||
|
|
f897273013 | ||
|
|
aff473ff8c | ||
|
|
728848c593 | ||
|
|
436e5a700a | ||
|
|
488ffe86d3 | ||
|
|
7a55ebe6f8 | ||
|
|
9924a6d545 | ||
|
|
9ba5e82c0d | ||
|
|
a1b7537511 | ||
|
|
febc0e8231 | ||
|
|
fb1765f1a7 | ||
|
|
a7a7e9a9db | ||
|
|
39502ae658 | ||
|
|
4337d15fc4 | ||
|
|
d5c1f9d2d7 | ||
|
|
b651c73b15 | ||
|
|
88c6a46e10 | ||
|
|
21694fbbaf | ||
|
|
ed534cc3ff | ||
|
|
ecf7476537 | ||
|
|
45765ef2d7 | ||
|
|
2262f1c58a | ||
|
|
7436bc593b | ||
|
|
45e7dbb2c7 | ||
|
|
b1542fe0cd | ||
|
|
2a4402b055 | ||
|
|
70f90c8f6b | ||
|
|
55a8f821c4 | ||
|
|
f6fa4f3b13 | ||
|
|
01af831980 | ||
|
|
ba28dbd72a | ||
|
|
ec7682ac94 | ||
|
|
e2d6493f91 | ||
|
|
efb9aaf8aa | ||
|
|
d0f7b8805c | ||
|
|
2437f3d4d0 | ||
|
|
ae5feb9bcb | ||
|
|
9d206345bf | ||
|
|
b7e6fed739 | ||
|
|
ae439695a1 | ||
|
|
9a28000280 | ||
|
|
5abf255801 | ||
|
|
4654c9425e | ||
|
|
d899f57fec | ||
|
|
7e0ceec977 | ||
|
|
1d67a8516f | ||
|
|
0da3ce8064 | ||
|
|
1905d3e0ce | ||
|
|
1426180b07 | ||
|
|
c9709a1f35 | ||
|
|
f8677f8d4c | ||
|
|
5dc50eb59f | ||
|
|
fa67482972 | ||
|
|
c4c6988306 | ||
|
|
2eec695f4c | ||
|
|
396d65762f | ||
|
|
ee31149392 | ||
|
|
a2f0a306bc | ||
|
|
5ea5794168 | ||
|
|
b82abdaf2c | ||
|
|
2962b3785b | ||
|
|
6c47ddd783 | ||
|
|
5cf59cbda0 | ||
|
|
9baea081f0 | ||
|
|
bdc247d02b | ||
|
|
579084d145 | ||
|
|
128ec7e478 | ||
|
|
daf1105c92 | ||
|
|
912d2157ef | ||
|
|
6bb8158920 | ||
|
|
88940e11bd | ||
|
|
7c07599725 | ||
|
|
275f7edc86 | ||
|
|
4e6b8f102a | ||
|
|
502c1a50db | ||
|
|
2617074192 | ||
|
|
d43bbc9dcd | ||
|
|
dd7d98ccf4 | ||
|
|
46a4582009 | ||
|
|
27e5975df5 | ||
|
|
64408303f1 | ||
|
|
f93d659375 | ||
|
|
fe4bb95f85 | ||
|
|
af8d44bf4b | ||
|
|
1fa26c9add | ||
|
|
880a2a8fdd | ||
|
|
8e1a65399c | ||
|
|
62e35226ed | ||
|
|
ab38e77526 | ||
|
|
b211c95bfe | ||
|
|
ea1ecceabe | ||
|
|
5db692fbe5 | ||
|
|
1b177e45bf | ||
|
|
6cb270c952 | ||
|
|
a5875162a7 | ||
|
|
adcede7780 | ||
|
|
a745d1f8e6 | ||
|
|
6c4cfd26a7 | ||
|
|
f6d99aed59 | ||
|
|
0046f56151 | ||
|
|
0f9c0a5fab | ||
|
|
c2e91ab943 | ||
|
|
59f9c394a8 | ||
|
|
4e0de4d4b2 | ||
|
|
684c4e84ac | ||
|
|
355742d644 | ||
|
|
ca7d4f0957 | ||
|
|
c7a592164b | ||
|
|
f750d9a830 | ||
|
|
19c9596816 | ||
|
|
d7b3b4a6f6 | ||
|
|
8f1f91601e | ||
|
|
12a7e8514a | ||
|
|
c030e39b3d | ||
|
|
2dca69dc00 | ||
|
|
10560ddb0e | ||
|
|
b3e76e1a0e | ||
|
|
9c9f27c698 | ||
|
|
8372ead3de | ||
|
|
18c89843e6 | ||
|
|
f194e44f8f | ||
|
|
3517471a22 | ||
|
|
d8be445872 | ||
|
|
2e3fb8371b |
No files matched your search
@@ -0,0 +1,9 @@
|
||||
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
tab_width = 8
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
@@ -0,0 +1,4 @@
|
||||
* text=auto eol=lf
|
||||
*.sln text eol=crlf
|
||||
*.vcxproj text eol=crlf
|
||||
*.vcxproj.filters text eol=crlf
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
.deps
|
||||
.libs
|
||||
autom4te.cache
|
||||
m4
|
||||
|
||||
ac_cfg.h
|
||||
ac_cfg.h.in
|
||||
aclocal.m4
|
||||
avrdude
|
||||
avrdude.conf
|
||||
avrdude.conf.tmp
|
||||
avrdude.spec
|
||||
compile
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
config_gram.c
|
||||
config_gram.h
|
||||
configure
|
||||
depcomp
|
||||
INSTALL
|
||||
install-sh
|
||||
lexer.c
|
||||
libtool
|
||||
ltmain.sh
|
||||
Makefile
|
||||
Makefile.in
|
||||
mdate-sh
|
||||
mkinstalldirs
|
||||
missing
|
||||
stamp-h.in
|
||||
stamp-h1
|
||||
texinfo.tex
|
||||
y.output
|
||||
y.tab.h
|
||||
ylwrap
|
||||
|
||||
*.o
|
||||
*.lo
|
||||
*.a
|
||||
*.la
|
||||
*.diff
|
||||
*.patch
|
||||
|
||||
## Ignore Visual Studio build results
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
x86/
|
||||
*.log
|
||||
|
||||
# Visual Studio cache/options directory
|
||||
.vs/
|
||||
|
||||
# Include pre-built files
|
||||
!ac_cfg.h
|
||||
!config_gram.c
|
||||
!config_gram.h
|
||||
!lexer.c
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
language: c++
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- name: "Linux (GCC)"
|
||||
os: linux
|
||||
dist: bionic
|
||||
compiler: gcc
|
||||
before_install:
|
||||
- sudo apt-get -y install make gcc automake libtool flex bison
|
||||
- sudo apt-get -y install libelf-dev libusb-dev libftdi1-dev libhidapi-dev
|
||||
script:
|
||||
- ./bootstrap
|
||||
- ./configure
|
||||
- make
|
||||
- name: "macOS (clang)"
|
||||
os: osx
|
||||
osx_image: xcode12u
|
||||
compiler: clang
|
||||
before_install:
|
||||
- brew install flex bison
|
||||
script:
|
||||
- ./bootstrap
|
||||
- ./configure
|
||||
- make
|
||||
- name: "Windows (MSVC)"
|
||||
if: branch = windows OR branch = dev
|
||||
os: windows
|
||||
before_install:
|
||||
- choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.18362"
|
||||
- export PATH=$PATH:"/c/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/MSBuild/Current/Bin"
|
||||
script:
|
||||
- MSBuild.exe -fileLogger -target:avrdude -property:Configuration=Release -property:Platform=x64 avrdude.sln
|
||||
@@ -24,8 +24,7 @@ Contributors:
|
||||
Rene Liebscher <r.liebscher@gmx.de>
|
||||
Jim Paris <jim@jtan.com>
|
||||
Jan Egil Ruud <janegil.ruud@microchip.com>
|
||||
David Mosberger <davidm@egauge.net>
|
||||
David Sainty
|
||||
David Mosberger-Tang
|
||||
|
||||
For minor contributions, please see the ChangeLog files.
|
||||
|
||||
@@ -1,320 +1,148 @@
|
||||
2021-12-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
2018-01-21 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* configure.ac (AC_INIT): Bump version to 6.4
|
||||
* main.c: Remove unmaintained year numbers from Copyright
|
||||
patch #8444: Proposal for modifications in -B and -U command options managment
|
||||
* update.c (parse_op): Default -U filename to RBIN for output
|
||||
files
|
||||
|
||||
2021-12-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
2018-01-18 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
bug #57338: if safemode has to change fuses avrdude should exit with non-zero exit code
|
||||
* main.c (main): drop unused variable `fuses_specified'
|
||||
Submitted by Simone:
|
||||
patch #8128: Added new option to configure.ac script
|
||||
* configure.ac (disable-libusb_1_0): New option
|
||||
|
||||
2021-12-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Dmitrii Chernukhin:
|
||||
bug #58994: VPP PWM still enabled at the end of programming process
|
||||
* pickit2.c (pickit2_disable): turn off VPP before shutting down
|
||||
|
||||
2021-12-05 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* configure.ac (AC_INIT): Bump version date
|
||||
* configure.ac (enabled_parport): Default to "no"
|
||||
|
||||
2021-12-03 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Alex Sverdlin:
|
||||
patch #10153: linuxspi: Support "-E reset" and "-E noreset"
|
||||
* linuxspi.c (linuxspi_parseexitspecs): New function
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
bug #58440: linuxgpio PIN limit too low
|
||||
* libavrdude.h (PIN_MAX): bump (for HAVE_LINUXGPIO) to 400
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Mosberger-Tang:
|
||||
patch #8923: Enable TPI for linuxgpio
|
||||
* linuxgpio.c (linuxgpio_initpgm): add cmd_tpi entry
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by: Milan Kupcevic <milan@debian.org>
|
||||
patch #8996: Remove lock byte read mask (bug#21954, bug#46759)
|
||||
* avrdude.conf.in (ATmega48, ATmega88, ATmega168, ATmega328)
|
||||
(ATmega32U4, ATmega640, ATmega1280, ATmega1281, ATmega2560)
|
||||
(ATmega2561, ATmega8, ATtiny13, ATmega64, ATmega128, ATmega16)
|
||||
(AT90CAN32, AT90CAN64, AT90CAN128, ATmega324, ATmega644)
|
||||
(ATmega1284, ATmega161, ATmega162, ATmega163, ATmega169, ATmega32)
|
||||
(ATmega329, ATmega649, ATmega8515, ATmega8535, ATtiny2313, ATtiny4313)
|
||||
(AT90PWM2, AT90USB646, AT90USB1286, AT90USB162, AT90USB82, ATmega32U2)
|
||||
(ATmega16U2, ATmega8U2, ATmega325, ATmega645, ATtiny1634): Remove
|
||||
lock byte read mask (bug#46759).
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Christopher Cooper:
|
||||
patch #9304: [Bug #48767] Implemented WinSock variation of "ser_drain(...)" functionality
|
||||
* ser_win32.c (ser_drain): Implement a network drain
|
||||
function.
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Lars Ollén:
|
||||
* linux_spi.c (linuxspi_open): ensure correct SPI mode is
|
||||
set (submitted in the audit trail of patch #9816).
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* linuxspi.c: Use -B <bitclock> rather than -b <baudrate>
|
||||
to specify the clock rate
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Improve defaults and documentation of linuxspi
|
||||
* avrdude.conf.in: use @HAVE_LINUXGPIO_BEGIN/END@ and
|
||||
@HAVE_LINUXSPI_BEGIN/END@ brackets around respective config
|
||||
snippets; values were already set in configure.ac.
|
||||
* linuxspi.c (linuxspi_open): Provide a reasonable (for the
|
||||
Raspberry Pi) default for the -P option
|
||||
* avrdude.1: Extend linuxspi documentation
|
||||
* doc/avrdude.texi: (Dito.)
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Alex Sverdlin:
|
||||
patch #10031: linuxspi: Support GPIO uAPI v2
|
||||
* linuxspi.c (linuxspi_reset_mcu, linuxspi_open): Since Linux
|
||||
v5.10 GPIO ABI Version 1 is optional and depends on
|
||||
CONFIG_GPIO_CDEV_V1.
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Alex Sverdlin:
|
||||
patch #10030: linuxspi: Support inverted GPIO pin
|
||||
* linuxspi.c (linuxspi_open): Clear the inversion mask on request
|
||||
and set default state to avoid short glitches on the GPIO line.
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Alex Sverdlin:
|
||||
patch #10029: linuxspi: Report GPIO_GET_LINEHANDLE_IOCTL errors
|
||||
* linuxspi.c (linuxspi_open): Report ioctl error
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Alex Sverdlin:
|
||||
patch #10028: linuxspi: close() only when necessary
|
||||
* linuxspi.c: unify descriptor closing
|
||||
|
||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Alex Sverdlin:
|
||||
patch #10027: linuxspi: Add reset pulse, according to AVR programming algorithm
|
||||
* linuxspi.c (linuxspi_open, linuxspi_program_enable):
|
||||
movw out reset code into linuxspi_reset_mcu()
|
||||
|
||||
2021-11-25 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Mosberger-Tang:
|
||||
patch #9328: ft245r.c: add TPI support (patches 5-7)
|
||||
* ft245r.c (ft245r_set_bitclock): add workaround for
|
||||
FT245 hardware bugs in bitclock setting
|
||||
|
||||
2021-11-25 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Mosberger-Tang:
|
||||
patch #9328: ft245r.c: add TPI support (patches 5-7)
|
||||
* ft245r.c: Remove the reader thread (also removes
|
||||
patch #9079)
|
||||
|
||||
2021-11-24 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Mosberger-Tang:
|
||||
patch #9327: ft245r.c: add TPI support (patches 1-4)
|
||||
* ft245r.c (set_pin, ft245r_open): use
|
||||
ft245r_send_and_discard() so ft245r_in can go away
|
||||
|
||||
2021-11-24 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Mosberger-Tang:
|
||||
patch #9327: ft245r.c: add TPI support (patches 1-4)
|
||||
* ft245r.c (ft245r_recv): Optimize TPI programming
|
||||
speed by reducing number of USB reads.
|
||||
|
||||
2021-11-24 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Mosberger-Tang:
|
||||
patch #9327: ft245r.c: add TPI support (patches 1-4)
|
||||
* ft245r.c (ft245r_open): add call to
|
||||
ftdi_set_latency_timer() to improve timing
|
||||
|
||||
2021-11-24 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Mosberger-Tang:
|
||||
patch #9327: ft245r.c: add TPI support (patches 1-4)
|
||||
* ft245r.c: add TPI support
|
||||
* avrdude.conf.in (tc2030): New programmer
|
||||
|
||||
2021-11-24 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* ft245r.c (ft245r_open): allow for picking a default
|
||||
device if none has been provided by -P
|
||||
|
||||
2021-11-24 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* jtag3.c (jtag3_edbg_recv_frame): Better handling for
|
||||
fragment_info == 0x00 (no response available)
|
||||
|
||||
2021-11-23 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* jtag3.c: Use matches() instead of strncmp()
|
||||
|
||||
2021-11-23 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
patch #9757: Fix ATtiny817 Xplained Mini programmer
|
||||
* jtag3.c (jtag3_getsync, jtag3_close): correctly extract
|
||||
programmer name from list of names
|
||||
|
||||
2021-11-22 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Sainty:
|
||||
patch #8719: Support Over-the-Air bootloading with XBeeBoot
|
||||
* xbee.c: New programmer
|
||||
* xbee.h: (Dito.)
|
||||
* pgm_type.c: Add xbee.h
|
||||
* avrdude.conf.in (xbee): New programmer
|
||||
* Makefile.am (libavrdude_a_SOURCES): add xbee.c, xbee.h
|
||||
* avrdude.1: document the new programmer
|
||||
* doc/avrdude.texi: (Dito.)
|
||||
|
||||
2021-11-14 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Ivan Frederiks:
|
||||
patch #9079: Fix ftdi_syncbb teardown (supersedes #9893)
|
||||
patch #9122: Fixed MISO sampling in ftdi_syncbb
|
||||
patch #9123: ftdi_syncbb: use FT245R_CYCLES in ft245r_set_bitclock()
|
||||
* ft245r.c: Various fixes for FT245-bitbang programmers
|
||||
|
||||
2021-11-14 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Mosberger-Tang:
|
||||
patch #9320: fix TPI RESET in bitbang.c
|
||||
* bitbang.c (bitbang_initialize): wait for 128 ms after deasserting
|
||||
/RESET (per datasheet), and keep /RESET low during MOSI/MISO link check
|
||||
|
||||
2021-11-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Jon Thacker:
|
||||
patch #9253: Fix for giving terminal_mode commands more than 20 arguments
|
||||
* term.c (tokenize): fix realloc usage, pointer returned not necessarily
|
||||
the same as pointer passed
|
||||
|
||||
2021-11-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Martino Facchin:
|
||||
patch #9110: Let reserved fuse bits to be read as *don't care*
|
||||
* avr.c (compare_memory_masked): New function
|
||||
* libavrdude.h: declare compare_memory_masked(); also, insist on C99
|
||||
so <stdint.h> is required now
|
||||
* main.c: Use compare_memory_masked() in safemode comparisons
|
||||
|
||||
2021-11-11 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Joseph Coffland:
|
||||
patch #8957: Allow reading prodsig memory from stk500v2 on xmega devices
|
||||
* stk500v2.c (stk600_xprog_read_byte, stk600_xprog_paged_load):
|
||||
treat "prodsig" memory space as equivalent to "calibration"
|
||||
|
||||
2021-11-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Martin Thierer:
|
||||
patch #10017: uspasp / tpi: Automatically clear configuration byte (fuse) before writing it
|
||||
* usbasp.c (usbasp_tpi_paged_write): clear fuse region before writing it
|
||||
|
||||
2021-11-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Michael Petersen:
|
||||
patch #9697: Add iseavrprog support
|
||||
* avrdude.conf.in (iseavrprog): New programmer
|
||||
|
||||
2021-11-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
bug #50630: Erase Cycle Counter options ( -y -Y n ) should be removed from usage Message
|
||||
* main.c (usage): remove -y / -Y descriptions
|
||||
|
||||
2021-11-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* avrdude.conf.in (ATmega8A): new device (alias for ATmega8)
|
||||
|
||||
2021-11-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
bug #50517: Reading fails if "immediate mode" for output file format is selected - fileio: invalid operation=1
|
||||
* update.c (do_op): refuse to write to "immediate format" argument
|
||||
|
||||
2021-11-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Martin Thierer:
|
||||
bug #60863: avrftdi programming error probably caused by multiple, consecutive empty pages
|
||||
* avrftdi.c (avrftdi_flash_write): Skip empty pages
|
||||
|
||||
2021-11-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Matwey V. Kornilov:
|
||||
bug #58495: Add atmega324pb support to avrdude.conf.in
|
||||
* avrdude.conf.in (ATmega324PB): new entry
|
||||
|
||||
2021-11-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
bug #55734: USBtiny programming of ATmega328p broken by Patch #9278
|
||||
* usbtiny.c (usbtiny_initialize): undo change from patch #9728
|
||||
|
||||
2021-11-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
bug #55009: no efuses for m164a/pa
|
||||
* avrdude.conf.in (ATmega164P): derive from ATmega324P
|
||||
|
||||
2021-11-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by evan Venn:
|
||||
bug #59227: Add new part. How does one get a part added to the CONF file?
|
||||
* avrdude.conf.in (LGT8FX88P, LGT8FX168P, LGT8FX328P): new parts
|
||||
|
||||
2021-11-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Britton Kerin:
|
||||
bug #57453: [PATCH] fix reference to nonexistant -m option by changing to -U
|
||||
* avrdude.1: replace -m option by -U
|
||||
|
||||
2021-11-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Andrew D'Addesio:
|
||||
bug #58078: [PATCH] buspirate: remove compound literals (fixes GCC>=9)
|
||||
* buspirate.c (buspirate_start_mode_bin):
|
||||
avoid propagating local scope compound literals
|
||||
|
||||
2021-11-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
2018-01-18 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Jan Egil Ruud:
|
||||
patch #10000: Add support for extended UPDI device context
|
||||
* avrdude.conf.in (pickit4_updi, snap_updi, pkobn_updi):
|
||||
new programmers
|
||||
* avrdude.conf.in (ATmega808, ATmega809, ATmega1608, ATmega1609)
|
||||
(AVR DA, AVR DB): new devices
|
||||
* jtag3.c: Add support for extended UPDI device context
|
||||
* jtag3_private.h: (Dito.)
|
||||
* tools/atdf-to-avrdude.xslt: Bug fixes
|
||||
* usbdevs.h: Bump USBDEV_MAX_XFER_3 to 912
|
||||
* doc/avrdude.texi: Document changes
|
||||
* avrdude.1: (Dito)
|
||||
patch #9542: Correct "usersig" on avr8x devices
|
||||
* avrdude.conf.in (.avr8x_tiny, .avr8x_mega): rename "userrow" to
|
||||
"usersig", and fix its page size for .avr8x_mega
|
||||
* jtag3.c: Remove all "userrow" handling
|
||||
|
||||
2021-06-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
2018-01-17 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
bug #60753: Patch #1436 breaks multiple programmer/device combinations on MacOS BigSur
|
||||
* avr.c: compare page_size > 1 instead of != 0
|
||||
* stk500v2.c: (Ditto.)
|
||||
Submitted by Reinhard Max
|
||||
patch #8311: Add IPv6 support to the -Pnet:host:port option
|
||||
* ser_posix.c (net_open): Rewrite to use getaddrinfo()
|
||||
rather than gethostbyname()
|
||||
* avrdude.1: Document IPv6 feature
|
||||
* doc/avrdude.texi: (Dito)
|
||||
|
||||
2021-06-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Maciej:
|
||||
patch #9185: Add extended_param to usbasp.c - erasing
|
||||
configuration section in ATtiny 4...40 (TPI)
|
||||
* usbasp.c: Implement extended parameter parsing, and modify
|
||||
usbasp_tpi_chip_erase() appropriately
|
||||
* avrdude.1: Document USBasp extended parameters
|
||||
* doc/avrdude.texi: (Dito)
|
||||
|
||||
2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Tom Carney:
|
||||
patch #8219: Fix boot_start for xmega devices on jtagmkII
|
||||
* jtagmkII.c (jtagmkII_initialize): Determine boarder between
|
||||
application and boot area correctly.
|
||||
|
||||
2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Jan Egil Ruud <janegil.ruud@microchip.com>
|
||||
patch #9507: Fix UPDI chip erase
|
||||
* libavrdude.h (PROGRAMMER): add unlock method
|
||||
* avr.c (avr_unlock): Generic unlock function
|
||||
* jtag3.c: Implement unlock feature; avoid calling
|
||||
jtag3_edbg_prepare() and jtag3_edbg_signoff() on XplainedMini
|
||||
boards to work around a bug in early firmware versions;
|
||||
implement "userrow" memory region
|
||||
* main.c: Call avr_unlock() rather than avr_chip_erase() when
|
||||
encountering a locked UPDI chip
|
||||
|
||||
2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Nicolas BRULEZ
|
||||
patch #8910: ATxmega32c4 and ATxmega16c4 have wrong signatures
|
||||
bug #41388: ATxmega32c4 and ATxmega16c4 have wrong signatures
|
||||
* avrdude.conf.in (ATxmega16C4, ATxmega32C4): Fix signatures
|
||||
|
||||
2018-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Dennis Reimers:
|
||||
patch #8580: FT245r support to select device by serial number
|
||||
* ft245r.c (ft245r_open): Add serial number parsing.
|
||||
|
||||
2018-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Axel Simon:
|
||||
patch #9033: avrdoper backend uses libhidapi instead of libusb
|
||||
* ser_avrdoper: Add libhidapi implementation
|
||||
* stk500v2.c: Adapt #ifdefs for LIBHIDAPI
|
||||
* avrdude.1: Document change
|
||||
* doc/avrdude.texi: (Dito)
|
||||
|
||||
2018-01-13 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Mosberger-Tang
|
||||
patch #8924: Enable TPI for usbtiny
|
||||
* usbtiny.c: Extend to handle TPI targets
|
||||
* configure.ac: Probe for <netinet/in.h>
|
||||
|
||||
2018-01-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Yegor Yefremov:
|
||||
patch #9222: Enable silent build
|
||||
* configure.ac: Add AM_SILENT_RULES
|
||||
* Makefile.am: Document how to run "make" to get verbose
|
||||
build messages
|
||||
|
||||
2018-01-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by: Kjetil Kjeka:
|
||||
patch #9317: Support atmega64m1 as part
|
||||
* avrdue.conf.in (ATmega64M1): New entry.
|
||||
|
||||
2018-01-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Submitted David Griffith:
|
||||
patch #9530: Update URL to Ladyada's USBtinyISP page.
|
||||
* avrdude.conf.in (usbtiny): Update URL
|
||||
|
||||
2018-01-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Milan Kupcevic:
|
||||
patch #9423: Support ATtiny841 and ATtiny441
|
||||
bug #47376: ATtiny841 description missing in configuration file
|
||||
bug #49455: support for tiny441
|
||||
* avrdude.conf.in (ATtiny841, ATtiny441): New entries
|
||||
|
||||
2018-01-10 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Morten Engelhardt Olsen
|
||||
patch #9506: Script to create device configuration stub from Atmel ATDF files
|
||||
* tools/atdf-to-avrdude.xslt: New script
|
||||
|
||||
2018-01-10 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Jan Egil Ruud <janegil.ruud@microchip.com>
|
||||
patch #9507: Fix UPDI chip erase
|
||||
* lexer.l (family_id): New keyword.
|
||||
* config_gram.y: (Ditto)
|
||||
* doc/avrdude.texi: Document new keyword
|
||||
* avrdude.conf.in: Add family_id for avr8x devices
|
||||
* avr.c: Pass error code up.
|
||||
* jtag3.c: Pass error code from memory read up; implement
|
||||
jtag3_read_sib()
|
||||
* libavrdude.h: Add new items.
|
||||
* main.c: Implement different chip erase handling required
|
||||
for UPDI devices.
|
||||
|
||||
2018-01-10 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Jan Egil Ruud <janegil.ruud@microchip.com>
|
||||
patch #9506: Script to create device configuration stub from Atmel ATDF files
|
||||
* avrdude.conf.in (ATtiny202, ATtiny204, ATtiny402, ATtiny404)
|
||||
(ATtiny406, ATtiny804, ATtiny806, ATtiny807, ATtiny1604)
|
||||
(ATtiny1606, ATtiny1607, ATtiny212, ATtiny214, ATtiny412)
|
||||
(ATTiny414, ATtiny416, ATtiny417, ATtiny814, ATtiny816)
|
||||
(ATtiny1614, ATtiny1616, ATtiny3214, ATtiny3216, ATtiny3217)
|
||||
(ATmega3208, ATmega3209, ATmega4808, ATmega4809): New devices
|
||||
|
||||
Submitted by gerardoallende:
|
||||
bug #59525: Bogus error message because Copy/Paste typo in stk500.c
|
||||
* stk500.c (stk500_getparm): Fix bogus ID in error message
|
||||
-148
@@ -1,148 +0,0 @@
|
||||
2018-01-21 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
patch #8444: Proposal for modifications in -B and -U command options managment
|
||||
* update.c (parse_op): Default -U filename to RBIN for output
|
||||
files
|
||||
|
||||
2018-01-18 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Simone:
|
||||
patch #8128: Added new option to configure.ac script
|
||||
* configure.ac (disable-libusb_1_0): New option
|
||||
|
||||
2018-01-18 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Jan Egil Ruud:
|
||||
patch #9542: Correct "usersig" on avr8x devices
|
||||
* avrdude.conf.in (.avr8x_tiny, .avr8x_mega): rename "userrow" to
|
||||
"usersig", and fix its page size for .avr8x_mega
|
||||
* jtag3.c: Remove all "userrow" handling
|
||||
|
||||
2018-01-17 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Reinhard Max
|
||||
patch #8311: Add IPv6 support to the -Pnet:host:port option
|
||||
* ser_posix.c (net_open): Rewrite to use getaddrinfo()
|
||||
rather than gethostbyname()
|
||||
* avrdude.1: Document IPv6 feature
|
||||
* doc/avrdude.texi: (Dito)
|
||||
|
||||
2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Maciej:
|
||||
patch #9185: Add extended_param to usbasp.c - erasing
|
||||
configuration section in ATtiny 4...40 (TPI)
|
||||
* usbasp.c: Implement extended parameter parsing, and modify
|
||||
usbasp_tpi_chip_erase() appropriately
|
||||
* avrdude.1: Document USBasp extended parameters
|
||||
* doc/avrdude.texi: (Dito)
|
||||
|
||||
2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Tom Carney:
|
||||
patch #8219: Fix boot_start for xmega devices on jtagmkII
|
||||
* jtagmkII.c (jtagmkII_initialize): Determine boarder between
|
||||
application and boot area correctly.
|
||||
|
||||
2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Jan Egil Ruud <janegil.ruud@microchip.com>
|
||||
patch #9507: Fix UPDI chip erase
|
||||
* libavrdude.h (PROGRAMMER): add unlock method
|
||||
* avr.c (avr_unlock): Generic unlock function
|
||||
* jtag3.c: Implement unlock feature; avoid calling
|
||||
jtag3_edbg_prepare() and jtag3_edbg_signoff() on XplainedMini
|
||||
boards to work around a bug in early firmware versions;
|
||||
implement "userrow" memory region
|
||||
* main.c: Call avr_unlock() rather than avr_chip_erase() when
|
||||
encountering a locked UPDI chip
|
||||
|
||||
2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Nicolas BRULEZ
|
||||
patch #8910: ATxmega32c4 and ATxmega16c4 have wrong signatures
|
||||
bug #41388: ATxmega32c4 and ATxmega16c4 have wrong signatures
|
||||
* avrdude.conf.in (ATxmega16C4, ATxmega32C4): Fix signatures
|
||||
|
||||
2018-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Dennis Reimers:
|
||||
patch #8580: FT245r support to select device by serial number
|
||||
* ft245r.c (ft245r_open): Add serial number parsing.
|
||||
|
||||
2018-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Axel Simon:
|
||||
patch #9033: avrdoper backend uses libhidapi instead of libusb
|
||||
* ser_avrdoper: Add libhidapi implementation
|
||||
* stk500v2.c: Adapt #ifdefs for LIBHIDAPI
|
||||
* avrdude.1: Document change
|
||||
* doc/avrdude.texi: (Dito)
|
||||
|
||||
2018-01-13 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by David Mosberger-Tang
|
||||
patch #8924: Enable TPI for usbtiny
|
||||
* usbtiny.c: Extend to handle TPI targets
|
||||
* configure.ac: Probe for <netinet/in.h>
|
||||
|
||||
2018-01-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Yegor Yefremov:
|
||||
patch #9222: Enable silent build
|
||||
* configure.ac: Add AM_SILENT_RULES
|
||||
* Makefile.am: Document how to run "make" to get verbose
|
||||
build messages
|
||||
|
||||
2018-01-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by: Kjetil Kjeka:
|
||||
patch #9317: Support atmega64m1 as part
|
||||
* avrdue.conf.in (ATmega64M1): New entry.
|
||||
|
||||
2018-01-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Submitted David Griffith:
|
||||
patch #9530: Update URL to Ladyada's USBtinyISP page.
|
||||
* avrdude.conf.in (usbtiny): Update URL
|
||||
|
||||
2018-01-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Milan Kupcevic:
|
||||
patch #9423: Support ATtiny841 and ATtiny441
|
||||
bug #47376: ATtiny841 description missing in configuration file
|
||||
bug #49455: support for tiny441
|
||||
* avrdude.conf.in (ATtiny841, ATtiny441): New entries
|
||||
|
||||
2018-01-10 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Morten Engelhardt Olsen
|
||||
patch #9506: Script to create device configuration stub from Atmel ATDF files
|
||||
* tools/atdf-to-avrdude.xslt: New script
|
||||
|
||||
2018-01-10 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Jan Egil Ruud <janegil.ruud@microchip.com>
|
||||
patch #9507: Fix UPDI chip erase
|
||||
* lexer.l (family_id): New keyword.
|
||||
* config_gram.y: (Ditto)
|
||||
* doc/avrdude.texi: Document new keyword
|
||||
* avrdude.conf.in: Add family_id for avr8x devices
|
||||
* avr.c: Pass error code up.
|
||||
* jtag3.c: Pass error code from memory read up; implement
|
||||
jtag3_read_sib()
|
||||
* libavrdude.h: Add new items.
|
||||
* main.c: Implement different chip erase handling required
|
||||
for UPDI devices.
|
||||
|
||||
2018-01-10 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Jan Egil Ruud <janegil.ruud@microchip.com>
|
||||
patch #9506: Script to create device configuration stub from Atmel ATDF files
|
||||
* avrdude.conf.in (ATtiny202, ATtiny204, ATtiny402, ATtiny404)
|
||||
(ATtiny406, ATtiny804, ATtiny806, ATtiny807, ATtiny1604)
|
||||
(ATtiny1606, ATtiny1607, ATtiny212, ATtiny214, ATtiny412)
|
||||
(ATTiny414, ATtiny416, ATtiny417, ATtiny814, ATtiny816)
|
||||
(ATtiny1614, ATtiny1616, ATtiny3214, ATtiny3216, ATtiny3217)
|
||||
(ATmega3208, ATmega3209, ATmega4808, ATmega4809): New devices
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
2019-12-17 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Britton Kerin:
|
||||
bug #57428: [PATCH] document when 'arduino' or 'wiring' should be used, and -D requirement of latter
|
||||
* avrdude.1: Clarify
|
||||
* doc/avrdude.texi: (dito)
|
||||
|
||||
2019-01-05 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Milan Kupcevic:
|
||||
patch #9735: spelling error fix: psuedo -> pseudo
|
||||
* avrpart.c (avr_display): Spelling fix
|
||||
|
||||
2019-01-05 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Martino Facchin:
|
||||
patch #9728: Fix UsbTiny programmer
|
||||
* usbtiny.c (usbtiny_initialize): Only consider
|
||||
pgm->program_enable successful if returning 0
|
||||
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
2020-09-22 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Reported by Hannes Wallnöfer:
|
||||
* avrdude.conf.in (m32m1): add "size" parameter in "efuse"
|
||||
section
|
||||
|
||||
2020-09-20 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Björn Mellström
|
||||
patch #9744: Patch for ATMega324A support
|
||||
* avrdude.conf.in (m324a): New entry.
|
||||
|
||||
2020-09-20 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Ronald Sutherland
|
||||
patch #9811: ATmega328pb has efuse bit 3
|
||||
* avrdude.conf.in (m328pb): Add own efuse definition
|
||||
|
||||
2020-09-19 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Ralf Ramsauer
|
||||
patch #9816: Implement new programmer type: linuxspi
|
||||
* linuxspi.c: (New file.)
|
||||
* linuxspi.h: (New file.)
|
||||
* Makefile.am: Add new files
|
||||
* configure.ac: Add "linuxspi" --enable option
|
||||
* avrdude.conf.in: Add "linuxspi" programmer template
|
||||
* pgm_type.c: Include linuxspi programmer
|
||||
* doc/avrdude.texi: Document new programmer
|
||||
* avrdude.1: (Dito.)
|
||||
|
||||
2020-09-18 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Marcin Miskiewic
|
||||
patch #9963: UsbAsp 3 MHz patch for UsbAsp-flash firmware
|
||||
* usbasp.c: Implement 3 MHz clock option including capability check
|
||||
* usbasp.h: (Dito.)
|
||||
|
||||
2020-09-18 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Sven Schwermer:
|
||||
patch #9966: Add JTAGICE3 in UPDI mode
|
||||
* avrdude.conf (jtag3updi): New entry.
|
||||
|
||||
2020-09-18 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Joel Ray Holveck
|
||||
patch #9732: usbtiny_paged_load overflows buffer e.g. when reading EEPROM
|
||||
* usbtiny.c (usbtiny_paged_load, usbtiny_paged_write): ensure chunk
|
||||
does not overflow memory area
|
||||
|
||||
2020-09-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Adrian Klieber:
|
||||
patch #9818: correct typos in SVN rev 1429
|
||||
* buspirate.c: Fix typos.
|
||||
* fileio.c: Fix typos.
|
||||
* jtagmkII.c: Fix typos.
|
||||
* main.c: Fix typos.
|
||||
* term.c: Fix typos.
|
||||
* usbasp.c: Fix typos.
|
||||
* usbtiny.h: Fix typos.
|
||||
|
||||
2020-09-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Adrian Klieber:
|
||||
patch #9820: Fix some out-of-bounds/uninitialized issues
|
||||
* stk500v2.c (stk500v2_display): fix uninitialized variables
|
||||
* stk500v2.c (stk500v2_set_sck_period_mk2): fix loop limits
|
||||
* pickit2.c (pickit2_open): Use pgm->desc to store description (WIN32 only)
|
||||
* config_gram.y (K_PAGE_SIZE): ensure page_size is > 0
|
||||
* avrpart.c (avr_new_memtype): initialize page_size to 1
|
||||
|
||||
2020-09-10 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* config_gram.y (K_DESC): Enforce correct length in strncpy()
|
||||
* config_gram.y (K_MEMORY): (Dito.)
|
||||
|
||||
2020-09-10 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* avrpart.c (avr_new_memtype): ensure page_size is at least 1
|
||||
* config_gram.y (K_PAGE_SIZE): (Dito.)
|
||||
|
||||
2020-03-14 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by Adrian Klieber:
|
||||
patch #9819: Address several leaks in SVN rev 1429
|
||||
* config.c: Fix potential memory leak
|
||||
* jtagmkII.c: (Dito.)
|
||||
* stk500v2.c: (Dito.)
|
||||
* update.c: (Dito.)
|
||||
* windows/loaddrv.c: Fix file descriptor leak.
|
||||
|
||||
2020-03-11 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Submitted by: kautism
|
||||
patch #9893: [PATCH] Reader reads ftdi handle after main thread close it
|
||||
* ft245r.c: Wait until reader thread has been stopped before closing FTDI
|
||||
|
||||
2020-03-11 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Fix compiler warnings
|
||||
* avr.c: misleading indentation after spin loop
|
||||
* fileio.c: EM_AVR32 might be defined in system <libelf.h>
|
||||
@@ -1,57 +0,0 @@
|
||||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Use `./configure; make all; sudo make install' for Unix-like systems.
|
||||
|
||||
Depending on your requirements, the following prerequisites are
|
||||
needed:
|
||||
|
||||
* libelf including header files (for directly reading ELF files)
|
||||
* libusb 0.1 or 1.0 (or compatible), including header files
|
||||
* libftdi or libftdi1 (for direct access to FTDI devices)
|
||||
* libhidapi or libhid (for access to recent Atmel/Microchip dongles)
|
||||
|
||||
If the header and/or library files for one of those are found in
|
||||
non-default locations, you can add them to configure, e.g.
|
||||
|
||||
`./configure CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib'
|
||||
|
||||
as an example for MacOS using Macports. MacOS Brew requires
|
||||
|
||||
`./configure CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/Cellar'
|
||||
|
||||
instead. (LDFLAGS and CPPFLAGS can also be supplied as environment
|
||||
variables to configure.)
|
||||
|
||||
At the end of the configure script, a configuration summary is issued,
|
||||
like this:
|
||||
|
||||
Configuration summary:
|
||||
----------------------
|
||||
DO HAVE libelf
|
||||
DO HAVE libusb
|
||||
DO HAVE libusb_1_0
|
||||
DO HAVE libftdi1
|
||||
DON'T HAVE libftdi
|
||||
DON'T HAVE libhid
|
||||
DO HAVE libhidapi
|
||||
DO HAVE pthread
|
||||
DISABLED doc
|
||||
DISABLED parport
|
||||
DISABLED linuxgpio
|
||||
DISABLED linuxspi
|
||||
|
||||
Make sure all the features you are interested in have been found.
|
||||
|
||||
For BSD-like systems, using GNU make (gmake) is not mandatory but
|
||||
appears to cause less troubles with the quite complex dependency graph
|
||||
that might be produced by autoconf/automake.
|
||||
|
||||
For Windows, right now, a toolset like MinGW is required to compile
|
||||
AVRDUDE.
|
||||
|
||||
Obviously, a working C compiler is needed. Tested compilers so far
|
||||
include GCC (in various versions) and Clang. The compiler needs to
|
||||
support (at least) C99 language level. For MacOS, either Xcode or the
|
||||
(smaller) Xcode Command Line tools are needed, for Windows, some port
|
||||
of GCC that supports generating native Windows executables.
|
||||
+3
-5
@@ -149,10 +149,10 @@ libavrdude_a_SOURCES = \
|
||||
libavrdude.h \
|
||||
linuxgpio.c \
|
||||
linuxgpio.h \
|
||||
linuxspi.c \
|
||||
linuxspi.h \
|
||||
linux_ppdev.h \
|
||||
lists.c \
|
||||
micronucleus.c \
|
||||
micronucleus.h \
|
||||
my_ddk_hidsdi.h \
|
||||
par.c \
|
||||
par.h \
|
||||
@@ -190,9 +190,7 @@ libavrdude_a_SOURCES = \
|
||||
usbtiny.c \
|
||||
update.c \
|
||||
wiring.h \
|
||||
wiring.c \
|
||||
xbee.h \
|
||||
xbee.c
|
||||
wiring.c
|
||||
libavrdude_la_SOURCES = $(libavrdude_a_SOURCES)
|
||||
libavrdude_la_LDFLAGS = -version-info 1:0
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Approximate change log for AVRDUDE by version.
|
||||
(For more detailed changes, see the ChangeLog file.)
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Version 6.4:
|
||||
Current:
|
||||
|
||||
* Major changes compared to the previous version:
|
||||
|
||||
@@ -14,18 +14,9 @@ Version 6.4:
|
||||
debuggers (JTAGICE3 with firmware 3+, AtmelICE, EDBG, mEDBG)
|
||||
- UPDI support added (AVR8X family)
|
||||
- TPI support for USBtinyISP
|
||||
- TPI support for ft245r
|
||||
- TPI support for linuxgpio
|
||||
- AVR Doper uses libhidapi rather than raw libusb (patch #9033)
|
||||
- -P net:host:port can use IPv6 now (Posix systems only)
|
||||
- New configure option: -disable-libusb_1_0
|
||||
- extended UPDI device context (> 64 Ki flash)
|
||||
- major overhaul of ft245r driver (patch #9327/#9328)
|
||||
- some improvements in linuxspi driver
|
||||
- Use -B <bitclock> rather than -b <baudrate> for linuxspi driver
|
||||
- unused lock byte bits are not masked on read anymore
|
||||
- parport support disabled by default; configure with
|
||||
--enable-parport to explicitly enable it
|
||||
|
||||
* New devices supported:
|
||||
|
||||
@@ -39,23 +30,13 @@ Version 6.4:
|
||||
ATmega4809
|
||||
- ATtiny841, ATtiny441
|
||||
- ATmega64M1
|
||||
- ATmega324A
|
||||
- ATmega808, ATmega809, ATmega1608, ATmega1609, AVR DA, AVR DB
|
||||
- LGT8FX88P, LGT8FX168P, LGT8FX328P
|
||||
- ATmega324PB
|
||||
- ATmega8A
|
||||
|
||||
* New programmers supported:
|
||||
|
||||
- ehajo-isp (commercial version of USBtiny)
|
||||
- XplainedPro in UPDI mode
|
||||
- XplainedMini in UPDI mode
|
||||
- JTAGICE3 in UPDI mode
|
||||
- Atmel Powerdebugger in all modes (JTAG, PDI, UPDI, debugWIRE, ISP)
|
||||
- linuxspi (direct SPI bus e.g. on Raspberry Pi devices)
|
||||
- PICkit4, Snap, PKoB
|
||||
- iseavrprog
|
||||
- XBeeBoot
|
||||
|
||||
* Bugfixes:
|
||||
bug #47550: Linux GPIO broken
|
||||
@@ -63,27 +44,6 @@ Version 6.4:
|
||||
bug #48084: Avoid compiled-in timestamp for reproducible release builds
|
||||
bug #47376: ATtiny841 description missing in configuration file
|
||||
bug #49455: support for tiny441
|
||||
bug #57428: document when 'arduino' or 'wiring' should be used, and -D requirement of latter
|
||||
bug #58095: error setting efuse on atmega328pb variant
|
||||
bug #51409: Can't program EFUSE on ATmega32M1
|
||||
bug #60753: Patch #1436 breaks multiple programmer/device combinations on MacOS BigSur
|
||||
bug #59525: Bogus error message because Copy/Paste typo in stk500.c
|
||||
bug #58078: [PATCH] buspirate: remove compound literals (fixes GCC>=9)
|
||||
bug #57453: [PATCH] fix reference to nonexistant -m option by changing to -U
|
||||
bug #59227: Add new part. How does one get a part added to the CONF file?
|
||||
bug #55009: no efuses for m164a/pa
|
||||
bug #55734: USBtiny programming of ATmega328p broken by Patch #9278
|
||||
bug #58495: Add atmega324pb support to avrdude.conf.in
|
||||
bug #60863: avrftdi programming error probably caused by multiple, consecutive empty pages
|
||||
bug #50517: Reading fails if "immediate mode" for output file format is selected - fileio: invalid operation=1
|
||||
bug #50630: Erase Cycle Counter options ( -y -Y n ) should be removed from usage Message
|
||||
bug #48767: ser_drain() for TCP on Windows doesn't work
|
||||
bug #46759: avrdude 6.1 -> 6.2 regression: lock byte verification error
|
||||
bug #58440: linuxgpio PIN limit too low
|
||||
bug #55462: wrong programmer id check in jtag3_getsync() and jtag3_close()
|
||||
bug #58994: VPP PWM still enabled at the end of programming process
|
||||
bug #57338: if safemode has to change fuses avrdude should exit with non-zero exit code
|
||||
bug #60575: Permission denied on macOS Big Sur
|
||||
|
||||
* Patches:
|
||||
patch #9482: Add support for UPDI and AVR8X
|
||||
@@ -104,43 +64,8 @@ Version 6.4:
|
||||
patch #8311: Add IPv6 support to the -Pnet:host:port option
|
||||
patch #9542: Correct "usersig" on avr8x devices
|
||||
patch #8128: Added new option to configure.ac script
|
||||
patch #8444: Proposal for modifications in -B and -U command options managment (partially)
|
||||
patch #9735: spelling error fix: psuedo -> pseudo
|
||||
patch #9893: [PATCH] Reader reads ftdi handle after main thread close it
|
||||
patch #9819: Address several leaks in SVN rev 1429
|
||||
patch #9820: Fix some out-of-bounds/uninitialized issues
|
||||
patch #9818: correct typos in SVN rev 1429
|
||||
patch #9732: usbtiny_paged_load overflows buffer e.g. when reading EEPROM
|
||||
patch #9966: Add JTAGICE3 in UPDI mode
|
||||
patch #9963: UsbAsp 3 MHz patch for UsbAsp-flash firmware
|
||||
patch #9816: Implement new programmer type: linuxspi
|
||||
patch #9811: ATmega328pb has efuse bit 3
|
||||
patch #9744: Patch for ATMega324A support
|
||||
patch #10000: Add support for extended UPDI device context
|
||||
patch #9697: Add iseavrprog support
|
||||
patch #10017: uspasp / tpi: Automatically clear configuration byte (fuse) before writing it
|
||||
patch #8957: Allow reading prodsig memory from stk500v2 on xmega devices
|
||||
patch #9110: Let reserved fuse bits to be read as *don't care*
|
||||
patch #9253: Fix for giving terminal_mode commands more than 20 arguments
|
||||
patch #9320: fix TPI RESET in bitbang.c
|
||||
patch #9079: Fix ftdi_syncbb teardown (supersedes #9893, superseded by #9328)
|
||||
patch #9122: Fixed MISO sampling in ftdi_syncbb
|
||||
patch #9123: ftdi_syncbb: use FT245R_CYCLES in ft245r_set_bitclock()
|
||||
patch #8719: Support Over-the-Air bootloading with XBeeBoot
|
||||
patch #9757: Fix ATtiny817 Xplained Mini programmer
|
||||
patch #9327: ft245r.c: add TPI support (patches 1-4)
|
||||
patch #9328: ft245r.c: add TPI support (patches 5-7)
|
||||
patch #10027: linuxspi: Add reset pulse, according to AVR programming algorithm
|
||||
patch #10028: linuxspi: close() only when necessary
|
||||
patch #10029: linuxspi: Report GPIO_GET_LINEHANDLE_IOCTL errors
|
||||
patch #10030: linuxspi: Support inverted GPIO pin
|
||||
patch #10031: linuxspi: Support GPIO uAPI v2
|
||||
(no-id): Improve documentation of linuxspi driver, provide portname default
|
||||
(no-id): Use -B <bitclock> rather than -b <baudrate> for linuxspi driver
|
||||
patch #9304: [Bug #48767] Implemented WinSock variation of "ser_drain(...)" functionality
|
||||
patch #8996: Remove lock byte read mask (bug#21954, bug#46759)
|
||||
patch #8923: Enable TPI for linuxgpio
|
||||
patch #10153: linuxspi: Support "-E reset" and "-E noreset"
|
||||
patch #8444: Proposal for modifications in -B and -U command options managment
|
||||
(partially)
|
||||
|
||||
* Internals:
|
||||
- New avrdude.conf keyword "family_id", used to verify SIB attributes
|
||||
|
||||
@@ -80,12 +80,11 @@ int avr_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
||||
0xFF
|
||||
};
|
||||
|
||||
while (avr_tpi_poll_nvmbsy(pgm))
|
||||
;
|
||||
while (avr_tpi_poll_nvmbsy(pgm));
|
||||
|
||||
err = pgm->cmd_tpi(pgm, cmd, sizeof(cmd), NULL, 0);
|
||||
if(err)
|
||||
return err;
|
||||
err = pgm->cmd_tpi(pgm, cmd, sizeof(cmd), NULL, 0);
|
||||
if(err)
|
||||
return err;
|
||||
|
||||
while (avr_tpi_poll_nvmbsy(pgm));
|
||||
|
||||
@@ -330,7 +329,7 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
|
||||
memset(mem->buf, 0xff, mem->size);
|
||||
|
||||
/* supports "paged load" thru post-increment */
|
||||
if ((p->flags & AVRPART_HAS_TPI) && mem->page_size > 1 &&
|
||||
if ((p->flags & AVRPART_HAS_TPI) && mem->page_size != 0 &&
|
||||
pgm->cmd_tpi != NULL) {
|
||||
|
||||
while (avr_tpi_poll_nvmbsy(pgm));
|
||||
@@ -361,7 +360,7 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype,
|
||||
return avr_mem_hiaddr(mem);
|
||||
}
|
||||
|
||||
if (pgm->paged_load != NULL && mem->page_size > 1) {
|
||||
if (pgm->paged_load != NULL && mem->page_size != 0) {
|
||||
/*
|
||||
* the programmer supports a paged mode read
|
||||
*/
|
||||
@@ -863,7 +862,7 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
||||
}
|
||||
|
||||
|
||||
if ((p->flags & AVRPART_HAS_TPI) && m->page_size > 1 &&
|
||||
if ((p->flags & AVRPART_HAS_TPI) && m->page_size != 0 &&
|
||||
pgm->cmd_tpi != NULL) {
|
||||
|
||||
while (avr_tpi_poll_nvmbsy(pgm));
|
||||
@@ -903,7 +902,7 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
||||
return i;
|
||||
}
|
||||
|
||||
if (pgm->paged_write != NULL && m->page_size > 1) {
|
||||
if (pgm->paged_write != NULL && m->page_size != 0) {
|
||||
/*
|
||||
* the programmer supports a paged mode write
|
||||
*/
|
||||
@@ -1063,30 +1062,6 @@ int avr_signature(PROGRAMMER * pgm, AVRPART * p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t get_fuse_bitmask(AVRMEM * m) {
|
||||
uint8_t bitmask_r = 0;
|
||||
uint8_t bitmask_w = 0;
|
||||
int i;
|
||||
|
||||
if (!m || m->size > 1) {
|
||||
// not a fuse, compare bytes directly
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
// For fuses, only compare bytes that are actually written *and* read.
|
||||
for (i = 0; i < 32; i++) {
|
||||
if (m->op[AVR_OP_WRITE]->bit[i].type == AVR_CMDBIT_INPUT)
|
||||
bitmask_w |= (1 << m->op[AVR_OP_WRITE]->bit[i].bitno);
|
||||
if (m->op[AVR_OP_READ]->bit[i].type == AVR_CMDBIT_OUTPUT)
|
||||
bitmask_r |= (1 << m->op[AVR_OP_READ]->bit[i].bitno);
|
||||
}
|
||||
return bitmask_r & bitmask_w;
|
||||
}
|
||||
|
||||
int compare_memory_masked(AVRMEM * m, uint8_t b1, uint8_t b2) {
|
||||
uint8_t bitmask = get_fuse_bitmask(m);
|
||||
return (b1 & bitmask) != (b2 & bitmask);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify the memory buffer of p with that of v. The byte range of v,
|
||||
@@ -1133,30 +1108,11 @@ int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size)
|
||||
for (i=0; i<size; i++) {
|
||||
if ((b->tags[i] & TAG_ALLOCATED) != 0 &&
|
||||
buf1[i] != buf2[i]) {
|
||||
uint8_t bitmask = get_fuse_bitmask(a);
|
||||
if((buf1[i] & bitmask) != (buf2[i] & bitmask)) {
|
||||
// Mismatch is not just in unused bits
|
||||
avrdude_message(MSG_INFO, "%s: verification error, first mismatch at byte 0x%04x\n"
|
||||
"%s0x%02x != 0x%02x\n",
|
||||
progname, i,
|
||||
progbuf, buf1[i], buf2[i]);
|
||||
return -1;
|
||||
} else {
|
||||
// Mismatch is only in unused bits
|
||||
if ((buf1[i] | bitmask) != 0xff) {
|
||||
// Programmer returned unused bits as 0, must be the part/programmer
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: ignoring mismatch in unused bits of \"%s\"\n"
|
||||
"%s(0x%02x != 0x%02x). To prevent this warning fix the part\n"
|
||||
"%sor programmer definition in the config file.\n",
|
||||
progname, memtype, progbuf, buf1[i], buf2[i], progbuf);
|
||||
} else {
|
||||
// Programmer returned unused bits as 1, must be the user
|
||||
avrdude_message(MSG_INFO, "%s: WARNING: ignoring mismatch in unused bits of \"%s\"\n"
|
||||
"%s(0x%02x != 0x%02x). To prevent this warning set unused bits\n"
|
||||
"%sto 1 when writing (double check with your datasheet first).\n",
|
||||
progname, memtype, progbuf, buf1[i], buf2[i], progbuf);
|
||||
}
|
||||
}
|
||||
avrdude_message(MSG_INFO, "%s: verification error, first mismatch at byte 0x%04x\n"
|
||||
"%s0x%02x != 0x%02x\n",
|
||||
progname, i,
|
||||
progbuf, buf1[i], buf2[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.\"
|
||||
.\" avrdude - A Downloader/Uploader for AVR device programmers
|
||||
.\" Copyright (C) 2001, 2002, 2003, 2005 - 2020 Joerg Wunsch
|
||||
.\" Copyright (C) 2001, 2002, 2003, 2005 - 2016 Joerg Wunsch
|
||||
.\"
|
||||
.\" This program is free software; you can redistribute it and/or modify
|
||||
.\" it under the terms of the GNU General Public License as published by
|
||||
@@ -18,7 +18,7 @@
|
||||
.\"
|
||||
.\" $Id$
|
||||
.\"
|
||||
.Dd DATE November 22, 2021
|
||||
.Dd DATE February 15, 2016
|
||||
.Os
|
||||
.Dt AVRDUDE 1
|
||||
.Sh NAME
|
||||
@@ -109,31 +109,6 @@ some resistors in series or better yet use a 3-state buffer driver like
|
||||
the 74HC244. Have a look at http://kolev.info/avrdude-linuxgpio for a more
|
||||
detailed tutorial about using this programmer type.
|
||||
.Pp
|
||||
Under a Linux installation with direct access to the SPI bus and GPIO
|
||||
pins, such as would be found on a Raspberry Pi, the ``linuxspi''
|
||||
programmer type can be used to directly connect to and program a chip
|
||||
using the built in interfaces on the computer. The requirements to use
|
||||
this type are that an SPI interface is exposed along with one GPIO
|
||||
pin. The GPIO serves as the reset output since the Linux SPI drivers
|
||||
do not hold slave select down when a transfer is not occuring and thus
|
||||
it cannot be used as the reset pin. A readily available level
|
||||
translator should be used between the SPI bus/reset GPIO and the chip
|
||||
to avoid potentially damaging the computer's SPI controller in the
|
||||
event that the chip is running at 5V and the SPI runs at 3.3V. The
|
||||
GPIO chosen for reset can be configured in the avrdude configuration
|
||||
file using the
|
||||
.Li reset
|
||||
entry under the linuxspi programmer, or
|
||||
directly in the port specification. An external pull-up resistor
|
||||
should be connected between the AVR's reset pin and Vcc. If Vcc is not
|
||||
the same as the SPI voltage, this should be done on the AVR side of
|
||||
the level translator to protect the hardware from damage.
|
||||
.Pp
|
||||
The
|
||||
.Fl P Ar portname
|
||||
option for this programmer defaults to
|
||||
.Li /dev/spidev0.0:/dev/gpiochip0 .
|
||||
.Pp
|
||||
Atmel's STK500 programmer is also supported and connects to a serial
|
||||
port.
|
||||
Both, firmware versions 1.x and 2.x can be handled, but require a
|
||||
@@ -142,15 +117,12 @@ Using firmware version 2, high-voltage programming is also supported,
|
||||
both parallel and serial
|
||||
(programmer types stk500pp and stk500hvsp).
|
||||
.Pp
|
||||
Wiring boards (e.g. Arduino Mega 2560 Rev3) are supported, utilizing STK500
|
||||
V2.x protocol, but a simple DTR/RTS toggle is used to set the boards into
|
||||
programming mode. The programmer type is ``wiring''. Note that the -D option
|
||||
will likely be required in this case, because the bootloader will rewrite the
|
||||
program memory, but no true chip erase can be performed.
|
||||
Wiring boards are supported, utilizing STK500 V2.x protocol, but
|
||||
a simple DTR/RTS toggle is used to set the boards into programming mode.
|
||||
The programmer type is ``wiring''.
|
||||
.Pp
|
||||
The Arduino (which is very similar to the STK500 1.x) is supported via
|
||||
its own programmer type specification ``arduino''. This programmer works for
|
||||
the Arduino Uno Rev3.
|
||||
its own programmer type specification ``arduino''.
|
||||
.Pp
|
||||
The BusPirate is a versatile tool that can also be used as an AVR programmer.
|
||||
A single BusPirate can be connected to up to 3 independent AVRs. See
|
||||
@@ -216,12 +188,6 @@ The Atmel DFU bootloader is supported in both, FLIP protocol version 1
|
||||
(AT90USB* and ATmega*U* devices), as well as version 2 (Xmega devices).
|
||||
See below for some hints about FLIP version 1 protocol behaviour.
|
||||
.Pp
|
||||
The MPLAB(R) PICkit 4, MPLAB(R) SNAP, and Curiosity Nano boards are
|
||||
supported in UPDI mode. The Curiosity Nano board is dubbed
|
||||
.Dq PICkit on Board ,
|
||||
thus the name
|
||||
.Pa pkobn_updi .
|
||||
.Pp
|
||||
Input files can be provided, and output files can be written in
|
||||
different file formats, such as raw binary files containing the data
|
||||
to download to the chip, Intel hex format, or Motorola S-record
|
||||
@@ -247,7 +213,7 @@ lock bits can be programmed as well. These are implemented within
|
||||
.Nm
|
||||
as separate memory types and can be programmed using data from a file
|
||||
(see the
|
||||
.Fl U
|
||||
.Fl m
|
||||
option) or from terminal mode (see the
|
||||
.Ar dump
|
||||
and
|
||||
@@ -528,22 +494,6 @@ location in the USB hierarchy. See the the respective
|
||||
.Em Troubleshooting
|
||||
entry in the detailed documentation for examples.
|
||||
.Pp
|
||||
For the XBee programmer the target MCU is to be programmed wirelessly over a
|
||||
ZigBee mesh using the XBeeBoot bootloader. The ZigBee 64-bit address for the
|
||||
target MCU's own XBee device must be supplied as a 16-character hexadecimal
|
||||
value as a
|
||||
.Ar port
|
||||
prefix, followed by the
|
||||
.Ql @
|
||||
character, and the serial device to connect to a second directly contactable
|
||||
XBee device associated with the same mesh (with a default baud rate of 9600).
|
||||
This may look similar to:
|
||||
.Pa 0013a20000000001@/dev/tty.serial .
|
||||
.Pp
|
||||
For diagnostic purposes, if the target MCU with an XBeeBoot bootloader is
|
||||
connected directly to the serial port, the 64-bit address field can be
|
||||
omitted. In this mode the default baud rate will be 19200.
|
||||
.Pp
|
||||
For programmers that attach to a serial port using some kind of
|
||||
higher level protocol (as opposed to bit-bang style programmers),
|
||||
.Ar port
|
||||
@@ -1113,23 +1063,6 @@ Programmer will erase configuration section with option
|
||||
(chip erase), rather than entire chip.
|
||||
Only applicable to TPI devices (ATtiny 4/5/9/10/20/40).
|
||||
.El
|
||||
.It Ar xbee
|
||||
Extended parameters:
|
||||
.Bl -tag -offset indent -width indent
|
||||
.It Ar xbeeresetpin=<1..7>
|
||||
Select the XBee pin DIO<1..7> that is connected to the MCU's
|
||||
.Ql /RESET
|
||||
line. The programmer needs to know which DIO pin to use to reset into the
|
||||
bootloader. The default (3) is the DIO3 pin (XBee pin 17), but some
|
||||
commercial products use a different XBee pin.
|
||||
.Pp
|
||||
The remaining two necessary XBee-to-MCU connections are not selectable - the
|
||||
XBee DOUT pin (pin 2) must be connected to the MCU's
|
||||
.Ql RXD
|
||||
line, and the XBee DIN pin (pin 3) must be connected to the MCU's
|
||||
.Ql TXD
|
||||
line.
|
||||
.El
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -offset indent -width /dev/ppi0XXX
|
||||
|
||||
+98
-1166
File diff suppressed because it is too large.
Load diff
@@ -42,6 +42,10 @@ int avrdude_message(const int msglvl, const char *format, ...);
|
||||
#include "ac_cfg.h"
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "msvc/msvc_compat.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30104.148
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "avrdude", "avrdude.vcxproj", "{718DDC4C-324E-485F-BE18-2D211659A2F4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libelf", "external\libelf\libelf.vcxproj", "{A2D07885-A0D1-473B-83B2-209CD008EE8F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhidapi", "external\libhidapi\libhidapi.vcxproj", "{17054837-6AE6-44D7-914D-9625EDEF4657}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb", "external\libusb\libusb.vcxproj", "{22615EC5-9DBC-4538-9C01-2CD535B3810B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libftdi1", "external\libftdi1\libftdi1.vcxproj", "{632649AB-A351-46D4-A81F-1D6E9A819A5C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{743FA5F6-A0D7-46F7-B73D-632B64C732FB}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
.travis.yml = .travis.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{718DDC4C-324E-485F-BE18-2D211659A2F4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{718DDC4C-324E-485F-BE18-2D211659A2F4}.Debug|x64.Build.0 = Debug|x64
|
||||
{718DDC4C-324E-485F-BE18-2D211659A2F4}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{718DDC4C-324E-485F-BE18-2D211659A2F4}.Debug|x86.Build.0 = Debug|Win32
|
||||
{718DDC4C-324E-485F-BE18-2D211659A2F4}.Release|x64.ActiveCfg = Release|x64
|
||||
{718DDC4C-324E-485F-BE18-2D211659A2F4}.Release|x64.Build.0 = Release|x64
|
||||
{718DDC4C-324E-485F-BE18-2D211659A2F4}.Release|x86.ActiveCfg = Release|Win32
|
||||
{718DDC4C-324E-485F-BE18-2D211659A2F4}.Release|x86.Build.0 = Release|Win32
|
||||
{A2D07885-A0D1-473B-83B2-209CD008EE8F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A2D07885-A0D1-473B-83B2-209CD008EE8F}.Debug|x64.Build.0 = Debug|x64
|
||||
{A2D07885-A0D1-473B-83B2-209CD008EE8F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{A2D07885-A0D1-473B-83B2-209CD008EE8F}.Debug|x86.Build.0 = Debug|Win32
|
||||
{A2D07885-A0D1-473B-83B2-209CD008EE8F}.Release|x64.ActiveCfg = Release|x64
|
||||
{A2D07885-A0D1-473B-83B2-209CD008EE8F}.Release|x64.Build.0 = Release|x64
|
||||
{A2D07885-A0D1-473B-83B2-209CD008EE8F}.Release|x86.ActiveCfg = Release|Win32
|
||||
{A2D07885-A0D1-473B-83B2-209CD008EE8F}.Release|x86.Build.0 = Release|Win32
|
||||
{17054837-6AE6-44D7-914D-9625EDEF4657}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{17054837-6AE6-44D7-914D-9625EDEF4657}.Debug|x64.Build.0 = Debug|x64
|
||||
{17054837-6AE6-44D7-914D-9625EDEF4657}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{17054837-6AE6-44D7-914D-9625EDEF4657}.Debug|x86.Build.0 = Debug|Win32
|
||||
{17054837-6AE6-44D7-914D-9625EDEF4657}.Release|x64.ActiveCfg = Release|x64
|
||||
{17054837-6AE6-44D7-914D-9625EDEF4657}.Release|x64.Build.0 = Release|x64
|
||||
{17054837-6AE6-44D7-914D-9625EDEF4657}.Release|x86.ActiveCfg = Release|Win32
|
||||
{17054837-6AE6-44D7-914D-9625EDEF4657}.Release|x86.Build.0 = Release|Win32
|
||||
{22615EC5-9DBC-4538-9C01-2CD535B3810B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{22615EC5-9DBC-4538-9C01-2CD535B3810B}.Debug|x64.Build.0 = Debug|x64
|
||||
{22615EC5-9DBC-4538-9C01-2CD535B3810B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{22615EC5-9DBC-4538-9C01-2CD535B3810B}.Debug|x86.Build.0 = Debug|Win32
|
||||
{22615EC5-9DBC-4538-9C01-2CD535B3810B}.Release|x64.ActiveCfg = Release|x64
|
||||
{22615EC5-9DBC-4538-9C01-2CD535B3810B}.Release|x64.Build.0 = Release|x64
|
||||
{22615EC5-9DBC-4538-9C01-2CD535B3810B}.Release|x86.ActiveCfg = Release|Win32
|
||||
{22615EC5-9DBC-4538-9C01-2CD535B3810B}.Release|x86.Build.0 = Release|Win32
|
||||
{632649AB-A351-46D4-A81F-1D6E9A819A5C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{632649AB-A351-46D4-A81F-1D6E9A819A5C}.Debug|x64.Build.0 = Debug|x64
|
||||
{632649AB-A351-46D4-A81F-1D6E9A819A5C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{632649AB-A351-46D4-A81F-1D6E9A819A5C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{632649AB-A351-46D4-A81F-1D6E9A819A5C}.Release|x64.ActiveCfg = Release|x64
|
||||
{632649AB-A351-46D4-A81F-1D6E9A819A5C}.Release|x64.Build.0 = Release|x64
|
||||
{632649AB-A351-46D4-A81F-1D6E9A819A5C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{632649AB-A351-46D4-A81F-1D6E9A819A5C}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6126B4FE-5EEC-46A7-934A-F3B0314F6B75}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
+279
@@ -0,0 +1,279 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{718DDC4C-324E-485F-BE18-2D211659A2F4}</ProjectGuid>
|
||||
<RootNamespace>avrdude</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32NATIVE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;LOG_APPNAME="avrdude";WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>msvc;msvc\generated;.;external\libelf\include;external\libusb\include;external\libhidapi\include;external\libftdi1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32NATIVE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;LOG_APPNAME="avrdude";_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>msvc;msvc\generated;.;external\libelf\include;external\libusb\include;external\libhidapi\include;external\libftdi1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32NATIVE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;LOG_APPNAME="avrdude";WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>msvc;msvc\generated;.;external\libelf\include;external\libusb\include;external\libhidapi\include;external\libftdi1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32NATIVE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;LOG_APPNAME="avrdude";NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>msvc;msvc\generated;.;external\libelf\include;external\libusb\include;external\libhidapi\include;external\libftdi1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="arduino.c" />
|
||||
<ClCompile Include="avr.c" />
|
||||
<ClCompile Include="avr910.c" />
|
||||
<ClCompile Include="avrftdi.c" />
|
||||
<ClCompile Include="avrftdi_tpi.c" />
|
||||
<ClCompile Include="avrpart.c" />
|
||||
<ClCompile Include="bitbang.c" />
|
||||
<ClCompile Include="buspirate.c" />
|
||||
<ClCompile Include="butterfly.c" />
|
||||
<ClCompile Include="config.c" />
|
||||
<ClCompile Include="confwin.c" />
|
||||
<ClCompile Include="crc16.c" />
|
||||
<ClCompile Include="dfu.c" />
|
||||
<ClCompile Include="fileio.c" />
|
||||
<ClCompile Include="flip1.c" />
|
||||
<ClCompile Include="flip2.c" />
|
||||
<ClCompile Include="ft245r.c" />
|
||||
<ClCompile Include="jtag3.c" />
|
||||
<ClCompile Include="jtagmkI.c" />
|
||||
<ClCompile Include="jtagmkII.c" />
|
||||
<ClCompile Include="linuxgpio.c" />
|
||||
<ClCompile Include="lists.c" />
|
||||
<ClCompile Include="main.c" />
|
||||
<ClCompile Include="micronucleus.c" />
|
||||
<ClCompile Include="msvc\pthread.cpp" />
|
||||
<ClCompile Include="msvc\semaphore.cpp" />
|
||||
<ClCompile Include="par.c" />
|
||||
<ClCompile Include="pgm.c" />
|
||||
<ClCompile Include="pgm_type.c" />
|
||||
<ClCompile Include="pickit2.c" />
|
||||
<ClCompile Include="pindefs.c" />
|
||||
<ClCompile Include="ppi.c" />
|
||||
<ClCompile Include="ppiwin.c" />
|
||||
<ClCompile Include="safemode.c" />
|
||||
<ClCompile Include="serbb_posix.c" />
|
||||
<ClCompile Include="serbb_win32.c" />
|
||||
<ClCompile Include="ser_avrdoper.c" />
|
||||
<ClCompile Include="ser_posix.c" />
|
||||
<ClCompile Include="ser_win32.c" />
|
||||
<ClCompile Include="stk500.c" />
|
||||
<ClCompile Include="stk500generic.c" />
|
||||
<ClCompile Include="stk500v2.c" />
|
||||
<ClCompile Include="term.c" />
|
||||
<ClCompile Include="update.c" />
|
||||
<ClCompile Include="usbasp.c" />
|
||||
<ClCompile Include="usbtiny.c" />
|
||||
<ClCompile Include="usb_hidapi.c" />
|
||||
<ClCompile Include="usb_libusb.c" />
|
||||
<ClCompile Include="wiring.c" />
|
||||
<ClCompile Include="msvc\generated\config_gram.c" />
|
||||
<ClCompile Include="msvc\generated\lexer.c">
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CONFIG_DIR=".";__STDC_VERSION__=199901L;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CONFIG_DIR=".";__STDC_VERSION__=199901L;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CONFIG_DIR=".";__STDC_VERSION__=199901L;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CONFIG_DIR=".";__STDC_VERSION__=199901L;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="msvc\getopt.c" />
|
||||
<ClCompile Include="msvc\gettimeofday.c" />
|
||||
<ClCompile Include="msvc\unistd.cpp" />
|
||||
<ClCompile Include="msvc\usb_com_helper.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="arduino.h" />
|
||||
<ClInclude Include="avr910.h" />
|
||||
<ClInclude Include="avrdude.h" />
|
||||
<ClInclude Include="avrftdi.h" />
|
||||
<ClInclude Include="avrftdi_private.h" />
|
||||
<ClInclude Include="avrftdi_tpi.h" />
|
||||
<ClInclude Include="bitbang.h" />
|
||||
<ClInclude Include="buspirate.h" />
|
||||
<ClInclude Include="butterfly.h" />
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="crc16.h" />
|
||||
<ClInclude Include="dfu.h" />
|
||||
<ClInclude Include="flip1.h" />
|
||||
<ClInclude Include="flip2.h" />
|
||||
<ClInclude Include="freebsd_ppi.h" />
|
||||
<ClInclude Include="ft245r.h" />
|
||||
<ClInclude Include="jtag3.h" />
|
||||
<ClInclude Include="jtag3_private.h" />
|
||||
<ClInclude Include="jtagmkI.h" />
|
||||
<ClInclude Include="jtagmkII.h" />
|
||||
<ClInclude Include="jtagmkII_private.h" />
|
||||
<ClInclude Include="jtagmkI_private.h" />
|
||||
<ClInclude Include="libavrdude.h" />
|
||||
<ClInclude Include="linuxgpio.h" />
|
||||
<ClInclude Include="linux_ppdev.h" />
|
||||
<ClInclude Include="micronucleus.h" />
|
||||
<ClInclude Include="msvc\IntegerHandleMap.h" />
|
||||
<ClInclude Include="msvc\pthread.h" />
|
||||
<ClInclude Include="msvc\ReaderWriterLock.h" />
|
||||
<ClInclude Include="msvc\semaphore.h" />
|
||||
<ClInclude Include="my_ddk_hidsdi.h" />
|
||||
<ClInclude Include="par.h" />
|
||||
<ClInclude Include="pickit2.h" />
|
||||
<ClInclude Include="ppi.h" />
|
||||
<ClInclude Include="serbb.h" />
|
||||
<ClInclude Include="ser_win32.h" />
|
||||
<ClInclude Include="solaris_ecpp.h" />
|
||||
<ClInclude Include="stk500.h" />
|
||||
<ClInclude Include="stk500generic.h" />
|
||||
<ClInclude Include="stk500v2.h" />
|
||||
<ClInclude Include="stk500v2_private.h" />
|
||||
<ClInclude Include="stk500_private.h" />
|
||||
<ClInclude Include="term.h" />
|
||||
<ClInclude Include="tpi.h" />
|
||||
<ClInclude Include="usbasp.h" />
|
||||
<ClInclude Include="usbdevs.h" />
|
||||
<ClInclude Include="usbtiny.h" />
|
||||
<ClInclude Include="wiring.h" />
|
||||
<ClInclude Include="msvc\generated\ac_cfg.h" />
|
||||
<ClInclude Include="msvc\generated\config_gram.h" />
|
||||
<ClInclude Include="msvc\getopt.h" />
|
||||
<ClInclude Include="msvc\msvc_compat.h" />
|
||||
<ClInclude Include="msvc\sys\time.h" />
|
||||
<ClInclude Include="msvc\unistd.h" />
|
||||
<ClInclude Include="msvc\usb_com_helper.h" />
|
||||
<ClInclude Include="msvc\usb_com_locator.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="external\libelf\libelf.vcxproj">
|
||||
<Project>{a2d07885-a0d1-473b-83b2-209cd008ee8f}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="external\libftdi1\libftdi1.vcxproj">
|
||||
<Project>{632649ab-a351-46d4-a81f-1d6e9a819a5c}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="external\libhidapi\libhidapi.vcxproj">
|
||||
<Project>{17054837-6ae6-44d7-914d-9625edef4657}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="external\libusb\libusb.vcxproj">
|
||||
<Project>{22615ec5-9dbc-4538-9c01-2cd535b3810b}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,359 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="2 Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="1 Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="3 Generated Files">
|
||||
<UniqueIdentifier>{be5ce6e6-223e-4d41-8915-29103d899c5a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="4 msvc">
|
||||
<UniqueIdentifier>{dbbd7498-e1e9-4d80-b91f-137dc5b988f1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="4 msvc\sys">
|
||||
<UniqueIdentifier>{1cc9d4fb-f03f-48cb-8af7-3e96681dc03b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="arduino.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="avr.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="avr910.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="avrftdi.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="avrftdi_tpi.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="avrpart.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="bitbang.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="buspirate.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="butterfly.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="config.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="confwin.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crc16.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="dfu.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fileio.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="flip1.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="flip2.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ft245r.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="jtag3.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="jtagmkI.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="jtagmkII.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="linuxgpio.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lists.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="micronucleus.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="par.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pgm.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pgm_type.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pickit2.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pindefs.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ppi.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ppiwin.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="safemode.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ser_avrdoper.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ser_posix.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ser_win32.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="serbb_posix.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="serbb_win32.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stk500.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stk500generic.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stk500v2.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="term.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="update.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="usb_hidapi.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="usb_libusb.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="usbasp.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="usbtiny.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wiring.c">
|
||||
<Filter>1 Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="msvc\generated\config_gram.c">
|
||||
<Filter>3 Generated Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="msvc\generated\lexer.c">
|
||||
<Filter>3 Generated Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="msvc\getopt.c">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="msvc\gettimeofday.c">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="msvc\unistd.cpp">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="msvc\usb_com_helper.cpp">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="msvc\pthread.cpp">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="msvc\semaphore.cpp">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="arduino.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="avr910.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="avrdude.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="avrftdi.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="avrftdi_private.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="avrftdi_tpi.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="bitbang.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="buspirate.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="butterfly.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="config.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crc16.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="dfu.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="flip1.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="flip2.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="freebsd_ppi.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ft245r.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jtag3.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jtag3_private.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jtagmkI.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jtagmkI_private.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jtagmkII.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jtagmkII_private.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="libavrdude.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="linux_ppdev.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="linuxgpio.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="micronucleus.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="my_ddk_hidsdi.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="par.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pickit2.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ppi.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ser_win32.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="serbb.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="solaris_ecpp.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stk500.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stk500_private.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stk500generic.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stk500v2.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stk500v2_private.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="term.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tpi.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="usbasp.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="usbdevs.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="usbtiny.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="wiring.h">
|
||||
<Filter>2 Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\generated\ac_cfg.h">
|
||||
<Filter>3 Generated Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\generated\config_gram.h">
|
||||
<Filter>3 Generated Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\getopt.h">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\unistd.h">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\sys\time.h">
|
||||
<Filter>4 msvc\sys</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\msvc_compat.h">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\usb_com_helper.h">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\usb_com_locator.h">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\pthread.h">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\semaphore.h">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\ReaderWriterLock.h">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="msvc\IntegerHandleMap.h">
|
||||
<Filter>4 msvc</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -364,7 +364,11 @@ static int avrftdi_transmit_bb(PROGRAMMER * pgm, unsigned char mode, const unsig
|
||||
// (8*2) outputs per data byte, 6 transmit bytes per output (SET_BITS_LOW/HIGH),
|
||||
// (8*1) inputs per data byte, 2 transmit bytes per input (GET_BITS_LOW/HIGH),
|
||||
// 1x SEND_IMMEDIATE
|
||||
#ifdef _MSC_VER
|
||||
unsigned char* send_buffer = _alloca((8 * 2 * 6) * transfer_size + (8 * 1 * 2) * transfer_size + 7);
|
||||
#else
|
||||
unsigned char send_buffer[(8*2*6)*transfer_size+(8*1*2)*transfer_size+7];
|
||||
#endif
|
||||
int len = 0;
|
||||
int i;
|
||||
|
||||
@@ -384,7 +388,11 @@ static int avrftdi_transmit_bb(PROGRAMMER * pgm, unsigned char mode, const unsig
|
||||
|
||||
E(ftdi_write_data(pdata->ftdic, send_buffer, len) != len, pdata->ftdic);
|
||||
if (mode & MPSSE_DO_READ) {
|
||||
#ifdef _MSC_VER
|
||||
unsigned char* recv_buffer = _alloca(2 * 16 * transfer_size);
|
||||
#else
|
||||
unsigned char recv_buffer[2*16*transfer_size];
|
||||
#endif
|
||||
int n;
|
||||
int k = 0;
|
||||
do {
|
||||
@@ -949,10 +957,16 @@ static int avrftdi_eeprom_read(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m,
|
||||
unsigned int page_size, unsigned int addr, unsigned int len)
|
||||
{
|
||||
unsigned char cmd[4];
|
||||
unsigned char buffer[len], *bufptr = buffer;
|
||||
unsigned int add;
|
||||
#ifdef _MSC_VER
|
||||
unsigned char* buffer = _alloca(len);
|
||||
unsigned char* bufptr = buffer;
|
||||
#else
|
||||
unsigned char buffer[len], *bufptr = buffer;
|
||||
#endif
|
||||
|
||||
memset(buffer, 0, len);
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
for (add = addr; add < addr + len; add++)
|
||||
{
|
||||
memset(cmd, 0, sizeof(cmd));
|
||||
@@ -980,9 +994,14 @@ static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||
|
||||
unsigned char poll_byte;
|
||||
unsigned char *buffer = &m->buf[addr];
|
||||
#ifdef _MSC_VER
|
||||
unsigned char* buf = _alloca(4 * len + 4);
|
||||
unsigned char* bufptr = buf;
|
||||
#else
|
||||
unsigned char buf[4*len+4], *bufptr = buf;
|
||||
#endif
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memset(buf, 0, 4 * len + 4);
|
||||
|
||||
/* pre-check opcodes */
|
||||
if (m->op[AVR_OP_LOADPAGE_LO] == NULL) {
|
||||
@@ -1045,6 +1064,16 @@ static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||
bufptr += 4;
|
||||
}
|
||||
|
||||
buf_size = bufptr - buf;
|
||||
|
||||
if(verbose > TRACE)
|
||||
buf_dump(buf, buf_size, "command buffer", 0, 16*2);
|
||||
|
||||
log_info("Transmitting buffer of size: %d\n", buf_size);
|
||||
if (0 > avrftdi_transmit(pgm, MPSSE_DO_WRITE, buf, buf, buf_size))
|
||||
return -1;
|
||||
|
||||
bufptr = buf;
|
||||
/* find a poll byte. we cannot poll a value of 0xff, so look
|
||||
* for a value != 0xff
|
||||
*/
|
||||
@@ -1054,17 +1083,6 @@ static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||
|
||||
if((poll_index < addr + len) && m->buf[poll_index] != 0xff)
|
||||
{
|
||||
buf_size = bufptr - buf;
|
||||
|
||||
if(verbose > TRACE)
|
||||
buf_dump(buf, buf_size, "command buffer", 0, 16*2);
|
||||
|
||||
log_info("Transmitting buffer of size: %d\n", buf_size);
|
||||
if (0 > avrftdi_transmit(pgm, MPSSE_DO_WRITE, buf, buf, buf_size))
|
||||
return -1;
|
||||
|
||||
bufptr = buf;
|
||||
|
||||
log_info("Using m->buf[%d] = 0x%02x as polling value ", poll_index,
|
||||
m->buf[poll_index]);
|
||||
/* poll page write ready */
|
||||
@@ -1078,7 +1096,9 @@ static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||
}
|
||||
else
|
||||
{
|
||||
log_warn("Skipping empty page (containing only 0xff bytes)\n");
|
||||
log_warn("No suitable byte (!=0xff) for polling found.\n");
|
||||
log_warn("Trying to sleep instead, but programming errors may occur.\n");
|
||||
log_warn("Be sure to verify programmed memory (no -V option)\n");
|
||||
/* TODO sync write */
|
||||
/* sleep */
|
||||
usleep((m->max_write_delay));
|
||||
@@ -1097,14 +1117,18 @@ static int avrftdi_flash_read(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||
int byte, word;
|
||||
int use_lext_address = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL;
|
||||
unsigned int address = addr/2;
|
||||
|
||||
unsigned char o_buf[4*len+4];
|
||||
unsigned char i_buf[4*len+4];
|
||||
unsigned int index;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
unsigned char* o_buf = _alloca(4 * len + 4);
|
||||
unsigned char* i_buf = _alloca(4 * len + 4);
|
||||
#else
|
||||
unsigned char o_buf[4*len+4];
|
||||
unsigned char i_buf[4*len+4];
|
||||
#endif
|
||||
|
||||
memset(o_buf, 0, sizeof(o_buf));
|
||||
memset(i_buf, 0, sizeof(i_buf));
|
||||
memset(o_buf, 0, 4 * len + 4);
|
||||
memset(i_buf, 0, 4 * len + 4);
|
||||
|
||||
/* pre-check opcodes */
|
||||
if (m->op[AVR_OP_READ_LO] == NULL) {
|
||||
|
||||
+5
-1
@@ -12,11 +12,15 @@
|
||||
# include <libftdi1/ftdi.h>
|
||||
# undef HAVE_LIBFTDI_TYPE_232H
|
||||
# define HAVE_LIBFTDI_TYPE_232H 1
|
||||
#elif defined(HAVE_LIBFTDI) && defined(HAVE_USB_H)
|
||||
#elif defined(HAVE_LIBFTDI) && (defined(HAVE_USB_H) || defined(_MSC_VER))
|
||||
/* ftdi.h includes usb.h */
|
||||
#include <ftdi.h>
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
#pragma message("No libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.")
|
||||
#else
|
||||
#warning No libftdi or libusb support. Install libftdi1/libusb-1.0 or libftdi/libusb and run configure/make again.
|
||||
#endif
|
||||
#define DO_NOT_BUILD_AVRFTDI
|
||||
#endif
|
||||
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
#include "avrftdi_tpi.h"
|
||||
#include "avrftdi_private.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
#define __builtin_popcount __popcnt
|
||||
#endif
|
||||
|
||||
#ifndef DO_NOT_BUILD_AVRFTDI
|
||||
|
||||
static void avrftdi_tpi_disable(PROGRAMMER *);
|
||||
|
||||
@@ -254,7 +254,6 @@ AVRMEM * avr_new_memtype(void)
|
||||
}
|
||||
|
||||
memset(m, 0, sizeof(*m));
|
||||
m->page_size = 1; // ensure not 0
|
||||
|
||||
return m;
|
||||
}
|
||||
@@ -646,7 +645,7 @@ void avr_display(FILE * f, AVRPART * p, const char * prefix, int verbose)
|
||||
prefix, avr_pin_name(p->retry_pulse),
|
||||
prefix, (p->flags & AVRPART_SERIALOK) ? "yes" : "no",
|
||||
prefix, (p->flags & AVRPART_PARALLELOK) ?
|
||||
((p->flags & AVRPART_PSEUDOPARALLEL) ? "pseudo" : "yes") : "no",
|
||||
((p->flags & AVRPART_PSEUDOPARALLEL) ? "psuedo" : "yes") : "no",
|
||||
prefix, p->timeout,
|
||||
prefix, p->stabdelay,
|
||||
prefix, p->cmdexedelay,
|
||||
|
||||
@@ -542,10 +542,7 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
|
||||
|
||||
/* bring RESET high first */
|
||||
pgm->setpin(pgm, PIN_AVR_RESET, 1);
|
||||
usleep(128000); /* wait t_TOUT (32-128ms) */
|
||||
|
||||
/* RESET must be LOW in case the existing code is driving the TPI pins: */
|
||||
pgm->setpin(pgm, PIN_AVR_RESET, 0);
|
||||
usleep(1000);
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "doing MOSI-MISO link check\n");
|
||||
|
||||
|
||||
+26
-22
@@ -493,31 +493,35 @@ static void buspirate_reset_from_binmode(struct programmer_t *pgm)
|
||||
|
||||
static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||
{
|
||||
struct submode {
|
||||
const struct submode {
|
||||
const char *name; /* Name of mode for user messages */
|
||||
char enter; /* Command to enter from base binary mode */
|
||||
const char *entered_format; /* Response, for "scanf" */
|
||||
char config; /* Command to setup submode parameters */
|
||||
} submode;
|
||||
} *submode;
|
||||
|
||||
if (pgm->flag & BP_FLAG_XPARM_RAWFREQ) {
|
||||
submode.name = "Raw-wire";
|
||||
submode.enter = 0x05;
|
||||
submode.entered_format = "RAW%1d";
|
||||
submode.config = 0x8C;
|
||||
submode = &(const struct submode){
|
||||
.name = "Raw-wire",
|
||||
.enter = 0x05,
|
||||
.entered_format = "RAW%1d",
|
||||
.config = 0x8C,
|
||||
};
|
||||
pgm->flag |= BP_FLAG_NOPAGEDWRITE;
|
||||
pgm->flag |= BP_FLAG_NOPAGEDREAD;
|
||||
} else {
|
||||
submode.name = "SPI";
|
||||
submode.enter = 0x01;
|
||||
submode.entered_format = "SPI%1d";
|
||||
|
||||
/* 1000wxyz - SPI config, w=HiZ(0)/3.3v(1), x=CLK idle, y=CLK edge, z=SMP sample
|
||||
* we want: 3.3V(1), idle low(0), data change on
|
||||
* trailing edge (1), sample in the middle
|
||||
* of the pulse (0)
|
||||
* => 0b10001010 = 0x8a */
|
||||
submode.config = 0x8A;
|
||||
submode = &(const struct submode){
|
||||
.name = "SPI",
|
||||
.enter = 0x01,
|
||||
.entered_format = "SPI%1d",
|
||||
|
||||
/* 1000wxyz - SPI config, w=HiZ(0)/3.3v(1), x=CLK idle, y=CLK edge, z=SMP sample
|
||||
* we want: 3.3V(1), idle low(0), data change on
|
||||
* trailing edge (1), sample in the middle
|
||||
* of the pulse (0)
|
||||
* => 0b10001010 = 0x8a */
|
||||
.config = 0x8A,
|
||||
};
|
||||
}
|
||||
|
||||
unsigned char buf[20] = { '\0' };
|
||||
@@ -562,18 +566,18 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||
}
|
||||
|
||||
/* == Set protocol sub-mode of binary mode == */
|
||||
buf[0] = submode.enter;
|
||||
buf[0] = submode->enter;
|
||||
buspirate_send_bin(pgm, buf, 1);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
buspirate_recv_bin(pgm, buf, 4);
|
||||
if (sscanf((const char*)buf, submode.entered_format, &PDATA(pgm)->submode_version) != 1) {
|
||||
if (sscanf((const char*)buf, submode->entered_format, &PDATA(pgm)->submode_version) != 1) {
|
||||
avrdude_message(MSG_INFO, "%s mode not confirmed: '%s'\n",
|
||||
submode.name, buf);
|
||||
submode->name, buf);
|
||||
buspirate_reset_from_binmode(pgm);
|
||||
return -1;
|
||||
}
|
||||
avrdude_message(MSG_NOTICE, "BusPirate %s version: %d\n",
|
||||
submode.name, PDATA(pgm)->submode_version);
|
||||
submode->name, PDATA(pgm)->submode_version);
|
||||
|
||||
if (pgm->flag & BP_FLAG_NOPAGEDWRITE) {
|
||||
avrdude_message(MSG_NOTICE, "%s: Paged flash write disabled.\n", progname);
|
||||
@@ -614,7 +618,7 @@ static int buspirate_start_mode_bin(struct programmer_t *pgm)
|
||||
return -1;
|
||||
|
||||
/* Submode config */
|
||||
if (buspirate_expect_bin_byte(pgm, submode.config, 0x01) < 0)
|
||||
if (buspirate_expect_bin_byte(pgm, submode->config, 0x01) < 0)
|
||||
return -1;
|
||||
|
||||
/* AVR Extended Commands - test for existence */
|
||||
@@ -797,7 +801,7 @@ static void buspirate_powerup(struct programmer_t *pgm)
|
||||
char buf[25];
|
||||
int ok = 0;
|
||||
snprintf(buf, sizeof(buf), "%d\n", PDATA(pgm)->cpufreq);
|
||||
if (buspirate_expect(pgm, "g\n", "Frequency in kHz", 1)) {
|
||||
if (buspirate_expect(pgm, "g\n", "Frequency in KHz", 1)) {
|
||||
if (buspirate_expect(pgm, buf, "Duty cycle in %", 1)) {
|
||||
if (buspirate_expect(pgm, "50\n", "PWM active", 1)) {
|
||||
ok = 1;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
@echo off
|
||||
rmdir /s /q ".vs" >nul 2>nul
|
||||
|
||||
rmdir /s /q "Debug" >nul 2>nul
|
||||
rmdir /s /q "Release" >nul 2>nul
|
||||
rmdir /s /q "x64" >nul 2>nul
|
||||
|
||||
rmdir /s /q "external\libelf\Debug" >nul 2>nul
|
||||
rmdir /s /q "external\libelf\Release" >nul 2>nul
|
||||
rmdir /s /q "external\libelf\x64" >nul 2>nul
|
||||
|
||||
rmdir /s /q "external\libftdi1\Debug" >nul 2>nul
|
||||
rmdir /s /q "external\libftdi1\Release" >nul 2>nul
|
||||
rmdir /s /q "external\libftdi1\x64" >nul 2>nul
|
||||
|
||||
rmdir /s /q "external\libhidapi\Debug" >nul 2>nul
|
||||
rmdir /s /q "external\libhidapi\Release" >nul 2>nul
|
||||
rmdir /s /q "external\libhidapi\x64" >nul 2>nul
|
||||
|
||||
rmdir /s /q "external\libusb\Debug" >nul 2>nul
|
||||
rmdir /s /q "external\libusb\Release" >nul 2>nul
|
||||
rmdir /s /q "external\libusb\x64" >nul 2>nul
|
||||
|
||||
rmdir /s /q .deps
|
||||
rmdir /s /q .libs
|
||||
rmdir /s /q autom4te.cache
|
||||
rmdir /s /q m4
|
||||
|
||||
del ac_cfg.h
|
||||
del ac_cfg.h.in
|
||||
del aclocal.m4
|
||||
del avrdude
|
||||
del avrdude.conf
|
||||
del avrdude.conf.tmp
|
||||
del avrdude.spec
|
||||
del compile
|
||||
del config.guess
|
||||
del config.log
|
||||
del config.status
|
||||
del config.sub
|
||||
del config_gram.c
|
||||
del config_gram.h
|
||||
del configure
|
||||
del depcomp
|
||||
del INSTALL
|
||||
del install-sh
|
||||
del lexer.c
|
||||
del libtool
|
||||
del ltmain.sh
|
||||
del Makefile
|
||||
del Makefile.in
|
||||
del mdate-sh
|
||||
del mkinstalldirs
|
||||
del missing
|
||||
del stamp-h.in
|
||||
del stamp-h1
|
||||
del texinfo.tex
|
||||
del y.output
|
||||
del y.tab.h
|
||||
del ylwrap
|
||||
del *.o
|
||||
del *.lo
|
||||
del *.a
|
||||
del *.la
|
||||
del *.diff
|
||||
del *.patch
|
||||
@@ -217,7 +217,6 @@ TOKEN * hexnumber(char * text)
|
||||
tkn->value.number = strtoul(text, &e, 16);
|
||||
if ((e == text) || (*e != 0)) {
|
||||
yyerror("can't scan hex number \"%s\"", text);
|
||||
free_token(tkn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -245,7 +244,6 @@ TOKEN * string(char * text)
|
||||
tkn->value.string = (char *) malloc(len+1);
|
||||
if (tkn->value.string == NULL) {
|
||||
yyerror("string(): out of memory");
|
||||
free_token(tkn);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(tkn->value.string, text);
|
||||
|
||||
+3
-9
@@ -672,7 +672,7 @@ part_parm :
|
||||
|
||||
K_DESC TKN_EQUAL TKN_STRING
|
||||
{
|
||||
strncpy(current_part->desc, $3->value.string, AVR_DESCLEN - 1);
|
||||
strncpy(current_part->desc, $3->value.string, AVR_DESCLEN);
|
||||
current_part->desc[AVR_DESCLEN-1] = 0;
|
||||
free_token($3);
|
||||
} |
|
||||
@@ -1240,7 +1240,7 @@ part_parm :
|
||||
free_token($2);
|
||||
YYABORT;
|
||||
}
|
||||
strncpy(current_mem->desc, $2->value.string, AVR_MEMDESCLEN - 1);
|
||||
strncpy(current_mem->desc, $2->value.string, AVR_MEMDESCLEN);
|
||||
current_mem->desc[AVR_MEMDESCLEN-1] = 0;
|
||||
free_token($2);
|
||||
}
|
||||
@@ -1310,13 +1310,7 @@ mem_spec :
|
||||
|
||||
K_PAGE_SIZE TKN_EQUAL TKN_NUMBER
|
||||
{
|
||||
int ps = $3->value.number;
|
||||
if (ps <= 0)
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s, line %d: invalid page size %d, ignored\n",
|
||||
infile, lineno, ps);
|
||||
else
|
||||
current_mem->page_size = ps;
|
||||
current_mem->page_size = $3->value.number;
|
||||
free_token($3);
|
||||
} |
|
||||
|
||||
|
||||
+2
-28
@@ -23,7 +23,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.60)
|
||||
AC_INIT(avrdude, 6.4, avrdude-dev@nongnu.org)
|
||||
AC_INIT(avrdude, 6.3-20171130, avrdude-dev@nongnu.org)
|
||||
|
||||
AC_CANONICAL_BUILD
|
||||
AC_CANONICAL_HOST
|
||||
@@ -322,7 +322,7 @@ AC_ARG_ENABLE(
|
||||
no) enabled_parport=no ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for enable-parport option) ;;
|
||||
esac],
|
||||
[enabled_parport=no])
|
||||
[enabled_parport=yes])
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[linuxgpio],
|
||||
@@ -336,18 +336,6 @@ AC_ARG_ENABLE(
|
||||
esac],
|
||||
[enabled_linuxgpio=no])
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[linuxspi],
|
||||
AC_HELP_STRING(
|
||||
[--enable-linuxspi],
|
||||
[Enable the Linux SPIDEV interface programmer type]),
|
||||
[case "${enableval}" in
|
||||
yes) enabled_linuxspi=yes ;;
|
||||
no) enabled_linuxspi=no ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for enable-linuxspi option) ;;
|
||||
esac],
|
||||
[enabled_linuxspi=no])
|
||||
|
||||
DIST_SUBDIRS_AC='doc windows'
|
||||
|
||||
if test "$enabled_doc" = "yes"; then
|
||||
@@ -425,14 +413,6 @@ else
|
||||
fi
|
||||
|
||||
|
||||
if test "$enabled_linuxspi" = "yes"; then
|
||||
AC_DEFINE(HAVE_LINUXSPI, 1, [Linux SPI support enabled])
|
||||
confsubst="$confsubst -e /^@HAVE_LINUXSPI_/d"
|
||||
else
|
||||
confsubst="$confsubst -e /^@HAVE_LINUXSPI_BEGIN@/,/^@HAVE_LINUXSPI_END@/d"
|
||||
fi
|
||||
|
||||
|
||||
# If we are compiling with gcc, enable all warning and make warnings errors.
|
||||
if test "$GCC" = yes; then
|
||||
ENABLE_WARNINGS="-Wall"
|
||||
@@ -610,9 +590,3 @@ else
|
||||
echo "DISABLED linuxgpio"
|
||||
fi
|
||||
|
||||
if test x$enabled_linuxspi = xyes; then
|
||||
echo "ENABLED linuxspi"
|
||||
else
|
||||
echo "DISABLED linuxspi"
|
||||
fi
|
||||
|
||||
+6
-88
@@ -30,7 +30,7 @@ For avrdude version @value{VERSION}, @value{UPDATED}.
|
||||
|
||||
Copyright @copyright{} 2003, 2005 Brian Dean
|
||||
|
||||
Copyright @copyright{} 2006 - 2021 J@"org Wunsch
|
||||
Copyright @copyright{} 2006 - 2016 J@"org Wunsch
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
@@ -180,49 +180,6 @@ some resistors in series or better yet use a 3-state buffer driver like
|
||||
the 74HC244. Have a look at http://kolev.info/avrdude-linuxgpio for a more
|
||||
detailed tutorial about using this programmer type.
|
||||
|
||||
Under a Linux installation with direct access to the SPI bus and GPIO
|
||||
pins, such as would be found on a Raspberry Pi, the ``linuxspi''
|
||||
programmer type can be used to directly connect to and program a chip
|
||||
using the built in interfaces on the computer. The requirements to use
|
||||
this type are that an SPI interface is exposed along with one GPIO
|
||||
pin. The GPIO serves as the reset output since the Linux SPI drivers
|
||||
do not hold slave select down when a transfer is not occuring and thus
|
||||
it cannot be used as the reset pin. A readily available level
|
||||
translator should be used between the SPI bus/reset GPIO and the chip
|
||||
to avoid potentially damaging the computer's SPI controller in the
|
||||
event that the chip is running at 5V and the SPI runs at 3.3V. The
|
||||
GPIO chosen for reset can be configured in the avrdude configuration
|
||||
file using the @code{reset} entry under the linuxspi programmer, or
|
||||
directly in the port specification. An external pull-up resistor
|
||||
should be connected between the AVR's reset pin and Vcc. If Vcc is not
|
||||
the same as the SPI voltage, this should be done on the AVR side of
|
||||
the level translator to protect the hardware from damage.
|
||||
|
||||
On a Raspberry Pi, header J8 provides access to the SPI and GPIO
|
||||
lines.
|
||||
|
||||
Typically, pins 19, 21, and 23 are SPI MOSI, MISO, and SCK, while
|
||||
pins 24 and 26 would serve as CE outputs. So, close to these pins
|
||||
is pin 22 as GPIO25 which can be used as /RESET, and pin 25 can
|
||||
be used as GND.
|
||||
|
||||
A typical programming cable would then look like:
|
||||
|
||||
@multitable @columnfractions .15 .15 .3
|
||||
@item @code{J8 pin} @tab @code{ISP pin} @tab @code{Name}
|
||||
@item @code{21} @tab @code{1} @tab @code{MISO}
|
||||
@item @code{-} @tab @code{2} @tab @code{Vcc - leave open}
|
||||
@item @code{23} @tab @code{3} @tab @code{SCK}
|
||||
@item @code{19} @tab @code{4} @tab @code{MOSI}
|
||||
@item @code{22} @tab @code{5} @tab @code{/RESET}
|
||||
@item @code{25} @tab @code{6} @tab @code{GND}
|
||||
@end multitable
|
||||
|
||||
(Mind the 3.3 V voltage level of the Raspberry Pi!)
|
||||
|
||||
The @code{-P @var{portname}} option defaults to
|
||||
@code{/dev/spidev0.0:/dev/gpiochip0} for this programmer.
|
||||
|
||||
The STK500, JTAG ICE, avr910, and avr109/butterfly use the serial port to communicate with the PC.
|
||||
The STK600, JTAG ICE mkII/3, AVRISP mkII, USBasp, avrftdi (and derivatives), and USBtinyISP
|
||||
programmers communicate through the USB, using @code{libusb} as a
|
||||
@@ -277,16 +234,12 @@ option might be required to achieve a stable ISP communication.
|
||||
For ATxmega devices, the AVR Dragon is supported in PDI mode, provided it
|
||||
has a firmware version of at least 6.11 (decimal).
|
||||
|
||||
Wiring boards (e.g. Arduino Mega 2560 Rev3) are supported, utilizing
|
||||
STK500 V2.x protocol, but a simple DTR/RTS toggle to set the boards
|
||||
into programming mode. The programmer type is ``wiring''. Note that
|
||||
the -D option will likely be required in this case, because the
|
||||
bootloader will rewrite the program memory, but no true chip erase can
|
||||
be performed.
|
||||
Wiring boards are supported, utilizing STK500 V2.x protocol, but
|
||||
a simple DTR/RTS toggle to set the boards into programming mode.
|
||||
The programmer type is ``wiring''.
|
||||
|
||||
The Arduino (which is very similar to the STK500 1.x) is supported via
|
||||
its own programmer type specification ``arduino''. This programmer works for
|
||||
the Arduino Uno Rev3.
|
||||
its own programmer type specification ``arduino''.
|
||||
|
||||
The BusPirate is a versatile tool that can also be used as an AVR programmer.
|
||||
A single BusPirate can be connected to up to 3 independent AVRs. See
|
||||
@@ -303,10 +256,6 @@ The Atmel DFU bootloader is supported in both, FLIP protocol version 1
|
||||
(AT90USB* and ATmega*U* devices), as well as version 2 (Xmega devices).
|
||||
See below for some hints about FLIP version 1 protocol behaviour.
|
||||
|
||||
The MPLAB(R) PICkit 4, MPLAB(R) SNAP, and Curiosity Nano boards are
|
||||
supported in UPDI mode. The Curiosity Nano board is dubbed ``PICkit on
|
||||
Board'', thus the name @code{pkobn_updi}.
|
||||
|
||||
|
||||
@menu
|
||||
* History::
|
||||
@@ -600,22 +549,7 @@ and Mac OS but not on Windows. For more information about AVR-Doper see
|
||||
For the USBtinyISP, which is a simplistic device not implementing
|
||||
serial numbers, multiple devices can be distinguished by their
|
||||
location in the USB hierarchy.
|
||||
See the respective
|
||||
@xref{Troubleshooting} entry for examples.
|
||||
|
||||
For the XBee programmer the target MCU is to be programmed wirelessly
|
||||
over a ZigBee mesh using the XBeeBoot bootloader. The ZigBee 64-bit
|
||||
address for the target MCU's own XBee device must be supplied as a
|
||||
16-character hexadecimal value as a port prefix, followed by the
|
||||
@code{@@} character, and the serial device to connect to a second
|
||||
directly contactable XBee device associated with the same mesh (with
|
||||
a default baud rate of 9600). This may look similar to:
|
||||
@code{0013a20000000001@/dev/tty.serial}.
|
||||
|
||||
For diagnostic purposes, if the target MCU with an XBeeBoot
|
||||
bootloader is connected directly to the serial port, the
|
||||
64-bit address field can be omitted. In this mode the
|
||||
default baud rate will be 19200.
|
||||
@xref{Troubleshooting}, for examples.
|
||||
|
||||
For programmers that attach to a serial port using some kind of
|
||||
higher level protocol (as opposed to bit-bang style programmers),
|
||||
@@ -990,22 +924,6 @@ rather than entire chip.
|
||||
Only applicable to TPI devices (ATtiny 4/5/9/10/20/40).
|
||||
@end table
|
||||
|
||||
@item xbee
|
||||
Extended parameters:
|
||||
@table @code
|
||||
@item @samp{xbeeresetpin=@var{1..7}}
|
||||
Select the XBee pin @code{DIO<1..7>} that is connected to the MCU's
|
||||
‘/RESET’ line. The programmer needs to know which DIO pin to use to
|
||||
reset into the bootloader. The default (3) is the @code{DIO3} pin
|
||||
(XBee pin 17), but some commercial products use a different XBee
|
||||
pin.
|
||||
|
||||
The remaining two necessary XBee-to-MCU connections are not selectable
|
||||
- the XBee @code{DOUT} pin (pin 2) must be connected to the MCU's
|
||||
‘RXD’ line, and the XBee @code{DIN} pin (pin 3) must be connected to
|
||||
the MCU's ‘TXD’ line.
|
||||
@end table
|
||||
|
||||
@end table
|
||||
|
||||
@page
|
||||
|
||||
Vendored
+481
@@ -0,0 +1,481 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
Vendored
+1435
File diff suppressed because it is too large.
Load diff
Vendored
+332
@@ -0,0 +1,332 @@
|
||||
This is the public release of libelf-0.8.13, a free ELF object
|
||||
file access library. If you have problems with applications
|
||||
that use libelf and work with the commercial (SVR4, Solaris)
|
||||
version but not with this one, please contact me.
|
||||
|
||||
IMPORTANT NOTE: If you have libelf-0.5.2 installed, you probably
|
||||
have a file .../include/elf.h that contains the single line
|
||||
``#include <libelf/elf.h>''. REMOVE THIS FILE BEFORE YOU RUN
|
||||
configure.
|
||||
|
||||
Installation is straightforward - the package is autoconf'ed. Just do
|
||||
``cd libelf-0.8.13; ./configure; make; make install''. Header files
|
||||
will be installed in .../include/libelf/. If your system does not
|
||||
provide its own versions of libelf.h, nlist.h or gelf.h, ``make
|
||||
install'' will add the missing headers. If you prefer not to have
|
||||
these files installed in /usr/include, use ``--disable-compat'' and
|
||||
add ``-I /usr/include/libelf'' to your CFLAGS when compiling
|
||||
libelf-based programs.
|
||||
|
||||
Note to distribution makers: You can install libelf in a separate root
|
||||
hierarchy by using the command ``make instroot=/my/root install''.
|
||||
You should also use the ``--enable-compat'' configure option in that
|
||||
case, or run ``make instroot=/my/root install-compat'' manually, to
|
||||
install all the required header files.
|
||||
|
||||
If you are running Linux with libc 5.* as the default C library,
|
||||
and you plan to use the 64-bit functions, you must either use
|
||||
``-I.../include/libelf'', or remove /usr/include/libelf.h and use
|
||||
``--enable-compat'' when running configure. Libc 6.* (aka glibc2)
|
||||
doesn't have its own <libelf.h>, <nlist.h> or <gelf.h>.
|
||||
|
||||
You need an ANSI/ISO C compiler to build libelf. Gcc is optimal.
|
||||
|
||||
On some systems (in particular, Solaris and all variants of Linux),
|
||||
``make'' will try to build a shared library. If you run into problems
|
||||
on your system, please pass ``--disable-shared'' to configure.
|
||||
If you build a shared library and want it to be installed as
|
||||
``libelf-0.8.13.so'' rather than ``libelf.so.0.8.13'', please use
|
||||
``./configure --enable-gnu-names''. Other files, e.g. ``libelf.so'' and
|
||||
``libelf.so.0'' are NOT affected.
|
||||
|
||||
Another configure option, ``--enable-debug'', adds debugging code to
|
||||
libelf; if you don't run into problems, you will probably not need it.
|
||||
|
||||
When creating an ELF shared library, it is possible to add references
|
||||
to other shared libraries in the DYNAMIC section of the resulting
|
||||
file. The make variable DEPSHLIBS contains a list of libraries to add.
|
||||
It is set to ``-lc'' on Linux systems, and empty otherwise. To
|
||||
override this setting, use something like ``make DEPSHLIBS="-la -lb"''.
|
||||
For Linux, `-lc' is included automagically.
|
||||
|
||||
NLS is available and enabled by default. To turn it off, pass the
|
||||
``--disable-nls'' option to configure.
|
||||
|
||||
Libelf can use gettext or catgets for accessing message
|
||||
catalogs. If gettext is available AND is part of libc (i.e. not
|
||||
in a separate library), it will be used. Otherwise, configure
|
||||
will look for catgets. If you have gettext in a separate
|
||||
library and want to use it, you should pass the library's name
|
||||
to configure, e.g. ``LIBS=-lintl ./configure''. Note that you
|
||||
MUST link your libelf-based applications with -lintl then,
|
||||
which is probably not what you want, or change the DEPSHLIBS variable
|
||||
described above (in case you're building a shared library).
|
||||
|
||||
If you have GNU gettext 0.10 installed on your system, and if GNU gettext
|
||||
runs on top of the catgets interface (rather old Linux systems, using
|
||||
libc5), configure will refuse to use it and use catgets instead. If you
|
||||
absolutely want to use GNU gettext, go ahead and rebuild it (which is
|
||||
IMHO a good idea in general in this case):
|
||||
|
||||
cd .../gettext-0.10
|
||||
ac_cv_func_catgets=no ac_cv_func_gettext=no ./configure
|
||||
make
|
||||
make install
|
||||
|
||||
After that, return to the libelf build directory, remove
|
||||
config.cache, and start over.
|
||||
|
||||
*** Large File Support (LFS) applications ***
|
||||
|
||||
Some 32-bit systems support files that are larger than the address space
|
||||
of the architecture. On these, the `off_t' data type may have 32 or
|
||||
64 bits, depending on the API you choose. Since off_t is also part of
|
||||
the libelf API, in particular the Elf_Data and Elf_Arhdr structures,
|
||||
an application compiled with large file support will need a version of
|
||||
libelf that has also been compiled with LFS; otherwise, it won't work
|
||||
correctly. Similarly, a program compiled without LFS needs a library
|
||||
compiled without LFS.
|
||||
|
||||
Note that libelf is currently unable to process large files on 32-bit
|
||||
architectures, whether you compile it for LFS or not, for the simple
|
||||
reason that the files won't fit into the processes' address space.
|
||||
Therefore, libelf is compiled without LFS by default. It can of course
|
||||
read and write ELF files for 64-bit architectures, but they will be
|
||||
limited in length on a 32-bit system.
|
||||
|
||||
You may compile libelf with large file support by setting CPPFLAGS at
|
||||
configuration time:
|
||||
|
||||
CPPFLAGS=`getconf LFS_CFLAGS` ./configure
|
||||
|
||||
But I really, really recommend you don't, because it breaks binary
|
||||
compatibility with existing libelf based applications.
|
||||
|
||||
*** 64-bit support ***
|
||||
|
||||
Starting with libelf-0.7.0, libelf also supports 64-bit ELF files.
|
||||
This is enabled by default unless your system (or your compiler) does
|
||||
not support 64-bit integers, or lacks 64-bit declarations in <elf.h>.
|
||||
If you have problems building with 64-bit support, please do
|
||||
|
||||
./configure --disable-elf64
|
||||
|
||||
for the moment, and contact me. Please note that I haven't tested 64-bit
|
||||
support much. There are still some unresolved problems, e.g. IRIX
|
||||
uses different Elf64_Rel and Elf64_Rela structures (they replaced the
|
||||
r_info member), and the enumeration values for Elf_Type differ from
|
||||
the commercial (SVR4) implementation of libelf - they broke binary
|
||||
compatibility for no good reason, and I'm not willing to follow their
|
||||
footsteps. The result is that libelf-0.7.* ist upward compatible with
|
||||
libelf-0.6.4 (as it should be) but INCOMPATIBLE WITH SVR4 LIBELF. If you
|
||||
have both versions installed, you'd better make sure that you link with
|
||||
the library that matches the <libelf.h> you're #include'ing.
|
||||
|
||||
*** Symbol Versioning ***
|
||||
|
||||
Libelf >= 0.8.0 supports the data structures and definitions used for
|
||||
symbol versioning on Solaris and Linux, in particular, the Elfxx_Verdef,
|
||||
Elfxx_Verdaux, Elfxx_Verneed, Elfxx_Vernaux and Elfxx_Versym structures
|
||||
and the SHT_XXX_verdef, SHT_XXX_verneed and SHT_XXX_versym section types
|
||||
(where `xx' is either `32' or `64', and `XXX' is either `SUNW' or `GNU').
|
||||
Libelf now translates versioning sections to/from their external
|
||||
representation properly (earlier versions left them in `raw' format,
|
||||
with the data type set to ELF_T_BYTE). This may cause problems on
|
||||
systems which use the same (OS-specific) section types for different
|
||||
purposes. The configure program tries to figure out if your OS uses
|
||||
versioning; if that check fails, you can use
|
||||
|
||||
./configure --disable-versioning
|
||||
|
||||
to turn off versioning translation support.
|
||||
|
||||
*** W32 Support ***
|
||||
|
||||
There is now some support for building on W32 systems (requires Microsoft
|
||||
VC++). In order to build a W32 DLL, cd into the `lib' subdirectory, edit
|
||||
build.bat if necessary (it needs the path to your compiler binaries) and
|
||||
run it. If you're lucky, libelf.dll and the import/export libraries will
|
||||
be built. If not, please drop me a line.
|
||||
|
||||
I tested it on XP Pro (SP2), using VC++ 2005 Express Edition.
|
||||
Apparently, Visual Studio .NET 2003 works fine as well.
|
||||
|
||||
Various notes regarding the W32 port:
|
||||
|
||||
- When you open() an ELF file, remember to use the O_BINARY flag.
|
||||
- You may have to add /MD to the linker command line.
|
||||
|
||||
*** Missing things ***
|
||||
|
||||
* There is no documentation. You can use the Solaris
|
||||
manpages instead (available at http://docs.sun.com/).
|
||||
The ELF file format is described in several places;
|
||||
among them Suns "Linker and Libraries Guide" and the
|
||||
"System V Application Binary Interface" documents;
|
||||
http://www.caldera.com/developer/devspecs/gabi41.pdf and
|
||||
http://www.caldera.com/developer/gabi/ are probably good
|
||||
starting points. Processor-specific documentation is spread
|
||||
across a number of `Processor Supplement' documents, one
|
||||
for each architecture; you'll have to use a search engine to
|
||||
find them.
|
||||
|
||||
* The COFF file format is not understood. This is so obsolete
|
||||
that it will probably never be implemented.
|
||||
|
||||
* nlist(3) is incomplete; the n_type and n_sclass
|
||||
members of struct nl are set to zero even if type
|
||||
(that is, debug) information is available.
|
||||
|
||||
* Libelf does not translate Solaris' `Move' and `Syminfo'
|
||||
sections. You can read them using elf_getdata(), but you'll
|
||||
only get raw (untranslated) bytes.
|
||||
|
||||
Changes since 0.8.12:
|
||||
|
||||
* New function elf_getaroff().
|
||||
|
||||
* Build fixes.
|
||||
|
||||
Changes since 0.8.11:
|
||||
|
||||
* Due to some unfortunate confusion, the elf_getphnum(),
|
||||
elf_getshnum() and elf_getshstrndx() are not compatible
|
||||
between libelf implementations. Therefore, the developers
|
||||
decided to replace them with new functions: elf_getphdrnum(),
|
||||
elf_getshdrnum() and elf_getshdrstrndx(), which will always
|
||||
return -1 on failure and 0 on success. Code using the old
|
||||
interface should be upgraded to increase portability.
|
||||
|
||||
Changes since 0.8.10:
|
||||
|
||||
* Fixed a bug in elf_rawfile().
|
||||
* If you use ELF_F_LAYOUT together with ELF_F_LAYOUT_OVERLAP,
|
||||
elf_update() will now tolerate overlapping sections.
|
||||
|
||||
Changes since 0.8.9:
|
||||
|
||||
* Ported to QNX Neutrino.
|
||||
* Fixed Windows build errors.
|
||||
* Parallel (make -j) installation should work now.
|
||||
|
||||
* It's now possible to enable and disable select sanity checks
|
||||
libelf performs. Currently, this affects the "NUL terminated
|
||||
string table entry" check performed in elf_strptr(). By
|
||||
default, the function will return an error if the string
|
||||
requested is not properly terminated - because some
|
||||
applications might dump core otherwise. If you configure
|
||||
libelf with `--disable-sanity-checks', however, the check
|
||||
(and, in the future, probably others as well) is disabled
|
||||
by default. You can still turn it on and off at runtime by
|
||||
setting the LIBELF_SANITY_CHECKS environment variable to
|
||||
an integer value:
|
||||
|
||||
# disable all sanity checks
|
||||
export LIBELF_SANITY_CHECKS=0
|
||||
|
||||
# enable all sanity checks
|
||||
export LIBELF_SANITY_CHECKS=-1
|
||||
|
||||
Each bit of the value corresponds to a particular check,
|
||||
so you could use LIBELF_SANITY_CHECKS=1 to enable only
|
||||
the elf_strptr() check. You may also use a value in hex
|
||||
(0x...) or octal (0...) format.
|
||||
|
||||
Changes since 0.8.8:
|
||||
|
||||
* Improved translator for symbol versioning sections.
|
||||
* The W32 library is now built in the `lib' subdirectory.
|
||||
* Windows DLLs should work now.
|
||||
|
||||
Changes since 0.8.6:
|
||||
|
||||
* added elf_getphnum().
|
||||
* added elf_getshnum().
|
||||
* added elf_getshstrndx().
|
||||
* added elfx_update_shstrndx().
|
||||
* handle interrupted reads/writes more gracefully.
|
||||
* added (partial) support for unusual e_[ps]hentsize values.
|
||||
* fixed the bugs introduced in 0.8.7.
|
||||
|
||||
Changes since 0.8.5:
|
||||
|
||||
* added W32 support.
|
||||
* added workaround for alignment errors in archive members.
|
||||
* my email address has changed again ;)
|
||||
|
||||
Changes since 0.8.4:
|
||||
|
||||
* elf_strptr() should now work more safely with fragmented
|
||||
or badly formatted string tables.
|
||||
|
||||
Changes since 0.8.3:
|
||||
|
||||
* Fixed a bug in elf_update() that was introduced in 0.8.3.
|
||||
|
||||
Changes since 0.8.2:
|
||||
|
||||
* Should compile on MacOSX now.
|
||||
|
||||
* Can read and write files with more than 65280 sections
|
||||
|
||||
* Tries to handle 64-bit ELF files that use 8-byte hash table
|
||||
entries. In particular, libelf tries to guess the data type in
|
||||
elf_getdata(), and doesn't override sh_entsize in elf_update()
|
||||
any longer. If you want the library to pick the entry size,
|
||||
you must set its value to 0 before you call elf_update().
|
||||
|
||||
* No longer dumps core in elf_update() when a versioning section
|
||||
has no data. Instead, it returns an error message. Note that
|
||||
you're supposed to provide a valid d_buf for any section, unless
|
||||
it's empty or has SHT_NOBITS type.
|
||||
|
||||
* Building a shared library is now the default (if supported).
|
||||
|
||||
Changes since 0.8.0:
|
||||
|
||||
* Corrected typo in lib/{32,64}.xlatetof.c that sometimes
|
||||
caused a compilation failure.
|
||||
|
||||
* Use open(name, O_RDONLY|O_BINARY) in lib/nlist.c.
|
||||
|
||||
Changes since 0.7.0:
|
||||
|
||||
* I implemented the gelf_* interface, as found on Solaris.
|
||||
I don't know whether it's compatible -- the Solaris manpage
|
||||
isn't very specific, so I had to guess return values etc. in
|
||||
some cases.
|
||||
|
||||
* Added elf{32,64}_checksum (supposed to be compatible with
|
||||
Solaris).
|
||||
|
||||
* Added symbol versioning support.
|
||||
|
||||
Changes since 0.6.4:
|
||||
|
||||
* Fixed configure for IRIX systems
|
||||
* Added check for truncated archive members
|
||||
* Added check for misaligned SHDR/PHDR tables
|
||||
* Support for building libelf together with GNU libc
|
||||
* Added elf_memory(3)
|
||||
* Added 64-bit support
|
||||
|
||||
Changes since 0.5.2:
|
||||
|
||||
* some bug fixes
|
||||
* mmap support
|
||||
* new directory layout
|
||||
* There is a new function, elf_delscn(), that deletes
|
||||
a section from an ELF file. It also adjusts the
|
||||
sh_link and sh_info members in the section header
|
||||
table, if (and ONLY if) the ELF standard indicates
|
||||
that these values are section indices. References
|
||||
to the deleted section will be cleared, so be careful.
|
||||
* my email address has changed ;)
|
||||
|
||||
Where to get libelf:
|
||||
|
||||
ftp://ftp.ibiblio.org/pub/Linux/libs/
|
||||
http://www.mr511.de/software/
|
||||
|
||||
Michael "Tired" Riepe
|
||||
<libelf@mr511.de>
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
0.8.13
|
||||
Vendored
+305
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* libelf.h - public header file for libelf.
|
||||
* Copyright (C) 1995 - 2008 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* @(#) $Id: libelf.h,v 1.29 2009/07/07 17:57:43 michael Exp $ */
|
||||
|
||||
#ifndef _LIBELF_H
|
||||
#define _LIBELF_H
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
#include <sys/types.h>
|
||||
|
||||
#if __LIBELF_INTERNAL__
|
||||
#include <sys_elf.h>
|
||||
#else /* __LIBELF_INTERNAL__ */
|
||||
#include <libelf/sys_elf.h>
|
||||
#endif /* __LIBELF_INTERNAL__ */
|
||||
|
||||
#if defined __GNUC__ && !defined __cplusplus
|
||||
#define DEPRECATED __attribute__((deprecated))
|
||||
#else
|
||||
#define DEPRECATED /* nothing */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef __P
|
||||
# if (__STDC__ + 0) || defined(__cplusplus) || defined(_WIN32)
|
||||
# define __P(args) args
|
||||
# else /* __STDC__ || defined(__cplusplus) */
|
||||
# define __P(args) ()
|
||||
# endif /* __STDC__ || defined(__cplusplus) */
|
||||
#endif /* __P */
|
||||
|
||||
/*
|
||||
* Commands
|
||||
*/
|
||||
typedef enum {
|
||||
ELF_C_NULL = 0, /* must be first, 0 */
|
||||
ELF_C_READ,
|
||||
ELF_C_WRITE,
|
||||
ELF_C_CLR,
|
||||
ELF_C_SET,
|
||||
ELF_C_FDDONE,
|
||||
ELF_C_FDREAD,
|
||||
ELF_C_RDWR,
|
||||
ELF_C_NUM /* must be last */
|
||||
} Elf_Cmd;
|
||||
|
||||
/*
|
||||
* Flags
|
||||
*/
|
||||
#define ELF_F_DIRTY 0x1
|
||||
#define ELF_F_LAYOUT 0x4
|
||||
/*
|
||||
* Allow sections to overlap when ELF_F_LAYOUT is in effect.
|
||||
* Note that this flag ist NOT portable, and that it may render
|
||||
* the output file unusable. Use with extreme caution!
|
||||
*/
|
||||
#define ELF_F_LAYOUT_OVERLAP 0x10000000
|
||||
|
||||
/*
|
||||
* File types
|
||||
*/
|
||||
typedef enum {
|
||||
ELF_K_NONE = 0, /* must be first, 0 */
|
||||
ELF_K_AR,
|
||||
ELF_K_COFF,
|
||||
ELF_K_ELF,
|
||||
ELF_K_NUM /* must be last */
|
||||
} Elf_Kind;
|
||||
|
||||
/*
|
||||
* Data types
|
||||
*/
|
||||
typedef enum {
|
||||
ELF_T_BYTE = 0, /* must be first, 0 */
|
||||
ELF_T_ADDR,
|
||||
ELF_T_DYN,
|
||||
ELF_T_EHDR,
|
||||
ELF_T_HALF,
|
||||
ELF_T_OFF,
|
||||
ELF_T_PHDR,
|
||||
ELF_T_RELA,
|
||||
ELF_T_REL,
|
||||
ELF_T_SHDR,
|
||||
ELF_T_SWORD,
|
||||
ELF_T_SYM,
|
||||
ELF_T_WORD,
|
||||
/*
|
||||
* New stuff for 64-bit.
|
||||
*
|
||||
* Most implementations add ELF_T_SXWORD after ELF_T_SWORD
|
||||
* which breaks binary compatibility with earlier versions.
|
||||
* If this causes problems for you, contact me.
|
||||
*/
|
||||
ELF_T_SXWORD,
|
||||
ELF_T_XWORD,
|
||||
/*
|
||||
* Symbol versioning. Sun broke binary compatibility (again!),
|
||||
* but I won't.
|
||||
*/
|
||||
ELF_T_VDEF,
|
||||
ELF_T_VNEED,
|
||||
ELF_T_NUM /* must be last */
|
||||
} Elf_Type;
|
||||
|
||||
/*
|
||||
* Elf descriptor
|
||||
*/
|
||||
typedef struct Elf Elf;
|
||||
|
||||
/*
|
||||
* Section descriptor
|
||||
*/
|
||||
typedef struct Elf_Scn Elf_Scn;
|
||||
|
||||
/*
|
||||
* Archive member header
|
||||
*/
|
||||
typedef struct {
|
||||
char* ar_name;
|
||||
time_t ar_date;
|
||||
long ar_uid;
|
||||
long ar_gid;
|
||||
unsigned long ar_mode;
|
||||
off_t ar_size;
|
||||
char* ar_rawname;
|
||||
} Elf_Arhdr;
|
||||
|
||||
/*
|
||||
* Archive symbol table
|
||||
*/
|
||||
typedef struct {
|
||||
char* as_name;
|
||||
size_t as_off;
|
||||
unsigned long as_hash;
|
||||
} Elf_Arsym;
|
||||
|
||||
/*
|
||||
* Data descriptor
|
||||
*/
|
||||
typedef struct {
|
||||
void* d_buf;
|
||||
Elf_Type d_type;
|
||||
size_t d_size;
|
||||
off_t d_off;
|
||||
size_t d_align;
|
||||
unsigned d_version;
|
||||
} Elf_Data;
|
||||
|
||||
/*
|
||||
* Function declarations
|
||||
*/
|
||||
extern Elf *elf_begin __P((int __fd, Elf_Cmd __cmd, Elf *__ref));
|
||||
extern Elf *elf_memory __P((char *__image, size_t __size));
|
||||
extern int elf_cntl __P((Elf *__elf, Elf_Cmd __cmd));
|
||||
extern int elf_end __P((Elf *__elf));
|
||||
extern const char *elf_errmsg __P((int __err));
|
||||
extern int elf_errno __P((void));
|
||||
extern void elf_fill __P((int __fill));
|
||||
extern unsigned elf_flagdata __P((Elf_Data *__data, Elf_Cmd __cmd,
|
||||
unsigned __flags));
|
||||
extern unsigned elf_flagehdr __P((Elf *__elf, Elf_Cmd __cmd,
|
||||
unsigned __flags));
|
||||
extern unsigned elf_flagelf __P((Elf *__elf, Elf_Cmd __cmd,
|
||||
unsigned __flags));
|
||||
extern unsigned elf_flagphdr __P((Elf *__elf, Elf_Cmd __cmd,
|
||||
unsigned __flags));
|
||||
extern unsigned elf_flagscn __P((Elf_Scn *__scn, Elf_Cmd __cmd,
|
||||
unsigned __flags));
|
||||
extern unsigned elf_flagshdr __P((Elf_Scn *__scn, Elf_Cmd __cmd,
|
||||
unsigned __flags));
|
||||
extern size_t elf32_fsize __P((Elf_Type __type, size_t __count,
|
||||
unsigned __ver));
|
||||
extern Elf_Arhdr *elf_getarhdr __P((Elf *__elf));
|
||||
extern Elf_Arsym *elf_getarsym __P((Elf *__elf, size_t *__ptr));
|
||||
extern off_t elf_getbase __P((Elf *__elf));
|
||||
extern Elf_Data *elf_getdata __P((Elf_Scn *__scn, Elf_Data *__data));
|
||||
extern Elf32_Ehdr *elf32_getehdr __P((Elf *__elf));
|
||||
extern char *elf_getident __P((Elf *__elf, size_t *__ptr));
|
||||
extern Elf32_Phdr *elf32_getphdr __P((Elf *__elf));
|
||||
extern Elf_Scn *elf_getscn __P((Elf *__elf, size_t __index));
|
||||
extern Elf32_Shdr *elf32_getshdr __P((Elf_Scn *__scn));
|
||||
extern unsigned long elf_hash __P((const unsigned char *__name));
|
||||
extern Elf_Kind elf_kind __P((Elf *__elf));
|
||||
extern size_t elf_ndxscn __P((Elf_Scn *__scn));
|
||||
extern Elf_Data *elf_newdata __P((Elf_Scn *__scn));
|
||||
extern Elf32_Ehdr *elf32_newehdr __P((Elf *__elf));
|
||||
extern Elf32_Phdr *elf32_newphdr __P((Elf *__elf, size_t __count));
|
||||
extern Elf_Scn *elf_newscn __P((Elf *__elf));
|
||||
extern Elf_Cmd elf_next __P((Elf *__elf));
|
||||
extern Elf_Scn *elf_nextscn __P((Elf *__elf, Elf_Scn *__scn));
|
||||
extern size_t elf_rand __P((Elf *__elf, size_t __offset));
|
||||
extern Elf_Data *elf_rawdata __P((Elf_Scn *__scn, Elf_Data *__data));
|
||||
extern char *elf_rawfile __P((Elf *__elf, size_t *__ptr));
|
||||
extern char *elf_strptr __P((Elf *__elf, size_t __section, size_t __offset));
|
||||
extern off_t elf_update __P((Elf *__elf, Elf_Cmd __cmd));
|
||||
extern unsigned elf_version __P((unsigned __ver));
|
||||
extern Elf_Data *elf32_xlatetof __P((Elf_Data *__dst, const Elf_Data *__src,
|
||||
unsigned __encode));
|
||||
extern Elf_Data *elf32_xlatetom __P((Elf_Data *__dst, const Elf_Data *__src,
|
||||
unsigned __encode));
|
||||
|
||||
/*
|
||||
* Additional functions found on Solaris
|
||||
*/
|
||||
extern long elf32_checksum __P((Elf *__elf));
|
||||
|
||||
#if __LIBELF64
|
||||
/*
|
||||
* 64-bit ELF functions
|
||||
* Not available on all platforms
|
||||
*/
|
||||
extern Elf64_Ehdr *elf64_getehdr __P((Elf *__elf));
|
||||
extern Elf64_Ehdr *elf64_newehdr __P((Elf *__elf));
|
||||
extern Elf64_Phdr *elf64_getphdr __P((Elf *__elf));
|
||||
extern Elf64_Phdr *elf64_newphdr __P((Elf *__elf, size_t __count));
|
||||
extern Elf64_Shdr *elf64_getshdr __P((Elf_Scn *__scn));
|
||||
extern size_t elf64_fsize __P((Elf_Type __type, size_t __count,
|
||||
unsigned __ver));
|
||||
extern Elf_Data *elf64_xlatetof __P((Elf_Data *__dst, const Elf_Data *__src,
|
||||
unsigned __encode));
|
||||
extern Elf_Data *elf64_xlatetom __P((Elf_Data *__dst, const Elf_Data *__src,
|
||||
unsigned __encode));
|
||||
|
||||
/*
|
||||
* Additional functions found on Solaris
|
||||
*/
|
||||
extern long elf64_checksum __P((Elf *__elf));
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* ELF format extensions
|
||||
*
|
||||
* These functions return 0 on failure, 1 on success. Since other
|
||||
* implementations of libelf may behave differently (there was quite
|
||||
* some confusion about the correct values), they are now officially
|
||||
* deprecated and should be replaced with the three new functions below.
|
||||
*/
|
||||
DEPRECATED extern int elf_getphnum __P((Elf *__elf, size_t *__resultp));
|
||||
DEPRECATED extern int elf_getshnum __P((Elf *__elf, size_t *__resultp));
|
||||
DEPRECATED extern int elf_getshstrndx __P((Elf *__elf, size_t *__resultp));
|
||||
/*
|
||||
* Replacement functions (return -1 on failure, 0 on success).
|
||||
*/
|
||||
extern int elf_getphdrnum __P((Elf *__elf, size_t *__resultp));
|
||||
extern int elf_getshdrnum __P((Elf *__elf, size_t *__resultp));
|
||||
extern int elf_getshdrstrndx __P((Elf *__elf, size_t *__resultp));
|
||||
|
||||
/*
|
||||
* Convenience functions
|
||||
*
|
||||
* elfx_update_shstrndx is elf_getshstrndx's counterpart.
|
||||
* It should be used to set the e_shstrndx member.
|
||||
* There is no update function for e_shnum or e_phnum
|
||||
* because libelf handles them internally.
|
||||
*/
|
||||
extern int elfx_update_shstrndx __P((Elf *__elf, size_t __index));
|
||||
|
||||
/*
|
||||
* Experimental extensions:
|
||||
*
|
||||
* elfx_movscn() moves section `__scn' directly after section `__after'.
|
||||
* elfx_remscn() removes section `__scn'. Both functions update
|
||||
* the section indices; elfx_remscn() also adjusts the ELF header's
|
||||
* e_shnum member. The application is responsible for updating other
|
||||
* data (in particular, e_shstrndx and the section headers' sh_link and
|
||||
* sh_info members).
|
||||
*
|
||||
* elfx_movscn() returns the new index of the moved section.
|
||||
* elfx_remscn() returns the original index of the removed section.
|
||||
* A return value of zero indicates an error.
|
||||
*/
|
||||
extern size_t elfx_movscn __P((Elf *__elf, Elf_Scn *__scn, Elf_Scn *__after));
|
||||
extern size_t elfx_remscn __P((Elf *__elf, Elf_Scn *__scn));
|
||||
|
||||
/*
|
||||
* elf_delscn() is obsolete. Please use elfx_remscn() instead.
|
||||
*/
|
||||
extern size_t elf_delscn __P((Elf *__elf, Elf_Scn *__scn));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LIBELF_H */
|
||||
+996
@@ -0,0 +1,996 @@
|
||||
/*
|
||||
* elf_repl.h - public header file for systems that lack it.
|
||||
* Copyright (C) 1995 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* @(#) $Id: elf_repl.h,v 1.22 2009/11/01 13:04:19 michael Exp $ */
|
||||
|
||||
/*
|
||||
* NEVER INCLUDE THIS FILE DIRECTLY - USE <libelf.h> INSTEAD!
|
||||
*/
|
||||
|
||||
#ifndef _ELF_REPL_H
|
||||
#define _ELF_REPL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Scalar data types
|
||||
*/
|
||||
typedef __libelf_u32_t Elf32_Addr;
|
||||
typedef __libelf_u16_t Elf32_Half;
|
||||
typedef __libelf_u32_t Elf32_Off;
|
||||
typedef __libelf_i32_t Elf32_Sword;
|
||||
typedef __libelf_u32_t Elf32_Word;
|
||||
|
||||
#define ELF32_FSZ_ADDR 4
|
||||
#define ELF32_FSZ_HALF 2
|
||||
#define ELF32_FSZ_OFF 4
|
||||
#define ELF32_FSZ_SWORD 4
|
||||
#define ELF32_FSZ_WORD 4
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
typedef __libelf_u64_t Elf64_Addr;
|
||||
typedef __libelf_u16_t Elf64_Half;
|
||||
typedef __libelf_u64_t Elf64_Off;
|
||||
typedef __libelf_i32_t Elf64_Sword;
|
||||
typedef __libelf_u32_t Elf64_Word;
|
||||
typedef __libelf_i64_t Elf64_Sxword;
|
||||
typedef __libelf_u64_t Elf64_Xword;
|
||||
|
||||
#define ELF64_FSZ_ADDR 8
|
||||
#define ELF64_FSZ_HALF 2
|
||||
#define ELF64_FSZ_OFF 8
|
||||
#define ELF64_FSZ_SWORD 4
|
||||
#define ELF64_FSZ_WORD 4
|
||||
#define ELF64_FSZ_SXWORD 8
|
||||
#define ELF64_FSZ_XWORD 8
|
||||
|
||||
/*
|
||||
* Blame Sun for this...
|
||||
*/
|
||||
typedef __libelf_u64_t Elf64_Lword;
|
||||
typedef __libelf_u64_t Elf32_Lword;
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* ELF header
|
||||
*/
|
||||
#define EI_NIDENT 16
|
||||
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT];
|
||||
Elf32_Half e_type;
|
||||
Elf32_Half e_machine;
|
||||
Elf32_Word e_version;
|
||||
Elf32_Addr e_entry;
|
||||
Elf32_Off e_phoff;
|
||||
Elf32_Off e_shoff;
|
||||
Elf32_Word e_flags;
|
||||
Elf32_Half e_ehsize;
|
||||
Elf32_Half e_phentsize;
|
||||
Elf32_Half e_phnum;
|
||||
Elf32_Half e_shentsize;
|
||||
Elf32_Half e_shnum;
|
||||
Elf32_Half e_shstrndx;
|
||||
} Elf32_Ehdr;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT];
|
||||
Elf64_Half e_type;
|
||||
Elf64_Half e_machine;
|
||||
Elf64_Word e_version;
|
||||
Elf64_Addr e_entry;
|
||||
Elf64_Off e_phoff;
|
||||
Elf64_Off e_shoff;
|
||||
Elf64_Word e_flags;
|
||||
Elf64_Half e_ehsize;
|
||||
Elf64_Half e_phentsize;
|
||||
Elf64_Half e_phnum;
|
||||
Elf64_Half e_shentsize;
|
||||
Elf64_Half e_shnum;
|
||||
Elf64_Half e_shstrndx;
|
||||
} Elf64_Ehdr;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* e_ident
|
||||
*/
|
||||
#define EI_MAG0 0
|
||||
#define EI_MAG1 1
|
||||
#define EI_MAG2 2
|
||||
#define EI_MAG3 3
|
||||
#define EI_CLASS 4
|
||||
#define EI_DATA 5
|
||||
#define EI_VERSION 6
|
||||
#define EI_OSABI 7
|
||||
#define EI_ABIVERSION 8
|
||||
#define EI_PAD 9
|
||||
|
||||
#define ELFMAG0 0x7f
|
||||
#define ELFMAG1 'E'
|
||||
#define ELFMAG2 'L'
|
||||
#define ELFMAG3 'F'
|
||||
#define ELFMAG "\177ELF"
|
||||
#define SELFMAG 4
|
||||
|
||||
/*
|
||||
* e_ident[EI_CLASS]
|
||||
*/
|
||||
#define ELFCLASSNONE 0
|
||||
#define ELFCLASS32 1
|
||||
#define ELFCLASS64 2
|
||||
#define ELFCLASSNUM 3
|
||||
|
||||
/*
|
||||
* e_ident[EI_DATA]
|
||||
*/
|
||||
#define ELFDATANONE 0
|
||||
#define ELFDATA2LSB 1
|
||||
#define ELFDATA2MSB 2
|
||||
#define ELFDATANUM 3
|
||||
|
||||
/*
|
||||
* e_ident[EI_OSABI]
|
||||
*/
|
||||
#define ELFOSABI_NONE 0 /* No extensions or unspecified */
|
||||
#define ELFOSABI_SYSV ELFOSABI_NONE
|
||||
#define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */
|
||||
#define ELFOSABI_NETBSD 2 /* NetBSD */
|
||||
#define ELFOSABI_LINUX 3 /* Linux */
|
||||
#define ELFOSABI_SOLARIS 6 /* Sun Solaris */
|
||||
#define ELFOSABI_AIX 7 /* AIX */
|
||||
#define ELFOSABI_IRIX 8 /* IRIX */
|
||||
#define ELFOSABI_FREEBSD 9 /* FreeBSD */
|
||||
#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */
|
||||
#define ELFOSABI_MODESTO 11 /* Novell Modesto */
|
||||
#define ELFOSABI_OPENBSD 12 /* Open BSD */
|
||||
#define ELFOSABI_OPENVMS 13 /* Open VMS */
|
||||
#define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */
|
||||
#define ELFOSABI_AROS 15 /* Amiga Research OS */
|
||||
/* these are probably obsolete: */
|
||||
#define ELFOSABI_ARM 97 /* ARM */
|
||||
#define ELFOSABI_STANDALONE 255 /* standalone (embedded) application */
|
||||
|
||||
|
||||
/*
|
||||
* e_type
|
||||
*/
|
||||
#define ET_NONE 0
|
||||
#define ET_REL 1
|
||||
#define ET_EXEC 2
|
||||
#define ET_DYN 3
|
||||
#define ET_CORE 4
|
||||
#define ET_NUM 5
|
||||
#define ET_LOOS 0xfe00
|
||||
#define ET_HIOS 0xfeff
|
||||
#define ET_LOPROC 0xff00
|
||||
#define ET_HIPROC 0xffff
|
||||
|
||||
/*
|
||||
* e_machine
|
||||
*/
|
||||
#define EM_NONE 0 /* No machine */
|
||||
#define EM_M32 1 /* AT&T WE 32100 */
|
||||
#define EM_SPARC 2 /* SPARC */
|
||||
#define EM_386 3 /* Intel 80386 */
|
||||
#define EM_68K 4 /* Motorola 68000 */
|
||||
#define EM_88K 5 /* Motorola 88000 */
|
||||
#define EM_486 6 /* Intel i486 (DO NOT USE THIS ONE) */
|
||||
#define EM_860 7 /* Intel 80860 */
|
||||
#define EM_MIPS 8 /* MIPS I Architecture */
|
||||
#define EM_S370 9 /* IBM System/370 Processor */
|
||||
#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
|
||||
#define EM_SPARC64 11 /* SPARC 64-bit */
|
||||
#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */
|
||||
#define EM_VPP500 17 /* Fujitsu VPP500 */
|
||||
#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
|
||||
#define EM_960 19 /* Intel 80960 */
|
||||
#define EM_PPC 20 /* PowerPC */
|
||||
#define EM_PPC64 21 /* 64-bit PowerPC */
|
||||
#define EM_S390 22 /* IBM System/390 Processor */
|
||||
#define EM_V800 36 /* NEC V800 */
|
||||
#define EM_FR20 37 /* Fujitsu FR20 */
|
||||
#define EM_RH32 38 /* TRW RH-32 */
|
||||
#define EM_RCE 39 /* Motorola RCE */
|
||||
#define EM_ARM 40 /* Advanced RISC Machines ARM */
|
||||
#define EM_ALPHA 41 /* Digital Alpha */
|
||||
#define EM_SH 42 /* Hitachi SH */
|
||||
#define EM_SPARCV9 43 /* SPARC Version 9 */
|
||||
#define EM_TRICORE 44 /* Siemens TriCore embedded processor */
|
||||
#define EM_ARC 45 /* Argonaut RISC Core, Argonaut Technologies Inc. */
|
||||
#define EM_H8_300 46 /* Hitachi H8/300 */
|
||||
#define EM_H8_300H 47 /* Hitachi H8/300H */
|
||||
#define EM_H8S 48 /* Hitachi H8S */
|
||||
#define EM_H8_500 49 /* Hitachi H8/500 */
|
||||
#define EM_IA_64 50 /* Intel IA-64 processor architecture */
|
||||
#define EM_MIPS_X 51 /* Stanford MIPS-X */
|
||||
#define EM_COLDFIRE 52 /* Motorola ColdFire */
|
||||
#define EM_68HC12 53 /* Motorola M68HC12 */
|
||||
#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */
|
||||
#define EM_PCP 55 /* Siemens PCP */
|
||||
#define EM_NCPU 56 /* Sony nCPU embedded RISC processor */
|
||||
#define EM_NDR1 57 /* Denso NDR1 microprocessor */
|
||||
#define EM_STARCORE 58 /* Motorola Star*Core processor */
|
||||
#define EM_ME16 59 /* Toyota ME16 processor */
|
||||
#define EM_ST100 60 /* STMicroelectronics ST100 processor */
|
||||
#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded processor family */
|
||||
#define EM_X86_64 62 /* AMD x86-64 architecture */
|
||||
#define EM_AMD64 EM_X86_64
|
||||
#define EM_PDSP 63 /* Sony DSP Processor */
|
||||
#define EM_FX66 66 /* Siemens FX66 microcontroller */
|
||||
#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */
|
||||
#define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */
|
||||
#define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */
|
||||
#define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */
|
||||
#define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */
|
||||
#define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */
|
||||
#define EM_SVX 73 /* Silicon Graphics SVx */
|
||||
#define EM_ST19 74 /* STMicroelectronics ST19 8-bit microcontroller */
|
||||
#define EM_VAX 75 /* Digital VAX */
|
||||
#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
|
||||
#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
|
||||
#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
|
||||
#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
|
||||
#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
|
||||
#define EM_HUANY 81 /* Harvard University machine-independent object files */
|
||||
#define EM_PRISM 82 /* SiTera Prism */
|
||||
#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
|
||||
#define EM_FR30 84 /* Fujitsu FR30 */
|
||||
#define EM_D10V 85 /* Mitsubishi D10V */
|
||||
#define EM_D30V 86 /* Mitsubishi D30V */
|
||||
#define EM_V850 87 /* NEC v850 */
|
||||
#define EM_M32R 88 /* Mitsubishi M32R */
|
||||
#define EM_MN10300 89 /* Matsushita MN10300 */
|
||||
#define EM_MN10200 90 /* Matsushita MN10200 */
|
||||
#define EM_PJ 91 /* picoJava */
|
||||
#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
|
||||
#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
|
||||
#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
|
||||
#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */
|
||||
#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */
|
||||
#define EM_NS32K 97 /* National Semiconductor 32000 series */
|
||||
#define EM_TPC 98 /* Tenor Network TPC processor */
|
||||
#define EM_SNP1K 99 /* Trebia SNP 1000 processor */
|
||||
#define EM_ST200 100 /* STMicroelectronics (www.st.com) ST200 microcontroller */
|
||||
#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */
|
||||
#define EM_MAX 102 /* MAX Processor */
|
||||
#define EM_CR 103 /* National Semiconductor CompactRISC microprocessor */
|
||||
#define EM_F2MC16 104 /* Fujitsu F2MC16 */
|
||||
#define EM_MSP430 105 /* Texas Instruments embedded microcontroller msp430 */
|
||||
#define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor */
|
||||
#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors */
|
||||
#define EM_SEP 108 /* Sharp embedded microprocessor */
|
||||
#define EM_ARCA 109 /* Arca RISC Microprocessor */
|
||||
#define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University */
|
||||
#define EM_NUM 111
|
||||
|
||||
/*
|
||||
* e_ident[EI_VERSION], e_version
|
||||
*/
|
||||
#define EV_NONE 0
|
||||
#define EV_CURRENT 1
|
||||
#define EV_NUM 2
|
||||
|
||||
/*
|
||||
* Section header
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Word sh_name;
|
||||
Elf32_Word sh_type;
|
||||
Elf32_Word sh_flags;
|
||||
Elf32_Addr sh_addr;
|
||||
Elf32_Off sh_offset;
|
||||
Elf32_Word sh_size;
|
||||
Elf32_Word sh_link;
|
||||
Elf32_Word sh_info;
|
||||
Elf32_Word sh_addralign;
|
||||
Elf32_Word sh_entsize;
|
||||
} Elf32_Shdr;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
Elf64_Word sh_name;
|
||||
Elf64_Word sh_type;
|
||||
Elf64_Xword sh_flags;
|
||||
Elf64_Addr sh_addr;
|
||||
Elf64_Off sh_offset;
|
||||
Elf64_Xword sh_size;
|
||||
Elf64_Word sh_link;
|
||||
Elf64_Word sh_info;
|
||||
Elf64_Xword sh_addralign;
|
||||
Elf64_Xword sh_entsize;
|
||||
} Elf64_Shdr;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Special section indices
|
||||
*/
|
||||
#define SHN_UNDEF 0
|
||||
#define SHN_LORESERVE 0xff00
|
||||
#define SHN_LOPROC 0xff00
|
||||
#define SHN_HIPROC 0xff1f
|
||||
#define SHN_LOOS 0xff20
|
||||
#define SHN_HIOS 0xff3f
|
||||
#define SHN_ABS 0xfff1
|
||||
#define SHN_COMMON 0xfff2
|
||||
#define SHN_XINDEX 0xffff
|
||||
#define SHN_HIRESERVE 0xffff
|
||||
|
||||
/*
|
||||
* sh_type
|
||||
*/
|
||||
#define SHT_NULL 0
|
||||
#define SHT_PROGBITS 1
|
||||
#define SHT_SYMTAB 2
|
||||
#define SHT_STRTAB 3
|
||||
#define SHT_RELA 4
|
||||
#define SHT_HASH 5
|
||||
#define SHT_DYNAMIC 6
|
||||
#define SHT_NOTE 7
|
||||
#define SHT_NOBITS 8
|
||||
#define SHT_REL 9
|
||||
#define SHT_SHLIB 10
|
||||
#define SHT_DYNSYM 11
|
||||
#define SHT_INIT_ARRAY 14
|
||||
#define SHT_FINI_ARRAY 15
|
||||
#define SHT_PREINIT_ARRAY 16
|
||||
#define SHT_GROUP 17
|
||||
#define SHT_SYMTAB_SHNDX 18
|
||||
#define SHT_NUM 19
|
||||
#define SHT_LOOS 0x60000000
|
||||
#define SHT_HIOS 0x6fffffff
|
||||
#define SHT_LOPROC 0x70000000
|
||||
#define SHT_HIPROC 0x7fffffff
|
||||
#define SHT_LOUSER 0x80000000
|
||||
#define SHT_HIUSER 0xffffffff
|
||||
|
||||
/*
|
||||
* Solaris extensions
|
||||
*/
|
||||
#define SHT_LOSUNW 0x6ffffff4
|
||||
#define SHT_SUNW_dof 0x6ffffff4
|
||||
#define SHT_SUNW_cap 0x6ffffff5
|
||||
#define SHT_SUNW_SIGNATURE 0x6ffffff6
|
||||
#define SHT_SUNW_ANNOTATE 0x6ffffff7
|
||||
#define SHT_SUNW_DEBUGSTR 0x6ffffff8
|
||||
#define SHT_SUNW_DEBUG 0x6ffffff9
|
||||
#define SHT_SUNW_move 0x6ffffffa
|
||||
#define SHT_SUNW_COMDAT 0x6ffffffb
|
||||
#define SHT_SUNW_syminfo 0x6ffffffc
|
||||
#define SHT_SUNW_verdef 0x6ffffffd
|
||||
#define SHT_SUNW_verneed 0x6ffffffe
|
||||
#define SHT_SUNW_versym 0x6fffffff
|
||||
#define SHT_HISUNW 0x6fffffff
|
||||
|
||||
#define SHT_SPARC_GOTDATA 0x70000000
|
||||
#define SHT_AMD64_UNWIND 0x70000001
|
||||
|
||||
/*
|
||||
* GNU extensions
|
||||
*/
|
||||
#define SHT_GNU_verdef 0x6ffffffd
|
||||
#define SHT_GNU_verneed 0x6ffffffe
|
||||
#define SHT_GNU_versym 0x6fffffff
|
||||
|
||||
/*
|
||||
* sh_flags
|
||||
*/
|
||||
#define SHF_WRITE 0x1
|
||||
#define SHF_ALLOC 0x2
|
||||
#define SHF_EXECINSTR 0x4
|
||||
#define SHF_MERGE 0x10
|
||||
#define SHF_STRINGS 0x20
|
||||
#define SHF_INFO_LINK 0x40
|
||||
#define SHF_LINK_ORDER 0x80
|
||||
#define SHF_OS_NONCONFORMING 0x100
|
||||
#define SHF_GROUP 0x200
|
||||
#define SHF_TLS 0x400
|
||||
#define SHF_MASKOS 0x0ff00000
|
||||
#define SHF_MASKPROC 0xf0000000
|
||||
|
||||
/*
|
||||
* Solaris extensions
|
||||
*/
|
||||
#define SHF_AMD64_LARGE 0x10000000
|
||||
#define SHF_ORDERED 0x40000000
|
||||
#define SHF_EXCLUDE 0x80000000
|
||||
|
||||
/*
|
||||
* Section group flags
|
||||
*/
|
||||
#define GRP_COMDAT 0x1
|
||||
#define GRP_MASKOS 0x0ff00000
|
||||
#define GRP_MASKPROC 0xf0000000
|
||||
|
||||
/*
|
||||
* Symbol table
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Word st_name;
|
||||
Elf32_Addr st_value;
|
||||
Elf32_Word st_size;
|
||||
unsigned char st_info;
|
||||
unsigned char st_other;
|
||||
Elf32_Half st_shndx;
|
||||
} Elf32_Sym;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
Elf64_Word st_name;
|
||||
unsigned char st_info;
|
||||
unsigned char st_other;
|
||||
Elf64_Half st_shndx;
|
||||
Elf64_Addr st_value;
|
||||
Elf64_Xword st_size;
|
||||
} Elf64_Sym;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Special symbol indices
|
||||
*/
|
||||
#define STN_UNDEF 0
|
||||
|
||||
/*
|
||||
* Macros for manipulating st_info
|
||||
*/
|
||||
#define ELF32_ST_BIND(i) ((i)>>4)
|
||||
#define ELF32_ST_TYPE(i) ((i)&0xf)
|
||||
#define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
|
||||
|
||||
#if __LIBELF64
|
||||
#define ELF64_ST_BIND(i) ((i)>>4)
|
||||
#define ELF64_ST_TYPE(i) ((i)&0xf)
|
||||
#define ELF64_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Symbol binding
|
||||
*/
|
||||
#define STB_LOCAL 0
|
||||
#define STB_GLOBAL 1
|
||||
#define STB_WEAK 2
|
||||
#define STB_NUM 3
|
||||
#define STB_LOOS 10
|
||||
#define STB_HIOS 12
|
||||
#define STB_LOPROC 13
|
||||
#define STB_HIPROC 15
|
||||
|
||||
/*
|
||||
* Symbol types
|
||||
*/
|
||||
#define STT_NOTYPE 0
|
||||
#define STT_OBJECT 1
|
||||
#define STT_FUNC 2
|
||||
#define STT_SECTION 3
|
||||
#define STT_FILE 4
|
||||
#define STT_COMMON 5
|
||||
#define STT_TLS 6
|
||||
#define STT_NUM 7
|
||||
#define STT_LOOS 10
|
||||
#define STT_HIOS 12
|
||||
#define STT_LOPROC 13
|
||||
#define STT_HIPROC 15
|
||||
|
||||
/*
|
||||
* Macros for manipulating st_other
|
||||
*/
|
||||
#define ELF32_ST_VISIBILITY(o) ((o)&0x3)
|
||||
#if __LIBELF64
|
||||
#define ELF64_ST_VISIBILITY(o) ((o)&0x3)
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Symbol visibility
|
||||
*/
|
||||
#define STV_DEFAULT 0
|
||||
#define STV_INTERNAL 1
|
||||
#define STV_HIDDEN 2
|
||||
#define STV_PROTECTED 3
|
||||
|
||||
/*
|
||||
* Relocation
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Addr r_offset;
|
||||
Elf32_Word r_info;
|
||||
} Elf32_Rel;
|
||||
|
||||
typedef struct {
|
||||
Elf32_Addr r_offset;
|
||||
Elf32_Word r_info;
|
||||
Elf32_Sword r_addend;
|
||||
} Elf32_Rela;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
Elf64_Addr r_offset;
|
||||
Elf64_Xword r_info;
|
||||
} Elf64_Rel;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Addr r_offset;
|
||||
Elf64_Xword r_info;
|
||||
Elf64_Sxword r_addend;
|
||||
} Elf64_Rela;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Macros for manipulating r_info
|
||||
*/
|
||||
#define ELF32_R_SYM(i) ((i)>>8)
|
||||
#define ELF32_R_TYPE(i) ((unsigned char)(i))
|
||||
#define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t))
|
||||
|
||||
#if __LIBELF64
|
||||
#define ELF64_R_SYM(i) ((Elf64_Xword)(i)>>32)
|
||||
#define ELF64_R_TYPE(i) ((i)&0xffffffffL)
|
||||
#define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Note entry header
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Word n_namesz; /* name size */
|
||||
Elf32_Word n_descsz; /* descriptor size */
|
||||
Elf32_Word n_type; /* descriptor type */
|
||||
} Elf32_Nhdr;
|
||||
|
||||
#if __LIBELF64
|
||||
/* Solaris and GNU use this layout. Be compatible. */
|
||||
/* XXX: Latest ELF specs say it's 64-bit!!! */
|
||||
typedef struct {
|
||||
Elf64_Word n_namesz; /* name size */
|
||||
Elf64_Word n_descsz; /* descriptor size */
|
||||
Elf64_Word n_type; /* descriptor type */
|
||||
} Elf64_Nhdr;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Well-known descriptor types for ET_CORE files
|
||||
*/
|
||||
#define NT_PRSTATUS 1
|
||||
#define NT_PRFPREG 2
|
||||
#define NT_PRPSINFO 3
|
||||
|
||||
/*
|
||||
* Program header
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Word p_type;
|
||||
Elf32_Off p_offset;
|
||||
Elf32_Addr p_vaddr;
|
||||
Elf32_Addr p_paddr;
|
||||
Elf32_Word p_filesz;
|
||||
Elf32_Word p_memsz;
|
||||
Elf32_Word p_flags;
|
||||
Elf32_Word p_align;
|
||||
} Elf32_Phdr;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
Elf64_Word p_type;
|
||||
Elf64_Word p_flags;
|
||||
Elf64_Off p_offset;
|
||||
Elf64_Addr p_vaddr;
|
||||
Elf64_Addr p_paddr;
|
||||
Elf64_Xword p_filesz;
|
||||
Elf64_Xword p_memsz;
|
||||
Elf64_Xword p_align;
|
||||
} Elf64_Phdr;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Special numbers
|
||||
*/
|
||||
#define PN_XNUM 0xffff
|
||||
|
||||
/*
|
||||
* p_type
|
||||
*/
|
||||
#define PT_NULL 0
|
||||
#define PT_LOAD 1
|
||||
#define PT_DYNAMIC 2
|
||||
#define PT_INTERP 3
|
||||
#define PT_NOTE 4
|
||||
#define PT_SHLIB 5
|
||||
#define PT_PHDR 6
|
||||
#define PT_TLS 7
|
||||
#define PT_NUM 8
|
||||
#define PT_LOOS 0x60000000
|
||||
#define PT_HIOS 0x6fffffff
|
||||
#define PT_LOPROC 0x70000000
|
||||
#define PT_HIPROC 0x7fffffff
|
||||
|
||||
/*
|
||||
* Solaris extensions
|
||||
*/
|
||||
|
||||
#define PT_SUNW_UNWIND 0x6464e550
|
||||
#define PT_LOSUNW 0x6ffffffa
|
||||
#define PT_SUNWBSS 0x6ffffffa
|
||||
#define PT_SUNWSTACK 0x6ffffffb
|
||||
#define PT_SUNWDTRACE 0x6ffffffc
|
||||
#define PT_SUNWCAP 0x6ffffffd
|
||||
#define PT_HISUNW 0x6fffffff
|
||||
|
||||
/*
|
||||
* p_flags
|
||||
*/
|
||||
#define PF_X 0x1
|
||||
#define PF_W 0x2
|
||||
#define PF_R 0x4
|
||||
#define PF_MASKOS 0x0ff00000
|
||||
#define PF_MASKPROC 0xf0000000
|
||||
|
||||
/*
|
||||
* Dynamic structure
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Sword d_tag;
|
||||
union {
|
||||
Elf32_Word d_val;
|
||||
Elf32_Addr d_ptr;
|
||||
} d_un;
|
||||
} Elf32_Dyn;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
Elf64_Sxword d_tag;
|
||||
union {
|
||||
Elf64_Xword d_val;
|
||||
Elf64_Addr d_ptr;
|
||||
} d_un;
|
||||
} Elf64_Dyn;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Dynamic array tags
|
||||
*/
|
||||
/* d_un exec shared */
|
||||
#define DT_NULL 0 /* ign. mand. mand. */
|
||||
#define DT_NEEDED 1 /* d_val opt. opt. */
|
||||
#define DT_PLTRELSZ 2 /* d_val opt. opt. */
|
||||
#define DT_PLTGOT 3 /* d_ptr opt. opt. */
|
||||
#define DT_HASH 4 /* d_ptr mand. mand. */
|
||||
#define DT_STRTAB 5 /* d_ptr mand. mand. */
|
||||
#define DT_SYMTAB 6 /* d_ptr mand. mand. */
|
||||
#define DT_RELA 7 /* d_ptr mand. opt. */
|
||||
#define DT_RELASZ 8 /* d_val mand. opt. */
|
||||
#define DT_RELAENT 9 /* d_val mand. opt. */
|
||||
#define DT_STRSZ 10 /* d_val mand. mand. */
|
||||
#define DT_SYMENT 11 /* d_val mand. mand. */
|
||||
#define DT_INIT 12 /* d_ptr opt. opt. */
|
||||
#define DT_FINI 13 /* d_ptr opt. opt. */
|
||||
#define DT_SONAME 14 /* d_val ign. opt. */
|
||||
#define DT_RPATH 15 /* d_val opt. ign. */
|
||||
#define DT_SYMBOLIC 16 /* ign. ign. opt. */
|
||||
#define DT_REL 17 /* d_ptr mand. opt. */
|
||||
#define DT_RELSZ 18 /* d_val mand. opt. */
|
||||
#define DT_RELENT 19 /* d_val mand. opt. */
|
||||
#define DT_PLTREL 20 /* d_val opt. opt. */
|
||||
#define DT_DEBUG 21 /* d_ptr opt. ign. */
|
||||
#define DT_TEXTREL 22 /* ign. opt. opt. */
|
||||
#define DT_JMPREL 23 /* d_ptr opt. opt. */
|
||||
#define DT_BIND_NOW 24 /* ign. opt. opt. */
|
||||
#define DT_INIT_ARRAY 25 /* d_ptr opt. opt. */
|
||||
#define DT_FINI_ARRAY 26 /* d_ptr opt. opt. */
|
||||
#define DT_INIT_ARRAYSZ 27 /* d_val opt. opt. */
|
||||
#define DT_FINI_ARRAYSZ 28 /* d_val opt. opt. */
|
||||
#define DT_RUNPATH 29 /* d_val opt. opt. */
|
||||
#define DT_FLAGS 30 /* d_val opt. opt. */
|
||||
#define DT_ENCODING 32 /* odd/even encoding rule starts here */
|
||||
#define DT_PREINIT_ARRAY 32 /* d_ptr opt. ign. */
|
||||
#define DT_PREINIT_ARRAYSZ 33 /* d_val opt. ign. */
|
||||
#define DT_NUM 34
|
||||
#define DT_LOOS 0x6000000D
|
||||
#define DT_HIOS 0x6ffff000
|
||||
#define DT_LOPROC 0x70000000
|
||||
#define DT_HIPROC 0x7fffffff
|
||||
|
||||
/*
|
||||
* DT_FLAGS values
|
||||
*/
|
||||
#define DF_ORIGIN 0x1
|
||||
#define DF_SYMBOLIC 0x2
|
||||
#define DF_TEXTREL 0x4
|
||||
#define DF_BIND_NOW 0x8
|
||||
#define DF_STATIC_TLS 0x10
|
||||
|
||||
/*
|
||||
* Solaris extensions
|
||||
*/
|
||||
#define DT_VALRNGLO 0x6ffffd00
|
||||
#define DT_CHECKSUM 0x6ffffdf8
|
||||
#define DT_PLTPADSZ 0x6ffffdf9
|
||||
#define DT_MOVEENT 0x6ffffdfa
|
||||
#define DT_MOVESZ 0x6ffffdfb
|
||||
#define DT_FEATURE_1 0x6ffffdfc
|
||||
#define DT_POSFLAG_1 0x6ffffdfd
|
||||
#define DT_SYMINSZ 0x6ffffdfe
|
||||
#define DT_SYMINENT 0x6ffffdff
|
||||
#define DT_VALRNGHI 0x6ffffdff
|
||||
|
||||
#define DT_ADDRRNGLO 0x6ffffe00
|
||||
#define DT_CONFIG 0x6ffffefa
|
||||
#define DT_DEPAUDIT 0x6ffffefb
|
||||
#define DT_AUDIT 0x6ffffefc
|
||||
#define DT_PLTPAD 0x6ffffefd
|
||||
#define DT_MOVETAB 0x6ffffefe
|
||||
#define DT_SYMINFO 0x6ffffeff
|
||||
#define DT_ADDRRNGHI 0x6ffffeff
|
||||
|
||||
#define DT_RELACOUNT 0x6ffffff9
|
||||
#define DT_RELCOUNT 0x6ffffffa
|
||||
#define DT_FLAGS_1 0x6ffffffb
|
||||
#define DT_VERDEF 0x6ffffffc
|
||||
#define DT_VERDEFNUM 0x6ffffffd
|
||||
#define DT_VERNEED 0x6ffffffe
|
||||
#define DT_VERNEEDNUM 0x6fffffff
|
||||
|
||||
#define DT_AUXILIARY 0x7ffffffd
|
||||
#define DT_USED 0x7ffffffe
|
||||
#define DT_FILTER 0x7fffffff
|
||||
|
||||
/*
|
||||
* GNU extensions
|
||||
*/
|
||||
#define DT_VERSYM 0x6ffffff0
|
||||
|
||||
/*
|
||||
* DT_FEATURE_1 values
|
||||
*/
|
||||
#define DTF_1_PARINIT 0x1
|
||||
#define DTF_1_CONFEXP 0x2
|
||||
|
||||
/*
|
||||
* DT_POSFLAG_1 values
|
||||
*/
|
||||
#define DF_P1_LAZYLOAD 0x1
|
||||
#define DF_P1_GROUPPERM 0x2
|
||||
|
||||
/*
|
||||
* DT_FLAGS_1 values
|
||||
*/
|
||||
#define DF_1_NOW 0x00000001
|
||||
#define DF_1_GLOBAL 0x00000002
|
||||
#define DF_1_GROUP 0x00000004
|
||||
#define DF_1_NODELETE 0x00000008
|
||||
#define DF_1_LOADFLTR 0x00000010
|
||||
#define DF_1_INITFIRST 0x00000020
|
||||
#define DF_1_NOOPEN 0x00000040
|
||||
#define DF_1_ORIGIN 0x00000080
|
||||
#define DF_1_DIRECT 0x00000100
|
||||
#define DF_1_TRANS 0x00000200
|
||||
#define DF_1_INTERPOSE 0x00000400
|
||||
#define DF_1_NODEFLIB 0x00000800
|
||||
#define DF_1_NODUMP 0x00001000
|
||||
#define DF_1_CONFALT 0x00002000
|
||||
#define DF_1_ENDFILTEE 0x00004000
|
||||
#define DF_1_DISPRELDNE 0x00008000
|
||||
#define DF_1_DISPRELPND 0x00010000
|
||||
|
||||
/*
|
||||
* Syminfo structure
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Half si_boundto;
|
||||
Elf32_Half si_flags;
|
||||
} Elf32_Syminfo;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
Elf64_Half si_boundto;
|
||||
Elf64_Half si_flags;
|
||||
} Elf64_Syminfo;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Syminfo version (stored in unused first entry)
|
||||
*/
|
||||
#define SYMINFO_NONE 0
|
||||
#define SYMINFO_CURRENT 1
|
||||
#define SYMINFO_NUM 2
|
||||
|
||||
/*
|
||||
* si_boundto special values
|
||||
*/
|
||||
#define SYMINFO_BT_LOWRESERVE 0xff00
|
||||
#define SYMINFO_BT_PARENT 0xfffe /* bound to parent */
|
||||
#define SYMINFO_BT_SELF 0xffff /* bound to self */
|
||||
|
||||
/*
|
||||
* si_flags
|
||||
*/
|
||||
#define SYMINFO_FLG_DIRECT 0x01 /* bound to an object */
|
||||
#define SYMINFO_FLG_PASSTHRU 0x02 /* pass-thru symbol */
|
||||
#define SYMINFO_FLG_COPY 0x04 /* result of a copy relocation */
|
||||
#define SYMINFO_FLG_LAZYLOAD 0x08 /* bound to lazy-loaded object */
|
||||
|
||||
/*
|
||||
* Version definitions
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Half vd_version;
|
||||
Elf32_Half vd_flags;
|
||||
Elf32_Half vd_ndx;
|
||||
Elf32_Half vd_cnt;
|
||||
Elf32_Word vd_hash;
|
||||
Elf32_Word vd_aux;
|
||||
Elf32_Word vd_next;
|
||||
} Elf32_Verdef;
|
||||
|
||||
typedef struct {
|
||||
Elf32_Word vda_name;
|
||||
Elf32_Word vda_next;
|
||||
} Elf32_Verdaux;
|
||||
|
||||
typedef struct {
|
||||
Elf32_Half vn_version;
|
||||
Elf32_Half vn_cnt;
|
||||
Elf32_Word vn_file;
|
||||
Elf32_Word vn_aux;
|
||||
Elf32_Word vn_next;
|
||||
} Elf32_Verneed;
|
||||
|
||||
typedef struct {
|
||||
Elf32_Word vna_hash;
|
||||
Elf32_Half vna_flags;
|
||||
Elf32_Half vna_other;
|
||||
Elf32_Word vna_name;
|
||||
Elf32_Word vna_next;
|
||||
} Elf32_Vernaux;
|
||||
|
||||
typedef Elf32_Half Elf32_Versym;
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
typedef struct {
|
||||
Elf64_Half vd_version;
|
||||
Elf64_Half vd_flags;
|
||||
Elf64_Half vd_ndx;
|
||||
Elf64_Half vd_cnt;
|
||||
Elf64_Word vd_hash;
|
||||
Elf64_Word vd_aux;
|
||||
Elf64_Word vd_next;
|
||||
} Elf64_Verdef;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Word vda_name;
|
||||
Elf64_Word vda_next;
|
||||
} Elf64_Verdaux;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Half vn_version;
|
||||
Elf64_Half vn_cnt;
|
||||
Elf64_Word vn_file;
|
||||
Elf64_Word vn_aux;
|
||||
Elf64_Word vn_next;
|
||||
} Elf64_Verneed;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Word vna_hash;
|
||||
Elf64_Half vna_flags;
|
||||
Elf64_Half vna_other;
|
||||
Elf64_Word vna_name;
|
||||
Elf64_Word vna_next;
|
||||
} Elf64_Vernaux;
|
||||
|
||||
typedef Elf64_Half Elf64_Versym;
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* vd_version
|
||||
*/
|
||||
#define VER_DEF_NONE 0
|
||||
#define VER_DEF_CURRENT 1
|
||||
#define VER_DEF_NUM 2
|
||||
|
||||
/*
|
||||
* vn_version
|
||||
*/
|
||||
#define VER_NEED_NONE 0
|
||||
#define VER_NEED_CURRENT 1
|
||||
#define VER_NEED_NUM 2
|
||||
|
||||
/*
|
||||
* vd_flags / vna_flags
|
||||
*/
|
||||
#define VER_FLG_BASE 0x1 /* vd_flags only */
|
||||
#define VER_FLG_WEAK 0x2
|
||||
|
||||
/*
|
||||
* Elf*_Versym special values
|
||||
*/
|
||||
#define VER_NDX_LOCAL 0
|
||||
#define VER_NDX_GLOBAL 1
|
||||
|
||||
/*
|
||||
* Solaris extensions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Move section
|
||||
*/
|
||||
#if __LIBELF64
|
||||
|
||||
typedef struct {
|
||||
Elf32_Lword m_value;
|
||||
Elf32_Word m_info;
|
||||
Elf32_Word m_poffset;
|
||||
Elf32_Half m_repeat;
|
||||
Elf32_Half m_stride;
|
||||
} Elf32_Move;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Lword m_value;
|
||||
Elf64_Xword m_info;
|
||||
Elf64_Xword m_poffset;
|
||||
Elf64_Half m_repeat;
|
||||
Elf64_Half m_stride;
|
||||
} Elf64_Move;
|
||||
|
||||
#define ELF32_M_SYM(info) ((info)>>8)
|
||||
#define ELF32_M_SIZE(info) ((unsigned char)(info))
|
||||
#define ELF32_M_INFO(sym, sz) (((sym)<<8)+(unsigned char)(sz))
|
||||
|
||||
#define ELF64_M_SYM(info) ((Elf64_Xword)(info)>>8)
|
||||
#define ELF64_M_SIZE(info) ((unsigned char)(info))
|
||||
#define ELF64_M_INFO(sym, sz) (((Elf64_Xword)(sym)<<8)+(unsigned char)(sz))
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Capabilities
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
Elf32_Word c_tag;
|
||||
union {
|
||||
Elf32_Word c_val;
|
||||
Elf32_Addr c_ptr;
|
||||
} c_un;
|
||||
} Elf32_Cap;
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
typedef struct {
|
||||
Elf64_Xword c_tag;
|
||||
union {
|
||||
Elf64_Xword c_val;
|
||||
Elf64_Addr c_ptr;
|
||||
} c_un;
|
||||
} Elf64_Cap;
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
#define CA_SUNW_NULL 0 /* c_un ignored */
|
||||
#define CA_SUNW_HW_1 1 /* c_un.c_val */
|
||||
#define CA_SUNW_SF_1 2 /* c_un.c_val */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _ELF_REPL_H */
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* lib/sys_elf.h.w32 - internal configuration file for W32 port
|
||||
* Copyright (C) 2004 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* @(#) $Id: sys_elf.h.w32,v 1.2 2006/09/07 15:55:42 michael Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* DO NOT USE THIS IN APPLICATIONS - #include <libelf.h> INSTEAD!
|
||||
*/
|
||||
|
||||
/* Define to `<elf.h>' or `<sys/elf.h>' if one of them is present */
|
||||
#undef __LIBELF_HEADER_ELF_H
|
||||
|
||||
/* Define if Elf32_Dyn is declared in <link.h> */
|
||||
#undef __LIBELF_NEED_LINK_H
|
||||
|
||||
/* Define if Elf32_Dyn is declared in <sys/link.h> */
|
||||
#undef __LIBELF_NEED_SYS_LINK_H
|
||||
|
||||
/* Define if you want 64-bit support (and your system supports it) */
|
||||
#define __LIBELF64 1
|
||||
|
||||
/* Define if you want 64-bit support, and are running IRIX */
|
||||
#undef __LIBELF64_IRIX
|
||||
|
||||
/* Define if you want 64-bit support, and are running Linux */
|
||||
#undef __LIBELF64_LINUX
|
||||
|
||||
/* Define if you want symbol versioning (and your system supports it) */
|
||||
#define __LIBELF_SYMBOL_VERSIONS 1
|
||||
|
||||
/* Define to a 64-bit signed integer type if one exists */
|
||||
#define __libelf_i64_t __int64
|
||||
|
||||
/* Define to a 64-bit unsigned integer type if one exists */
|
||||
#define __libelf_u64_t unsigned __int64
|
||||
|
||||
/* Define to a 32-bit signed integer type if one exists */
|
||||
#define __libelf_i32_t int
|
||||
|
||||
/* Define to a 32-bit unsigned integer type if one exists */
|
||||
#define __libelf_u32_t unsigned int
|
||||
|
||||
/* Define to a 16-bit signed integer type if one exists */
|
||||
#define __libelf_i16_t short int
|
||||
|
||||
/* Define to a 16-bit unsigned integer type if one exists */
|
||||
#define __libelf_u16_t unsigned short int
|
||||
|
||||
/*
|
||||
* Ok, now get the correct instance of elf.h...
|
||||
*/
|
||||
#ifdef __LIBELF_HEADER_ELF_H
|
||||
# include __LIBELF_HEADER_ELF_H
|
||||
#else /* __LIBELF_HEADER_ELF_H */
|
||||
# if __LIBELF_INTERNAL__
|
||||
# include <elf_repl.h>
|
||||
# else /* __LIBELF_INTERNAL__ */
|
||||
# include <libelf/elf_repl.h>
|
||||
# endif /* __LIBELF_INTERNAL__ */
|
||||
#endif /* __LIBELF_HEADER_ELF_H */
|
||||
|
||||
/*
|
||||
* On some systems, <elf.h> is severely broken. Try to fix it.
|
||||
*/
|
||||
#ifdef __LIBELF_HEADER_ELF_H
|
||||
|
||||
# ifndef ELF32_FSZ_ADDR
|
||||
# define ELF32_FSZ_ADDR 4
|
||||
# define ELF32_FSZ_HALF 2
|
||||
# define ELF32_FSZ_OFF 4
|
||||
# define ELF32_FSZ_SWORD 4
|
||||
# define ELF32_FSZ_WORD 4
|
||||
# endif /* ELF32_FSZ_ADDR */
|
||||
|
||||
# ifndef STN_UNDEF
|
||||
# define STN_UNDEF 0
|
||||
# endif /* STN_UNDEF */
|
||||
|
||||
# if __LIBELF64
|
||||
|
||||
# ifndef ELF64_FSZ_ADDR
|
||||
# define ELF64_FSZ_ADDR 8
|
||||
# define ELF64_FSZ_HALF 2
|
||||
# define ELF64_FSZ_OFF 8
|
||||
# define ELF64_FSZ_SWORD 4
|
||||
# define ELF64_FSZ_WORD 4
|
||||
# define ELF64_FSZ_SXWORD 8
|
||||
# define ELF64_FSZ_XWORD 8
|
||||
# endif /* ELF64_FSZ_ADDR */
|
||||
|
||||
# ifndef ELF64_ST_BIND
|
||||
# define ELF64_ST_BIND(i) ((i)>>4)
|
||||
# define ELF64_ST_TYPE(i) ((i)&0xf)
|
||||
# define ELF64_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
|
||||
# endif /* ELF64_ST_BIND */
|
||||
|
||||
# ifndef ELF64_R_SYM
|
||||
# define ELF64_R_SYM(i) ((Elf64_Xword)(i)>>32)
|
||||
# define ELF64_R_TYPE(i) ((i)&0xffffffffL)
|
||||
# define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
|
||||
# endif /* ELF64_R_SYM */
|
||||
|
||||
# if __LIBELF64_LINUX
|
||||
typedef __libelf_u64_t Elf64_Addr;
|
||||
typedef __libelf_u16_t Elf64_Half;
|
||||
typedef __libelf_u64_t Elf64_Off;
|
||||
typedef __libelf_i32_t Elf64_Sword;
|
||||
typedef __libelf_u32_t Elf64_Word;
|
||||
typedef __libelf_i64_t Elf64_Sxword;
|
||||
typedef __libelf_u64_t Elf64_Xword;
|
||||
# endif /* __LIBELF64_LINUX */
|
||||
|
||||
# endif /* __LIBELF64 */
|
||||
#endif /* __LIBELF_HEADER_ELF_H */
|
||||
Vendored
+222
@@ -0,0 +1,222 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\32.fsize.c" />
|
||||
<ClCompile Include="src\32.getehdr.c" />
|
||||
<ClCompile Include="src\32.getphdr.c" />
|
||||
<ClCompile Include="src\32.getshdr.c" />
|
||||
<ClCompile Include="src\32.newehdr.c" />
|
||||
<ClCompile Include="src\32.newphdr.c" />
|
||||
<ClCompile Include="src\32.xlatetof.c" />
|
||||
<ClCompile Include="src\64.xlatetof.c" />
|
||||
<ClCompile Include="src\assert.c" />
|
||||
<ClCompile Include="src\begin.c" />
|
||||
<ClCompile Include="src\checksum.c" />
|
||||
<ClCompile Include="src\cntl.c" />
|
||||
<ClCompile Include="src\cook.c" />
|
||||
<ClCompile Include="src\data.c" />
|
||||
<ClCompile Include="src\end.c" />
|
||||
<ClCompile Include="src\errmsg.c" />
|
||||
<ClCompile Include="src\errno.c" />
|
||||
<ClCompile Include="src\fill.c" />
|
||||
<ClCompile Include="src\flag.c" />
|
||||
<ClCompile Include="src\gelfehdr.c" />
|
||||
<ClCompile Include="src\gelfphdr.c" />
|
||||
<ClCompile Include="src\gelfshdr.c" />
|
||||
<ClCompile Include="src\gelftrans.c" />
|
||||
<ClCompile Include="src\getarhdr.c" />
|
||||
<ClCompile Include="src\getaroff.c" />
|
||||
<ClCompile Include="src\getarsym.c" />
|
||||
<ClCompile Include="src\getbase.c" />
|
||||
<ClCompile Include="src\getdata.c" />
|
||||
<ClCompile Include="src\getident.c" />
|
||||
<ClCompile Include="src\getscn.c" />
|
||||
<ClCompile Include="src\hash.c" />
|
||||
<ClCompile Include="src\input.c" />
|
||||
<ClCompile Include="src\kind.c" />
|
||||
<ClCompile Include="src\memset.c" />
|
||||
<ClCompile Include="src\ndxscn.c" />
|
||||
<ClCompile Include="src\newdata.c" />
|
||||
<ClCompile Include="src\newscn.c" />
|
||||
<ClCompile Include="src\next.c" />
|
||||
<ClCompile Include="src\nextscn.c" />
|
||||
<ClCompile Include="src\nlist.c" />
|
||||
<ClCompile Include="src\opt.delscn.c" />
|
||||
<ClCompile Include="src\rand.c" />
|
||||
<ClCompile Include="src\rawdata.c" />
|
||||
<ClCompile Include="src\rawfile.c" />
|
||||
<ClCompile Include="src\strptr.c" />
|
||||
<ClCompile Include="src\swap64.c" />
|
||||
<ClCompile Include="src\update.c" />
|
||||
<ClCompile Include="src\verdef_32_tof.c" />
|
||||
<ClCompile Include="src\verdef_32_tom.c" />
|
||||
<ClCompile Include="src\verdef_64_tof.c" />
|
||||
<ClCompile Include="src\verdef_64_tom.c" />
|
||||
<ClCompile Include="src\version.c" />
|
||||
<ClCompile Include="src\x.elfext.c" />
|
||||
<ClCompile Include="src\x.movscn.c" />
|
||||
<ClCompile Include="src\x.remscn.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\libelf.h" />
|
||||
<ClInclude Include="include\libelf\elf_repl.h" />
|
||||
<ClInclude Include="include\libelf\sys_elf.h" />
|
||||
<ClInclude Include="src\byteswap.h" />
|
||||
<ClInclude Include="src\config.h" />
|
||||
<ClInclude Include="src\errors.h" />
|
||||
<ClInclude Include="src\ext_types.h" />
|
||||
<ClInclude Include="src\gelf.h" />
|
||||
<ClInclude Include="src\nlist.h" />
|
||||
<ClInclude Include="src\private.h" />
|
||||
<ClInclude Include="src\verdef.h" />
|
||||
<ClInclude Include="src\verneed.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{a2d07885-a0d1-473b-83b2-209cd008ee8f}</ProjectGuid>
|
||||
<RootNamespace>libelf</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>libelf</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;HAVE_CONFIG_H=1;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>include;include\libelf;src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4244;4267;4311</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;HAVE_CONFIG_H=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>include;include\libelf;src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4244;4267;4311</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;HAVE_CONFIG_H=1;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>include;include\libelf;src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4244;4267;4311</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;HAVE_CONFIG_H=1;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>include;include\libelf;src</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4244;4267;4311</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\32.fsize.c" />
|
||||
<ClCompile Include="src\32.getehdr.c" />
|
||||
<ClCompile Include="src\32.getphdr.c" />
|
||||
<ClCompile Include="src\32.getshdr.c" />
|
||||
<ClCompile Include="src\32.newehdr.c" />
|
||||
<ClCompile Include="src\32.newphdr.c" />
|
||||
<ClCompile Include="src\32.xlatetof.c" />
|
||||
<ClCompile Include="src\64.xlatetof.c" />
|
||||
<ClCompile Include="src\assert.c" />
|
||||
<ClCompile Include="src\begin.c" />
|
||||
<ClCompile Include="src\checksum.c" />
|
||||
<ClCompile Include="src\cntl.c" />
|
||||
<ClCompile Include="src\cook.c" />
|
||||
<ClCompile Include="src\data.c" />
|
||||
<ClCompile Include="src\end.c" />
|
||||
<ClCompile Include="src\errmsg.c" />
|
||||
<ClCompile Include="src\errno.c" />
|
||||
<ClCompile Include="src\fill.c" />
|
||||
<ClCompile Include="src\flag.c" />
|
||||
<ClCompile Include="src\gelfehdr.c" />
|
||||
<ClCompile Include="src\gelfphdr.c" />
|
||||
<ClCompile Include="src\gelfshdr.c" />
|
||||
<ClCompile Include="src\gelftrans.c" />
|
||||
<ClCompile Include="src\getarhdr.c" />
|
||||
<ClCompile Include="src\getaroff.c" />
|
||||
<ClCompile Include="src\getarsym.c" />
|
||||
<ClCompile Include="src\getbase.c" />
|
||||
<ClCompile Include="src\getdata.c" />
|
||||
<ClCompile Include="src\getident.c" />
|
||||
<ClCompile Include="src\getscn.c" />
|
||||
<ClCompile Include="src\hash.c" />
|
||||
<ClCompile Include="src\input.c" />
|
||||
<ClCompile Include="src\kind.c" />
|
||||
<ClCompile Include="src\memset.c" />
|
||||
<ClCompile Include="src\ndxscn.c" />
|
||||
<ClCompile Include="src\newdata.c" />
|
||||
<ClCompile Include="src\newscn.c" />
|
||||
<ClCompile Include="src\next.c" />
|
||||
<ClCompile Include="src\nextscn.c" />
|
||||
<ClCompile Include="src\nlist.c" />
|
||||
<ClCompile Include="src\opt.delscn.c" />
|
||||
<ClCompile Include="src\rand.c" />
|
||||
<ClCompile Include="src\rawdata.c" />
|
||||
<ClCompile Include="src\rawfile.c" />
|
||||
<ClCompile Include="src\strptr.c" />
|
||||
<ClCompile Include="src\swap64.c" />
|
||||
<ClCompile Include="src\update.c" />
|
||||
<ClCompile Include="src\verdef_32_tof.c" />
|
||||
<ClCompile Include="src\verdef_32_tom.c" />
|
||||
<ClCompile Include="src\verdef_64_tof.c" />
|
||||
<ClCompile Include="src\verdef_64_tom.c" />
|
||||
<ClCompile Include="src\version.c" />
|
||||
<ClCompile Include="src\x.elfext.c" />
|
||||
<ClCompile Include="src\x.movscn.c" />
|
||||
<ClCompile Include="src\x.remscn.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\byteswap.h" />
|
||||
<ClInclude Include="src\config.h" />
|
||||
<ClInclude Include="src\errors.h" />
|
||||
<ClInclude Include="src\ext_types.h" />
|
||||
<ClInclude Include="src\gelf.h" />
|
||||
<ClInclude Include="src\nlist.h" />
|
||||
<ClInclude Include="src\private.h" />
|
||||
<ClInclude Include="src\verdef.h" />
|
||||
<ClInclude Include="src\verneed.h" />
|
||||
<ClInclude Include="include\libelf\elf_repl.h" />
|
||||
<ClInclude Include="include\libelf\sys_elf.h" />
|
||||
<ClInclude Include="include\libelf.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Vendored
+155
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
32.fsize.c - implementation of the elf{32,64}_fsize(3) functions.
|
||||
Copyright (C) 1995 - 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
#include <ext_types.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: 32.fsize.c,v 1.13 2008/05/23 08:15:33 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
const size_t
|
||||
_elf_fmsize[2][EV_CURRENT - EV_NONE][ELF_T_NUM][2] = {
|
||||
/* ELFCLASS32 */
|
||||
{
|
||||
/* version 1 */
|
||||
{
|
||||
{ sizeof(unsigned char), sizeof(unsigned char) },
|
||||
{ sizeof(Elf32_Addr), sizeof(__ext_Elf32_Addr) },
|
||||
{ sizeof(Elf32_Dyn), sizeof(__ext_Elf32_Dyn) },
|
||||
{ sizeof(Elf32_Ehdr), sizeof(__ext_Elf32_Ehdr) },
|
||||
{ sizeof(Elf32_Half), sizeof(__ext_Elf32_Half) },
|
||||
{ sizeof(Elf32_Off), sizeof(__ext_Elf32_Off) },
|
||||
{ sizeof(Elf32_Phdr), sizeof(__ext_Elf32_Phdr) },
|
||||
{ sizeof(Elf32_Rela), sizeof(__ext_Elf32_Rela) },
|
||||
{ sizeof(Elf32_Rel), sizeof(__ext_Elf32_Rel) },
|
||||
{ sizeof(Elf32_Shdr), sizeof(__ext_Elf32_Shdr) },
|
||||
{ sizeof(Elf32_Sword), sizeof(__ext_Elf32_Sword) },
|
||||
{ sizeof(Elf32_Sym), sizeof(__ext_Elf32_Sym) },
|
||||
{ sizeof(Elf32_Word), sizeof(__ext_Elf32_Word) },
|
||||
{ 0, 0 }, /* there is no Elf32_Sxword */
|
||||
{ 0, 0 }, /* there is no Elf32_Xword */
|
||||
/* XXX: check Solaris values */
|
||||
{ 0, 0 }, /* Elf32_Verdef/Verdaux size varies */
|
||||
{ 0, 0 }, /* Elf32_Verneed/Vernaux size varies */
|
||||
},
|
||||
},
|
||||
#if __LIBELF64
|
||||
/* ELFCLASS64 */
|
||||
{
|
||||
/* version 1 */
|
||||
{
|
||||
{ sizeof(unsigned char), sizeof(unsigned char) },
|
||||
{ sizeof(Elf64_Addr), sizeof(__ext_Elf64_Addr) },
|
||||
{ sizeof(Elf64_Dyn), sizeof(__ext_Elf64_Dyn) },
|
||||
{ sizeof(Elf64_Ehdr), sizeof(__ext_Elf64_Ehdr) },
|
||||
{ sizeof(Elf64_Half), sizeof(__ext_Elf64_Half) },
|
||||
{ sizeof(Elf64_Off), sizeof(__ext_Elf64_Off) },
|
||||
{ sizeof(Elf64_Phdr), sizeof(__ext_Elf64_Phdr) },
|
||||
{ sizeof(Elf64_Rela), sizeof(__ext_Elf64_Rela) },
|
||||
{ sizeof(Elf64_Rel), sizeof(__ext_Elf64_Rel) },
|
||||
{ sizeof(Elf64_Shdr), sizeof(__ext_Elf64_Shdr) },
|
||||
{ sizeof(Elf64_Sword), sizeof(__ext_Elf64_Sword) },
|
||||
{ sizeof(Elf64_Sym), sizeof(__ext_Elf64_Sym) },
|
||||
{ sizeof(Elf64_Word), sizeof(__ext_Elf64_Word) },
|
||||
{ sizeof(Elf64_Sxword), sizeof(__ext_Elf64_Sxword) },
|
||||
{ sizeof(Elf64_Xword), sizeof(__ext_Elf64_Xword) },
|
||||
/* XXX: check Solaris values */
|
||||
{ 0, 0 }, /* Elf64_Verdef/Verdaux size varies */
|
||||
{ 0, 0 }, /* Elf64_Verneed/Vernaux size varies */
|
||||
},
|
||||
},
|
||||
#endif /* __LIBELF64 */
|
||||
};
|
||||
|
||||
static size_t
|
||||
_elf_fsize(unsigned cls, Elf_Type type, unsigned ver) {
|
||||
size_t n = 0;
|
||||
|
||||
if (!valid_version(ver)) {
|
||||
seterr(ERROR_UNKNOWN_VERSION);
|
||||
}
|
||||
else if (!valid_type(type)) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
}
|
||||
else if (!(n = _fsize(cls, ver, type))) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t
|
||||
elf32_fsize(Elf_Type type, size_t count, unsigned ver) {
|
||||
return count * _elf_fsize(ELFCLASS32, type, ver);
|
||||
}
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
size_t
|
||||
elf64_fsize(Elf_Type type, size_t count, unsigned ver) {
|
||||
return count * _elf_fsize(ELFCLASS64, type, ver);
|
||||
}
|
||||
|
||||
size_t
|
||||
gelf_fsize(Elf *elf, Elf_Type type, size_t count, unsigned ver) {
|
||||
if (elf) {
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (valid_class(elf->e_class)) {
|
||||
return count * _elf_fsize(elf->e_class, type, ver);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extension: report memory size
|
||||
*/
|
||||
size_t
|
||||
gelf_msize(Elf *elf, Elf_Type type, size_t count, unsigned ver) {
|
||||
size_t n;
|
||||
|
||||
if (elf) {
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (!valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
else if (!valid_version(ver)) {
|
||||
seterr(ERROR_UNKNOWN_VERSION);
|
||||
}
|
||||
else if (!valid_type(type)) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
}
|
||||
else if (!(n = _msize(elf->e_class, ver, type))) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
}
|
||||
else {
|
||||
return count * n;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
32.getehdr.c - implementation of the elf{32,64}_getehdr(3) functions.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: 32.getehdr.c,v 1.9 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
char*
|
||||
_elf_getehdr(Elf *elf, unsigned cls) {
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (elf->e_class != cls) {
|
||||
seterr(ERROR_CLASSMISMATCH);
|
||||
}
|
||||
else if (elf->e_ehdr || _elf_cook(elf)) {
|
||||
return elf->e_ehdr;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Elf32_Ehdr*
|
||||
elf32_getehdr(Elf *elf) {
|
||||
return (Elf32_Ehdr*)_elf_getehdr(elf, ELFCLASS32);
|
||||
}
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
Elf64_Ehdr*
|
||||
elf64_getehdr(Elf *elf) {
|
||||
return (Elf64_Ehdr*)_elf_getehdr(elf, ELFCLASS64);
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
32.getphdr.c - implementation of the elf{32,64}_getphdr(3) functions.
|
||||
Copyright (C) 1995 - 2000 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: 32.getphdr.c,v 1.11 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
char*
|
||||
_elf_getphdr(Elf *elf, unsigned cls) {
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (elf->e_class != cls) {
|
||||
seterr(ERROR_CLASSMISMATCH);
|
||||
}
|
||||
else if (elf->e_ehdr || _elf_cook(elf)) {
|
||||
return elf->e_phdr;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Elf32_Phdr*
|
||||
elf32_getphdr(Elf *elf) {
|
||||
return (Elf32_Phdr*)_elf_getphdr(elf, ELFCLASS32);
|
||||
}
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
Elf64_Phdr*
|
||||
elf64_getphdr(Elf *elf) {
|
||||
return (Elf64_Phdr*)_elf_getphdr(elf, ELFCLASS64);
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
32.getshdr.c - implementation of the elf{32,64}_getshdr(3) functions.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: 32.getshdr.c,v 1.10 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
Elf32_Shdr*
|
||||
elf32_getshdr(Elf_Scn *scn) {
|
||||
if (!scn) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
elf_assert(scn->s_elf);
|
||||
elf_assert(scn->s_elf->e_magic == ELF_MAGIC);
|
||||
if (scn->s_elf->e_class == ELFCLASS32) {
|
||||
return &scn->s_shdr32;
|
||||
}
|
||||
seterr(ERROR_CLASSMISMATCH);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
Elf64_Shdr*
|
||||
elf64_getshdr(Elf_Scn *scn) {
|
||||
if (!scn) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
elf_assert(scn->s_elf);
|
||||
elf_assert(scn->s_elf->e_magic == ELF_MAGIC);
|
||||
if (scn->s_elf->e_class == ELFCLASS64) {
|
||||
return &scn->s_shdr64;
|
||||
}
|
||||
seterr(ERROR_CLASSMISMATCH);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 32.newehdr.c - implementation of the elf{32,64}_newehdr(3) functions.
|
||||
* Copyright (C) 1995 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: 32.newehdr.c,v 1.16 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
static char*
|
||||
_elf_newehdr(Elf *elf, unsigned cls) {
|
||||
size_t size;
|
||||
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (elf->e_readable) {
|
||||
return _elf_getehdr(elf, cls);
|
||||
}
|
||||
else if (!elf->e_ehdr) {
|
||||
size = _msize(cls, _elf_version, ELF_T_EHDR);
|
||||
elf_assert(size);
|
||||
if ((elf->e_ehdr = (char*)malloc(size))) {
|
||||
memset(elf->e_ehdr, 0, size);
|
||||
elf->e_ehdr_flags |= ELF_F_DIRTY;
|
||||
elf->e_kind = ELF_K_ELF;
|
||||
elf->e_class = cls;
|
||||
return elf->e_ehdr;
|
||||
}
|
||||
seterr(ERROR_MEM_EHDR);
|
||||
}
|
||||
else if (elf->e_class != cls) {
|
||||
seterr(ERROR_CLASSMISMATCH);
|
||||
}
|
||||
else {
|
||||
elf_assert(elf->e_kind == ELF_K_ELF);
|
||||
return elf->e_ehdr;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Elf32_Ehdr*
|
||||
elf32_newehdr(Elf *elf) {
|
||||
return (Elf32_Ehdr*)_elf_newehdr(elf, ELFCLASS32);
|
||||
}
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
Elf64_Ehdr*
|
||||
elf64_newehdr(Elf *elf) {
|
||||
return (Elf64_Ehdr*)_elf_newehdr(elf, ELFCLASS64);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
gelf_newehdr(Elf *elf, int cls) {
|
||||
if (!valid_class(cls) || !_msize(cls, _elf_version, ELF_T_EHDR)) {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
return 0;
|
||||
}
|
||||
return (unsigned long)_elf_newehdr(elf, cls);
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+118
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 32.newphdr.c - implementation of the elf{32,64}_newphdr(3) functions.
|
||||
* Copyright (C) 1995 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: 32.newphdr.c,v 1.16 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
static char*
|
||||
_elf_newphdr(Elf *elf, size_t count, unsigned cls) {
|
||||
size_t extcount = 0;
|
||||
Elf_Scn *scn = NULL;
|
||||
char *phdr = NULL;
|
||||
size_t size;
|
||||
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (!elf->e_ehdr && !elf->e_readable) {
|
||||
seterr(ERROR_NOEHDR);
|
||||
}
|
||||
else if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (elf->e_class != cls) {
|
||||
seterr(ERROR_CLASSMISMATCH);
|
||||
}
|
||||
else if (elf->e_ehdr || _elf_cook(elf)) {
|
||||
size = _msize(cls, _elf_version, ELF_T_PHDR);
|
||||
elf_assert(size);
|
||||
if (!(scn = _elf_first_scn(elf))) {
|
||||
return NULL;
|
||||
}
|
||||
if (count) {
|
||||
if (!(phdr = (char*)malloc(count * size))) {
|
||||
seterr(ERROR_MEM_PHDR);
|
||||
return NULL;
|
||||
}
|
||||
memset(phdr, 0, count * size);
|
||||
}
|
||||
elf_assert(elf->e_ehdr);
|
||||
elf->e_phnum = count;
|
||||
if (count >= PN_XNUM) {
|
||||
/*
|
||||
* get NULL section (create it if necessary)
|
||||
*/
|
||||
extcount = count;
|
||||
count = PN_XNUM;
|
||||
}
|
||||
if (cls == ELFCLASS32) {
|
||||
((Elf32_Ehdr*)elf->e_ehdr)->e_phnum = count;
|
||||
scn->s_shdr32.sh_info = extcount;
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (cls == ELFCLASS64) {
|
||||
((Elf64_Ehdr*)elf->e_ehdr)->e_phnum = count;
|
||||
scn->s_shdr64.sh_info = extcount;
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
if (phdr) {
|
||||
free(phdr);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (elf->e_phdr) {
|
||||
free(elf->e_phdr);
|
||||
}
|
||||
elf->e_phdr = phdr;
|
||||
elf->e_phdr_flags |= ELF_F_DIRTY;
|
||||
elf->e_ehdr_flags |= ELF_F_DIRTY;
|
||||
scn->s_scn_flags |= ELF_F_DIRTY;
|
||||
return phdr;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Elf32_Phdr*
|
||||
elf32_newphdr(Elf *elf, size_t count) {
|
||||
return (Elf32_Phdr*)_elf_newphdr(elf, count, ELFCLASS32);
|
||||
}
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
Elf64_Phdr*
|
||||
elf64_newphdr(Elf *elf, size_t count) {
|
||||
return (Elf64_Phdr*)_elf_newphdr(elf, count, ELFCLASS64);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
gelf_newphdr(Elf *elf, size_t phnum) {
|
||||
if (!valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
return 0;
|
||||
}
|
||||
return (unsigned long)_elf_newphdr(elf, phnum, elf->e_class);
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+438
@@ -0,0 +1,438 @@
|
||||
/*
|
||||
* 32.xlatetof.c - implementation of the elf32_xlateto[fm](3) functions.
|
||||
* Copyright (C) 1995 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
#include <ext_types.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: 32.xlatetof.c,v 1.27 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
/*
|
||||
* Ugly, ugly
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
# define Cat2(a,b)a##b
|
||||
# define Cat3(a,b,c)a##b##c
|
||||
# define Ex1(m1,m2,a,b)m1##m2(a##b)
|
||||
# define Ex2(m1,m2,a,b,c)m1##m2(a,b##c)
|
||||
#else /* _WIN32 */
|
||||
# define x
|
||||
# if defined/**/x
|
||||
# define Cat2(a,b)a##b
|
||||
# define Cat3(a,b,c)a##b##c
|
||||
# define Ex1(m1,m2,a,b)m1##m2(a##b)
|
||||
# define Ex2(m1,m2,a,b,c)m1##m2(a,b##c)
|
||||
# else
|
||||
# define Cat2(a,b)a/**/b
|
||||
# define Cat3(a,b,c)a/**/b/**/c
|
||||
# define Ex1(m1,m2,a,b)m1/**/m2(a/**/b)
|
||||
# define Ex2(m1,m2,a,b,c)m1/**/m2(a,b/**/c)
|
||||
# endif
|
||||
# undef x
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/*
|
||||
* auxiliary macros for execution order reversal
|
||||
*/
|
||||
#define seq_forw(a,b) a b
|
||||
#define seq_back(a,b) b a
|
||||
|
||||
/*
|
||||
* function instantiator
|
||||
*/
|
||||
#define copy_type_e_io(name,e,io,tfrom,tto,copy) \
|
||||
static size_t \
|
||||
Cat3(name,_,io)(unsigned char *dst, const unsigned char *src, size_t n) { \
|
||||
n /= sizeof(tfrom); \
|
||||
if (n && dst) { \
|
||||
const tfrom *from = (const tfrom*)src; \
|
||||
tto *to = (tto*)dst; \
|
||||
size_t i; \
|
||||
\
|
||||
if (sizeof(tfrom) < sizeof(tto)) { \
|
||||
from += n; \
|
||||
to += n; \
|
||||
for (i = 0; i < n; i++) { \
|
||||
--from; \
|
||||
--to; \
|
||||
copy(e,io,seq_back) \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
for (i = 0; i < n; i++) { \
|
||||
copy(e,io,seq_forw) \
|
||||
from++; \
|
||||
to++; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
return n * sizeof(tto); \
|
||||
}
|
||||
|
||||
#define copy_type_e(name,e,type,copy) \
|
||||
copy_type_e_io(name,e,tom,Cat2(__ext_,type),type,copy) \
|
||||
copy_type_e_io(name,e,tof,type,Cat2(__ext_,type),copy)
|
||||
|
||||
/*
|
||||
* master function instantiator
|
||||
*/
|
||||
#define copy_type(name,version,type,copy) \
|
||||
copy_type_e(Cat3(name,L,version),L,type,copy) \
|
||||
copy_type_e(Cat3(name,M,version),M,type,copy)
|
||||
|
||||
/*
|
||||
* scalar copying
|
||||
*/
|
||||
#define copy_scalar_tom(type) *to = Cat2(__load_,type)(*from);
|
||||
#define copy_scalar_tof(type) Cat2(__store_,type)(*to, *from);
|
||||
|
||||
/*
|
||||
* structure member copying
|
||||
*/
|
||||
#define copy_tom(mb,type) to->mb = Cat2(__load_,type)(from->mb);
|
||||
#define copy_tof(mb,type) Cat2(__store_,type)(to->mb, from->mb);
|
||||
|
||||
/*
|
||||
* structure member copying (direction independent)
|
||||
*/
|
||||
#define copy_byte(e,io,mb) to->mb = from->mb;
|
||||
#define copy_addr(e,io,mb) Ex2(copy_,io,mb,u32,e)
|
||||
#define copy_half(e,io,mb) Ex2(copy_,io,mb,u16,e)
|
||||
#define copy_off(e,io,mb) Ex2(copy_,io,mb,u32,e)
|
||||
#define copy_sword(e,io,mb) Ex2(copy_,io,mb,i32,e)
|
||||
#define copy_word(e,io,mb) Ex2(copy_,io,mb,u32,e)
|
||||
#define copy_arr(e,io,mb) \
|
||||
array_copy(to->mb, sizeof(to->mb), from->mb, sizeof(from->mb));
|
||||
|
||||
/*
|
||||
* scalar copying (direction independent)
|
||||
* these macros are used as `copy' arguments to copy_type()
|
||||
*/
|
||||
#define copy_addr_11(e,io,seq) Ex1(copy_scalar_,io,u32,e)
|
||||
#define copy_half_11(e,io,seq) Ex1(copy_scalar_,io,u16,e)
|
||||
#define copy_off_11(e,io,seq) Ex1(copy_scalar_,io,u32,e)
|
||||
#define copy_sword_11(e,io,seq) Ex1(copy_scalar_,io,i32,e)
|
||||
#define copy_word_11(e,io,seq) Ex1(copy_scalar_,io,u32,e)
|
||||
|
||||
/*
|
||||
* structure copying (direction independent)
|
||||
* these macros are used as `copy' arguments to copy_type()
|
||||
*/
|
||||
#define copy_dyn_11(e,io,seq) \
|
||||
seq(copy_sword(e,io,d_tag), \
|
||||
seq(copy_addr(e,io,d_un.d_ptr), \
|
||||
nullcopy))
|
||||
#define copy_ehdr_11(e,io,seq) \
|
||||
seq(copy_arr(e,io,e_ident), \
|
||||
seq(copy_half(e,io,e_type), \
|
||||
seq(copy_half(e,io,e_machine), \
|
||||
seq(copy_word(e,io,e_version), \
|
||||
seq(copy_addr(e,io,e_entry), \
|
||||
seq(copy_off(e,io,e_phoff), \
|
||||
seq(copy_off(e,io,e_shoff), \
|
||||
seq(copy_word(e,io,e_flags), \
|
||||
seq(copy_half(e,io,e_ehsize), \
|
||||
seq(copy_half(e,io,e_phentsize), \
|
||||
seq(copy_half(e,io,e_phnum), \
|
||||
seq(copy_half(e,io,e_shentsize), \
|
||||
seq(copy_half(e,io,e_shnum), \
|
||||
seq(copy_half(e,io,e_shstrndx), \
|
||||
nullcopy))))))))))))))
|
||||
#define copy_phdr_11(e,io,seq) \
|
||||
seq(copy_word(e,io,p_type), \
|
||||
seq(copy_off(e,io,p_offset), \
|
||||
seq(copy_addr(e,io,p_vaddr), \
|
||||
seq(copy_addr(e,io,p_paddr), \
|
||||
seq(copy_word(e,io,p_filesz), \
|
||||
seq(copy_word(e,io,p_memsz), \
|
||||
seq(copy_word(e,io,p_flags), \
|
||||
seq(copy_word(e,io,p_align), \
|
||||
nullcopy))))))))
|
||||
#define copy_rela_11(e,io,seq) \
|
||||
seq(copy_addr(e,io,r_offset), \
|
||||
seq(copy_word(e,io,r_info), \
|
||||
seq(copy_sword(e,io,r_addend), \
|
||||
nullcopy)))
|
||||
#define copy_rel_11(e,io,seq) \
|
||||
seq(copy_addr(e,io,r_offset), \
|
||||
seq(copy_word(e,io,r_info), \
|
||||
nullcopy))
|
||||
#define copy_shdr_11(e,io,seq) \
|
||||
seq(copy_word(e,io,sh_name), \
|
||||
seq(copy_word(e,io,sh_type), \
|
||||
seq(copy_word(e,io,sh_flags), \
|
||||
seq(copy_addr(e,io,sh_addr), \
|
||||
seq(copy_off(e,io,sh_offset), \
|
||||
seq(copy_word(e,io,sh_size), \
|
||||
seq(copy_word(e,io,sh_link), \
|
||||
seq(copy_word(e,io,sh_info), \
|
||||
seq(copy_word(e,io,sh_addralign), \
|
||||
seq(copy_word(e,io,sh_entsize), \
|
||||
nullcopy))))))))))
|
||||
#define copy_sym_11(e,io,seq) \
|
||||
seq(copy_word(e,io,st_name), \
|
||||
seq(copy_addr(e,io,st_value), \
|
||||
seq(copy_word(e,io,st_size), \
|
||||
seq(copy_byte(e,io,st_info), \
|
||||
seq(copy_byte(e,io,st_other), \
|
||||
seq(copy_half(e,io,st_shndx), \
|
||||
nullcopy))))))
|
||||
|
||||
#define nullcopy /**/
|
||||
|
||||
static size_t
|
||||
byte_copy(unsigned char *dst, const unsigned char *src, size_t n) {
|
||||
if (n && dst && dst != src) {
|
||||
#if HAVE_BROKEN_MEMMOVE
|
||||
size_t i;
|
||||
|
||||
if (dst >= src + n || dst + n <= src) {
|
||||
memcpy(dst, src, n);
|
||||
}
|
||||
else if (dst < src) {
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = n; --i; ) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
#else /* HAVE_BROKEN_MEMMOVE */
|
||||
memmove(dst, src, n);
|
||||
#endif /* HAVE_BROKEN_MEMMOVE */
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
array_copy(unsigned char *dst, size_t dlen, const unsigned char *src, size_t slen) {
|
||||
byte_copy(dst, src, dlen < slen ? dlen : slen);
|
||||
if (dlen > slen) {
|
||||
memset(dst + slen, 0, dlen - slen);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* instantiate copy functions
|
||||
*/
|
||||
copy_type(addr_32,_,Elf32_Addr,copy_addr_11)
|
||||
copy_type(half_32,_,Elf32_Half,copy_half_11)
|
||||
copy_type(off_32,_,Elf32_Off,copy_off_11)
|
||||
copy_type(sword_32,_,Elf32_Sword,copy_sword_11)
|
||||
copy_type(word_32,_,Elf32_Word,copy_word_11)
|
||||
copy_type(dyn_32,11,Elf32_Dyn,copy_dyn_11)
|
||||
copy_type(ehdr_32,11,Elf32_Ehdr,copy_ehdr_11)
|
||||
copy_type(phdr_32,11,Elf32_Phdr,copy_phdr_11)
|
||||
copy_type(rela_32,11,Elf32_Rela,copy_rela_11)
|
||||
copy_type(rel_32,11,Elf32_Rel,copy_rel_11)
|
||||
copy_type(shdr_32,11,Elf32_Shdr,copy_shdr_11)
|
||||
copy_type(sym_32,11,Elf32_Sym,copy_sym_11)
|
||||
|
||||
typedef size_t (*xlator)(unsigned char*, const unsigned char*, size_t);
|
||||
typedef xlator xltab[ELF_T_NUM][2];
|
||||
|
||||
/*
|
||||
* translation table (32-bit, version 1 -> version 1)
|
||||
*/
|
||||
#if PIC
|
||||
static xltab
|
||||
#else /* PIC */
|
||||
static const xltab
|
||||
#endif /* PIC */
|
||||
xlate32_11[/*encoding*/] = {
|
||||
{
|
||||
{ byte_copy, byte_copy },
|
||||
{ addr_32L__tom, addr_32L__tof },
|
||||
{ dyn_32L11_tom, dyn_32L11_tof },
|
||||
{ ehdr_32L11_tom, ehdr_32L11_tof },
|
||||
{ half_32L__tom, half_32L__tof },
|
||||
{ off_32L__tom, off_32L__tof },
|
||||
{ phdr_32L11_tom, phdr_32L11_tof },
|
||||
{ rela_32L11_tom, rela_32L11_tof },
|
||||
{ rel_32L11_tom, rel_32L11_tof },
|
||||
{ shdr_32L11_tom, shdr_32L11_tof },
|
||||
{ sword_32L__tom, sword_32L__tof },
|
||||
{ sym_32L11_tom, sym_32L11_tof },
|
||||
{ word_32L__tom, word_32L__tof },
|
||||
{ 0, 0 }, /* there is no Sxword */
|
||||
{ 0, 0 }, /* there is no Xword */
|
||||
#if __LIBELF_SYMBOL_VERSIONS
|
||||
{ _elf_verdef_32L11_tom, _elf_verdef_32L11_tof },
|
||||
{ _elf_verneed_32L11_tom, _elf_verneed_32L11_tof },
|
||||
#else /* __LIBELF_SYMBOL_VERSIONS */
|
||||
{ 0, 0 },
|
||||
{ 0, 0 },
|
||||
#endif /* __LIBELF_SYMBOL_VERSIONS */
|
||||
},
|
||||
{
|
||||
{ byte_copy, byte_copy },
|
||||
{ addr_32M__tom, addr_32M__tof },
|
||||
{ dyn_32M11_tom, dyn_32M11_tof },
|
||||
{ ehdr_32M11_tom, ehdr_32M11_tof },
|
||||
{ half_32M__tom, half_32M__tof },
|
||||
{ off_32M__tom, off_32M__tof },
|
||||
{ phdr_32M11_tom, phdr_32M11_tof },
|
||||
{ rela_32M11_tom, rela_32M11_tof },
|
||||
{ rel_32M11_tom, rel_32M11_tof },
|
||||
{ shdr_32M11_tom, shdr_32M11_tof },
|
||||
{ sword_32M__tom, sword_32M__tof },
|
||||
{ sym_32M11_tom, sym_32M11_tof },
|
||||
{ word_32M__tom, word_32M__tof },
|
||||
{ 0, 0 }, /* there is no Sxword */
|
||||
{ 0, 0 }, /* there is no Xword */
|
||||
#if __LIBELF_SYMBOL_VERSIONS
|
||||
{ _elf_verdef_32M11_tom, _elf_verdef_32M11_tof },
|
||||
{ _elf_verneed_32M11_tom, _elf_verneed_32M11_tof },
|
||||
#else /* __LIBELF_SYMBOL_VERSIONS */
|
||||
{ 0, 0 },
|
||||
{ 0, 0 },
|
||||
#endif /* __LIBELF_SYMBOL_VERSIONS */
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* main translation table (32-bit)
|
||||
*/
|
||||
#if PIC
|
||||
static xltab*
|
||||
#else /* PIC */
|
||||
static const xltab *const
|
||||
#endif /* PIC */
|
||||
xlate32[EV_CURRENT - EV_NONE][EV_CURRENT - EV_NONE] = {
|
||||
{ xlate32_11, },
|
||||
};
|
||||
|
||||
#define translator(sv,dv,enc,type,d) \
|
||||
(xlate32[(sv) - EV_NONE - 1] \
|
||||
[(dv) - EV_NONE - 1] \
|
||||
[(enc) - ELFDATA2LSB] \
|
||||
[(type) - ELF_T_BYTE] \
|
||||
[d])
|
||||
|
||||
/*
|
||||
* destination buffer size
|
||||
*/
|
||||
size_t
|
||||
_elf32_xltsize(const Elf_Data *src, unsigned dv, unsigned encode, int tof) {
|
||||
Elf_Type type = src->d_type;
|
||||
unsigned sv = src->d_version;
|
||||
xlator op;
|
||||
|
||||
if (!valid_version(sv) || !valid_version(dv)) {
|
||||
seterr(ERROR_UNKNOWN_VERSION);
|
||||
return (size_t)-1;
|
||||
}
|
||||
if (tof) {
|
||||
/*
|
||||
* Encoding doesn't really matter (the translator only looks at
|
||||
* the source, which resides in memory), but we need a proper
|
||||
* encoding to select a translator...
|
||||
*/
|
||||
encode = ELFDATA2LSB;
|
||||
}
|
||||
else if (!valid_encoding(encode)) {
|
||||
seterr(ERROR_UNKNOWN_ENCODING);
|
||||
return (size_t)-1;
|
||||
}
|
||||
if (!valid_type(type)) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
return (size_t)-1;
|
||||
}
|
||||
if (!(op = translator(sv, dv, encode, type, tof))) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
return (size_t)-1;
|
||||
}
|
||||
return (*op)(NULL, src->d_buf, src->d_size);
|
||||
}
|
||||
|
||||
/*
|
||||
* direction-independent translation
|
||||
*/
|
||||
static Elf_Data*
|
||||
elf32_xlate(Elf_Data *dst, const Elf_Data *src, unsigned encode, int tof) {
|
||||
Elf_Type type;
|
||||
int dv;
|
||||
int sv;
|
||||
size_t dsize;
|
||||
size_t tmp;
|
||||
xlator op;
|
||||
|
||||
if (!src || !dst) {
|
||||
return NULL;
|
||||
}
|
||||
if (!src->d_buf || !dst->d_buf) {
|
||||
seterr(ERROR_NULLBUF);
|
||||
return NULL;
|
||||
}
|
||||
if (!valid_encoding(encode)) {
|
||||
seterr(ERROR_UNKNOWN_ENCODING);
|
||||
return NULL;
|
||||
}
|
||||
sv = src->d_version;
|
||||
dv = dst->d_version;
|
||||
if (!valid_version(sv) || !valid_version(dv)) {
|
||||
seterr(ERROR_UNKNOWN_VERSION);
|
||||
return NULL;
|
||||
}
|
||||
type = src->d_type;
|
||||
if (!valid_type(type)) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
return NULL;
|
||||
}
|
||||
op = translator(sv, dv, encode, type, tof);
|
||||
if (!op) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
return NULL;
|
||||
}
|
||||
dsize = (*op)(NULL, src->d_buf, src->d_size);
|
||||
if (dsize == (size_t)-1) {
|
||||
return NULL;
|
||||
}
|
||||
if (dst->d_size < dsize) {
|
||||
seterr(ERROR_DST2SMALL);
|
||||
return NULL;
|
||||
}
|
||||
if (dsize) {
|
||||
tmp = (*op)(dst->d_buf, src->d_buf, src->d_size);
|
||||
if (tmp == (size_t)-1) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(tmp == dsize);
|
||||
}
|
||||
dst->d_size = dsize;
|
||||
dst->d_type = type;
|
||||
return dst;
|
||||
}
|
||||
|
||||
/*
|
||||
* finally, the "official" translation functions
|
||||
*/
|
||||
Elf_Data*
|
||||
elf32_xlatetom(Elf_Data *dst, const Elf_Data *src, unsigned encode) {
|
||||
return elf32_xlate(dst, src, encode, 0);
|
||||
}
|
||||
|
||||
Elf_Data*
|
||||
elf32_xlatetof(Elf_Data *dst, const Elf_Data *src, unsigned encode) {
|
||||
return elf32_xlate(dst, src, encode, 1);
|
||||
}
|
||||
Vendored
+512
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
* 64.xlatetof.c - implementation of the elf64_xlateto[fm](3) functions.
|
||||
* Copyright (C) 1995 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
#include <ext_types.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: 64.xlatetof.c,v 1.27 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
/*
|
||||
* Ugly, ugly
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
# define Cat2(a,b)a##b
|
||||
# define Cat3(a,b,c)a##b##c
|
||||
# define Ex1(m1,m2,a,b)m1##m2(a##b)
|
||||
# define Ex2(m1,m2,a,b,c)m1##m2(a,b##c)
|
||||
#else /* _WIN32 */
|
||||
# define x
|
||||
# if defined/**/x
|
||||
# define Cat2(a,b)a##b
|
||||
# define Cat3(a,b,c)a##b##c
|
||||
# define Ex1(m1,m2,a,b)m1##m2(a##b)
|
||||
# define Ex2(m1,m2,a,b,c)m1##m2(a,b##c)
|
||||
# else
|
||||
# define Cat2(a,b)a/**/b
|
||||
# define Cat3(a,b,c)a/**/b/**/c
|
||||
# define Ex1(m1,m2,a,b)m1/**/m2(a/**/b)
|
||||
# define Ex2(m1,m2,a,b,c)m1/**/m2(a,b/**/c)
|
||||
# endif
|
||||
# undef x
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/*
|
||||
* auxiliary macros for execution order reversal
|
||||
*/
|
||||
#define seq_forw(a,b) a b
|
||||
#define seq_back(a,b) b a
|
||||
|
||||
/*
|
||||
* function instantiator
|
||||
*/
|
||||
#define copy_type_e_io(name,e,io,tfrom,tto,copy) \
|
||||
static size_t \
|
||||
Cat3(name,_,io)(unsigned char *dst, const unsigned char *src, size_t n) { \
|
||||
n /= sizeof(tfrom); \
|
||||
if (n && dst) { \
|
||||
const tfrom *from = (const tfrom*)src; \
|
||||
tto *to = (tto*)dst; \
|
||||
size_t i; \
|
||||
\
|
||||
if (sizeof(tfrom) < sizeof(tto)) { \
|
||||
from += n; \
|
||||
to += n; \
|
||||
for (i = 0; i < n; i++) { \
|
||||
--from; \
|
||||
--to; \
|
||||
copy(e,io,seq_back) \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
for (i = 0; i < n; i++) { \
|
||||
copy(e,io,seq_forw) \
|
||||
from++; \
|
||||
to++; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
return n * sizeof(tto); \
|
||||
}
|
||||
|
||||
#define copy_type_e(name,e,type,copy) \
|
||||
copy_type_e_io(name,e,tom,Cat2(__ext_,type),type,copy) \
|
||||
copy_type_e_io(name,e,tof,type,Cat2(__ext_,type),copy)
|
||||
|
||||
/*
|
||||
* master function instantiator
|
||||
*/
|
||||
#define copy_type(name,version,type,copy) \
|
||||
copy_type_e(Cat3(name,L,version),L,type,copy) \
|
||||
copy_type_e(Cat3(name,M,version),M,type,copy)
|
||||
|
||||
/*
|
||||
* scalar copying
|
||||
*/
|
||||
#define copy_scalar_tom(type) *to = Cat2(__load_,type)(*from);
|
||||
#define copy_scalar_tof(type) Cat2(__store_,type)(*to, *from);
|
||||
|
||||
/*
|
||||
* structure member copying
|
||||
*/
|
||||
#define copy_tom(mb,type) to->mb = Cat2(__load_,type)(from->mb);
|
||||
#define copy_tof(mb,type) Cat2(__store_,type)(to->mb, from->mb);
|
||||
|
||||
/*
|
||||
* structure member copying (direction independent)
|
||||
*/
|
||||
#define copy_byte(e,io,mb) to->mb = from->mb;
|
||||
#define copy_addr(e,io,mb) Ex2(copy_,io,mb,u64,e)
|
||||
#define copy_half(e,io,mb) Ex2(copy_,io,mb,u16,e)
|
||||
#define copy_off(e,io,mb) Ex2(copy_,io,mb,u64,e)
|
||||
#define copy_sword(e,io,mb) Ex2(copy_,io,mb,i32,e)
|
||||
#define copy_word(e,io,mb) Ex2(copy_,io,mb,u32,e)
|
||||
#define copy_sxword(e,io,mb) Ex2(copy_,io,mb,i64,e)
|
||||
#define copy_xword(e,io,mb) Ex2(copy_,io,mb,u64,e)
|
||||
#define copy_arr(e,io,mb) \
|
||||
array_copy(to->mb, sizeof(to->mb), from->mb, sizeof(from->mb));
|
||||
|
||||
/*
|
||||
* scalar copying (direction independent)
|
||||
* these macros are used as `copy' arguments to copy_type()
|
||||
*/
|
||||
#define copy_addr_11(e,io,seq) Ex1(copy_scalar_,io,u64,e)
|
||||
#define copy_half_11(e,io,seq) Ex1(copy_scalar_,io,u16,e)
|
||||
#define copy_off_11(e,io,seq) Ex1(copy_scalar_,io,u64,e)
|
||||
#define copy_sword_11(e,io,seq) Ex1(copy_scalar_,io,i32,e)
|
||||
#define copy_word_11(e,io,seq) Ex1(copy_scalar_,io,u32,e)
|
||||
#define copy_sxword_11(e,io,seq)Ex1(copy_scalar_,io,i64,e)
|
||||
#define copy_xword_11(e,io,seq) Ex1(copy_scalar_,io,u64,e)
|
||||
|
||||
/*
|
||||
* structure copying (direction independent)
|
||||
* these macros are used as `copy' arguments to copy_type()
|
||||
*/
|
||||
#define copy_dyn_11(e,io,seq) \
|
||||
seq(copy_xword(e,io,d_tag), \
|
||||
seq(copy_addr(e,io,d_un.d_ptr), \
|
||||
nullcopy))
|
||||
#define copy_ehdr_11(e,io,seq) \
|
||||
seq(copy_arr(e,io,e_ident), \
|
||||
seq(copy_half(e,io,e_type), \
|
||||
seq(copy_half(e,io,e_machine), \
|
||||
seq(copy_word(e,io,e_version), \
|
||||
seq(copy_addr(e,io,e_entry), \
|
||||
seq(copy_off(e,io,e_phoff), \
|
||||
seq(copy_off(e,io,e_shoff), \
|
||||
seq(copy_word(e,io,e_flags), \
|
||||
seq(copy_half(e,io,e_ehsize), \
|
||||
seq(copy_half(e,io,e_phentsize), \
|
||||
seq(copy_half(e,io,e_phnum), \
|
||||
seq(copy_half(e,io,e_shentsize), \
|
||||
seq(copy_half(e,io,e_shnum), \
|
||||
seq(copy_half(e,io,e_shstrndx), \
|
||||
nullcopy))))))))))))))
|
||||
#define copy_phdr_11(e,io,seq) \
|
||||
seq(copy_word(e,io,p_type), \
|
||||
seq(copy_word(e,io,p_flags), \
|
||||
seq(copy_off(e,io,p_offset), \
|
||||
seq(copy_addr(e,io,p_vaddr), \
|
||||
seq(copy_addr(e,io,p_paddr), \
|
||||
seq(copy_xword(e,io,p_filesz), \
|
||||
seq(copy_xword(e,io,p_memsz), \
|
||||
seq(copy_xword(e,io,p_align), \
|
||||
nullcopy))))))))
|
||||
#if __LIBELF64_IRIX
|
||||
#define copy_rela_11(e,io,seq) \
|
||||
seq(copy_addr(e,io,r_offset), \
|
||||
seq(copy_word(e,io,r_sym), \
|
||||
seq(copy_byte(e,io,r_ssym), \
|
||||
seq(copy_byte(e,io,r_type3), \
|
||||
seq(copy_byte(e,io,r_type2), \
|
||||
seq(copy_byte(e,io,r_type), \
|
||||
seq(copy_sxword(e,io,r_addend), \
|
||||
nullcopy)))))))
|
||||
#define copy_rel_11(e,io,seq) \
|
||||
seq(copy_addr(e,io,r_offset), \
|
||||
seq(copy_word(e,io,r_sym), \
|
||||
seq(copy_byte(e,io,r_ssym), \
|
||||
seq(copy_byte(e,io,r_type3), \
|
||||
seq(copy_byte(e,io,r_type2), \
|
||||
seq(copy_byte(e,io,r_type), \
|
||||
nullcopy))))))
|
||||
#else /* __LIBELF64_IRIX */
|
||||
#define copy_rela_11(e,io,seq) \
|
||||
seq(copy_addr(e,io,r_offset), \
|
||||
seq(copy_xword(e,io,r_info), \
|
||||
seq(copy_sxword(e,io,r_addend), \
|
||||
nullcopy)))
|
||||
#define copy_rel_11(e,io,seq) \
|
||||
seq(copy_addr(e,io,r_offset), \
|
||||
seq(copy_xword(e,io,r_info), \
|
||||
nullcopy))
|
||||
#endif /* __LIBELF64_IRIX */
|
||||
#define copy_shdr_11(e,io,seq) \
|
||||
seq(copy_word(e,io,sh_name), \
|
||||
seq(copy_word(e,io,sh_type), \
|
||||
seq(copy_xword(e,io,sh_flags), \
|
||||
seq(copy_addr(e,io,sh_addr), \
|
||||
seq(copy_off(e,io,sh_offset), \
|
||||
seq(copy_xword(e,io,sh_size), \
|
||||
seq(copy_word(e,io,sh_link), \
|
||||
seq(copy_word(e,io,sh_info), \
|
||||
seq(copy_xword(e,io,sh_addralign), \
|
||||
seq(copy_xword(e,io,sh_entsize), \
|
||||
nullcopy))))))))))
|
||||
#define copy_sym_11(e,io,seq) \
|
||||
seq(copy_word(e,io,st_name), \
|
||||
seq(copy_byte(e,io,st_info), \
|
||||
seq(copy_byte(e,io,st_other), \
|
||||
seq(copy_half(e,io,st_shndx), \
|
||||
seq(copy_addr(e,io,st_value), \
|
||||
seq(copy_xword(e,io,st_size), \
|
||||
nullcopy))))))
|
||||
|
||||
#define nullcopy /**/
|
||||
|
||||
static size_t
|
||||
byte_copy(unsigned char *dst, const unsigned char *src, size_t n) {
|
||||
if (n && dst && dst != src) {
|
||||
#if HAVE_BROKEN_MEMMOVE
|
||||
size_t i;
|
||||
|
||||
if (dst >= src + n || dst + n <= src) {
|
||||
memcpy(dst, src, n);
|
||||
}
|
||||
else if (dst < src) {
|
||||
for (i = 0; i < n; i++) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = n; --i; ) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
#else /* HAVE_BROKEN_MEMMOVE */
|
||||
memmove(dst, src, n);
|
||||
#endif /* HAVE_BROKEN_MEMMOVE */
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
array_copy(unsigned char *dst, size_t dlen, const unsigned char *src, size_t slen) {
|
||||
byte_copy(dst, src, dlen < slen ? dlen : slen);
|
||||
if (dlen > slen) {
|
||||
memset(dst + slen, 0, dlen - slen);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* instantiate copy functions
|
||||
*/
|
||||
copy_type(addr_64,_,Elf64_Addr,copy_addr_11)
|
||||
copy_type(half_64,_,Elf64_Half,copy_half_11)
|
||||
copy_type(off_64,_,Elf64_Off,copy_off_11)
|
||||
copy_type(sword_64,_,Elf64_Sword,copy_sword_11)
|
||||
copy_type(word_64,_,Elf64_Word,copy_word_11)
|
||||
copy_type(sxword_64,_,Elf64_Sxword,copy_sxword_11)
|
||||
copy_type(xword_64,_,Elf64_Xword,copy_xword_11)
|
||||
copy_type(dyn_64,11,Elf64_Dyn,copy_dyn_11)
|
||||
copy_type(ehdr_64,11,Elf64_Ehdr,copy_ehdr_11)
|
||||
copy_type(phdr_64,11,Elf64_Phdr,copy_phdr_11)
|
||||
copy_type(rela_64,11,Elf64_Rela,copy_rela_11)
|
||||
copy_type(rel_64,11,Elf64_Rel,copy_rel_11)
|
||||
copy_type(shdr_64,11,Elf64_Shdr,copy_shdr_11)
|
||||
copy_type(sym_64,11,Elf64_Sym,copy_sym_11)
|
||||
|
||||
typedef size_t (*xlator)(unsigned char*, const unsigned char*, size_t);
|
||||
typedef xlator xltab[ELF_T_NUM][2];
|
||||
|
||||
/*
|
||||
* translation table (64-bit, version 1 -> version 1)
|
||||
*/
|
||||
#if PIC
|
||||
static xltab
|
||||
#else /* PIC */
|
||||
static const xltab
|
||||
#endif /* PIC */
|
||||
xlate64_11[/*encoding*/] = {
|
||||
{
|
||||
{ byte_copy, byte_copy },
|
||||
{ addr_64L__tom, addr_64L__tof },
|
||||
{ dyn_64L11_tom, dyn_64L11_tof },
|
||||
{ ehdr_64L11_tom, ehdr_64L11_tof },
|
||||
{ half_64L__tom, half_64L__tof },
|
||||
{ off_64L__tom, off_64L__tof },
|
||||
{ phdr_64L11_tom, phdr_64L11_tof },
|
||||
{ rela_64L11_tom, rela_64L11_tof },
|
||||
{ rel_64L11_tom, rel_64L11_tof },
|
||||
{ shdr_64L11_tom, shdr_64L11_tof },
|
||||
{ sword_64L__tom, sword_64L__tof },
|
||||
{ sym_64L11_tom, sym_64L11_tof },
|
||||
{ word_64L__tom, word_64L__tof },
|
||||
{ sxword_64L__tom, sxword_64L__tof },
|
||||
{ xword_64L__tom, xword_64L__tof },
|
||||
#if __LIBELF_SYMBOL_VERSIONS
|
||||
{ _elf_verdef_64L11_tom, _elf_verdef_64L11_tof },
|
||||
{ _elf_verneed_64L11_tom, _elf_verneed_64L11_tof },
|
||||
#else /* __LIBELF_SYMBOL_VERSIONS */
|
||||
{ 0, 0 },
|
||||
{ 0, 0 },
|
||||
#endif /* __LIBELF_SYMBOL_VERSIONS */
|
||||
},
|
||||
{
|
||||
{ byte_copy, byte_copy },
|
||||
{ addr_64M__tom, addr_64M__tof },
|
||||
{ dyn_64M11_tom, dyn_64M11_tof },
|
||||
{ ehdr_64M11_tom, ehdr_64M11_tof },
|
||||
{ half_64M__tom, half_64M__tof },
|
||||
{ off_64M__tom, off_64M__tof },
|
||||
{ phdr_64M11_tom, phdr_64M11_tof },
|
||||
{ rela_64M11_tom, rela_64M11_tof },
|
||||
{ rel_64M11_tom, rel_64M11_tof },
|
||||
{ shdr_64M11_tom, shdr_64M11_tof },
|
||||
{ sword_64M__tom, sword_64M__tof },
|
||||
{ sym_64M11_tom, sym_64M11_tof },
|
||||
{ word_64M__tom, word_64M__tof },
|
||||
{ sxword_64M__tom, sxword_64M__tof },
|
||||
{ xword_64M__tom, xword_64M__tof },
|
||||
#if __LIBELF_SYMBOL_VERSIONS
|
||||
{ _elf_verdef_64M11_tom, _elf_verdef_64M11_tof },
|
||||
{ _elf_verneed_64M11_tom, _elf_verneed_64M11_tof },
|
||||
#else /* __LIBELF_SYMBOL_VERSIONS */
|
||||
{ 0, 0 },
|
||||
{ 0, 0 },
|
||||
#endif /* __LIBELF_SYMBOL_VERSIONS */
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* main translation table (64-bit)
|
||||
*/
|
||||
#if PIC
|
||||
static xltab*
|
||||
#else /* PIC */
|
||||
static const xltab *const
|
||||
#endif /* PIC */
|
||||
xlate64[EV_CURRENT - EV_NONE][EV_CURRENT - EV_NONE] = {
|
||||
{ xlate64_11, },
|
||||
};
|
||||
|
||||
#define translator(sv,dv,enc,type,d) \
|
||||
(xlate64[(sv) - EV_NONE - 1] \
|
||||
[(dv) - EV_NONE - 1] \
|
||||
[(enc) - ELFDATA2LSB] \
|
||||
[(type) - ELF_T_BYTE] \
|
||||
[d])
|
||||
|
||||
/*
|
||||
* destination buffer size
|
||||
*/
|
||||
size_t
|
||||
_elf64_xltsize(const Elf_Data *src, unsigned dv, unsigned encode, int tof) {
|
||||
Elf_Type type = src->d_type;
|
||||
unsigned sv = src->d_version;
|
||||
xlator op;
|
||||
|
||||
if (!valid_version(sv) || !valid_version(dv)) {
|
||||
seterr(ERROR_UNKNOWN_VERSION);
|
||||
return (size_t)-1;
|
||||
}
|
||||
if (tof) {
|
||||
/*
|
||||
* Encoding doesn't really matter (the translator only looks at
|
||||
* the source, which resides in memory), but we need a proper
|
||||
* encoding to select a translator...
|
||||
*/
|
||||
encode = ELFDATA2LSB;
|
||||
}
|
||||
else if (!valid_encoding(encode)) {
|
||||
seterr(ERROR_UNKNOWN_ENCODING);
|
||||
return (size_t)-1;
|
||||
}
|
||||
if (!valid_type(type)) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
return (size_t)-1;
|
||||
}
|
||||
if (!(op = translator(sv, dv, encode, type, tof))) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
return (size_t)-1;
|
||||
}
|
||||
return (*op)(NULL, src->d_buf, src->d_size);
|
||||
}
|
||||
|
||||
/*
|
||||
* direction-independent translation
|
||||
*/
|
||||
static Elf_Data*
|
||||
elf64_xlate(Elf_Data *dst, const Elf_Data *src, unsigned encode, int tof) {
|
||||
Elf_Type type;
|
||||
int dv;
|
||||
int sv;
|
||||
size_t dsize;
|
||||
size_t tmp;
|
||||
xlator op;
|
||||
|
||||
if (!src || !dst) {
|
||||
return NULL;
|
||||
}
|
||||
if (!src->d_buf || !dst->d_buf) {
|
||||
seterr(ERROR_NULLBUF);
|
||||
return NULL;
|
||||
}
|
||||
if (!valid_encoding(encode)) {
|
||||
seterr(ERROR_UNKNOWN_ENCODING);
|
||||
return NULL;
|
||||
}
|
||||
sv = src->d_version;
|
||||
dv = dst->d_version;
|
||||
if (!valid_version(sv) || !valid_version(dv)) {
|
||||
seterr(ERROR_UNKNOWN_VERSION);
|
||||
return NULL;
|
||||
}
|
||||
type = src->d_type;
|
||||
if (!valid_type(type)) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
return NULL;
|
||||
}
|
||||
op = translator(sv, dv, encode, type, tof);
|
||||
if (!op) {
|
||||
seterr(ERROR_UNKNOWN_TYPE);
|
||||
return NULL;
|
||||
}
|
||||
dsize = (*op)(NULL, src->d_buf, src->d_size);
|
||||
if (dsize == (size_t)-1) {
|
||||
return NULL;
|
||||
}
|
||||
if (dst->d_size < dsize) {
|
||||
seterr(ERROR_DST2SMALL);
|
||||
return NULL;
|
||||
}
|
||||
if (dsize) {
|
||||
tmp = (*op)(dst->d_buf, src->d_buf, src->d_size);
|
||||
if (tmp == (size_t)-1) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(tmp == dsize);
|
||||
}
|
||||
dst->d_size = dsize;
|
||||
dst->d_type = type;
|
||||
return dst;
|
||||
}
|
||||
|
||||
/*
|
||||
* finally, the "official" translation functions
|
||||
*/
|
||||
Elf_Data*
|
||||
elf64_xlatetom(Elf_Data *dst, const Elf_Data *src, unsigned encode) {
|
||||
return elf64_xlate(dst, src, encode, 0);
|
||||
}
|
||||
|
||||
Elf_Data*
|
||||
elf64_xlatetof(Elf_Data *dst, const Elf_Data *src, unsigned encode) {
|
||||
return elf64_xlate(dst, src, encode, 1);
|
||||
}
|
||||
|
||||
Elf_Data*
|
||||
gelf_xlatetom(Elf *elf, Elf_Data *dst, const Elf_Data *src, unsigned encode) {
|
||||
if (elf) {
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (elf->e_class == ELFCLASS32) {
|
||||
return elf32_xlatetom(dst, src, encode);
|
||||
}
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
return elf64_xlatetom(dst, src, encode);
|
||||
}
|
||||
else if (valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Elf_Data*
|
||||
gelf_xlatetof(Elf *elf, Elf_Data *dst, const Elf_Data *src, unsigned encode) {
|
||||
if (elf) {
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (elf->e_class == ELFCLASS32) {
|
||||
return elf32_xlatetof(dst, src, encode);
|
||||
}
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
return elf64_xlatetof(dst, src, encode);
|
||||
}
|
||||
else if (valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64__ */
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
assert.c - assert function for libelf.
|
||||
Copyright (C) 1999 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: assert.c,v 1.5 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void
|
||||
__elf_assert(const char *file, unsigned line, const char *cond) {
|
||||
fprintf(stderr, "%s:%u: libelf assertion failure: %s\n",
|
||||
file, line, cond);
|
||||
abort();
|
||||
}
|
||||
Vendored
+429
@@ -0,0 +1,429 @@
|
||||
/*
|
||||
* begin.c - implementation of the elf_begin(3) and elf_memory(3) functions.
|
||||
* Copyright (C) 1995 - 2004 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: begin.c,v 1.22 2009/11/01 13:04:19 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
static const Elf _elf_init = INIT_ELF;
|
||||
static const char fmag[] = ARFMAG;
|
||||
|
||||
static unsigned long
|
||||
getnum(const char *str, size_t len, int base, size_t *err) {
|
||||
unsigned long result = 0;
|
||||
|
||||
while (len && *str == ' ') {
|
||||
str++; len--;
|
||||
}
|
||||
while (len && *str >= '0' && (*str - '0') < base) {
|
||||
result = base * result + *str++ - '0'; len--;
|
||||
}
|
||||
while (len && *str == ' ') {
|
||||
str++; len--;
|
||||
}
|
||||
if (len) {
|
||||
*err = len;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
_elf_init_ar(Elf *elf) {
|
||||
struct ar_hdr *hdr;
|
||||
size_t offset;
|
||||
size_t size;
|
||||
size_t err = 0;
|
||||
|
||||
elf->e_kind = ELF_K_AR;
|
||||
elf->e_idlen = SARMAG;
|
||||
elf->e_off = SARMAG;
|
||||
|
||||
/* process special members */
|
||||
offset = SARMAG;
|
||||
while (!elf->e_strtab && offset + sizeof(*hdr) <= elf->e_size) {
|
||||
hdr = (struct ar_hdr*)(elf->e_data + offset);
|
||||
if (memcmp(hdr->ar_fmag, fmag, sizeof(fmag) - 1)) {
|
||||
break;
|
||||
}
|
||||
if (hdr->ar_name[0] != '/') {
|
||||
break;
|
||||
}
|
||||
size = getnum(hdr->ar_size, sizeof(hdr->ar_size), 10, &err);
|
||||
if (err || !size) {
|
||||
break;
|
||||
}
|
||||
offset += sizeof(*hdr);
|
||||
if (offset + size > elf->e_size) {
|
||||
break;
|
||||
}
|
||||
if (hdr->ar_name[1] == '/' && hdr->ar_name[2] == ' ') {
|
||||
elf->e_strtab = elf->e_data + offset;
|
||||
elf->e_strlen = size;
|
||||
break;
|
||||
}
|
||||
if (hdr->ar_name[1] != ' ') {
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Windows (.lib) archives provide two symbol tables
|
||||
* The first one is the one we want.
|
||||
*/
|
||||
if (!elf->e_symtab) {
|
||||
elf->e_symtab = elf->e_data + offset;
|
||||
elf->e_symlen = size;
|
||||
}
|
||||
offset += size + (size & 1);
|
||||
}
|
||||
}
|
||||
|
||||
static Elf_Arhdr*
|
||||
_elf_arhdr(Elf *arf) {
|
||||
struct ar_hdr *hdr;
|
||||
Elf_Arhdr *arhdr;
|
||||
size_t namelen;
|
||||
size_t tmp;
|
||||
char *name;
|
||||
size_t err = 0;
|
||||
|
||||
if (arf->e_off == arf->e_size) {
|
||||
/* no error! */
|
||||
return NULL;
|
||||
}
|
||||
if (arf->e_off < 0 || arf->e_off > arf->e_size) {
|
||||
seterr(ERROR_OUTSIDE);
|
||||
return NULL;
|
||||
}
|
||||
if (arf->e_off + sizeof(*hdr) > arf->e_size) {
|
||||
seterr(ERROR_TRUNC_ARHDR);
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(arf->e_data != NULL);
|
||||
hdr = (struct ar_hdr*)(arf->e_data + arf->e_off);
|
||||
if (memcmp(hdr->ar_fmag, fmag, sizeof(fmag) - 1)) {
|
||||
seterr(ERROR_ARFMAG);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
name = hdr->ar_name;
|
||||
for (namelen = sizeof(hdr->ar_name); namelen > 0; namelen--) {
|
||||
if (name[namelen - 1] != ' ') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (name[0] == '/') {
|
||||
if (name[1] >= '0' && name[1] <= '9') {
|
||||
if (!arf->e_strtab) {
|
||||
seterr(ERROR_ARSTRTAB);
|
||||
return NULL;
|
||||
}
|
||||
tmp = getnum(&name[1], namelen - 1, 10, &err);
|
||||
if (err) {
|
||||
seterr(ERROR_ARSPECIAL);
|
||||
return NULL;
|
||||
}
|
||||
if (tmp < 0 || tmp >= arf->e_strlen) {
|
||||
seterr(ERROR_ARSTRTAB);
|
||||
return NULL;
|
||||
}
|
||||
for (namelen = tmp; namelen < arf->e_strlen; namelen++) {
|
||||
if (arf->e_strtab[namelen] == '/') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (namelen == arf->e_strlen) {
|
||||
seterr(ERROR_ARSTRTAB);
|
||||
return NULL;
|
||||
}
|
||||
name = arf->e_strtab + tmp;
|
||||
namelen -= tmp;
|
||||
}
|
||||
else if (namelen != 1 && !(namelen == 2 && name[1] == '/')) {
|
||||
seterr(ERROR_ARSPECIAL);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (namelen > 0 && name[namelen - 1] == '/') {
|
||||
namelen--;
|
||||
}
|
||||
/* XXX some broken software omits the trailing slash
|
||||
else {
|
||||
namelen = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
if (!(arhdr = (Elf_Arhdr*)malloc(sizeof(*arhdr) +
|
||||
sizeof(hdr->ar_name) + namelen + 2))) {
|
||||
seterr(ERROR_MEM_ARHDR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
arhdr->ar_name = NULL;
|
||||
arhdr->ar_rawname = (char*)(arhdr + 1);
|
||||
arhdr->ar_date = getnum(hdr->ar_date, sizeof(hdr->ar_date), 10, &err);
|
||||
arhdr->ar_uid = getnum(hdr->ar_uid, sizeof(hdr->ar_uid), 10, &err);
|
||||
arhdr->ar_gid = getnum(hdr->ar_gid, sizeof(hdr->ar_gid), 10, &err);
|
||||
arhdr->ar_mode = getnum(hdr->ar_mode, sizeof(hdr->ar_mode), 8, &err);
|
||||
arhdr->ar_size = getnum(hdr->ar_size, sizeof(hdr->ar_size), 10, &err);
|
||||
if (err) {
|
||||
free(arhdr);
|
||||
seterr(ERROR_ARHDR);
|
||||
return NULL;
|
||||
}
|
||||
if (arf->e_off + sizeof(struct ar_hdr) + arhdr->ar_size > arf->e_size) {
|
||||
free(arhdr);
|
||||
seterr(ERROR_TRUNC_MEMBER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(arhdr->ar_rawname, hdr->ar_name, sizeof(hdr->ar_name));
|
||||
arhdr->ar_rawname[sizeof(hdr->ar_name)] = '\0';
|
||||
|
||||
if (namelen) {
|
||||
arhdr->ar_name = arhdr->ar_rawname + sizeof(hdr->ar_name) + 1;
|
||||
memcpy(arhdr->ar_name, name, namelen);
|
||||
arhdr->ar_name[namelen] = '\0';
|
||||
}
|
||||
|
||||
return arhdr;
|
||||
}
|
||||
|
||||
static void
|
||||
_elf_check_type(Elf *elf, size_t size) {
|
||||
elf->e_idlen = size;
|
||||
if (size >= EI_NIDENT && !memcmp(elf->e_data, ELFMAG, SELFMAG)) {
|
||||
elf->e_kind = ELF_K_ELF;
|
||||
elf->e_idlen = EI_NIDENT;
|
||||
elf->e_class = elf->e_data[EI_CLASS];
|
||||
elf->e_encoding = elf->e_data[EI_DATA];
|
||||
elf->e_version = elf->e_data[EI_VERSION];
|
||||
}
|
||||
else if (size >= SARMAG && !memcmp(elf->e_data, ARMAG, SARMAG)) {
|
||||
_elf_init_ar(elf);
|
||||
}
|
||||
}
|
||||
|
||||
Elf*
|
||||
elf_begin(int fd, Elf_Cmd cmd, Elf *ref) {
|
||||
Elf_Arhdr *arhdr = NULL;
|
||||
size_t size = 0;
|
||||
off_t off;
|
||||
Elf *elf;
|
||||
|
||||
elf_assert(_elf_init.e_magic == ELF_MAGIC);
|
||||
if (_elf_version == EV_NONE) {
|
||||
seterr(ERROR_VERSION_UNSET);
|
||||
return NULL;
|
||||
}
|
||||
else if (cmd == ELF_C_NULL) {
|
||||
return NULL;
|
||||
}
|
||||
else if (cmd == ELF_C_WRITE) {
|
||||
ref = NULL;
|
||||
}
|
||||
else if (cmd != ELF_C_READ && cmd != ELF_C_RDWR) {
|
||||
seterr(ERROR_INVALID_CMD);
|
||||
return NULL;
|
||||
}
|
||||
else if (ref) {
|
||||
elf_assert(ref->e_magic == ELF_MAGIC);
|
||||
if (!ref->e_readable || (cmd == ELF_C_RDWR && !ref->e_writable)) {
|
||||
seterr(ERROR_CMDMISMATCH);
|
||||
return NULL;
|
||||
}
|
||||
if (ref->e_kind != ELF_K_AR) {
|
||||
ref->e_count++;
|
||||
return ref;
|
||||
}
|
||||
if (cmd == ELF_C_RDWR) {
|
||||
seterr(ERROR_MEMBERWRITE);
|
||||
return NULL;
|
||||
}
|
||||
if (ref->e_memory) {
|
||||
fd = ref->e_fd;
|
||||
}
|
||||
else if (fd != ref->e_fd) {
|
||||
seterr(ERROR_FDMISMATCH);
|
||||
return NULL;
|
||||
}
|
||||
if (!(arhdr = _elf_arhdr(ref))) {
|
||||
return NULL;
|
||||
}
|
||||
size = arhdr->ar_size;
|
||||
}
|
||||
else if ((off = lseek(fd, (off_t)0, SEEK_END)) == (off_t)-1
|
||||
|| (off_t)(size = off) != off) {
|
||||
seterr(ERROR_IO_GETSIZE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(elf = (Elf*)malloc(sizeof(Elf)))) {
|
||||
seterr(ERROR_MEM_ELF);
|
||||
return NULL;
|
||||
}
|
||||
*elf = _elf_init;
|
||||
elf->e_fd = fd;
|
||||
elf->e_parent = ref;
|
||||
elf->e_size = elf->e_dsize = size;
|
||||
|
||||
if (cmd != ELF_C_READ) {
|
||||
elf->e_writable = 1;
|
||||
}
|
||||
if (cmd != ELF_C_WRITE) {
|
||||
elf->e_readable = 1;
|
||||
}
|
||||
else {
|
||||
return elf;
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
size_t offset = ref->e_off + sizeof(struct ar_hdr);
|
||||
Elf *xelf;
|
||||
|
||||
elf_assert(arhdr);
|
||||
elf->e_arhdr = arhdr;
|
||||
elf->e_base = ref->e_base + offset;
|
||||
/*
|
||||
* Share the archive's memory image. To avoid
|
||||
* multiple independent elf descriptors if the
|
||||
* same member is requested twice, scan the list
|
||||
* of open members for duplicates.
|
||||
*
|
||||
* I don't know how SVR4 handles this case. Don't rely on it.
|
||||
*/
|
||||
for (xelf = ref->e_members; xelf; xelf = xelf->e_link) {
|
||||
elf_assert(xelf->e_parent == ref);
|
||||
if (xelf->e_base == elf->e_base) {
|
||||
free(arhdr);
|
||||
free(elf);
|
||||
xelf->e_count++;
|
||||
return xelf;
|
||||
}
|
||||
}
|
||||
if (size == 0) {
|
||||
elf->e_data = NULL;
|
||||
}
|
||||
#if 1
|
||||
else {
|
||||
/*
|
||||
* Archive members may be misaligned. Freezing them will
|
||||
* cause libelf to allocate buffers for translated data,
|
||||
* which should be properly aligned in all cases.
|
||||
*/
|
||||
elf_assert(!ref->e_cooked);
|
||||
elf->e_data = elf->e_rawdata = ref->e_data + offset;
|
||||
}
|
||||
#else
|
||||
else if (ref->e_data == ref->e_rawdata) {
|
||||
elf_assert(!ref->e_cooked);
|
||||
/*
|
||||
* archive is frozen - freeze member, too
|
||||
*/
|
||||
elf->e_data = elf->e_rawdata = ref->e_data + offset;
|
||||
}
|
||||
else {
|
||||
elf_assert(!ref->e_memory);
|
||||
elf->e_data = ref->e_data + offset;
|
||||
/*
|
||||
* The member's memory image may have been modified if
|
||||
* the member has been processed before. Since we need the
|
||||
* original image, we have to re-read the archive file.
|
||||
* Will fail if the archive's file descriptor is disabled.
|
||||
*/
|
||||
if (!ref->e_cooked) {
|
||||
ref->e_cooked = 1;
|
||||
}
|
||||
else if (!_elf_read(ref, elf->e_data, offset, size)) {
|
||||
free(arhdr);
|
||||
free(elf);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
elf->e_next = offset + size + (size & 1);
|
||||
elf->e_disabled = ref->e_disabled;
|
||||
elf->e_memory = ref->e_memory;
|
||||
/* parent/child linking */
|
||||
elf->e_link = ref->e_members;
|
||||
ref->e_members = elf;
|
||||
ref->e_count++;
|
||||
/* Slowaris compatibility - do not rely on this! */
|
||||
ref->e_off = elf->e_next;
|
||||
}
|
||||
else if (size) {
|
||||
#if HAVE_MMAP
|
||||
/*
|
||||
* Using mmap on writable files will interfere with elf_update
|
||||
*/
|
||||
if (!elf->e_writable && (elf->e_data = _elf_mmap(elf))) {
|
||||
elf->e_unmap_data = 1;
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_MMAP */
|
||||
if (!(elf->e_data = _elf_read(elf, NULL, 0, size))) {
|
||||
free(elf);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
_elf_check_type(elf, size);
|
||||
return elf;
|
||||
}
|
||||
|
||||
Elf*
|
||||
elf_memory(char *image, size_t size) {
|
||||
Elf *elf;
|
||||
|
||||
elf_assert(_elf_init.e_magic == ELF_MAGIC);
|
||||
if (_elf_version == EV_NONE) {
|
||||
seterr(ERROR_VERSION_UNSET);
|
||||
return NULL;
|
||||
}
|
||||
else if (size == 0 || image == NULL) {
|
||||
/* TODO: set error code? */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(elf = (Elf*)malloc(sizeof(Elf)))) {
|
||||
seterr(ERROR_MEM_ELF);
|
||||
return NULL;
|
||||
}
|
||||
*elf = _elf_init;
|
||||
elf->e_size = elf->e_dsize = size;
|
||||
elf->e_data = elf->e_rawdata = image;
|
||||
elf->e_readable = 1;
|
||||
elf->e_disabled = 1;
|
||||
elf->e_memory = 1;
|
||||
|
||||
_elf_check_type(elf, size);
|
||||
return elf;
|
||||
}
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
int
|
||||
gelf_getclass(Elf *elf) {
|
||||
if (elf && elf->e_kind == ELF_K_ELF && valid_class(elf->e_class)) {
|
||||
return elf->e_class;
|
||||
}
|
||||
return ELFCLASSNONE;
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+95
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
byteswap.h - functions and macros for byte swapping.
|
||||
Copyright (C) 1995 - 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* @(#) $Id: byteswap.h,v 1.7 2008/05/23 08:15:34 michael Exp $ */
|
||||
|
||||
#ifndef _BYTESWAP_H
|
||||
#define _BYTESWAP_H
|
||||
|
||||
#define lu(from,i,s) (((__libelf_u32_t)((unsigned char*)(from))[i])<<(s))
|
||||
#define li(from,i,s) (((__libelf_i32_t)(( signed char*)(from))[i])<<(s))
|
||||
|
||||
#define __load_u16L(from) ((__libelf_u32_t) \
|
||||
(lu(from,1,8) | lu(from,0,0)))
|
||||
#define __load_u16M(from) ((__libelf_u32_t) \
|
||||
(lu(from,0,8) | lu(from,1,0)))
|
||||
#define __load_i16L(from) ((__libelf_i32_t) \
|
||||
(li(from,1,8) | lu(from,0,0)))
|
||||
#define __load_i16M(from) ((__libelf_i32_t) \
|
||||
(li(from,0,8) | lu(from,1,0)))
|
||||
|
||||
#define __load_u32L(from) ((__libelf_u32_t) \
|
||||
(lu(from,3,24) | lu(from,2,16) | lu(from,1,8) | lu(from,0,0)))
|
||||
#define __load_u32M(from) ((__libelf_u32_t) \
|
||||
(lu(from,0,24) | lu(from,1,16) | lu(from,2,8) | lu(from,3,0)))
|
||||
#define __load_i32L(from) ((__libelf_i32_t) \
|
||||
(li(from,3,24) | lu(from,2,16) | lu(from,1,8) | lu(from,0,0)))
|
||||
#define __load_i32M(from) ((__libelf_i32_t) \
|
||||
(li(from,0,24) | lu(from,1,16) | lu(from,2,8) | lu(from,3,0)))
|
||||
|
||||
#define su(to,i,v,s) (((char*)(to))[i]=((__libelf_u32_t)(v)>>(s)))
|
||||
#define si(to,i,v,s) (((char*)(to))[i]=((__libelf_i32_t)(v)>>(s)))
|
||||
|
||||
#define __store_u16L(to,v) \
|
||||
(su(to,1,v,8), su(to,0,v,0))
|
||||
#define __store_u16M(to,v) \
|
||||
(su(to,0,v,8), su(to,1,v,0))
|
||||
#define __store_i16L(to,v) \
|
||||
(si(to,1,v,8), si(to,0,v,0))
|
||||
#define __store_i16M(to,v) \
|
||||
(si(to,0,v,8), si(to,1,v,0))
|
||||
|
||||
#define __store_u32L(to,v) \
|
||||
(su(to,3,v,24), su(to,2,v,16), su(to,1,v,8), su(to,0,v,0))
|
||||
#define __store_u32M(to,v) \
|
||||
(su(to,0,v,24), su(to,1,v,16), su(to,2,v,8), su(to,3,v,0))
|
||||
#define __store_i32L(to,v) \
|
||||
(si(to,3,v,24), si(to,2,v,16), si(to,1,v,8), si(to,0,v,0))
|
||||
#define __store_i32M(to,v) \
|
||||
(si(to,0,v,24), si(to,1,v,16), si(to,2,v,8), si(to,3,v,0))
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
/*
|
||||
* conversion functions from swap64.c
|
||||
*/
|
||||
extern __libelf_u64_t _elf_load_u64L(const unsigned char *from);
|
||||
extern __libelf_u64_t _elf_load_u64M(const unsigned char *from);
|
||||
extern __libelf_i64_t _elf_load_i64L(const unsigned char *from);
|
||||
extern __libelf_i64_t _elf_load_i64M(const unsigned char *from);
|
||||
extern void _elf_store_u64L(unsigned char *to, __libelf_u64_t v);
|
||||
extern void _elf_store_u64M(unsigned char *to, __libelf_u64_t v);
|
||||
extern void _elf_store_i64L(unsigned char *to, __libelf_u64_t v);
|
||||
extern void _elf_store_i64M(unsigned char *to, __libelf_u64_t v);
|
||||
|
||||
/*
|
||||
* aliases for existing conversion code
|
||||
*/
|
||||
#define __load_u64L _elf_load_u64L
|
||||
#define __load_u64M _elf_load_u64M
|
||||
#define __load_i64L _elf_load_i64L
|
||||
#define __load_i64M _elf_load_i64M
|
||||
#define __store_u64L _elf_store_u64L
|
||||
#define __store_u64M _elf_store_u64M
|
||||
#define __store_i64L _elf_store_i64L
|
||||
#define __store_i64M _elf_store_i64M
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
#endif /* _BYTESWAP_H */
|
||||
Vendored
+178
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
checksum.c - implementation of the elf{32,64}_checksum(3) functions.
|
||||
Copyright (C) 1995 - 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: checksum.c,v 1.7 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
/*
|
||||
* Compatibility note:
|
||||
*
|
||||
* The algorithm used in {elf32,elf64,gelf}_checksum() does not seem to
|
||||
* be documented. I hope I got it right. My implementation does the
|
||||
* following:
|
||||
*
|
||||
* - skip sections that do not have the SHF_ALLOC flag set
|
||||
* - skip sections of type SHT_NULL, SHT_NOBITS, SHT_DYNSYM and
|
||||
* SHT_DYNAMIC
|
||||
* - add all data bytes from the remaining sections, modulo 2**32
|
||||
* - add upper and lower half of the result
|
||||
* - subtract 0xffff if the result is > 0xffff
|
||||
* - if any error occurs, return 0L
|
||||
*/
|
||||
|
||||
static int
|
||||
skip_section(Elf_Scn *scn, unsigned cls) {
|
||||
if (cls == ELFCLASS32) {
|
||||
Elf32_Shdr *shdr = &scn->s_shdr32;
|
||||
|
||||
if (!(shdr->sh_flags & SHF_ALLOC)) {
|
||||
return 1;
|
||||
}
|
||||
switch (shdr->sh_type) {
|
||||
case SHT_NULL:
|
||||
case SHT_NOBITS:
|
||||
/* Solaris seems to ignore these, too */
|
||||
case SHT_DYNSYM:
|
||||
case SHT_DYNAMIC:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (cls == ELFCLASS64) {
|
||||
Elf64_Shdr *shdr = &scn->s_shdr64;
|
||||
|
||||
if (!(shdr->sh_flags & SHF_ALLOC)) {
|
||||
return 1;
|
||||
}
|
||||
switch (shdr->sh_type) {
|
||||
case SHT_NULL:
|
||||
case SHT_NOBITS:
|
||||
/* Solaris seems to ignore these, too */
|
||||
case SHT_DYNSYM:
|
||||
case SHT_DYNAMIC:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long
|
||||
add_bytes(unsigned char *ptr, size_t len) {
|
||||
long csum = 0;
|
||||
|
||||
while (len--) {
|
||||
csum += *ptr++;
|
||||
}
|
||||
return csum;
|
||||
}
|
||||
|
||||
static long
|
||||
_elf_csum(Elf *elf) {
|
||||
long csum = 0;
|
||||
Elf_Data *data;
|
||||
Elf_Scn *scn;
|
||||
|
||||
if (!elf->e_ehdr && !_elf_cook(elf)) {
|
||||
/* propagate errors from _elf_cook */
|
||||
return 0L;
|
||||
}
|
||||
seterr(0);
|
||||
for (scn = elf->e_scn_1; scn; scn = scn->s_link) {
|
||||
if (scn->s_index == SHN_UNDEF || skip_section(scn, elf->e_class)) {
|
||||
continue;
|
||||
}
|
||||
data = NULL;
|
||||
while ((data = elf_getdata(scn, data))) {
|
||||
if (data->d_size) {
|
||||
if (data->d_buf == NULL) {
|
||||
seterr(ERROR_NULLBUF);
|
||||
return 0L;
|
||||
}
|
||||
csum += add_bytes(data->d_buf, data->d_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_elf_errno) {
|
||||
return 0L;
|
||||
}
|
||||
csum = (csum & 0xffff) + ((csum >> 16) & 0xffff);
|
||||
if (csum > 0xffff) {
|
||||
csum -= 0xffff;
|
||||
}
|
||||
return csum;
|
||||
}
|
||||
|
||||
long
|
||||
elf32_checksum(Elf *elf) {
|
||||
if (elf) {
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (elf->e_class != ELFCLASS32) {
|
||||
seterr(ERROR_CLASSMISMATCH);
|
||||
}
|
||||
else {
|
||||
return _elf_csum(elf);
|
||||
}
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
long
|
||||
elf64_checksum(Elf *elf) {
|
||||
if (elf) {
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (elf->e_class != ELFCLASS64) {
|
||||
seterr(ERROR_CLASSMISMATCH);
|
||||
}
|
||||
else {
|
||||
return _elf_csum(elf);
|
||||
}
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
long
|
||||
gelf_checksum(Elf *elf) {
|
||||
if (elf) {
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (!valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
else {
|
||||
return _elf_csum(elf);
|
||||
}
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
cntl.c - implementation of the elf_cntl(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: cntl.c,v 1.7 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
int
|
||||
elf_cntl(Elf *elf, Elf_Cmd cmd) {
|
||||
Elf_Scn *scn;
|
||||
Elf *child;
|
||||
|
||||
if (!elf) {
|
||||
return -1;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (cmd == ELF_C_FDREAD) {
|
||||
if (!elf->e_readable) {
|
||||
seterr(ERROR_WRONLY);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (cmd != ELF_C_FDDONE) {
|
||||
seterr(ERROR_INVALID_CMD);
|
||||
return -1;
|
||||
}
|
||||
if (elf->e_disabled) {
|
||||
return 0;
|
||||
}
|
||||
if (elf->e_kind == ELF_K_AR) {
|
||||
for (child = elf->e_members; child; child = child->e_link) {
|
||||
elf_assert(elf == child->e_parent);
|
||||
if (elf_cntl(child, cmd)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (elf->e_kind == ELF_K_ELF && cmd == ELF_C_FDREAD) {
|
||||
if (!elf->e_ehdr && !_elf_cook(elf)) {
|
||||
return -1;
|
||||
}
|
||||
for (scn = elf->e_scn_1; scn; scn = scn->s_link) {
|
||||
if (scn->s_index == SHN_UNDEF || scn->s_type == SHT_NULL) {
|
||||
continue;
|
||||
}
|
||||
else if (!elf_getdata(scn, NULL)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
elf->e_disabled = 1;
|
||||
return 0;
|
||||
}
|
||||
Vendored
+164
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* lib/config.h.w32 - configuration file for W32 port
|
||||
* Copyright (C) 2004 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* @(#) $Id: config.h.w32,v 1.2 2006/09/07 15:55:42 michael Exp $
|
||||
*/
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
|
||||
/* Define if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if you want to include extra debugging code */
|
||||
#define ENABLE_DEBUG 1
|
||||
|
||||
/* Define if memmove() does not copy overlapping arrays correctly */
|
||||
#undef HAVE_BROKEN_MEMMOVE
|
||||
|
||||
/* Define if you have the catgets function. */
|
||||
#undef HAVE_CATGETS
|
||||
|
||||
/* Define if you have the dgettext function. */
|
||||
#undef HAVE_DGETTEXT
|
||||
|
||||
/* Define if you have the memset function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define if struct nlist is declared in <elf.h> or <sys/elf.h> */
|
||||
#undef HAVE_STRUCT_NLIST_DECLARATION
|
||||
|
||||
/* Define if Elf32_Dyn is declared in <link.h> */
|
||||
#undef __LIBELF_NEED_LINK_H
|
||||
|
||||
/* Define if Elf32_Dyn is declared in <sys/link.h> */
|
||||
#undef __LIBELF_NEED_SYS_LINK_H
|
||||
|
||||
/* Define to `<elf.h>' or `<sys/elf.h>' if one of them is present */
|
||||
#undef __LIBELF_HEADER_ELF_H
|
||||
|
||||
/* Define if you want 64-bit support (and your system supports it) */
|
||||
#define __LIBELF64 1
|
||||
|
||||
/* Define if you want 64-bit support, and are running IRIX */
|
||||
#undef __LIBELF64_IRIX
|
||||
|
||||
/* Define if you want 64-bit support, and are running Linux */
|
||||
#undef __LIBELF64_LINUX
|
||||
|
||||
/* Define if you want symbol versioning (and your system supports it) */
|
||||
#define __LIBELF_SYMBOL_VERSIONS 1
|
||||
|
||||
/* Define if symbol versioning uses Sun section type (SHT_SUNW_*) */
|
||||
#define __LIBELF_SUN_SYMBOL_VERSIONS 1
|
||||
|
||||
/* Define if symbol versioning uses GNU section types (SHT_GNU_*) */
|
||||
#undef __LIBELF_GNU_SYMBOL_VERSIONS
|
||||
|
||||
/* Define to a 64-bit signed integer type if one exists */
|
||||
#define __libelf_i64_t __int64
|
||||
|
||||
/* Define to a 64-bit unsigned integer type if one exists */
|
||||
#define __libelf_u64_t unsigned __int64
|
||||
|
||||
/* Define to a 32-bit signed integer type if one exists */
|
||||
#define __libelf_i32_t int
|
||||
|
||||
/* Define to a 32-bit unsigned integer type if one exists */
|
||||
#define __libelf_u32_t unsigned int
|
||||
|
||||
/* Define to a 16-bit signed integer type if one exists */
|
||||
#define __libelf_i16_t short int
|
||||
|
||||
/* Define to a 16-bit unsigned integer type if one exists */
|
||||
#define __libelf_u16_t unsigned short int
|
||||
|
||||
/* The number of bytes in a __int64. */
|
||||
#define SIZEOF___INT64 8
|
||||
|
||||
/* The number of bytes in a int. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
/* The number of bytes in a long. */
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
/* The number of bytes in a long long. */
|
||||
#define SIZEOF_LONG_LONG 0
|
||||
|
||||
/* The number of bytes in a short. */
|
||||
#define SIZEOF_SHORT 2
|
||||
|
||||
/* Define if you have the ftruncate function. */
|
||||
#undef HAVE_FTRUNCATE
|
||||
|
||||
/* Define if you have the getpagesize function. */
|
||||
#undef HAVE_GETPAGESIZE
|
||||
|
||||
/* Define if you have the memcmp function. */
|
||||
#define HAVE_MEMCMP 1
|
||||
|
||||
/* Define if you have the memcpy function. */
|
||||
#define HAVE_MEMCPY 1
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* Define if you have the memset function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define if you have the <ar.h> header file. */
|
||||
#undef HAVE_AR_H
|
||||
|
||||
/* Define if you have the <elf.h> header file. */
|
||||
#undef HAVE_ELF_H
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define if you have the <gelf.h> header file. */
|
||||
#undef HAVE_GELF_H
|
||||
|
||||
/* Define if you have the <libelf.h> header file. */
|
||||
#undef HAVE_LIBELF_H
|
||||
|
||||
/* Define if you have the <link.h> header file. */
|
||||
#undef HAVE_LINK_H
|
||||
|
||||
/* Define if you have the <nlist.h> header file. */
|
||||
#undef HAVE_NLIST_H
|
||||
|
||||
/* Define if you have the <sys/elf.h> header file. */
|
||||
#undef HAVE_SYS_ELF_H
|
||||
|
||||
/* Define if you have the <sys/link.h> header file. */
|
||||
#undef HAVE_SYS_LINK_H
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
Vendored
+501
@@ -0,0 +1,501 @@
|
||||
/*
|
||||
* cook.c - read and translate ELF files.
|
||||
* Copyright (C) 1995 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: cook.c,v 1.29 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
const Elf_Scn _elf_scn_init = INIT_SCN;
|
||||
const Scn_Data _elf_data_init = INIT_DATA;
|
||||
|
||||
Elf_Type
|
||||
_elf_scn_type(unsigned t) {
|
||||
switch (t) {
|
||||
case SHT_DYNAMIC: return ELF_T_DYN;
|
||||
case SHT_DYNSYM: return ELF_T_SYM;
|
||||
case SHT_HASH: return ELF_T_WORD;
|
||||
case SHT_REL: return ELF_T_REL;
|
||||
case SHT_RELA: return ELF_T_RELA;
|
||||
case SHT_SYMTAB: return ELF_T_SYM;
|
||||
case SHT_SYMTAB_SHNDX: return ELF_T_WORD; /* XXX: really? */
|
||||
#if __LIBELF_SYMBOL_VERSIONS
|
||||
#if __LIBELF_SUN_SYMBOL_VERSIONS
|
||||
case SHT_SUNW_verdef: return ELF_T_VDEF;
|
||||
case SHT_SUNW_verneed: return ELF_T_VNEED;
|
||||
case SHT_SUNW_versym: return ELF_T_HALF;
|
||||
#else /* __LIBELF_SUN_SYMBOL_VERSIONS */
|
||||
case SHT_GNU_verdef: return ELF_T_VDEF;
|
||||
case SHT_GNU_verneed: return ELF_T_VNEED;
|
||||
case SHT_GNU_versym: return ELF_T_HALF;
|
||||
#endif /* __LIBELF_SUN_SYMBOL_VERSIONS */
|
||||
#endif /* __LIBELF_SYMBOL_VERSIONS */
|
||||
}
|
||||
return ELF_T_BYTE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for overflow on 32-bit systems
|
||||
*/
|
||||
#define overflow(a,b,t) (sizeof(a) < sizeof(t) && (t)(a) != (b))
|
||||
|
||||
#define truncerr(t) ((t)==ELF_T_EHDR?ERROR_TRUNC_EHDR: \
|
||||
((t)==ELF_T_PHDR?ERROR_TRUNC_PHDR: \
|
||||
ERROR_INTERNAL))
|
||||
#define memerr(t) ((t)==ELF_T_EHDR?ERROR_MEM_EHDR: \
|
||||
((t)==ELF_T_PHDR?ERROR_MEM_PHDR: \
|
||||
ERROR_INTERNAL))
|
||||
|
||||
Elf_Data*
|
||||
_elf_xlatetom(const Elf *elf, Elf_Data *dst, const Elf_Data *src) {
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
return elf32_xlatetom(dst, src, elf->e_encoding);
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
return elf64_xlatetom(dst, src, elf->e_encoding);
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char*
|
||||
_elf_item(void *buf, Elf *elf, Elf_Type type, size_t off) {
|
||||
Elf_Data src, dst;
|
||||
|
||||
elf_assert(valid_type(type));
|
||||
if (off < 0 || off > elf->e_size) {
|
||||
seterr(ERROR_OUTSIDE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
src.d_type = type;
|
||||
src.d_version = elf->e_version;
|
||||
src.d_size = _fsize(elf->e_class, src.d_version, type);
|
||||
elf_assert(src.d_size);
|
||||
if ((elf->e_size - off) < src.d_size) {
|
||||
seterr(truncerr(type));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dst.d_version = _elf_version;
|
||||
dst.d_size = _msize(elf->e_class, dst.d_version, type);
|
||||
elf_assert(dst.d_size);
|
||||
|
||||
if (!(dst.d_buf = buf) && !(dst.d_buf = malloc(dst.d_size))) {
|
||||
seterr(memerr(type));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
elf_assert(elf->e_data);
|
||||
if (elf->e_rawdata) {
|
||||
src.d_buf = elf->e_rawdata + off;
|
||||
}
|
||||
else {
|
||||
src.d_buf = elf->e_data + off;
|
||||
}
|
||||
|
||||
if (_elf_xlatetom(elf, &dst, &src)) {
|
||||
return (char*)dst.d_buf;
|
||||
}
|
||||
if (dst.d_buf != buf) {
|
||||
free(dst.d_buf);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
_elf_cook_phdr(Elf *elf) {
|
||||
size_t num, off, entsz;
|
||||
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
num = ((Elf32_Ehdr*)elf->e_ehdr)->e_phnum;
|
||||
off = ((Elf32_Ehdr*)elf->e_ehdr)->e_phoff;
|
||||
entsz = ((Elf32_Ehdr*)elf->e_ehdr)->e_phentsize;
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
num = ((Elf64_Ehdr*)elf->e_ehdr)->e_phnum;
|
||||
off = ((Elf64_Ehdr*)elf->e_ehdr)->e_phoff;
|
||||
entsz = ((Elf64_Ehdr*)elf->e_ehdr)->e_phentsize;
|
||||
/*
|
||||
* Check for overflow on 32-bit systems
|
||||
*/
|
||||
if (overflow(off, ((Elf64_Ehdr*)elf->e_ehdr)->e_phoff, Elf64_Off)) {
|
||||
seterr(ERROR_OUTSIDE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
if (off) {
|
||||
Elf_Scn *scn;
|
||||
size_t size;
|
||||
unsigned i;
|
||||
char *p;
|
||||
|
||||
if (num == PN_XNUM) {
|
||||
/*
|
||||
* Overflow in ehdr->e_phnum.
|
||||
* Get real value from first SHDR.
|
||||
*/
|
||||
if (!(scn = elf->e_scn_1)) {
|
||||
seterr(ERROR_NOSUCHSCN);
|
||||
return 0;
|
||||
}
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
num = scn->s_shdr32.sh_info;
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
num = scn->s_shdr64.sh_info;
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
/* we already had this
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
size = _fsize(elf->e_class, elf->e_version, ELF_T_PHDR);
|
||||
elf_assert(size);
|
||||
#if ENABLE_EXTENDED_FORMAT
|
||||
if (entsz < size) {
|
||||
#else /* ENABLE_EXTENDED_FORMAT */
|
||||
if (entsz != size) {
|
||||
#endif /* ENABLE_EXTENDED_FORMAT */
|
||||
seterr(ERROR_EHDR_PHENTSIZE);
|
||||
return 0;
|
||||
}
|
||||
size = _msize(elf->e_class, _elf_version, ELF_T_PHDR);
|
||||
elf_assert(size);
|
||||
if (!(p = malloc(num * size))) {
|
||||
seterr(memerr(ELF_T_PHDR));
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < num; i++) {
|
||||
if (!_elf_item(p + i * size, elf, ELF_T_PHDR, off + i * entsz)) {
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
elf->e_phdr = p;
|
||||
elf->e_phnum = num;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_elf_cook_shdr(Elf *elf) {
|
||||
size_t num, off, entsz;
|
||||
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
num = ((Elf32_Ehdr*)elf->e_ehdr)->e_shnum;
|
||||
off = ((Elf32_Ehdr*)elf->e_ehdr)->e_shoff;
|
||||
entsz = ((Elf32_Ehdr*)elf->e_ehdr)->e_shentsize;
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
num = ((Elf64_Ehdr*)elf->e_ehdr)->e_shnum;
|
||||
off = ((Elf64_Ehdr*)elf->e_ehdr)->e_shoff;
|
||||
entsz = ((Elf64_Ehdr*)elf->e_ehdr)->e_shentsize;
|
||||
/*
|
||||
* Check for overflow on 32-bit systems
|
||||
*/
|
||||
if (overflow(off, ((Elf64_Ehdr*)elf->e_ehdr)->e_shoff, Elf64_Off)) {
|
||||
seterr(ERROR_OUTSIDE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
if (off) {
|
||||
struct tmp {
|
||||
Elf_Scn scn;
|
||||
Scn_Data data;
|
||||
} *head;
|
||||
Elf_Data src, dst;
|
||||
Elf_Scn *scn;
|
||||
Scn_Data *sd;
|
||||
unsigned i;
|
||||
|
||||
if (off < 0 || off > elf->e_size) {
|
||||
seterr(ERROR_OUTSIDE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
src.d_type = ELF_T_SHDR;
|
||||
src.d_version = elf->e_version;
|
||||
src.d_size = _fsize(elf->e_class, src.d_version, ELF_T_SHDR);
|
||||
elf_assert(src.d_size);
|
||||
#if ENABLE_EXTENDED_FORMAT
|
||||
if (entsz < src.d_size) {
|
||||
#else /* ENABLE_EXTENDED_FORMAT */
|
||||
if (entsz != src.d_size) {
|
||||
#endif /* ENABLE_EXTENDED_FORMAT */
|
||||
seterr(ERROR_EHDR_SHENTSIZE);
|
||||
return 0;
|
||||
}
|
||||
dst.d_version = EV_CURRENT;
|
||||
|
||||
if (num == 0) {
|
||||
union {
|
||||
Elf32_Shdr sh32;
|
||||
#if __LIBELF64
|
||||
Elf64_Shdr sh64;
|
||||
#endif /* __LIBELF64 */
|
||||
} u;
|
||||
|
||||
/*
|
||||
* Overflow in ehdr->e_shnum.
|
||||
* Get real value from first SHDR.
|
||||
*/
|
||||
if (elf->e_size - off < entsz) {
|
||||
seterr(ERROR_TRUNC_SHDR);
|
||||
return 0;
|
||||
}
|
||||
if (elf->e_rawdata) {
|
||||
src.d_buf = elf->e_rawdata + off;
|
||||
}
|
||||
else {
|
||||
src.d_buf = elf->e_data + off;
|
||||
}
|
||||
dst.d_buf = &u;
|
||||
dst.d_size = sizeof(u);
|
||||
if (!_elf_xlatetom(elf, &dst, &src)) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(dst.d_size == _msize(elf->e_class, EV_CURRENT, ELF_T_SHDR));
|
||||
elf_assert(dst.d_type == ELF_T_SHDR);
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
num = u.sh32.sh_size;
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
num = u.sh64.sh_size;
|
||||
/*
|
||||
* Check for overflow on 32-bit systems
|
||||
*/
|
||||
if (overflow(num, u.sh64.sh_size, Elf64_Xword)) {
|
||||
seterr(ERROR_OUTSIDE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
}
|
||||
|
||||
if ((elf->e_size - off) / entsz < num) {
|
||||
seterr(ERROR_TRUNC_SHDR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(head = (struct tmp*)malloc(num * sizeof(struct tmp)))) {
|
||||
seterr(ERROR_MEM_SCN);
|
||||
return 0;
|
||||
}
|
||||
for (scn = NULL, i = num; i-- > 0; ) {
|
||||
head[i].scn = _elf_scn_init;
|
||||
head[i].data = _elf_data_init;
|
||||
head[i].scn.s_link = scn;
|
||||
if (!scn) {
|
||||
elf->e_scn_n = &head[i].scn;
|
||||
}
|
||||
scn = &head[i].scn;
|
||||
sd = &head[i].data;
|
||||
|
||||
if (elf->e_rawdata) {
|
||||
src.d_buf = elf->e_rawdata + off + i * entsz;
|
||||
}
|
||||
else {
|
||||
src.d_buf = elf->e_data + off + i * entsz;
|
||||
}
|
||||
dst.d_buf = &scn->s_uhdr;
|
||||
dst.d_size = sizeof(scn->s_uhdr);
|
||||
if (!_elf_xlatetom(elf, &dst, &src)) {
|
||||
elf->e_scn_n = NULL;
|
||||
free(head);
|
||||
return 0;
|
||||
}
|
||||
elf_assert(dst.d_size == _msize(elf->e_class, EV_CURRENT, ELF_T_SHDR));
|
||||
elf_assert(dst.d_type == ELF_T_SHDR);
|
||||
|
||||
scn->s_elf = elf;
|
||||
scn->s_index = i;
|
||||
scn->s_data_1 = sd;
|
||||
scn->s_data_n = sd;
|
||||
|
||||
sd->sd_scn = scn;
|
||||
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
Elf32_Shdr *shdr = &scn->s_shdr32;
|
||||
|
||||
scn->s_type = shdr->sh_type;
|
||||
scn->s_size = shdr->sh_size;
|
||||
scn->s_offset = shdr->sh_offset;
|
||||
sd->sd_data.d_align = shdr->sh_addralign;
|
||||
sd->sd_data.d_type = _elf_scn_type(scn->s_type);
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
Elf64_Shdr *shdr = &scn->s_shdr64;
|
||||
|
||||
scn->s_type = shdr->sh_type;
|
||||
scn->s_size = shdr->sh_size;
|
||||
scn->s_offset = shdr->sh_offset;
|
||||
sd->sd_data.d_align = shdr->sh_addralign;
|
||||
/*
|
||||
* Check for overflow on 32-bit systems
|
||||
*/
|
||||
if (overflow(scn->s_size, shdr->sh_size, Elf64_Xword)
|
||||
|| overflow(scn->s_offset, shdr->sh_offset, Elf64_Off)
|
||||
|| overflow(sd->sd_data.d_align, shdr->sh_addralign, Elf64_Xword)) {
|
||||
seterr(ERROR_OUTSIDE);
|
||||
return 0;
|
||||
}
|
||||
sd->sd_data.d_type = _elf_scn_type(scn->s_type);
|
||||
/*
|
||||
* QUIRKS MODE:
|
||||
*
|
||||
* Some 64-bit architectures use 64-bit entries in the
|
||||
* .hash section. This violates the ELF standard, and
|
||||
* should be fixed. It's mostly harmless as long as the
|
||||
* binary and the machine running your program have the
|
||||
* same byte order, but you're in trouble if they don't,
|
||||
* and if the entry size is wrong.
|
||||
*
|
||||
* As a workaround, I let libelf guess the right size
|
||||
* for the binary. This relies pretty much on the fact
|
||||
* that the binary provides correct data in the section
|
||||
* headers. If it doesn't, it's probably broken anyway.
|
||||
* Therefore, libelf uses a standard conforming value
|
||||
* when it's not absolutely sure.
|
||||
*/
|
||||
if (scn->s_type == SHT_HASH) {
|
||||
int override = 0;
|
||||
|
||||
/*
|
||||
* sh_entsize must reflect the entry size
|
||||
*/
|
||||
if (shdr->sh_entsize == ELF64_FSZ_ADDR) {
|
||||
override++;
|
||||
}
|
||||
/*
|
||||
* sh_size must be a multiple of sh_entsize
|
||||
*/
|
||||
if (shdr->sh_size % ELF64_FSZ_ADDR == 0) {
|
||||
override++;
|
||||
}
|
||||
/*
|
||||
* There must be room for at least 2 entries
|
||||
*/
|
||||
if (shdr->sh_size >= 2 * ELF64_FSZ_ADDR) {
|
||||
override++;
|
||||
}
|
||||
/*
|
||||
* sh_addralign must be correctly set
|
||||
*/
|
||||
if (shdr->sh_addralign == ELF64_FSZ_ADDR) {
|
||||
override++;
|
||||
}
|
||||
/*
|
||||
* The section must be properly aligned
|
||||
*/
|
||||
if (shdr->sh_offset % ELF64_FSZ_ADDR == 0) {
|
||||
override++;
|
||||
}
|
||||
/* XXX: also look at the data? */
|
||||
/*
|
||||
* Make a conservative decision...
|
||||
*/
|
||||
if (override >= 5) {
|
||||
sd->sd_data.d_type = ELF_T_ADDR;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* END QUIRKS MODE.
|
||||
*/
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
/* we already had this
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
sd->sd_data.d_size = scn->s_size;
|
||||
sd->sd_data.d_version = _elf_version;
|
||||
}
|
||||
elf_assert(scn == &head[0].scn);
|
||||
elf->e_scn_1 = &head[0].scn;
|
||||
head[0].scn.s_freeme = 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_elf_cook_file(Elf *elf) {
|
||||
elf->e_ehdr = _elf_item(NULL, elf, ELF_T_EHDR, 0);
|
||||
if (!elf->e_ehdr) {
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Note: _elf_cook_phdr may require the first section header!
|
||||
*/
|
||||
if (!_elf_cook_shdr(elf)) {
|
||||
return 0;
|
||||
}
|
||||
if (!_elf_cook_phdr(elf)) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
_elf_cook(Elf *elf) {
|
||||
elf_assert(_elf_scn_init.s_magic == SCN_MAGIC);
|
||||
elf_assert(_elf_data_init.sd_magic == DATA_MAGIC);
|
||||
elf_assert(elf);
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
elf_assert(elf->e_kind == ELF_K_ELF);
|
||||
elf_assert(!elf->e_ehdr);
|
||||
if (!valid_version(elf->e_version)) {
|
||||
seterr(ERROR_UNKNOWN_VERSION);
|
||||
}
|
||||
else if (!valid_encoding(elf->e_encoding)) {
|
||||
seterr(ERROR_UNKNOWN_ENCODING);
|
||||
}
|
||||
else if (valid_class(elf->e_class)) {
|
||||
return _elf_cook_file(elf);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* data.c - libelf internal variables.
|
||||
* Copyright (C) 1995 - 1998, 2007 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: data.c,v 1.8 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
unsigned _elf_version = EV_NONE;
|
||||
int _elf_errno = 0;
|
||||
int _elf_fill = 0;
|
||||
|
||||
#if ENABLE_SANITY_CHECKS
|
||||
#define SANITY_CHECKS -1
|
||||
#else
|
||||
#define SANITY_CHECKS 0
|
||||
#endif
|
||||
|
||||
int _elf_sanity_checks = SANITY_CHECKS;
|
||||
Vendored
+118
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* end.c - implementation of the elf_end(3) function.
|
||||
* Copyright (C) 1995 - 2004 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: end.c,v 1.12 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#if HAVE_MMAP
|
||||
#include <sys/mman.h>
|
||||
#endif /* HAVE_MMAP */
|
||||
|
||||
static void
|
||||
_elf_free(void *ptr) {
|
||||
if (ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_elf_free_scns(Elf *elf, Elf_Scn *scn) {
|
||||
Scn_Data *sd, *tmp;
|
||||
Elf_Scn *freescn;
|
||||
|
||||
for (freescn = NULL; scn; scn = scn->s_link) {
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
elf_assert(scn->s_elf == elf);
|
||||
for (sd = scn->s_data_1; sd; sd = tmp) {
|
||||
elf_assert(sd->sd_magic == DATA_MAGIC);
|
||||
elf_assert(sd->sd_scn == scn);
|
||||
tmp = sd->sd_link;
|
||||
if (sd->sd_free_data) {
|
||||
_elf_free(sd->sd_memdata);
|
||||
}
|
||||
if (sd->sd_freeme) {
|
||||
free(sd);
|
||||
}
|
||||
}
|
||||
if ((sd = scn->s_rawdata)) {
|
||||
elf_assert(sd->sd_magic == DATA_MAGIC);
|
||||
elf_assert(sd->sd_scn == scn);
|
||||
if (sd->sd_free_data) {
|
||||
_elf_free(sd->sd_memdata);
|
||||
}
|
||||
if (sd->sd_freeme) {
|
||||
free(sd);
|
||||
}
|
||||
}
|
||||
if (scn->s_freeme) {
|
||||
_elf_free(freescn);
|
||||
freescn = scn;
|
||||
}
|
||||
}
|
||||
_elf_free(freescn);
|
||||
}
|
||||
|
||||
int
|
||||
elf_end(Elf *elf) {
|
||||
Elf **siblings;
|
||||
|
||||
if (!elf) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (--elf->e_count) {
|
||||
return elf->e_count;
|
||||
}
|
||||
if (elf->e_parent) {
|
||||
elf_assert(elf->e_parent->e_magic == ELF_MAGIC);
|
||||
elf_assert(elf->e_parent->e_kind == ELF_K_AR);
|
||||
siblings = &elf->e_parent->e_members;
|
||||
while (*siblings) {
|
||||
if (*siblings == elf) {
|
||||
*siblings = elf->e_link;
|
||||
break;
|
||||
}
|
||||
siblings = &(*siblings)->e_link;
|
||||
}
|
||||
elf_end(elf->e_parent);
|
||||
_elf_free(elf->e_arhdr);
|
||||
}
|
||||
#if HAVE_MMAP
|
||||
else if (elf->e_unmap_data) {
|
||||
munmap(elf->e_data, elf->e_size);
|
||||
}
|
||||
#endif /* HAVE_MMAP */
|
||||
else if (!elf->e_memory) {
|
||||
_elf_free(elf->e_data);
|
||||
}
|
||||
_elf_free_scns(elf, elf->e_scn_1);
|
||||
if (elf->e_rawdata != elf->e_data) {
|
||||
_elf_free(elf->e_rawdata);
|
||||
}
|
||||
if (elf->e_free_syms) {
|
||||
_elf_free(elf->e_symtab);
|
||||
}
|
||||
_elf_free(elf->e_ehdr);
|
||||
_elf_free(elf->e_phdr);
|
||||
free(elf);
|
||||
return 0;
|
||||
}
|
||||
Vendored
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* errmsg.c - implementation of the elf_errmsg(3) function.
|
||||
* Copyright (C) 1995 - 1999, 2004 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: errmsg.c,v 1.11 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#if HAVE_DGETTEXT
|
||||
# undef HAVE_CATGETS
|
||||
# include <libintl.h>
|
||||
#else /* HAVE_DGETTEXT */
|
||||
# define dgettext(dom, str) str
|
||||
#endif /* HAVE_DGETTEXT */
|
||||
|
||||
#if HAVE_CATGETS
|
||||
# include <nl_types.h>
|
||||
static nl_catd _libelf_cat = (nl_catd)0;
|
||||
#endif /* HAVE_CATGETS */
|
||||
|
||||
#if HAVE_DGETTEXT || HAVE_CATGETS
|
||||
static const char domain[] = "libelf";
|
||||
#endif /* HAVE_DGETTEXT || HAVE_CATGETS */
|
||||
|
||||
#if PIC
|
||||
static const char *_messages[] = {
|
||||
#else /* PIC */
|
||||
static const char *const _messages[] = {
|
||||
#endif /* PIC */
|
||||
#define __err__(a,b) b,
|
||||
#include <errors.h> /* include string tables from errors.h */
|
||||
#undef __err__
|
||||
};
|
||||
|
||||
const char*
|
||||
elf_errmsg(int err) {
|
||||
if (err == 0) {
|
||||
err = _elf_errno;
|
||||
if (err == 0) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (err == -1) {
|
||||
err = _elf_errno;
|
||||
}
|
||||
|
||||
if (err < 0 || err >= ERROR_NUM || _messages[err] == NULL) {
|
||||
err = ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
#if HAVE_CATGETS
|
||||
if (_libelf_cat == (nl_catd)0) {
|
||||
_libelf_cat = catopen(domain, 0);
|
||||
}
|
||||
if (_libelf_cat != (nl_catd)-1) {
|
||||
return catgets(_libelf_cat, 1, err + 1, _messages[err]);
|
||||
}
|
||||
#endif /* HAVE_CATGETS */
|
||||
return dgettext(domain, _messages[err]);
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
errno.c - implementation of the elf_errno(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: errno.c,v 1.7 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
int
|
||||
elf_errno(void) {
|
||||
int tmp = _elf_errno;
|
||||
|
||||
_elf_errno = 0;
|
||||
return tmp;
|
||||
}
|
||||
Vendored
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* errors.h - exhaustive list of all error codes and messages for libelf.
|
||||
* Copyright (C) 1995 - 2003, 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* @(#) $Id: errors.h,v 1.18 2008/05/23 08:15:34 michael Exp $ */
|
||||
|
||||
/* dummy for xgettext */
|
||||
#define _(str) str
|
||||
|
||||
__err__(ERROR_OK, _("no error"))
|
||||
__err__(ERROR_UNKNOWN, _("unknown error"))
|
||||
__err__(ERROR_INTERNAL, _("Internal error: unknown reason"))
|
||||
__err__(ERROR_UNIMPLEMENTED, _("Internal error: not implemented"))
|
||||
__err__(ERROR_WRONLY, _("Request error: cntl(ELF_C_FDREAD) on write-only file"))
|
||||
__err__(ERROR_INVALID_CMD, _("Request error: invalid ELF_C_* argument"))
|
||||
__err__(ERROR_FDDISABLED, _("Request error: file descriptor disabled"))
|
||||
__err__(ERROR_NOTARCHIVE, _("Request error: not an archive"))
|
||||
__err__(ERROR_BADOFF, _("Request error: offset out of range"))
|
||||
__err__(ERROR_UNKNOWN_VERSION, _("Request error: unknown ELF version"))
|
||||
__err__(ERROR_CMDMISMATCH, _("Request error: ELF_C_* argument does not match"))
|
||||
__err__(ERROR_MEMBERWRITE, _("Request error: archive member begin() for writing"))
|
||||
__err__(ERROR_FDMISMATCH, _("Request error: archive/member file descriptor mismatch"))
|
||||
__err__(ERROR_NOTELF, _("Request error: not an ELF file"))
|
||||
__err__(ERROR_CLASSMISMATCH, _("Request error: class file/memory mismatch"))
|
||||
__err__(ERROR_UNKNOWN_TYPE, _("Request error: invalid ELF_T_* argument"))
|
||||
__err__(ERROR_UNKNOWN_ENCODING, _("Request error: unknown data encoding"))
|
||||
__err__(ERROR_DST2SMALL, _("Request error: destination buffer too small"))
|
||||
__err__(ERROR_NULLBUF, _("Request error: d_buf is NULL"))
|
||||
__err__(ERROR_UNKNOWN_CLASS, _("Request error: unknown ELF class"))
|
||||
__err__(ERROR_ELFSCNMISMATCH, _("Request error: section does not belong to file"))
|
||||
__err__(ERROR_NOSUCHSCN, _("Request error: no section at index"))
|
||||
__err__(ERROR_NULLSCN, _("Request error: can't manipulate null section"))
|
||||
__err__(ERROR_SCNDATAMISMATCH, _("Request error: data does not belong to section"))
|
||||
__err__(ERROR_NOSTRTAB, _("Request error: no string table"))
|
||||
__err__(ERROR_BADSTROFF, _("Request error: string table offset out of range"))
|
||||
__err__(ERROR_RDONLY, _("Request error: update(ELF_C_WRITE) on read-only file"))
|
||||
__err__(ERROR_IO_SEEK, _("I/O error: seek"))
|
||||
__err__(ERROR_IO_2BIG, _("I/O error: file too big for memory"))
|
||||
__err__(ERROR_IO_READ, _("I/O error: raw read"))
|
||||
__err__(ERROR_IO_GETSIZE, _("I/O error: get file size"))
|
||||
__err__(ERROR_IO_WRITE, _("I/O error: output write"))
|
||||
__err__(ERROR_IO_TRUNC, _("I/O error: can't truncate output file"))
|
||||
__err__(ERROR_VERSION_UNSET, _("Sequence error: must set ELF version first"))
|
||||
__err__(ERROR_NOEHDR, _("Sequence error: must create ELF header first"))
|
||||
__err__(ERROR_OUTSIDE, _("Format error: reference outside file"))
|
||||
__err__(ERROR_TRUNC_ARHDR, _("Format error: archive header truncated"))
|
||||
__err__(ERROR_ARFMAG, _("Format error: archive fmag"))
|
||||
__err__(ERROR_ARHDR, _("Format error: archive header"))
|
||||
__err__(ERROR_TRUNC_MEMBER, _("Format error: archive member truncated"))
|
||||
__err__(ERROR_SIZE_ARSYMTAB, _("Format error: archive symbol table size"))
|
||||
__err__(ERROR_ARSTRTAB, _("Format error: archive string table"))
|
||||
__err__(ERROR_ARSPECIAL, _("Format error: archive special name unknown"))
|
||||
__err__(ERROR_TRUNC_EHDR, _("Format error: ELF header truncated"))
|
||||
__err__(ERROR_TRUNC_PHDR, _("Format error: program header table truncated"))
|
||||
__err__(ERROR_TRUNC_SHDR, _("Format error: section header table truncated"))
|
||||
__err__(ERROR_TRUNC_SCN, _("Format error: data region truncated"))
|
||||
__err__(ERROR_ALIGN_PHDR, _("Format error: program header table alignment"))
|
||||
__err__(ERROR_ALIGN_SHDR, _("Format error: section header table alignment"))
|
||||
__err__(ERROR_VERDEF_FORMAT, _("Format error: bad parameter in Verdef record"))
|
||||
__err__(ERROR_VERDEF_VERSION, _("Format error: unknown Verdef version"))
|
||||
__err__(ERROR_VERNEED_FORMAT, _("Format error: bad parameter in Verneed record"))
|
||||
__err__(ERROR_VERNEED_VERSION, _("Format error: unknown Verneed version"))
|
||||
__err__(ERROR_EHDR_SHNUM, _("Format error: bad e_shnum value"))
|
||||
__err__(ERROR_EHDR_SHENTSIZE, _("Format error: bad e_shentsize value"))
|
||||
__err__(ERROR_EHDR_PHENTSIZE, _("Format error: bad e_phentsize value"))
|
||||
__err__(ERROR_UNTERM, _("Format error: unterminated string in string table"))
|
||||
__err__(ERROR_SCN2SMALL, _("Layout error: section size too small for data"))
|
||||
__err__(ERROR_SCN_OVERLAP, _("Layout error: overlapping sections"))
|
||||
__err__(ERROR_MEM_ELF, _("Memory error: elf descriptor"))
|
||||
__err__(ERROR_MEM_ARSYMTAB, _("Memory error: archive symbol table"))
|
||||
__err__(ERROR_MEM_ARHDR, _("Memory error: archive member header"))
|
||||
__err__(ERROR_MEM_EHDR, _("Memory error: ELF header"))
|
||||
__err__(ERROR_MEM_PHDR, _("Memory error: program header table"))
|
||||
__err__(ERROR_MEM_SHDR, _("Memory error: section header table"))
|
||||
__err__(ERROR_MEM_SCN, _("Memory error: section descriptor"))
|
||||
__err__(ERROR_MEM_SCNDATA, _("Memory error: section data"))
|
||||
__err__(ERROR_MEM_OUTBUF, _("Memory error: output file space"))
|
||||
__err__(ERROR_MEM_TEMPORARY, _("Memory error: temporary buffer"))
|
||||
__err__(ERROR_BADVALUE, _("GElf error: value out of range"))
|
||||
__err__(ERROR_BADINDEX, _("GElf error: index out of range"))
|
||||
__err__(ERROR_BADTYPE, _("GElf error: type mismatch"))
|
||||
__err__(ERROR_MEM_SYM, _("GElf error: not enough memory for GElf_Sym"))
|
||||
__err__(ERROR_MEM_DYN, _("GElf error: not enough memory for GElf_Dyn"))
|
||||
__err__(ERROR_MEM_RELA, _("GElf error: not enough memory for GElf_Rela"))
|
||||
__err__(ERROR_MEM_REL, _("GElf error: not enough memory for GElf_Rel"))
|
||||
Vendored
+334
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
ext_types.h - external representation of ELF data types.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* @(#) $Id: ext_types.h,v 1.9 2008/05/23 08:15:34 michael Exp $ */
|
||||
|
||||
#ifndef _EXT_TYPES_H
|
||||
#define _EXT_TYPES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Scalar data types
|
||||
*/
|
||||
typedef unsigned char __ext_Elf32_Addr [ELF32_FSZ_ADDR];
|
||||
typedef unsigned char __ext_Elf32_Half [ELF32_FSZ_HALF];
|
||||
typedef unsigned char __ext_Elf32_Off [ELF32_FSZ_OFF];
|
||||
typedef unsigned char __ext_Elf32_Sword [ELF32_FSZ_SWORD];
|
||||
typedef unsigned char __ext_Elf32_Word [ELF32_FSZ_WORD];
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
typedef unsigned char __ext_Elf32_Lword [8];
|
||||
|
||||
typedef unsigned char __ext_Elf64_Addr [ELF64_FSZ_ADDR];
|
||||
typedef unsigned char __ext_Elf64_Half [ELF64_FSZ_HALF];
|
||||
typedef unsigned char __ext_Elf64_Off [ELF64_FSZ_OFF];
|
||||
typedef unsigned char __ext_Elf64_Sword [ELF64_FSZ_SWORD];
|
||||
typedef unsigned char __ext_Elf64_Word [ELF64_FSZ_WORD];
|
||||
typedef unsigned char __ext_Elf64_Sxword[ELF64_FSZ_SXWORD];
|
||||
typedef unsigned char __ext_Elf64_Xword [ELF64_FSZ_XWORD];
|
||||
|
||||
typedef unsigned char __ext_Elf64_Lword [8];
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* ELF header
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT];
|
||||
__ext_Elf32_Half e_type;
|
||||
__ext_Elf32_Half e_machine;
|
||||
__ext_Elf32_Word e_version;
|
||||
__ext_Elf32_Addr e_entry;
|
||||
__ext_Elf32_Off e_phoff;
|
||||
__ext_Elf32_Off e_shoff;
|
||||
__ext_Elf32_Word e_flags;
|
||||
__ext_Elf32_Half e_ehsize;
|
||||
__ext_Elf32_Half e_phentsize;
|
||||
__ext_Elf32_Half e_phnum;
|
||||
__ext_Elf32_Half e_shentsize;
|
||||
__ext_Elf32_Half e_shnum;
|
||||
__ext_Elf32_Half e_shstrndx;
|
||||
} __ext_Elf32_Ehdr;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT];
|
||||
__ext_Elf64_Half e_type;
|
||||
__ext_Elf64_Half e_machine;
|
||||
__ext_Elf64_Word e_version;
|
||||
__ext_Elf64_Addr e_entry;
|
||||
__ext_Elf64_Off e_phoff;
|
||||
__ext_Elf64_Off e_shoff;
|
||||
__ext_Elf64_Word e_flags;
|
||||
__ext_Elf64_Half e_ehsize;
|
||||
__ext_Elf64_Half e_phentsize;
|
||||
__ext_Elf64_Half e_phnum;
|
||||
__ext_Elf64_Half e_shentsize;
|
||||
__ext_Elf64_Half e_shnum;
|
||||
__ext_Elf64_Half e_shstrndx;
|
||||
} __ext_Elf64_Ehdr;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Section header
|
||||
*/
|
||||
typedef struct {
|
||||
__ext_Elf32_Word sh_name;
|
||||
__ext_Elf32_Word sh_type;
|
||||
__ext_Elf32_Word sh_flags;
|
||||
__ext_Elf32_Addr sh_addr;
|
||||
__ext_Elf32_Off sh_offset;
|
||||
__ext_Elf32_Word sh_size;
|
||||
__ext_Elf32_Word sh_link;
|
||||
__ext_Elf32_Word sh_info;
|
||||
__ext_Elf32_Word sh_addralign;
|
||||
__ext_Elf32_Word sh_entsize;
|
||||
} __ext_Elf32_Shdr;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
__ext_Elf64_Word sh_name;
|
||||
__ext_Elf64_Word sh_type;
|
||||
__ext_Elf64_Xword sh_flags;
|
||||
__ext_Elf64_Addr sh_addr;
|
||||
__ext_Elf64_Off sh_offset;
|
||||
__ext_Elf64_Xword sh_size;
|
||||
__ext_Elf64_Word sh_link;
|
||||
__ext_Elf64_Word sh_info;
|
||||
__ext_Elf64_Xword sh_addralign;
|
||||
__ext_Elf64_Xword sh_entsize;
|
||||
} __ext_Elf64_Shdr;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Symbol table
|
||||
*/
|
||||
typedef struct {
|
||||
__ext_Elf32_Word st_name;
|
||||
__ext_Elf32_Addr st_value;
|
||||
__ext_Elf32_Word st_size;
|
||||
unsigned char st_info;
|
||||
unsigned char st_other;
|
||||
__ext_Elf32_Half st_shndx;
|
||||
} __ext_Elf32_Sym;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
__ext_Elf64_Word st_name;
|
||||
unsigned char st_info;
|
||||
unsigned char st_other;
|
||||
__ext_Elf64_Half st_shndx;
|
||||
__ext_Elf64_Addr st_value;
|
||||
__ext_Elf64_Xword st_size;
|
||||
} __ext_Elf64_Sym;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Relocation
|
||||
*/
|
||||
typedef struct {
|
||||
__ext_Elf32_Addr r_offset;
|
||||
__ext_Elf32_Word r_info;
|
||||
} __ext_Elf32_Rel;
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf32_Addr r_offset;
|
||||
__ext_Elf32_Word r_info;
|
||||
__ext_Elf32_Sword r_addend;
|
||||
} __ext_Elf32_Rela;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
__ext_Elf64_Addr r_offset;
|
||||
#if __LIBELF64_IRIX
|
||||
__ext_Elf64_Word r_sym;
|
||||
unsigned char r_ssym;
|
||||
unsigned char r_type3;
|
||||
unsigned char r_type2;
|
||||
unsigned char r_type;
|
||||
#else /* __LIBELF64_IRIX */
|
||||
__ext_Elf64_Xword r_info;
|
||||
#endif /* __LIBELF64_IRIX */
|
||||
} __ext_Elf64_Rel;
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf64_Addr r_offset;
|
||||
#if __LIBELF64_IRIX
|
||||
__ext_Elf64_Word r_sym;
|
||||
unsigned char r_ssym;
|
||||
unsigned char r_type3;
|
||||
unsigned char r_type2;
|
||||
unsigned char r_type;
|
||||
#else /* __LIBELF64_IRIX */
|
||||
__ext_Elf64_Xword r_info;
|
||||
#endif /* __LIBELF64_IRIX */
|
||||
__ext_Elf64_Sxword r_addend;
|
||||
} __ext_Elf64_Rela;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Program header
|
||||
*/
|
||||
typedef struct {
|
||||
__ext_Elf32_Word p_type;
|
||||
__ext_Elf32_Off p_offset;
|
||||
__ext_Elf32_Addr p_vaddr;
|
||||
__ext_Elf32_Addr p_paddr;
|
||||
__ext_Elf32_Word p_filesz;
|
||||
__ext_Elf32_Word p_memsz;
|
||||
__ext_Elf32_Word p_flags;
|
||||
__ext_Elf32_Word p_align;
|
||||
} __ext_Elf32_Phdr;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
__ext_Elf64_Word p_type;
|
||||
__ext_Elf64_Word p_flags;
|
||||
__ext_Elf64_Off p_offset;
|
||||
__ext_Elf64_Addr p_vaddr;
|
||||
__ext_Elf64_Addr p_paddr;
|
||||
__ext_Elf64_Xword p_filesz;
|
||||
__ext_Elf64_Xword p_memsz;
|
||||
__ext_Elf64_Xword p_align;
|
||||
} __ext_Elf64_Phdr;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Dynamic structure
|
||||
*/
|
||||
typedef struct {
|
||||
__ext_Elf32_Sword d_tag;
|
||||
union {
|
||||
__ext_Elf32_Word d_val;
|
||||
__ext_Elf32_Addr d_ptr;
|
||||
} d_un;
|
||||
} __ext_Elf32_Dyn;
|
||||
|
||||
#if __LIBELF64
|
||||
typedef struct {
|
||||
__ext_Elf64_Sxword d_tag;
|
||||
union {
|
||||
__ext_Elf64_Xword d_val;
|
||||
__ext_Elf64_Addr d_ptr;
|
||||
} d_un;
|
||||
} __ext_Elf64_Dyn;
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Version definitions
|
||||
*/
|
||||
typedef struct {
|
||||
__ext_Elf32_Half vd_version;
|
||||
__ext_Elf32_Half vd_flags;
|
||||
__ext_Elf32_Half vd_ndx;
|
||||
__ext_Elf32_Half vd_cnt;
|
||||
__ext_Elf32_Word vd_hash;
|
||||
__ext_Elf32_Word vd_aux;
|
||||
__ext_Elf32_Word vd_next;
|
||||
} __ext_Elf32_Verdef;
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf32_Word vda_name;
|
||||
__ext_Elf32_Word vda_next;
|
||||
} __ext_Elf32_Verdaux;
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf32_Half vn_version;
|
||||
__ext_Elf32_Half vn_cnt;
|
||||
__ext_Elf32_Word vn_file;
|
||||
__ext_Elf32_Word vn_aux;
|
||||
__ext_Elf32_Word vn_next;
|
||||
} __ext_Elf32_Verneed;
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf32_Word vna_hash;
|
||||
__ext_Elf32_Half vna_flags;
|
||||
__ext_Elf32_Half vna_other;
|
||||
__ext_Elf32_Word vna_name;
|
||||
__ext_Elf32_Word vna_next;
|
||||
} __ext_Elf32_Vernaux;
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf64_Half vd_version;
|
||||
__ext_Elf64_Half vd_flags;
|
||||
__ext_Elf64_Half vd_ndx;
|
||||
__ext_Elf64_Half vd_cnt;
|
||||
__ext_Elf64_Word vd_hash;
|
||||
__ext_Elf64_Word vd_aux;
|
||||
__ext_Elf64_Word vd_next;
|
||||
} __ext_Elf64_Verdef;
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf64_Word vda_name;
|
||||
__ext_Elf64_Word vda_next;
|
||||
} __ext_Elf64_Verdaux;
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf64_Half vn_version;
|
||||
__ext_Elf64_Half vn_cnt;
|
||||
__ext_Elf64_Word vn_file;
|
||||
__ext_Elf64_Word vn_aux;
|
||||
__ext_Elf64_Word vn_next;
|
||||
} __ext_Elf64_Verneed;
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf64_Word vna_hash;
|
||||
__ext_Elf64_Half vna_flags;
|
||||
__ext_Elf64_Half vna_other;
|
||||
__ext_Elf64_Word vna_name;
|
||||
__ext_Elf64_Word vna_next;
|
||||
} __ext_Elf64_Vernaux;
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
/*
|
||||
* Move section
|
||||
*/
|
||||
#if __LIBELF64
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf32_Lword m_value;
|
||||
__ext_Elf32_Word m_info;
|
||||
__ext_Elf32_Word m_poffset;
|
||||
__ext_Elf32_Half m_repeat;
|
||||
__ext_Elf32_Half m_stride;
|
||||
} __ext_Elf32_Move;
|
||||
|
||||
typedef struct {
|
||||
__ext_Elf64_Lword m_value;
|
||||
__ext_Elf64_Xword m_info;
|
||||
__ext_Elf64_Xword m_poffset;
|
||||
__ext_Elf64_Half m_repeat;
|
||||
__ext_Elf64_Half m_stride;
|
||||
} __ext_Elf64_Move;
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _EXT_TYPES_H */
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
fill.c - implementation of the elf_fill(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: fill.c,v 1.7 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
void
|
||||
elf_fill(int fill) {
|
||||
_elf_fill = fill;
|
||||
}
|
||||
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
flag.c - implementation of the elf_flag*(3) functions.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: flag.c,v 1.7 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
static unsigned
|
||||
_elf_flag(unsigned *f, Elf_Cmd cmd, unsigned flags) {
|
||||
if (cmd == ELF_C_SET) {
|
||||
return *f |= flags;
|
||||
}
|
||||
if (cmd == ELF_C_CLR) {
|
||||
return *f &= ~flags;
|
||||
}
|
||||
seterr(ERROR_INVALID_CMD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned
|
||||
elf_flagdata(Elf_Data *data, Elf_Cmd cmd, unsigned flags) {
|
||||
Scn_Data *sd = (Scn_Data*)data;
|
||||
|
||||
if (!sd) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(sd->sd_magic == DATA_MAGIC);
|
||||
return _elf_flag(&sd->sd_data_flags, cmd, flags);
|
||||
}
|
||||
|
||||
unsigned
|
||||
elf_flagehdr(Elf *elf, Elf_Cmd cmd, unsigned flags) {
|
||||
if (!elf) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
return _elf_flag(&elf->e_ehdr_flags, cmd, flags);
|
||||
}
|
||||
|
||||
unsigned
|
||||
elf_flagelf(Elf *elf, Elf_Cmd cmd, unsigned flags) {
|
||||
if (!elf) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
return _elf_flag(&elf->e_elf_flags, cmd, flags);
|
||||
}
|
||||
|
||||
unsigned
|
||||
elf_flagphdr(Elf *elf, Elf_Cmd cmd, unsigned flags) {
|
||||
if (!elf) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
return _elf_flag(&elf->e_phdr_flags, cmd, flags);
|
||||
}
|
||||
|
||||
unsigned
|
||||
elf_flagscn(Elf_Scn *scn, Elf_Cmd cmd, unsigned flags) {
|
||||
if (!scn) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
return _elf_flag(&scn->s_scn_flags, cmd, flags);
|
||||
}
|
||||
|
||||
unsigned
|
||||
elf_flagshdr(Elf_Scn *scn, Elf_Cmd cmd, unsigned flags) {
|
||||
if (!scn) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
return _elf_flag(&scn->s_shdr_flags, cmd, flags);
|
||||
}
|
||||
Vendored
+155
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* gelf.h - public header file for libelf.
|
||||
* Copyright (C) 2000 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* @(#) $Id: gelf.h,v 1.16 2008/05/23 08:15:34 michael Exp $ */
|
||||
|
||||
#ifndef _GELF_H
|
||||
#define _GELF_H
|
||||
|
||||
#if __LIBELF_INTERNAL__
|
||||
#include <libelf.h>
|
||||
#else /* __LIBELF_INTERNAL__ */
|
||||
#include <libelf/libelf.h>
|
||||
#endif /* __LIBELF_INTERNAL__ */
|
||||
|
||||
#if __LIBELF_NEED_LINK_H
|
||||
#include <link.h>
|
||||
#elif __LIBELF_NEED_SYS_LINK_H
|
||||
#include <sys/link.h>
|
||||
#endif /* __LIBELF_NEED_LINK_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef __P
|
||||
# if (__STDC__ + 0) || defined(__cplusplus) || defined(_WIN32)
|
||||
# define __P(args) args
|
||||
# else /* __STDC__ || defined(__cplusplus) */
|
||||
# define __P(args) ()
|
||||
# endif /* __STDC__ || defined(__cplusplus) */
|
||||
#endif /* __P */
|
||||
|
||||
#if !__LIBELF64
|
||||
|
||||
#error "GElf is not supported on this system."
|
||||
|
||||
#else /* __LIBELF64 */
|
||||
|
||||
typedef Elf64_Addr GElf_Addr;
|
||||
typedef Elf64_Half GElf_Half;
|
||||
typedef Elf64_Off GElf_Off;
|
||||
typedef Elf64_Sword GElf_Sword;
|
||||
typedef Elf64_Word GElf_Word;
|
||||
typedef Elf64_Sxword GElf_Sxword;
|
||||
typedef Elf64_Xword GElf_Xword;
|
||||
|
||||
typedef Elf64_Ehdr GElf_Ehdr;
|
||||
typedef Elf64_Phdr GElf_Phdr;
|
||||
typedef Elf64_Shdr GElf_Shdr;
|
||||
typedef Elf64_Dyn GElf_Dyn;
|
||||
typedef Elf64_Rel GElf_Rel;
|
||||
typedef Elf64_Rela GElf_Rela;
|
||||
typedef Elf64_Sym GElf_Sym;
|
||||
|
||||
/*
|
||||
* Symbol versioning
|
||||
*/
|
||||
#if __LIBELF_SYMBOL_VERSIONS
|
||||
typedef Elf64_Verdef GElf_Verdef;
|
||||
typedef Elf64_Verneed GElf_Verneed;
|
||||
typedef Elf64_Verdaux GElf_Verdaux;
|
||||
typedef Elf64_Vernaux GElf_Vernaux;
|
||||
#endif /* __LIBELF_SYMBOL_VERSIONS */
|
||||
|
||||
/*
|
||||
* These types aren't implemented (yet)
|
||||
*
|
||||
typedef Elf64_Move GElf_Move;
|
||||
typedef Elf64_Syminfo GElf_Syminfo;
|
||||
*/
|
||||
|
||||
/*
|
||||
* Generic macros
|
||||
*/
|
||||
#define GELF_ST_BIND ELF64_ST_BIND
|
||||
#define GELF_ST_TYPE ELF64_ST_TYPE
|
||||
#define GELF_ST_INFO ELF64_ST_INFO
|
||||
|
||||
#define GELF_R_TYPE ELF64_R_TYPE
|
||||
#define GELF_R_SYM ELF64_R_SYM
|
||||
#define GELF_R_INFO ELF64_R_INFO
|
||||
|
||||
/*
|
||||
* Function declarations
|
||||
*/
|
||||
extern int gelf_getclass __P((Elf *__elf));
|
||||
|
||||
extern size_t gelf_fsize __P((Elf *__elf, Elf_Type __type, size_t __count, unsigned __ver));
|
||||
|
||||
extern Elf_Data *gelf_xlatetof __P((Elf *__elf, Elf_Data *__dst, const Elf_Data *__src, unsigned __encode));
|
||||
extern Elf_Data *gelf_xlatetom __P((Elf *__elf, Elf_Data *__dst, const Elf_Data *__src, unsigned __encode));
|
||||
|
||||
extern GElf_Ehdr *gelf_getehdr __P((Elf *__elf, GElf_Ehdr *__dst));
|
||||
extern int gelf_update_ehdr __P((Elf *__elf, GElf_Ehdr *__src));
|
||||
extern unsigned long gelf_newehdr __P((Elf *__elf, int __elfclass));
|
||||
|
||||
extern GElf_Phdr *gelf_getphdr __P((Elf *__elf, int ndx, GElf_Phdr *__dst));
|
||||
extern int gelf_update_phdr __P((Elf *__elf, int ndx, GElf_Phdr *__src));
|
||||
extern unsigned long gelf_newphdr __P((Elf *__elf, size_t __phnum));
|
||||
|
||||
extern GElf_Shdr *gelf_getshdr __P((Elf_Scn *__scn, GElf_Shdr *__dst));
|
||||
extern int gelf_update_shdr __P((Elf_Scn *__scn, GElf_Shdr *__src));
|
||||
|
||||
extern GElf_Dyn *gelf_getdyn __P((Elf_Data *__src, int __ndx, GElf_Dyn *__dst));
|
||||
extern int gelf_update_dyn __P((Elf_Data *__dst, int __ndx, GElf_Dyn *__src));
|
||||
|
||||
extern GElf_Rel *gelf_getrel __P((Elf_Data *__src, int __ndx, GElf_Rel *__dst));
|
||||
extern int gelf_update_rel __P((Elf_Data *__dst, int __ndx, GElf_Rel *__src));
|
||||
|
||||
extern GElf_Rela *gelf_getrela __P((Elf_Data *__src, int __ndx, GElf_Rela *__dst));
|
||||
extern int gelf_update_rela __P((Elf_Data *__dst, int __ndx, GElf_Rela *__src));
|
||||
|
||||
extern GElf_Sym *gelf_getsym __P((Elf_Data *__src, int __ndx, GElf_Sym *__dst));
|
||||
extern int gelf_update_sym __P((Elf_Data *__dst, int __ndx, GElf_Sym *__src));
|
||||
|
||||
extern long gelf_checksum __P((Elf *__elf));
|
||||
|
||||
/*
|
||||
* These functions aren't implemented (yet)
|
||||
*
|
||||
extern GElf_Move *gelf_getmove __P((Elf_Data *__src, int __ndx, GElf_Move *__src));
|
||||
extern int gelf_update_move __P((Elf_Data *__dst, int __ndx, GElf_Move *__src));
|
||||
*
|
||||
extern GElf_Syminfo* gelf_getsyminfo __P((Elf_Data *__src, int __ndx, GElf_Syminfo *__dst));
|
||||
extern int gelf_update_syminfo __P((Elf_Data *__dst, int __ndx, GElf_Syminfo *__src));
|
||||
*/
|
||||
|
||||
/*
|
||||
* Extensions (not available in other versions of libelf)
|
||||
*/
|
||||
extern size_t gelf_msize __P((Elf *__elf, Elf_Type __type, size_t __count, unsigned __ver));
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _GELF_H */
|
||||
Vendored
+140
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* gelfehdr.c - gelf_* translation functions.
|
||||
* Copyright (C) 2000 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: gelfehdr.c,v 1.9 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#define check_and_copy(type, d, s, name, eret) \
|
||||
do { \
|
||||
if (sizeof((d)->name) < sizeof((s)->name) \
|
||||
&& (type)(s)->name != (s)->name) { \
|
||||
seterr(ERROR_BADVALUE); \
|
||||
return (eret); \
|
||||
} \
|
||||
(d)->name = (type)(s)->name; \
|
||||
} while (0)
|
||||
|
||||
GElf_Ehdr*
|
||||
gelf_getehdr(Elf *elf, GElf_Ehdr *dst) {
|
||||
GElf_Ehdr buf;
|
||||
char *tmp;
|
||||
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
tmp = _elf_getehdr(elf, elf->e_class);
|
||||
if (!tmp) {
|
||||
return NULL;
|
||||
}
|
||||
if (!dst) {
|
||||
dst = &buf;
|
||||
}
|
||||
if (elf->e_class == ELFCLASS64) {
|
||||
*dst = *(Elf64_Ehdr*)tmp;
|
||||
}
|
||||
else if (elf->e_class == ELFCLASS32) {
|
||||
Elf32_Ehdr *src = (Elf32_Ehdr*)tmp;
|
||||
|
||||
memcpy(dst->e_ident, src->e_ident, EI_NIDENT);
|
||||
check_and_copy(GElf_Half, dst, src, e_type, NULL);
|
||||
check_and_copy(GElf_Half, dst, src, e_machine, NULL);
|
||||
check_and_copy(GElf_Word, dst, src, e_version, NULL);
|
||||
check_and_copy(GElf_Addr, dst, src, e_entry, NULL);
|
||||
check_and_copy(GElf_Off, dst, src, e_phoff, NULL);
|
||||
check_and_copy(GElf_Off, dst, src, e_shoff, NULL);
|
||||
check_and_copy(GElf_Word, dst, src, e_flags, NULL);
|
||||
check_and_copy(GElf_Half, dst, src, e_ehsize, NULL);
|
||||
check_and_copy(GElf_Half, dst, src, e_phentsize, NULL);
|
||||
check_and_copy(GElf_Half, dst, src, e_phnum, NULL);
|
||||
check_and_copy(GElf_Half, dst, src, e_shentsize, NULL);
|
||||
check_and_copy(GElf_Half, dst, src, e_shnum, NULL);
|
||||
check_and_copy(GElf_Half, dst, src, e_shstrndx, NULL);
|
||||
}
|
||||
else {
|
||||
if (valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (dst == &buf) {
|
||||
dst = (GElf_Ehdr*)malloc(sizeof(GElf_Ehdr));
|
||||
if (!dst) {
|
||||
seterr(ERROR_MEM_EHDR);
|
||||
return NULL;
|
||||
}
|
||||
*dst = buf;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
int
|
||||
gelf_update_ehdr(Elf *elf, GElf_Ehdr *src) {
|
||||
char *tmp;
|
||||
|
||||
if (!elf || !src) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
tmp = _elf_getehdr(elf, elf->e_class);
|
||||
if (!tmp) {
|
||||
return 0;
|
||||
}
|
||||
if (elf->e_class == ELFCLASS64) {
|
||||
*(Elf64_Ehdr*)tmp = *src;
|
||||
}
|
||||
else if (elf->e_class == ELFCLASS32) {
|
||||
Elf32_Ehdr *dst = (Elf32_Ehdr*)tmp;
|
||||
|
||||
memcpy(dst->e_ident, src->e_ident, EI_NIDENT);
|
||||
check_and_copy(Elf32_Half, dst, src, e_type, 0);
|
||||
check_and_copy(Elf32_Half, dst, src, e_machine, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, e_version, 0);
|
||||
check_and_copy(Elf32_Addr, dst, src, e_entry, 0);
|
||||
check_and_copy(Elf32_Off, dst, src, e_phoff, 0);
|
||||
check_and_copy(Elf32_Off, dst, src, e_shoff, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, e_flags, 0);
|
||||
check_and_copy(Elf32_Half, dst, src, e_ehsize, 0);
|
||||
check_and_copy(Elf32_Half, dst, src, e_phentsize, 0);
|
||||
check_and_copy(Elf32_Half, dst, src, e_phnum, 0);
|
||||
check_and_copy(Elf32_Half, dst, src, e_shentsize, 0);
|
||||
check_and_copy(Elf32_Half, dst, src, e_shnum, 0);
|
||||
check_and_copy(Elf32_Half, dst, src, e_shstrndx, 0);
|
||||
}
|
||||
else {
|
||||
if (valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+148
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* gelfphdr.c - gelf_* translation functions.
|
||||
* Copyright (C) 2000 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: gelfphdr.c,v 1.9 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#define check_and_copy(type, d, s, name, eret) \
|
||||
do { \
|
||||
if (sizeof((d)->name) < sizeof((s)->name) \
|
||||
&& (type)(s)->name != (s)->name) { \
|
||||
seterr(ERROR_BADVALUE); \
|
||||
return (eret); \
|
||||
} \
|
||||
(d)->name = (type)(s)->name; \
|
||||
} while (0)
|
||||
|
||||
GElf_Phdr*
|
||||
gelf_getphdr(Elf *elf, int ndx, GElf_Phdr *dst) {
|
||||
GElf_Phdr buf;
|
||||
char *tmp;
|
||||
size_t n;
|
||||
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
tmp = _elf_getphdr(elf, elf->e_class);
|
||||
if (!tmp) {
|
||||
return NULL;
|
||||
}
|
||||
if (ndx < 0 || ndx >= elf->e_phnum) {
|
||||
seterr(ERROR_BADINDEX);
|
||||
return NULL;
|
||||
}
|
||||
n = _msize(elf->e_class, _elf_version, ELF_T_PHDR);
|
||||
if (n == 0) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
if (!dst) {
|
||||
dst = &buf;
|
||||
}
|
||||
if (elf->e_class == ELFCLASS64) {
|
||||
*dst = *(Elf64_Phdr*)(tmp + ndx * n);
|
||||
}
|
||||
else if (elf->e_class == ELFCLASS32) {
|
||||
Elf32_Phdr *src = (Elf32_Phdr*)(tmp + ndx * n);
|
||||
|
||||
check_and_copy(GElf_Word, dst, src, p_type, NULL);
|
||||
check_and_copy(GElf_Word, dst, src, p_flags, NULL);
|
||||
check_and_copy(GElf_Off, dst, src, p_offset, NULL);
|
||||
check_and_copy(GElf_Addr, dst, src, p_vaddr, NULL);
|
||||
check_and_copy(GElf_Addr, dst, src, p_paddr, NULL);
|
||||
check_and_copy(GElf_Xword, dst, src, p_filesz, NULL);
|
||||
check_and_copy(GElf_Xword, dst, src, p_memsz, NULL);
|
||||
check_and_copy(GElf_Xword, dst, src, p_align, NULL);
|
||||
}
|
||||
else {
|
||||
if (valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (dst == &buf) {
|
||||
dst = (GElf_Phdr*)malloc(sizeof(GElf_Phdr));
|
||||
if (!dst) {
|
||||
seterr(ERROR_MEM_PHDR);
|
||||
return NULL;
|
||||
}
|
||||
*dst = buf;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
int
|
||||
gelf_update_phdr(Elf *elf, int ndx, GElf_Phdr *src) {
|
||||
char *tmp;
|
||||
size_t n;
|
||||
|
||||
if (!elf || !src) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
tmp = _elf_getphdr(elf, elf->e_class);
|
||||
if (!tmp) {
|
||||
return 0;
|
||||
}
|
||||
if (ndx < 0 || ndx >= elf->e_phnum) {
|
||||
seterr(ERROR_BADINDEX);
|
||||
return 0;
|
||||
}
|
||||
n = _msize(elf->e_class, _elf_version, ELF_T_PHDR);
|
||||
if (n == 0) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
if (elf->e_class == ELFCLASS64) {
|
||||
*(Elf64_Phdr*)(tmp + ndx * n) = *src;
|
||||
}
|
||||
else if (elf->e_class == ELFCLASS32) {
|
||||
Elf32_Phdr *dst = (Elf32_Phdr*)(tmp + ndx * n);
|
||||
|
||||
check_and_copy(Elf32_Word, dst, src, p_type, 0);
|
||||
check_and_copy(Elf32_Off, dst, src, p_offset, 0);
|
||||
check_and_copy(Elf32_Addr, dst, src, p_vaddr, 0);
|
||||
check_and_copy(Elf32_Addr, dst, src, p_paddr, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, p_filesz, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, p_memsz, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, p_flags, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, p_align, 0);
|
||||
}
|
||||
else {
|
||||
if (valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+125
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* gelfshdr.c - gelf_* translation functions.
|
||||
* Copyright (C) 2000 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: gelfshdr.c,v 1.10 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#define check_and_copy(type, d, s, name, eret) \
|
||||
do { \
|
||||
if (sizeof((d)->name) < sizeof((s)->name) \
|
||||
&& (type)(s)->name != (s)->name) { \
|
||||
seterr(ERROR_BADVALUE); \
|
||||
return (eret); \
|
||||
} \
|
||||
(d)->name = (type)(s)->name; \
|
||||
} while (0)
|
||||
|
||||
GElf_Shdr*
|
||||
gelf_getshdr(Elf_Scn *scn, GElf_Shdr *dst) {
|
||||
GElf_Shdr buf;
|
||||
|
||||
if (!scn) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
elf_assert(scn->s_elf);
|
||||
elf_assert(scn->s_elf->e_magic == ELF_MAGIC);
|
||||
if (!dst) {
|
||||
dst = &buf;
|
||||
}
|
||||
if (scn->s_elf->e_class == ELFCLASS64) {
|
||||
*dst = scn->s_shdr64;
|
||||
}
|
||||
else if (scn->s_elf->e_class == ELFCLASS32) {
|
||||
Elf32_Shdr *src = &scn->s_shdr32;
|
||||
|
||||
check_and_copy(GElf_Word, dst, src, sh_name, NULL);
|
||||
check_and_copy(GElf_Word, dst, src, sh_type, NULL);
|
||||
check_and_copy(GElf_Xword, dst, src, sh_flags, NULL);
|
||||
check_and_copy(GElf_Addr, dst, src, sh_addr, NULL);
|
||||
check_and_copy(GElf_Off, dst, src, sh_offset, NULL);
|
||||
check_and_copy(GElf_Xword, dst, src, sh_size, NULL);
|
||||
check_and_copy(GElf_Word, dst, src, sh_link, NULL);
|
||||
check_and_copy(GElf_Word, dst, src, sh_info, NULL);
|
||||
check_and_copy(GElf_Xword, dst, src, sh_addralign, NULL);
|
||||
check_and_copy(GElf_Xword, dst, src, sh_entsize, NULL);
|
||||
}
|
||||
else {
|
||||
if (valid_class(scn->s_elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (dst == &buf) {
|
||||
dst = (GElf_Shdr*)malloc(sizeof(GElf_Shdr));
|
||||
if (!dst) {
|
||||
seterr(ERROR_MEM_SHDR);
|
||||
return NULL;
|
||||
}
|
||||
*dst = buf;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
int
|
||||
gelf_update_shdr(Elf_Scn *scn, GElf_Shdr *src) {
|
||||
if (!scn || !src) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
elf_assert(scn->s_elf);
|
||||
elf_assert(scn->s_elf->e_magic == ELF_MAGIC);
|
||||
if (scn->s_elf->e_class == ELFCLASS64) {
|
||||
scn->s_shdr64 = *src;
|
||||
}
|
||||
else if (scn->s_elf->e_class == ELFCLASS32) {
|
||||
Elf32_Shdr *dst = &scn->s_shdr32;
|
||||
|
||||
check_and_copy(Elf32_Word, dst, src, sh_name, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, sh_type, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, sh_flags, 0);
|
||||
check_and_copy(Elf32_Addr, dst, src, sh_addr, 0);
|
||||
check_and_copy(Elf32_Off, dst, src, sh_offset, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, sh_size, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, sh_link, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, sh_info, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, sh_addralign, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, sh_entsize, 0);
|
||||
}
|
||||
else {
|
||||
if (valid_class(scn->s_elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+407
@@ -0,0 +1,407 @@
|
||||
/*
|
||||
gelftrans.c - gelf_* translation functions.
|
||||
Copyright (C) 2000 - 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: gelftrans.c,v 1.10 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#define check_and_copy(type, d, s, name, eret) \
|
||||
do { \
|
||||
if (sizeof((d)->name) < sizeof((s)->name) \
|
||||
&& (type)(s)->name != (s)->name) { \
|
||||
seterr(ERROR_BADVALUE); \
|
||||
return (eret); \
|
||||
} \
|
||||
(d)->name = (type)(s)->name; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* These macros are missing on some Linux systems
|
||||
*/
|
||||
#if !defined(ELF32_R_SYM) || !defined(ELF32_R_TYPE) || !defined(ELF32_R_INFO)
|
||||
# undef ELF32_R_SYM
|
||||
# undef ELF32_R_TYPE
|
||||
# undef ELF32_R_INFO
|
||||
# define ELF32_R_SYM(i) ((i)>>8)
|
||||
# define ELF32_R_TYPE(i) ((unsigned char)(i))
|
||||
# define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t))
|
||||
#endif /* !defined(...) */
|
||||
|
||||
#if !defined(ELF64_R_SYM) || !defined(ELF64_R_TYPE) || !defined(ELF64_R_INFO)
|
||||
# undef ELF64_R_SYM
|
||||
# undef ELF64_R_TYPE
|
||||
# undef ELF64_R_INFO
|
||||
# define ELF64_R_SYM(i) ((i)>>32)
|
||||
# define ELF64_R_TYPE(i) ((i)&0xffffffffL)
|
||||
# define ELF64_R_INFO(s,t) (((Elf64_Xword)(s)<<32)+((t)&0xffffffffL))
|
||||
#endif /* !defined(...) */
|
||||
|
||||
static char*
|
||||
get_addr_and_class(const Elf_Data *data, int ndx, Elf_Type type, unsigned *cls) {
|
||||
Scn_Data *sd = (Scn_Data*)data;
|
||||
Elf_Scn *scn;
|
||||
Elf *elf;
|
||||
size_t n;
|
||||
|
||||
if (!sd) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(sd->sd_magic == DATA_MAGIC);
|
||||
scn = sd->sd_scn;
|
||||
elf_assert(scn);
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
elf = scn->s_elf;
|
||||
elf_assert(elf);
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
return NULL;
|
||||
}
|
||||
if (!valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
return NULL;
|
||||
}
|
||||
if (data->d_type != type) {
|
||||
seterr(ERROR_BADTYPE);
|
||||
return NULL;
|
||||
}
|
||||
n = _msize(elf->e_class, data->d_version, type);
|
||||
if (n == 0) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
if (ndx < 0 || data->d_size < (ndx + 1) * n) {
|
||||
seterr(ERROR_BADINDEX);
|
||||
return NULL;
|
||||
}
|
||||
if (!data->d_buf) {
|
||||
seterr(ERROR_NULLBUF);
|
||||
return NULL;
|
||||
}
|
||||
if (cls) {
|
||||
*cls = elf->e_class;
|
||||
}
|
||||
return (char*)data->d_buf + n * ndx;
|
||||
}
|
||||
|
||||
GElf_Sym*
|
||||
gelf_getsym(Elf_Data *src, int ndx, GElf_Sym *dst) {
|
||||
GElf_Sym buf;
|
||||
unsigned cls;
|
||||
char *tmp;
|
||||
|
||||
if (!dst) {
|
||||
dst = &buf;
|
||||
}
|
||||
tmp = get_addr_and_class(src, ndx, ELF_T_SYM, &cls);
|
||||
if (!tmp) {
|
||||
return NULL;
|
||||
}
|
||||
if (cls == ELFCLASS64) {
|
||||
*dst = *(Elf64_Sym*)tmp;
|
||||
}
|
||||
else if (cls == ELFCLASS32) {
|
||||
Elf32_Sym *src = (Elf32_Sym*)tmp;
|
||||
|
||||
check_and_copy(GElf_Word, dst, src, st_name, NULL);
|
||||
check_and_copy(unsigned char, dst, src, st_info, NULL);
|
||||
check_and_copy(unsigned char, dst, src, st_other, NULL);
|
||||
check_and_copy(GElf_Half, dst, src, st_shndx, NULL);
|
||||
check_and_copy(GElf_Addr, dst, src, st_value, NULL);
|
||||
check_and_copy(GElf_Xword, dst, src, st_size, NULL);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
if (dst == &buf) {
|
||||
dst = (GElf_Sym*)malloc(sizeof(GElf_Sym));
|
||||
if (!dst) {
|
||||
seterr(ERROR_MEM_SYM);
|
||||
return NULL;
|
||||
}
|
||||
*dst = buf;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
int
|
||||
gelf_update_sym(Elf_Data *dst, int ndx, GElf_Sym *src) {
|
||||
unsigned cls;
|
||||
char *tmp;
|
||||
|
||||
tmp = get_addr_and_class(dst, ndx, ELF_T_SYM, &cls);
|
||||
if (!tmp) {
|
||||
return 0;
|
||||
}
|
||||
if (cls == ELFCLASS64) {
|
||||
*(Elf64_Sym*)tmp = *src;
|
||||
}
|
||||
else if (cls == ELFCLASS32) {
|
||||
Elf32_Sym *dst = (Elf32_Sym*)tmp;
|
||||
|
||||
check_and_copy(Elf32_Word, dst, src, st_name, 0);
|
||||
check_and_copy(Elf32_Addr, dst, src, st_value, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, st_size, 0);
|
||||
check_and_copy(unsigned char, dst, src, st_info, 0);
|
||||
check_and_copy(unsigned char, dst, src, st_other, 0);
|
||||
check_and_copy(Elf32_Half, dst, src, st_shndx, 0);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
GElf_Dyn*
|
||||
gelf_getdyn(Elf_Data *src, int ndx, GElf_Dyn *dst) {
|
||||
GElf_Dyn buf;
|
||||
unsigned cls;
|
||||
char *tmp;
|
||||
|
||||
if (!dst) {
|
||||
dst = &buf;
|
||||
}
|
||||
tmp = get_addr_and_class(src, ndx, ELF_T_DYN, &cls);
|
||||
if (!tmp) {
|
||||
return NULL;
|
||||
}
|
||||
if (cls == ELFCLASS64) {
|
||||
*dst = *(Elf64_Dyn*)tmp;
|
||||
}
|
||||
else if (cls == ELFCLASS32) {
|
||||
Elf32_Dyn *src = (Elf32_Dyn*)tmp;
|
||||
|
||||
check_and_copy(GElf_Sxword, dst, src, d_tag, NULL);
|
||||
check_and_copy(GElf_Xword, dst, src, d_un.d_val, NULL);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
if (dst == &buf) {
|
||||
dst = (GElf_Dyn*)malloc(sizeof(GElf_Dyn));
|
||||
if (!dst) {
|
||||
seterr(ERROR_MEM_DYN);
|
||||
return NULL;
|
||||
}
|
||||
*dst = buf;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
int
|
||||
gelf_update_dyn(Elf_Data *dst, int ndx, GElf_Dyn *src) {
|
||||
unsigned cls;
|
||||
char *tmp;
|
||||
|
||||
tmp = get_addr_and_class(dst, ndx, ELF_T_DYN, &cls);
|
||||
if (!tmp) {
|
||||
return 0;
|
||||
}
|
||||
if (cls == ELFCLASS64) {
|
||||
*(Elf64_Dyn*)tmp = *src;
|
||||
}
|
||||
else if (cls == ELFCLASS32) {
|
||||
Elf32_Dyn *dst = (Elf32_Dyn*)tmp;
|
||||
|
||||
check_and_copy(Elf32_Sword, dst, src, d_tag, 0);
|
||||
check_and_copy(Elf32_Word, dst, src, d_un.d_val, 0);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
GElf_Rela*
|
||||
gelf_getrela(Elf_Data *src, int ndx, GElf_Rela *dst) {
|
||||
GElf_Rela buf;
|
||||
unsigned cls;
|
||||
char *tmp;
|
||||
|
||||
if (!dst) {
|
||||
dst = &buf;
|
||||
}
|
||||
tmp = get_addr_and_class(src, ndx, ELF_T_RELA, &cls);
|
||||
if (!tmp) {
|
||||
return NULL;
|
||||
}
|
||||
if (cls == ELFCLASS64) {
|
||||
*dst = *(Elf64_Rela*)tmp;
|
||||
}
|
||||
else if (cls == ELFCLASS32) {
|
||||
Elf32_Rela *src = (Elf32_Rela*)tmp;
|
||||
|
||||
check_and_copy(GElf_Addr, dst, src, r_offset, NULL);
|
||||
dst->r_info = ELF64_R_INFO((Elf64_Xword)ELF32_R_SYM(src->r_info),
|
||||
(Elf64_Xword)ELF32_R_TYPE(src->r_info));
|
||||
check_and_copy(GElf_Sxword, dst, src, r_addend, NULL);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
if (dst == &buf) {
|
||||
dst = (GElf_Rela*)malloc(sizeof(GElf_Rela));
|
||||
if (!dst) {
|
||||
seterr(ERROR_MEM_RELA);
|
||||
return NULL;
|
||||
}
|
||||
*dst = buf;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
int
|
||||
gelf_update_rela(Elf_Data *dst, int ndx, GElf_Rela *src) {
|
||||
unsigned cls;
|
||||
char *tmp;
|
||||
|
||||
tmp = get_addr_and_class(dst, ndx, ELF_T_RELA, &cls);
|
||||
if (!tmp) {
|
||||
return 0;
|
||||
}
|
||||
if (cls == ELFCLASS64) {
|
||||
*(Elf64_Rela*)tmp = *src;
|
||||
}
|
||||
else if (cls == ELFCLASS32) {
|
||||
Elf32_Rela *dst = (Elf32_Rela*)tmp;
|
||||
|
||||
check_and_copy(Elf32_Addr, dst, src, r_offset, 0);
|
||||
if (ELF64_R_SYM(src->r_info) > 0xffffffUL
|
||||
|| ELF64_R_TYPE(src->r_info) > 0xffUL) {
|
||||
seterr(ERROR_BADVALUE);
|
||||
return 0;
|
||||
}
|
||||
dst->r_info = ELF32_R_INFO((Elf32_Word)ELF64_R_SYM(src->r_info),
|
||||
(Elf32_Word)ELF64_R_TYPE(src->r_info));
|
||||
check_and_copy(Elf32_Sword, dst, src, r_addend, 0);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
GElf_Rel*
|
||||
gelf_getrel(Elf_Data *src, int ndx, GElf_Rel *dst) {
|
||||
GElf_Rel buf;
|
||||
unsigned cls;
|
||||
char *tmp;
|
||||
|
||||
if (!dst) {
|
||||
dst = &buf;
|
||||
}
|
||||
tmp = get_addr_and_class(src, ndx, ELF_T_REL, &cls);
|
||||
if (!tmp) {
|
||||
return NULL;
|
||||
}
|
||||
if (cls == ELFCLASS64) {
|
||||
*dst = *(Elf64_Rel*)tmp;
|
||||
}
|
||||
else if (cls == ELFCLASS32) {
|
||||
Elf32_Rel *src = (Elf32_Rel*)tmp;
|
||||
|
||||
check_and_copy(GElf_Addr, dst, src, r_offset, NULL);
|
||||
dst->r_info = ELF64_R_INFO((Elf64_Xword)ELF32_R_SYM(src->r_info),
|
||||
(Elf64_Xword)ELF32_R_TYPE(src->r_info));
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
if (dst == &buf) {
|
||||
dst = (GElf_Rel*)malloc(sizeof(GElf_Rel));
|
||||
if (!dst) {
|
||||
seterr(ERROR_MEM_REL);
|
||||
return NULL;
|
||||
}
|
||||
*dst = buf;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
int
|
||||
gelf_update_rel(Elf_Data *dst, int ndx, GElf_Rel *src) {
|
||||
unsigned cls;
|
||||
char *tmp;
|
||||
|
||||
tmp = get_addr_and_class(dst, ndx, ELF_T_REL, &cls);
|
||||
if (!tmp) {
|
||||
return 0;
|
||||
}
|
||||
if (cls == ELFCLASS64) {
|
||||
*(Elf64_Rel*)tmp = *src;
|
||||
}
|
||||
else if (cls == ELFCLASS32) {
|
||||
Elf32_Rel *dst = (Elf32_Rel*)tmp;
|
||||
|
||||
check_and_copy(Elf32_Addr, dst, src, r_offset, 0);
|
||||
if (ELF64_R_SYM(src->r_info) > 0xffffffUL
|
||||
|| ELF64_R_TYPE(src->r_info) > 0xffUL) {
|
||||
seterr(ERROR_BADVALUE);
|
||||
return 0;
|
||||
}
|
||||
dst->r_info = ELF32_R_INFO((Elf32_Word)ELF64_R_SYM(src->r_info),
|
||||
(Elf32_Word)ELF64_R_TYPE(src->r_info));
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
GElf_Syminfo*
|
||||
gelf_getsyminfo(Elf_Data *src, int ndx, GElf_Syminfo *dst) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
gelf_update_syminfo(Elf_Data *dst, int ndx, GElf_Syminfo *src) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GElf_Move*
|
||||
gelf_getmove(Elf_Data *src, int ndx, GElf_Move *src) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
gelf_update_move(Elf_Data *dst, int ndx, GElf_Move *src) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
getarhdr.c - implementation of the elf_getarhdr(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: getarhdr.c,v 1.7 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
Elf_Arhdr*
|
||||
elf_getarhdr(Elf *elf) {
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (elf->e_arhdr) {
|
||||
return elf->e_arhdr;
|
||||
}
|
||||
seterr(ERROR_NOTARCHIVE);
|
||||
return NULL;
|
||||
}
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* getaroff.c - implementation of the elf_getaroff(3) function.
|
||||
* Copyright (C) 2009 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: getaroff.c,v 1.1 2009/11/01 13:04:19 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
off_t
|
||||
elf_getaroff(Elf *elf) {
|
||||
Elf *ref;
|
||||
|
||||
if (!elf) {
|
||||
return (off_t)-1;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (!(ref = elf->e_parent)) {
|
||||
return (off_t)-1;
|
||||
}
|
||||
elf_assert(ref->e_magic == ELF_MAGIC);
|
||||
elf_assert(elf->e_base >= ref->e_base + SARMAG + sizeof(struct ar_hdr));
|
||||
return (off_t)(elf->e_base - ref->e_base - sizeof(struct ar_hdr));
|
||||
}
|
||||
Vendored
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* getarsym.c - implementation of the elf_getarsym(3) function.
|
||||
* Copyright (C) 1995 - 1998, 2004 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: getarsym.c,v 1.9 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
Elf_Arsym*
|
||||
elf_getarsym(Elf *elf, size_t *ptr) {
|
||||
Elf_Arsym *syms;
|
||||
size_t count;
|
||||
size_t tmp;
|
||||
size_t i;
|
||||
char *s;
|
||||
char *e;
|
||||
|
||||
if (!ptr) {
|
||||
ptr = &tmp;
|
||||
}
|
||||
*ptr = 0;
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (elf->e_kind != ELF_K_AR) {
|
||||
seterr(ERROR_NOTARCHIVE);
|
||||
return NULL;
|
||||
}
|
||||
if (elf->e_symtab && !elf->e_free_syms) {
|
||||
if (elf->e_symlen < 4) {
|
||||
seterr(ERROR_SIZE_ARSYMTAB);
|
||||
return NULL;
|
||||
}
|
||||
count = __load_u32M(elf->e_symtab);
|
||||
if (elf->e_symlen < 4 * (count + 1)) {
|
||||
seterr(ERROR_SIZE_ARSYMTAB);
|
||||
return NULL;
|
||||
}
|
||||
if (!(syms = (Elf_Arsym*)malloc((count + 1) * sizeof(*syms)))) {
|
||||
seterr(ERROR_MEM_ARSYMTAB);
|
||||
return NULL;
|
||||
}
|
||||
s = elf->e_symtab + 4 * (count + 1);
|
||||
e = elf->e_symtab + elf->e_symlen;
|
||||
for (i = 0; i < count; i++, s++) {
|
||||
syms[i].as_name = s;
|
||||
while (s < e && *s) {
|
||||
s++;
|
||||
}
|
||||
if (s >= e) {
|
||||
seterr(ERROR_SIZE_ARSYMTAB);
|
||||
free(syms);
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(!*s);
|
||||
syms[i].as_hash = elf_hash((unsigned char*)syms[i].as_name);
|
||||
syms[i].as_off = __load_u32M(elf->e_symtab + 4 * (i + 1));
|
||||
}
|
||||
syms[count].as_name = NULL;
|
||||
syms[count].as_hash = ~0UL;
|
||||
syms[count].as_off = 0;
|
||||
elf->e_symtab = (char*)syms;
|
||||
elf->e_symlen = count + 1;
|
||||
elf->e_free_syms = 1;
|
||||
}
|
||||
*ptr = elf->e_symlen;
|
||||
return (Elf_Arsym*)elf->e_symtab;
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
getbase.c - implementation of the elf_getbase(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: getbase.c,v 1.7 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
off_t
|
||||
elf_getbase(Elf *elf) {
|
||||
if (!elf) {
|
||||
return -1;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
return (off_t)elf->e_base;
|
||||
}
|
||||
Vendored
+157
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
getdata.c - implementation of the elf_getdata(3) function.
|
||||
Copyright (C) 1995 - 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: getdata.c,v 1.13 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
static Elf_Data*
|
||||
_elf_cook_scn(Elf *elf, Elf_Scn *scn, Scn_Data *sd) {
|
||||
Elf_Data dst;
|
||||
Elf_Data src;
|
||||
int flag = 0;
|
||||
size_t dlen;
|
||||
|
||||
elf_assert(elf->e_data);
|
||||
|
||||
/*
|
||||
* Prepare source
|
||||
*/
|
||||
src = sd->sd_data;
|
||||
src.d_version = elf->e_version;
|
||||
if (elf->e_rawdata) {
|
||||
src.d_buf = elf->e_rawdata + scn->s_offset;
|
||||
}
|
||||
else {
|
||||
src.d_buf = elf->e_data + scn->s_offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare destination (needs prepared source!)
|
||||
*/
|
||||
dst = sd->sd_data;
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
dlen = _elf32_xltsize(&src, dst.d_version, elf->e_encoding, 0);
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
dlen = _elf64_xltsize(&src, dst.d_version, elf->e_encoding, 0);
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
else {
|
||||
elf_assert(valid_class(elf->e_class));
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
if (dlen == (size_t)-1) {
|
||||
return NULL;
|
||||
}
|
||||
dst.d_size = dlen;
|
||||
if (elf->e_rawdata != elf->e_data && dst.d_size <= src.d_size) {
|
||||
dst.d_buf = elf->e_data + scn->s_offset;
|
||||
}
|
||||
else if (!(dst.d_buf = malloc(dst.d_size))) {
|
||||
seterr(ERROR_MEM_SCNDATA);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
flag = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate data
|
||||
*/
|
||||
if (_elf_xlatetom(elf, &dst, &src)) {
|
||||
sd->sd_memdata = (char*)dst.d_buf;
|
||||
sd->sd_data = dst;
|
||||
if (!(sd->sd_free_data = flag)) {
|
||||
elf->e_cooked = 1;
|
||||
}
|
||||
return &sd->sd_data;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
free(dst.d_buf);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Elf_Data*
|
||||
elf_getdata(Elf_Scn *scn, Elf_Data *data) {
|
||||
Scn_Data *sd;
|
||||
Elf *elf;
|
||||
|
||||
if (!scn) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
if (scn->s_index == SHN_UNDEF) {
|
||||
seterr(ERROR_NULLSCN);
|
||||
}
|
||||
else if (data) {
|
||||
for (sd = scn->s_data_1; sd; sd = sd->sd_link) {
|
||||
elf_assert(sd->sd_magic == DATA_MAGIC);
|
||||
elf_assert(sd->sd_scn == scn);
|
||||
if (data == &sd->sd_data) {
|
||||
/*
|
||||
* sd_link allocated by elf_newdata().
|
||||
*/
|
||||
return &sd->sd_link->sd_data;
|
||||
}
|
||||
}
|
||||
seterr(ERROR_SCNDATAMISMATCH);
|
||||
}
|
||||
else if ((sd = scn->s_data_1)) {
|
||||
elf_assert(sd->sd_magic == DATA_MAGIC);
|
||||
elf_assert(sd->sd_scn == scn);
|
||||
elf = scn->s_elf;
|
||||
elf_assert(elf);
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (sd->sd_freeme) {
|
||||
/* allocated by elf_newdata() */
|
||||
return &sd->sd_data;
|
||||
}
|
||||
else if (scn->s_type == SHT_NULL) {
|
||||
seterr(ERROR_NULLSCN);
|
||||
}
|
||||
else if (sd->sd_memdata) {
|
||||
/* already cooked */
|
||||
return &sd->sd_data;
|
||||
}
|
||||
else if (scn->s_offset < 0 || scn->s_offset > elf->e_size) {
|
||||
seterr(ERROR_OUTSIDE);
|
||||
}
|
||||
else if (scn->s_type == SHT_NOBITS || !scn->s_size) {
|
||||
/* no data to read */
|
||||
return &sd->sd_data;
|
||||
}
|
||||
else if (scn->s_offset + scn->s_size > elf->e_size) {
|
||||
seterr(ERROR_TRUNC_SCN);
|
||||
}
|
||||
else if (valid_class(elf->e_class)) {
|
||||
return _elf_cook_scn(elf, scn, sd);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
getident.c - implementation of the elf_getident(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: getident.c,v 1.7 2008/05/23 08:15:34 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
char*
|
||||
elf_getident(Elf *elf, size_t *ptr) {
|
||||
size_t tmp;
|
||||
|
||||
if (!ptr) {
|
||||
ptr = &tmp;
|
||||
}
|
||||
if (!elf) {
|
||||
*ptr = 0;
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
*ptr = elf->e_idlen;
|
||||
return elf->e_data;
|
||||
}
|
||||
if (elf->e_ehdr || _elf_cook(elf)) {
|
||||
*ptr = elf->e_idlen;
|
||||
return elf->e_ehdr;
|
||||
}
|
||||
*ptr = 0;
|
||||
return NULL;
|
||||
}
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
getscn.c - implementation of the elf_getscn(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: getscn.c,v 1.7 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
Elf_Scn*
|
||||
elf_getscn(Elf *elf, size_t index) {
|
||||
Elf_Scn *scn;
|
||||
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (elf->e_ehdr || _elf_cook(elf)) {
|
||||
for (scn = elf->e_scn_1; scn; scn = scn->s_link) {
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
elf_assert(scn->s_elf == elf);
|
||||
if (scn->s_index == index) {
|
||||
return scn;
|
||||
}
|
||||
}
|
||||
seterr(ERROR_NOSUCHSCN);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
hash.c - implementation of the elf_hash(3) function.
|
||||
Copyright (C) 1995 - 2002 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: hash.c,v 1.10 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
unsigned long
|
||||
elf_hash(const unsigned char *name) {
|
||||
unsigned long hash = 0;
|
||||
unsigned long tmp;
|
||||
|
||||
while (*name) {
|
||||
hash = (hash << 4) + (unsigned char)*name++;
|
||||
if ((tmp = hash & 0xf0000000)) {
|
||||
hash ^= tmp | (tmp >> 24);
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
Vendored
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* input.c - low-level input for libelf.
|
||||
* Copyright (C) 1995 - 2001, 2005 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: input.c,v 1.11 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if HAVE_MMAP
|
||||
#include <sys/mman.h>
|
||||
#endif /* HAVE_MMAP */
|
||||
|
||||
static int
|
||||
xread(int fd, char *buffer, size_t len) {
|
||||
size_t done = 0;
|
||||
size_t n;
|
||||
|
||||
while (done < len) {
|
||||
n = read(fd, buffer + done, len - done);
|
||||
if (n == 0) {
|
||||
/* premature end of file */
|
||||
return -1;
|
||||
}
|
||||
else if (n != (size_t)-1) {
|
||||
/* some bytes read, continue */
|
||||
done += n;
|
||||
}
|
||||
else if (errno != EAGAIN && errno != EINTR) {
|
||||
/* real error */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void*
|
||||
_elf_read(Elf *elf, void *buffer, size_t off, size_t len) {
|
||||
void *tmp;
|
||||
|
||||
elf_assert(elf);
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
elf_assert(off >= 0 && off + len <= elf->e_size);
|
||||
if (elf->e_disabled) {
|
||||
seterr(ERROR_FDDISABLED);
|
||||
}
|
||||
else if (len) {
|
||||
off += elf->e_base;
|
||||
if (lseek(elf->e_fd, (off_t)off, SEEK_SET) != (off_t)off) {
|
||||
seterr(ERROR_IO_SEEK);
|
||||
}
|
||||
else if (!(tmp = buffer) && !(tmp = malloc(len))) {
|
||||
seterr(ERROR_IO_2BIG);
|
||||
}
|
||||
else if (xread(elf->e_fd, tmp, len)) {
|
||||
seterr(ERROR_IO_READ);
|
||||
if (tmp != buffer) {
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void*
|
||||
_elf_mmap(Elf *elf) {
|
||||
#if HAVE_MMAP
|
||||
void *tmp;
|
||||
|
||||
elf_assert(elf);
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
elf_assert(elf->e_base == 0);
|
||||
if (elf->e_disabled) {
|
||||
seterr(ERROR_FDDISABLED);
|
||||
}
|
||||
else if (elf->e_size) {
|
||||
tmp = (void*)mmap(0, elf->e_size, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE, elf->e_fd, 0);
|
||||
if (tmp != (void*)-1) {
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_MMAP */
|
||||
return NULL;
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
kind.c - implementation of the elf_kind(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: kind.c,v 1.7 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
Elf_Kind
|
||||
elf_kind(Elf *elf) {
|
||||
if (!elf) {
|
||||
return ELF_K_NONE;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
return elf->e_kind;
|
||||
}
|
||||
Vendored
+82
@@ -0,0 +1,82 @@
|
||||
LIBRARY libelf
|
||||
VERSION 0.8
|
||||
EXPORTS
|
||||
elf_begin
|
||||
elf_cntl
|
||||
elf_delscn
|
||||
elf_end
|
||||
elf_errmsg
|
||||
elf_errno
|
||||
elf_fill
|
||||
elf_flagdata
|
||||
elf_flagehdr
|
||||
elf_flagelf
|
||||
elf_flagphdr
|
||||
elf_flagscn
|
||||
elf_flagshdr
|
||||
elf_getarhdr
|
||||
elf_getarsym
|
||||
elf_getbase
|
||||
elf_getdata
|
||||
elf_getident
|
||||
elf_getscn
|
||||
elf_hash
|
||||
elf_kind
|
||||
elf_memory
|
||||
elf_ndxscn
|
||||
elf_newdata
|
||||
elf_newscn
|
||||
elf_next
|
||||
elf_nextscn
|
||||
elf_rand
|
||||
elf_rawdata
|
||||
elf_rawfile
|
||||
elf_strptr
|
||||
elf_update
|
||||
elf_version
|
||||
elf32_checksum
|
||||
elf32_fsize
|
||||
elf32_getehdr
|
||||
elf32_getphdr
|
||||
elf32_getshdr
|
||||
elf32_newehdr
|
||||
elf32_newphdr
|
||||
elf32_xlatetof
|
||||
elf32_xlatetom
|
||||
elf64_checksum
|
||||
elf64_fsize
|
||||
elf64_getehdr
|
||||
elf64_getphdr
|
||||
elf64_getshdr
|
||||
elf64_newehdr
|
||||
elf64_newphdr
|
||||
elf64_xlatetof
|
||||
elf64_xlatetom
|
||||
elfx_movscn
|
||||
elfx_remscn
|
||||
gelf_checksum
|
||||
gelf_fsize
|
||||
gelf_getclass
|
||||
gelf_getdyn
|
||||
gelf_getehdr
|
||||
gelf_getphdr
|
||||
gelf_getrel
|
||||
gelf_getrela
|
||||
gelf_getshdr
|
||||
gelf_getsym
|
||||
gelf_msize
|
||||
gelf_newehdr
|
||||
gelf_newphdr
|
||||
gelf_update_dyn
|
||||
gelf_update_ehdr
|
||||
gelf_update_phdr
|
||||
gelf_update_rel
|
||||
gelf_update_rela
|
||||
gelf_update_shdr
|
||||
gelf_update_sym
|
||||
gelf_xlatetof
|
||||
gelf_xlatetom
|
||||
elf_getphnum
|
||||
elf_getshnum
|
||||
elf_getshstrndx
|
||||
elfx_update_shstrndx
|
||||
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* memset.c - replacement for memset(3), using duff's device.
|
||||
* Copyright (C) 1995 - 2004 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: memset.c,v 1.11 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
#include <sys/types.h>
|
||||
|
||||
void*
|
||||
_elf_memset(void *s, int c, size_t n) {
|
||||
char *t = (char*)s;
|
||||
|
||||
if (n) {
|
||||
switch (n % 8u) {
|
||||
do {
|
||||
n -= 8;
|
||||
default:
|
||||
case 0: *t++ = (char)c;
|
||||
case 7: *t++ = (char)c;
|
||||
case 6: *t++ = (char)c;
|
||||
case 5: *t++ = (char)c;
|
||||
case 4: *t++ = (char)c;
|
||||
case 3: *t++ = (char)c;
|
||||
case 2: *t++ = (char)c;
|
||||
case 1: *t++ = (char)c;
|
||||
}
|
||||
while (n > 8);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
ndxscn.c - implementation of the elf_ndxscn(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: ndxscn.c,v 1.7 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
size_t
|
||||
elf_ndxscn(Elf_Scn *scn) {
|
||||
if (!scn) {
|
||||
return SHN_UNDEF;
|
||||
}
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
return scn->s_index;
|
||||
}
|
||||
Vendored
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
newdata.c - implementation of the elf_newdata(3) function.
|
||||
Copyright (C) 1995 - 2000 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: newdata.c,v 1.10 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
Elf_Data*
|
||||
elf_newdata(Elf_Scn *scn) {
|
||||
Scn_Data *sd;
|
||||
|
||||
if (!scn) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
if (scn->s_index == SHN_UNDEF) {
|
||||
seterr(ERROR_NULLSCN);
|
||||
}
|
||||
else if (!(sd = (Scn_Data*)malloc(sizeof(*sd)))) {
|
||||
seterr(ERROR_MEM_SCNDATA);
|
||||
}
|
||||
else {
|
||||
*sd = _elf_data_init;
|
||||
sd->sd_scn = scn;
|
||||
sd->sd_data_flags = ELF_F_DIRTY;
|
||||
sd->sd_freeme = 1;
|
||||
sd->sd_data.d_version = _elf_version;
|
||||
if (scn->s_data_n) {
|
||||
scn->s_data_n->sd_link = sd;
|
||||
}
|
||||
else {
|
||||
scn->s_data_1 = sd;
|
||||
}
|
||||
scn->s_data_n = sd;
|
||||
return &sd->sd_data;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Vendored
+145
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* newscn.c - implementation of the elf_newscn(3) function.
|
||||
* Copyright (C) 1995 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: newscn.c,v 1.13 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
int
|
||||
_elf_update_shnum(Elf *elf, size_t shnum) {
|
||||
size_t extshnum = 0;
|
||||
Elf_Scn *scn;
|
||||
|
||||
elf_assert(elf);
|
||||
elf_assert(elf->e_ehdr);
|
||||
scn = elf->e_scn_1;
|
||||
elf_assert(scn);
|
||||
elf_assert(scn->s_index == 0);
|
||||
if (shnum >= SHN_LORESERVE) {
|
||||
extshnum = shnum;
|
||||
shnum = 0;
|
||||
}
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
((Elf32_Ehdr*)elf->e_ehdr)->e_shnum = shnum;
|
||||
scn->s_shdr32.sh_size = extshnum;
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
((Elf64_Ehdr*)elf->e_ehdr)->e_shnum = shnum;
|
||||
scn->s_shdr64.sh_size = extshnum;
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
else {
|
||||
if (valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
elf->e_ehdr_flags |= ELF_F_DIRTY;
|
||||
scn->s_shdr_flags |= ELF_F_DIRTY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Elf_Scn*
|
||||
_makescn(Elf *elf, size_t index) {
|
||||
Elf_Scn *scn;
|
||||
|
||||
elf_assert(elf);
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
elf_assert(elf->e_ehdr);
|
||||
elf_assert(_elf_scn_init.s_magic == SCN_MAGIC);
|
||||
if (!(scn = (Elf_Scn*)malloc(sizeof(*scn)))) {
|
||||
seterr(ERROR_MEM_SCN);
|
||||
return NULL;
|
||||
}
|
||||
*scn = _elf_scn_init;
|
||||
scn->s_elf = elf;
|
||||
scn->s_scn_flags = ELF_F_DIRTY;
|
||||
scn->s_shdr_flags = ELF_F_DIRTY;
|
||||
scn->s_freeme = 1;
|
||||
scn->s_index = index;
|
||||
return scn;
|
||||
}
|
||||
|
||||
Elf_Scn*
|
||||
_elf_first_scn(Elf *elf) {
|
||||
Elf_Scn *scn;
|
||||
|
||||
elf_assert(elf);
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if ((scn = elf->e_scn_1)) {
|
||||
return scn;
|
||||
}
|
||||
if ((scn = _makescn(elf, 0))) {
|
||||
elf->e_scn_1 = elf->e_scn_n = scn;
|
||||
if (_elf_update_shnum(elf, 1)) {
|
||||
free(scn);
|
||||
elf->e_scn_1 = elf->e_scn_n = scn = NULL;
|
||||
}
|
||||
}
|
||||
return scn;
|
||||
}
|
||||
|
||||
static Elf_Scn*
|
||||
_buildscn(Elf *elf) {
|
||||
Elf_Scn *scn;
|
||||
|
||||
if (!_elf_first_scn(elf)) {
|
||||
return NULL;
|
||||
}
|
||||
scn = elf->e_scn_n;
|
||||
elf_assert(scn);
|
||||
if (!(scn = _makescn(elf, scn->s_index + 1))) {
|
||||
return NULL;
|
||||
}
|
||||
if (_elf_update_shnum(elf, scn->s_index + 1)) {
|
||||
free(scn);
|
||||
return NULL;
|
||||
}
|
||||
elf->e_scn_n = elf->e_scn_n->s_link = scn;
|
||||
return scn;
|
||||
}
|
||||
|
||||
Elf_Scn*
|
||||
elf_newscn(Elf *elf) {
|
||||
Elf_Scn *scn;
|
||||
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (!elf->e_readable && !elf->e_ehdr) {
|
||||
seterr(ERROR_NOEHDR);
|
||||
}
|
||||
else if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (!elf->e_ehdr && !_elf_cook(elf)) {
|
||||
return NULL;
|
||||
}
|
||||
else if ((scn = _buildscn(elf))) {
|
||||
return scn;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
next.c - implementation of the elf_next(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: next.c,v 1.7 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
Elf_Cmd
|
||||
elf_next(Elf *elf) {
|
||||
if (!elf) {
|
||||
return ELF_C_NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (!elf->e_parent) {
|
||||
return ELF_C_NULL;
|
||||
}
|
||||
elf_assert(elf->e_parent->e_magic == ELF_MAGIC);
|
||||
elf_assert(elf->e_parent->e_kind == ELF_K_AR);
|
||||
elf->e_parent->e_off = elf->e_next;
|
||||
if (elf->e_next == elf->e_parent->e_size) {
|
||||
return ELF_C_NULL;
|
||||
}
|
||||
return ELF_C_READ;
|
||||
}
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
nextscn.c - implementation of the elf_nextscn(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: nextscn.c,v 1.7 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
Elf_Scn*
|
||||
elf_nextscn(Elf *elf, Elf_Scn *scn) {
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (scn) {
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
if (scn->s_elf == elf) {
|
||||
return scn->s_link;
|
||||
}
|
||||
seterr(ERROR_ELFSCNMISMATCH);
|
||||
}
|
||||
else if (elf->e_kind != ELF_K_ELF) {
|
||||
seterr(ERROR_NOTELF);
|
||||
}
|
||||
else if (elf->e_ehdr || _elf_cook(elf)) {
|
||||
elf_assert(elf->e_ehdr);
|
||||
for (scn = elf->e_scn_1; scn; scn = scn->s_link) {
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
elf_assert(scn->s_elf == elf);
|
||||
if (scn->s_index == 1) {
|
||||
return scn;
|
||||
}
|
||||
}
|
||||
seterr(ERROR_NOSUCHSCN);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Vendored
+253
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* nlist.c - implementation of the nlist(3) function.
|
||||
* Copyright (C) 1995 - 2004 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
#include <nlist.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: nlist.c,v 1.15 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#if HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
extern int open();
|
||||
#endif /* HAVE_FCNTL_H */
|
||||
#endif /* defined(_WIN32) */
|
||||
|
||||
#ifndef O_RDONLY
|
||||
#define O_RDONLY 0
|
||||
#endif /* O_RDONLY */
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif /* O_BINARY */
|
||||
|
||||
#define FILE_OPEN_MODE (O_RDONLY | O_BINARY)
|
||||
|
||||
#define PRIME 217
|
||||
|
||||
struct hash {
|
||||
const char* name;
|
||||
unsigned long hash;
|
||||
unsigned next;
|
||||
};
|
||||
|
||||
static const char*
|
||||
symbol_name(Elf *elf, const void *syms, const char *names, size_t nlimit, size_t index) {
|
||||
size_t off;
|
||||
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
off = ((Elf32_Sym*)syms)[index].st_name;
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
off = ((Elf64_Sym*)syms)[index].st_name;
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
if (off >= 0 && off < nlimit) {
|
||||
return &names[off];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
copy_symbol(Elf *elf, struct nlist *np, const void *syms, size_t index) {
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
np->n_value = ((Elf32_Sym*)syms)[index].st_value;
|
||||
np->n_scnum = ((Elf32_Sym*)syms)[index].st_shndx;
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
np->n_value = ((Elf64_Sym*)syms)[index].st_value;
|
||||
np->n_scnum = ((Elf64_Sym*)syms)[index].st_shndx;
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
/*
|
||||
* this needs more work
|
||||
*/
|
||||
np->n_type = 0;
|
||||
np->n_sclass = 0;
|
||||
np->n_numaux = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_elf_nlist(Elf *elf, struct nlist *nl) {
|
||||
unsigned first[PRIME];
|
||||
Elf_Scn *symtab = NULL;
|
||||
Elf_Scn *strtab = NULL;
|
||||
Elf_Data *symdata;
|
||||
Elf_Data *strdata;
|
||||
size_t symsize;
|
||||
size_t nsymbols;
|
||||
const char *name;
|
||||
struct hash *table;
|
||||
unsigned long hash;
|
||||
unsigned i;
|
||||
struct nlist *np;
|
||||
|
||||
/*
|
||||
* Get and translate ELF header, section table and so on.
|
||||
* Must be class independent, so don't use elf32_get*().
|
||||
*/
|
||||
if (elf->e_kind != ELF_K_ELF) {
|
||||
return -1;
|
||||
}
|
||||
if (!elf->e_ehdr && !_elf_cook(elf)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find symbol table. If there is none, try dynamic symbols.
|
||||
*/
|
||||
for (symtab = elf->e_scn_1; symtab; symtab = symtab->s_link) {
|
||||
if (symtab->s_type == SHT_SYMTAB) {
|
||||
break;
|
||||
}
|
||||
if (symtab->s_type == SHT_DYNSYM) {
|
||||
strtab = symtab;
|
||||
}
|
||||
}
|
||||
if (!symtab && !(symtab = strtab)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get associated string table.
|
||||
*/
|
||||
i = 0;
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
i = symtab->s_shdr32.sh_link;
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
i = symtab->s_shdr64.sh_link;
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
if (i == 0) {
|
||||
return -1;
|
||||
}
|
||||
for (strtab = elf->e_scn_1; strtab; strtab = strtab->s_link) {
|
||||
if (strtab->s_index == i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!strtab || strtab->s_type != SHT_STRTAB) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get and translate section data.
|
||||
*/
|
||||
symdata = elf_getdata(symtab, NULL);
|
||||
strdata = elf_getdata(strtab, NULL);
|
||||
if (!symdata || !strdata) {
|
||||
return -1;
|
||||
}
|
||||
symsize = _msize(elf->e_class, _elf_version, ELF_T_SYM);
|
||||
elf_assert(symsize);
|
||||
nsymbols = symdata->d_size / symsize;
|
||||
if (!symdata->d_buf || !strdata->d_buf || !nsymbols || !strdata->d_size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build a simple hash table.
|
||||
*/
|
||||
if (!(table = (struct hash*)malloc(nsymbols * sizeof(*table)))) {
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < PRIME; i++) {
|
||||
first[i] = 0;
|
||||
}
|
||||
for (i = 0; i < nsymbols; i++) {
|
||||
table[i].name = NULL;
|
||||
table[i].hash = 0;
|
||||
table[i].next = 0;
|
||||
}
|
||||
for (i = 1; i < nsymbols; i++) {
|
||||
name = symbol_name(elf, symdata->d_buf, strdata->d_buf,
|
||||
strdata->d_size, i);
|
||||
if (name == NULL) {
|
||||
free(table);
|
||||
return -1;
|
||||
}
|
||||
if (*name != '\0') {
|
||||
table[i].name = name;
|
||||
table[i].hash = elf_hash((unsigned char*)name);
|
||||
hash = table[i].hash % PRIME;
|
||||
table[i].next = first[hash];
|
||||
first[hash] = i;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup symbols, one by one.
|
||||
*/
|
||||
for (np = nl; (name = np->n_name) && *name; np++) {
|
||||
hash = elf_hash((unsigned char*)name);
|
||||
for (i = first[hash % PRIME]; i; i = table[i].next) {
|
||||
if (table[i].hash == hash && !strcmp(table[i].name, name)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i) {
|
||||
copy_symbol(elf, np, symdata->d_buf, i);
|
||||
}
|
||||
else {
|
||||
np->n_value = 0;
|
||||
np->n_scnum = 0;
|
||||
np->n_type = 0;
|
||||
np->n_sclass = 0;
|
||||
np->n_numaux = 0;
|
||||
}
|
||||
}
|
||||
free(table);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nlist(const char *filename, struct nlist *nl) {
|
||||
int result = -1;
|
||||
unsigned oldver;
|
||||
Elf *elf;
|
||||
int fd;
|
||||
|
||||
if ((oldver = elf_version(EV_CURRENT)) != EV_NONE) {
|
||||
if ((fd = open(filename, FILE_OPEN_MODE)) != -1) {
|
||||
if ((elf = elf_begin(fd, ELF_C_READ, NULL))) {
|
||||
result = _elf_nlist(elf, nl);
|
||||
elf_end(elf);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
elf_version(oldver);
|
||||
}
|
||||
if (result) {
|
||||
while (nl->n_name && *nl->n_name) {
|
||||
nl->n_value = 0;
|
||||
nl++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* nlist.h - public header file for nlist(3).
|
||||
* Copyright (C) 1995 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* @(#) $Id: nlist.h,v 1.10 2008/05/23 08:15:35 michael Exp $ */
|
||||
|
||||
#ifndef _NLIST_H
|
||||
#define _NLIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct nlist {
|
||||
char* n_name;
|
||||
long n_value;
|
||||
short n_scnum;
|
||||
unsigned short n_type;
|
||||
char n_sclass;
|
||||
char n_numaux;
|
||||
};
|
||||
|
||||
#if (__STDC__ + 0) || defined(__cplusplus) || defined(_WIN32)
|
||||
extern int nlist(const char *__filename, struct nlist *__nl);
|
||||
#else /* __STDC__ || defined(__cplusplus) */
|
||||
extern int nlist();
|
||||
#endif /* __STDC__ || defined(__cplusplus) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _NLIST_H */
|
||||
Vendored
+205
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
opt.delscn.c - implementation of the elf_delscn(3) function.
|
||||
Copyright (C) 1995 - 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: opt.delscn.c,v 1.12 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
static size_t
|
||||
_newindex(size_t old, size_t index) {
|
||||
return old == index ? SHN_UNDEF : (old > index ? old - 1 : old);
|
||||
}
|
||||
|
||||
static void
|
||||
_elf32_update_shdr(Elf *elf, size_t index) {
|
||||
Elf32_Shdr *shdr;
|
||||
Elf_Scn *scn;
|
||||
|
||||
((Elf32_Ehdr*)elf->e_ehdr)->e_shnum = elf->e_scn_n->s_index + 1;
|
||||
for (scn = elf->e_scn_1; scn; scn = scn->s_link) {
|
||||
shdr = &scn->s_shdr32;
|
||||
switch (shdr->sh_type) {
|
||||
case SHT_REL:
|
||||
case SHT_RELA:
|
||||
shdr->sh_info = _newindex(shdr->sh_info, index);
|
||||
/* fall through */
|
||||
case SHT_DYNSYM:
|
||||
case SHT_DYNAMIC:
|
||||
case SHT_HASH:
|
||||
case SHT_SYMTAB:
|
||||
#if __LIBELF_SYMBOL_VERSIONS
|
||||
#if __LIBELF_SUN_SYMBOL_VERSIONS
|
||||
case SHT_SUNW_verdef:
|
||||
case SHT_SUNW_verneed:
|
||||
case SHT_SUNW_versym:
|
||||
#else /* __LIBELF_SUN_SYMBOL_VERSIONS */
|
||||
case SHT_GNU_verdef:
|
||||
case SHT_GNU_verneed:
|
||||
case SHT_GNU_versym:
|
||||
#endif /* __LIBELF_SUN_SYMBOL_VERSIONS */
|
||||
#endif /* __LIBELF_SYMBOL_VERSIONS */
|
||||
shdr->sh_link = _newindex(shdr->sh_link, index);
|
||||
/* fall through */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
static void
|
||||
_elf64_update_shdr(Elf *elf, size_t index) {
|
||||
Elf64_Shdr *shdr;
|
||||
Elf_Scn *scn;
|
||||
|
||||
((Elf64_Ehdr*)elf->e_ehdr)->e_shnum = elf->e_scn_n->s_index + 1;
|
||||
for (scn = elf->e_scn_1; scn; scn = scn->s_link) {
|
||||
shdr = &scn->s_shdr64;
|
||||
switch (shdr->sh_type) {
|
||||
case SHT_REL:
|
||||
case SHT_RELA:
|
||||
shdr->sh_info = _newindex(shdr->sh_info, index);
|
||||
/* fall through */
|
||||
case SHT_DYNSYM:
|
||||
case SHT_DYNAMIC:
|
||||
case SHT_HASH:
|
||||
case SHT_SYMTAB:
|
||||
#if __LIBELF_SYMBOL_VERSIONS
|
||||
#if __LIBELF_SUN_SYMBOL_VERSIONS
|
||||
case SHT_SUNW_verdef:
|
||||
case SHT_SUNW_verneed:
|
||||
case SHT_SUNW_versym:
|
||||
#else /* __LIBELF_SUN_SYMBOL_VERSIONS */
|
||||
case SHT_GNU_verdef:
|
||||
case SHT_GNU_verneed:
|
||||
case SHT_GNU_versym:
|
||||
#endif /* __LIBELF_SUN_SYMBOL_VERSIONS */
|
||||
#endif /* __LIBELF_SYMBOL_VERSIONS */
|
||||
shdr->sh_link = _newindex(shdr->sh_link, index);
|
||||
/* fall through */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
size_t
|
||||
elf_delscn(Elf *elf, Elf_Scn *scn) {
|
||||
Elf_Scn *pscn;
|
||||
Scn_Data *sd;
|
||||
Scn_Data *tmp;
|
||||
size_t index;
|
||||
|
||||
if (!elf || !scn) {
|
||||
return SHN_UNDEF;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
elf_assert(elf->e_ehdr);
|
||||
if (scn->s_elf != elf) {
|
||||
seterr(ERROR_ELFSCNMISMATCH);
|
||||
return SHN_UNDEF;
|
||||
}
|
||||
elf_assert(elf->e_scn_1);
|
||||
if (scn == elf->e_scn_1) {
|
||||
seterr(ERROR_NULLSCN);
|
||||
return SHN_UNDEF;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find previous section.
|
||||
*/
|
||||
for (pscn = elf->e_scn_1; pscn->s_link; pscn = pscn->s_link) {
|
||||
if (pscn->s_link == scn) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pscn->s_link != scn) {
|
||||
seterr(ERROR_ELFSCNMISMATCH);
|
||||
return SHN_UNDEF;
|
||||
}
|
||||
/*
|
||||
* Unlink section.
|
||||
*/
|
||||
if (elf->e_scn_n == scn) {
|
||||
elf->e_scn_n = pscn;
|
||||
}
|
||||
pscn->s_link = scn->s_link;
|
||||
index = scn->s_index;
|
||||
/*
|
||||
* Free section descriptor and data.
|
||||
*/
|
||||
for (sd = scn->s_data_1; sd; sd = tmp) {
|
||||
elf_assert(sd->sd_magic == DATA_MAGIC);
|
||||
elf_assert(sd->sd_scn == scn);
|
||||
tmp = sd->sd_link;
|
||||
if (sd->sd_free_data && sd->sd_memdata) {
|
||||
free(sd->sd_memdata);
|
||||
}
|
||||
if (sd->sd_freeme) {
|
||||
free(sd);
|
||||
}
|
||||
}
|
||||
if ((sd = scn->s_rawdata)) {
|
||||
elf_assert(sd->sd_magic == DATA_MAGIC);
|
||||
elf_assert(sd->sd_scn == scn);
|
||||
if (sd->sd_free_data && sd->sd_memdata) {
|
||||
free(sd->sd_memdata);
|
||||
}
|
||||
if (sd->sd_freeme) {
|
||||
free(sd);
|
||||
}
|
||||
}
|
||||
if (scn->s_freeme) {
|
||||
elf_assert(scn->s_index > 0);
|
||||
free(scn);
|
||||
}
|
||||
/*
|
||||
* Adjust section indices.
|
||||
*/
|
||||
for (scn = pscn->s_link; scn; scn = scn->s_link) {
|
||||
elf_assert(scn->s_index > index);
|
||||
scn->s_index--;
|
||||
}
|
||||
/*
|
||||
* Adjust ELF header and well-known section headers.
|
||||
*/
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
_elf32_update_shdr(elf, index);
|
||||
return index;
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
_elf64_update_shdr(elf, index);
|
||||
return index;
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
else if (valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
}
|
||||
return SHN_UNDEF;
|
||||
}
|
||||
Vendored
+446
@@ -0,0 +1,446 @@
|
||||
/*
|
||||
* private.h - private definitions for libelf.
|
||||
* Copyright (C) 1995 - 2007 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* @(#) $Id: private.h,v 1.40 2009/11/01 13:04:19 michael Exp $ */
|
||||
|
||||
#ifndef _PRIVATE_H
|
||||
#define _PRIVATE_H
|
||||
|
||||
#define __LIBELF_INTERNAL__ 1
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
/*
|
||||
* Workaround for GLIBC bug:
|
||||
* include <stdint.h> before <sys/types.h>
|
||||
*/
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#else /* STDC_HEADERS */
|
||||
extern void *malloc(), *realloc();
|
||||
extern void free(), bcopy(), abort();
|
||||
extern int strcmp(), strncmp(), memcmp();
|
||||
extern void *memcpy(), *memmove(), *memset();
|
||||
#endif /* STDC_HEADERS */
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <io.h>
|
||||
#else
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#else /* HAVE_UNISTD_H */
|
||||
extern int read(), write(), close();
|
||||
extern off_t lseek();
|
||||
#if HAVE_FTRUNCATE
|
||||
extern int ftruncate();
|
||||
#endif /* HAVE_FTRUNCATE */
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#endif /* defined(_WIN32) */
|
||||
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
#endif /* SEEK_SET */
|
||||
#ifndef SEEK_CUR
|
||||
#define SEEK_CUR 1
|
||||
#endif /* SEEK_CUR */
|
||||
#ifndef SEEK_END
|
||||
#define SEEK_END 2
|
||||
#endif /* SEEK_END */
|
||||
|
||||
#if !HAVE_MEMCMP
|
||||
# define memcmp strncmp
|
||||
#endif /* !HAVE_MEMCMP */
|
||||
#if !HAVE_MEMCPY
|
||||
# define memcpy(d,s,n) bcopy(s,d,n)
|
||||
#endif /* !HAVE_MEMCPY */
|
||||
#if !HAVE_MEMMOVE
|
||||
# define memmove(d,s,n) bcopy(s,d,n)
|
||||
#endif /* !HAVE_MEMMOVE */
|
||||
|
||||
#if !HAVE_MEMSET
|
||||
# define memset _elf_memset
|
||||
extern void *_elf_memset();
|
||||
#endif /* !HAVE_MEMSET */
|
||||
|
||||
#if HAVE_STRUCT_NLIST_DECLARATION
|
||||
# define nlist __override_nlist_declaration
|
||||
#endif /* HAVE_STRUCT_NLIST_DECLARATION */
|
||||
|
||||
#if __LIBELF_NEED_LINK_H
|
||||
# include <link.h>
|
||||
#elif __LIBELF_NEED_SYS_LINK_H
|
||||
# include <sys/link.h>
|
||||
#endif /* __LIBELF_NEED_LINK_H */
|
||||
|
||||
#if HAVE_AR_H
|
||||
#include <ar.h>
|
||||
#else /* HAVE_AR_H */
|
||||
|
||||
#define ARMAG "!<arch>\n"
|
||||
#define SARMAG 8
|
||||
|
||||
struct ar_hdr {
|
||||
char ar_name[16];
|
||||
char ar_date[12];
|
||||
char ar_uid[6];
|
||||
char ar_gid[6];
|
||||
char ar_mode[8];
|
||||
char ar_size[10];
|
||||
char ar_fmag[2];
|
||||
};
|
||||
|
||||
#define ARFMAG "`\n"
|
||||
|
||||
#endif /* HAVE_AR_H */
|
||||
|
||||
#include <libelf.h>
|
||||
|
||||
#if HAVE_STRUCT_NLIST_DECLARATION
|
||||
# undef nlist
|
||||
#endif /* HAVE_STRUCT_NLIST_DECLARATION */
|
||||
|
||||
#if __LIBELF64
|
||||
#include <gelf.h>
|
||||
#endif /* __LIBELF64 */
|
||||
|
||||
typedef struct Scn_Data Scn_Data;
|
||||
|
||||
/*
|
||||
* ELF descriptor
|
||||
*/
|
||||
struct Elf {
|
||||
/* common */
|
||||
size_t e_size; /* file/member size */
|
||||
size_t e_dsize; /* size of memory image */
|
||||
Elf_Kind e_kind; /* kind of file */
|
||||
char* e_data; /* file/member data */
|
||||
char* e_rawdata; /* file/member raw data */
|
||||
size_t e_idlen; /* identifier size */
|
||||
int e_fd; /* file descriptor */
|
||||
unsigned e_count; /* activation count */
|
||||
/* archive members (still common) */
|
||||
Elf* e_parent; /* NULL if not an archive member */
|
||||
size_t e_next; /* 0 if not an archive member */
|
||||
size_t e_base; /* 0 if not an archive member */
|
||||
Elf* e_link; /* next archive member or NULL */
|
||||
Elf_Arhdr* e_arhdr; /* archive member header or NULL */
|
||||
/* archives */
|
||||
size_t e_off; /* current member offset (for elf_begin) */
|
||||
Elf* e_members; /* linked list of active archive members */
|
||||
char* e_symtab; /* archive symbol table */
|
||||
size_t e_symlen; /* length of archive symbol table */
|
||||
char* e_strtab; /* archive string table */
|
||||
size_t e_strlen; /* length of archive string table */
|
||||
/* ELF files */
|
||||
unsigned e_class; /* ELF class */
|
||||
unsigned e_encoding; /* ELF data encoding */
|
||||
unsigned e_version; /* ELF version */
|
||||
char* e_ehdr; /* ELF header */
|
||||
char* e_phdr; /* ELF program header table */
|
||||
size_t e_phnum; /* size of program header table */
|
||||
Elf_Scn* e_scn_1; /* first section */
|
||||
Elf_Scn* e_scn_n; /* last section */
|
||||
unsigned e_elf_flags; /* elf flags (ELF_F_*) */
|
||||
unsigned e_ehdr_flags; /* ehdr flags (ELF_F_*) */
|
||||
unsigned e_phdr_flags; /* phdr flags (ELF_F_*) */
|
||||
/* misc flags */
|
||||
unsigned e_readable : 1; /* file is readable */
|
||||
unsigned e_writable : 1; /* file is writable */
|
||||
unsigned e_disabled : 1; /* e_fd has been disabled */
|
||||
unsigned e_cooked : 1; /* e_data was modified */
|
||||
unsigned e_free_syms : 1; /* e_symtab is malloc'ed */
|
||||
unsigned e_unmap_data : 1; /* e_data is mmap'ed */
|
||||
unsigned e_memory : 1; /* created by elf_memory() */
|
||||
/* magic number for debugging */
|
||||
long e_magic;
|
||||
};
|
||||
|
||||
#define ELF_MAGIC 0x012b649e
|
||||
|
||||
#define INIT_ELF {\
|
||||
/* e_size */ 0,\
|
||||
/* e_dsize */ 0,\
|
||||
/* e_kind */ ELF_K_NONE,\
|
||||
/* e_data */ NULL,\
|
||||
/* e_rawdata */ NULL,\
|
||||
/* e_idlen */ 0,\
|
||||
/* e_fd */ -1,\
|
||||
/* e_count */ 1,\
|
||||
/* e_parent */ NULL,\
|
||||
/* e_next */ 0,\
|
||||
/* e_base */ 0,\
|
||||
/* e_link */ NULL,\
|
||||
/* e_arhdr */ NULL,\
|
||||
/* e_off */ 0,\
|
||||
/* e_members */ NULL,\
|
||||
/* e_symtab */ NULL,\
|
||||
/* e_symlen */ 0,\
|
||||
/* e_strtab */ NULL,\
|
||||
/* e_strlen */ 0,\
|
||||
/* e_class */ ELFCLASSNONE,\
|
||||
/* e_encoding */ ELFDATANONE,\
|
||||
/* e_version */ EV_NONE,\
|
||||
/* e_ehdr */ NULL,\
|
||||
/* e_phdr */ NULL,\
|
||||
/* e_phnum */ 0,\
|
||||
/* e_scn_1 */ NULL,\
|
||||
/* e_scn_n */ NULL,\
|
||||
/* e_elf_flags */ 0,\
|
||||
/* e_ehdr_flags */ 0,\
|
||||
/* e_phdr_flags */ 0,\
|
||||
/* e_readable */ 0,\
|
||||
/* e_writable */ 0,\
|
||||
/* e_disabled */ 0,\
|
||||
/* e_cooked */ 0,\
|
||||
/* e_free_syms */ 0,\
|
||||
/* e_unmap_data */ 0,\
|
||||
/* e_memory */ 0,\
|
||||
/* e_magic */ ELF_MAGIC\
|
||||
}
|
||||
|
||||
/*
|
||||
* Section descriptor
|
||||
*/
|
||||
struct Elf_Scn {
|
||||
Elf_Scn* s_link; /* pointer to next Elf_Scn */
|
||||
Elf* s_elf; /* pointer to elf descriptor */
|
||||
size_t s_index; /* number of this section */
|
||||
unsigned s_scn_flags; /* section flags (ELF_F_*) */
|
||||
unsigned s_shdr_flags; /* shdr flags (ELF_F_*) */
|
||||
Scn_Data* s_data_1; /* first data buffer */
|
||||
Scn_Data* s_data_n; /* last data buffer */
|
||||
Scn_Data* s_rawdata; /* raw data buffer */
|
||||
/* data copied from shdr */
|
||||
unsigned s_type; /* section type */
|
||||
size_t s_offset; /* section offset */
|
||||
size_t s_size; /* section size */
|
||||
/* misc flags */
|
||||
unsigned s_freeme : 1; /* this Elf_Scn was malloc'ed */
|
||||
/* section header */
|
||||
union {
|
||||
#if __LIBELF64
|
||||
Elf64_Shdr u_shdr64;
|
||||
#endif /* __LIBELF64 */
|
||||
Elf32_Shdr u_shdr32;
|
||||
} s_uhdr;
|
||||
/* magic number for debugging */
|
||||
long s_magic;
|
||||
};
|
||||
#define s_shdr32 s_uhdr.u_shdr32
|
||||
#define s_shdr64 s_uhdr.u_shdr64
|
||||
|
||||
#define SCN_MAGIC 0x012c747d
|
||||
|
||||
#define INIT_SCN {\
|
||||
/* s_link */ NULL,\
|
||||
/* s_elf */ NULL,\
|
||||
/* s_index */ 0,\
|
||||
/* s_scn_flags */ 0,\
|
||||
/* s_shdr_flags */ 0,\
|
||||
/* s_data_1 */ NULL,\
|
||||
/* s_data_n */ NULL,\
|
||||
/* s_rawdata */ NULL,\
|
||||
/* s_type */ SHT_NULL,\
|
||||
/* s_offset */ 0,\
|
||||
/* s_size */ 0,\
|
||||
/* s_freeme */ 0,\
|
||||
/* s_uhdr */ {{0,}},\
|
||||
/* s_magic */ SCN_MAGIC\
|
||||
}
|
||||
|
||||
/*
|
||||
* Data descriptor
|
||||
*/
|
||||
struct Scn_Data {
|
||||
Elf_Data sd_data; /* must be first! */
|
||||
Scn_Data* sd_link; /* pointer to next Scn_Data */
|
||||
Elf_Scn* sd_scn; /* pointer to section */
|
||||
char* sd_memdata; /* memory image of section */
|
||||
unsigned sd_data_flags; /* data flags (ELF_F_*) */
|
||||
/* misc flags */
|
||||
unsigned sd_freeme : 1; /* this Scn_Data was malloc'ed */
|
||||
unsigned sd_free_data : 1; /* sd_memdata is malloc'ed */
|
||||
/* magic number for debugging */
|
||||
long sd_magic;
|
||||
};
|
||||
|
||||
#define DATA_MAGIC 0x01072639
|
||||
|
||||
#define INIT_DATA {\
|
||||
{\
|
||||
/* d_buf */ NULL,\
|
||||
/* d_type */ ELF_T_BYTE,\
|
||||
/* d_size */ 0,\
|
||||
/* d_off */ 0,\
|
||||
/* d_align */ 0,\
|
||||
/* d_version */ EV_NONE\
|
||||
},\
|
||||
/* sd_link */ NULL,\
|
||||
/* sd_scn */ NULL,\
|
||||
/* sd_memdata */ NULL,\
|
||||
/* sd_data_flags */ 0,\
|
||||
/* sd_freeme */ 0,\
|
||||
/* sd_free_data */ 0,\
|
||||
/* sd_magic */ DATA_MAGIC\
|
||||
}
|
||||
|
||||
/*
|
||||
* Private status variables
|
||||
*/
|
||||
extern unsigned _elf_version;
|
||||
extern int _elf_errno;
|
||||
extern int _elf_fill;
|
||||
extern int _elf_sanity_checks;
|
||||
#define SANITY_CHECK_STRPTR (1u << 0)
|
||||
|
||||
/*
|
||||
* Private functions
|
||||
*/
|
||||
extern void *_elf_read __P((Elf*, void*, size_t, size_t));
|
||||
extern void *_elf_mmap __P((Elf*));
|
||||
extern int _elf_cook __P((Elf*));
|
||||
extern char *_elf_getehdr __P((Elf*, unsigned));
|
||||
extern char *_elf_getphdr __P((Elf*, unsigned));
|
||||
extern Elf_Data *_elf_xlatetom __P((const Elf*, Elf_Data*, const Elf_Data*));
|
||||
extern Elf_Type _elf_scn_type __P((unsigned));
|
||||
extern size_t _elf32_xltsize __P((const Elf_Data *__src, unsigned __dv, unsigned __encode, int __tof));
|
||||
extern size_t _elf64_xltsize __P((const Elf_Data *__src, unsigned __dv, unsigned __encode, int __tof));
|
||||
extern int _elf_update_shnum(Elf *__elf, size_t __shnum);
|
||||
extern Elf_Scn *_elf_first_scn(Elf *__elf);
|
||||
|
||||
/*
|
||||
* Special translators
|
||||
*/
|
||||
extern size_t _elf_verdef_32L11_tof __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verdef_32L11_tom __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verdef_32M11_tof __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verdef_32M11_tom __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verdef_64L11_tof __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verdef_64L11_tom __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verdef_64M11_tof __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verdef_64M11_tom __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verneed_32L11_tof __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verneed_32L11_tom __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verneed_32M11_tof __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verneed_32M11_tom __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verneed_64L11_tof __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verneed_64L11_tom __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verneed_64M11_tof __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
extern size_t _elf_verneed_64M11_tom __P((unsigned char *dst, const unsigned char *src, size_t n));
|
||||
|
||||
/*
|
||||
* Private data
|
||||
*/
|
||||
extern const Elf_Scn _elf_scn_init;
|
||||
extern const Scn_Data _elf_data_init;
|
||||
extern const size_t _elf_fmsize[2][EV_CURRENT - EV_NONE][ELF_T_NUM][2];
|
||||
|
||||
/*
|
||||
* Access macros for _elf_fmsize[]
|
||||
*/
|
||||
#define _fmsize(c,v,t,w) \
|
||||
(_elf_fmsize[(c)-ELFCLASS32][(v)-EV_NONE-1][(t)-ELF_T_BYTE][(w)])
|
||||
#define _fsize(c,v,t) _fmsize((c),(v),(t),1)
|
||||
#define _msize(c,v,t) _fmsize((c),(v),(t),0)
|
||||
|
||||
/*
|
||||
* Various checks
|
||||
*/
|
||||
#define valid_class(c) ((c) >= ELFCLASS32 && (c) <= ELFCLASS64)
|
||||
#define valid_encoding(e) ((e) >= ELFDATA2LSB && (e) <= ELFDATA2MSB)
|
||||
#define valid_version(v) ((v) > EV_NONE && (v) <= EV_CURRENT)
|
||||
#define valid_type(t) ((unsigned)(t) < ELF_T_NUM)
|
||||
|
||||
/*
|
||||
* Error codes
|
||||
*/
|
||||
enum {
|
||||
#define __err__(a,b) a,
|
||||
#include <errors.h> /* include constants from errors.h */
|
||||
#undef __err__
|
||||
ERROR_NUM
|
||||
};
|
||||
|
||||
#define seterr(err) (_elf_errno = (err))
|
||||
|
||||
/*
|
||||
* Sizes of data types (external representation)
|
||||
* These definitions should be in <elf.h>, but...
|
||||
*/
|
||||
#ifndef ELF32_FSZ_ADDR
|
||||
# define ELF32_FSZ_ADDR 4
|
||||
# define ELF32_FSZ_HALF 2
|
||||
# define ELF32_FSZ_OFF 4
|
||||
# define ELF32_FSZ_SWORD 4
|
||||
# define ELF32_FSZ_WORD 4
|
||||
#endif /* ELF32_FSZ_ADDR */
|
||||
#ifndef ELF64_FSZ_ADDR
|
||||
# define ELF64_FSZ_ADDR 8
|
||||
# define ELF64_FSZ_HALF 2
|
||||
# define ELF64_FSZ_OFF 8
|
||||
# define ELF64_FSZ_SWORD 4
|
||||
# define ELF64_FSZ_SXWORD 8
|
||||
# define ELF64_FSZ_WORD 4
|
||||
# define ELF64_FSZ_XWORD 8
|
||||
#endif /* ELF64_FSZ_ADDR */
|
||||
|
||||
/*
|
||||
* More missing pieces, in no particular order
|
||||
*/
|
||||
#ifndef SHT_SYMTAB_SHNDX
|
||||
#define SHT_SYMTAB_SHNDX 18
|
||||
#endif /* SHT_SYMTAB_SHNDX */
|
||||
|
||||
#ifndef SHN_XINDEX
|
||||
#define SHN_XINDEX 0xffff
|
||||
#endif /* SHN_XINDEX */
|
||||
|
||||
#ifndef PN_XNUM
|
||||
#define PN_XNUM 0xffff
|
||||
#endif /* PN_XNUM */
|
||||
|
||||
/*
|
||||
* Debugging
|
||||
*/
|
||||
#if ENABLE_DEBUG
|
||||
extern void __elf_assert __P((const char*, unsigned, const char*));
|
||||
# if (__STDC__ + 0)
|
||||
# define elf_assert(x) do{if(!(x))__elf_assert(__FILE__,__LINE__,#x);}while(0)
|
||||
# else /* __STDC__ */
|
||||
# define elf_assert(x) do{if(!(x))__elf_assert(__FILE__,__LINE__,"x");}while(0)
|
||||
# endif /* __STDC__ */
|
||||
#else /* ENABLE_DEBUG */
|
||||
# define elf_assert(x) do{}while(0)
|
||||
#endif /* ENABLE_DEBUG */
|
||||
|
||||
/*
|
||||
* Return values for certain functions
|
||||
*/
|
||||
#define LIBELF_SUCCESS 1
|
||||
#define LIBELF_FAILURE 0
|
||||
|
||||
#endif /* _PRIVATE_H */
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
rand.c - implementation of the elf_rand(3) function.
|
||||
Copyright (C) 1995 - 1998 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: rand.c,v 1.7 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
size_t
|
||||
elf_rand(Elf *elf, size_t offset) {
|
||||
if (!elf) {
|
||||
return 0;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (elf->e_kind != ELF_K_AR) {
|
||||
seterr(ERROR_NOTARCHIVE);
|
||||
}
|
||||
else if (offset <= 0 || offset > elf->e_size) {
|
||||
seterr(ERROR_BADOFF);
|
||||
}
|
||||
else {
|
||||
elf->e_off = offset;
|
||||
return offset;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Vendored
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
rawdata.c - implementation of the elf_rawdata(3) function.
|
||||
Copyright (C) 1995 - 2000 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: rawdata.c,v 1.10 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
Elf_Data*
|
||||
elf_rawdata(Elf_Scn *scn, Elf_Data *data) {
|
||||
Scn_Data *sd;
|
||||
Elf *elf;
|
||||
|
||||
if (!scn) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(scn->s_magic == SCN_MAGIC);
|
||||
elf = scn->s_elf;
|
||||
elf_assert(elf);
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (!elf->e_readable) {
|
||||
return NULL;
|
||||
}
|
||||
else if (scn->s_index == SHN_UNDEF || scn->s_type == SHT_NULL) {
|
||||
seterr(ERROR_NULLSCN);
|
||||
}
|
||||
else if (data) {
|
||||
return NULL;
|
||||
}
|
||||
else if ((sd = scn->s_rawdata)) {
|
||||
elf_assert(sd->sd_magic == DATA_MAGIC);
|
||||
elf_assert(sd->sd_scn == scn);
|
||||
return &sd->sd_data;
|
||||
}
|
||||
else if (scn->s_offset < 0 || scn->s_offset > elf->e_size) {
|
||||
seterr(ERROR_OUTSIDE);
|
||||
}
|
||||
else if (scn->s_type != SHT_NOBITS
|
||||
&& scn->s_offset + scn->s_size > elf->e_size) {
|
||||
seterr(ERROR_TRUNC_SCN);
|
||||
}
|
||||
else if (!(sd = (Scn_Data*)malloc(sizeof(*sd)))) {
|
||||
seterr(ERROR_MEM_SCNDATA);
|
||||
}
|
||||
else {
|
||||
*sd = _elf_data_init;
|
||||
sd->sd_scn = scn;
|
||||
sd->sd_freeme = 1;
|
||||
sd->sd_data.d_size = scn->s_size;
|
||||
sd->sd_data.d_version = _elf_version;
|
||||
if (scn->s_type != SHT_NOBITS && scn->s_size) {
|
||||
if (!(sd->sd_memdata = (char*)malloc(scn->s_size))) {
|
||||
seterr(ERROR_IO_2BIG);
|
||||
free(sd);
|
||||
return NULL;
|
||||
}
|
||||
else if (elf->e_rawdata) {
|
||||
memcpy(sd->sd_memdata, elf->e_rawdata + scn->s_offset, scn->s_size);
|
||||
}
|
||||
else if (!_elf_read(elf, sd->sd_memdata, scn->s_offset, scn->s_size)) {
|
||||
free(sd->sd_memdata);
|
||||
free(sd);
|
||||
return NULL;
|
||||
}
|
||||
sd->sd_data.d_buf = sd->sd_memdata;
|
||||
sd->sd_free_data = 1;
|
||||
}
|
||||
scn->s_rawdata = sd;
|
||||
return &sd->sd_data;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* rawfile.c - implementation of the elf_rawfile(3) function.
|
||||
* Copyright (C) 1995 - 2009 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: rawfile.c,v 1.8 2009/05/22 17:07:46 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
char*
|
||||
elf_rawfile(Elf *elf, size_t *ptr) {
|
||||
size_t tmp;
|
||||
|
||||
if (!ptr) {
|
||||
ptr = &tmp;
|
||||
}
|
||||
*ptr = 0;
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (!elf->e_readable) {
|
||||
return NULL;
|
||||
}
|
||||
else if (elf->e_size) {
|
||||
if (!elf->e_rawdata) {
|
||||
elf_assert(elf->e_data);
|
||||
if (!elf->e_cooked) {
|
||||
elf->e_rawdata = elf->e_data;
|
||||
}
|
||||
else if (!(elf->e_rawdata = _elf_read(elf, NULL, 0, elf->e_size))) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
*ptr = elf->e_size;
|
||||
}
|
||||
return elf->e_rawdata;
|
||||
}
|
||||
Vendored
+150
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* strptr.c - implementation of the elf_strptr(3) function.
|
||||
* Copyright (C) 1995 - 2007 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: strptr.c,v 1.12 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
char*
|
||||
elf_strptr(Elf *elf, size_t section, size_t offset) {
|
||||
Elf_Data *data;
|
||||
Elf_Scn *scn;
|
||||
size_t n;
|
||||
char *s;
|
||||
|
||||
if (!elf) {
|
||||
return NULL;
|
||||
}
|
||||
elf_assert(elf->e_magic == ELF_MAGIC);
|
||||
if (!(scn = elf_getscn(elf, section))) {
|
||||
return NULL;
|
||||
}
|
||||
if (scn->s_index == SHN_UNDEF) {
|
||||
seterr(ERROR_NOSTRTAB);
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
* checking the section header is more appropriate
|
||||
*/
|
||||
if (elf->e_class == ELFCLASS32) {
|
||||
if (scn->s_shdr32.sh_type != SHT_STRTAB) {
|
||||
seterr(ERROR_NOSTRTAB);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#if __LIBELF64
|
||||
else if (elf->e_class == ELFCLASS64) {
|
||||
if (scn->s_shdr64.sh_type != SHT_STRTAB) {
|
||||
seterr(ERROR_NOSTRTAB);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif /* __LIBELF64 */
|
||||
else if (valid_class(elf->e_class)) {
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
seterr(ERROR_UNKNOWN_CLASS);
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
* Find matching buffer
|
||||
*/
|
||||
n = 0;
|
||||
data = NULL;
|
||||
if (elf->e_elf_flags & ELF_F_LAYOUT) {
|
||||
/*
|
||||
* Programmer is responsible for d_off
|
||||
* Note: buffers may be in any order!
|
||||
*/
|
||||
while ((data = elf_getdata(scn, data))) {
|
||||
n = data->d_off;
|
||||
if (offset >= n && offset - n < data->d_size) {
|
||||
/*
|
||||
* Found it
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Calculate offsets myself
|
||||
*/
|
||||
while ((data = elf_getdata(scn, data))) {
|
||||
if (data->d_align > 1) {
|
||||
n += data->d_align - 1;
|
||||
n -= n % data->d_align;
|
||||
}
|
||||
if (offset < n) {
|
||||
/*
|
||||
* Invalid offset: points into a hole
|
||||
*/
|
||||
seterr(ERROR_BADSTROFF);
|
||||
return NULL;
|
||||
}
|
||||
if (offset - n < data->d_size) {
|
||||
/*
|
||||
* Found it
|
||||
*/
|
||||
break;
|
||||
}
|
||||
n += data->d_size;
|
||||
}
|
||||
}
|
||||
if (data == NULL) {
|
||||
/*
|
||||
* Not found
|
||||
*/
|
||||
seterr(ERROR_BADSTROFF);
|
||||
return NULL;
|
||||
}
|
||||
if (data->d_buf == NULL) {
|
||||
/*
|
||||
* Buffer is NULL (usually the programmers' fault)
|
||||
*/
|
||||
seterr(ERROR_NULLBUF);
|
||||
return NULL;
|
||||
}
|
||||
offset -= n;
|
||||
s = (char*)data->d_buf;
|
||||
if (!(_elf_sanity_checks & SANITY_CHECK_STRPTR)) {
|
||||
return s + offset;
|
||||
}
|
||||
/*
|
||||
* Perform extra sanity check
|
||||
*/
|
||||
for (n = offset; n < data->d_size; n++) {
|
||||
if (s[n] == '\0') {
|
||||
/*
|
||||
* Return properly NUL terminated string
|
||||
*/
|
||||
return s + offset;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* String is not NUL terminated
|
||||
* Return error to avoid SEGV in application
|
||||
*/
|
||||
seterr(ERROR_UNTERM);
|
||||
return NULL;
|
||||
}
|
||||
Vendored
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
swap64.c - 64-bit byte swapping functions.
|
||||
Copyright (C) 1995 - 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#if __LIBELF64
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: swap64.c,v 1.6 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
__libelf_u64_t
|
||||
_elf_load_u64L(const unsigned char *from) {
|
||||
return ((__libelf_u64_t)__load_u32L(from + 4) << 32)
|
||||
| (__libelf_u64_t)__load_u32L(from);
|
||||
}
|
||||
|
||||
__libelf_u64_t
|
||||
_elf_load_u64M(const unsigned char *from) {
|
||||
return ((__libelf_u64_t)__load_u32M(from) << 32)
|
||||
| (__libelf_u64_t)__load_u32M(from + 4);
|
||||
}
|
||||
|
||||
__libelf_i64_t
|
||||
_elf_load_i64L(const unsigned char *from) {
|
||||
return ((__libelf_i64_t)__load_i32L(from + 4) << 32)
|
||||
| (__libelf_u64_t)__load_u32L(from);
|
||||
}
|
||||
|
||||
__libelf_i64_t
|
||||
_elf_load_i64M(const unsigned char *from) {
|
||||
return ((__libelf_i64_t)__load_i32M(from) << 32)
|
||||
| (__libelf_u64_t)__load_u32M(from + 4);
|
||||
}
|
||||
|
||||
void
|
||||
_elf_store_u64L(unsigned char *to, __libelf_u64_t v) {
|
||||
__store_u32L(to, (__libelf_u32_t)v);
|
||||
v >>= 32;
|
||||
__store_u32L(to + 4, (__libelf_u32_t)v);
|
||||
}
|
||||
|
||||
void
|
||||
_elf_store_u64M(unsigned char *to, __libelf_u64_t v) {
|
||||
__store_u32M(to + 4, (__libelf_u32_t)v);
|
||||
v >>= 32;
|
||||
__store_u32M(to, (__libelf_u32_t)v);
|
||||
}
|
||||
|
||||
void
|
||||
_elf_store_i64L(unsigned char *to, __libelf_u64_t v) {
|
||||
__store_u32L(to, (__libelf_u32_t)v);
|
||||
v >>= 32;
|
||||
__store_i32L(to + 4, (__libelf_u32_t)v);
|
||||
}
|
||||
|
||||
void
|
||||
_elf_store_i64M(unsigned char *to, __libelf_u64_t v) {
|
||||
__store_u32M(to + 4, (__libelf_u32_t)v);
|
||||
v >>= 32;
|
||||
__store_i32M(to, (__libelf_u32_t)v);
|
||||
}
|
||||
|
||||
#endif /* __LIBELF64 */
|
||||
Vendored
+1021
File diff suppressed because it is too large.
Load diff
Vendored
+241
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* verdef.h - copy versioning information.
|
||||
* Copyright (C) 2001 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char verdef_h_rcsid[] = "@(#) $Id: verdef.h,v 1.13 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#if VER_DEF_CURRENT != 1
|
||||
#error libelf currently does not support VER_DEF_CURRENT != 1
|
||||
#endif /* VER_DEF_CURRENT != 1 */
|
||||
|
||||
#if TOFILE
|
||||
|
||||
static void
|
||||
__store_verdaux(verdaux_ftype *dst, const verdaux_mtype *src, unsigned enc) {
|
||||
if (enc == ELFDATA2LSB) {
|
||||
__store_u32L(dst->vda_name, src->vda_name);
|
||||
__store_u32L(dst->vda_next, src->vda_next);
|
||||
}
|
||||
else {
|
||||
__store_u32M(dst->vda_name, src->vda_name);
|
||||
__store_u32M(dst->vda_next, src->vda_next);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
__store_verdef(verdef_ftype *dst, const verdef_mtype *src, unsigned enc) {
|
||||
if (enc == ELFDATA2LSB) {
|
||||
__store_u16L(dst->vd_version, src->vd_version);
|
||||
__store_u16L(dst->vd_flags, src->vd_flags);
|
||||
__store_u16L(dst->vd_ndx, src->vd_ndx);
|
||||
__store_u16L(dst->vd_cnt, src->vd_cnt);
|
||||
__store_u32L(dst->vd_hash, src->vd_hash);
|
||||
__store_u32L(dst->vd_aux, src->vd_aux);
|
||||
__store_u32L(dst->vd_next, src->vd_next);
|
||||
}
|
||||
else {
|
||||
__store_u16M(dst->vd_version, src->vd_version);
|
||||
__store_u16M(dst->vd_flags, src->vd_flags);
|
||||
__store_u16M(dst->vd_ndx, src->vd_ndx);
|
||||
__store_u16M(dst->vd_cnt, src->vd_cnt);
|
||||
__store_u32M(dst->vd_hash, src->vd_hash);
|
||||
__store_u32M(dst->vd_aux, src->vd_aux);
|
||||
__store_u32M(dst->vd_next, src->vd_next);
|
||||
}
|
||||
}
|
||||
|
||||
typedef verdaux_mtype verdaux_stype;
|
||||
typedef verdaux_ftype verdaux_dtype;
|
||||
typedef verdef_mtype verdef_stype;
|
||||
typedef verdef_ftype verdef_dtype;
|
||||
typedef align_mtype verdef_atype;
|
||||
|
||||
#define copy_verdaux_srctotmp(d, s, e) (*(d) = *(s))
|
||||
#define copy_verdaux_tmptodst(d, s, e) __store_verdaux((d), (s), (e))
|
||||
#define copy_verdef_srctotmp(d, s, e) (*(d) = *(s))
|
||||
#define copy_verdef_tmptodst(d, s, e) __store_verdef((d), (s), (e))
|
||||
|
||||
#define translator_suffix _tof
|
||||
|
||||
#else /* TOFILE */
|
||||
|
||||
static void
|
||||
__load_verdaux(verdaux_mtype *dst, const verdaux_ftype *src, unsigned enc) {
|
||||
if (enc == ELFDATA2LSB) {
|
||||
dst->vda_name = __load_u32L(src->vda_name);
|
||||
dst->vda_next = __load_u32L(src->vda_next);
|
||||
}
|
||||
else {
|
||||
dst->vda_name = __load_u32M(src->vda_name);
|
||||
dst->vda_next = __load_u32M(src->vda_next);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
__load_verdef(verdef_mtype *dst, const verdef_ftype *src, unsigned enc) {
|
||||
if (enc == ELFDATA2LSB) {
|
||||
dst->vd_version = __load_u16L(src->vd_version);
|
||||
dst->vd_flags = __load_u16L(src->vd_flags);
|
||||
dst->vd_ndx = __load_u16L(src->vd_ndx);
|
||||
dst->vd_cnt = __load_u16L(src->vd_cnt);
|
||||
dst->vd_hash = __load_u32L(src->vd_hash);
|
||||
dst->vd_aux = __load_u32L(src->vd_aux);
|
||||
dst->vd_next = __load_u32L(src->vd_next);
|
||||
}
|
||||
else {
|
||||
dst->vd_version = __load_u16M(src->vd_version);
|
||||
dst->vd_flags = __load_u16M(src->vd_flags);
|
||||
dst->vd_ndx = __load_u16M(src->vd_ndx);
|
||||
dst->vd_cnt = __load_u16M(src->vd_cnt);
|
||||
dst->vd_hash = __load_u32M(src->vd_hash);
|
||||
dst->vd_aux = __load_u32M(src->vd_aux);
|
||||
dst->vd_next = __load_u32M(src->vd_next);
|
||||
}
|
||||
}
|
||||
|
||||
typedef verdaux_ftype verdaux_stype;
|
||||
typedef verdaux_mtype verdaux_dtype;
|
||||
typedef verdef_ftype verdef_stype;
|
||||
typedef verdef_mtype verdef_dtype;
|
||||
typedef align_ftype verdef_atype;
|
||||
|
||||
#define copy_verdaux_srctotmp(d, s, e) __load_verdaux((d), (s), (e))
|
||||
#define copy_verdaux_tmptodst(d, s, e) (*(d) = *(s))
|
||||
#define copy_verdef_srctotmp(d, s, e) __load_verdef((d), (s), (e))
|
||||
#define copy_verdef_tmptodst(d, s, e) (*(d) = *(s))
|
||||
|
||||
#define translator_suffix _tom
|
||||
|
||||
#endif /* TOFILE */
|
||||
|
||||
#define cat3(a,b,c) a##b##c
|
||||
#define xlt3(p,e,s) cat3(p,e,s)
|
||||
#define xltprefix(x) xlt3(x,_,class_suffix)
|
||||
#define translator(x,e) xlt3(xltprefix(_elf_##x),e,translator_suffix)
|
||||
|
||||
static size_t
|
||||
xlt_verdef(unsigned char *dst, const unsigned char *src, size_t n, unsigned enc) {
|
||||
size_t off;
|
||||
|
||||
if (sizeof(verdef_stype) != sizeof(verdef_dtype)
|
||||
|| sizeof(verdaux_stype) != sizeof(verdaux_dtype)) {
|
||||
/* never happens for ELF v1 and Verneed v1 */
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return (size_t)-1;
|
||||
}
|
||||
/* size translation shortcut */
|
||||
if (dst == NULL) {
|
||||
return n;
|
||||
}
|
||||
if (src == NULL) {
|
||||
seterr(ERROR_NULLBUF);
|
||||
return (size_t)-1;
|
||||
}
|
||||
off = 0;
|
||||
while (off + sizeof(verdef_stype) <= n) {
|
||||
const verdef_stype *svd;
|
||||
verdef_dtype *dvd;
|
||||
verdef_mtype vd;
|
||||
size_t acount;
|
||||
size_t aoff;
|
||||
|
||||
/*
|
||||
* check for proper alignment
|
||||
*/
|
||||
if (off % sizeof(verdef_atype)) {
|
||||
seterr(ERROR_VERDEF_FORMAT);
|
||||
return (size_t)-1;
|
||||
}
|
||||
/*
|
||||
* copy and check src
|
||||
*/
|
||||
svd = (verdef_stype*)(src + off);
|
||||
dvd = (verdef_dtype*)(dst + off);
|
||||
copy_verdef_srctotmp(&vd, svd, enc);
|
||||
if (vd.vd_version < 1
|
||||
|| vd.vd_version > VER_DEF_CURRENT) {
|
||||
seterr(ERROR_VERDEF_VERSION);
|
||||
return (size_t)-1;
|
||||
}
|
||||
if (vd.vd_cnt < 1
|
||||
|| vd.vd_aux == 0) {
|
||||
seterr(ERROR_VERDEF_FORMAT);
|
||||
return (size_t)-1;
|
||||
}
|
||||
copy_verdef_tmptodst(dvd, &vd, enc);
|
||||
/*
|
||||
* copy aux array
|
||||
*/
|
||||
aoff = off + vd.vd_aux;
|
||||
for (acount = 0; acount < vd.vd_cnt; acount++) {
|
||||
const verdaux_stype *svda;
|
||||
verdaux_dtype *dvda;
|
||||
verdaux_mtype vda;
|
||||
|
||||
/*
|
||||
* are we still inside the buffer limits?
|
||||
*/
|
||||
if (aoff + sizeof(verdaux_stype) > n) {
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* check for proper alignment
|
||||
*/
|
||||
if (aoff % sizeof(verdef_atype)) {
|
||||
seterr(ERROR_VERDEF_FORMAT);
|
||||
return (size_t)-1;
|
||||
}
|
||||
/*
|
||||
* copy and check src
|
||||
*/
|
||||
svda = (verdaux_stype*)(src + aoff);
|
||||
dvda = (verdaux_dtype*)(dst + aoff);
|
||||
copy_verdaux_srctotmp(&vda, svda, enc);
|
||||
copy_verdaux_tmptodst(dvda, &vda, enc);
|
||||
/*
|
||||
* advance to next verdaux
|
||||
*/
|
||||
if (vda.vda_next == 0) {
|
||||
/* end of list */
|
||||
break;
|
||||
}
|
||||
aoff += vda.vda_next;
|
||||
}
|
||||
/*
|
||||
* advance to next verdef
|
||||
*/
|
||||
if (vd.vd_next == 0) {
|
||||
/* end of list */
|
||||
break;
|
||||
}
|
||||
off += vd.vd_next;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t
|
||||
translator(verdef,L11)(unsigned char *dst, const unsigned char *src, size_t n) {
|
||||
return xlt_verdef(dst, src, n, ELFDATA2LSB);
|
||||
}
|
||||
|
||||
size_t
|
||||
translator(verdef,M11)(unsigned char *dst, const unsigned char *src, size_t n) {
|
||||
return xlt_verdef(dst, src, n, ELFDATA2MSB);
|
||||
}
|
||||
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
verdef_32_tof.c - copy 32-bit versioning information.
|
||||
Copyright (C) 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
#include <ext_types.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#if __LIBELF_SYMBOL_VERSIONS
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: verdef_32_tof.c,v 1.5 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
typedef Elf32_Verdaux verdaux_mtype;
|
||||
typedef Elf32_Verdef verdef_mtype;
|
||||
typedef Elf32_Vernaux vernaux_mtype;
|
||||
typedef Elf32_Verneed verneed_mtype;
|
||||
typedef Elf32_Word align_mtype;
|
||||
|
||||
typedef __ext_Elf32_Verdaux verdaux_ftype;
|
||||
typedef __ext_Elf32_Verdef verdef_ftype;
|
||||
typedef __ext_Elf32_Vernaux vernaux_ftype;
|
||||
typedef __ext_Elf32_Verneed verneed_ftype;
|
||||
typedef __ext_Elf32_Word align_ftype;
|
||||
|
||||
#define class_suffix 32
|
||||
|
||||
#undef TOFILE
|
||||
#define TOFILE 1
|
||||
|
||||
/*
|
||||
* Include shared code
|
||||
*/
|
||||
#include "verdef.h"
|
||||
#include "verneed.h"
|
||||
|
||||
#endif /* __LIBELF_SYMBOL_VERSIONS */
|
||||
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
verdef_32_tom.c - copy 32-bit versioning information.
|
||||
Copyright (C) 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
#include <ext_types.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#if __LIBELF_SYMBOL_VERSIONS
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: verdef_32_tom.c,v 1.5 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
typedef Elf32_Verdaux verdaux_mtype;
|
||||
typedef Elf32_Verdef verdef_mtype;
|
||||
typedef Elf32_Vernaux vernaux_mtype;
|
||||
typedef Elf32_Verneed verneed_mtype;
|
||||
typedef Elf32_Word align_mtype;
|
||||
|
||||
typedef __ext_Elf32_Verdaux verdaux_ftype;
|
||||
typedef __ext_Elf32_Verdef verdef_ftype;
|
||||
typedef __ext_Elf32_Vernaux vernaux_ftype;
|
||||
typedef __ext_Elf32_Verneed verneed_ftype;
|
||||
typedef __ext_Elf32_Word align_ftype;
|
||||
|
||||
#define class_suffix 32
|
||||
|
||||
#undef TOFILE
|
||||
#define TOFILE 0
|
||||
|
||||
/*
|
||||
* Include shared code
|
||||
*/
|
||||
#include "verdef.h"
|
||||
#include "verneed.h"
|
||||
|
||||
#endif /* __LIBELF_SYMBOL_VERSIONS */
|
||||
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
verdef_64_tof.c - copy 64-bit versioning information.
|
||||
Copyright (C) 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
#include <ext_types.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#if __LIBELF64 && __LIBELF_SYMBOL_VERSIONS
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: verdef_64_tof.c,v 1.5 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
typedef Elf64_Verdaux verdaux_mtype;
|
||||
typedef Elf64_Verdef verdef_mtype;
|
||||
typedef Elf64_Vernaux vernaux_mtype;
|
||||
typedef Elf64_Verneed verneed_mtype;
|
||||
typedef Elf64_Word align_mtype;
|
||||
|
||||
typedef __ext_Elf64_Verdaux verdaux_ftype;
|
||||
typedef __ext_Elf64_Verdef verdef_ftype;
|
||||
typedef __ext_Elf64_Vernaux vernaux_ftype;
|
||||
typedef __ext_Elf64_Verneed verneed_ftype;
|
||||
typedef __ext_Elf64_Word align_ftype;
|
||||
|
||||
#define class_suffix 64
|
||||
|
||||
#undef TOFILE
|
||||
#define TOFILE 1
|
||||
|
||||
/*
|
||||
* Include shared code
|
||||
*/
|
||||
#include "verdef.h"
|
||||
#include "verneed.h"
|
||||
|
||||
#endif /* __LIBELF64 && __LIBELF_SYMBOL_VERSIONS */
|
||||
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
verdef_64_tom.c - copy 64-bit versioning information.
|
||||
Copyright (C) 2001 Michael Riepe
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <private.h>
|
||||
#include <ext_types.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#if __LIBELF64 && __LIBELF_SYMBOL_VERSIONS
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "@(#) $Id: verdef_64_tom.c,v 1.5 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
typedef Elf64_Verdaux verdaux_mtype;
|
||||
typedef Elf64_Verdef verdef_mtype;
|
||||
typedef Elf64_Vernaux vernaux_mtype;
|
||||
typedef Elf64_Verneed verneed_mtype;
|
||||
typedef Elf64_Word align_mtype;
|
||||
|
||||
typedef __ext_Elf64_Verdaux verdaux_ftype;
|
||||
typedef __ext_Elf64_Verdef verdef_ftype;
|
||||
typedef __ext_Elf64_Vernaux vernaux_ftype;
|
||||
typedef __ext_Elf64_Verneed verneed_ftype;
|
||||
typedef __ext_Elf64_Word align_ftype;
|
||||
|
||||
#define class_suffix 64
|
||||
|
||||
#undef TOFILE
|
||||
#define TOFILE 0
|
||||
|
||||
/*
|
||||
* Include shared code
|
||||
*/
|
||||
#include "verdef.h"
|
||||
#include "verneed.h"
|
||||
|
||||
#endif /* __LIBELF64 && __LIBELF_SYMBOL_VERSIONS */
|
||||
Vendored
+245
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* verneed.h - copy versioning information.
|
||||
* Copyright (C) 2001 - 2006 Michael Riepe
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char verneed_h_rcsid[] = "@(#) $Id: verneed.h,v 1.13 2008/05/23 08:15:35 michael Exp $";
|
||||
#endif /* lint */
|
||||
|
||||
#if VER_NEED_CURRENT != 1
|
||||
#error libelf currently does not support VER_NEED_CURRENT != 1
|
||||
#endif /* VER_NEED_CURRENT != 1 */
|
||||
|
||||
#if TOFILE
|
||||
|
||||
static void
|
||||
__store_vernaux(vernaux_ftype *dst, const vernaux_mtype *src, unsigned enc) {
|
||||
if (enc == ELFDATA2LSB) {
|
||||
__store_u32L(dst->vna_hash, src->vna_hash);
|
||||
__store_u16L(dst->vna_flags, src->vna_flags);
|
||||
__store_u16L(dst->vna_other, src->vna_other);
|
||||
__store_u32L(dst->vna_name, src->vna_name);
|
||||
__store_u32L(dst->vna_next, src->vna_next);
|
||||
}
|
||||
else {
|
||||
__store_u32M(dst->vna_hash, src->vna_hash);
|
||||
__store_u16M(dst->vna_flags, src->vna_flags);
|
||||
__store_u16M(dst->vna_other, src->vna_other);
|
||||
__store_u32M(dst->vna_name, src->vna_name);
|
||||
__store_u32M(dst->vna_next, src->vna_next);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
__store_verneed(verneed_ftype *dst, const verneed_mtype *src, unsigned enc) {
|
||||
if (enc == ELFDATA2LSB) {
|
||||
__store_u16L(dst->vn_version, src->vn_version);
|
||||
__store_u16L(dst->vn_cnt, src->vn_cnt);
|
||||
__store_u32L(dst->vn_file, src->vn_file);
|
||||
__store_u32L(dst->vn_aux, src->vn_aux);
|
||||
__store_u32L(dst->vn_next, src->vn_next);
|
||||
}
|
||||
else {
|
||||
__store_u16M(dst->vn_version, src->vn_version);
|
||||
__store_u16M(dst->vn_cnt, src->vn_cnt);
|
||||
__store_u32M(dst->vn_file, src->vn_file);
|
||||
__store_u32M(dst->vn_aux, src->vn_aux);
|
||||
__store_u32M(dst->vn_next, src->vn_next);
|
||||
}
|
||||
}
|
||||
|
||||
typedef vernaux_mtype vernaux_stype;
|
||||
typedef vernaux_ftype vernaux_dtype;
|
||||
typedef verneed_mtype verneed_stype;
|
||||
typedef verneed_ftype verneed_dtype;
|
||||
typedef align_mtype verneed_atype;
|
||||
|
||||
#define copy_vernaux_srctotmp(d, s, e) (*(d) = *(s))
|
||||
#define copy_vernaux_tmptodst(d, s, e) __store_vernaux((d), (s), (e))
|
||||
#define copy_verneed_srctotmp(d, s, e) (*(d) = *(s))
|
||||
#define copy_verneed_tmptodst(d, s, e) __store_verneed((d), (s), (e))
|
||||
|
||||
#define translator_suffix _tof
|
||||
|
||||
#else /* TOFILE */
|
||||
|
||||
static void
|
||||
__load_vernaux(vernaux_mtype *dst, const vernaux_ftype *src, unsigned enc) {
|
||||
if (enc == ELFDATA2LSB) {
|
||||
dst->vna_hash = __load_u32L(src->vna_hash);
|
||||
dst->vna_flags = __load_u16L(src->vna_flags);
|
||||
dst->vna_other = __load_u16L(src->vna_other);
|
||||
dst->vna_name = __load_u32L(src->vna_name);
|
||||
dst->vna_next = __load_u32L(src->vna_next);
|
||||
}
|
||||
else {
|
||||
dst->vna_hash = __load_u32M(src->vna_hash);
|
||||
dst->vna_flags = __load_u16M(src->vna_flags);
|
||||
dst->vna_other = __load_u16M(src->vna_other);
|
||||
dst->vna_name = __load_u32M(src->vna_name);
|
||||
dst->vna_next = __load_u32M(src->vna_next);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
__load_verneed(verneed_mtype *dst, const verneed_ftype *src, unsigned enc) {
|
||||
if (enc == ELFDATA2LSB) {
|
||||
dst->vn_version = __load_u16L(src->vn_version);
|
||||
dst->vn_cnt = __load_u16L(src->vn_cnt);
|
||||
dst->vn_file = __load_u32L(src->vn_file);
|
||||
dst->vn_aux = __load_u32L(src->vn_aux);
|
||||
dst->vn_next = __load_u32L(src->vn_next);
|
||||
}
|
||||
else {
|
||||
dst->vn_version = __load_u16M(src->vn_version);
|
||||
dst->vn_cnt = __load_u16M(src->vn_cnt);
|
||||
dst->vn_file = __load_u32M(src->vn_file);
|
||||
dst->vn_aux = __load_u32M(src->vn_aux);
|
||||
dst->vn_next = __load_u32M(src->vn_next);
|
||||
}
|
||||
}
|
||||
|
||||
typedef vernaux_ftype vernaux_stype;
|
||||
typedef vernaux_mtype vernaux_dtype;
|
||||
typedef verneed_ftype verneed_stype;
|
||||
typedef verneed_mtype verneed_dtype;
|
||||
typedef align_ftype verneed_atype;
|
||||
|
||||
#define copy_vernaux_srctotmp(d, s, e) __load_vernaux((d), (s), (e))
|
||||
#define copy_vernaux_tmptodst(d, s, e) (*(d) = *(s))
|
||||
#define copy_verneed_srctotmp(d, s, e) __load_verneed((d), (s), (e))
|
||||
#define copy_verneed_tmptodst(d, s, e) (*(d) = *(s))
|
||||
|
||||
#define translator_suffix _tom
|
||||
|
||||
#endif /* TOFILE */
|
||||
|
||||
#define cat3(a,b,c) a##b##c
|
||||
#define xlt3(p,e,s) cat3(p,e,s)
|
||||
#define xltprefix(x) xlt3(x,_,class_suffix)
|
||||
#define translator(x,e) xlt3(xltprefix(_elf_##x),e,translator_suffix)
|
||||
|
||||
static size_t
|
||||
xlt_verneed(unsigned char *dst, const unsigned char *src, size_t n, unsigned enc) {
|
||||
size_t off;
|
||||
|
||||
if (sizeof(verneed_stype) != sizeof(verneed_dtype)
|
||||
|| sizeof(vernaux_stype) != sizeof(vernaux_dtype)) {
|
||||
/* never happens for ELF v1 and Verneed v1 */
|
||||
seterr(ERROR_UNIMPLEMENTED);
|
||||
return (size_t)-1;
|
||||
}
|
||||
/* size translation shortcut */
|
||||
if (dst == NULL) {
|
||||
return n;
|
||||
}
|
||||
if (src == NULL) {
|
||||
seterr(ERROR_NULLBUF);
|
||||
return (size_t)-1;
|
||||
}
|
||||
off = 0;
|
||||
while (off + sizeof(verneed_stype) <= n) {
|
||||
const verneed_stype *svn;
|
||||
verneed_dtype *dvn;
|
||||
verneed_mtype vn;
|
||||
size_t acount;
|
||||
size_t aoff;
|
||||
|
||||
/*
|
||||
* check for proper alignment
|
||||
*/
|
||||
if (off % sizeof(verneed_atype)) {
|
||||
seterr(ERROR_VERNEED_FORMAT);
|
||||
return (size_t)-1;
|
||||
}
|
||||
/*
|
||||
* copy and check src
|
||||
*/
|
||||
svn = (verneed_stype*)(src + off);
|
||||
dvn = (verneed_dtype*)(dst + off);
|
||||
copy_verneed_srctotmp(&vn, svn, enc);
|
||||
if (vn.vn_version < 1
|
||||
|| vn.vn_version > VER_NEED_CURRENT) {
|
||||
seterr(ERROR_VERNEED_VERSION);
|
||||
return (size_t)-1;
|
||||
}
|
||||
if (vn.vn_cnt < 1
|
||||
|| vn.vn_aux == 0) {
|
||||
seterr(ERROR_VERNEED_FORMAT);
|
||||
return (size_t)-1;
|
||||
}
|
||||
copy_verneed_tmptodst(dvn, &vn, enc);
|
||||
/*
|
||||
* copy aux array
|
||||
*/
|
||||
aoff = off + vn.vn_aux;
|
||||
for (acount = 0; acount < vn.vn_cnt; acount++) {
|
||||
const vernaux_stype *svna;
|
||||
vernaux_dtype *dvna;
|
||||
vernaux_mtype vna;
|
||||
|
||||
/*
|
||||
* are we still inside the buffer limits?
|
||||
*/
|
||||
if (aoff + sizeof(vernaux_stype) > n) {
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* check for proper alignment
|
||||
*/
|
||||
if (aoff % sizeof(verneed_atype)) {
|
||||
seterr(ERROR_VERNEED_FORMAT);
|
||||
return (size_t)-1;
|
||||
}
|
||||
/*
|
||||
* copy and check src
|
||||
*/
|
||||
svna = (vernaux_stype*)(src + aoff);
|
||||
dvna = (vernaux_dtype*)(dst + aoff);
|
||||
copy_vernaux_srctotmp(&vna, svna, enc);
|
||||
copy_vernaux_tmptodst(dvna, &vna, enc);
|
||||
/*
|
||||
* advance to next vernaux
|
||||
*/
|
||||
if (vna.vna_next == 0) {
|
||||
/* end of list */
|
||||
break;
|
||||
}
|
||||
aoff += vna.vna_next;
|
||||
}
|
||||
/*
|
||||
* advance to next verneed
|
||||
*/
|
||||
if (vn.vn_next == 0) {
|
||||
/* end of list */
|
||||
break;
|
||||
}
|
||||
off += vn.vn_next;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t
|
||||
translator(verneed,L11)(unsigned char *dst, const unsigned char *src, size_t n) {
|
||||
return xlt_verneed(dst, src, n, ELFDATA2LSB);
|
||||
}
|
||||
|
||||
size_t
|
||||
translator(verneed,M11)(unsigned char *dst, const unsigned char *src, size_t n) {
|
||||
return xlt_verneed(dst, src, n, ELFDATA2MSB);
|
||||
}
|
||||
Loaded 100 of 198 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user