mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 19:34:43 +01:00
Compare commits
1124
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4894493155 | ||
|
|
274b8bdee7 | ||
|
|
bd168eeaad | ||
|
|
f509c4c435 | ||
|
|
2d3b605d6f | ||
|
|
2825ff93f6 | ||
|
|
f07e5bc8ea | ||
|
|
4f3d99485b | ||
|
|
be153092d7 | ||
|
|
d29096165b | ||
|
|
a33296462b | ||
|
|
10349c7e01 | ||
|
|
d529d2b19c | ||
|
|
63d6cd97cb | ||
|
|
556bf008c9 | ||
|
|
f08e0f77bd | ||
|
|
c1e644e298 | ||
|
|
decd933ec9 | ||
|
|
6cc65521df | ||
|
|
b21a8f477d | ||
|
|
ec42787081 | ||
|
|
b9486dfe71 | ||
|
|
608cb943ff | ||
|
|
de653435c9 | ||
|
|
a47a52fd33 | ||
|
|
9173804e1f | ||
|
|
bcb1ab7077 | ||
|
|
641b3c3a27 | ||
|
|
70e16c24be | ||
|
|
2d950f8de6 | ||
|
|
8c4827362a | ||
|
|
ada88fa941 | ||
|
|
c6bb93ef85 | ||
|
|
70bb51efed | ||
|
|
159383909b | ||
|
|
a939b979e6 | ||
|
|
1aea294e0b | ||
|
|
785731e6ee | ||
|
|
4a29037187 | ||
|
|
bad3094753 | ||
|
|
c56e7e0d33 | ||
|
|
b270f2184a | ||
|
|
c9696ffda7 | ||
|
|
2d2c13fa44 | ||
|
|
59a43aeeb3 | ||
|
|
fe9924ea93 | ||
|
|
e6a450f7ed | ||
|
|
52fb1ea4d6 | ||
|
|
f5bffdc45d | ||
|
|
8d5ff86730 | ||
|
|
285135278e | ||
|
|
175bf9790f | ||
|
|
1e69c26406 | ||
|
|
ecad4f2956 | ||
|
|
4791321c6b | ||
|
|
d59831fba9 | ||
|
|
0259d93a5f | ||
|
|
ef9d30dc02 | ||
|
|
32d57bb4c9 | ||
|
|
2b61e1aeed | ||
|
|
86656d3255 | ||
|
|
3e9b5f9cb4 | ||
|
|
0a6b754d8d | ||
|
|
05ff977879 | ||
|
|
3f7e5cf977 | ||
|
|
8d16a7ecc8 | ||
|
|
b243620314 | ||
|
|
0979eb2d5b | ||
|
|
dc7f46c388 | ||
|
|
69262873f5 | ||
|
|
818f20ada7 | ||
|
|
d4ed5bacb5 | ||
|
|
e25f9792ba | ||
|
|
3acc35a3fc | ||
|
|
13501768c0 | ||
|
|
e1ad2787bf | ||
|
|
13adfb6d0e | ||
|
|
d47f9a7cbf | ||
|
|
9a109dc04d | ||
|
|
0baf3d70f0 | ||
|
|
d322f3e58d | ||
|
|
3c716c531d | ||
|
|
dd700cf503 | ||
|
|
3e31ac95cd | ||
|
|
67c5e4bd27 | ||
|
|
6b84ce2f40 | ||
|
|
cb0bae6ef8 | ||
|
|
92e864d54d | ||
|
|
de330f7d1a | ||
|
|
922dfe46d8 | ||
|
|
320253280e | ||
|
|
b00337aa84 | ||
|
|
ec8d8f8d52 | ||
|
|
9668f9bcc8 | ||
|
|
7b4e38e0a6 | ||
|
|
b6546c8a6a | ||
|
|
d206b50808 | ||
|
|
d6063caca2 | ||
|
|
a4ab3288cc | ||
|
|
be0a15870e | ||
|
|
ef3e1ddfdf | ||
|
|
06f5f562aa | ||
|
|
f1836b812a | ||
|
|
4a2aa32363 | ||
|
|
3a109e38e0 | ||
|
|
672eda858a | ||
|
|
291827ef18 | ||
|
|
bcf16a2550 | ||
|
|
d462bb102e | ||
|
|
e3d8f93fdd | ||
|
|
c6cae98b06 | ||
|
|
6ceab96a3b | ||
|
|
94f52bf536 | ||
|
|
71b0ec5043 | ||
|
|
6ef2311075 | ||
|
|
9c8e81767c | ||
|
|
7144d76f46 | ||
|
|
be568c1ee7 | ||
|
|
bd8cb93189 | ||
|
|
75fdc89614 | ||
|
|
ce16f788cf | ||
|
|
d00d48e97c | ||
|
|
7a924bc194 | ||
|
|
0195cf74be | ||
|
|
2c08ee2b9e | ||
|
|
062db0d664 | ||
|
|
1b6a4dc3b7 | ||
|
|
bc36e9dd0c | ||
|
|
7eb3fa8a45 | ||
|
|
7337d34dc1 | ||
|
|
16b906ec80 | ||
|
|
099426dba3 | ||
|
|
eaeae9c9f9 | ||
|
|
e3a1b47d04 | ||
|
|
0f1b409dfb | ||
|
|
4e91a6e488 | ||
|
|
8cf50cdd84 | ||
|
|
aa8916c463 | ||
|
|
3c996673c2 | ||
|
|
0299f215cc | ||
|
|
c019b24d18 | ||
|
|
4e3c4a518c | ||
|
|
a7f1456b9c | ||
|
|
c1f72c5bcd | ||
|
|
a5b108bc51 | ||
|
|
a7261a4ea8 | ||
|
|
8d64d78a5f | ||
|
|
5f391b7e81 | ||
|
|
c6864fc4fc | ||
|
|
ab1413285d | ||
|
|
598199b3a5 | ||
|
|
da600acca1 | ||
|
|
e2e226b38b | ||
|
|
8da1d91e69 | ||
|
|
19ffddc927 | ||
|
|
14134c617e | ||
|
|
e1d109ba5e | ||
|
|
b9f759ce33 | ||
|
|
c8d2ac2c6c | ||
|
|
424090734c | ||
|
|
5f98e8fe8e | ||
|
|
661c69b39b | ||
|
|
77553ccede | ||
|
|
476e9ce6a5 | ||
|
|
8081bf16e2 | ||
|
|
9f21280dee | ||
|
|
7ce1a53095 | ||
|
|
29025a4bb3 | ||
|
|
55fc7c214c | ||
|
|
bb92c09e2c | ||
|
|
087ab6aea2 | ||
|
|
97c31386d4 | ||
|
|
de6d2cb7e5 | ||
|
|
7e64a9cd0a | ||
|
|
7a7238f66d | ||
|
|
2b76afd7dc | ||
|
|
e054a15e04 | ||
|
|
d37fafaf19 | ||
|
|
113f6d8634 | ||
|
|
66b24d028d | ||
|
|
331f06654c | ||
|
|
513641e110 | ||
|
|
9bbc1e268e | ||
|
|
558655a970 | ||
|
|
4e5fe43329 | ||
|
|
ab8e448055 | ||
|
|
216a0aac23 | ||
|
|
85bcbd5f7a | ||
|
|
cf05d67b8c | ||
|
|
a64f983145 | ||
|
|
bfb12a9b40 | ||
|
|
d4ded98203 | ||
|
|
b4155293fd | ||
|
|
c4449cb256 | ||
|
|
d9893762d6 | ||
|
|
d6b9f0f39a | ||
|
|
3643b3db58 | ||
|
|
3371efedb4 | ||
|
|
7213b30c36 | ||
|
|
060ff5394c | ||
|
|
aeb0aaa71b | ||
|
|
9ec400a387 | ||
|
|
860319f79c | ||
|
|
8383e3914a | ||
|
|
28fb9d9eed | ||
|
|
af19acb140 | ||
|
|
c979e2cde7 | ||
|
|
ab510b97db | ||
|
|
21a48510e3 | ||
|
|
bde4810ce6 | ||
|
|
4004fff4e0 | ||
|
|
1b13c48dbc | ||
|
|
1298790f23 | ||
|
|
cf051f307b | ||
|
|
d7ef05ed1d | ||
|
|
41971a3e9a | ||
|
|
c67e8bf9ee | ||
|
|
70974df7db | ||
|
|
9f19a95bf2 | ||
|
|
c1194b5b47 | ||
|
|
cbe28762a4 | ||
|
|
0432e0f9ba | ||
|
|
4605357768 | ||
|
|
b11d2ed3b6 | ||
|
|
e924648f8c | ||
|
|
0dffd04e0e | ||
|
|
1ba87f5fbd | ||
|
|
58c1412c7b | ||
|
|
695d072d41 | ||
|
|
debaa35e88 | ||
|
|
6cb62f7dc6 | ||
|
|
37c2653dd1 | ||
|
|
8df56bf066 | ||
|
|
31ed8fb267 | ||
|
|
6bf2c9e247 | ||
|
|
722f0ff4e1 | ||
|
|
a59f490a9f | ||
|
|
15d1d9dd9c | ||
|
|
80df5a3374 | ||
|
|
e8115fb7f2 | ||
|
|
b343a69fdd | ||
|
|
d53055b7e8 | ||
|
|
e6864ce05b | ||
|
|
30255d6255 | ||
|
|
47b81c7f4d | ||
|
|
c2fd089d26 | ||
|
|
51c3452d11 | ||
|
|
9dffc61f80 | ||
|
|
feb04644ee | ||
|
|
05a2b453a6 | ||
|
|
a8a0474845 | ||
|
|
91322dd77a | ||
|
|
212c14bc97 | ||
|
|
910d59af8e | ||
|
|
18a219a4b2 | ||
|
|
44ee0824d1 | ||
|
|
dae2cd6398 | ||
|
|
516fea4749 | ||
|
|
746b3dd00b | ||
|
|
8919fc8de8 | ||
|
|
192d6d9064 | ||
|
|
6b48cb2e17 | ||
|
|
2919a5feb9 | ||
|
|
941faf963e | ||
|
|
231a1e21e9 | ||
|
|
329a83ad9f | ||
|
|
3590d16a9f | ||
|
|
34e50ed326 | ||
|
|
43d0d0e4ee | ||
|
|
aec04a773f | ||
|
|
b86e9f2ff2 | ||
|
|
3831584c2e | ||
|
|
f58cd85384 | ||
|
|
c9a97b033b | ||
|
|
905a1bafc7 | ||
|
|
a62b18d55f | ||
|
|
c332172e2c | ||
|
|
b5ba9b5b72 | ||
|
|
01ba62d67b | ||
|
|
cc95b0e8b1 | ||
|
|
f15f2c057c | ||
|
|
dac585682d | ||
|
|
5ab47bf0c0 | ||
|
|
cf9e07cfa0 | ||
|
|
1f9608ebc3 | ||
|
|
ed0ff6f519 | ||
|
|
e5ef9193c5 | ||
|
|
fbc7b0e509 | ||
|
|
4e7d561f99 | ||
|
|
3d17db0dcf | ||
|
|
dd99818c30 | ||
|
|
974c0777cc | ||
|
|
e5bb55672b | ||
|
|
6813038dde | ||
|
|
1b3d1898b6 | ||
|
|
c8dc0e1c0c | ||
|
|
86a15af733 | ||
|
|
f6109ac0ba | ||
|
|
637938f272 | ||
|
|
c3f1838328 | ||
|
|
6915509db8 | ||
|
|
cce50feb48 | ||
|
|
15468857a8 | ||
|
|
5f9fe6fb8a | ||
|
|
b0da4f99a3 | ||
|
|
fe8278e78f | ||
|
|
11c9b76503 | ||
|
|
81cb9671d5 | ||
|
|
761b159955 | ||
|
|
49a9d4f853 | ||
|
|
fff8b0e6e4 | ||
|
|
dc824c3006 | ||
|
|
d028ae87b8 | ||
|
|
9c554cd98b | ||
|
|
a2e146f240 | ||
|
|
e586c18cb5 | ||
|
|
214e44ba18 | ||
|
|
126ad52993 | ||
|
|
3dd3fa5fea | ||
|
|
0aeb8cb2ed | ||
|
|
289c42d817 | ||
|
|
1b036924a6 | ||
|
|
bcaf230c7a | ||
|
|
627b5340af | ||
|
|
e70b568c25 | ||
|
|
a527226685 | ||
|
|
a3854291d7 | ||
|
|
306386c0b9 | ||
|
|
80af0cab46 | ||
|
|
c2bba5201e | ||
|
|
65515dc44a | ||
|
|
63a4bcfeb5 | ||
|
|
e691d32024 | ||
|
|
2c09824abe | ||
|
|
57dbe911a3 | ||
|
|
331fe8330f | ||
|
|
b32ee09c8f | ||
|
|
9422a6d178 | ||
|
|
6582763782 | ||
|
|
df8e89cdb9 | ||
|
|
d7275460e4 | ||
|
|
b0f110daff | ||
|
|
df289582fc | ||
|
|
2855038af9 | ||
|
|
7eb46df189 | ||
|
|
c132df4a7b | ||
|
|
9d71d451b9 | ||
|
|
fab6f7b788 | ||
|
|
79011b4f90 | ||
|
|
d026de01dd | ||
|
|
a5f5026375 | ||
|
|
319ad1705e | ||
|
|
4b4336a91d | ||
|
|
7d79becfbd | ||
|
|
ea90c5aaa6 | ||
|
|
b675c197ce | ||
|
|
39a8a91c10 | ||
|
|
746a26eb74 | ||
|
|
2db9c7a614 | ||
|
|
e32f43c694 | ||
|
|
788ddff855 | ||
|
|
f451897ae7 | ||
|
|
4a99364b5c | ||
|
|
bec90bdd5c | ||
|
|
7df4319b3e | ||
|
|
a8500cf25d | ||
|
|
9fb6f4bc07 | ||
|
|
f9fc83ddba | ||
|
|
72ab9614f3 | ||
|
|
ca84108c43 | ||
|
|
196e927400 | ||
|
|
1287944895 | ||
|
|
0cc9e8a2d7 | ||
|
|
6e5da338ec | ||
|
|
296cc427f1 | ||
|
|
8cd5129a74 | ||
|
|
d830b1de0e | ||
|
|
cd2995a11b | ||
|
|
29dab0d8f3 | ||
|
|
35997c43cb | ||
|
|
971ab02ae2 | ||
|
|
a7d36b2a89 | ||
|
|
c4f3341e83 | ||
|
|
0745c2980d | ||
|
|
148dcd2c00 | ||
|
|
39b4b59298 | ||
|
|
5ed050e322 | ||
|
|
3f5bbac8b8 | ||
|
|
de965d524d | ||
|
|
c8d3cc14a8 | ||
|
|
20c114834b | ||
|
|
04ada11a89 | ||
|
|
31687f30cf | ||
|
|
6d10ebd1c9 | ||
|
|
c826bcdacb | ||
|
|
f3c10a6811 | ||
|
|
bdbc9b998e | ||
|
|
a13b63d54b | ||
|
|
7100359a84 | ||
|
|
251479d8f3 | ||
|
|
32a155b983 | ||
|
|
5cc842d4b3 | ||
|
|
8d171aab67 | ||
|
|
f0c81c7d74 | ||
|
|
a599a6544a | ||
|
|
c5205e865b | ||
|
|
972af13e36 | ||
|
|
0b0e2c09e5 | ||
|
|
54222cc0b9 | ||
|
|
f36f8e69e5 | ||
|
|
64c944dd10 | ||
|
|
ac84106d13 | ||
|
|
764e29ea40 | ||
|
|
788bd3dc89 | ||
|
|
ed29dd348e | ||
|
|
23949df397 | ||
|
|
36b1a75460 | ||
|
|
a19ccc06ec | ||
|
|
e6906093bd | ||
|
|
57180617c4 | ||
|
|
b8b3e79c89 | ||
|
|
5973a24e47 | ||
|
|
f0d11942ef | ||
|
|
3ed07c30b6 | ||
|
|
5b8b7a92ca | ||
|
|
9715f661f8 | ||
|
|
7ce550ea4b | ||
|
|
4a4fd54cf6 | ||
|
|
f034e62cbd | ||
|
|
4e98f30779 | ||
|
|
f849645ee2 | ||
|
|
f88e4783cf | ||
|
|
3c7741ac29 | ||
|
|
07fb93e9a2 | ||
|
|
1ce32669fa | ||
|
|
52d7038694 | ||
|
|
0dd7b60d43 | ||
|
|
397f220718 | ||
|
|
70ec6a1c15 | ||
|
|
bb8a3d7dca | ||
|
|
fecc0c61eb | ||
|
|
0773f3467b | ||
|
|
94cc32c946 | ||
|
|
06b7ab6997 | ||
|
|
c51e3ae17c | ||
|
|
f732ee7ed2 | ||
|
|
68c4e97c48 | ||
|
|
3dff96feaa | ||
|
|
9a2b8c3aa1 | ||
|
|
49dec39aa9 | ||
|
|
26c9d108dc | ||
|
|
c2dfa024ee | ||
|
|
3d9565db10 | ||
|
|
d5545015ef | ||
|
|
9c027e79d9 | ||
|
|
8191cddc17 | ||
|
|
95736afb74 | ||
|
|
a04ca26cbf | ||
|
|
18e7b43363 | ||
|
|
24f5e22778 | ||
|
|
8c96e7942d | ||
|
|
8ad09cf030 | ||
|
|
2f4d298701 | ||
|
|
6c75387d25 | ||
|
|
b45ea39946 | ||
|
|
da207089b6 | ||
|
|
77cc0a07e9 | ||
|
|
d1d7010e5c | ||
|
|
f1d1aa0b46 | ||
|
|
2cd42b9ff9 | ||
|
|
b8f0e2e3c7 | ||
|
|
d668fc5de5 | ||
|
|
472be89b7c | ||
|
|
6f5db6157a | ||
|
|
6d6b708d6d | ||
|
|
f64ca7742b | ||
|
|
33f0d2fc11 | ||
|
|
5f6195af04 | ||
|
|
883d8d0e9d | ||
|
|
fc88536775 | ||
|
|
241d2d762b | ||
|
|
66384342a9 | ||
|
|
70d202889b | ||
|
|
52b8f2c72b | ||
|
|
cc43410934 | ||
|
|
d925c163b6 | ||
|
|
5e149c858e | ||
|
|
02dc1b38dc | ||
|
|
c374a1f622 | ||
|
|
9a8ecff9c0 | ||
|
|
4038ce187a | ||
|
|
7eceaf6714 | ||
|
|
13e681f359 | ||
|
|
e3a85c2378 | ||
|
|
df761b7872 | ||
|
|
a8384ba264 | ||
|
|
3ecb22a80b | ||
|
|
cb20b66654 | ||
|
|
2c96b9b24c | ||
|
|
59ed9f9a48 | ||
|
|
f708c3addf | ||
|
|
8cb12e4158 | ||
|
|
54c0930bf7 | ||
|
|
cd2621e849 | ||
|
|
f7e6b011ab | ||
|
|
b0596a4a03 | ||
|
|
ead16f740d | ||
|
|
94b5898f8d | ||
|
|
a22ab7531b | ||
|
|
98abd65ab2 | ||
|
|
d471695aea | ||
|
|
eaa6f67a71 | ||
|
|
5e2ef6007b | ||
|
|
589b31cbeb | ||
|
|
eb148c60f5 | ||
|
|
b5a3c3e7fc | ||
|
|
2795d6e0e2 | ||
|
|
88c978ca37 | ||
|
|
9cbc895934 | ||
|
|
1b4463c060 | ||
|
|
23341251a4 | ||
|
|
3ff13177ef | ||
|
|
1cfaa777c5 | ||
|
|
b9f48c3707 | ||
|
|
b7f68923a3 | ||
|
|
4d250fe326 | ||
|
|
9bdc010363 | ||
|
|
7edc5cfbbe | ||
|
|
bd0cb3611b | ||
|
|
6801fcf5ea | ||
|
|
432cad44e2 | ||
|
|
d1c849bab3 | ||
|
|
6ca99aea7a | ||
|
|
27386147e5 | ||
|
|
ddb3f981e5 | ||
|
|
6b6d5f89f3 | ||
|
|
2bf15eb191 | ||
|
|
180023a2d7 | ||
|
|
8f4f036260 | ||
|
|
e8c76d4d79 | ||
|
|
75fd7b88d9 | ||
|
|
378fefac4f | ||
|
|
a362408f6b | ||
|
|
87a161ec5d | ||
|
|
4346598573 | ||
|
|
200f358489 | ||
|
|
6816d661e3 | ||
|
|
44da356598 | ||
|
|
a943dcb724 | ||
|
|
ef4608e82a | ||
|
|
b5c00e6e60 | ||
|
|
5693435cc2 | ||
|
|
29f9a22a0d | ||
|
|
ce6f3eb6e4 | ||
|
|
b3865af487 | ||
|
|
6541c2e8da | ||
|
|
94025afd98 | ||
|
|
f0b17814b2 | ||
|
|
150ba25539 | ||
|
|
f3f6dfe8d8 | ||
|
|
e57bbcf3b6 | ||
|
|
8e6865783d | ||
|
|
aeda4adfb0 | ||
|
|
30eeff9b56 | ||
|
|
e324519f9c | ||
|
|
75218277dd | ||
|
|
c4234a8c67 | ||
|
|
b57cf10195 | ||
|
|
c37c596aa3 | ||
|
|
cfe71dcfa5 | ||
|
|
5a2eb6a516 | ||
|
|
ba994902a5 | ||
|
|
93876b521a | ||
|
|
36ed0fef31 | ||
|
|
2963eaba88 | ||
|
|
974763d9b1 | ||
|
|
d470daecc3 | ||
|
|
0812916a8c | ||
|
|
a30424396e | ||
|
|
50e199358e | ||
|
|
54d4400365 | ||
|
|
c08597167b | ||
|
|
5f6eb1011e | ||
|
|
33d8f81e70 | ||
|
|
f96090af37 | ||
|
|
7336d9e0b5 | ||
|
|
28d18b3fe2 | ||
|
|
5c16f4c852 | ||
|
|
0c95cba4f1 | ||
|
|
9a83ffce5e | ||
|
|
59f767f587 | ||
|
|
0246071dc0 | ||
|
|
42165f24a1 | ||
|
|
05ec449cf0 | ||
|
|
d08a245552 | ||
|
|
8a4586b4f7 | ||
|
|
48efa2070b | ||
|
|
e0dde95954 | ||
|
|
0d434c76d3 | ||
|
|
4b20a12169 | ||
|
|
9ce30cea88 | ||
|
|
953e4e95fd | ||
|
|
07806cbe19 | ||
|
|
7716bdd089 | ||
|
|
aea254eca8 | ||
|
|
c0baec9032 | ||
|
|
f4ddc6009c | ||
|
|
e1b2d1f0b8 | ||
|
|
2c212bcf3c | ||
|
|
95459e3032 | ||
|
|
d29f638121 | ||
|
|
609f1afc83 | ||
|
|
af0719316a | ||
|
|
349a45442f | ||
|
|
22a63264ba | ||
|
|
5ec8eddb49 | ||
|
|
394e4817a9 | ||
|
|
f4dd6e9335 | ||
|
|
7150fcec2a | ||
|
|
37f318c694 | ||
|
|
561a4a3115 | ||
|
|
13fa038b31 | ||
|
|
bd56e1cac2 | ||
|
|
5ed4d4ff27 | ||
|
|
bacd92f6bd | ||
|
|
a18e956177 | ||
|
|
542f144a0b | ||
|
|
8984b3eb9f | ||
|
|
82948804fa | ||
|
|
4d68f8cff8 | ||
|
|
159634069a | ||
|
|
d024529317 | ||
|
|
5b8ca72619 | ||
|
|
62eb84fb2b | ||
|
|
dc5712fbc2 | ||
|
|
578a8776c7 | ||
|
|
61dfdc30ed | ||
|
|
cd39ec838a | ||
|
|
2cb0b70080 | ||
|
|
606b584c67 | ||
|
|
cd989fcb86 | ||
|
|
953048e352 | ||
|
|
a7dff83e9a | ||
|
|
9aef5b5c3c | ||
|
|
6af2152dde | ||
|
|
943b5ee50a | ||
|
|
5b8cb7bb4c | ||
|
|
38fce2654f | ||
|
|
7dd33c60bc | ||
|
|
634237a465 | ||
|
|
db156c4427 | ||
|
|
73d3688442 | ||
|
|
4c5d22195d | ||
|
|
b9e6b2024a | ||
|
|
4b9e037d02 | ||
|
|
13b4fb51ba | ||
|
|
ab1d6ce62a | ||
|
|
7062700ba4 | ||
|
|
71aa8f61b0 | ||
|
|
695756726e | ||
|
|
116a3e078e | ||
|
|
99144cad40 | ||
|
|
88ae6de546 | ||
|
|
58efa27338 | ||
|
|
5eb0eb940e | ||
|
|
844f16e692 | ||
|
|
8d84153a09 | ||
|
|
697b58ad00 | ||
|
|
11a58db513 | ||
|
|
e07d8383ef | ||
|
|
aec050dd2a | ||
|
|
3140a58b50 | ||
|
|
b0cf53ede5 | ||
|
|
ab5eb680ec | ||
|
|
c7f3ae3b92 | ||
|
|
eec2bf7d68 | ||
|
|
b9ab266923 | ||
|
|
c263d83522 | ||
|
|
d82f9fa210 | ||
|
|
979943e28c | ||
|
|
e68599c201 | ||
|
|
3e3413d2cb | ||
|
|
6a5706b5ab | ||
|
|
7ccbdf2b62 | ||
|
|
b1f8852f84 | ||
|
|
c7fd256104 | ||
|
|
25e2834400 | ||
|
|
7257d9ea3b | ||
|
|
d1ddff807e | ||
|
|
7047728be3 | ||
|
|
e780e210db | ||
|
|
8f0398b23f | ||
|
|
ddf26eb51e | ||
|
|
0aa9d5efd8 | ||
|
|
47b1da8f2c | ||
|
|
67ef4dfb9a | ||
|
|
c2665e8ab1 | ||
|
|
1e7cf1d995 | ||
|
|
95e773d574 | ||
|
|
6064ff51d3 | ||
|
|
46cdecc8f3 | ||
|
|
6607514e50 | ||
|
|
9845480ec7 | ||
|
|
8c503437a8 | ||
|
|
89ebd1bc49 | ||
|
|
ada021190f | ||
|
|
77cfd388b2 | ||
|
|
29b303100b | ||
|
|
695d72618d | ||
|
|
1fa5aafa53 | ||
|
|
e60a1ae5dd | ||
|
|
844e36350c | ||
|
|
6c389d217d | ||
|
|
d9ec28f982 | ||
|
|
bb40138019 | ||
|
|
34bf612540 | ||
|
|
ce09c14eb9 | ||
|
|
5d8c96c6c3 | ||
|
|
87d4c57515 | ||
|
|
ee81c82fec | ||
|
|
8f5ce86a9d | ||
|
|
78f34660c1 | ||
|
|
a7a5e2ff03 | ||
|
|
14c2e8fb7b | ||
|
|
741a5baf4d | ||
|
|
7eddd59e83 | ||
|
|
469644f0bf | ||
|
|
6306d1dc2f | ||
|
|
b9e8885465 | ||
|
|
769e8242e4 | ||
|
|
657f308675 | ||
|
|
18ab2258f2 | ||
|
|
496830aff2 | ||
|
|
3be071ece6 | ||
|
|
857ec2877f | ||
|
|
b6362673fd | ||
|
|
bc01087993 | ||
|
|
fefe0bb8a5 | ||
|
|
ccbc5de87d | ||
|
|
c695660a97 | ||
|
|
9a1148eda0 | ||
|
|
f3b8430a6c | ||
|
|
56d12bc8e0 | ||
|
|
1a5ffb430b | ||
|
|
cd300f685d | ||
|
|
9a448be597 | ||
|
|
59e6adf4a8 | ||
|
|
3f6d6d8487 | ||
|
|
c91d3fedc2 | ||
|
|
7b874305ea | ||
|
|
11f809b1ee | ||
|
|
ef7557a989 | ||
|
|
fffd976e09 | ||
|
|
5dda5c003d | ||
|
|
21089c9020 | ||
|
|
a4dcbe5762 | ||
|
|
1e6ba99b30 | ||
|
|
f1825b4272 | ||
|
|
84840809b7 | ||
|
|
2951b6480c | ||
|
|
e638b2b555 | ||
|
|
848077bb79 | ||
|
|
49a79574c8 | ||
|
|
b03fd3ad93 | ||
|
|
4f1edbefe8 | ||
|
|
04f88c6864 | ||
|
|
98879271af | ||
|
|
dcad4baeb2 | ||
|
|
0d4f1e61ad | ||
|
|
5a025b743a | ||
|
|
806f378fa2 | ||
|
|
85921a688f | ||
|
|
7fe6940156 | ||
|
|
bc552e377a | ||
|
|
1ae18b6ed0 | ||
|
|
f14e86f4e2 | ||
|
|
9323e8f562 | ||
|
|
7c6605ed8b | ||
|
|
bb641fdbaa | ||
|
|
f6324c7720 | ||
|
|
4075bea7ed | ||
|
|
ef00de5be9 | ||
|
|
6a38ef7676 | ||
|
|
c15e202a5b | ||
|
|
0fdb40467e | ||
|
|
e254454834 | ||
|
|
70257027f1 | ||
|
|
490c6897ca | ||
|
|
e0ceff1ee9 | ||
|
|
8295b2b6a6 | ||
|
|
84f5c83a10 | ||
|
|
fba82b9e7a | ||
|
|
9528d56cf3 | ||
|
|
719eb902bd | ||
|
|
06979aa7b7 | ||
|
|
510c2423d2 | ||
|
|
f216293217 | ||
|
|
5829140eff | ||
|
|
7635785c65 | ||
|
|
5a00ef4e01 | ||
|
|
08cfa6778d | ||
|
|
267f2ccd8a | ||
|
|
271c7565fa | ||
|
|
7dcc9e9d95 | ||
|
|
56bde78c23 | ||
|
|
60d598e641 | ||
|
|
a9b1d7e43b | ||
|
|
4213c47f70 | ||
|
|
ca80cc518a | ||
|
|
0a89823eef | ||
|
|
48fafb06a7 | ||
|
|
519bf94796 | ||
|
|
91823711a8 | ||
|
|
dc73e5cef6 | ||
|
|
ab3fde8480 | ||
|
|
9466d1ad0f | ||
|
|
95f3cfd06c | ||
|
|
e33ea312cf | ||
|
|
7043e4bae9 | ||
|
|
1b56107ab7 | ||
|
|
6eb5e8ec19 | ||
|
|
cdac2477b3 | ||
|
|
bff34fa53a | ||
|
|
799705e20d | ||
|
|
03e827f3c1 | ||
|
|
2fc7d538ec | ||
|
|
ff89164460 | ||
|
|
10cd5b4b04 | ||
|
|
d78a110902 | ||
|
|
a668d5a7b8 | ||
|
|
190dda712d | ||
|
|
5ef42f014e | ||
|
|
f12d340f1b | ||
|
|
350480d9d8 | ||
|
|
b868bfb31a | ||
|
|
60fea1acec | ||
|
|
9b04918f3b | ||
|
|
8192cecc4c | ||
|
|
51aa0fbfe3 | ||
|
|
195cd56e1a | ||
|
|
c5c14b6a39 | ||
|
|
21fbeb540e | ||
|
|
7f2ed5ccbe | ||
|
|
ce29a74cca | ||
|
|
1e818beb7b | ||
|
|
8cc1a336c1 | ||
|
|
1e4b25596c | ||
|
|
ac633b67ad | ||
|
|
3e076a19b7 | ||
|
|
d67bce6c2c | ||
|
|
ef0f098c83 | ||
|
|
8bdcd94e29 | ||
|
|
c0808fc268 | ||
|
|
cb566ccbd3 | ||
|
|
0a241f8499 | ||
|
|
55b59b472d | ||
|
|
369f28e650 | ||
|
|
2d21c22f9d | ||
|
|
848120aac4 | ||
|
|
feddc8e960 | ||
|
|
8919369190 | ||
|
|
8f1ab9ea75 | ||
|
|
52ce0e98ad | ||
|
|
dc03510277 | ||
|
|
26077d50d8 | ||
|
|
d4e935b63f | ||
|
|
caf2429980 | ||
|
|
2533321273 | ||
|
|
4df87281a9 | ||
|
|
9a7e03d399 | ||
|
|
5f6a8c30c5 | ||
|
|
7eafa1dd4c | ||
|
|
d6aae70445 | ||
|
|
347feb399c | ||
|
|
114067edf0 | ||
|
|
636d90ebac | ||
|
|
cd8e4119d2 | ||
|
|
e8c2e7ac64 | ||
|
|
0ca566d112 | ||
|
|
a59d796a6d | ||
|
|
8aeef2dacd | ||
|
|
c0276ffe11 | ||
|
|
395e9b6d91 | ||
|
|
06b0068a37 | ||
|
|
038377282f | ||
|
|
33317389ba | ||
|
|
8cfed4babe | ||
|
|
8cf9852d19 | ||
|
|
d102185c03 | ||
|
|
ca1ec5cff4 | ||
|
|
f6d5d2430b | ||
|
|
cc0bc1b4dc | ||
|
|
5be747a14d | ||
|
|
9af4dc78d2 | ||
|
|
78dc821756 | ||
|
|
2b55b6092c | ||
|
|
6e8049bcfd | ||
|
|
078b6507fe | ||
|
|
84890e0612 | ||
|
|
15ea322f05 | ||
|
|
2eb03efcdd | ||
|
|
62bb4104e0 | ||
|
|
29566ebf6d | ||
|
|
bde343ed7f | ||
|
|
fac24c27e3 | ||
|
|
6bb58cd48a | ||
|
|
89f1e2ea47 | ||
|
|
216dea5a61 | ||
|
|
f6dc336fdb | ||
|
|
aadcaa4ec1 | ||
|
|
d1ec3bf6e4 | ||
|
|
f95983b84c | ||
|
|
1122dc8b88 | ||
|
|
ce0ec49084 | ||
|
|
32664a7872 | ||
|
|
4c3ef1e2db | ||
|
|
855b9610a8 | ||
|
|
710f53404d | ||
|
|
99fb6017f4 | ||
|
|
3506b1e893 | ||
|
|
fd9e75afff | ||
|
|
9947fb2825 | ||
|
|
b5d4a968bf | ||
|
|
a90a687539 | ||
|
|
7aae518ae0 | ||
|
|
91e116b49f | ||
|
|
0925934a27 | ||
|
|
683d60d301 | ||
|
|
863d888fa8 | ||
|
|
452117852a | ||
|
|
13a9ed8dc4 | ||
|
|
808602d2d5 | ||
|
|
d0f4c70000 | ||
|
|
09b61f6e64 | ||
|
|
2796078a72 | ||
|
|
6614561c3d | ||
|
|
ab157260c5 | ||
|
|
03ae2d20fd | ||
|
|
be85758a53 | ||
|
|
2cb00a8f4a | ||
|
|
ae0f252d4c | ||
|
|
466e8541a5 | ||
|
|
be3d2f30aa | ||
|
|
9dca203f8e | ||
|
|
e1ced5ee97 | ||
|
|
cd90937335 | ||
|
|
45e057b331 | ||
|
|
e0320585b7 | ||
|
|
1ad635a7d6 | ||
|
|
aee9ddd759 | ||
|
|
7412592f9c | ||
|
|
efdc77ca2a | ||
|
|
c28cabbcc4 | ||
|
|
f94c70c905 | ||
|
|
861b05e390 | ||
|
|
9ff735d1ad | ||
|
|
7be67f38cf | ||
|
|
17d47d00ac | ||
|
|
93dfb3962d | ||
|
|
ea47cf9f3a | ||
|
|
4d347eff29 | ||
|
|
3581ef2de9 | ||
|
|
3460dd628d | ||
|
|
b48e760dfa | ||
|
|
ecc4cbacf2 | ||
|
|
c2d5daf530 | ||
|
|
8080b06dee | ||
|
|
1043d75814 | ||
|
|
a88ae1dd19 | ||
|
|
69a825ccf7 | ||
|
|
1d9df7afd1 | ||
|
|
d3ee664668 | ||
|
|
abab9471bd | ||
|
|
ce67681ee3 | ||
|
|
c0621c83c9 | ||
|
|
36faf98976 | ||
|
|
6dca99bf55 | ||
|
|
e8df6853f1 | ||
|
|
6b924af4b2 | ||
|
|
cab7562f08 | ||
|
|
75f7dd61e2 | ||
|
|
db03f0e3fc | ||
|
|
a23e671ff7 | ||
|
|
5a7c7ec0b6 | ||
|
|
88defe7480 | ||
|
|
00d9d07947 | ||
|
|
e1679b91ee | ||
|
|
4f390903d3 | ||
|
|
596640ff0a | ||
|
|
d68500f3f1 | ||
|
|
cd7f325fc4 | ||
|
|
37ba690bf1 | ||
|
|
f035d401ed | ||
|
|
73ae6fecac | ||
|
|
9d0a97d053 | ||
|
|
45e4924e18 | ||
|
|
e56cec74b4 | ||
|
|
4420bcc126 | ||
|
|
1c9966455e | ||
|
|
245110794e | ||
|
|
0a950567fc | ||
|
|
1c77154fa0 | ||
|
|
ba97584a87 | ||
|
|
9a4aea776f | ||
|
|
0c60a50211 | ||
|
|
71bfa3647d | ||
|
|
f1709b7eea | ||
|
|
d9f69d3a36 | ||
|
|
f72f5a58cc | ||
|
|
716ca698cf | ||
|
|
6da12f666a | ||
|
|
010de69620 | ||
|
|
ecffe94354 | ||
|
|
3814657f3e | ||
|
|
ed12016a9d | ||
|
|
3b020d9f64 | ||
|
|
8e6f97674c | ||
|
|
98890d6198 | ||
|
|
2dc2f43bb2 | ||
|
|
e327282419 | ||
|
|
a384ea263c | ||
|
|
c6431fb76a | ||
|
|
1f6094077f | ||
|
|
909b8efc13 | ||
|
|
6abe331786 | ||
|
|
838a0b30cb | ||
|
|
ed93b122dd | ||
|
|
149348ab9e | ||
|
|
7c0884065f | ||
|
|
eed1a21eae | ||
|
|
c49818001a | ||
|
|
42ff3e9e3a | ||
|
|
fc476a58e6 | ||
|
|
58dceb6fa6 | ||
|
|
ce7e86be94 | ||
|
|
fa07a91825 | ||
|
|
5dd007e4c0 | ||
|
|
2bcb06a690 | ||
|
|
e0b2d75e45 | ||
|
|
44e8268080 | ||
|
|
ba0f8ead95 | ||
|
|
55207c2d12 | ||
|
|
1ab306b335 | ||
|
|
a70a83f9d2 | ||
|
|
1697699b9a | ||
|
|
624c3e13e7 | ||
|
|
afd4757fab | ||
|
|
9ea6fa13e5 | ||
|
|
41c841ccec | ||
|
|
37dbbb898f | ||
|
|
805b7660a6 | ||
|
|
330c3f7085 | ||
|
|
b5f8fcfeba | ||
|
|
17adef6fc2 | ||
|
|
567e9f9540 | ||
|
|
2f4ed0f31b | ||
|
|
0d97ecc09a | ||
|
|
afec3c65ed | ||
|
|
17a55a6941 | ||
|
|
35ac24c699 | ||
|
|
ab74d3fb25 | ||
|
|
8b62f74164 | ||
|
|
fd61a027dd | ||
|
|
e654624bb8 | ||
|
|
223741ae0b | ||
|
|
2dc41d6bf5 | ||
|
|
03e783dbec | ||
|
|
452eae5de8 | ||
|
|
6b48679c13 | ||
|
|
ba2399849f | ||
|
|
22a0665099 | ||
|
|
ea5e30913d | ||
|
|
1bb386962c | ||
|
|
87e7c5616f | ||
|
|
6aa90e5e21 | ||
|
|
a816720e5b | ||
|
|
d30487f10f | ||
|
|
6e63ff8f7c | ||
|
|
ac6f1989ed | ||
|
|
6acb8030bb | ||
|
|
de5fe9e9af | ||
|
|
f85d01574b | ||
|
|
7f6109e927 | ||
|
|
e50b5f9464 | ||
|
|
3b64d1be73 | ||
|
|
17d3f4664f | ||
|
|
9048021e9b | ||
|
|
109c629653 | ||
|
|
af1a4a5973 | ||
|
|
514951087d | ||
|
|
b4d97e34a4 | ||
|
|
a628ec42ca | ||
|
|
e59bfaaada | ||
|
|
51a4e988b1 | ||
|
|
f1afedd412 | ||
|
|
7867148daf | ||
|
|
b687d11813 | ||
|
|
de424e8b2f | ||
|
|
a7bd1576fd | ||
|
|
230fede891 | ||
|
|
a13a7ffd28 | ||
|
|
79c8e4b873 | ||
|
|
e7a72d31ae | ||
|
|
714fb74c24 | ||
|
|
aaadd24076 | ||
|
|
2077e4e6a4 | ||
|
|
2f12b88ae7 | ||
|
|
80e0dad1c8 | ||
|
|
97fd70d685 | ||
|
|
baae2b6f3c | ||
|
|
5a0156c1fc | ||
|
|
a50e0de122 | ||
|
|
5bc589fc3f | ||
|
|
a1ec9373e1 | ||
|
|
c9a6465a45 | ||
|
|
94782a8b1f | ||
|
|
ddae0b00e5 | ||
|
|
385b5b1262 | ||
|
|
21df92fc11 | ||
|
|
40235fd9cb | ||
|
|
76da2e9a28 | ||
|
|
6372d68ce3 | ||
|
|
7796e18bc5 | ||
|
|
2fce0b4e66 |
No files matched your search
@@ -1,11 +1,13 @@
|
||||
#
|
||||
# $Id: Makefile,v 1.108 1996/10/25 14:22:50 bde Exp $
|
||||
# $Id: Makefile,v 1.109.2.1 1996/11/28 21:43:35 phk Exp $
|
||||
#
|
||||
# Make command line options:
|
||||
# -DCLOBBER will remove /usr/include
|
||||
# -DMAKE_LOCAL to add ./local to the SUBDIR list
|
||||
# -DMAKE_PORTS to add ./ports to the SUBDIR list
|
||||
# -DMAKE_EBONES to build eBones (KerberosIV)
|
||||
# -DALLLANG to build documentation for all languages
|
||||
# (where available -- see share/doc/Makefile)
|
||||
#
|
||||
# -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
|
||||
# -DNOCLEAN do not clean at all
|
||||
@@ -129,7 +131,7 @@ MK_FLAGS= -DNOMAN -DNOPROFILE
|
||||
#
|
||||
world:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo "make world started on `LC_TIME= date`"
|
||||
@echo "make world started on `LC_TIME=C date`"
|
||||
@echo "--------------------------------------------------------------"
|
||||
.if target(pre-world)
|
||||
@echo "--------------------------------------------------------------"
|
||||
@@ -222,7 +224,7 @@ world:
|
||||
.endif
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo "make world completed on `LC_TIME= date`"
|
||||
@echo "make world completed on `LC_TIME=C date`"
|
||||
@echo "--------------------------------------------------------------"
|
||||
|
||||
#
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
This is the top level of the FreeBSD source directory. This file
|
||||
was last revised on: $Id$
|
||||
|
||||
For copyright information, please see the file COPYRIGHT in this
|
||||
directory (additional copyright information also exists for some
|
||||
sources in this tree - please see the specific source directories for
|
||||
more information).
|
||||
|
||||
The Makefile in this directory supports a number of targets for
|
||||
building components (or all) of the FreeBSD source tree, the most
|
||||
commonly used one being ``world'', which rebuilds and installs
|
||||
everything in the FreeBSD system from the source tree except the
|
||||
kernel. Please see the top of the Makefile for more information on
|
||||
the standard build targets and compile-time flags.
|
||||
|
||||
Building a kernel with config(1) is a somewhat more involved process,
|
||||
documentation for which can be found at:
|
||||
http://www.freebsd.org/handbook/kernelconfig.html
|
||||
And in the config(1) man page.
|
||||
|
||||
The sample kernel configuration files reside in the sys/i386/conf
|
||||
sub-directory (assuming that you've installed the kernel sources), the
|
||||
file named GENERIC being the one used to build your initial installation
|
||||
kernel. The file LINT contains entries for all possible devices, not
|
||||
just those commonly used, and is meant more as a general reference
|
||||
than an actual kernel configuration file (a kernel built from it
|
||||
wouldn't even run).
|
||||
|
||||
|
||||
Source Roadmap:
|
||||
---------------
|
||||
bin System/User commands.
|
||||
|
||||
contrib Packages contributed by 3rd parties.
|
||||
|
||||
eBones Kerberos package - NOT FOR EXPORT!
|
||||
|
||||
etc Template files for /etc
|
||||
|
||||
games Amusements.
|
||||
|
||||
gnu Various commands and libraries under the GNU Public License.
|
||||
Please see gnu/COPYING* for more information.
|
||||
|
||||
include System include files.
|
||||
|
||||
lib System libraries.
|
||||
|
||||
libexec System daemons.
|
||||
|
||||
lkm Loadable Kernel Modules.
|
||||
|
||||
release Release building Makefile & associated tools.
|
||||
|
||||
sbin System commands.
|
||||
|
||||
secure DES and DES-related utilities - NOT FOR EXPORT!
|
||||
|
||||
share Shared resources.
|
||||
|
||||
sys Kernel sources.
|
||||
|
||||
tools Utilities for regression testing and miscellaneous tasks.
|
||||
|
||||
usr.bin User commands.
|
||||
|
||||
usr.sbin System administration commands.
|
||||
|
||||
|
||||
For information on synchronizing your source tree with one or more of
|
||||
the FreeBSD Project's development branches, please see:
|
||||
|
||||
http://www.freebsd.org/handbook/synching.html
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
# From: @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
# $Id: Makefile,v 1.3 1995/09/29 19:31:55 ache Exp $
|
||||
# $Id: Makefile,v 1.4 1995/10/01 14:24:01 markm Exp $
|
||||
|
||||
SUBDIR= cat chmod cp csh date dd df domainname echo ed expr hostname \
|
||||
SUBDIR= cat chio chmod cp csh date dd df domainname echo ed expr hostname \
|
||||
kill ln ls mkdir mv pax ps pwd rcp rm rmail rmdir sh sleep \
|
||||
stty sync test
|
||||
|
||||
|
||||
+7
-8
@@ -32,10 +32,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)cat.1 8.1 (Berkeley) 6/29/93
|
||||
.\" $Id: cat.1,v 1.2 1994/09/24 02:53:25 davidg Exp $
|
||||
.\" @(#)cat.1 8.3 (Berkeley) 5/2/95
|
||||
.\" $Id: cat.1,v 1.6 1997/02/22 14:01:26 peter Exp $
|
||||
.\"
|
||||
.Dd June 29, 1993
|
||||
.Dd May 2, 1995
|
||||
.Dt CAT 1
|
||||
.Os BSD 3
|
||||
.Sh NAME
|
||||
@@ -69,9 +69,7 @@ option, and displays a dollar sign
|
||||
at the end of each line
|
||||
as well.
|
||||
.It Fl n
|
||||
Number the
|
||||
.Ar output
|
||||
lines, starting at 1.
|
||||
Number the output lines, starting at 1.
|
||||
.It Fl s
|
||||
Squeeze multiple adjacent empty lines, causing the output to be
|
||||
single spaced.
|
||||
@@ -79,7 +77,7 @@ single spaced.
|
||||
Implies the
|
||||
.Fl v
|
||||
option, and displays tab characters as
|
||||
.Pq Ql ^I
|
||||
.Ql ^I
|
||||
as well.
|
||||
.It Fl u
|
||||
The
|
||||
@@ -109,7 +107,8 @@ will cause the original data in file1 to be destroyed!
|
||||
.Xr head 1 ,
|
||||
.Xr more 1 ,
|
||||
.Xr pr 1 ,
|
||||
.Xr tail 1
|
||||
.Xr tail 1 ,
|
||||
.Xr vis 1
|
||||
.Rs
|
||||
.%A Rob Pike
|
||||
.%T "UNIX Style, or cat -v Considered Harmful"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
NOSHARED= true
|
||||
|
||||
PROG= chflags
|
||||
SRCS= chflags.c stat_flags.c
|
||||
.PATH: ${.CURDIR}/../../bin/ls
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,125 +0,0 @@
|
||||
.\" Copyright (c) 1989, 1990, 1993, 1994
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to Berkeley by
|
||||
.\" the Institute of Electrical and Electronics Engineers, Inc.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" 4. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)chflags.1 8.2 (Berkeley) 3/31/94
|
||||
.\"
|
||||
.Dd March 31, 1994
|
||||
.Dt CHFLAGS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm chflags
|
||||
.Nd change file flags
|
||||
.Sh SYNOPSIS
|
||||
.Nm chflags
|
||||
.Oo
|
||||
.Fl R
|
||||
.Op Fl H | Fl L | Fl P
|
||||
.Oc
|
||||
.Ar flags
|
||||
.Ar file ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm chflags
|
||||
utility modifies the file flags of the listed files
|
||||
as specified by the
|
||||
.Ar flags
|
||||
operand.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl H
|
||||
If the
|
||||
.Fl R
|
||||
option is specified, symbolic links on the command line are followed.
|
||||
(Symbolic links encountered in the tree traversal are not followed.)
|
||||
.It Fl L
|
||||
If the
|
||||
.Fl R
|
||||
option is specified, all symbolic links are followed.
|
||||
.It Fl P
|
||||
If the
|
||||
.Fl R
|
||||
option is specified, no symbolic links are followed.
|
||||
.It Fl R
|
||||
Change the file flags for the file hierarchies rooted
|
||||
in the files instead of just the files themselves.
|
||||
.El
|
||||
.Pp
|
||||
Flags are a comma separated list of keywords.
|
||||
The following keywords are currently defined:
|
||||
.Bd -literal -offset indent compact
|
||||
arch set the archived flag (super-user only)
|
||||
dump set the dump flag
|
||||
sappnd set the system append-only flag (super-user only)
|
||||
schg set the system immutable flag (super-user only)
|
||||
uappnd set the user append-only flag (owner or super-user only)
|
||||
uchg set the user immutable flag (owner or super-user only)
|
||||
archived, sappend, schange, simmutable, uappend, uchange, uimmutable
|
||||
aliases for the above
|
||||
.Ed
|
||||
.Pp
|
||||
Putting the letters
|
||||
.Dq no
|
||||
before an option causes the flag to be turned off.
|
||||
For example:
|
||||
.Bd -literal -offset indent compact
|
||||
nodump the file should never be dumped
|
||||
.Ed
|
||||
.Pp
|
||||
Symbolic links do not have flags, so unless the
|
||||
.Fl H
|
||||
or
|
||||
.Fl L
|
||||
option is set,
|
||||
.Nm chflags
|
||||
on a symbolic link always succeeds and has no effect.
|
||||
The
|
||||
.Fl H ,
|
||||
.Fl L
|
||||
and
|
||||
.Fl P
|
||||
options are ignored unless the
|
||||
.Fl R
|
||||
option is specified.
|
||||
In addition, these options override each other and the
|
||||
command's actions are determined by the last one specified.
|
||||
.Pp
|
||||
The
|
||||
.Nm chflags
|
||||
utility exits 0 on success, and >0 if an error occurs.
|
||||
.Sh SEE ALSO
|
||||
.Xr chflags 2 ,
|
||||
.Xr stat 2 ,
|
||||
.Xr fts 3 ,
|
||||
.Xr symlink 7
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1992, 1993, 1994\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)chflags.c 8.5 (Berkeley) 4/1/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fts.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
u_long string_to_flags __P((char **, u_long *, u_long *));
|
||||
void usage __P((void));
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
FTS *ftsp;
|
||||
FTSENT *p;
|
||||
u_long clear, set;
|
||||
long val;
|
||||
int Hflag, Lflag, Pflag, Rflag, ch, fts_options, oct, rval;
|
||||
char *flags, *ep;
|
||||
|
||||
Hflag = Lflag = Pflag = Rflag = 0;
|
||||
while ((ch = getopt(argc, argv, "HLPR")) != EOF)
|
||||
switch (ch) {
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
Lflag = Pflag = 0;
|
||||
break;
|
||||
case 'L':
|
||||
Lflag = 1;
|
||||
Hflag = Pflag = 0;
|
||||
break;
|
||||
case 'P':
|
||||
Pflag = 1;
|
||||
Hflag = Lflag = 0;
|
||||
break;
|
||||
case 'R':
|
||||
Rflag = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
fts_options = FTS_PHYSICAL;
|
||||
if (Rflag) {
|
||||
if (Hflag)
|
||||
fts_options |= FTS_COMFOLLOW;
|
||||
if (Lflag) {
|
||||
fts_options &= ~FTS_PHYSICAL;
|
||||
fts_options |= FTS_LOGICAL;
|
||||
}
|
||||
}
|
||||
|
||||
flags = *argv;
|
||||
if (*flags >= '0' && *flags <= '7') {
|
||||
errno = 0;
|
||||
val = strtol(flags, &ep, 8);
|
||||
if (val < 0)
|
||||
errno = ERANGE;
|
||||
if (errno)
|
||||
err(1, "invalid flags: %s", flags);
|
||||
if (*ep)
|
||||
errx(1, "invalid flags: %s", flags);
|
||||
set = val;
|
||||
oct = 1;
|
||||
} else {
|
||||
if (string_to_flags(&flags, &set, &clear))
|
||||
errx(1, "invalid flag: %s", flags);
|
||||
clear = ~clear;
|
||||
oct = 0;
|
||||
}
|
||||
|
||||
if ((ftsp = fts_open(++argv, fts_options , 0)) == NULL)
|
||||
err(1, NULL);
|
||||
|
||||
for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
|
||||
switch (p->fts_info) {
|
||||
case FTS_D:
|
||||
if (Rflag) /* Change it at FTS_DP. */
|
||||
continue;
|
||||
fts_set(ftsp, p, FTS_SKIP);
|
||||
break;
|
||||
case FTS_DNR: /* Warn, chflag, continue. */
|
||||
warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
|
||||
rval = 1;
|
||||
break;
|
||||
case FTS_ERR: /* Warn, continue. */
|
||||
case FTS_NS:
|
||||
warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
|
||||
rval = 1;
|
||||
continue;
|
||||
case FTS_SL: /* Ignore. */
|
||||
case FTS_SLNONE:
|
||||
/*
|
||||
* The only symlinks that end up here are ones that
|
||||
* don't point to anything and ones that we found
|
||||
* doing a physical walk.
|
||||
*/
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (oct) {
|
||||
if (!chflags(p->fts_accpath, set))
|
||||
continue;
|
||||
} else {
|
||||
p->fts_statp->st_flags |= set;
|
||||
p->fts_statp->st_flags &= clear;
|
||||
if (!chflags(p->fts_accpath, p->fts_statp->st_flags))
|
||||
continue;
|
||||
}
|
||||
warn("%s", p->fts_path);
|
||||
rval = 1;
|
||||
}
|
||||
if (errno)
|
||||
err(1, "fts_read");
|
||||
exit(rval);
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: chflags [-R [-H | -L | -P]] flags file ...\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# $Id: $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
PROG= chio
|
||||
SRCS= chio.c
|
||||
BINOWN= root
|
||||
BINMODE=4555
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
.\" $NetBSD: $
|
||||
.\"
|
||||
.\" Copyright (c) 1996 Jason R. Thorpe <[email protected]>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgements:
|
||||
.\" This product includes software developed by Jason R. Thorpe
|
||||
.\" for And Communications, http://www.and.com/
|
||||
.\" 4. The name of the author may not be used to endorse or promote products
|
||||
.\" derived from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd April 2, 1996
|
||||
.Dt CHIO 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm chio
|
||||
.Nd medium changer control utility
|
||||
.Sh SYNOPSIS
|
||||
.Nm chio
|
||||
.Op Fl f Ar changer
|
||||
.Ar command
|
||||
.Ar arg1
|
||||
.Ar arg2
|
||||
.Oo
|
||||
.Ar arg3 Oo ...
|
||||
.Oc
|
||||
.Oc
|
||||
.Sh DESCRIPTION
|
||||
.Nm Chio
|
||||
is used to control the operation of medium changers, such as those found
|
||||
in tape and optical disk jukeboxes.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl f Ar changer
|
||||
Use the device
|
||||
.Pa changer
|
||||
rather than the default device
|
||||
.Pa /dev/ch0 .
|
||||
.El
|
||||
.Pp
|
||||
The default changer may be overridden by setting the environment variable
|
||||
.Nm CHANGER
|
||||
to the desired changer device.
|
||||
.Pp
|
||||
A medium changer apparatus is made up of
|
||||
.Pa elements .
|
||||
There are four element types:
|
||||
.Pa picker
|
||||
(medium transport),
|
||||
.Pa slot
|
||||
(storage),
|
||||
.Pa portal
|
||||
(import/export), and
|
||||
.Pa drive
|
||||
(data transfer). In this command description, the shorthand
|
||||
.Nm ET
|
||||
will be used to represent an element type, and
|
||||
.Nm EU
|
||||
will be used to represent an element unit. For example, to represent
|
||||
the first robotic arm in the changer, the ET would be
|
||||
.Dq picker
|
||||
and the EU would be
|
||||
.Dq 0 .
|
||||
.Pp
|
||||
.Sh SUPPORTED COMMANDS
|
||||
.Nm chio move
|
||||
.Ar <from ET> <from EU> <to ET> <to EU>
|
||||
.Op Ar inv
|
||||
.Pp
|
||||
Moves the media unit from
|
||||
.Pa <from ET/EU>
|
||||
to
|
||||
.Pa <to ET/EU> .
|
||||
If the optional modifier
|
||||
.Pa inv
|
||||
is specified, the media unit will be inverted before insertion.
|
||||
.Pp
|
||||
.Nm chio exchange
|
||||
.Ar <src ET> <src EU> <dst1 ET> <dst1 EU>
|
||||
.Op Ar <dst2 ET> <dst2 ET>
|
||||
.Op Ar inv1
|
||||
.Op Ar inv2
|
||||
.Pp
|
||||
Performs a media unit exchange operation. The media unit in
|
||||
.Pa <src ET/EU>
|
||||
is moved to
|
||||
.Pa <dst1 ET/EU>
|
||||
and the media unit previously in
|
||||
.Pa <dst1 ET/EU>
|
||||
is moved to
|
||||
.Pa <dst2 ET/EU> .
|
||||
In the case of a simple exchange,
|
||||
.Pa <dst2 ET/EU>
|
||||
is omitted and the values
|
||||
.Pa <src ET/EU>
|
||||
are used in their place.
|
||||
The optional modifiers
|
||||
.Pa inv1
|
||||
and
|
||||
.Pa inv2
|
||||
specify whether the media units are to be inverted before insertion into
|
||||
.Pa <dst1 ET/EU>
|
||||
and
|
||||
.Pa <dst2 ET/EU>
|
||||
respecitively.
|
||||
.Pp
|
||||
Note that not all medium changers support the
|
||||
.Nm exchange
|
||||
operation; The changer must have multiple free pickers or emulate
|
||||
multiple free pickers with transient storage.
|
||||
.Pp
|
||||
.Nm chio position
|
||||
.Ar <to ET> <to EU>
|
||||
.Op Ar inv
|
||||
.Pp
|
||||
Position the picker in front of the element described by
|
||||
.Pa <to ET/EU> .
|
||||
If the optional modifier
|
||||
.Pa inv
|
||||
is specified, the media unit will be inverted before insertion.
|
||||
.Pp
|
||||
Note that not all changers behave as expected when issued this command.
|
||||
.Pp
|
||||
.Nm chio params
|
||||
.Pp
|
||||
Report the number of slots, drives, pickers, and portals in the changer,
|
||||
and which picker unit the changer is currently configured to use.
|
||||
.Pp
|
||||
.Nm chio getpicker
|
||||
.Pp
|
||||
Report which picker unit the changer is currently configured to use.
|
||||
.Pp
|
||||
.Nm chio setpicker
|
||||
.Ar <unit>
|
||||
.Pp
|
||||
Configure the changer to use picker
|
||||
.Pa <unit> .
|
||||
.Pp
|
||||
.Nm chio status
|
||||
.Op Ar <type>
|
||||
.Pp
|
||||
Report the status of all elements in the changer. If
|
||||
.Pa <type>
|
||||
is specified, report the status of all elements of type
|
||||
.Pa <type> .
|
||||
.Pp
|
||||
The status bits are defined as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Nm FULL
|
||||
Element contains a media unit.
|
||||
.It Nm IMPEXP
|
||||
Media was deposited into element by an outside human operator.
|
||||
.It Nm EXCEPT
|
||||
Element is in an abnormal state.
|
||||
.It Nm ACCESS
|
||||
Media in this element is accessible by a picker.
|
||||
.It Nm EXENAB
|
||||
Element supports passing media (exporting) to an outsite human operator.
|
||||
.It Nm INENAB
|
||||
Element supports receiving media (importing) from an outside human operator.
|
||||
.El
|
||||
.Pp
|
||||
.Sh EXAMPLES
|
||||
.Nm chio move slot 3 drive 0
|
||||
.Pp
|
||||
Moves the media in slot 3 (fourth slot) to drive 0 (first drive).
|
||||
.Pp
|
||||
.Nm chio setpicker 2
|
||||
Configures the changer to use picker 2 (third picker) for operations.
|
||||
.Pp
|
||||
.Sh FILES
|
||||
/dev/ch0 - default changer device
|
||||
.Sh SEE ALSO
|
||||
.Xr mt 1 ,
|
||||
.Xr mount 8 .
|
||||
.Sh AUTHOR
|
||||
The
|
||||
.Nm chio
|
||||
program and SCSI changer driver were written by Jason R. Thorpe
|
||||
<[email protected]> for And Communications, http://www.and.com/
|
||||
+663
@@ -0,0 +1,663 @@
|
||||
/* $Id: $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Jason R. Thorpe <[email protected]>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgements:
|
||||
* This product includes software developed by Jason R. Thorpe
|
||||
* for And Communications, http://www.and.com/
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/chio.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "defs.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
extern char *__progname; /* from crt0.o */
|
||||
|
||||
static void usage __P((void));
|
||||
static void cleanup __P((void));
|
||||
static int parse_element_type __P((char *));
|
||||
static int parse_element_unit __P((char *));
|
||||
static int parse_special __P((char *));
|
||||
static int is_special __P((char *));
|
||||
static char *bits_to_string __P((int, const char *));
|
||||
|
||||
static int do_move __P((char *, int, char **));
|
||||
static int do_exchange __P((char *, int, char **));
|
||||
static int do_position __P((char *, int, char **));
|
||||
static int do_params __P((char *, int, char **));
|
||||
static int do_getpicker __P((char *, int, char **));
|
||||
static int do_setpicker __P((char *, int, char **));
|
||||
static int do_status __P((char *, int, char **));
|
||||
|
||||
/* Valid changer element types. */
|
||||
const struct element_type elements[] = {
|
||||
{ "picker", CHET_MT },
|
||||
{ "slot", CHET_ST },
|
||||
{ "portal", CHET_IE },
|
||||
{ "drive", CHET_DT },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
/* Valid commands. */
|
||||
const struct changer_command commands[] = {
|
||||
{ "move", do_move },
|
||||
{ "exchange", do_exchange },
|
||||
{ "position", do_position },
|
||||
{ "params", do_params },
|
||||
{ "getpicker", do_getpicker },
|
||||
{ "setpicker", do_setpicker },
|
||||
{ "status", do_status },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
/* Valid special words. */
|
||||
const struct special_word specials[] = {
|
||||
{ "inv", SW_INVERT },
|
||||
{ "inv1", SW_INVERT1 },
|
||||
{ "inv2", SW_INVERT2 },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
static int changer_fd;
|
||||
static char *changer_name;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int ch, i;
|
||||
char *cp;
|
||||
|
||||
while ((ch = getopt(argc, argv, "f:")) != -1) {
|
||||
switch (ch) {
|
||||
case 'f':
|
||||
changer_name = optarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc == 0)
|
||||
usage();
|
||||
|
||||
/* Get the default changer if not already specified. */
|
||||
if (changer_name == NULL)
|
||||
if ((changer_name = getenv(CHANGER_ENV_VAR)) == NULL)
|
||||
changer_name = _PATH_CH;
|
||||
|
||||
/* Open the changer device. */
|
||||
if ((changer_fd = open(changer_name, O_RDWR, 0600)) == -1)
|
||||
err(1, "%s: open", changer_name);
|
||||
|
||||
/* Register cleanup function. */
|
||||
if (atexit(cleanup))
|
||||
err(1, "can't register cleanup function");
|
||||
|
||||
/* Find the specified command. */
|
||||
for (i = 0; commands[i].cc_name != NULL; ++i)
|
||||
if (strcmp(*argv, commands[i].cc_name) == 0)
|
||||
break;
|
||||
if (commands[i].cc_name == NULL)
|
||||
errx(1, "unknown command: %s", *argv);
|
||||
|
||||
/* Skip over the command name and call handler. */
|
||||
++argv; --argc;
|
||||
exit ((*commands[i].cc_handler)(commands[i].cc_name, argc, argv));
|
||||
}
|
||||
|
||||
static int
|
||||
do_move(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct changer_move cmd;
|
||||
int val;
|
||||
|
||||
/*
|
||||
* On a move command, we expect the following:
|
||||
*
|
||||
* <from ET> <from EU> <to ET> <to EU> [inv]
|
||||
*
|
||||
* where ET == element type and EU == element unit.
|
||||
*/
|
||||
if (argc < 4) {
|
||||
warnx("%s: too few arguments", cname);
|
||||
goto usage;
|
||||
} else if (argc > 5) {
|
||||
warnx("%s: too many arguments", cname);
|
||||
goto usage;
|
||||
}
|
||||
bzero(&cmd, sizeof(cmd));
|
||||
|
||||
/* <from ET> */
|
||||
cmd.cm_fromtype = parse_element_type(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/* <from EU> */
|
||||
cmd.cm_fromunit = parse_element_unit(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/* <to ET> */
|
||||
cmd.cm_totype = parse_element_type(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/* <to EU> */
|
||||
cmd.cm_tounit = parse_element_unit(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/* Deal with optional command modifier. */
|
||||
if (argc) {
|
||||
val = parse_special(*argv);
|
||||
switch (val) {
|
||||
case SW_INVERT:
|
||||
cmd.cm_flags |= CM_INVERT;
|
||||
break;
|
||||
|
||||
default:
|
||||
errx(1, "%s: inappropriate modifier `%s'",
|
||||
cname, *argv);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
|
||||
/* Send command to changer. */
|
||||
if (ioctl(changer_fd, CHIOMOVE, (char *)&cmd))
|
||||
err(1, "%s: CHIOMOVE", changer_name);
|
||||
|
||||
return (0);
|
||||
|
||||
usage:
|
||||
fprintf(stderr, "usage: %s %s "
|
||||
"<from ET> <from EU> <to ET> <to EU> [inv]\n", __progname, cname);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
do_exchange(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct changer_exchange cmd;
|
||||
int val;
|
||||
|
||||
/*
|
||||
* On an exchange command, we expect the following:
|
||||
*
|
||||
* <src ET> <src EU> <dst1 ET> <dst1 EU> [<dst2 ET> <dst2 EU>] [inv1] [inv2]
|
||||
*
|
||||
* where ET == element type and EU == element unit.
|
||||
*/
|
||||
if (argc < 4) {
|
||||
warnx("%s: too few arguments", cname);
|
||||
goto usage;
|
||||
} else if (argc > 8) {
|
||||
warnx("%s: too many arguments", cname);
|
||||
goto usage;
|
||||
}
|
||||
bzero(&cmd, sizeof(cmd));
|
||||
|
||||
/* <src ET> */
|
||||
cmd.ce_srctype = parse_element_type(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/* <src EU> */
|
||||
cmd.ce_srcunit = parse_element_unit(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/* <dst1 ET> */
|
||||
cmd.ce_fdsttype = parse_element_type(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/* <dst1 EU> */
|
||||
cmd.ce_fdstunit = parse_element_unit(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/*
|
||||
* If the next token is a special word or there are no more
|
||||
* arguments, then this is a case of simple exchange.
|
||||
* dst2 == src.
|
||||
*/
|
||||
if ((argc == 0) || is_special(*argv)) {
|
||||
cmd.ce_sdsttype = cmd.ce_srctype;
|
||||
cmd.ce_sdstunit = cmd.ce_srcunit;
|
||||
goto do_special;
|
||||
}
|
||||
|
||||
/* <dst2 ET> */
|
||||
cmd.ce_sdsttype = parse_element_type(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/* <dst2 EU> */
|
||||
cmd.ce_sdstunit = parse_element_unit(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
do_special:
|
||||
/* Deal with optional command modifiers. */
|
||||
while (argc) {
|
||||
val = parse_special(*argv);
|
||||
++argv; --argc;
|
||||
switch (val) {
|
||||
case SW_INVERT1:
|
||||
cmd.ce_flags |= CE_INVERT1;
|
||||
break;
|
||||
|
||||
case SW_INVERT2:
|
||||
cmd.ce_flags |= CE_INVERT2;
|
||||
break;
|
||||
|
||||
default:
|
||||
errx(1, "%s: inappropriate modifier `%s'",
|
||||
cname, *argv);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
|
||||
/* Send command to changer. */
|
||||
if (ioctl(changer_fd, CHIOEXCHANGE, (char *)&cmd))
|
||||
err(1, "%s: CHIOEXCHANGE", changer_name);
|
||||
|
||||
return (0);
|
||||
|
||||
usage:
|
||||
fprintf(stderr, "usage: %s %s <src ET> <src EU> <dst1 ET> <dst1 EU>\n"
|
||||
" [<dst2 ET> <dst2 EU>] [inv1] [inv2]\n",
|
||||
__progname, cname);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
do_position(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct changer_position cmd;
|
||||
int val;
|
||||
|
||||
/*
|
||||
* On a position command, we expect the following:
|
||||
*
|
||||
* <to ET> <to EU> [inv]
|
||||
*
|
||||
* where ET == element type and EU == element unit.
|
||||
*/
|
||||
if (argc < 2) {
|
||||
warnx("%s: too few arguments", cname);
|
||||
goto usage;
|
||||
} else if (argc > 3) {
|
||||
warnx("%s: too many arguments", cname);
|
||||
goto usage;
|
||||
}
|
||||
bzero(&cmd, sizeof(cmd));
|
||||
|
||||
/* <to ET> */
|
||||
cmd.cp_type = parse_element_type(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/* <to EU> */
|
||||
cmd.cp_unit = parse_element_unit(*argv);
|
||||
++argv; --argc;
|
||||
|
||||
/* Deal with optional command modifier. */
|
||||
if (argc) {
|
||||
val = parse_special(*argv);
|
||||
switch (val) {
|
||||
case SW_INVERT:
|
||||
cmd.cp_flags |= CP_INVERT;
|
||||
break;
|
||||
|
||||
default:
|
||||
errx(1, "%s: inappropriate modifier `%s'",
|
||||
cname, *argv);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
|
||||
/* Send command to changer. */
|
||||
if (ioctl(changer_fd, CHIOPOSITION, (char *)&cmd))
|
||||
err(1, "%s: CHIOPOSITION", changer_name);
|
||||
|
||||
return (0);
|
||||
|
||||
usage:
|
||||
fprintf(stderr, "usage: %s %s <to ET> <to EU> [inv]\n",
|
||||
__progname, cname);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
do_params(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct changer_params data;
|
||||
|
||||
/* No arguments to this command. */
|
||||
if (argc) {
|
||||
warnx("%s: no arguements expected", cname);
|
||||
goto usage;
|
||||
}
|
||||
|
||||
/* Get params from changer and display them. */
|
||||
bzero(&data, sizeof(data));
|
||||
if (ioctl(changer_fd, CHIOGPARAMS, (char *)&data))
|
||||
err(1, "%s: CHIOGPARAMS", changer_name);
|
||||
|
||||
printf("%s: %d slot%s, %d drive%s, %d picker%s",
|
||||
changer_name,
|
||||
data.cp_nslots, (data.cp_nslots > 1) ? "s" : "",
|
||||
data.cp_ndrives, (data.cp_ndrives > 1) ? "s" : "",
|
||||
data.cp_npickers, (data.cp_npickers > 1) ? "s" : "");
|
||||
if (data.cp_nportals)
|
||||
printf(", %d portal%s", data.cp_nportals,
|
||||
(data.cp_nportals > 1) ? "s" : "");
|
||||
printf("\n%s: current picker: %d\n", changer_name, data.cp_curpicker);
|
||||
|
||||
return (0);
|
||||
|
||||
usage:
|
||||
fprintf(stderr, "usage: %s %s\n", __progname, cname);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
do_getpicker(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int picker;
|
||||
|
||||
/* No arguments to this command. */
|
||||
if (argc) {
|
||||
warnx("%s: no arguments expected", cname);
|
||||
goto usage;
|
||||
}
|
||||
|
||||
/* Get current picker from changer and display it. */
|
||||
if (ioctl(changer_fd, CHIOGPICKER, (char *)&picker))
|
||||
err(1, "%s: CHIOGPICKER", changer_name);
|
||||
|
||||
printf("%s: current picker: %d\n", changer_name, picker);
|
||||
|
||||
return (0);
|
||||
|
||||
usage:
|
||||
fprintf(stderr, "usage: %s %s\n", __progname, cname);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
do_setpicker(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int picker;
|
||||
|
||||
if (argc < 1) {
|
||||
warnx("%s: too few arguments", cname);
|
||||
goto usage;
|
||||
} else if (argc > 1) {
|
||||
warnx("%s: too many arguments", cname);
|
||||
goto usage;
|
||||
}
|
||||
|
||||
picker = parse_element_unit(*argv);
|
||||
|
||||
/* Set the changer picker. */
|
||||
if (ioctl(changer_fd, CHIOSPICKER, (char *)&picker))
|
||||
err(1, "%s: CHIOSPICKER", changer_name);
|
||||
|
||||
return (0);
|
||||
|
||||
usage:
|
||||
fprintf(stderr, "usage: %s %s <picker>\n", __progname, cname);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
do_status(cname, argc, argv)
|
||||
char *cname;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct changer_element_status cmd;
|
||||
struct changer_params data;
|
||||
u_int8_t *statusp;
|
||||
int i, count, chet, schet, echet;
|
||||
char *cmdname, *description;
|
||||
|
||||
/*
|
||||
* On a status command, we expect the following:
|
||||
*
|
||||
* [<ET>]
|
||||
*
|
||||
* where ET == element type.
|
||||
*
|
||||
* If we get no arguments, we get the status of all
|
||||
* known element types.
|
||||
*/
|
||||
if (argc > 1) {
|
||||
warnx("%s: too many arguments", cname);
|
||||
goto usage;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get params from changer. Specifically, we need the element
|
||||
* counts.
|
||||
*/
|
||||
bzero(&data, sizeof(data));
|
||||
if (ioctl(changer_fd, CHIOGPARAMS, (char *)&data))
|
||||
err(1, "%s: CHIOGPARAMS", changer_name);
|
||||
|
||||
if (argc)
|
||||
schet = echet = parse_element_type(*argv);
|
||||
else {
|
||||
schet = CHET_MT;
|
||||
echet = CHET_DT;
|
||||
}
|
||||
|
||||
for (chet = schet; chet <= echet; ++chet) {
|
||||
switch (chet) {
|
||||
case CHET_MT:
|
||||
count = data.cp_npickers;
|
||||
description = "picker";
|
||||
break;
|
||||
|
||||
case CHET_ST:
|
||||
count = data.cp_nslots;
|
||||
description = "slot";
|
||||
break;
|
||||
|
||||
case CHET_IE:
|
||||
count = data.cp_nportals;
|
||||
description = "portal";
|
||||
break;
|
||||
|
||||
case CHET_DT:
|
||||
count = data.cp_ndrives;
|
||||
description = "drive";
|
||||
break;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
if (argc == 0)
|
||||
continue;
|
||||
else {
|
||||
printf("%s: no %s elements\n",
|
||||
changer_name, description);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate storage for the status bytes. */
|
||||
if ((statusp = (u_int8_t *)malloc(count)) == NULL)
|
||||
errx(1, "can't allocate status storage");
|
||||
|
||||
bzero(statusp, count);
|
||||
bzero(&cmd, sizeof(cmd));
|
||||
|
||||
cmd.ces_type = chet;
|
||||
cmd.ces_data = statusp;
|
||||
|
||||
if (ioctl(changer_fd, CHIOGSTATUS, (char *)&cmd)) {
|
||||
free(statusp);
|
||||
err(1, "%s: CHIOGSTATUS", changer_name);
|
||||
}
|
||||
|
||||
/* Dump the status for each element of this type. */
|
||||
for (i = 0; i < count; ++i) {
|
||||
printf("%s %d: %s\n", description, i,
|
||||
bits_to_string(statusp[i], CESTATUS_BITS));
|
||||
}
|
||||
|
||||
free(statusp);
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
usage:
|
||||
fprintf(stderr, "usage: %s %s [<element type>]\n", __progname,
|
||||
cname);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
parse_element_type(cp)
|
||||
char *cp;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; elements[i].et_name != NULL; ++i)
|
||||
if (strcmp(elements[i].et_name, cp) == 0)
|
||||
return (elements[i].et_type);
|
||||
|
||||
errx(1, "invalid element type `%s'", cp);
|
||||
}
|
||||
|
||||
static int
|
||||
parse_element_unit(cp)
|
||||
char *cp;
|
||||
{
|
||||
int i;
|
||||
char *p;
|
||||
|
||||
i = (int)strtol(cp, &p, 10);
|
||||
if ((i < 0) || (*p != '\0'))
|
||||
errx(1, "invalid unit number `%s'", cp);
|
||||
|
||||
return (i);
|
||||
}
|
||||
|
||||
static int
|
||||
parse_special(cp)
|
||||
char *cp;
|
||||
{
|
||||
int val;
|
||||
|
||||
val = is_special(cp);
|
||||
if (val)
|
||||
return (val);
|
||||
|
||||
errx(1, "invalid modifier `%s'", cp);
|
||||
}
|
||||
|
||||
static int
|
||||
is_special(cp)
|
||||
char *cp;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; specials[i].sw_name != NULL; ++i)
|
||||
if (strcmp(specials[i].sw_name, cp) == 0)
|
||||
return (specials[i].sw_value);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static char *
|
||||
bits_to_string(v, cp)
|
||||
int v;
|
||||
const char *cp;
|
||||
{
|
||||
const char *np;
|
||||
char f, sep, *bp;
|
||||
static char buf[128];
|
||||
|
||||
bp = buf;
|
||||
bzero(buf, sizeof(buf));
|
||||
|
||||
for (sep = '<'; (f = *cp++) != 0; cp = np) {
|
||||
for (np = cp; *np >= ' ';)
|
||||
np++;
|
||||
if ((v & (1 << (f - 1))) == 0)
|
||||
continue;
|
||||
bp += sprintf(bp, "%c%.*s", sep, np - cp, cp);
|
||||
sep = ',';
|
||||
}
|
||||
if (sep != '<')
|
||||
*bp = '>';
|
||||
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup()
|
||||
{
|
||||
|
||||
/* Simple enough... */
|
||||
(void)close(changer_fd);
|
||||
}
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
|
||||
fprintf(stderr, "usage: %s command arg1 arg2 ...\n", __progname);
|
||||
exit(1);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/* $Id: $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Jason R. Thorpe <[email protected]>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgements:
|
||||
* This product includes software developed by Jason R. Thorpe
|
||||
* for And Communications, http://www.and.com/
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
struct element_type {
|
||||
char *et_name; /* name; i.e. "picker, "slot", etc. */
|
||||
int et_type; /* type number */
|
||||
};
|
||||
|
||||
struct changer_command {
|
||||
char *cc_name; /* command name */
|
||||
/* command handler */
|
||||
int (*cc_handler) __P((char *, int, char **));
|
||||
};
|
||||
|
||||
struct special_word {
|
||||
char *sw_name; /* special word */
|
||||
int sw_value; /* token value */
|
||||
};
|
||||
|
||||
/* sw_value */
|
||||
#define SW_INVERT 1 /* set "invert media" flag */
|
||||
#define SW_INVERT1 2 /* set "invert media 1" flag */
|
||||
#define SW_INVERT2 3 /* set "invert media 2" flag */
|
||||
|
||||
/* Environment variable to check for default changer. */
|
||||
#define CHANGER_ENV_VAR "CHANGER"
|
||||
@@ -0,0 +1,35 @@
|
||||
/* $Id: $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Jason R. Thorpe <[email protected]>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgements:
|
||||
* This product includes software developed by Jason R. Thorpe
|
||||
* for And Communications, http://www.and.com/
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _PATH_CH "/dev/ch0"
|
||||
+3
-2
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
|
||||
.\" $Id: chmod.1,v 1.3 1996/02/16 00:08:53 joerg Exp $
|
||||
.\" $Id: chmod.1,v 1.7 1997/02/22 14:01:29 peter Exp $
|
||||
.\"
|
||||
.Dd March 31, 1994
|
||||
.Dt CHMOD 1
|
||||
@@ -286,7 +286,8 @@ option for the naughty bits.
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm chmod
|
||||
utility is expected to be POSIX 1003.2
|
||||
utility is expected to be
|
||||
.St -p1003.2
|
||||
compatible with the exception of the
|
||||
.Ar perm
|
||||
symbols
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
|
||||
.\" $Id: cp.1,v 1.5 1996/03/08 06:58:05 wosch Exp $
|
||||
.\" $Id: cp.1,v 1.9 1997/02/22 14:01:32 peter Exp $
|
||||
.\"
|
||||
.Dd April 18, 1994
|
||||
.Dt CP 1
|
||||
@@ -213,7 +213,7 @@ or fifo's.
|
||||
.Xr umask 2 ,
|
||||
.Xr fts 3 ,
|
||||
.Xr symlink 7
|
||||
.Sh HISTORY
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm cp
|
||||
command is expected to be
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)csh.1 8.2 (Berkeley) 1/21/94
|
||||
.\" $Id: csh.1,v 1.4 1996/04/06 09:47:15 mpp Exp $
|
||||
.\" $Id: csh.1,v 1.8 1997/02/22 14:01:40 peter Exp $
|
||||
.\"
|
||||
.Dd January 21, 1994
|
||||
.Dt CSH 1
|
||||
@@ -2121,13 +2121,13 @@ substitutions on a single line to 20.
|
||||
.Xr fork 2 ,
|
||||
.Xr killpg 2 ,
|
||||
.Xr pipe 2 ,
|
||||
.Xr setrlimit 2 ,
|
||||
.Xr sigvec 2 ,
|
||||
.Xr umask 2 ,
|
||||
.Xr setrlimit 2 ,
|
||||
.Xr wait 2 ,
|
||||
.Xr tty 4 ,
|
||||
.Xr a.out 5 ,
|
||||
.Xr environ 7 ,
|
||||
.Xr environ 7
|
||||
.br
|
||||
.Em An introduction to the C shell
|
||||
.Sh HISTORY
|
||||
|
||||
+11
-8
@@ -32,8 +32,8 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)date.1 8.2 (Berkeley) 11/17/93
|
||||
.\" $Id: date.1,v 1.7 1996/03/12 05:30:39 nate Exp $
|
||||
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
|
||||
.\" $Id: date.1,v 1.11 1997/02/22 14:02:31 peter Exp $
|
||||
.\"
|
||||
.Dd November 17, 1993
|
||||
.Dt DATE 1
|
||||
@@ -50,7 +50,7 @@
|
||||
.Op Cm + Ns Ar format
|
||||
.Op [yy[mm[dd[hh]]]]mm[\&.ss]
|
||||
.Sh DESCRIPTION
|
||||
.Nm Date
|
||||
.Nm
|
||||
displays the current date and time when invoked without arguments.
|
||||
Providing arguments will format the date and time in a user-defined
|
||||
way or set the date.
|
||||
@@ -105,9 +105,11 @@ The format string may contain any of the conversion specifications described
|
||||
in the
|
||||
.Xr strftime 3
|
||||
manual page, as well as any arbitrary text.
|
||||
A <newline> character is always output after the characters specified by
|
||||
the format string.
|
||||
The format string for the default display is:
|
||||
.Bd -literal -offset indent
|
||||
``%+''.
|
||||
``+%+''
|
||||
.Ed
|
||||
.Pp
|
||||
If an operand does not have a leading plus sign, it is interpreted as
|
||||
@@ -137,7 +139,7 @@ and years are handled automatically.
|
||||
.Sh EXAMPLES
|
||||
The command:
|
||||
.Bd -literal -offset indent
|
||||
date ``+DATE: %m/%d/%y%nTIME: %H:%M:%S%n''
|
||||
date ``+DATE: %m/%d/%y%nTIME: %H:%M:%S''
|
||||
.Ed
|
||||
.Pp
|
||||
will display:
|
||||
@@ -162,9 +164,10 @@ date 1432
|
||||
sets the time to
|
||||
.Li "2:32 PM" ,
|
||||
without modifying the date.
|
||||
.Sh ENVIRONMENTAL VARIABLES
|
||||
The following environment variables affect the execution of
|
||||
.Nm date :
|
||||
.Sh ENVIRONMENT VARIABLES
|
||||
The execution of
|
||||
.Nm
|
||||
is affected by the following evironment variables:
|
||||
.Bl -tag -width Ds
|
||||
.It Ev TZ
|
||||
The timezone to use when displaying dates.
|
||||
|
||||
+3
-2
@@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: netdate.c,v 1.2 1994/09/24 02:54:38 davidg Exp $
|
||||
* $Id: netdate.c,v 1.3 1995/05/30 00:06:41 rgrimes Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -116,7 +116,8 @@ netsettime(tval)
|
||||
warn("gethostname");
|
||||
goto bad;
|
||||
}
|
||||
(void)strncpy(msg.tsp_name, hostname, sizeof(hostname));
|
||||
(void)strncpy(msg.tsp_name, hostname, sizeof(msg.tsp_name));
|
||||
msg.tsp_name[sizeof(msg.tsp_name) - 1] = '\0';
|
||||
msg.tsp_seq = htons((u_short)0);
|
||||
msg.tsp_time.tv_sec = htonl((u_long)tval);
|
||||
msg.tsp_time.tv_usec = htonl((u_long)0);
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: args.c,v 1.3 1994/09/24 02:54:42 davidg Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -100,7 +100,7 @@ jcl(argv)
|
||||
|
||||
in.dbsz = out.dbsz = 512;
|
||||
|
||||
while ((oper = *++argv)) {/* JEAG */
|
||||
while ((oper = *++argv) != NULL) {
|
||||
if ((arg = strchr(oper, '=')) == NULL)
|
||||
errx(1, "unknown operand %s", oper);
|
||||
*arg++ = '\0';
|
||||
|
||||
+5
-5
@@ -34,7 +34,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: conv.c,v 1.3 1994/09/24 02:54:44 davidg Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -61,7 +61,7 @@ def()
|
||||
int cnt;
|
||||
u_char *inp, *t;
|
||||
|
||||
if ((t = ctab))
|
||||
if ((t = ctab) != NULL)
|
||||
for (inp = in.dbp - (cnt = in.dbrcnt); cnt--; ++inp)
|
||||
*inp = t[*inp];
|
||||
|
||||
@@ -105,7 +105,6 @@ block()
|
||||
int ch, cnt, maxlen;
|
||||
u_char *inp, *outp, *t;
|
||||
|
||||
ch = 0;
|
||||
/*
|
||||
* Record truncation can cross block boundaries. If currently in a
|
||||
* truncation state, keep tossing characters until reach a newline.
|
||||
@@ -130,9 +129,10 @@ block()
|
||||
* Copy records (max cbsz size chunks) into the output buffer. The
|
||||
* translation is done as we copy into the output buffer.
|
||||
*/
|
||||
ch = 0; /* Help the compiler. */
|
||||
for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) {
|
||||
maxlen = MIN(cbsz, in.dbcnt);
|
||||
if ((t = ctab))
|
||||
if ((t = ctab) != NULL)
|
||||
for (cnt = 0;
|
||||
cnt < maxlen && (ch = *inp++) != '\n'; ++cnt)
|
||||
*outp++ = t[ch];
|
||||
@@ -216,7 +216,7 @@ unblock()
|
||||
u_char *inp, *t;
|
||||
|
||||
/* Translation and case conversion. */
|
||||
if ((t = ctab))
|
||||
if ((t = ctab) != NULL)
|
||||
for (cnt = in.dbrcnt, inp = in.dbp; cnt--;)
|
||||
*--inp = t[*inp];
|
||||
/*
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)dd.1 8.2 (Berkeley) 1/13/94
|
||||
.\" $Id$
|
||||
.\" $Id: dd.1,v 1.4 1997/02/22 14:02:43 peter Exp $
|
||||
.\"
|
||||
.Dd January 13, 1994
|
||||
.Dt DD 1
|
||||
|
||||
+6
-4
@@ -34,7 +34,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: dd.c,v 1.4 1995/01/17 23:04:29 ache Exp $
|
||||
* $Id: dd.c,v 1.5 1995/10/23 21:31:48 ache Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -56,12 +56,12 @@ static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "dd.h"
|
||||
#include "extern.h"
|
||||
@@ -85,7 +85,7 @@ main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
(void) setlocale(LC_CTYPE, "");
|
||||
(void)setlocale(LC_CTYPE, "");
|
||||
jcl(argv);
|
||||
setup();
|
||||
|
||||
@@ -105,6 +105,7 @@ static void
|
||||
setup()
|
||||
{
|
||||
u_int cnt;
|
||||
struct timeval tv;
|
||||
|
||||
if (in.name == NULL) {
|
||||
in.name = "stdin";
|
||||
@@ -213,7 +214,8 @@ setup()
|
||||
ctab[cnt] = cnt;
|
||||
}
|
||||
}
|
||||
(void)time(&st.start); /* Statistics timestamp. */
|
||||
(void)gettimeofday(&tv, (struct timezone *)NULL);
|
||||
st.start = tv.tv_sec + tv.tv_usec * 1e-6;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)dd.h 8.3 (Berkeley) 4/2/94
|
||||
* $Id$
|
||||
* $Id: dd.h,v 1.2 1994/09/24 02:54:54 davidg Exp $
|
||||
*/
|
||||
|
||||
/* Input/output stream state. */
|
||||
@@ -70,7 +70,7 @@ typedef struct {
|
||||
u_long trunc; /* # of truncated records */
|
||||
u_long swab; /* # of odd-length swab blocks */
|
||||
u_long bytes; /* # of bytes written */
|
||||
time_t start; /* start time of dd */
|
||||
double start; /* start time of dd */
|
||||
} STAT;
|
||||
|
||||
/* Flags (in ddflags). */
|
||||
|
||||
+9
-6
@@ -34,7 +34,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: misc.c,v 1.2 1994/09/24 02:55:01 davidg Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -42,6 +42,7 @@ static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
@@ -56,12 +57,14 @@ static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
|
||||
void
|
||||
summary()
|
||||
{
|
||||
time_t secs;
|
||||
struct timeval tv;
|
||||
double secs;
|
||||
char buf[100];
|
||||
|
||||
(void)time(&secs);
|
||||
if ((secs -= st.start) == 0)
|
||||
secs = 1;
|
||||
(void)gettimeofday(&tv, (struct timezone *)NULL);
|
||||
secs = tv.tv_sec + tv.tv_usec * 1e-6 - st.start;
|
||||
if (secs < 1e-6)
|
||||
secs = 1e-6;
|
||||
/* Use snprintf(3) so that we don't reenter stdio(3). */
|
||||
(void)snprintf(buf, sizeof(buf),
|
||||
"%u+%u records in\n%u+%u records out\n",
|
||||
@@ -78,7 +81,7 @@ summary()
|
||||
(void)write(STDERR_FILENO, buf, strlen(buf));
|
||||
}
|
||||
(void)snprintf(buf, sizeof(buf),
|
||||
"%u bytes transferred in %u secs (%u bytes/sec)\n",
|
||||
"%u bytes transferred in %.6f secs (%.0f bytes/sec)\n",
|
||||
st.bytes, secs, st.bytes / secs);
|
||||
(void)write(STDERR_FILENO, buf, strlen(buf));
|
||||
}
|
||||
|
||||
+6
-3
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)df.1 8.2 (Berkeley) 1/13/94
|
||||
.\" $Id: df.1,v 1.3 1994/09/24 02:55:08 davidg Exp $
|
||||
.\" $Id: df.1,v 1.4 1996/08/29 18:05:48 wosch Exp $
|
||||
.\"
|
||||
.Dd January 13, 1994
|
||||
.Dt DF 1
|
||||
@@ -78,11 +78,14 @@ with the possibly stale statistics that were previously obtained.
|
||||
.It Fl t
|
||||
Only print out statistics for filesystems of the specified types.
|
||||
The recognized types are:
|
||||
ufs, nfs, mfs, lfs, msdos, fdesc, portal, kernfs, procfs, afs and isofs.
|
||||
ufs, nfs, mfs, lfs, msdos, fdesc, portal, kernfs, procfs, afs, isofs,
|
||||
iso9660fs, cdfs, and cd9660,
|
||||
along with the aggregates:
|
||||
all (the default),
|
||||
local (ufs, mfs, lfs, msdos, isofs),
|
||||
local (ufs, mfs, lfs, msdos, cd9660),
|
||||
and misc (fdesc, portal, kernfs, procfs).
|
||||
The names isofs, iso9660fs, cdfs, and cd9660 are aliases to each other
|
||||
all of them refering to the same type of file system.
|
||||
The string ``no'' may be prepending to a type to get its complement
|
||||
(e.g. ``nonfs'' to get non-NFS filesystems). The first
|
||||
.Fl t
|
||||
|
||||
+3
-1
@@ -35,7 +35,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: df.c,v 1.7 1995/05/30 00:06:42 rgrimes Exp $
|
||||
* $Id: df.c,v 1.8 1996/01/14 18:55:09 bde Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -95,6 +95,8 @@ struct typetab {
|
||||
{"procfs", MT(MOUNT_PROCFS)},
|
||||
{"afs", MT(MOUNT_AFS)},
|
||||
{"iso9660fs", MT(MOUNT_CD9660)},
|
||||
{"isofs", MT(MOUNT_CD9660)},
|
||||
{"cd9660", MT(MOUNT_CD9660)},
|
||||
{"cdfs", MT(MOUNT_CD9660)},
|
||||
{"misc", MT(MOUNT_LOFS)|MT(MOUNT_FDESC)|MT(MOUNT_PORTAL)|
|
||||
MT(MOUNT_KERNFS)|MT(MOUNT_PROCFS)},
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)hostname.1 8.1 (Berkeley) 5/31/93
|
||||
.\" $Id: hostname.1,v 1.2 1994/09/24 02:55:40 davidg Exp $
|
||||
.\" @(#)hostname.1 8.2 (Berkeley) 4/28/95
|
||||
.\" $Id: hostname.1,v 1.6 1997/02/22 14:03:41 peter Exp $
|
||||
.\"
|
||||
.Dd May 31, 1993
|
||||
.Dd April 28, 1995
|
||||
.Dt HOSTNAME 1
|
||||
.Os BSD 4.2
|
||||
.Sh NAME
|
||||
@@ -41,9 +41,9 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm hostname
|
||||
.Op Fl s
|
||||
.Op Ar nameofhost
|
||||
.Op Ar name-of-host
|
||||
.Sh DESCRIPTION
|
||||
.Nm Hostname
|
||||
.Nm
|
||||
prints the name of the current host. The super-user can
|
||||
set the hostname by supplying an argument; this is usually done in the
|
||||
network initialization script
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: cmp.c,v 1.2 1994/09/24 02:55:52 davidg Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -53,14 +53,14 @@ int
|
||||
namecmp(a, b)
|
||||
const FTSENT *a, *b;
|
||||
{
|
||||
return (strcmp(a->fts_name, b->fts_name));
|
||||
return (strcoll(a->fts_name, b->fts_name));
|
||||
}
|
||||
|
||||
int
|
||||
revnamecmp(a, b)
|
||||
const FTSENT *a, *b;
|
||||
{
|
||||
return (strcmp(b->fts_name, a->fts_name));
|
||||
return (strcoll(b->fts_name, a->fts_name));
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
+10
-3
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)ls.1 8.6 (Berkeley) 4/18/94
|
||||
.\" $Id: ls.1,v 1.4 1995/09/26 08:48:09 mpp Exp $
|
||||
.\" $Id: ls.1,v 1.5.2.1 1997/02/25 00:38:13 mpp Exp $
|
||||
.\"
|
||||
.Dd April 18, 1994
|
||||
.Dt LS 1
|
||||
@@ -43,7 +43,7 @@
|
||||
.Nd list directory contents
|
||||
.Sh SYNOPSIS
|
||||
.Nm ls
|
||||
.Op Fl ACFLRTacdfiloqrstu1
|
||||
.Op Fl ACFLRTacdfgiloqrstu1
|
||||
.Op Ar file ...
|
||||
.Sh DESCRIPTION
|
||||
For each operand that names a
|
||||
@@ -104,6 +104,13 @@ Directories are listed as plain files (not searched recursively) and
|
||||
symbolic links in the argument list are not indirected through.
|
||||
.It Fl f
|
||||
Output is not sorted.
|
||||
.It Fl g
|
||||
This option is deprecated and is only available for compatibility
|
||||
with
|
||||
.Bx 4.3 ;
|
||||
it was used to display the group name in the long
|
||||
.Pq Fl l
|
||||
format output.
|
||||
.It Fl i
|
||||
For each file, print the file's file serial number (inode number).
|
||||
.It Fl k
|
||||
@@ -116,7 +123,7 @@ sizes is output on a line before the long listing.
|
||||
.It Fl o
|
||||
Include the file flags in a long
|
||||
.Pq Fl l
|
||||
output
|
||||
output.
|
||||
.It Fl q
|
||||
Force printing of non-graphic characters in file names as
|
||||
the character `?'; this is the default when output is to a terminal.
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)mkdir.1 8.2 (Berkeley) 1/25/94
|
||||
.\" $Id: mkdir.1,v 1.2 1994/09/24 02:56:02 davidg Exp $
|
||||
.\" $Id: mkdir.1,v 1.6 1997/02/22 14:04:08 peter Exp $
|
||||
.\"
|
||||
.Dd January 25, 1994
|
||||
.Dt MKDIR 1
|
||||
@@ -47,7 +47,7 @@
|
||||
.Op Fl m Ar mode
|
||||
.Ar directory_name ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm Mkdir
|
||||
.Nm
|
||||
creates the directories named as operands, in the order specified,
|
||||
using mode
|
||||
.Li rwxrwxrwx (\&0777)
|
||||
@@ -81,7 +81,7 @@ permission for the owner.
|
||||
.Pp
|
||||
The user must have write permission in the parent directory.
|
||||
.Pp
|
||||
.Nm Mkdir
|
||||
.Nm
|
||||
exits 0 if successful, and >0 if an error occurred.
|
||||
.Sh SEE ALSO
|
||||
.Xr rmdir 1
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: fmt.c,v 1.5 1995/03/09 20:40:17 davidg Exp $
|
||||
* $Id: fmt.c,v 1.6 1995/10/23 21:03:40 ache Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -59,7 +59,7 @@ shquote(argv)
|
||||
char **argv;
|
||||
{
|
||||
char **p, *dst, *src;
|
||||
static char buf[ARG_MAX]; /* XXX */
|
||||
static char buf[4*ARG_MAX]; /* XXX */
|
||||
|
||||
if (*argv == 0) {
|
||||
buf[0] = 0;
|
||||
|
||||
+1
-2
@@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ps.c,v 1.12 1996/01/20 10:43:54 mpp Exp $
|
||||
* $Id: ps.c,v 1.13 1996/10/21 07:30:26 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -47,7 +47,6 @@ static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94";
|
||||
#include <sys/user.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
+6
-6
@@ -32,10 +32,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)pwd.1 8.1 (Berkeley) 5/31/93
|
||||
.\" $Id$
|
||||
.\" @(#)pwd.1 8.2 (Berkeley) 4/28/95
|
||||
.\" $Id: pwd.1,v 1.5 1997/02/22 14:05:15 peter Exp $
|
||||
.\"
|
||||
.Dd May 31, 1993
|
||||
.Dd April 28, 1995
|
||||
.Dt PWD 1
|
||||
.Os BSD 4
|
||||
.Sh NAME
|
||||
@@ -44,7 +44,7 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm pwd
|
||||
.Sh DESCRIPTION
|
||||
.Nm Pwd
|
||||
.Nm
|
||||
writes the absolute pathname of the current working directory to
|
||||
the standard output.
|
||||
.Pp
|
||||
@@ -54,11 +54,11 @@ The
|
||||
.Nm pwd
|
||||
command is expected to be
|
||||
.St -p1003.2
|
||||
compatible .
|
||||
compatible.
|
||||
.Sh SEE ALSO
|
||||
.Xr cd 1 ,
|
||||
.Xr csh 1 ,
|
||||
.Xr getwd 3
|
||||
.Xr getcwd 3
|
||||
.Sh BUGS
|
||||
In
|
||||
.Xr csh 1
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)rcp.1 8.1 (Berkeley) 5/31/93
|
||||
.\" $Id$
|
||||
.\" $Id: rcp.1,v 1.5 1997/02/22 14:05:21 peter Exp $
|
||||
.\"
|
||||
.Dd May 31, 1993
|
||||
.Dt RCP 1
|
||||
@@ -130,8 +130,8 @@ are on the current machine.
|
||||
.Sh SEE ALSO
|
||||
.Xr cp 1 ,
|
||||
.Xr ftp 1 ,
|
||||
.Xr rsh 1 ,
|
||||
.Xr rlogin 1
|
||||
.Xr rlogin 1 ,
|
||||
.Xr rsh 1
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm rcp
|
||||
|
||||
+4
-4
@@ -30,7 +30,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)rmail.8 6.10 (Berkeley) 4/29/93
|
||||
.\" $Id$
|
||||
.\" $Id: rmail.8,v 1.5 1997/02/22 14:05:30 peter Exp $
|
||||
.\"
|
||||
.Dd April 29, 1993
|
||||
.Dt RMAIL 8
|
||||
@@ -42,7 +42,7 @@
|
||||
.Nm rmail
|
||||
.Ar user ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm Rmail
|
||||
.Nm
|
||||
interprets incoming mail received via
|
||||
.Xr uucp 1 ,
|
||||
collapsing ``From'' lines in the form generated
|
||||
@@ -52,7 +52,7 @@ into a single line of the form ``return-path!sender'',
|
||||
and passing the processed mail on to
|
||||
.Xr sendmail 8 .
|
||||
.Pp
|
||||
.Nm Rmail
|
||||
.Nm
|
||||
is explicitly designed for use with
|
||||
.Xr uucp
|
||||
and
|
||||
@@ -67,6 +67,6 @@ The
|
||||
program appeared in
|
||||
.Bx 4.2 .
|
||||
.Sh BUGS
|
||||
.Nm Rmail
|
||||
.Nm
|
||||
should not reside in
|
||||
.Pa /bin .
|
||||
+2
-19
@@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: eval.c,v 1.6 1996/10/06 15:17:19 steve Exp $
|
||||
* $Id: eval.c,v 1.8 1996/11/12 18:35:06 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -854,24 +854,7 @@ cmddone:
|
||||
parent: /* parent process gets here (if we forked) */
|
||||
if (mode == 0) { /* argument to fork */
|
||||
INTOFF;
|
||||
if (minusc) {
|
||||
struct sigaction iact, qact, oiact, oqact;
|
||||
|
||||
(void)sigaction(SIGINT, (struct sigaction *)NULL, &oiact);
|
||||
(void)sigaction(SIGQUIT, (struct sigaction *)NULL, &oqact);
|
||||
|
||||
iact = oiact;
|
||||
qact = oqact;
|
||||
|
||||
qact.sa_handler = iact.sa_handler = SIG_IGN;
|
||||
|
||||
(void)sigaction(SIGINT, &iact, (struct sigaction *)NULL);
|
||||
(void)sigaction(SIGQUIT, &qact, (struct sigaction *)NULL);
|
||||
exitstatus = waitforjob(jp);
|
||||
(void)sigaction(SIGINT, &oiact, (struct sigaction *)NULL);
|
||||
(void)sigaction(SIGQUIT, &oqact, (struct sigaction *)NULL);
|
||||
} else
|
||||
exitstatus = waitforjob(jp);
|
||||
exitstatus = waitforjob(jp);
|
||||
INTON;
|
||||
} else if (mode == 2) {
|
||||
backcmd->fd = pip[0];
|
||||
|
||||
+6
-3
@@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: expand.c,v 1.10 1996/09/10 02:42:30 peter Exp $
|
||||
* $Id: expand.c,v 1.11 1996/10/31 07:15:54 ache Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -335,7 +335,10 @@ expari(flag)
|
||||
* have to rescan starting from the beginning since CTLESC
|
||||
* characters have to be processed left to right.
|
||||
*/
|
||||
CHECKSTRSPACE(8, expdest);
|
||||
#if INT_MAX / 1000000000 >= 10 || INT_MIN / 1000000000 <= -10
|
||||
#error "integers with more than 10 digits are not supported"
|
||||
#endif
|
||||
CHECKSTRSPACE(12 - 2, expdest);
|
||||
USTPUTC('\0', expdest);
|
||||
start = stackblock();
|
||||
p = expdest;
|
||||
@@ -350,7 +353,7 @@ expari(flag)
|
||||
if (quotes)
|
||||
rmescapes(p+1);
|
||||
result = arith(p+1);
|
||||
fmtstr(p, 10, "%d", result);
|
||||
fmtstr(p, 12, "%d", result);
|
||||
while (*p++)
|
||||
;
|
||||
result = expdest - p + 1;
|
||||
|
||||
+2
-3
@@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: jobs.c,v 1.7 1996/09/03 14:15:52 peter Exp $
|
||||
* $Id: jobs.c,v 1.8 1996/10/16 02:30:39 steve Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -580,8 +580,7 @@ forkshell(jp, n, mode)
|
||||
pgrp = getpid();
|
||||
else
|
||||
pgrp = jp->ps[0].pid;
|
||||
setpgid(0, pgrp);
|
||||
if (mode == FORK_FG) {
|
||||
if (setpgid(0, pgrp) == 0 && mode == FORK_FG) {
|
||||
/*** this causes superfluous TIOCSPGRPS ***/
|
||||
if (ioctl(2, TIOCSPGRP, (char *)&pgrp) < 0)
|
||||
error("TIOCSPGRP failed, errno=%d", errno);
|
||||
|
||||
+2
-1
@@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: options.c,v 1.7 1996/09/01 10:21:16 peter Exp $
|
||||
* $Id: options.c,v 1.8 1996/10/29 03:12:48 steve Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -408,6 +408,7 @@ atend:
|
||||
if (*p == '\0' && (p = *shellparam.optnext++) == NULL) {
|
||||
out1fmt("No arg for -%c option\n", c);
|
||||
c = '?';
|
||||
shellparam.optnext--;
|
||||
goto out;
|
||||
}
|
||||
setvar("OPTARG", p, 0);
|
||||
|
||||
+106
-50
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)sh.1 8.6 (Berkeley) 5/4/95
|
||||
.\" $Id: sh.1,v 1.8 1996/09/03 14:15:59 peter Exp $
|
||||
.\" $Id: sh.1,v 1.12 1997/02/22 13:58:43 peter Exp $
|
||||
.\"
|
||||
.na
|
||||
.TH SH 1
|
||||
@@ -200,11 +200,11 @@ no effect when set after the shell has already started
|
||||
running (i.e. with set(1)).
|
||||
.TP
|
||||
-V vi
|
||||
Enable the builtin vi(1) command line editor (disables
|
||||
Enable the built-in vi(1) command line editor (disables
|
||||
-E if it has been set).
|
||||
.TP
|
||||
-E emacs
|
||||
Enable the builtin emacs(1) command line editor (disables
|
||||
Enable the built-in emacs(1) command line editor (disables
|
||||
-V if it has been set).
|
||||
.TP
|
||||
-b notify
|
||||
@@ -250,7 +250,8 @@ a <newline> is treated as a line continuation.
|
||||
.sp
|
||||
.LP
|
||||
Enclosing characters in single quotes preserves the literal
|
||||
meaning of all the characters.
|
||||
meaning of all the characters (except single quotes, making
|
||||
it impossible to put single-quotes in a single-quoted string).
|
||||
.sp 2
|
||||
.B Double Quotes
|
||||
.sp
|
||||
@@ -355,33 +356,33 @@ previously. Following is a list of the possible redirections.
|
||||
The [n] is an optional number, as in '3' (not '[3]'), that
|
||||
refers to a file descriptor.
|
||||
.TP
|
||||
[n]> file
|
||||
[n]> file
|
||||
Redirect standard output (or n) to file.
|
||||
.TP
|
||||
[n]>| file
|
||||
[n]>| file
|
||||
Same, but override the -C option.
|
||||
.TP
|
||||
[n]>> file
|
||||
[n]>> file
|
||||
Append standard output (or n) to file.
|
||||
.TP
|
||||
[n]< file
|
||||
[n]< file
|
||||
Redirect standard input (or n) from file.
|
||||
.TP
|
||||
[n1]<&n2
|
||||
[n1]<&n2
|
||||
Duplicate standard input (or n1) from
|
||||
file descriptor n2.
|
||||
.TP
|
||||
[n]<&-
|
||||
[n]<&-
|
||||
Close standard input (or n).
|
||||
.TP
|
||||
[n1]>&n2
|
||||
[n1]>&n2
|
||||
Duplicate standard output (or n) from
|
||||
n2.
|
||||
.TP
|
||||
[n]>&-
|
||||
[n]>&-
|
||||
Close standard output (or n).
|
||||
.TP
|
||||
[n]<> file
|
||||
[n]<> file
|
||||
Open file for reading and writing on
|
||||
standard input (or n).
|
||||
.LP
|
||||
@@ -406,11 +407,13 @@ in the here-doc-text are stripped.
|
||||
.B Search and Execution
|
||||
.sp
|
||||
.LP
|
||||
There are three types of commands: shell functions, builtin commands, and normal programs -- and the
|
||||
There are three types of commands: shell functions,
|
||||
builtin commands, and normal programs -- and the
|
||||
command is searched for (by name) in that order. They
|
||||
each are executed in a different way.
|
||||
.LP
|
||||
When a shell function is executed, all of the shell positional parameters (except $0, which remains unchanged) are
|
||||
When a shell function is executed, all of the shell positional
|
||||
parameters (except $0, which remains unchanged) are
|
||||
set to the arguments of the shell function.
|
||||
The variables which are explicitly placed in the environment of
|
||||
the command (by placing assignments to them before the
|
||||
@@ -418,37 +421,49 @@ function name) are made local to the function and are set
|
||||
to the values given. Then the command given in the function
|
||||
definition is executed. The positional parameters are
|
||||
restored to their original values when the command completes.
|
||||
This all occurs within the current shell.
|
||||
.LP
|
||||
Shell builtins are executed internally to the shell, without spawning a new process.
|
||||
Shell builtins are executed internally to the shell, without
|
||||
spawning a new process.
|
||||
.LP
|
||||
Otherwise, if the command name doesn't match a function
|
||||
or builtin, the command is searched for as a normal
|
||||
program in the filesystem (as described in the next section).
|
||||
When a normal program is executed, the shell runs the program,
|
||||
passing the arguments and the environment to the
|
||||
program. If the program is a shell procedure, the shell
|
||||
will interpret the program in a subshell. The shell will
|
||||
program. If the program is not a normal executable file
|
||||
(i.e., if it does not begin with the "magic number"
|
||||
whose ASCII representation is "#!", so execve(2) returns
|
||||
ENOEXEC then) the shell
|
||||
will interpret the program in a subshell. The child shell will
|
||||
reinitialize itself in this case, so that the effect will
|
||||
be as if a new shell had been invoked to handle the shell
|
||||
procedure, except that the location of commands located in
|
||||
be as if a new shell had been invoked to handle the ad-hoc shell
|
||||
script, except that the location of hashed commands located in
|
||||
the parent shell will be remembered by the child.
|
||||
.LP
|
||||
Note that previous versions of this document
|
||||
and the source code itself misleadingly and sporadically
|
||||
refer to a shell script without a magic number
|
||||
as a "shell procedure".
|
||||
.sp 2
|
||||
.B Path Search
|
||||
.sp
|
||||
.LP
|
||||
When locating a command, the shell first looks to see if
|
||||
it has a shell function by that name. Then it looks for a
|
||||
builtin command by that name.
|
||||
Finally, it searches each
|
||||
entry in PATH in turn for the command.
|
||||
.LP
|
||||
builtin command by that name. If a builtin command is not found,
|
||||
one of two things happen:
|
||||
.sp
|
||||
1) Command names containing a slash are simply executed without
|
||||
performing any searches.
|
||||
.sp
|
||||
2) The shell searches each entry in PATH in turn for the command.
|
||||
The value of the PATH variable should be a series of
|
||||
entries separated by colons. Each entry consists of a
|
||||
directory name.
|
||||
The current directory
|
||||
may be indicated by an empty directory name.
|
||||
.LP
|
||||
Command names containing a slash are simply executed without performing any of the above searches.
|
||||
may be indicated implicitly by an empty directory name,
|
||||
or explicitly by a single period.
|
||||
.sp 2
|
||||
.B Command Exit Status
|
||||
.sp
|
||||
@@ -459,7 +474,7 @@ with zero for normal or success, and non-zero for failure,
|
||||
error, or a false indication. The man page for each command
|
||||
should indicate the various exit codes and what they mean.
|
||||
Additionally, the builtin commands return exit codes, as does
|
||||
an executed function.
|
||||
an executed shell function.
|
||||
.sp 2
|
||||
.B Complex Commands
|
||||
.sp
|
||||
@@ -484,13 +499,14 @@ command. More generally, a command is one of the following:
|
||||
Unless otherwise stated, the exit status of a command is
|
||||
that of the last simple command executed by the command.
|
||||
.sp 2
|
||||
.B Pipeline
|
||||
.B Pipelines
|
||||
.sp
|
||||
.LP
|
||||
A pipeline is a sequence of one or more commands separated
|
||||
by the control operator |. The standard output of all but
|
||||
the last command is connected to the standard input
|
||||
of the next command.
|
||||
of the next command. The standard output of the last
|
||||
command is inherited from the shell, as usual.
|
||||
.LP
|
||||
The format for a pipeline is:
|
||||
.nf
|
||||
@@ -530,6 +546,12 @@ to the standard input of command2.
|
||||
A ; or <newline> terminator causes the preceding
|
||||
AND-OR-list (described next) to be executed sequentially; a & causes
|
||||
asynchronous execution of the preceding AND-OR-list.
|
||||
.LP
|
||||
Note that unlike some other shells, each process in the
|
||||
pipeline is a child of the invoking shell (unless it
|
||||
is a shell builtin, in which case it executes in the
|
||||
current shell -- but any effect it has on the
|
||||
environment is wiped).
|
||||
.sp 2
|
||||
.B Background Commands -- &
|
||||
.sp
|
||||
@@ -560,6 +582,9 @@ If command is followed by an ampersand, the shell starts the
|
||||
command and immediately proceed onto the next command;
|
||||
otherwise it waits for the command to terminate before
|
||||
proceeding to the next one.
|
||||
.sp 2
|
||||
.B Short-Circuit List Operators
|
||||
.sp
|
||||
.LP
|
||||
``&&'' and ``||'' are AND-OR list operators. ``&&'' executes
|
||||
the first command, and then executes the second command
|
||||
@@ -567,6 +592,9 @@ iff the exit status of the first command is zero. ``||''
|
||||
is similar, but executes the second command iff the exit
|
||||
status of the first command is nonzero. ``&&'' and ``||''
|
||||
both have the same priority.
|
||||
.sp 2
|
||||
.B Flow-Control Constructs -- if, while, for, case
|
||||
.sp
|
||||
.LP
|
||||
The syntax of the if command is
|
||||
.nf
|
||||
@@ -587,7 +615,9 @@ The syntax of the while command is
|
||||
done
|
||||
|
||||
.fi
|
||||
The two lists are executed repeatedly while the exit status of the first list is zero. The until command is similar, but has the word until in place of while
|
||||
The two lists are executed repeatedly while the exit status of the
|
||||
first list is zero. The until command is similar, but has the word
|
||||
until in place of while, which causes it to
|
||||
repeat until the exit status of the first list is zero.
|
||||
.LP
|
||||
The syntax of the for command is
|
||||
@@ -610,7 +640,8 @@ The syntax of the break and continue command is
|
||||
|
||||
.fi
|
||||
Break terminates the num innermost for or while loops.
|
||||
Continue continues with the next iteration of the innermost loop. These are implemented as builtin commands.
|
||||
Continue continues with the next iteration of the innermost loop.
|
||||
These are implemented as builtin commands.
|
||||
.LP
|
||||
The syntax of the case command is
|
||||
.nf
|
||||
@@ -624,7 +655,9 @@ The syntax of the case command is
|
||||
.LP
|
||||
The pattern can actually be one or more patterns (see Shell
|
||||
Patterns described later), separated by ``|'' characters.
|
||||
|
||||
.sp 2
|
||||
.B Grouping Commands Together
|
||||
.sp
|
||||
.LP
|
||||
Commands may be grouped by writing either
|
||||
.nf
|
||||
@@ -639,6 +672,17 @@ or
|
||||
|
||||
.fi
|
||||
The first of these executes the commands in a subshell.
|
||||
Builtin commands grouped into a (list) will not affect
|
||||
the current shell.
|
||||
The second form does not fork another shell so is
|
||||
slightly more efficient.
|
||||
Grouping commands together this way allows you to
|
||||
redirect their output as though they were one program:
|
||||
.nf
|
||||
|
||||
{ echo -n "hello"; echo " world" } > greeting
|
||||
|
||||
.fi
|
||||
.sp 2
|
||||
.B Functions
|
||||
.sp
|
||||
@@ -799,7 +843,7 @@ The $ character is used to introduce parameter expansion, command
|
||||
substitution, or arithmetic evaluation.
|
||||
.sp 2
|
||||
.B Tilde Expansion (substituting a user's home directory)
|
||||
.sp
|
||||
.sp
|
||||
.LP
|
||||
A word beginning with an unquoted tilde character (~) is
|
||||
subjected to tilde expansion. All the characters up to
|
||||
@@ -889,13 +933,13 @@ String Length. The length in characters of
|
||||
the value of parameter.
|
||||
.LP
|
||||
The following four varieties of parameter expansion provide for substring
|
||||
processing. In each case, pattern matching notation (see Shell Patterns), rather
|
||||
processing. In each case, pattern matching notation (see Shell Patterns),
|
||||
rather
|
||||
than regular expression notation, is used to evaluate the patterns.
|
||||
If parameter is * or @, the result of the expansion is unspecified.
|
||||
Enclosing the full parameter expansion string in double-quotes does not
|
||||
cause the following four varieties of pattern characters to be quoted,
|
||||
whereas quoting characters within the braces has this effect.
|
||||
(UNIMPLEMENTED IN 4.4alpha)
|
||||
.TP
|
||||
${parameter%word}
|
||||
Remove Smallest Suffix Pattern. The word
|
||||
@@ -903,7 +947,6 @@ is expanded to produce a pattern. The
|
||||
parameter expansion then results in
|
||||
parameter, with the smallest portion of the
|
||||
suffix matched by the pattern deleted.
|
||||
|
||||
.TP
|
||||
${parameter%%word}
|
||||
Remove Largest Suffix Pattern. The word
|
||||
@@ -991,12 +1034,14 @@ substitution into fields.
|
||||
.B Pathname Expansion (File Name Generation)
|
||||
.sp
|
||||
.LP
|
||||
Unless the -f flag is set, file name generation is performed after word splitting is complete. Each word is
|
||||
Unless the -f flag is set, file name generation is performed
|
||||
after word splitting is complete. Each word is
|
||||
viewed as a series of patterns, separated by slashes. The
|
||||
process of expansion replaces the word with the names of
|
||||
all existing files whose names can be formed by replacing
|
||||
each pattern with a string that matches the specified pattern.
|
||||
There are two restrictions on this: first, a pattern cannot match a string containing a slash, and second,
|
||||
There are two restrictions on this: first, a pattern cannot match
|
||||
a string containing a slash, and second,
|
||||
a pattern cannot match a string starting with a period
|
||||
unless the first character of the pattern is a period.
|
||||
The next section describes the patterns used for both
|
||||
@@ -1037,8 +1082,8 @@ minus sign, make it the first or last character listed
|
||||
.LP
|
||||
This section lists the builtin commands which
|
||||
are builtin because they need to perform some operation
|
||||
that can't be performed by a separate process. In addition
|
||||
to these, there are several other commands that may
|
||||
that can't be performed by a separate process. In addition to
|
||||
these, there are several other commands that may
|
||||
be builtin for efficiency (e.g. printf(1), echo(1), test(1),
|
||||
etc).
|
||||
.TP
|
||||
@@ -1060,8 +1105,8 @@ Continue the specified jobs (or the current job if no
|
||||
jobs are given) in the background.
|
||||
.TP
|
||||
command command arg...
|
||||
Execute the specified builtin command. (This is useful
|
||||
when you have a shell function with the same name
|
||||
Execute the specified builtin command. (This is useful when you
|
||||
have a shell function with the same name
|
||||
as a builtin command.)
|
||||
.TP
|
||||
cd [ directory ]
|
||||
@@ -1071,7 +1116,8 @@ of the cd command or the shell variable CDPATH is set
|
||||
and the directory name does not begin with a slash,
|
||||
then the directories listed in CDPATH will be
|
||||
searched for the specified directory. The format of
|
||||
CDPATH is the same as that of PATH. In an interactive shell, the cd command will print out the name of
|
||||
CDPATH is the same as that of PATH. In an interactive shell,
|
||||
the cd command will print out the name of
|
||||
the directory that it actually switched to if this is
|
||||
different from the name that the user gave. These
|
||||
may be different either because the CDPATH mechanism
|
||||
@@ -1085,7 +1131,8 @@ exec [ command arg... ]
|
||||
Unless command is omitted, the shell process is
|
||||
replaced with the specified program (which must be a
|
||||
real program, not a shell builtin or function). Any
|
||||
redirections on the exec command are marked as permanent, so that they are not undone when the exec command finishes.
|
||||
redirections on the exec command are marked as permanent,
|
||||
so that they are not undone when the exec command finishes.
|
||||
.TP
|
||||
exit [ exitstatus ]
|
||||
Terminate the shell process. If exitstatus is given
|
||||
@@ -1183,6 +1230,14 @@ foreground.
|
||||
.TP
|
||||
getopts optstring var
|
||||
The POSIX getopts command.
|
||||
The getopts command deprecates the older getopt command.
|
||||
The first argument should be a series of letters, each possibly
|
||||
followed by a colon which indicates that the option takes an argument.
|
||||
The specified variable is set to the parsed option. The index of
|
||||
the next argument is placed into the shell variable OPTIND.
|
||||
If an option takes an argument, it is placed into the shell variable
|
||||
OPTARG. If an invalid option is encountered, var is set to '?'.
|
||||
It returns a false value (1) when it encounters the end of the options.
|
||||
.TP
|
||||
hash -rv command...
|
||||
The shell maintains a hash table which remembers the
|
||||
@@ -1192,8 +1247,8 @@ table. Entries which have not been looked at since
|
||||
the last cd command are marked with an asterisk; it
|
||||
is possible for these entries to be invalid.
|
||||
.sp
|
||||
With arguments, the hash command removes the specified
|
||||
commands from the hash table (unless they are
|
||||
With arguments, the hash command removes the specified commands
|
||||
from the hash table (unless they are
|
||||
functions) and then locates them. With the -v
|
||||
option, hash prints the locations of the commands as
|
||||
it finds them. The -r option causes the hash command
|
||||
@@ -1261,7 +1316,8 @@ called ``Argument List Processing''.
|
||||
The third use of the set command is to set the values
|
||||
of the shell's positional parameters to the specified
|
||||
args. To change the positional parameters without
|
||||
changing any options, use ``--'' as the first argument to set. If no args are present, the set command
|
||||
changing any options, use ``--'' as the first argument
|
||||
to set. If no args are present, the set command
|
||||
will clear all the positional parameters (equivalent
|
||||
to executing ``shift $#''.
|
||||
.TP
|
||||
@@ -1341,8 +1397,8 @@ The maximal amount of CPU time to be used by each process, in seconds.
|
||||
.RE
|
||||
.TP
|
||||
umask [ mask ]
|
||||
Set the value of umask (see umask(2)) to the specified octal value.
|
||||
If the argument is omitted, the
|
||||
Set the value of umask (see umask(2)) to the specified
|
||||
octal value. If the argument is omitted, the
|
||||
umask value is printed.
|
||||
.TP
|
||||
unalias [-a] [name]
|
||||
|
||||
+5
-5
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)sleep.1 8.3 (Berkeley) 4/18/94
|
||||
.\" $Id$
|
||||
.\" $Id: sleep.1,v 1.6 1997/02/22 14:05:44 peter Exp $
|
||||
.\"
|
||||
.Dd April 18, 1994
|
||||
.Dt SLEEP 1
|
||||
@@ -50,13 +50,13 @@ The
|
||||
command
|
||||
suspends execution for a minimum of
|
||||
.Ar seconds .
|
||||
.Nm Sleep
|
||||
.Nm
|
||||
is used to schedule the execution of other commands (see
|
||||
.Sx EXAMPLES
|
||||
below).
|
||||
.Pp
|
||||
The
|
||||
.Nm Sleep
|
||||
.Nm
|
||||
utility exits with one of the following values:
|
||||
.Bl -tag -width flag
|
||||
.It Li \&0
|
||||
@@ -105,10 +105,10 @@ when the file is found, then another portion processing
|
||||
is done courteously by sleeping for 70 seconds in between each
|
||||
awk job.
|
||||
.Sh SEE ALSO
|
||||
.Xr at 1 ,
|
||||
.Xr setitimer 2 ,
|
||||
.Xr alarm 3 ,
|
||||
.Xr sleep 3 ,
|
||||
.Xr at 1
|
||||
.Xr sleep 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm sleep
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: key.c,v 1.3 1995/03/19 13:29:25 joerg Exp $
|
||||
* $Id: key.c,v 1.4 1995/04/28 19:29:29 ache Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -192,7 +192,7 @@ f_extproc(ip)
|
||||
struct info *ip;
|
||||
{
|
||||
|
||||
if (ip->set) {
|
||||
if (!ip->off) {
|
||||
int tmp = 1;
|
||||
(void)ioctl(ip->fd, TIOCEXT, &tmp);
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)stty.1 8.4 (Berkeley) 4/18/94
|
||||
.\" $Id: stty.1,v 1.3 1995/11/11 03:31:13 bde Exp $
|
||||
.\" $Id: stty.1,v 1.7 1997/03/12 15:59:22 mpp Exp $
|
||||
.\"
|
||||
.Dd April 18, 1994
|
||||
.Dt STTY 1
|
||||
@@ -551,7 +551,7 @@ The converse of
|
||||
.Cm opost .
|
||||
.It Cm tabs Pq Fl tabs
|
||||
The converse of
|
||||
.Cm tabs .
|
||||
.Cm oxtabs .
|
||||
.It Cm brk Ar value
|
||||
Same as the control character
|
||||
.Cm eol .
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: test.c,v 1.12 1995/10/28 11:54:42 ache Exp $
|
||||
* $Id: test.c,v 1.13 1996/03/11 11:01:03 joerg Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -157,7 +157,7 @@ main(argc, argv)
|
||||
ret_val = posix_unary_op(&argv[1]);
|
||||
if (ret_val >= 0)
|
||||
return (!ret_val);
|
||||
} else {
|
||||
} else if (lookup_op(argv[2], andor_op) < 0) {
|
||||
ret_val = posix_binary_op(&argv[1]);
|
||||
if (ret_val >= 0)
|
||||
return (ret_val);
|
||||
|
||||
+2
-2
@@ -341,12 +341,12 @@ end_final (filename)
|
||||
|
||||
ASM_OUTPUT_ALIGN (asm_out_file, align);
|
||||
|
||||
fprintf(asm_out_file,".stabs \"bbset\", 25, 0, 0, LPBX0\n");
|
||||
|
||||
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 0);
|
||||
/* zero word */
|
||||
assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
|
||||
|
||||
fprintf(asm_out_file,".stabs \"bbset\", 25, 0, 0, LPBX0\n");
|
||||
|
||||
/* address of filename */
|
||||
ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 1);
|
||||
assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,50 @@
|
||||
README for GNU development tools
|
||||
|
||||
This directory contains various GNU compilers, assemblers, linkers,
|
||||
debuggers, etc., plus their support routines, definitions, and documentation.
|
||||
|
||||
If you are receiving this as part of a GDB release, see the file gdb/README.
|
||||
If with a gas release, see gas/README; if with a libg++ release,
|
||||
see libg++/README, etc. That'll give you info about this
|
||||
package -- supported targets, how to use it, how to report bugs, etc.
|
||||
|
||||
It is now possible to automatically configure and build a variety of
|
||||
tools with one command. To build all of the tools contained herein,
|
||||
run the ``configure'' script here, e.g.:
|
||||
|
||||
./configure
|
||||
make
|
||||
|
||||
To install them (by default in /usr/local/bin, /usr/local/lib, etc),
|
||||
then do:
|
||||
make install
|
||||
|
||||
If the configure script can't determine your type of computer, give it
|
||||
the name as an argument, for instance ``./configure sun4''. You can
|
||||
use the script ``config.sub'' to test whether a name is recognized; if
|
||||
it is, config.sub translates it to a triplet specifying CPU, vendor,
|
||||
and OS.)
|
||||
|
||||
If you have more than one compiler on your system, it is often best to
|
||||
explicitly set CC in the environment before running configure, and to
|
||||
also set CC when running make. For example (assuming sh/bash/ksh):
|
||||
|
||||
CC=gcc ./configure
|
||||
make CC=gcc
|
||||
|
||||
A similar example using csh:
|
||||
|
||||
setenv CC gcc
|
||||
./configure
|
||||
make CC=gcc
|
||||
|
||||
See etc/cfg-paper.texi, etc/configure.texi, and/or the README files in
|
||||
various subdirectories, for more details.
|
||||
|
||||
Much of the code and documentation enclosed is copyright by
|
||||
the Free Software Foundation, Inc. See the file COPYING or
|
||||
COPYING.LIB in the various directories, for a description of the
|
||||
GNU General Public License terms under which you can copy the files.
|
||||
|
||||
REPORTING BUGS: Again, see gdb/README, gas/README, etc., for info on where and
|
||||
how to report problems.
|
||||
File renamed without changes.
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,83 @@
|
||||
Preliminary Notes on Porting BFD
|
||||
--------------------------------
|
||||
|
||||
The 'host' is the system a tool runs *on*.
|
||||
The 'target' is the system a tool runs *for*, i.e.
|
||||
a tool can read/write the binaries of the target.
|
||||
|
||||
Porting to a new host
|
||||
---------------------
|
||||
Pick a name for your host. Call that <host>.
|
||||
(<host> might be sun4, ...)
|
||||
Create a file hosts/<host>.mh.
|
||||
|
||||
Porting to a new target
|
||||
-----------------------
|
||||
Pick a name for your target. Call that <target>.
|
||||
Call the name for your CPU architecture <cpu>.
|
||||
You need to create <target>.c and config/<target>.mt,
|
||||
and add a case for it to a case statements in bfd/configure.host and
|
||||
bfd/config.bfd, which associates each canonical host type with a BFD
|
||||
host type (used as the base of the makefile fragment names), and to the
|
||||
table in bfd/configure.in which associates each target vector with
|
||||
the .o files it uses.
|
||||
|
||||
config/<target>.mt is a Makefile fragment.
|
||||
The following is usually enough:
|
||||
DEFAULT_VECTOR=<target>_vec
|
||||
SELECT_ARCHITECTURES=bfd_<cpu>_arch
|
||||
|
||||
See the list of cpu types in archures.c, or "ls cpu-*.c".
|
||||
If your architecture is new, you need to add it to the tables
|
||||
in bfd/archures.c, opcodes/configure.in, and binutils/objdump.c.
|
||||
|
||||
For more information about .mt and .mh files, see config/README.
|
||||
|
||||
The file <target>.c is the hard part. It implements the
|
||||
bfd_target <target>_vec, which includes pointers to
|
||||
functions that do the actual <target>-specific methods.
|
||||
|
||||
Porting to a <target> that uses the a.out binary format
|
||||
-------------------------------------------------------
|
||||
|
||||
In this case, the include file aout-target.h probaby does most
|
||||
of what you need. The program gen-aout generates <target>.c for
|
||||
you automatically for many a.out systems. Do:
|
||||
make gen-aout
|
||||
./gen-aout <target> > <target>.c
|
||||
(This only works if you are building on the target ("native").
|
||||
If you must make a cross-port from scratch, copy the most
|
||||
similar existing file that includes aout-target.h, and fix what is wrong.)
|
||||
|
||||
Check the parameters in <target>.c, and fix anything that is wrong.
|
||||
(Also let us know about it; perhaps we can improve gen-aout.c.)
|
||||
|
||||
TARGET_IS_BIG_ENDIAN_P
|
||||
Should be defined if <target> is big-endian.
|
||||
|
||||
N_HEADER_IN_TEXT(x)
|
||||
See discussion in ../include/aout/aout64.h.
|
||||
|
||||
BYTES_IN_WORD
|
||||
Number of bytes per word. (Usually 4 but can be 8.)
|
||||
|
||||
ARCH
|
||||
Number of bits per word. (Usually 32, but can be 64.)
|
||||
|
||||
ENTRY_CAN_BE_ZERO
|
||||
Define if the extry point (start address of an
|
||||
executable program) can be 0x0.
|
||||
|
||||
TEXT_START_ADDR
|
||||
The address of the start of the text segemnt in
|
||||
virtual memory. Normally, the same as the entry point.
|
||||
|
||||
TARGET_PAGE_SIZE
|
||||
|
||||
SEGMENT_SIZE
|
||||
Usually, the same as the TARGET_PAGE_SIZE.
|
||||
Alignment needed for the data segment.
|
||||
|
||||
TARGETNAME
|
||||
The name of the target, for run-time lookups.
|
||||
Usually "a.out-<target>"
|
||||
@@ -0,0 +1,25 @@
|
||||
Things that still need to be done: -*- Text -*-
|
||||
|
||||
o - A source of space lossage is that all the target-dependent code
|
||||
is in a single bfd_target structure. Hence all the code for
|
||||
*writing* object files is still pulled into all the applications
|
||||
that only care about *reading* (gdb, nm, objdump), while gas has
|
||||
to carry along all the unneded baggage for reading objects. And
|
||||
so on. This would be a substantial change, and the payoff would
|
||||
not all that great (essentially none if bfd is used as a shared
|
||||
library).
|
||||
|
||||
o - The storage needed by BFD data structures is also larger than strictly
|
||||
needed. This may be difficult to do much about.
|
||||
|
||||
o - implement bfd_abort, which should close the bfd but not alter the
|
||||
filesystem.
|
||||
|
||||
o - update the bfd doc; write a how-to-write-a-backend doc, take out
|
||||
the stupid quips and fill in all the blanks.
|
||||
|
||||
o - upgrade the reloc handling as per Steve's suggestion.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
cygnus-2.6
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
/* Whether malloc must be declared even if <stdlib.h> is included. */
|
||||
#undef NEED_DECLARATION_MALLOC
|
||||
|
||||
/* Whether free must be declared even if <stdlib.h> is included. */
|
||||
#undef NEED_DECLARATION_FREE
|
||||
@TOP@
|
||||
|
||||
/* Do we need to use the b modifier when opening binary files? */
|
||||
#undef USE_BINARY_FOPEN
|
||||
|
||||
/* Name of host specific header file to include in trad-core.c. */
|
||||
#undef TRAD_HEADER
|
||||
|
||||
/* Define only if <sys/procfs.h> is available *and* it defines prstatus_t. */
|
||||
#undef HAVE_SYS_PROCFS_H
|
||||
|
||||
/* Do we really want to use mmap if it's available? */
|
||||
#undef USE_MMAP
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
|
||||
AC_DEFUN(BFD_BINARY_FOPEN,
|
||||
[AC_REQUIRE([AC_CANONICAL_SYSTEM])
|
||||
case "${host}" in
|
||||
changequote(,)dnl
|
||||
i[345]86-*-msdos* | i[345]86-*-go32* | *-*-cygwin32)
|
||||
changequote([,])dnl
|
||||
AC_DEFINE(USE_BINARY_FOPEN) ;;
|
||||
esac])dnl
|
||||
|
||||
dnl Get a default for CC_FOR_BUILD to put into Makefile.
|
||||
AC_DEFUN(BFD_CC_FOR_BUILD,
|
||||
[# Put a plausible default for CC_FOR_BUILD in Makefile.
|
||||
AC_REQUIRE([AC_C_CROSS])dnl
|
||||
if test -z "$CC_FOR_BUILD"; then
|
||||
if test "x$cross_compiling" = "xno"; then
|
||||
CC_FOR_BUILD='$(CC)'
|
||||
else
|
||||
CC_FOR_BUILD=gcc
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(CC_FOR_BUILD)])dnl
|
||||
|
||||
dnl See whether we need a declaration for a function.
|
||||
AC_DEFUN(BFD_NEED_DECLARATION,
|
||||
[AC_MSG_CHECKING([whether $1 must be declared])
|
||||
AC_CACHE_VAL(bfd_cv_decl_needed_$1,
|
||||
[AC_TRY_COMPILE([
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif],
|
||||
[char *(*pfn) = (char *(*)) $1],
|
||||
bfd_cv_decl_needed_$1=no, bfd_cv_decl_needed_$1=yes)])
|
||||
AC_MSG_RESULT($bfd_cv_decl_needed_$1)
|
||||
if test $bfd_cv_decl_needed_$1 = yes; then
|
||||
bfd_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
|
||||
AC_DEFINE_UNQUOTED($bfd_tr_decl)
|
||||
fi
|
||||
])dnl
|
||||
@@ -0,0 +1,285 @@
|
||||
/* BFD back-end for AIX on PS/2 core files.
|
||||
This was based on trad-core.c, which was written by John Gilmore of
|
||||
Cygnus Support.
|
||||
Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Minh Tran-Le <TRANLE@INTELLICORP.COM>.
|
||||
Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/i386.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if defined (_AIX) && defined (_I386)
|
||||
#define NOCHECKS /* this is for coredump.h */
|
||||
#define _h_USER /* avoid including user.h from coredump.h */
|
||||
#include <uinfo.h>
|
||||
#include <sys/i386/coredump.h>
|
||||
#endif /* _AIX && _I386 */
|
||||
|
||||
/* maybe this could work on some other i386 but I have not tried it
|
||||
* mtranle@paris - Tue Sep 24 12:49:35 1991
|
||||
*/
|
||||
|
||||
#ifndef COR_MAGIC
|
||||
# define COR_MAGIC "core"
|
||||
#endif
|
||||
|
||||
/* need this cast because ptr is really void * */
|
||||
#define core_hdr(bfd) \
|
||||
(((bfd->tdata.trad_core_data))->hdr)
|
||||
#define core_section(bfd,n) \
|
||||
(((bfd)->tdata.trad_core_data)->sections[n])
|
||||
#define core_regsec(bfd) \
|
||||
(((bfd)->tdata.trad_core_data)->reg_section)
|
||||
#define core_reg2sec(bfd) \
|
||||
(((bfd)->tdata.trad_core_data)->reg2_section)
|
||||
|
||||
/* These are stored in the bfd's tdata */
|
||||
struct trad_core_struct {
|
||||
struct corehdr *hdr; /* core file header */
|
||||
asection *reg_section;
|
||||
asection *reg2_section;
|
||||
asection *sections[MAX_CORE_SEGS];
|
||||
};
|
||||
|
||||
static const bfd_target *
|
||||
aix386_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
int i,n;
|
||||
unsigned char longbuf[4]; /* Raw bytes of various header fields */
|
||||
int core_size = sizeof (struct corehdr);
|
||||
struct corehdr *core;
|
||||
struct mergem {
|
||||
struct trad_core_struct coredata;
|
||||
struct corehdr internal_core;
|
||||
} *mergem;
|
||||
|
||||
if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strncmp(longbuf,COR_MAGIC,4)) return 0;
|
||||
|
||||
if (bfd_seek (abfd, 0L, false) < 0) return 0;
|
||||
|
||||
mergem = (struct mergem *)bfd_zalloc (abfd, sizeof (struct mergem));
|
||||
if (mergem == NULL)
|
||||
return 0;
|
||||
|
||||
core = &mergem->internal_core;
|
||||
|
||||
if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
bfd_release (abfd, (char *)mergem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
set_tdata (abfd, &mergem->coredata);
|
||||
core_hdr (abfd) = core;
|
||||
|
||||
/* create the sections. This is raunchy, but bfd_close wants to reclaim
|
||||
them */
|
||||
core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_regsec (abfd) == NULL)
|
||||
{
|
||||
loser:
|
||||
bfd_release (abfd, (char *)mergem);
|
||||
return 0;
|
||||
}
|
||||
core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_reg2sec (abfd) == NULL)
|
||||
{
|
||||
loser1:
|
||||
bfd_release (abfd, core_regsec (abfd));
|
||||
goto loser;
|
||||
}
|
||||
|
||||
for (i=0, n=0 ; (i < MAX_CORE_SEGS) && (core->cd_segs[i].cs_type) ; i++)
|
||||
{
|
||||
if (core->cd_segs[i].cs_offset == 0)
|
||||
continue;
|
||||
core_section (abfd,n) =
|
||||
(asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_section (abfd,n) == NULL)
|
||||
{
|
||||
int j;
|
||||
if (n > 0)
|
||||
{
|
||||
for (j=0; j < n; j++)
|
||||
bfd_release (abfd, core_section(abfd, j));
|
||||
}
|
||||
bfd_release (abfd, (char *)mergem);
|
||||
goto loser1;
|
||||
}
|
||||
|
||||
switch (core->cd_segs[i].cs_type)
|
||||
{
|
||||
case COR_TYPE_DATA:
|
||||
core_section (abfd, n)->name = ".data";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_LOAD +
|
||||
SEC_HAS_CONTENTS);
|
||||
break;
|
||||
case COR_TYPE_STACK:
|
||||
core_section (abfd, n)->name = ".stack";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_LOAD +
|
||||
SEC_HAS_CONTENTS);
|
||||
break;
|
||||
case COR_TYPE_LIBDATA:
|
||||
core_section (abfd, n)->name = ".libdata";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||
break;
|
||||
case COR_TYPE_WRITE:
|
||||
core_section (abfd, n)->name = ".writeable";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||
break;
|
||||
case COR_TYPE_MSC:
|
||||
core_section (abfd, n)->name = ".misc";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||
break;
|
||||
default:
|
||||
core_section (abfd, n)->name = ".unknown";
|
||||
core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
|
||||
break;
|
||||
}
|
||||
core_section (abfd, n)->_raw_size = core->cd_segs[i].cs_len;
|
||||
core_section (abfd, n)->vma = core->cd_segs[i].cs_address;
|
||||
core_section (abfd, n)->filepos = core->cd_segs[i].cs_offset;
|
||||
core_section (abfd, n)->alignment_power = 2;
|
||||
core_section (abfd, n)->next = NULL;
|
||||
if (n > 0)
|
||||
core_section (abfd, (n-1))->next = core_section (abfd, n);
|
||||
|
||||
abfd->section_count = ++n;
|
||||
}
|
||||
|
||||
core_regsec (abfd)->name = ".reg";
|
||||
core_reg2sec (abfd)->name = ".reg2";
|
||||
|
||||
core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
|
||||
core_regsec (abfd)->_raw_size = sizeof(core->cd_regs);
|
||||
core_reg2sec (abfd)->_raw_size = sizeof(core->cd_fpregs);
|
||||
|
||||
core_regsec (abfd)->vma = -1;
|
||||
core_reg2sec (abfd)->vma = -1;
|
||||
|
||||
/* We'll access the regs afresh in the core file, like any section: */
|
||||
core_regsec (abfd)->filepos = (file_ptr)offsetof(struct corehdr,cd_regs[0]);
|
||||
core_reg2sec (abfd)->filepos = (file_ptr)offsetof(struct corehdr,
|
||||
cd_fpregs);
|
||||
|
||||
/* add the 2 reg fake sections to abfd */
|
||||
abfd->section_count += 2;
|
||||
abfd->sections = core_regsec (abfd);
|
||||
core_regsec (abfd)->next = core_reg2sec (abfd);
|
||||
core_reg2sec (abfd)->next = core_section (abfd, 0);
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
static char *
|
||||
aix386_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->cd_comm;
|
||||
}
|
||||
|
||||
static int
|
||||
aix386_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->cd_cursig;
|
||||
}
|
||||
|
||||
static boolean
|
||||
aix386_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
return true; /* FIXME, We have no way of telling at this
|
||||
point */
|
||||
}
|
||||
|
||||
/* If somebody calls any byte-swapping routines, shoot them. */
|
||||
void
|
||||
swap_abort()
|
||||
{
|
||||
abort(); /* This way doesn't require any declaration for ANSI to fuck up */
|
||||
}
|
||||
#define NO_GET ((PROTO(bfd_vma, (*), ( const bfd_byte *))) swap_abort )
|
||||
#define NO_GETS ((PROTO(bfd_signed_vma, (*), (const bfd_byte *))) swap_abort )
|
||||
#define NO_PUT ((PROTO(void, (*), (bfd_vma, bfd_byte *))) swap_abort )
|
||||
|
||||
const bfd_target aix386_core_vec =
|
||||
{
|
||||
"aix386-core",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order */
|
||||
BFD_ENDIANG_BIG, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT, /* data */
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT,
|
||||
NO_GET, NO_GETS, NO_PUT, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, _bfd_dummy_target,
|
||||
_bfd_dummy_target, aix386_core_file_p},
|
||||
{bfd_false, bfd_false, /* bfd_create_object */
|
||||
bfd_false, bfd_false},
|
||||
{bfd_false, bfd_false, /* bfd_write_contents */
|
||||
bfd_false, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (aix386),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0
|
||||
};
|
||||
@@ -0,0 +1,528 @@
|
||||
/* BFD back-end for a.out.adobe binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support. Based on bout.c.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include "aout/adobe.h"
|
||||
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
|
||||
extern const bfd_target a_out_adobe_vec; /* Forward decl */
|
||||
|
||||
static const bfd_target *aout_adobe_callback PARAMS ((bfd *));
|
||||
|
||||
extern boolean aout_32_slurp_symbol_table PARAMS ((bfd *abfd));
|
||||
extern boolean aout_32_write_syms PARAMS ((bfd *));
|
||||
static void aout_adobe_write_section PARAMS ((bfd *abfd, sec_ptr sect));
|
||||
|
||||
/* Swaps the information in an executable header taken from a raw byte
|
||||
stream memory image, into the internal exec_header structure. */
|
||||
|
||||
void aout_adobe_swap_exec_header_in
|
||||
PARAMS ((bfd *abfd, struct external_exec *raw_bytes,
|
||||
struct internal_exec *execp));
|
||||
|
||||
void
|
||||
aout_adobe_swap_exec_header_in (abfd, raw_bytes, execp)
|
||||
bfd *abfd;
|
||||
struct external_exec *raw_bytes;
|
||||
struct internal_exec *execp;
|
||||
{
|
||||
struct external_exec *bytes = (struct external_exec *)raw_bytes;
|
||||
|
||||
/* Now fill in fields in the execp, from the bytes in the raw data. */
|
||||
execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
|
||||
execp->a_text = GET_WORD (abfd, bytes->e_text);
|
||||
execp->a_data = GET_WORD (abfd, bytes->e_data);
|
||||
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
|
||||
execp->a_syms = GET_WORD (abfd, bytes->e_syms);
|
||||
execp->a_entry = GET_WORD (abfd, bytes->e_entry);
|
||||
execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
|
||||
execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
|
||||
}
|
||||
|
||||
/* Swaps the information in an internal exec header structure into the
|
||||
supplied buffer ready for writing to disk. */
|
||||
|
||||
PROTO(void, aout_adobe_swap_exec_header_out,
|
||||
(bfd *abfd,
|
||||
struct internal_exec *execp,
|
||||
struct external_exec *raw_bytes));
|
||||
void
|
||||
aout_adobe_swap_exec_header_out (abfd, execp, raw_bytes)
|
||||
bfd *abfd;
|
||||
struct internal_exec *execp;
|
||||
struct external_exec *raw_bytes;
|
||||
{
|
||||
struct external_exec *bytes = (struct external_exec *)raw_bytes;
|
||||
|
||||
/* Now fill in fields in the raw data, from the fields in the exec struct. */
|
||||
bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
|
||||
PUT_WORD (abfd, execp->a_text , bytes->e_text);
|
||||
PUT_WORD (abfd, execp->a_data , bytes->e_data);
|
||||
PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
|
||||
PUT_WORD (abfd, execp->a_syms , bytes->e_syms);
|
||||
PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
|
||||
PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
|
||||
PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
|
||||
}
|
||||
|
||||
|
||||
static const bfd_target *
|
||||
aout_adobe_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec anexec;
|
||||
struct external_exec exec_bytes;
|
||||
char *targ;
|
||||
|
||||
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
|
||||
!= EXEC_BYTES_SIZE) {
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
|
||||
|
||||
/* Normally we just compare for the magic number.
|
||||
However, a bunch of Adobe tools aren't fixed up yet; they generate
|
||||
files using ZMAGIC(!).
|
||||
If the environment variable GNUTARGET is set to "a.out.adobe", we will
|
||||
take just about any a.out file as an Adobe a.out file. FIXME! */
|
||||
|
||||
if (N_BADMAG (anexec)) {
|
||||
extern char *getenv ();
|
||||
|
||||
targ = getenv ("GNUTARGET");
|
||||
if (targ && !strcmp (targ, a_out_adobe_vec.name))
|
||||
; /* Just continue anyway, if specifically set to this format */
|
||||
else
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
aout_adobe_swap_exec_header_in (abfd, &exec_bytes, &anexec);
|
||||
return aout_32_some_aout_object_p (abfd, &anexec, aout_adobe_callback);
|
||||
}
|
||||
|
||||
|
||||
/* Finish up the opening of a b.out file for reading. Fill in all the
|
||||
fields that are not handled by common code. */
|
||||
|
||||
static const bfd_target *
|
||||
aout_adobe_callback (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
asection *sect;
|
||||
struct external_segdesc ext[1];
|
||||
char *section_name;
|
||||
char try_again[30]; /* name and number */
|
||||
char *newname;
|
||||
int trynum;
|
||||
flagword flags;
|
||||
|
||||
/* Architecture and machine type -- unknown in this format. */
|
||||
bfd_set_arch_mach(abfd, bfd_arch_unknown, 0);
|
||||
|
||||
/* The positions of the string table and symbol table. */
|
||||
obj_str_filepos (abfd) = N_STROFF (*execp);
|
||||
obj_sym_filepos (abfd) = N_SYMOFF (*execp);
|
||||
|
||||
/* Suck up the section information from the file, one section at a time. */
|
||||
|
||||
for (;;) {
|
||||
if (bfd_read ((PTR) ext, 1, sizeof (*ext), abfd) != sizeof (*ext)) {
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
switch (ext->e_type[0]) {
|
||||
case N_TEXT:
|
||||
section_name = ".text";
|
||||
flags = SEC_CODE | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||
break;
|
||||
|
||||
case N_DATA:
|
||||
section_name = ".data";
|
||||
flags = SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||
break;
|
||||
|
||||
case N_BSS:
|
||||
section_name = ".bss";
|
||||
flags = SEC_DATA | SEC_HAS_CONTENTS;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
goto no_more_sections;
|
||||
|
||||
default:
|
||||
(*_bfd_error_handler)
|
||||
("%s: Unknown section type in a.out.adobe file: %x\n",
|
||||
bfd_get_filename (abfd), ext->e_type[0]);
|
||||
goto no_more_sections;
|
||||
}
|
||||
|
||||
/* First one is called ".text" or whatever; subsequent ones are
|
||||
".text1", ".text2", ... */
|
||||
|
||||
bfd_set_error (bfd_error_no_error);
|
||||
sect = bfd_make_section (abfd, section_name);
|
||||
trynum = 0;
|
||||
while (!sect) {
|
||||
if (bfd_get_error () != bfd_error_no_error)
|
||||
return 0; /* Some other error -- slide into the sunset */
|
||||
sprintf (try_again, "%s%d", section_name, ++trynum);
|
||||
sect = bfd_make_section (abfd, try_again);
|
||||
}
|
||||
|
||||
/* Fix the name, if it is a sprintf'd name. */
|
||||
if (sect->name == try_again) {
|
||||
newname = (char *) bfd_zalloc(abfd, strlen (sect->name));
|
||||
if (newname == NULL)
|
||||
return 0;
|
||||
strcpy (newname, sect->name);
|
||||
sect->name = newname;
|
||||
}
|
||||
|
||||
/* Now set the section's attributes. */
|
||||
bfd_set_section_flags (abfd, sect, flags);
|
||||
sect->_raw_size = ((ext->e_size[0] << 8) /* Assumed big-endian */
|
||||
| ext->e_size[1] << 8)
|
||||
| ext->e_size[2];
|
||||
sect->_cooked_size = sect->_raw_size;
|
||||
sect->vma = bfd_h_get_32 (abfd, ext->e_virtbase);
|
||||
sect->filepos = bfd_h_get_32 (abfd, ext->e_filebase);
|
||||
/* FIXME XXX alignment? */
|
||||
|
||||
/* Set relocation information for first section of each type. */
|
||||
if (trynum == 0) switch (ext->e_type[0]) {
|
||||
case N_TEXT:
|
||||
sect->rel_filepos = N_TRELOFF (*execp);
|
||||
sect->reloc_count = execp->a_trsize;
|
||||
break;
|
||||
|
||||
case N_DATA:
|
||||
sect->rel_filepos = N_DRELOFF (*execp);
|
||||
sect->reloc_count = execp->a_drsize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
no_more_sections:
|
||||
|
||||
adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external);
|
||||
adata(abfd).symbol_entry_size = sizeof (struct external_nlist);
|
||||
adata(abfd).page_size = 1; /* Not applicable. */
|
||||
adata(abfd).segment_size = 1; /* Not applicable. */
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
struct bout_data_struct {
|
||||
struct aoutdata a;
|
||||
struct internal_exec e;
|
||||
};
|
||||
|
||||
static boolean
|
||||
aout_adobe_mkobject (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct bout_data_struct *rawptr;
|
||||
|
||||
rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
|
||||
if (rawptr == NULL)
|
||||
return false;
|
||||
|
||||
abfd->tdata.bout_data = rawptr;
|
||||
exec_hdr (abfd) = &rawptr->e;
|
||||
|
||||
adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external);
|
||||
adata(abfd).symbol_entry_size = sizeof (struct external_nlist);
|
||||
adata(abfd).page_size = 1; /* Not applicable. */
|
||||
adata(abfd).segment_size = 1; /* Not applicable. */
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static boolean
|
||||
aout_adobe_write_object_contents (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct external_exec swapped_hdr;
|
||||
static struct external_segdesc sentinel[1]; /* Initialized to zero */
|
||||
asection *sect;
|
||||
|
||||
exec_hdr (abfd)->a_info = ZMAGIC;
|
||||
|
||||
/* Calculate text size as total of text sections, etc. */
|
||||
|
||||
exec_hdr (abfd)->a_text = 0;
|
||||
exec_hdr (abfd)->a_data = 0;
|
||||
exec_hdr (abfd)->a_bss = 0;
|
||||
exec_hdr (abfd)->a_trsize = 0;
|
||||
exec_hdr (abfd)->a_drsize = 0;
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_CODE) {
|
||||
exec_hdr (abfd)->a_text += sect->_raw_size;
|
||||
exec_hdr (abfd)->a_trsize += sect->reloc_count *
|
||||
sizeof (struct reloc_std_external);
|
||||
} else if (sect->flags & SEC_DATA) {
|
||||
exec_hdr (abfd)->a_data += sect->_raw_size;
|
||||
exec_hdr (abfd)->a_drsize += sect->reloc_count *
|
||||
sizeof (struct reloc_std_external);
|
||||
} else if (sect->flags & SEC_ALLOC && !(sect->flags & SEC_LOAD)) {
|
||||
exec_hdr (abfd)->a_bss += sect->_raw_size;
|
||||
}
|
||||
}
|
||||
|
||||
exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd)
|
||||
* sizeof (struct external_nlist);
|
||||
exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
|
||||
|
||||
aout_adobe_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
|
||||
|| (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
|
||||
!= EXEC_BYTES_SIZE))
|
||||
return false;
|
||||
|
||||
/* Now write out the section information. Text first, data next, rest
|
||||
afterward. */
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_CODE) {
|
||||
aout_adobe_write_section (abfd, sect);
|
||||
}
|
||||
}
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_DATA) {
|
||||
aout_adobe_write_section (abfd, sect);
|
||||
}
|
||||
}
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (!(sect->flags & (SEC_CODE|SEC_DATA))) {
|
||||
aout_adobe_write_section (abfd, sect);
|
||||
}
|
||||
}
|
||||
|
||||
/* Write final `sentinel` section header (with type of 0). */
|
||||
if (bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd)
|
||||
!= sizeof (*sentinel))
|
||||
return false;
|
||||
|
||||
/* Now write out reloc info, followed by syms and strings */
|
||||
if (bfd_get_symcount (abfd) != 0)
|
||||
{
|
||||
if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return false;
|
||||
|
||||
if (! aout_32_write_syms (abfd))
|
||||
return false;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*exec_hdr(abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return false;
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_CODE) {
|
||||
if (!aout_32_squirt_out_relocs (abfd, sect))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*exec_hdr(abfd))), SEEK_SET)
|
||||
!= 0)
|
||||
return false;
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_DATA) {
|
||||
if (!aout_32_squirt_out_relocs (abfd, sect))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
aout_adobe_write_section (abfd, sect)
|
||||
bfd *abfd;
|
||||
sec_ptr sect;
|
||||
{
|
||||
/* FIXME XXX */
|
||||
}
|
||||
|
||||
static boolean
|
||||
aout_adobe_set_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
PTR location;
|
||||
file_ptr offset;
|
||||
bfd_size_type count;
|
||||
{
|
||||
file_ptr section_start;
|
||||
sec_ptr sect;
|
||||
|
||||
if (abfd->output_has_begun == false) { /* set by bfd.c handler */
|
||||
|
||||
/* Assign file offsets to sections. Text sections are first, and
|
||||
are contiguous. Then data sections. Everything else at the end. */
|
||||
|
||||
section_start = N_TXTOFF (ignore<-->me);
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_CODE) {
|
||||
sect->filepos = section_start;
|
||||
/* FIXME: Round to alignment */
|
||||
section_start += sect->_raw_size;
|
||||
}
|
||||
}
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_DATA) {
|
||||
sect->filepos = section_start;
|
||||
/* FIXME: Round to alignment */
|
||||
section_start += sect->_raw_size;
|
||||
}
|
||||
}
|
||||
|
||||
for (sect = abfd->sections; sect; sect = sect->next) {
|
||||
if (sect->flags & SEC_HAS_CONTENTS &&
|
||||
!(sect->flags & (SEC_CODE|SEC_DATA))) {
|
||||
sect->filepos = section_start;
|
||||
/* FIXME: Round to alignment */
|
||||
section_start += sect->_raw_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* regardless, once we know what we're doing, we might as well get going */
|
||||
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
|
||||
return false;
|
||||
|
||||
if (count != 0) {
|
||||
return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean
|
||||
aout_adobe_set_arch_mach (abfd, arch, machine)
|
||||
bfd *abfd;
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
{
|
||||
if (! bfd_default_set_arch_mach (abfd, arch, machine))
|
||||
return false;
|
||||
|
||||
if (arch == bfd_arch_unknown
|
||||
|| arch == bfd_arch_m68k)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
aout_adobe_sizeof_headers (ignore_abfd, ignore)
|
||||
bfd *ignore_abfd;
|
||||
boolean ignore;
|
||||
{
|
||||
return sizeof(struct internal_exec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Build the transfer vector for Adobe A.Out files. */
|
||||
|
||||
#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
|
||||
|
||||
#define aout_32_bfd_make_debug_symbol \
|
||||
((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
|
||||
|
||||
#define aout_32_bfd_reloc_type_lookup \
|
||||
((reloc_howto_type *(*) \
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
|
||||
|
||||
#define aout_32_set_arch_mach aout_adobe_set_arch_mach
|
||||
#define aout_32_set_section_contents aout_adobe_set_section_contents
|
||||
|
||||
#define aout_32_sizeof_headers aout_adobe_sizeof_headers
|
||||
#define aout_32_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
#define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
|
||||
#define aout_32_bfd_relax_section bfd_generic_relax_section
|
||||
#define aout_32_bfd_link_hash_table_create \
|
||||
_bfd_generic_link_hash_table_create
|
||||
#define aout_32_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define aout_32_bfd_final_link _bfd_generic_final_link
|
||||
#define aout_32_bfd_link_split_section _bfd_generic_link_split_section
|
||||
|
||||
const bfd_target a_out_adobe_vec =
|
||||
{
|
||||
"a.out.adobe", /* name */
|
||||
bfd_target_aout_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is unknown (big assumed) */
|
||||
BFD_ENDIAN_BIG, /* hdr byte order is big */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT ),
|
||||
/* section flags */
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_DATA | SEC_RELOC),
|
||||
'_', /* symbol leading char */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
{_bfd_dummy_target, aout_adobe_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, aout_adobe_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, aout_adobe_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (aout_32),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
|
||||
BFD_JUMP_TABLE_SYMBOLS (aout_32),
|
||||
BFD_JUMP_TABLE_RELOCS (aout_32),
|
||||
BFD_JUMP_TABLE_WRITE (aout_32),
|
||||
BFD_JUMP_TABLE_LINK (aout_32),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0
|
||||
};
|
||||
@@ -0,0 +1,548 @@
|
||||
/* BFD back-end for raw ARM a.out binaries.
|
||||
Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#define N_TXTADDR(x) \
|
||||
((N_MAGIC(x) == NMAGIC) ? 0x8000 : \
|
||||
(N_MAGIC(x) != ZMAGIC) ? 0 : \
|
||||
(N_SHARED_LIB(x)) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) : \
|
||||
TEXT_START_ADDR)
|
||||
|
||||
#define TEXT_START_ADDR 0x8000
|
||||
#define TARGET_PAGE_SIZE 0x8000
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#define DEFAULT_ARCH bfd_arch_arm
|
||||
|
||||
#define MY(OP) CAT(aoutarm_,OP)
|
||||
#define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \
|
||||
(((x).a_info & ~006000) != OMAGIC) && \
|
||||
((x).a_info != NMAGIC))
|
||||
#define N_MAGIC(x) ((x).a_info & ~07200)
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "assert.h"
|
||||
|
||||
#define MYARM(OP) CAT(aoutarm_,OP)
|
||||
reloc_howto_type *MYARM(bfd_reloc_type_lookup)
|
||||
PARAMS((bfd *, bfd_reloc_code_real_type));
|
||||
static boolean MYARM(write_object_contents) PARAMS((bfd *));
|
||||
|
||||
/* Avoid multiple defininitions from aoutx if supporting standarad a.out
|
||||
as well as our own. */
|
||||
#define NAME(x,y) CAT3(aoutarm,_32_,y)
|
||||
|
||||
#define MY_bfd_reloc_type_lookup aoutarm_bfd_reloc_type_lookup
|
||||
|
||||
#include "libaout.h"
|
||||
#include "aout/aout64.h"
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY(fix_pcrel_26_done) PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY(fix_pcrel_26) PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
static void MY(swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
|
||||
arelent *, asymbol **,
|
||||
bfd_size_type));
|
||||
void MY(swap_std_reloc_out) PARAMS ((bfd *, arelent *,
|
||||
struct reloc_std_external *));
|
||||
|
||||
reloc_howto_type MY(howto_table)[] =
|
||||
{
|
||||
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask
|
||||
pcdone */
|
||||
HOWTO (0, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true,
|
||||
0x000000ff, 0x000000ff, false),
|
||||
HOWTO (1, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true,
|
||||
0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (2, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true,
|
||||
0xffffffff, 0xffffffff, false),
|
||||
HOWTO (3, 2, 2, 26, true, 0, complain_overflow_signed, MY(fix_pcrel_26),
|
||||
"ARM26", true, 0x00ffffff, 0x00ffffff, true),
|
||||
HOWTO (4, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true,
|
||||
0x000000ff, 0x000000ff, true),
|
||||
HOWTO (5, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true,
|
||||
0x0000ffff, 0x0000ffff, true),
|
||||
HOWTO (6, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true,
|
||||
0xffffffff, 0xffffffff, true),
|
||||
HOWTO (7, 2, 2, 26, false, 0, complain_overflow_signed,
|
||||
MY(fix_pcrel_26_done), "ARM26D", true, 0x0, 0x0,
|
||||
false),
|
||||
{-1},
|
||||
HOWTO (9, 0, -1, 16, false, 0, complain_overflow_bitfield, 0, "NEG16", true,
|
||||
0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (10, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "NEG32", true,
|
||||
0xffffffff, 0xffffffff, false)
|
||||
};
|
||||
|
||||
#define RELOC_ARM_BITS_NEG_BIG ((unsigned int) 0x08)
|
||||
#define RELOC_ARM_BITS_NEG_LITTLE ((unsigned int) 0x10)
|
||||
|
||||
reloc_howto_type *
|
||||
MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *rel;
|
||||
int *r_index;
|
||||
int *r_extern;
|
||||
int *r_pcrel;
|
||||
{
|
||||
unsigned int r_length;
|
||||
unsigned int r_pcrel_done;
|
||||
unsigned int r_neg;
|
||||
int index;
|
||||
|
||||
*r_pcrel = 0;
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
*r_index = ((rel->r_index[0] << 16)
|
||||
| (rel->r_index[1] << 8)
|
||||
| rel->r_index[2]);
|
||||
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
|
||||
r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
|
||||
r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_BIG));
|
||||
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
|
||||
>> RELOC_STD_BITS_LENGTH_SH_BIG);
|
||||
}
|
||||
else
|
||||
{
|
||||
*r_index = ((rel->r_index[2] << 16)
|
||||
| (rel->r_index[1] << 8)
|
||||
| rel->r_index[0]);
|
||||
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
|
||||
r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
|
||||
r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_LITTLE));
|
||||
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
|
||||
>> RELOC_STD_BITS_LENGTH_SH_LITTLE);
|
||||
}
|
||||
index = r_length + 4 * r_pcrel_done + 8 * r_neg;
|
||||
if (index == 3)
|
||||
*r_pcrel = 1;
|
||||
|
||||
return MY(howto_table) + index;
|
||||
}
|
||||
|
||||
#define MY_reloc_howto(BFD, REL, IN, EX, PC) \
|
||||
MY(reloc_howto) (BFD, REL, &IN, &EX, &PC)
|
||||
|
||||
void
|
||||
MY(put_reloc)(abfd, r_extern, r_index, value, howto, reloc)
|
||||
bfd *abfd;
|
||||
int r_extern;
|
||||
int r_index;
|
||||
long value;
|
||||
reloc_howto_type *howto;
|
||||
struct reloc_std_external *reloc;
|
||||
{
|
||||
unsigned int r_length;
|
||||
int r_pcrel;
|
||||
int r_neg;
|
||||
|
||||
PUT_WORD (abfd, value, reloc->r_address);
|
||||
r_length = howto->size ; /* Size as a power of two */
|
||||
|
||||
/* Special case for branch relocations. */
|
||||
if (howto->type == 3 || howto->type == 7)
|
||||
r_length = 3;
|
||||
|
||||
r_pcrel = howto->type & 4; /* PC Relative done? */
|
||||
r_neg = howto->type & 8; /* Negative relocation */
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
reloc->r_index[0] = r_index >> 16;
|
||||
reloc->r_index[1] = r_index >> 8;
|
||||
reloc->r_index[2] = r_index;
|
||||
reloc->r_type[0] =
|
||||
((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_BIG : 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
|
||||
}
|
||||
else
|
||||
{
|
||||
reloc->r_index[2] = r_index >> 16;
|
||||
reloc->r_index[1] = r_index >> 8;
|
||||
reloc->r_index[0] = r_index;
|
||||
reloc->r_type[0] =
|
||||
((r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_LITTLE : 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
|
||||
}
|
||||
}
|
||||
|
||||
#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
|
||||
MY(put_reloc)(BFD, EXT, IDX, VAL, HOWTO, RELOC)
|
||||
|
||||
void
|
||||
MY(relocatable_reloc)(howto, abfd, reloc, amount, r_addr)
|
||||
reloc_howto_type *howto;
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *reloc;
|
||||
bfd_vma *amount;
|
||||
bfd_vma r_addr;
|
||||
{
|
||||
if (howto->type == 3)
|
||||
{
|
||||
if (reloc->r_type[0]
|
||||
& (bfd_header_big_endian (abfd)
|
||||
? RELOC_STD_BITS_EXTERN_BIG : RELOC_STD_BITS_EXTERN_LITTLE))
|
||||
{
|
||||
/* The reloc is still external, so don't modify anything. */
|
||||
*amount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*amount -= r_addr;
|
||||
/* Change the r_pcrel value -- on the ARM, this bit is set once the
|
||||
relocation is done. */
|
||||
if (bfd_header_big_endian (abfd))
|
||||
reloc->r_type[0] |= RELOC_STD_BITS_PCREL_BIG;
|
||||
else
|
||||
reloc->r_type[0] |= RELOC_STD_BITS_PCREL_LITTLE;
|
||||
}
|
||||
}
|
||||
else if (howto->type == 7)
|
||||
*amount = 0;
|
||||
}
|
||||
|
||||
#define MY_relocatable_reloc(HOW, BFD, REL, AMOUNT, ADDR) \
|
||||
MY(relocatable_reloc)(HOW, BFD, REL, &(AMOUNT), ADDR)
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY(fix_pcrel_26_done) (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
/* This is dead simple at present. */
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static bfd_reloc_status_type
|
||||
MY(fix_pcrel_26) (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
bfd_vma relocation;
|
||||
bfd_size_type addr = reloc_entry->address;
|
||||
long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
|
||||
bfd_reloc_status_type flag = bfd_reloc_ok;
|
||||
|
||||
/* If this is an undefined symbol, return error */
|
||||
if (symbol->section == &bfd_und_section
|
||||
&& (symbol->flags & BSF_WEAK) == 0)
|
||||
return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
|
||||
|
||||
/* If the sections are different, and we are doing a partial relocation,
|
||||
just ignore it for now. */
|
||||
if (symbol->section->name != input_section->name
|
||||
&& output_bfd != (bfd *)NULL)
|
||||
return bfd_reloc_ok;
|
||||
|
||||
relocation = (target & 0x00ffffff) << 2;
|
||||
relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
|
||||
relocation += symbol->value;
|
||||
relocation += symbol->section->output_section->vma;
|
||||
relocation += symbol->section->output_offset;
|
||||
relocation += reloc_entry->addend;
|
||||
relocation -= input_section->output_section->vma;
|
||||
relocation -= input_section->output_offset;
|
||||
relocation -= addr;
|
||||
if (relocation & 3)
|
||||
return bfd_reloc_overflow;
|
||||
|
||||
/* Check for overflow */
|
||||
if (relocation & 0x02000000)
|
||||
{
|
||||
if ((relocation & ~0x03ffffff) != ~0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
}
|
||||
else if (relocation & ~0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
|
||||
target &= ~0x00ffffff;
|
||||
target |= (relocation >> 2) & 0x00ffffff;
|
||||
bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
|
||||
|
||||
/* Now the ARM magic... Change the reloc type so that it is marked as done.
|
||||
Strictly this is only necessary if we are doing a partial relocation. */
|
||||
reloc_entry->howto = &MY(howto_table)[7];
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
reloc_howto_type *
|
||||
MY(bfd_reloc_type_lookup)(abfd,code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
#define ASTD(i,j) case i: return &MY(howto_table)[j]
|
||||
if (code == BFD_RELOC_CTOR)
|
||||
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||
{
|
||||
case 32:
|
||||
code = BFD_RELOC_32;
|
||||
break;
|
||||
default: return (CONST struct reloc_howto_struct *) 0;
|
||||
}
|
||||
|
||||
switch (code)
|
||||
{
|
||||
ASTD (BFD_RELOC_16, 1);
|
||||
ASTD (BFD_RELOC_32, 2);
|
||||
ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
|
||||
ASTD (BFD_RELOC_8_PCREL, 4);
|
||||
ASTD (BFD_RELOC_16_PCREL, 5);
|
||||
ASTD (BFD_RELOC_32_PCREL, 6);
|
||||
default: return (CONST struct reloc_howto_struct *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
|
||||
#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
|
||||
#define MY_get_section_contents _bfd_generic_get_section_contents
|
||||
/* #define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create */
|
||||
/* #define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols */
|
||||
/* #define MY_bfd_final_link _bfd_generic_final_link */
|
||||
|
||||
#include "aoutx.h"
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *bytes;
|
||||
arelent *cache_ptr;
|
||||
asymbol **symbols;
|
||||
bfd_size_type symcount;
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
unsigned int r_length;
|
||||
int r_pcrel;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
|
||||
|
||||
cache_ptr->howto = MY_reloc_howto (abfd, bytes, r_index, r_extern, r_pcrel);
|
||||
|
||||
MOVE_ADDRESS (0);
|
||||
}
|
||||
|
||||
void
|
||||
MY_swap_std_reloc_out (abfd, g, natptr)
|
||||
bfd *abfd;
|
||||
arelent *g;
|
||||
struct reloc_std_external *natptr;
|
||||
{
|
||||
int r_index;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
int r_extern;
|
||||
int r_length;
|
||||
int r_pcrel;
|
||||
int r_neg = 0; /* Negative relocs use the BASEREL bit. */
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
PUT_WORD(abfd, g->address, natptr->r_address);
|
||||
|
||||
r_length = g->howto->size ; /* Size as a power of two */
|
||||
if (r_length < 0)
|
||||
{
|
||||
r_length = -r_length;
|
||||
r_neg = 1;
|
||||
}
|
||||
|
||||
r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
|
||||
|
||||
/* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
|
||||
relocation has been done already (Only for the 26-bit one I think)???!!!
|
||||
*/
|
||||
|
||||
if (g->howto->type == 3)
|
||||
{
|
||||
r_length = 3;
|
||||
r_pcrel = 0;
|
||||
}
|
||||
else if (g->howto->type == 7)
|
||||
{
|
||||
r_length = 3;
|
||||
r_pcrel = 1;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/* For a standard reloc, the addend is in the object file. */
|
||||
r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||
#endif
|
||||
|
||||
/* name was clobbered by aout_write_syms to be symbol index */
|
||||
|
||||
/* If this relocation is relative to a symbol then set the
|
||||
r_index to the symbols index, and the r_extern bit.
|
||||
|
||||
Absolute symbols can come in in two ways, either as an offset
|
||||
from the abs section, or as a symbol which has an abs value.
|
||||
check for that here
|
||||
*/
|
||||
|
||||
if (bfd_is_com_section (output_section)
|
||||
|| output_section == &bfd_abs_section
|
||||
|| output_section == &bfd_und_section)
|
||||
{
|
||||
if (bfd_abs_section.symbol == sym)
|
||||
{
|
||||
/* Whoops, looked like an abs symbol, but is really an offset
|
||||
from the abs section */
|
||||
r_index = 0;
|
||||
r_extern = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fill in symbol */
|
||||
r_extern = 1;
|
||||
r_index = (*(g->sym_ptr_ptr))->KEEPIT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just an ordinary section */
|
||||
r_extern = 0;
|
||||
r_index = output_section->target_index;
|
||||
}
|
||||
|
||||
/* now the fun stuff */
|
||||
if (bfd_header_big_endian (abfd))
|
||||
{
|
||||
natptr->r_index[0] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[2] = r_index;
|
||||
natptr->r_type[0] =
|
||||
( (r_extern ? RELOC_STD_BITS_EXTERN_BIG: 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_BIG: 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_BIG: 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
|
||||
}
|
||||
else
|
||||
{
|
||||
natptr->r_index[2] = r_index >> 16;
|
||||
natptr->r_index[1] = r_index >> 8;
|
||||
natptr->r_index[0] = r_index;
|
||||
natptr->r_type[0] =
|
||||
( (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE: 0)
|
||||
| (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE: 0)
|
||||
| (r_neg ? RELOC_ARM_BITS_NEG_LITTLE: 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
|
||||
}
|
||||
}
|
||||
|
||||
#define MY_BFD_TARGET
|
||||
|
||||
#include "aout-target.h"
|
||||
|
||||
const bfd_target aout_arm_little_vec =
|
||||
{
|
||||
"a.out-arm-little", /* name */
|
||||
bfd_target_aout_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* target byte order (little) */
|
||||
BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
MY_symbol_leading_char,
|
||||
AR_PAD_CHAR, /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
{_bfd_dummy_target, MY_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, MY_core_file_p},
|
||||
{bfd_false, MY_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, MY_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (MY),
|
||||
BFD_JUMP_TABLE_COPY (MY),
|
||||
BFD_JUMP_TABLE_CORE (MY),
|
||||
BFD_JUMP_TABLE_ARCHIVE (MY),
|
||||
BFD_JUMP_TABLE_SYMBOLS (MY),
|
||||
BFD_JUMP_TABLE_RELOCS (MY),
|
||||
BFD_JUMP_TABLE_WRITE (MY),
|
||||
BFD_JUMP_TABLE_LINK (MY),
|
||||
BFD_JUMP_TABLE_DYNAMIC (MY),
|
||||
|
||||
(PTR) MY_backend_data,
|
||||
};
|
||||
|
||||
const bfd_target aout_arm_big_vec =
|
||||
{
|
||||
"a.out-arm-big", /* name */
|
||||
bfd_target_aout_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order (big) */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order (big) */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
MY_symbol_leading_char,
|
||||
AR_PAD_CHAR, /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
{_bfd_dummy_target, MY_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, MY_core_file_p},
|
||||
{bfd_false, MY_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, MY_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (MY),
|
||||
BFD_JUMP_TABLE_COPY (MY),
|
||||
BFD_JUMP_TABLE_CORE (MY),
|
||||
BFD_JUMP_TABLE_ARCHIVE (MY),
|
||||
BFD_JUMP_TABLE_SYMBOLS (MY),
|
||||
BFD_JUMP_TABLE_RELOCS (MY),
|
||||
BFD_JUMP_TABLE_WRITE (MY),
|
||||
BFD_JUMP_TABLE_LINK (MY),
|
||||
BFD_JUMP_TABLE_DYNAMIC (MY),
|
||||
|
||||
(PTR) MY_backend_data,
|
||||
};
|
||||
@@ -0,0 +1,236 @@
|
||||
/* BFD back-end for a.out files encapsulated with COFF headers.
|
||||
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* THIS MODULE IS NOT FINISHED. IT PROBABLY DOESN'T EVEN COMPILE. */
|
||||
|
||||
#if 0
|
||||
#define TARGET_PAGE_SIZE 4096
|
||||
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
||||
#define TEXT_START_ADDR 0
|
||||
#define BYTES_IN_WORD 4
|
||||
#endif
|
||||
|
||||
#include "bfd.h"
|
||||
#include <sysdep.h>
|
||||
#include "libbfd.h"
|
||||
#include <aout/aout64.h>
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
|
||||
const bfd_target *encap_real_callback ();
|
||||
|
||||
const bfd_target *
|
||||
encap_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
unsigned char magicbuf[4]; /* Raw bytes of magic number from file */
|
||||
unsigned long magic; /* Swapped magic number */
|
||||
short coff_magic;
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec exec;
|
||||
|
||||
if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
|
||||
sizeof (magicbuf))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
coff_magic = bfd_h_get_16 (abfd, magicbuf);
|
||||
if (coff_magic != COFF_MAGIC)
|
||||
return 0; /* Not an encap coff file */
|
||||
|
||||
__header_offset_temp==COFF_MAGIC ? sizeof(struct coffheader) : 0)
|
||||
(fseek ((f), HEADER_OFFSET((f)), 1))
|
||||
|
||||
magic = bfd_h_get_32 (abfd, magicbuf);
|
||||
|
||||
if (N_BADMAG (*((struct internal_exec *) &magic))) return 0;
|
||||
|
||||
struct external_exec exec_bytes;
|
||||
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
|
||||
!= EXEC_BYTES_SIZE) {
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return 0;
|
||||
}
|
||||
NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
|
||||
|
||||
return aout_32_some_aout_object_p (abfd, &exec, encap_realcallback);
|
||||
}
|
||||
|
||||
/* Finish up the reading of a encapsulated-coff a.out file header */
|
||||
const bfd_target *
|
||||
encap_real_callback (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
MY(callback)(abfd, execp);
|
||||
|
||||
/* If we have a coff header, it can give us better values for
|
||||
text_start and exec_data_start. This is particularly useful
|
||||
for remote debugging of embedded systems. */
|
||||
if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE)
|
||||
{
|
||||
struct coffheader ch;
|
||||
int val;
|
||||
val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1);
|
||||
if (val == -1)
|
||||
perror_with_name (filename);
|
||||
val = myread (execchan, &ch, sizeof (ch));
|
||||
if (val < 0)
|
||||
perror_with_name (filename);
|
||||
text_start = ch.text_start;
|
||||
exec_data_start = ch.data_start;
|
||||
} else
|
||||
{
|
||||
text_start =
|
||||
IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr);
|
||||
exec_data_start = IS_OBJECT_FILE (exec_aouthdr)
|
||||
? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr);
|
||||
}
|
||||
|
||||
/* Determine the architecture and machine type of the object file. */
|
||||
bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0); /* FIXME */
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
/* Write an object file in Encapsulated COFF format.
|
||||
Section contents have already been written. We write the
|
||||
file header, symbols, and relocation. */
|
||||
|
||||
boolean
|
||||
encap_write_object_contents (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
bfd_size_type data_pad = 0;
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
/****** FIXME: Fragments from the old GNU LD program for dealing with
|
||||
encap coff. */
|
||||
struct coffheader coffheader;
|
||||
int need_coff_header;
|
||||
|
||||
/* Determine whether to count the header as part of
|
||||
the text size, and initialize the text size accordingly.
|
||||
This depends on the kind of system and on the output format selected. */
|
||||
|
||||
N_SET_MAGIC (outheader, magic);
|
||||
#ifdef INITIALIZE_HEADER
|
||||
INITIALIZE_HEADER;
|
||||
#endif
|
||||
|
||||
text_size = sizeof (struct exec);
|
||||
#ifdef COFF_ENCAPSULATE
|
||||
if (relocatable_output == 0 && file_table[0].just_syms_flag == 0)
|
||||
{
|
||||
need_coff_header = 1;
|
||||
/* set this flag now, since it will change the values of N_TXTOFF, etc */
|
||||
N_SET_FLAGS (outheader, aout_backend_info (abfd)->exec_hdr_flags);
|
||||
text_size += sizeof (struct coffheader);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COFF_ENCAPSULATE
|
||||
if (need_coff_header)
|
||||
{
|
||||
/* We are encapsulating BSD format within COFF format. */
|
||||
struct coffscn *tp, *dp, *bp;
|
||||
|
||||
tp = &coffheader.scns[0];
|
||||
dp = &coffheader.scns[1];
|
||||
bp = &coffheader.scns[2];
|
||||
|
||||
strcpy (tp->s_name, ".text");
|
||||
tp->s_paddr = text_start;
|
||||
tp->s_vaddr = text_start;
|
||||
tp->s_size = text_size;
|
||||
tp->s_scnptr = sizeof (struct coffheader) + sizeof (struct exec);
|
||||
tp->s_relptr = 0;
|
||||
tp->s_lnnoptr = 0;
|
||||
tp->s_nreloc = 0;
|
||||
tp->s_nlnno = 0;
|
||||
tp->s_flags = 0x20;
|
||||
strcpy (dp->s_name, ".data");
|
||||
dp->s_paddr = data_start;
|
||||
dp->s_vaddr = data_start;
|
||||
dp->s_size = data_size;
|
||||
dp->s_scnptr = tp->s_scnptr + tp->s_size;
|
||||
dp->s_relptr = 0;
|
||||
dp->s_lnnoptr = 0;
|
||||
dp->s_nreloc = 0;
|
||||
dp->s_nlnno = 0;
|
||||
dp->s_flags = 0x40;
|
||||
strcpy (bp->s_name, ".bss");
|
||||
bp->s_paddr = dp->s_vaddr + dp->s_size;
|
||||
bp->s_vaddr = bp->s_paddr;
|
||||
bp->s_size = bss_size;
|
||||
bp->s_scnptr = 0;
|
||||
bp->s_relptr = 0;
|
||||
bp->s_lnnoptr = 0;
|
||||
bp->s_nreloc = 0;
|
||||
bp->s_nlnno = 0;
|
||||
bp->s_flags = 0x80;
|
||||
|
||||
coffheader.f_magic = COFF_MAGIC;
|
||||
coffheader.f_nscns = 3;
|
||||
/* store an unlikely time so programs can
|
||||
* tell that there is a bsd header
|
||||
*/
|
||||
coffheader.f_timdat = 1;
|
||||
coffheader.f_symptr = 0;
|
||||
coffheader.f_nsyms = 0;
|
||||
coffheader.f_opthdr = 28;
|
||||
coffheader.f_flags = 0x103;
|
||||
/* aouthdr */
|
||||
coffheader.magic = ZMAGIC;
|
||||
coffheader.vstamp = 0;
|
||||
coffheader.tsize = tp->s_size;
|
||||
coffheader.dsize = dp->s_size;
|
||||
coffheader.bsize = bp->s_size;
|
||||
coffheader.entry = outheader.a_entry;
|
||||
coffheader.text_start = tp->s_vaddr;
|
||||
coffheader.data_start = dp->s_vaddr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COFF_ENCAPSULATE
|
||||
if (need_coff_header)
|
||||
mywrite (&coffheader, sizeof coffheader, 1, outdesc);
|
||||
#endif
|
||||
|
||||
#ifndef COFF_ENCAPSULATE
|
||||
padfile (N_TXTOFF (outheader) - sizeof outheader, outdesc);
|
||||
#endif
|
||||
|
||||
text_size -= N_TXTOFF (outheader);
|
||||
WRITE_HEADERS(abfd, execp);
|
||||
return true;
|
||||
}
|
||||
|
||||
#define MY_write_object_content encap_write_object_contents
|
||||
#define MY_object_p encap_object_p
|
||||
#define MY_exec_hdr_flags N_FLAGS_COFF_ENCAPSULATE
|
||||
|
||||
#include "aout-target.h"
|
||||
@@ -0,0 +1,399 @@
|
||||
/* BFD back-end for ns32k a.out-ish binaries.
|
||||
Copyright (C) 1990, 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
|
||||
Contributed by Ian Dall (idall@eleceng.adelaide.edu.au).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define BYTES_IN_WORD 4
|
||||
|
||||
#include "bfd.h"
|
||||
#include "aout/aout64.h"
|
||||
|
||||
#define MYNS(OP) CAT(ns32kaout_,OP)
|
||||
reloc_howto_type *
|
||||
MYNS(bfd_reloc_type_lookup)
|
||||
PARAMS((bfd *abfd AND
|
||||
bfd_reloc_code_real_type code));
|
||||
|
||||
boolean
|
||||
MYNS(write_object_contents)
|
||||
PARAMS((bfd *abfd));
|
||||
|
||||
/* Avoid multiple definitions from aoutx if supporting standard a.out format(s)
|
||||
* as well as this one
|
||||
*/
|
||||
#define NAME(x,y) CAT3(ns32kaout,_32_,y)
|
||||
|
||||
void bfd_ns32k_arch PARAMS ((void));
|
||||
long ns32k_get_displacement PARAMS ((bfd_byte *buffer, long offset, long size));
|
||||
int ns32k_put_displacement PARAMS ((long value, bfd_byte *buffer, long offset, long size));
|
||||
long ns32k_get_immediate PARAMS ((bfd_byte *buffer, long offset, long size));
|
||||
int ns32k_put_immediate PARAMS ((long value, bfd_byte *buffer, long offset, long size));
|
||||
bfd_reloc_status_type
|
||||
ns32k_reloc_disp PARAMS ((bfd *abfd, arelent *reloc_entry,
|
||||
struct symbol_cache_entry *symbol,
|
||||
PTR data,
|
||||
asection *input_section,
|
||||
bfd *output_bfd,
|
||||
char **error_message));
|
||||
bfd_reloc_status_type
|
||||
ns32k_reloc_imm PARAMS ((bfd *abfd,
|
||||
arelent *reloc_entry,
|
||||
struct symbol_cache_entry *symbol,
|
||||
PTR data,
|
||||
asection *input_section,
|
||||
bfd *output_bfd,
|
||||
char **error_message));
|
||||
bfd_reloc_status_type
|
||||
ns32k_final_link_relocate PARAMS ((reloc_howto_type *howto,
|
||||
bfd *input_bfd,
|
||||
asection *input_section,
|
||||
bfd_byte *contents,
|
||||
bfd_vma address,
|
||||
bfd_vma value,
|
||||
bfd_vma addend ));
|
||||
bfd_reloc_status_type
|
||||
ns32k_relocate_contents PARAMS ((reloc_howto_type *howto,
|
||||
bfd *input_bfd,
|
||||
bfd_vma relocation,
|
||||
bfd_byte *location));
|
||||
|
||||
#include "libaout.h"
|
||||
|
||||
#define MY(OP) MYNS(OP)
|
||||
|
||||
#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
|
||||
#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_in PARAMS ((bfd *abfd, struct reloc_std_external *bytes,
|
||||
arelent *cache_ptr, asymbol **symbols,
|
||||
bfd_size_type symcount));
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_out PARAMS ((bfd *abfd, arelent *g,
|
||||
struct reloc_std_external *natptr));
|
||||
|
||||
/* The ns32k series is ah, unusual, when it comes to relocation.
|
||||
* There are three storage methods for relocateable objects. There
|
||||
* are displacements, immediate operands and ordinary twos complement
|
||||
* data. Of these, only the last fits into the standard relocation
|
||||
* scheme. Immediate operands are stored huffman encoded and
|
||||
* immediate operands are stored big endian (where as the natural byte
|
||||
* order is little endian for this achitecture).
|
||||
|
||||
* Note that the ns32k displacement storage method is orthogonal to
|
||||
* whether the relocation is pc relative or not. The "displacement"
|
||||
* storage scheme is used for essentially all address constants. The
|
||||
* displacement can be relative to zero (absolute displacement),
|
||||
* relative to the pc (pc relative), the stack pointer, the frame
|
||||
* pointer, the static base register and general purpose register etc.
|
||||
|
||||
* For example:
|
||||
*
|
||||
* sym1: .long . # pc relative 2's complement
|
||||
* sym1: .long foo # 2's complement not pc relative
|
||||
*
|
||||
* self: movd @self, r0 # pc relative displacement
|
||||
* movd foo, r0 # non pc relative displacement
|
||||
*
|
||||
* self: movd self, r0 # pc relative immediate
|
||||
* movd foo, r0 # non pc relative immediate
|
||||
*
|
||||
* In addition, for historical reasons the encoding of the relocation types
|
||||
* in the a.out format relocation entries is such that even the relocation
|
||||
* methods which are standard are not encoded the standard way.
|
||||
*
|
||||
*/
|
||||
|
||||
reloc_howto_type MY(howto_table)[] =
|
||||
{
|
||||
/* ns32k immediate operands */
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_8, 0, 0, 8, false, 0, true,
|
||||
ns32k_reloc_imm, "NS32K_IMM_8",
|
||||
true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_16, 0, 1, 16, false, 0, true,
|
||||
ns32k_reloc_imm, "NS32K_IMM_16",
|
||||
true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_32, 0, 2, 32, false, 0, true,
|
||||
ns32k_reloc_imm, "NS32K_IMM_32",
|
||||
true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_8_PCREL, 0, 0, 8, true, 0, false,
|
||||
ns32k_reloc_imm, "PCREL_NS32K_IMM_8",
|
||||
true, 0x000000ff, 0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_16_PCREL, 0, 1, 16, true, 0, false,
|
||||
ns32k_reloc_imm, "PCREL_NS32K_IMM_16",
|
||||
true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_IMM_32_PCREL, 0, 2, 32, true, 0, false,
|
||||
ns32k_reloc_imm, "PCREL_NS32K_IMM_32",
|
||||
true, 0xffffffff,0xffffffff, false),
|
||||
|
||||
/* ns32k displacements */
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_8, 0, 0, 8, false, 0, true,
|
||||
ns32k_reloc_disp, "NS32K_DISP_8",
|
||||
true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_16, 0, 1, 16, false, 0, true,
|
||||
ns32k_reloc_disp, "NS32K_DISP_16",
|
||||
true, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_32, 0, 2, 32, false, 0, true,
|
||||
ns32k_reloc_disp, "NS32K_DISP_32",
|
||||
true, 0xffffffff, 0xffffffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_8_PCREL, 0, 0, 8, true, 0, false,
|
||||
ns32k_reloc_disp, "PCREL_NS32K_DISP_8",
|
||||
true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_16_PCREL, 0, 1, 16, true, 0, false,
|
||||
ns32k_reloc_disp, "PCREL_NS32K_DISP_16",
|
||||
true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_NS32K_DISP_32_PCREL, 0, 2, 32, true, 0, false,
|
||||
ns32k_reloc_disp, "PCREL_NS32K_DISP_32",
|
||||
true, 0xffffffff,0xffffffff, false),
|
||||
|
||||
/* Normal 2's complement */
|
||||
HOWTO(BFD_RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0,
|
||||
"8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0,
|
||||
"16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,
|
||||
"32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(BFD_RELOC_8_PCREL, 0, 0, 8, true, 0, complain_overflow_signed, 0,
|
||||
"PCREL_8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(BFD_RELOC_16_PCREL, 0, 1, 16, true, 0, complain_overflow_signed, 0,
|
||||
"PCREL_16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(BFD_RELOC_32_PCREL, 0, 2, 32, true, 0, complain_overflow_signed, 0,
|
||||
"PCREL_32", true, 0xffffffff,0xffffffff, false),
|
||||
};
|
||||
|
||||
|
||||
#define CTOR_TABLE_RELOC_HOWTO(BFD) (MY(howto_table) + 14)
|
||||
|
||||
#define RELOC_STD_BITS_NS32K_TYPE_BIG 0x06
|
||||
#define RELOC_STD_BITS_NS32K_TYPE_LITTLE 0x60
|
||||
#define RELOC_STD_BITS_NS32K_TYPE_SH_BIG 1
|
||||
#define RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE 5
|
||||
|
||||
reloc_howto_type *
|
||||
MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *rel;
|
||||
int *r_index;
|
||||
int *r_extern;
|
||||
int *r_pcrel;
|
||||
{
|
||||
unsigned int r_length;
|
||||
int r_ns32k_type;
|
||||
/* BFD_ASSERT(bfd_header_little_endian (abfd)); */
|
||||
*r_index = ((rel->r_index[2] << 16)
|
||||
| (rel->r_index[1] << 8)
|
||||
| rel->r_index[0] );
|
||||
*r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
|
||||
*r_pcrel = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
|
||||
r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
|
||||
>> RELOC_STD_BITS_LENGTH_SH_LITTLE);
|
||||
r_ns32k_type = ((rel->r_type[0] & RELOC_STD_BITS_NS32K_TYPE_LITTLE)
|
||||
>> RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
|
||||
return (MY(howto_table) + r_length + 3 * (*r_pcrel) + 6 * r_ns32k_type);
|
||||
}
|
||||
|
||||
#define MY_reloc_howto(BFD,REL,IN,EX,PC) MY(reloc_howto)(BFD, REL, &IN, &EX, &PC)
|
||||
|
||||
void
|
||||
MY(put_reloc)(abfd, r_extern, r_index, value, howto, reloc)
|
||||
bfd *abfd;
|
||||
int r_extern;
|
||||
int r_index;
|
||||
long value;
|
||||
reloc_howto_type *howto;
|
||||
struct reloc_std_external *reloc;
|
||||
{
|
||||
unsigned int r_length;
|
||||
int r_pcrel;
|
||||
int r_ns32k_type;
|
||||
PUT_WORD (abfd, value, reloc->r_address);
|
||||
r_length = howto->size ; /* Size as a power of two */
|
||||
r_pcrel = (int) howto->pc_relative; /* Relative to PC? */
|
||||
r_ns32k_type = (howto - MY(howto_table) )/6;
|
||||
/* BFD_ASSERT (bfd_header_little_endian (abfd)); */
|
||||
reloc->r_index[2] = r_index >> 16;
|
||||
reloc->r_index[1] = r_index >> 8;
|
||||
reloc->r_index[0] = r_index;
|
||||
reloc->r_type[0] =
|
||||
(r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0)
|
||||
| (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0)
|
||||
| (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE)
|
||||
| (r_ns32k_type << RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
|
||||
}
|
||||
|
||||
#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
|
||||
MY(put_reloc)(BFD, EXT, IDX, VAL, HOWTO, RELOC)
|
||||
|
||||
#define STAT_FOR_EXEC
|
||||
|
||||
#define MY_final_link_relocate ns32k_final_link_relocate
|
||||
#define MY_relocate_contents ns32k_relocate_contents
|
||||
|
||||
#include <aoutx.h>
|
||||
|
||||
reloc_howto_type *
|
||||
MY(bfd_reloc_type_lookup)(abfd,code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
|
||||
#define ENTRY(i,j) case i: return &MY(howto_table)[j]
|
||||
|
||||
int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
|
||||
|
||||
BFD_ASSERT(ext == 0);
|
||||
if (code == BFD_RELOC_CTOR)
|
||||
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||
{
|
||||
case 32:
|
||||
code = BFD_RELOC_32;
|
||||
break;
|
||||
}
|
||||
switch (code)
|
||||
{
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_8, 0);
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_16, 1);
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_32, 2);
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_8_PCREL, 3);
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_16_PCREL, 4);
|
||||
ENTRY(BFD_RELOC_NS32K_IMM_32_PCREL, 5);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_8, 6);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_16, 7);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_32, 8);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_8_PCREL, 9);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_16_PCREL, 10);
|
||||
ENTRY(BFD_RELOC_NS32K_DISP_32_PCREL, 11);
|
||||
ENTRY(BFD_RELOC_8, 12);
|
||||
ENTRY(BFD_RELOC_16, 13);
|
||||
ENTRY(BFD_RELOC_32, 14);
|
||||
ENTRY(BFD_RELOC_8_PCREL, 15);
|
||||
ENTRY(BFD_RELOC_16_PCREL, 16);
|
||||
ENTRY(BFD_RELOC_32_PCREL, 17);
|
||||
default: return (reloc_howto_type *) NULL;
|
||||
}
|
||||
#undef ENTRY
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
|
||||
bfd *abfd;
|
||||
struct reloc_std_external *bytes;
|
||||
arelent *cache_ptr;
|
||||
asymbol **symbols;
|
||||
bfd_size_type symcount;
|
||||
{
|
||||
int r_index;
|
||||
int r_extern;
|
||||
int r_pcrel;
|
||||
struct aoutdata *su = &(abfd->tdata.aout_data->a);
|
||||
|
||||
cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
|
||||
|
||||
/* now the fun stuff */
|
||||
|
||||
cache_ptr->howto = MY_reloc_howto(abfd, bytes, r_index, r_extern, r_pcrel);
|
||||
|
||||
MOVE_ADDRESS(0);
|
||||
}
|
||||
|
||||
static void
|
||||
MY_swap_std_reloc_out (abfd, g, natptr)
|
||||
bfd *abfd;
|
||||
arelent *g;
|
||||
struct reloc_std_external *natptr;
|
||||
{
|
||||
int r_index;
|
||||
asymbol *sym = *(g->sym_ptr_ptr);
|
||||
int r_extern;
|
||||
unsigned int r_addend;
|
||||
asection *output_section = sym->section->output_section;
|
||||
|
||||
r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
|
||||
|
||||
/* name was clobbered by aout_write_syms to be symbol index */
|
||||
|
||||
/* If this relocation is relative to a symbol then set the
|
||||
r_index to the symbols index, and the r_extern bit.
|
||||
|
||||
Absolute symbols can come in in two ways, either as an offset
|
||||
from the abs section, or as a symbol which has an abs value.
|
||||
Check for that here. */
|
||||
|
||||
if (bfd_is_com_section (output_section)
|
||||
|| output_section == &bfd_abs_section
|
||||
|| output_section == &bfd_und_section)
|
||||
{
|
||||
if (bfd_abs_section.symbol == sym)
|
||||
{
|
||||
/* Whoops, looked like an abs symbol, but is really an offset
|
||||
from the abs section */
|
||||
r_index = 0;
|
||||
r_extern = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fill in symbol */
|
||||
r_extern = 1;
|
||||
#undef KEEPIT
|
||||
#define KEEPIT udata.i
|
||||
r_index = (*(g->sym_ptr_ptr))->KEEPIT;
|
||||
#undef KEEPIT
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just an ordinary section */
|
||||
r_extern = 0;
|
||||
r_index = output_section->target_index;
|
||||
}
|
||||
|
||||
MY_put_reloc (abfd, r_extern, r_index, g->address, g->howto, natptr);
|
||||
}
|
||||
|
||||
bfd_reloc_status_type
|
||||
ns32k_relocate_contents (howto, input_bfd, relocation, location)
|
||||
reloc_howto_type *howto;
|
||||
bfd *input_bfd;
|
||||
bfd_vma relocation;
|
||||
bfd_byte *location;
|
||||
{
|
||||
int r_ns32k_type = (howto - MY(howto_table)) / 6;
|
||||
long (*get_data)();
|
||||
int (*put_data)();
|
||||
|
||||
switch (r_ns32k_type)
|
||||
{
|
||||
case 0:
|
||||
get_data = ns32k_get_immediate;
|
||||
put_data = ns32k_put_immediate;
|
||||
break;
|
||||
case 1:
|
||||
get_data = ns32k_get_displacement;
|
||||
put_data = ns32k_put_displacement;
|
||||
break;
|
||||
case 2:
|
||||
return _bfd_relocate_contents (howto, input_bfd, relocation,
|
||||
location);
|
||||
/* NOT REACHED */
|
||||
break;
|
||||
}
|
||||
return do_ns32k_reloc_contents (howto, input_bfd, relocation,
|
||||
location, get_data, put_data);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Define a target vector and some small routines for a variant of a.out.
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
@@ -15,14 +15,14 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "aout/aout64.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
/*#include "libaout.h"*/
|
||||
|
||||
extern CONST struct reloc_howto_struct * NAME(aout,reloc_type_lookup) ();
|
||||
extern reloc_howto_type * NAME(aout,reloc_type_lookup) ();
|
||||
|
||||
/* Set parameters about this a.out file that are machine-dependent.
|
||||
This routine is called from some_aout_object_p just before it returns. */
|
||||
@@ -43,6 +43,10 @@ MY(callback) (abfd)
|
||||
obj_datasec (abfd)->vma = N_DATADDR(*execp);
|
||||
obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
|
||||
|
||||
obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
|
||||
obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
|
||||
obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
|
||||
|
||||
/* The file offsets of the sections */
|
||||
obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
|
||||
obj_datasec (abfd)->filepos = N_DATOFF (*execp);
|
||||
@@ -54,7 +58,7 @@ MY(callback) (abfd)
|
||||
/* The file offsets of the string table and symbol table. */
|
||||
obj_sym_filepos (abfd) = N_SYMOFF (*execp);
|
||||
obj_str_filepos (abfd) = N_STROFF (*execp);
|
||||
|
||||
|
||||
/* Determine the architecture and machine type of the object file. */
|
||||
#ifdef SET_ARCH_MACH
|
||||
SET_ARCH_MACH(abfd, *execp);
|
||||
@@ -85,11 +89,11 @@ MY(callback) (abfd)
|
||||
/* Don't set sizes now -- can't be sure until we know arch & mach.
|
||||
Sizes get set in set_sizes callback, later. */
|
||||
#if 0
|
||||
adata(abfd).page_size = PAGE_SIZE;
|
||||
adata(abfd).page_size = TARGET_PAGE_SIZE;
|
||||
#ifdef SEGMENT_SIZE
|
||||
adata(abfd).segment_size = SEGMENT_SIZE;
|
||||
#else
|
||||
adata(abfd).segment_size = PAGE_SIZE;
|
||||
adata(abfd).segment_size = TARGET_PAGE_SIZE;
|
||||
#endif
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
#endif
|
||||
@@ -170,11 +174,11 @@ MY(mkobject) (abfd)
|
||||
return false;
|
||||
#if 0 /* Sizes get set in set_sizes callback, later, after we know
|
||||
the architecture and machine. */
|
||||
adata(abfd).page_size = PAGE_SIZE;
|
||||
adata(abfd).page_size = TARGET_PAGE_SIZE;
|
||||
#ifdef SEGMENT_SIZE
|
||||
adata(abfd).segment_size = SEGMENT_SIZE;
|
||||
#else
|
||||
adata(abfd).segment_size = PAGE_SIZE;
|
||||
adata(abfd).segment_size = TARGET_PAGE_SIZE;
|
||||
#endif
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
#endif
|
||||
@@ -199,7 +203,8 @@ MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
|
||||
bfd *obfd;
|
||||
asection *osec;
|
||||
{
|
||||
obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
|
||||
if (bfd_get_flavour (obfd) == bfd_target_aout_flavour)
|
||||
obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -235,18 +240,18 @@ static boolean
|
||||
MY(set_sizes) (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
adata(abfd).page_size = PAGE_SIZE;
|
||||
adata(abfd).page_size = TARGET_PAGE_SIZE;
|
||||
|
||||
#ifdef SEGMENT_SIZE
|
||||
adata(abfd).segment_size = SEGMENT_SIZE;
|
||||
#else
|
||||
adata(abfd).segment_size = PAGE_SIZE;
|
||||
adata(abfd).segment_size = TARGET_PAGE_SIZE;
|
||||
#endif
|
||||
|
||||
#ifdef ZMAGIC_DISK_BLOCK_SIZE
|
||||
adata(abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
|
||||
#else
|
||||
adata(abfd).zmagic_disk_block_size = PAGE_SIZE;
|
||||
adata(abfd).zmagic_disk_block_size = TARGET_PAGE_SIZE;
|
||||
#endif
|
||||
|
||||
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
@@ -261,9 +266,15 @@ MY(set_sizes) (abfd)
|
||||
|
||||
#ifndef MY_backend_data
|
||||
|
||||
#ifndef MY_zmagic_contiguous
|
||||
#define MY_zmagic_contiguous 0
|
||||
#endif
|
||||
#ifndef MY_text_includes_header
|
||||
#define MY_text_includes_header 0
|
||||
#endif
|
||||
#ifndef MY_exec_header_not_counted
|
||||
#define MY_exec_header_not_counted 0
|
||||
#endif
|
||||
#ifndef MY_add_dynamic_symbols
|
||||
#define MY_add_dynamic_symbols 0
|
||||
#endif
|
||||
@@ -284,12 +295,12 @@ MY(set_sizes) (abfd)
|
||||
#endif
|
||||
|
||||
static CONST struct aout_backend_data MY(backend_data) = {
|
||||
0, /* zmagic contiguous */
|
||||
MY_zmagic_contiguous,
|
||||
MY_text_includes_header,
|
||||
MY_exec_hdr_flags,
|
||||
0, /* text vma? */
|
||||
MY_set_sizes,
|
||||
0, /* exec header is counted */
|
||||
MY_exec_header_not_counted,
|
||||
MY_add_dynamic_symbols,
|
||||
MY_add_one_symbol,
|
||||
MY_link_dynamic_object,
|
||||
@@ -342,6 +353,9 @@ MY_bfd_final_link (abfd, info)
|
||||
#ifndef MY_openr_next_archived_file
|
||||
#define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
|
||||
#endif
|
||||
#ifndef MY_get_elt_at_index
|
||||
#define MY_get_elt_at_index _bfd_generic_get_elt_at_index
|
||||
#endif
|
||||
#ifndef MY_generic_stat_arch_elt
|
||||
#define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
|
||||
#endif
|
||||
@@ -351,12 +365,22 @@ MY_bfd_final_link (abfd, info)
|
||||
#ifndef MY_slurp_extended_name_table
|
||||
#define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
|
||||
#endif
|
||||
#ifndef MY_construct_extended_name_table
|
||||
#define MY_construct_extended_name_table \
|
||||
_bfd_archive_bsd_construct_extended_name_table
|
||||
#endif
|
||||
#ifndef MY_write_armap
|
||||
#define MY_write_armap bsd_write_armap
|
||||
#endif
|
||||
#ifndef MY_read_ar_hdr
|
||||
#define MY_read_ar_hdr _bfd_generic_read_ar_hdr
|
||||
#endif
|
||||
#ifndef MY_truncate_arname
|
||||
#define MY_truncate_arname bfd_bsd_truncate_arname
|
||||
#endif
|
||||
#ifndef MY_update_armap_timestamp
|
||||
#define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
|
||||
#endif
|
||||
|
||||
/* No core file defined here -- configure in trad-core.c separately. */
|
||||
#ifndef MY_core_file_failing_command
|
||||
@@ -399,6 +423,9 @@ MY_bfd_final_link (abfd, info)
|
||||
#ifndef MY_get_section_contents
|
||||
#define MY_get_section_contents NAME(aout,get_section_contents)
|
||||
#endif
|
||||
#ifndef MY_get_section_contents_in_window
|
||||
#define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
|
||||
#endif
|
||||
#ifndef MY_new_section_hook
|
||||
#define MY_new_section_hook NAME(aout,new_section_hook)
|
||||
#endif
|
||||
@@ -448,17 +475,43 @@ MY_bfd_final_link (abfd, info)
|
||||
#ifndef MY_bfd_make_debug_symbol
|
||||
#define MY_bfd_make_debug_symbol 0
|
||||
#endif
|
||||
#ifndef MY_read_minisymbols
|
||||
#define MY_read_minisymbols NAME(aout,read_minisymbols)
|
||||
#endif
|
||||
#ifndef MY_minisymbol_to_symbol
|
||||
#define MY_minisymbol_to_symbol NAME(aout,minisymbol_to_symbol)
|
||||
#endif
|
||||
#ifndef MY_bfd_link_hash_table_create
|
||||
#define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
|
||||
#endif
|
||||
#ifndef MY_bfd_link_add_symbols
|
||||
#define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
|
||||
#endif
|
||||
#ifndef MY_bfd_link_split_section
|
||||
#define MY_bfd_link_split_section _bfd_generic_link_split_section
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MY_bfd_copy_private_bfd_data
|
||||
#define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_merge_private_bfd_data
|
||||
#define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_copy_private_symbol_data
|
||||
#define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_print_private_bfd_data
|
||||
#define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_set_private_flags
|
||||
#define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
|
||||
#endif
|
||||
|
||||
#ifndef MY_bfd_is_local_label
|
||||
#define MY_bfd_is_local_label bfd_generic_is_local_label
|
||||
#endif
|
||||
@@ -489,7 +542,7 @@ MY_bfd_final_link (abfd, info)
|
||||
#endif
|
||||
|
||||
/* Aout symbols normally have leading underscores */
|
||||
#ifndef MY_symbol_leading_char
|
||||
#ifndef MY_symbol_leading_char
|
||||
#define MY_symbol_leading_char '_'
|
||||
#endif
|
||||
|
||||
@@ -504,11 +557,11 @@ const bfd_target MY(vec) =
|
||||
TARGETNAME, /* name */
|
||||
bfd_target_aout_flavour,
|
||||
#ifdef TARGET_IS_BIG_ENDIAN_P
|
||||
true, /* target byte order (big) */
|
||||
true, /* target headers byte order (big) */
|
||||
BFD_ENDIAN_BIG, /* target byte order (big) */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order (big) */
|
||||
#else
|
||||
false, /* target byte order (little) */
|
||||
false, /* target headers byte order (little) */
|
||||
BFD_ENDIAN_LITTLE, /* target byte order (little) */
|
||||
BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
|
||||
#endif
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
@@ -517,7 +570,6 @@ const bfd_target MY(vec) =
|
||||
MY_symbol_leading_char,
|
||||
AR_PAD_CHAR, /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
3, /* minimum alignment */
|
||||
#ifdef TARGET_IS_BIG_ENDIAN_P
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
@@ -0,0 +1,32 @@
|
||||
/* BFD backend for SunOS style a.out with flags set to 0
|
||||
Copyright (C) 1990, 91, 92, 93, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGETNAME "a.out-zero-big"
|
||||
#define MY(OP) CAT(aout0_big_,OP)
|
||||
|
||||
#include "bfd.h"
|
||||
|
||||
#define MY_exec_hdr_flags 0
|
||||
|
||||
#define MACHTYPE_OK(mtype) \
|
||||
((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020)
|
||||
|
||||
/* Include the usual a.out support. */
|
||||
#include "aoutf1.h"
|
||||
@@ -16,7 +16,7 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define ARCH_SIZE 32
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/* BFD back-end for 64-bit a.out files.
|
||||
Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define ARCH_SIZE 64
|
||||
|
||||
/* aoutx.h requires definitions for BMAGIC and QMAGIC. */
|
||||
#ifndef BMAGIC
|
||||
#define BMAGIC 0
|
||||
#endif
|
||||
#ifndef QMAGIC
|
||||
#define QMAGIC 0
|
||||
#endif
|
||||
|
||||
#include "aoutx.h"
|
||||
@@ -0,0 +1,788 @@
|
||||
/* A.out "format 1" file handling code for BFD.
|
||||
Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#include "aout/sun4.h"
|
||||
#include "libaout.h" /* BFD a.out internal data structures */
|
||||
|
||||
#include "aout/aout64.h"
|
||||
#include "aout/stab_gnu.h"
|
||||
#include "aout/ar.h"
|
||||
|
||||
/* This is needed to reject a NewsOS file, e.g. in
|
||||
gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
|
||||
I needed to add M_UNKNOWN to recognize a 68000 object, so this will
|
||||
probably no longer reject a NewsOS object. <ian@cygnus.com>. */
|
||||
#ifndef MACHTYPE_OK
|
||||
#define MACHTYPE_OK(mtype) \
|
||||
(((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
|
||||
|| (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
|
||||
&& bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))
|
||||
#endif
|
||||
|
||||
/*
|
||||
The file @code{aoutf1.h} contains the code for BFD's
|
||||
a.out back end. Control over the generated back end is given by these
|
||||
two preprocessor names:
|
||||
@table @code
|
||||
@item ARCH_SIZE
|
||||
This value should be either 32 or 64, depending upon the size of an
|
||||
int in the target format. It changes the sizes of the structs which
|
||||
perform the memory/disk mapping of structures.
|
||||
|
||||
The 64 bit backend may only be used if the host compiler supports 64
|
||||
ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}.
|
||||
With this name defined, @emph{all} bfd operations are performed with 64bit
|
||||
arithmetic, not just those to a 64bit target.
|
||||
|
||||
@item TARGETNAME
|
||||
The name put into the target vector.
|
||||
@item
|
||||
@end table
|
||||
|
||||
*/
|
||||
|
||||
/*SUPPRESS558*/
|
||||
/*SUPPRESS529*/
|
||||
|
||||
static void
|
||||
#if ARCH_SIZE == 64
|
||||
sunos_64_set_arch_mach
|
||||
#else
|
||||
sunos_32_set_arch_mach
|
||||
#endif
|
||||
(abfd, machtype)
|
||||
bfd *abfd;
|
||||
int machtype;
|
||||
{
|
||||
/* Determine the architecture and machine type of the object file. */
|
||||
enum bfd_architecture arch;
|
||||
long machine;
|
||||
switch (machtype)
|
||||
{
|
||||
|
||||
case M_UNKNOWN:
|
||||
/* Some Sun3s make magic numbers without cpu types in them, so
|
||||
we'll default to the 68000. */
|
||||
arch = bfd_arch_m68k;
|
||||
machine = 68000;
|
||||
break;
|
||||
|
||||
case M_68010:
|
||||
case M_HP200:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = 68010;
|
||||
break;
|
||||
|
||||
case M_68020:
|
||||
case M_HP300:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = 68020;
|
||||
break;
|
||||
|
||||
case M_SPARC:
|
||||
arch = bfd_arch_sparc;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
case M_386:
|
||||
case M_386_DYNIX:
|
||||
arch = bfd_arch_i386;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
case M_29K:
|
||||
arch = bfd_arch_a29k;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
case M_HPUX:
|
||||
arch = bfd_arch_m68k;
|
||||
machine = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
arch = bfd_arch_obscure;
|
||||
machine = 0;
|
||||
break;
|
||||
}
|
||||
bfd_set_arch_mach (abfd, arch, machine);
|
||||
}
|
||||
|
||||
#define SET_ARCH_MACH(ABFD, EXEC) \
|
||||
NAME(sunos,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
|
||||
choose_reloc_size(ABFD);
|
||||
|
||||
/* Determine the size of a relocation entry, based on the architecture */
|
||||
static void
|
||||
choose_reloc_size (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
switch (bfd_get_arch (abfd))
|
||||
{
|
||||
case bfd_arch_sparc:
|
||||
case bfd_arch_a29k:
|
||||
obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
|
||||
break;
|
||||
default:
|
||||
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write an object file in SunOS format.
|
||||
Section contents have already been written. We write the
|
||||
file header, symbols, and relocation. */
|
||||
|
||||
static boolean
|
||||
#if ARCH_SIZE == 64
|
||||
aout_64_sunos4_write_object_contents
|
||||
#else
|
||||
aout_32_sunos4_write_object_contents
|
||||
#endif
|
||||
(abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct external_exec exec_bytes;
|
||||
struct internal_exec *execp = exec_hdr (abfd);
|
||||
|
||||
/* Magic number, maestro, please! */
|
||||
switch (bfd_get_arch (abfd))
|
||||
{
|
||||
case bfd_arch_m68k:
|
||||
switch (bfd_get_mach (abfd))
|
||||
{
|
||||
case 68000:
|
||||
N_SET_MACHTYPE (*execp, M_UNKNOWN);
|
||||
break;
|
||||
case 68010:
|
||||
N_SET_MACHTYPE (*execp, M_68010);
|
||||
break;
|
||||
default:
|
||||
case 68020:
|
||||
N_SET_MACHTYPE (*execp, M_68020);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case bfd_arch_sparc:
|
||||
N_SET_MACHTYPE (*execp, M_SPARC);
|
||||
break;
|
||||
case bfd_arch_i386:
|
||||
N_SET_MACHTYPE (*execp, M_386);
|
||||
break;
|
||||
case bfd_arch_a29k:
|
||||
N_SET_MACHTYPE (*execp, M_29K);
|
||||
break;
|
||||
default:
|
||||
N_SET_MACHTYPE (*execp, M_UNKNOWN);
|
||||
}
|
||||
|
||||
choose_reloc_size (abfd);
|
||||
|
||||
N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
|
||||
|
||||
N_SET_DYNAMIC (*execp, bfd_get_file_flags (abfd) & DYNAMIC);
|
||||
|
||||
WRITE_HEADERS (abfd, execp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* core files */
|
||||
|
||||
#define CORE_MAGIC 0x080456
|
||||
#define CORE_NAMELEN 16
|
||||
|
||||
/* The core structure is taken from the Sun documentation.
|
||||
Unfortunately, they don't document the FPA structure, or at least I
|
||||
can't find it easily. Fortunately the core header contains its own
|
||||
length. So this shouldn't cause problems, except for c_ucode, which
|
||||
so far we don't use but is easy to find with a little arithmetic. */
|
||||
|
||||
/* But the reg structure can be gotten from the SPARC processor handbook.
|
||||
This really should be in a GNU include file though so that gdb can use
|
||||
the same info. */
|
||||
struct regs
|
||||
{
|
||||
int r_psr;
|
||||
int r_pc;
|
||||
int r_npc;
|
||||
int r_y;
|
||||
int r_g1;
|
||||
int r_g2;
|
||||
int r_g3;
|
||||
int r_g4;
|
||||
int r_g5;
|
||||
int r_g6;
|
||||
int r_g7;
|
||||
int r_o0;
|
||||
int r_o1;
|
||||
int r_o2;
|
||||
int r_o3;
|
||||
int r_o4;
|
||||
int r_o5;
|
||||
int r_o6;
|
||||
int r_o7;
|
||||
};
|
||||
|
||||
/* Taken from Sun documentation: */
|
||||
|
||||
/* FIXME: It's worse than we expect. This struct contains TWO substructs
|
||||
neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't
|
||||
even portably access the stuff in between! */
|
||||
|
||||
struct external_sparc_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
#define SPARC_CORE_LEN 432
|
||||
int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
|
||||
struct external_exec c_aouthdr; /* A.out header */
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||
/* The type "double" is critical here, for alignment.
|
||||
SunOS declares a struct here, but the struct's alignment
|
||||
is double since it contains doubles. */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
/* (this member is not accessible by name since we don't
|
||||
portably know the size of fp_stuff.) */
|
||||
};
|
||||
|
||||
/* Core files generated by the BCP (the part of Solaris which allows
|
||||
it to run SunOS4 a.out files). */
|
||||
struct external_solaris_bcp_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
#define SOLARIS_BCP_CORE_LEN 456
|
||||
int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
|
||||
int c_exdata_vp; /* exdata structure */
|
||||
int c_exdata_tsize;
|
||||
int c_exdata_dsize;
|
||||
int c_exdata_bsize;
|
||||
int c_exdata_lsize;
|
||||
int c_exdata_nshlibs;
|
||||
short c_exdata_mach;
|
||||
short c_exdata_mag;
|
||||
int c_exdata_toffset;
|
||||
int c_exdata_doffset;
|
||||
int c_exdata_loffset;
|
||||
int c_exdata_txtorg;
|
||||
int c_exdata_datorg;
|
||||
int c_exdata_entloc;
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||
/* The type "double" is critical here, for alignment.
|
||||
SunOS declares a struct here, but the struct's alignment
|
||||
is double since it contains doubles. */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
/* (this member is not accessible by name since we don't
|
||||
portably know the size of fp_stuff.) */
|
||||
};
|
||||
|
||||
struct external_sun3_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
#define SUN3_CORE_LEN 826 /* As of SunOS 4.1.1 */
|
||||
int c_regs[18]; /* General purpose registers -- MACHDEP SIZE */
|
||||
struct external_exec c_aouthdr; /* A.out header */
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
double fp_stuff[1]; /* external FPU state (size unknown by us) */
|
||||
/* The type "double" is critical here, for alignment.
|
||||
SunOS declares a struct here, but the struct's alignment
|
||||
is double since it contains doubles. */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
/* (this member is not accessible by name since we don't
|
||||
portably know the size of fp_stuff.) */
|
||||
};
|
||||
|
||||
struct internal_sunos_core
|
||||
{
|
||||
int c_magic; /* Corefile magic number */
|
||||
int c_len; /* Sizeof (struct core) */
|
||||
long c_regs_pos; /* file offset of General purpose registers */
|
||||
int c_regs_size; /* size of General purpose registers */
|
||||
struct internal_exec c_aouthdr; /* A.out header */
|
||||
int c_signo; /* Killing signal, if any */
|
||||
int c_tsize; /* Text size (bytes) */
|
||||
int c_dsize; /* Data size (bytes) */
|
||||
bfd_vma c_data_addr; /* Data start (address) */
|
||||
int c_ssize; /* Stack size (bytes) */
|
||||
bfd_vma c_stacktop; /* Stack top (address) */
|
||||
char c_cmdname[CORE_NAMELEN + 1]; /* Command name */
|
||||
long fp_stuff_pos; /* file offset of external FPU state (regs) */
|
||||
int fp_stuff_size; /* Size of it */
|
||||
int c_ucode; /* Exception no. from u_code */
|
||||
};
|
||||
|
||||
/* byte-swap in the Sun-3 core structure */
|
||||
static void
|
||||
swapcore_sun3 (abfd, ext, intcore)
|
||||
bfd *abfd;
|
||||
char *ext;
|
||||
struct internal_sunos_core *intcore;
|
||||
{
|
||||
struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
|
||||
|
||||
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
|
||||
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
|
||||
intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
|
||||
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||
#if ARCH_SIZE == 64
|
||||
aout_64_swap_exec_header_in
|
||||
#else
|
||||
aout_32_swap_exec_header_in
|
||||
#endif
|
||||
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
|
||||
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
|
||||
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
|
||||
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
|
||||
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
|
||||
intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
(file_ptr) (((struct external_sun3_core *) 0)->fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end */
|
||||
intcore->c_ucode =
|
||||
bfd_h_get_32 (abfd,
|
||||
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
|
||||
intcore->c_stacktop = 0x0E000000; /* By experimentation */
|
||||
}
|
||||
|
||||
|
||||
/* byte-swap in the Sparc core structure */
|
||||
static void
|
||||
swapcore_sparc (abfd, ext, intcore)
|
||||
bfd *abfd;
|
||||
char *ext;
|
||||
struct internal_sunos_core *intcore;
|
||||
{
|
||||
struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
|
||||
|
||||
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
|
||||
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
|
||||
intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
|
||||
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||
#if ARCH_SIZE == 64
|
||||
aout_64_swap_exec_header_in
|
||||
#else
|
||||
aout_32_swap_exec_header_in
|
||||
#endif
|
||||
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
|
||||
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
|
||||
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
|
||||
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
|
||||
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
|
||||
intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
(file_ptr) (((struct external_sparc_core *) 0)->fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end */
|
||||
intcore->c_ucode =
|
||||
bfd_h_get_32 (abfd,
|
||||
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
|
||||
|
||||
/* Supposedly the user stack grows downward from the bottom of kernel memory.
|
||||
Presuming that this remains true, this definition will work. */
|
||||
/* Now sun has provided us with another challenge. The value is different
|
||||
for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
|
||||
the other based on the current value of the stack pointer. This
|
||||
loses (a) if the stack pointer has been clobbered, or (b) if the stack
|
||||
is larger than 128 megabytes.
|
||||
|
||||
It's times like these you're glad they're switching to ELF.
|
||||
|
||||
Note that using include files or nlist on /vmunix would be wrong,
|
||||
because we want the value for this core file, no matter what kind of
|
||||
machine we were compiled on or are running on. */
|
||||
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
|
||||
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
|
||||
{
|
||||
bfd_vma sp = bfd_h_get_32
|
||||
(abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
|
||||
if (sp < SPARC_USRSTACK_SPARC10)
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
|
||||
else
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
|
||||
}
|
||||
}
|
||||
|
||||
/* byte-swap in the Solaris BCP core structure */
|
||||
static void
|
||||
swapcore_solaris_bcp (abfd, ext, intcore)
|
||||
bfd *abfd;
|
||||
char *ext;
|
||||
struct internal_sunos_core *intcore;
|
||||
{
|
||||
struct external_solaris_bcp_core *extcore =
|
||||
(struct external_solaris_bcp_core *) ext;
|
||||
|
||||
intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
|
||||
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
|
||||
intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs);
|
||||
intcore->c_regs_size = sizeof (extcore->c_regs);
|
||||
|
||||
/* The Solaris BCP exdata structure does not contain an a_syms field,
|
||||
so we are unable to synthesize an internal exec header.
|
||||
Luckily we are able to figure out the start address of the data section,
|
||||
which is the only thing needed from the internal exec header,
|
||||
from the exdata structure.
|
||||
|
||||
As of Solaris 2.3, BCP core files for statically linked executables
|
||||
are buggy. The exdata structure is not properly filled in, and
|
||||
the data section is written from address zero instead of the data
|
||||
start address. */
|
||||
memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
|
||||
intcore->c_data_addr =
|
||||
bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg);
|
||||
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
|
||||
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
|
||||
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
|
||||
intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
|
||||
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
|
||||
intcore->fp_stuff_pos =
|
||||
(long) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
|
||||
/* FP stuff takes up whole rest of struct, except c_ucode. */
|
||||
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
|
||||
(file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
|
||||
/* Ucode is the last thing in the struct -- just before the end */
|
||||
intcore->c_ucode =
|
||||
bfd_h_get_32 (abfd,
|
||||
intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
|
||||
|
||||
/* Supposedly the user stack grows downward from the bottom of kernel memory.
|
||||
Presuming that this remains true, this definition will work. */
|
||||
/* Now sun has provided us with another challenge. The value is different
|
||||
for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
|
||||
the other based on the current value of the stack pointer. This
|
||||
loses (a) if the stack pointer has been clobbered, or (b) if the stack
|
||||
is larger than 128 megabytes.
|
||||
|
||||
It's times like these you're glad they're switching to ELF.
|
||||
|
||||
Note that using include files or nlist on /vmunix would be wrong,
|
||||
because we want the value for this core file, no matter what kind of
|
||||
machine we were compiled on or are running on. */
|
||||
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
|
||||
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
|
||||
{
|
||||
bfd_vma sp = bfd_h_get_32
|
||||
(abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
|
||||
if (sp < SPARC_USRSTACK_SPARC10)
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
|
||||
else
|
||||
intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
|
||||
}
|
||||
}
|
||||
|
||||
/* need this cast because ptr is really void * */
|
||||
#define core_hdr(bfd) ((bfd)->tdata.sun_core_data)
|
||||
#define core_datasec(bfd) (core_hdr(bfd)->data_section)
|
||||
#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
|
||||
#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
|
||||
#define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section)
|
||||
|
||||
/* These are stored in the bfd's tdata */
|
||||
struct sun_core_struct
|
||||
{
|
||||
struct internal_sunos_core *hdr; /* core file header */
|
||||
asection *data_section;
|
||||
asection *stack_section;
|
||||
asection *reg_section;
|
||||
asection *reg2_section;
|
||||
};
|
||||
|
||||
static const bfd_target *
|
||||
sunos4_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
unsigned char longbuf[4]; /* Raw bytes of various header fields */
|
||||
bfd_size_type core_size;
|
||||
unsigned long core_mag;
|
||||
struct internal_sunos_core *core;
|
||||
char *extcore;
|
||||
struct mergem
|
||||
{
|
||||
struct sun_core_struct suncoredata;
|
||||
struct internal_sunos_core internal_sunos_core;
|
||||
char external_core[1];
|
||||
}
|
||||
*mergem;
|
||||
|
||||
if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
|
||||
sizeof (longbuf))
|
||||
return 0;
|
||||
core_mag = bfd_h_get_32 (abfd, longbuf);
|
||||
|
||||
if (core_mag != CORE_MAGIC)
|
||||
return 0;
|
||||
|
||||
/* SunOS core headers can vary in length; second word is size; */
|
||||
if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
|
||||
sizeof (longbuf))
|
||||
return 0;
|
||||
core_size = bfd_h_get_32 (abfd, longbuf);
|
||||
/* Sanity check */
|
||||
if (core_size > 20000)
|
||||
return 0;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
|
||||
return 0;
|
||||
|
||||
mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem));
|
||||
if (mergem == NULL)
|
||||
return 0;
|
||||
|
||||
extcore = mergem->external_core;
|
||||
|
||||
if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size)
|
||||
{
|
||||
bfd_release (abfd, (char *) mergem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Validate that it's a core file we know how to handle, due to sun
|
||||
botching the positioning of registers and other fields in a machine
|
||||
dependent way. */
|
||||
core = &mergem->internal_sunos_core;
|
||||
switch (core_size)
|
||||
{
|
||||
case SPARC_CORE_LEN:
|
||||
swapcore_sparc (abfd, extcore, core);
|
||||
break;
|
||||
case SUN3_CORE_LEN:
|
||||
swapcore_sun3 (abfd, extcore, core);
|
||||
break;
|
||||
case SOLARIS_BCP_CORE_LEN:
|
||||
swapcore_solaris_bcp (abfd, extcore, core);
|
||||
break;
|
||||
default:
|
||||
bfd_set_error (bfd_error_system_call); /* FIXME */
|
||||
bfd_release (abfd, (char *) mergem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
abfd->tdata.sun_core_data = &mergem->suncoredata;
|
||||
abfd->tdata.sun_core_data->hdr = core;
|
||||
|
||||
/* create the sections. This is raunchy, but bfd_close wants to reclaim
|
||||
them */
|
||||
core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_stacksec (abfd) == NULL)
|
||||
{
|
||||
loser:
|
||||
bfd_release (abfd, (char *) mergem);
|
||||
return 0;
|
||||
}
|
||||
core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_datasec (abfd) == NULL)
|
||||
{
|
||||
loser1:
|
||||
bfd_release (abfd, core_stacksec (abfd));
|
||||
goto loser;
|
||||
}
|
||||
core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_regsec (abfd) == NULL)
|
||||
{
|
||||
loser2:
|
||||
bfd_release (abfd, core_datasec (abfd));
|
||||
goto loser1;
|
||||
}
|
||||
core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (core_reg2sec (abfd) == NULL)
|
||||
{
|
||||
bfd_release (abfd, core_regsec (abfd));
|
||||
goto loser2;
|
||||
}
|
||||
|
||||
core_stacksec (abfd)->name = ".stack";
|
||||
core_datasec (abfd)->name = ".data";
|
||||
core_regsec (abfd)->name = ".reg";
|
||||
core_reg2sec (abfd)->name = ".reg2";
|
||||
|
||||
core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
|
||||
|
||||
core_stacksec (abfd)->_raw_size = core->c_ssize;
|
||||
core_datasec (abfd)->_raw_size = core->c_dsize;
|
||||
core_regsec (abfd)->_raw_size = core->c_regs_size;
|
||||
core_reg2sec (abfd)->_raw_size = core->fp_stuff_size;
|
||||
|
||||
core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize);
|
||||
core_datasec (abfd)->vma = core->c_data_addr;
|
||||
core_regsec (abfd)->vma = 0;
|
||||
core_reg2sec (abfd)->vma = 0;
|
||||
|
||||
core_stacksec (abfd)->filepos = core->c_len + core->c_dsize;
|
||||
core_datasec (abfd)->filepos = core->c_len;
|
||||
/* We'll access the regs afresh in the core file, like any section: */
|
||||
core_regsec (abfd)->filepos = (file_ptr) core->c_regs_pos;
|
||||
core_reg2sec (abfd)->filepos = (file_ptr) core->fp_stuff_pos;
|
||||
|
||||
/* Align to word at least */
|
||||
core_stacksec (abfd)->alignment_power = 2;
|
||||
core_datasec (abfd)->alignment_power = 2;
|
||||
core_regsec (abfd)->alignment_power = 2;
|
||||
core_reg2sec (abfd)->alignment_power = 2;
|
||||
|
||||
abfd->sections = core_stacksec (abfd);
|
||||
core_stacksec (abfd)->next = core_datasec (abfd);
|
||||
core_datasec (abfd)->next = core_regsec (abfd);
|
||||
core_regsec (abfd)->next = core_reg2sec (abfd);
|
||||
|
||||
abfd->section_count = 4;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
static char *
|
||||
sunos4_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->hdr->c_cmdname;
|
||||
}
|
||||
|
||||
static int
|
||||
sunos4_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return core_hdr (abfd)->hdr->c_signo;
|
||||
}
|
||||
|
||||
static boolean
|
||||
sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
if (core_bfd->xvec != exec_bfd->xvec)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Solaris core files do not include an aouthdr. */
|
||||
if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
|
||||
return true;
|
||||
|
||||
return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr),
|
||||
(char *) exec_hdr (exec_bfd),
|
||||
sizeof (struct internal_exec)) == 0) ? true : false;
|
||||
}
|
||||
|
||||
#define MY_set_sizes sunos4_set_sizes
|
||||
static boolean
|
||||
sunos4_set_sizes (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
switch (bfd_get_arch (abfd))
|
||||
{
|
||||
default:
|
||||
return false;
|
||||
case bfd_arch_sparc:
|
||||
adata (abfd).page_size = 0x2000;
|
||||
adata (abfd).segment_size = 0x2000;
|
||||
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
return true;
|
||||
case bfd_arch_m68k:
|
||||
adata (abfd).page_size = 0x2000;
|
||||
adata (abfd).segment_size = 0x20000;
|
||||
adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* We default to setting the toolversion field to 1, as is required by
|
||||
SunOS. */
|
||||
#ifndef MY_exec_hdr_flags
|
||||
#define MY_exec_hdr_flags 1
|
||||
#endif
|
||||
|
||||
#ifndef MY_add_dynamic_symbols
|
||||
#define MY_add_dynamic_symbols 0
|
||||
#endif
|
||||
#ifndef MY_add_one_symbol
|
||||
#define MY_add_one_symbol 0
|
||||
#endif
|
||||
#ifndef MY_link_dynamic_object
|
||||
#define MY_link_dynamic_object 0
|
||||
#endif
|
||||
#ifndef MY_write_dynamic_symbol
|
||||
#define MY_write_dynamic_symbol 0
|
||||
#endif
|
||||
#ifndef MY_check_dynamic_reloc
|
||||
#define MY_check_dynamic_reloc 0
|
||||
#endif
|
||||
#ifndef MY_finish_dynamic_link
|
||||
#define MY_finish_dynamic_link 0
|
||||
#endif
|
||||
|
||||
static CONST struct aout_backend_data sunos4_aout_backend =
|
||||
{
|
||||
0, /* zmagic files are not contiguous */
|
||||
1, /* text includes header */
|
||||
MY_exec_hdr_flags,
|
||||
0, /* default text vma */
|
||||
sunos4_set_sizes,
|
||||
0, /* header is counted in zmagic text */
|
||||
MY_add_dynamic_symbols,
|
||||
MY_add_one_symbol,
|
||||
MY_link_dynamic_object,
|
||||
MY_write_dynamic_symbol,
|
||||
MY_check_dynamic_reloc,
|
||||
MY_finish_dynamic_link
|
||||
};
|
||||
|
||||
#define MY_core_file_failing_command sunos4_core_file_failing_command
|
||||
#define MY_core_file_failing_signal sunos4_core_file_failing_signal
|
||||
#define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p
|
||||
|
||||
#define MY_bfd_debug_info_start bfd_void
|
||||
#define MY_bfd_debug_info_end bfd_void
|
||||
#define MY_bfd_debug_info_accumulate \
|
||||
(void (*) PARAMS ((bfd *, struct sec *))) bfd_void
|
||||
#define MY_core_file_p sunos4_core_file_p
|
||||
#define MY_write_object_contents NAME(aout,sunos4_write_object_contents)
|
||||
#define MY_backend_data &sunos4_aout_backend
|
||||
|
||||
#define TARGET_IS_BIG_ENDIAN_P
|
||||
|
||||
#include "aout-target.h"
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
||||
/* BFD back-end for archive files (libraries).
|
||||
Copyright 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
@@ -16,7 +16,7 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/*
|
||||
@setfilename archive-info
|
||||
@@ -175,15 +175,9 @@ static char *get_extended_arelt_filename PARAMS ((bfd *arch,
|
||||
const char *name));
|
||||
static boolean do_slurp_bsd_armap PARAMS ((bfd *abfd));
|
||||
static boolean do_slurp_coff_armap PARAMS ((bfd *abfd));
|
||||
static const char *normalize PARAMS ((const char *file));
|
||||
static boolean bfd_construct_extended_name_table PARAMS ((bfd *abfd,
|
||||
char **tabloc,
|
||||
unsigned int *));
|
||||
static const char *normalize PARAMS ((bfd *, const char *file));
|
||||
static struct areltdata *bfd_ar_hdr_from_filesystem PARAMS ((bfd *abfd,
|
||||
const char *));
|
||||
static boolean compute_and_write_armap PARAMS ((bfd *arch,
|
||||
unsigned int elength));
|
||||
static boolean bsd_update_armap_timestamp PARAMS ((bfd *arch));
|
||||
|
||||
boolean
|
||||
_bfd_generic_mkarchive (abfd)
|
||||
@@ -193,10 +187,7 @@ _bfd_generic_mkarchive (abfd)
|
||||
bfd_zalloc (abfd, sizeof (struct artdata)));
|
||||
|
||||
if (bfd_ardata (abfd) == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
bfd_ardata (abfd)->cache = NULL;
|
||||
bfd_ardata (abfd)->archive_head = NULL;
|
||||
@@ -242,7 +233,9 @@ bfd_get_next_mapent (abfd, prev, entry)
|
||||
|
||||
if (prev == BFD_NO_MORE_SYMBOLS)
|
||||
prev = 0;
|
||||
else if (++prev >= bfd_ardata (abfd)->symdef_count)
|
||||
else
|
||||
++prev;
|
||||
if (prev >= bfd_ardata (abfd)->symdef_count)
|
||||
return BFD_NO_MORE_SYMBOLS;
|
||||
|
||||
*entry = (bfd_ardata (abfd)->symdefs + prev);
|
||||
@@ -255,15 +248,7 @@ bfd *
|
||||
_bfd_create_empty_archive_element_shell (obfd)
|
||||
bfd *obfd;
|
||||
{
|
||||
bfd *nbfd;
|
||||
|
||||
nbfd = _bfd_new_bfd_contained_in (obfd);
|
||||
if (nbfd == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return NULL;
|
||||
}
|
||||
return nbfd;
|
||||
return _bfd_new_bfd_contained_in (obfd);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -314,10 +299,7 @@ _bfd_add_bfd_to_archive_cache (arch_bfd, filepos, new_elt)
|
||||
sizeof (struct ar_cache)));
|
||||
|
||||
if (new_cache == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
new_cache->ptr = filepos;
|
||||
new_cache->arelt = new_elt;
|
||||
@@ -369,14 +351,21 @@ get_extended_arelt_filename (arch, name)
|
||||
could have been moved arbitrarily.
|
||||
*/
|
||||
|
||||
struct areltdata *
|
||||
_bfd_snarf_ar_hdr (abfd)
|
||||
PTR
|
||||
_bfd_generic_read_ar_hdr (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
return _bfd_generic_read_ar_hdr_mag (abfd, (const char *) NULL);
|
||||
}
|
||||
|
||||
/* Alpha ECOFF uses an optional different ARFMAG value, so we have a
|
||||
variant of _bfd_generic_read_ar_hdr which accepts a magic string. */
|
||||
|
||||
PTR
|
||||
_bfd_generic_read_ar_hdr_mag (abfd, mag)
|
||||
bfd *abfd;
|
||||
const char *mag;
|
||||
{
|
||||
struct ar_hdr hdr;
|
||||
char *hdrp = (char *) &hdr;
|
||||
unsigned int parsed_size;
|
||||
@@ -393,7 +382,9 @@ _bfd_snarf_ar_hdr (abfd)
|
||||
bfd_set_error (bfd_error_no_more_archived_files);
|
||||
return NULL;
|
||||
}
|
||||
if (strncmp (hdr.ar_fmag, ARFMAG, 2))
|
||||
if (strncmp (hdr.ar_fmag, ARFMAG, 2) != 0
|
||||
&& (mag == NULL
|
||||
|| strncmp (hdr.ar_fmag, mag, 2) != 0))
|
||||
{
|
||||
bfd_set_error (bfd_error_malformed_archive);
|
||||
return NULL;
|
||||
@@ -434,10 +425,7 @@ _bfd_snarf_ar_hdr (abfd)
|
||||
|
||||
allocptr = bfd_zalloc (abfd, allocsize);
|
||||
if (allocptr == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
filename = (allocptr
|
||||
+ sizeof (struct areltdata)
|
||||
+ sizeof (struct ar_hdr));
|
||||
@@ -477,10 +465,7 @@ _bfd_snarf_ar_hdr (abfd)
|
||||
{
|
||||
allocptr = bfd_zalloc (abfd, allocsize);
|
||||
if (allocptr == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ared = (struct areltdata *) allocptr;
|
||||
@@ -500,7 +485,7 @@ _bfd_snarf_ar_hdr (abfd)
|
||||
ared->filename[namelen] = '\0';
|
||||
}
|
||||
|
||||
return ared;
|
||||
return (PTR) ared;
|
||||
}
|
||||
|
||||
/* This is an internal function; it's mainly used when indexing
|
||||
@@ -522,7 +507,7 @@ _bfd_get_elt_at_filepos (archive, filepos)
|
||||
if (0 > bfd_seek (archive, filepos, SEEK_SET))
|
||||
return NULL;
|
||||
|
||||
if ((new_areldata = _bfd_snarf_ar_hdr (archive)) == NULL)
|
||||
if ((new_areldata = (struct areltdata *) _bfd_read_ar_hdr (archive)) == NULL)
|
||||
return NULL;
|
||||
|
||||
n_nfd = _bfd_create_empty_archive_element_shell (archive);
|
||||
@@ -545,23 +530,13 @@ _bfd_get_elt_at_filepos (archive, filepos)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_get_elt_at_index
|
||||
/* Return the BFD which is referenced by the symbol in ABFD indexed by
|
||||
INDEX. INDEX should have been returned by bfd_get_next_mapent. */
|
||||
|
||||
SYNOPSIS
|
||||
bfd *bfd_get_elt_at_index(bfd *archive, int index);
|
||||
|
||||
DESCRIPTION
|
||||
Return the BFD which is referenced by the symbol in @var{archive}
|
||||
indexed by @var{index}. @var{index} should have been returned by
|
||||
<<bfd_get_next_mapent>> (q.v.).
|
||||
|
||||
*/
|
||||
bfd *
|
||||
bfd_get_elt_at_index (abfd, index)
|
||||
_bfd_generic_get_elt_at_index (abfd, index)
|
||||
bfd *abfd;
|
||||
int index;
|
||||
symindex index;
|
||||
{
|
||||
carsym *entry;
|
||||
|
||||
@@ -631,8 +606,11 @@ const bfd_target *
|
||||
bfd_generic_archive_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct artdata *tdata_hold;
|
||||
char armag[SARMAG + 1];
|
||||
|
||||
tdata_hold = abfd->tdata.aout_ar_data;
|
||||
|
||||
if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
@@ -655,10 +633,7 @@ bfd_generic_archive_p (abfd)
|
||||
bfd_zalloc (abfd, sizeof (struct artdata)));
|
||||
|
||||
if (bfd_ardata (abfd) == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
bfd_ardata (abfd)->first_file_filepos = SARMAG;
|
||||
bfd_ardata (abfd)->cache = NULL;
|
||||
@@ -670,17 +645,54 @@ bfd_generic_archive_p (abfd)
|
||||
if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd)))
|
||||
{
|
||||
bfd_release (abfd, bfd_ardata (abfd));
|
||||
abfd->tdata.aout_ar_data = NULL;
|
||||
abfd->tdata.aout_ar_data = tdata_hold;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd)))
|
||||
{
|
||||
bfd_release (abfd, bfd_ardata (abfd));
|
||||
abfd->tdata.aout_ar_data = NULL;
|
||||
abfd->tdata.aout_ar_data = tdata_hold;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (bfd_has_map (abfd))
|
||||
{
|
||||
bfd *first;
|
||||
|
||||
/* This archive has a map, so we may presume that the contents
|
||||
are object files. Make sure that if the first file in the
|
||||
archive can be recognized as an object file, it is for this
|
||||
target. If not, assume that this is the wrong format. If
|
||||
the first file is not an object file, somebody is doing
|
||||
something weird, and we permit it so that ar -t will work.
|
||||
|
||||
This is done because any normal format will recognize any
|
||||
normal archive, regardless of the format of the object files.
|
||||
We do accept an empty archive. */
|
||||
|
||||
first = bfd_openr_next_archived_file (abfd, (bfd *) NULL);
|
||||
if (first != NULL)
|
||||
{
|
||||
boolean fail;
|
||||
|
||||
first->target_defaulted = false;
|
||||
fail = false;
|
||||
if (bfd_check_format (first, bfd_object)
|
||||
&& first->xvec != abfd->xvec)
|
||||
{
|
||||
(void) bfd_close (first);
|
||||
bfd_release (abfd, bfd_ardata (abfd));
|
||||
abfd->tdata.aout_ar_data = tdata_hold;
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We ought to close first here, but we can't, because we
|
||||
have no way to remove it from the archive cache. FIXME. */
|
||||
}
|
||||
}
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
@@ -715,7 +727,7 @@ do_slurp_bsd_armap (abfd)
|
||||
unsigned int parsed_size;
|
||||
carsym *set;
|
||||
|
||||
mapdata = _bfd_snarf_ar_hdr (abfd);
|
||||
mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
|
||||
if (mapdata == NULL)
|
||||
return false;
|
||||
parsed_size = mapdata->parsed_size;
|
||||
@@ -723,10 +735,7 @@ do_slurp_bsd_armap (abfd)
|
||||
|
||||
raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
|
||||
if (raw_armap == (bfd_byte *) NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
|
||||
{
|
||||
@@ -756,10 +765,7 @@ do_slurp_bsd_armap (abfd)
|
||||
(ardata->symdef_count
|
||||
* sizeof (carsym)));
|
||||
if (!ardata->symdefs)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
for (counter = 0, set = ardata->symdefs;
|
||||
counter < ardata->symdef_count;
|
||||
@@ -796,7 +802,7 @@ do_slurp_coff_armap (abfd)
|
||||
char int_buf[sizeof (long)];
|
||||
unsigned int carsym_size, ptrsize, i;
|
||||
|
||||
mapdata = _bfd_snarf_ar_hdr (abfd);
|
||||
mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
|
||||
if (mapdata == NULL)
|
||||
return false;
|
||||
parsed_size = mapdata->parsed_size;
|
||||
@@ -837,20 +843,14 @@ do_slurp_coff_armap (abfd)
|
||||
|
||||
ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
|
||||
if (ardata->symdefs == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
carsyms = ardata->symdefs;
|
||||
stringbase = ((char *) ardata->symdefs) + carsym_size;
|
||||
|
||||
/* Allocate and read in the raw offsets. */
|
||||
raw_armap = (int *) bfd_alloc (abfd, ptrsize);
|
||||
if (raw_armap == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
goto release_symdefs;
|
||||
}
|
||||
goto release_symdefs;
|
||||
if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize
|
||||
|| bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)
|
||||
{
|
||||
@@ -875,8 +875,29 @@ do_slurp_coff_armap (abfd)
|
||||
/* Pad to an even boundary if you have to */
|
||||
ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
|
||||
|
||||
|
||||
bfd_has_map (abfd) = true;
|
||||
bfd_release (abfd, (PTR) raw_armap);
|
||||
|
||||
|
||||
/* Check for a second archive header (as used by PE) */
|
||||
{
|
||||
struct areltdata *tmp;
|
||||
|
||||
bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET);
|
||||
tmp = (struct areltdata *) _bfd_read_ar_hdr (abfd);
|
||||
if (tmp != NULL)
|
||||
{
|
||||
if (tmp->arch_header[0] == '/'
|
||||
&& tmp->arch_header[1] == ' ')
|
||||
{
|
||||
ardata->first_file_filepos +=
|
||||
(tmp->parsed_size + sizeof(struct ar_hdr) + 1) & ~1;
|
||||
}
|
||||
bfd_release (abfd, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
release_raw_armap:
|
||||
@@ -954,14 +975,13 @@ bfd_slurp_bsd_armap_f2 (abfd)
|
||||
return true;
|
||||
}
|
||||
|
||||
mapdata = _bfd_snarf_ar_hdr (abfd);
|
||||
mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
|
||||
if (mapdata == NULL)
|
||||
return false;
|
||||
|
||||
raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);
|
||||
if (raw_armap == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
byebye:
|
||||
bfd_release (abfd, (PTR) mapdata);
|
||||
return false;
|
||||
@@ -999,10 +1019,7 @@ bfd_slurp_bsd_armap_f2 (abfd)
|
||||
(ardata->symdef_count
|
||||
* BSD_SYMDEF_SIZE));
|
||||
if (!ardata->symdefs)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
for (counter = 0, set = ardata->symdefs;
|
||||
counter < ardata->symdef_count;
|
||||
@@ -1042,9 +1059,9 @@ _bfd_slurp_extended_name_table (abfd)
|
||||
|
||||
/* FIXME: Formatting sucks here, and in case of failure of BFD_READ,
|
||||
we probably don't want to return true. */
|
||||
bfd_seek (abfd, bfd_ardata (abfd)->first_file_filepos, SEEK_SET);
|
||||
if (bfd_read ((PTR) nextname, 1, 16, abfd) == 16)
|
||||
{
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
|
||||
return false;
|
||||
|
||||
@@ -1055,7 +1072,7 @@ _bfd_slurp_extended_name_table (abfd)
|
||||
return true;
|
||||
}
|
||||
|
||||
namedata = _bfd_snarf_ar_hdr (abfd);
|
||||
namedata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
|
||||
if (namedata == NULL)
|
||||
return false;
|
||||
|
||||
@@ -1063,7 +1080,6 @@ _bfd_slurp_extended_name_table (abfd)
|
||||
bfd_zalloc (abfd, namedata->parsed_size);
|
||||
if (bfd_ardata (abfd)->extended_names == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
byebye:
|
||||
bfd_release (abfd, (PTR) namedata);
|
||||
return false;
|
||||
@@ -1082,13 +1098,17 @@ _bfd_slurp_extended_name_table (abfd)
|
||||
/* Since the archive is supposed to be printable if it contains
|
||||
text, the entries in the list are newline-padded, not null
|
||||
padded. In SVR4-style archives, the names also have a
|
||||
trailing '/'. We'll fix both problems here.. */
|
||||
trailing '/'. DOS/NT created archive often have \ in them
|
||||
We'll fix all problems here.. */
|
||||
{
|
||||
char *temp = bfd_ardata (abfd)->extended_names;
|
||||
char *limit = temp + namedata->parsed_size;
|
||||
for (; temp < limit; ++temp)
|
||||
for (; temp < limit; ++temp) {
|
||||
if (*temp == '\012')
|
||||
temp[temp[-1] == '/' ? -1 : 0] = '\0';
|
||||
if (*temp == '\\')
|
||||
*temp = '/';
|
||||
}
|
||||
}
|
||||
|
||||
/* Pad to an even boundary if you have to */
|
||||
@@ -1108,7 +1128,8 @@ _bfd_slurp_extended_name_table (abfd)
|
||||
/* Return a copy of the stuff in the filename between any :]> and a
|
||||
semicolon */
|
||||
static const char *
|
||||
normalize (file)
|
||||
normalize (abfd, file)
|
||||
bfd *abfd;
|
||||
const char *file;
|
||||
{
|
||||
CONST char *first;
|
||||
@@ -1130,10 +1151,9 @@ normalize (file)
|
||||
first--;
|
||||
}
|
||||
|
||||
|
||||
copy = malloc (last - first + 1);
|
||||
if (!copy)
|
||||
return copy;
|
||||
copy = (char *) bfd_alloc (abfd, last - first + 1);
|
||||
if (copy == NULL)
|
||||
return NULL;
|
||||
|
||||
memcpy (copy, first, last - first);
|
||||
copy[last - first] = 0;
|
||||
@@ -1143,10 +1163,11 @@ normalize (file)
|
||||
|
||||
#else
|
||||
static const char *
|
||||
normalize (file)
|
||||
normalize (abfd, file)
|
||||
bfd *abfd;
|
||||
const char *file;
|
||||
{
|
||||
CONST char *filename = strrchr (file, '/');
|
||||
const char *filename = strrchr (file, '/');
|
||||
|
||||
if (filename != (char *) NULL)
|
||||
filename++;
|
||||
@@ -1156,6 +1177,32 @@ normalize (file)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Build a BFD style extended name table. */
|
||||
|
||||
boolean
|
||||
_bfd_archive_bsd_construct_extended_name_table (abfd, tabloc, tablen, name)
|
||||
bfd *abfd;
|
||||
char **tabloc;
|
||||
bfd_size_type *tablen;
|
||||
const char **name;
|
||||
{
|
||||
*name = "ARFILENAMES/";
|
||||
return _bfd_construct_extended_name_table (abfd, false, tabloc, tablen);
|
||||
}
|
||||
|
||||
/* Build an SVR4 style extended name table. */
|
||||
|
||||
boolean
|
||||
_bfd_archive_coff_construct_extended_name_table (abfd, tabloc, tablen, name)
|
||||
bfd *abfd;
|
||||
char **tabloc;
|
||||
bfd_size_type *tablen;
|
||||
const char **name;
|
||||
{
|
||||
*name = "//";
|
||||
return _bfd_construct_extended_name_table (abfd, true, tabloc, tablen);
|
||||
}
|
||||
|
||||
/* Follows archive_head and produces an extended name table if
|
||||
necessary. Returns (in tabloc) a pointer to an extended name
|
||||
table, and in tablen the length of the table. If it makes an entry
|
||||
@@ -1164,11 +1211,12 @@ normalize (file)
|
||||
something went wrong. A successful return may still involve a
|
||||
zero-length tablen! */
|
||||
|
||||
static boolean
|
||||
bfd_construct_extended_name_table (abfd, tabloc, tablen)
|
||||
boolean
|
||||
_bfd_construct_extended_name_table (abfd, trailing_slash, tabloc, tablen)
|
||||
bfd *abfd;
|
||||
boolean trailing_slash;
|
||||
char **tabloc;
|
||||
unsigned int *tablen;
|
||||
bfd_size_type *tablen;
|
||||
{
|
||||
unsigned int maxname = abfd->xvec->ar_max_namelen;
|
||||
unsigned int total_namelen = 0;
|
||||
@@ -1180,17 +1228,44 @@ bfd_construct_extended_name_table (abfd, tabloc, tablen)
|
||||
/* Figure out how long the table should be */
|
||||
for (current = abfd->archive_head; current != NULL; current = current->next)
|
||||
{
|
||||
CONST char *normal = normalize (current->filename);
|
||||
const char *normal;
|
||||
unsigned int thislen;
|
||||
|
||||
if (!normal)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
normal = normalize (current, current->filename);
|
||||
if (normal == NULL)
|
||||
return false;
|
||||
|
||||
thislen = strlen (normal);
|
||||
|
||||
if (thislen > maxname
|
||||
&& (bfd_get_file_flags (abfd) & BFD_TRADITIONAL_FORMAT) != 0)
|
||||
thislen = maxname;
|
||||
|
||||
if (thislen > maxname)
|
||||
total_namelen += thislen + 1; /* leave room for \n */
|
||||
{
|
||||
/* Add one to leave room for \n. */
|
||||
total_namelen += thislen + 1;
|
||||
if (trailing_slash)
|
||||
{
|
||||
/* Leave room for trailing slash. */
|
||||
++total_namelen;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
struct ar_hdr *hdr = arch_hdr (current);
|
||||
if (strncmp (normal, hdr->ar_name, thislen) != 0
|
||||
|| (thislen < sizeof hdr->ar_name
|
||||
&& hdr->ar_name[thislen] != ar_padchar (current)))
|
||||
{
|
||||
/* Must have been using extended format even though it
|
||||
didn't need to. Fix it to use normal format. */
|
||||
memcpy (hdr->ar_name, normal, thislen);
|
||||
if (thislen < maxname
|
||||
|| (thislen == maxname && thislen < sizeof hdr->ar_name))
|
||||
hdr->ar_name[thislen] = ar_padchar (current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (total_namelen == 0)
|
||||
@@ -1198,10 +1273,7 @@ bfd_construct_extended_name_table (abfd, tabloc, tablen)
|
||||
|
||||
*tabloc = bfd_zalloc (abfd, total_namelen);
|
||||
if (*tabloc == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
*tablen = total_namelen;
|
||||
strptr = *tabloc;
|
||||
@@ -1209,14 +1281,13 @@ bfd_construct_extended_name_table (abfd, tabloc, tablen)
|
||||
for (current = abfd->archive_head; current != NULL; current =
|
||||
current->next)
|
||||
{
|
||||
CONST char *normal = normalize (current->filename);
|
||||
const char *normal;
|
||||
unsigned int thislen;
|
||||
|
||||
if (!normal)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
normal = normalize (current, current->filename);
|
||||
if (normal == NULL)
|
||||
return false;
|
||||
|
||||
thislen = strlen (normal);
|
||||
if (thislen > maxname)
|
||||
{
|
||||
@@ -1225,7 +1296,13 @@ bfd_construct_extended_name_table (abfd, tabloc, tablen)
|
||||
generalise this hack. */
|
||||
struct ar_hdr *hdr = arch_hdr (current);
|
||||
strcpy (strptr, normal);
|
||||
strptr[thislen] = '\012';
|
||||
if (! trailing_slash)
|
||||
strptr[thislen] = '\012';
|
||||
else
|
||||
{
|
||||
strptr[thislen] = '/';
|
||||
strptr[thislen + 1] = '\012';
|
||||
}
|
||||
hdr->ar_name[0] = ar_padchar (current);
|
||||
/* We know there will always be enough room (one of the few
|
||||
cases where you may safely use sprintf). */
|
||||
@@ -1239,6 +1316,8 @@ bfd_construct_extended_name_table (abfd, tabloc, tablen)
|
||||
*temp = ' ';
|
||||
}
|
||||
strptr += thislen + 1;
|
||||
if (trailing_slash)
|
||||
++strptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1270,10 +1349,7 @@ bfd_ar_hdr_from_filesystem (abfd, filename)
|
||||
ared = (struct areltdata *) bfd_zalloc (abfd, sizeof (struct ar_hdr) +
|
||||
sizeof (struct areltdata));
|
||||
if (ared == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
|
||||
|
||||
/* ar headers are space padded, not null padded! */
|
||||
@@ -1364,16 +1440,31 @@ bfd_dont_truncate_arname (abfd, pathname, arhdr)
|
||||
intel's release is out the door. */
|
||||
|
||||
struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
|
||||
int length;
|
||||
CONST char *filename = normalize (pathname);
|
||||
int maxlen = ar_maxnamelen (abfd);
|
||||
size_t length;
|
||||
const char *filename;
|
||||
size_t maxlen = ar_maxnamelen (abfd);
|
||||
|
||||
if ((bfd_get_file_flags (abfd) & BFD_TRADITIONAL_FORMAT) != 0)
|
||||
{
|
||||
bfd_bsd_truncate_arname (abfd, pathname, arhdr);
|
||||
return;
|
||||
}
|
||||
|
||||
filename = normalize (abfd, pathname);
|
||||
if (filename == NULL)
|
||||
{
|
||||
/* FIXME */
|
||||
abort ();
|
||||
}
|
||||
|
||||
length = strlen (filename);
|
||||
|
||||
if (length <= maxlen)
|
||||
memcpy (hdr->ar_name, filename, length);
|
||||
|
||||
if (length < maxlen)
|
||||
/* Add the padding character if there is room for it. */
|
||||
if (length < maxlen
|
||||
|| (length == maxlen && length < sizeof hdr->ar_name))
|
||||
(hdr->ar_name)[length] = ar_padchar (abfd);
|
||||
}
|
||||
|
||||
@@ -1460,7 +1551,8 @@ _bfd_write_archive_contents (arch)
|
||||
{
|
||||
bfd *current;
|
||||
char *etable = NULL;
|
||||
unsigned int elength = 0;
|
||||
bfd_size_type elength = 0;
|
||||
const char *ename = NULL;
|
||||
boolean makemap = bfd_has_map (arch);
|
||||
boolean hasobjects = false; /* if no .o's, don't bother to make a map */
|
||||
bfd_size_type wrote;
|
||||
@@ -1501,7 +1593,8 @@ _bfd_write_archive_contents (arch)
|
||||
}
|
||||
}
|
||||
|
||||
if (!bfd_construct_extended_name_table (arch, &etable, &elength))
|
||||
if (!BFD_SEND (arch, _bfd_construct_extended_name_table,
|
||||
(arch, &etable, &elength, &ename)))
|
||||
return false;
|
||||
|
||||
if (bfd_seek (arch, (file_ptr) 0, SEEK_SET) != 0)
|
||||
@@ -1516,7 +1609,7 @@ _bfd_write_archive_contents (arch)
|
||||
|
||||
if (makemap && hasobjects)
|
||||
{
|
||||
if (compute_and_write_armap (arch, elength) != true)
|
||||
if (_bfd_compute_and_write_armap (arch, elength) != true)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1525,11 +1618,10 @@ _bfd_write_archive_contents (arch)
|
||||
struct ar_hdr hdr;
|
||||
|
||||
memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
|
||||
if (ar_padchar (arch) == '/')
|
||||
sprintf (&(hdr.ar_name[0]), "//");
|
||||
else
|
||||
sprintf (&(hdr.ar_name[0]), "ARFILENAMES/");
|
||||
sprintf (&(hdr.ar_size[0]), "%-10d", (int) elength);
|
||||
strcpy (hdr.ar_name, ename);
|
||||
/* Round size up to even number in archive header. */
|
||||
sprintf (&(hdr.ar_size[0]), "%-10d",
|
||||
(int) ((elength + 1) & ~1));
|
||||
strncpy (hdr.ar_fmag, ARFMAG, 2);
|
||||
for (i = 0; i < sizeof (struct ar_hdr); i++)
|
||||
if (((char *) (&hdr))[i] == '\0')
|
||||
@@ -1579,44 +1671,32 @@ _bfd_write_archive_contents (arch)
|
||||
}
|
||||
}
|
||||
|
||||
/* Verify the timestamp in the archive file. If it would not be
|
||||
accepted by the linker, rewrite it until it would be. If
|
||||
anything odd happens, break out and just return. (The Berkeley
|
||||
linker checks the timestamp and refuses to read the
|
||||
table-of-contents if it is >60 seconds less than the file's
|
||||
modified-time. That painful hack requires this painful hack. */
|
||||
|
||||
tries = 1;
|
||||
do
|
||||
if (makemap && hasobjects)
|
||||
{
|
||||
/* FIXME! This kludge is to avoid adding a member to the xvec,
|
||||
while generating a small patch for Adobe. FIXME! The
|
||||
update_armap_timestamp function call should be in the xvec,
|
||||
thus:
|
||||
|
||||
if (bfd_update_armap_timestamp (arch) == true) break;
|
||||
^
|
||||
|
||||
Instead, we check whether in a BSD archive, and call
|
||||
directly. */
|
||||
|
||||
if (arch->xvec->write_armap != bsd_write_armap)
|
||||
break;
|
||||
if (bsd_update_armap_timestamp (arch) == true) /* FIXME!!! Vector it */
|
||||
break;
|
||||
if (tries > 0)
|
||||
fprintf (stderr,
|
||||
"Warning: writing archive was slow: rewriting timestamp\n");
|
||||
/* Verify the timestamp in the archive file. If it would not be
|
||||
accepted by the linker, rewrite it until it would be. If
|
||||
anything odd happens, break out and just return. (The
|
||||
Berkeley linker checks the timestamp and refuses to read the
|
||||
table-of-contents if it is >60 seconds less than the file's
|
||||
modified-time. That painful hack requires this painful hack. */
|
||||
tries = 1;
|
||||
do
|
||||
{
|
||||
if (bfd_update_armap_timestamp (arch))
|
||||
break;
|
||||
(*_bfd_error_handler)
|
||||
("Warning: writing archive was slow: rewriting timestamp\n");
|
||||
}
|
||||
while (++tries < 6);
|
||||
}
|
||||
while (++tries < 6);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Note that the namidx for the first symbol is 0 */
|
||||
|
||||
static boolean
|
||||
compute_and_write_armap (arch, elength)
|
||||
boolean
|
||||
_bfd_compute_and_write_armap (arch, elength)
|
||||
bfd *arch;
|
||||
unsigned int elength;
|
||||
{
|
||||
@@ -1636,15 +1716,15 @@ compute_and_write_armap (arch, elength)
|
||||
elength += sizeof (struct ar_hdr);
|
||||
elength += elength % 2;
|
||||
|
||||
map = (struct orl *) malloc (orl_max * sizeof (struct orl));
|
||||
map = (struct orl *) bfd_malloc (orl_max * sizeof (struct orl));
|
||||
if (map == NULL)
|
||||
goto no_memory_return;
|
||||
goto error_return;
|
||||
|
||||
/* We put the symbol names on the arch obstack, and then discard
|
||||
them when done. */
|
||||
first_name = bfd_alloc (arch, 1);
|
||||
if (first_name == NULL)
|
||||
goto no_memory_return;
|
||||
goto error_return;
|
||||
|
||||
/* Drop all the files called __.SYMDEF, we're going to make our
|
||||
own */
|
||||
@@ -1675,9 +1755,9 @@ compute_and_write_armap (arch, elength)
|
||||
if (syms_max > 0)
|
||||
free (syms);
|
||||
syms_max = storage;
|
||||
syms = (asymbol **) malloc ((size_t) syms_max);
|
||||
syms = (asymbol **) bfd_malloc ((size_t) syms_max);
|
||||
if (syms == NULL)
|
||||
goto no_memory_return;
|
||||
goto error_return;
|
||||
}
|
||||
symcount = bfd_canonicalize_symtab (current, syms);
|
||||
if (symcount < 0)
|
||||
@@ -1702,11 +1782,11 @@ compute_and_write_armap (arch, elength)
|
||||
if (orl_count == orl_max)
|
||||
{
|
||||
orl_max *= 2;
|
||||
new_map = ((struct orl *)
|
||||
realloc ((PTR) map,
|
||||
orl_max * sizeof (struct orl)));
|
||||
new_map =
|
||||
((struct orl *)
|
||||
bfd_realloc (map, orl_max * sizeof (struct orl)));
|
||||
if (new_map == (struct orl *) NULL)
|
||||
goto no_memory_return;
|
||||
goto error_return;
|
||||
|
||||
map = new_map;
|
||||
}
|
||||
@@ -1716,10 +1796,10 @@ compute_and_write_armap (arch, elength)
|
||||
bfd_alloc (arch,
|
||||
sizeof (char *)));
|
||||
if (map[orl_count].name == NULL)
|
||||
goto no_memory_return;
|
||||
goto error_return;
|
||||
*(map[orl_count].name) = bfd_alloc (arch, namelen + 1);
|
||||
if (*(map[orl_count].name) == NULL)
|
||||
goto no_memory_return;
|
||||
goto error_return;
|
||||
strcpy (*(map[orl_count].name), syms[src_count]->name);
|
||||
(map[orl_count]).pos = (file_ptr) current;
|
||||
(map[orl_count]).namidx = stridx;
|
||||
@@ -1750,9 +1830,6 @@ compute_and_write_armap (arch, elength)
|
||||
|
||||
return ret;
|
||||
|
||||
no_memory_return:
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
|
||||
error_return:
|
||||
if (syms_max > 0)
|
||||
free (syms);
|
||||
@@ -1773,15 +1850,15 @@ bsd_write_armap (arch, elength, map, orl_count, stridx)
|
||||
int stridx;
|
||||
{
|
||||
int padit = stridx & 1;
|
||||
unsigned int ranlibsize = orl_count * sizeof (struct ranlib);
|
||||
unsigned int ranlibsize = orl_count * BSD_SYMDEF_SIZE;
|
||||
unsigned int stringsize = stridx + padit;
|
||||
/* Include 8 bytes to store ranlibsize and stringsize in output. */
|
||||
unsigned int mapsize = ranlibsize + stringsize + 8;
|
||||
file_ptr firstreal;
|
||||
bfd *current = arch->archive_head;
|
||||
bfd *last_elt = current; /* last element arch seen */
|
||||
int temp;
|
||||
int count;
|
||||
bfd_byte temp[4];
|
||||
unsigned int count;
|
||||
struct ar_hdr hdr;
|
||||
struct stat statbuf;
|
||||
unsigned int i;
|
||||
@@ -1796,8 +1873,8 @@ bsd_write_armap (arch, elength, map, orl_count, stridx)
|
||||
bfd_ardata (arch)->armap_datepos = (SARMAG
|
||||
+ offsetof (struct ar_hdr, ar_date[0]));
|
||||
sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp);
|
||||
sprintf (hdr.ar_uid, "%d", getuid ());
|
||||
sprintf (hdr.ar_gid, "%d", getgid ());
|
||||
sprintf (hdr.ar_uid, "%ld", (long) getuid ());
|
||||
sprintf (hdr.ar_gid, "%ld", (long) getgid ());
|
||||
sprintf (hdr.ar_size, "%-10d", (int) mapsize);
|
||||
strncpy (hdr.ar_fmag, ARFMAG, 2);
|
||||
for (i = 0; i < sizeof (struct ar_hdr); i++)
|
||||
@@ -1806,14 +1883,13 @@ bsd_write_armap (arch, elength, map, orl_count, stridx)
|
||||
if (bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
|
||||
!= sizeof (struct ar_hdr))
|
||||
return false;
|
||||
bfd_h_put_32 (arch, (bfd_vma) ranlibsize, (PTR) &temp);
|
||||
if (bfd_write (&temp, 1, sizeof (temp), arch) != sizeof (temp))
|
||||
bfd_h_put_32 (arch, (bfd_vma) ranlibsize, temp);
|
||||
if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
|
||||
return false;
|
||||
|
||||
for (count = 0; count < orl_count; count++)
|
||||
{
|
||||
struct symdef outs;
|
||||
struct symdef *outp = &outs;
|
||||
bfd_byte buf[BSD_SYMDEF_SIZE];
|
||||
|
||||
if (((bfd *) (map[count]).pos) != last_elt)
|
||||
{
|
||||
@@ -1827,15 +1903,15 @@ bsd_write_armap (arch, elength, map, orl_count, stridx)
|
||||
} /* if new archive element */
|
||||
|
||||
last_elt = current;
|
||||
bfd_h_put_32 (arch, ((map[count]).namidx), (PTR) &outs.s.string_offset);
|
||||
bfd_h_put_32 (arch, firstreal, (PTR) &outs.file_offset);
|
||||
if (bfd_write ((char *) outp, 1, sizeof (outs), arch) != sizeof (outs))
|
||||
bfd_h_put_32 (arch, map[count].namidx, buf);
|
||||
bfd_h_put_32 (arch, firstreal, buf + BSD_SYMDEF_OFFSET_SIZE);
|
||||
if (bfd_write (buf, BSD_SYMDEF_SIZE, 1, arch) != BSD_SYMDEF_SIZE)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* now write the strings themselves */
|
||||
bfd_h_put_32 (arch, stringsize, (PTR) &temp);
|
||||
if (bfd_write ((PTR) &temp, 1, sizeof (temp), arch) != sizeof (temp))
|
||||
bfd_h_put_32 (arch, stringsize, temp);
|
||||
if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
|
||||
return false;
|
||||
for (count = 0; count < orl_count; count++)
|
||||
{
|
||||
@@ -1862,13 +1938,13 @@ bsd_write_armap (arch, elength, map, orl_count, stridx)
|
||||
Return true if the timestamp was OK, or an unusual problem happened.
|
||||
Return false if we updated the timestamp. */
|
||||
|
||||
static boolean
|
||||
bsd_update_armap_timestamp (arch)
|
||||
boolean
|
||||
_bfd_archive_bsd_update_armap_timestamp (arch)
|
||||
bfd *arch;
|
||||
{
|
||||
struct stat archstat;
|
||||
struct ar_hdr hdr;
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/* Flush writes, get last-write timestamp from file, and compare it
|
||||
to the timestamp IN the file. */
|
||||
@@ -1892,6 +1968,8 @@ bsd_update_armap_timestamp (arch)
|
||||
(hdr.ar_date)[i] = ' ';
|
||||
|
||||
/* Write it into the file. */
|
||||
bfd_ardata (arch)->armap_datepos = (SARMAG
|
||||
+ offsetof (struct ar_hdr, ar_date[0]));
|
||||
if (bfd_seek (arch, bfd_ardata (arch)->armap_datepos, SEEK_SET) != 0
|
||||
|| (bfd_write (hdr.ar_date, sizeof (hdr.ar_date), 1, arch)
|
||||
!= sizeof (hdr.ar_date)))
|
||||
@@ -1933,7 +2011,7 @@ coff_write_armap (arch, elength, map, symbol_count, stridx)
|
||||
unsigned int mapsize = stringsize + ranlibsize;
|
||||
file_ptr archive_member_file_ptr;
|
||||
bfd *current = arch->archive_head;
|
||||
int count;
|
||||
unsigned int count;
|
||||
struct ar_hdr hdr;
|
||||
unsigned int i;
|
||||
int padit = mapsize & 1;
|
||||
@@ -0,0 +1,720 @@
|
||||
/* BFD library support routines for architectures.
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include <ctype.h>
|
||||
|
||||
/*
|
||||
|
||||
SECTION
|
||||
Architectures
|
||||
|
||||
BFD keeps one atom in a BFD describing the
|
||||
architecture of the data attached to the BFD: a pointer to a
|
||||
<<bfd_arch_info_type>>.
|
||||
|
||||
Pointers to structures can be requested independently of a BFD
|
||||
so that an architecture's information can be interrogated
|
||||
without access to an open BFD.
|
||||
|
||||
The architecture information is provided by each architecture package.
|
||||
The set of default architectures is selected by the macro
|
||||
<<SELECT_ARCHITECTURES>>. This is normally set up in the
|
||||
@file{config/@var{target}.mt} file of your choice. If the name is not
|
||||
defined, then all the architectures supported are included.
|
||||
|
||||
When BFD starts up, all the architectures are called with an
|
||||
initialize method. It is up to the architecture back end to
|
||||
insert as many items into the list of architectures as it wants to;
|
||||
generally this would be one for each machine and one for the
|
||||
default case (an item with a machine field of 0).
|
||||
|
||||
BFD's idea of an architecture is implemented in @file{archures.c}.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
SUBSECTION
|
||||
bfd_architecture
|
||||
|
||||
DESCRIPTION
|
||||
This enum gives the object file's CPU architecture, in a
|
||||
global sense---i.e., what processor family does it belong to?
|
||||
Another field indicates which processor within
|
||||
the family is in use. The machine gives a number which
|
||||
distinguishes different versions of the architecture,
|
||||
containing, for example, 2 and 3 for Intel i960 KA and i960 KB,
|
||||
and 68020 and 68030 for Motorola 68020 and 68030.
|
||||
|
||||
.enum bfd_architecture
|
||||
.{
|
||||
. bfd_arch_unknown, {* File arch not known *}
|
||||
. bfd_arch_obscure, {* Arch known, not one of these *}
|
||||
. bfd_arch_m68k, {* Motorola 68xxx *}
|
||||
. bfd_arch_vax, {* DEC Vax *}
|
||||
. bfd_arch_i960, {* Intel 960 *}
|
||||
. {* The order of the following is important.
|
||||
. lower number indicates a machine type that
|
||||
. only accepts a subset of the instructions
|
||||
. available to machines with higher numbers.
|
||||
. The exception is the "ca", which is
|
||||
. incompatible with all other machines except
|
||||
. "core". *}
|
||||
.
|
||||
.#define bfd_mach_i960_core 1
|
||||
.#define bfd_mach_i960_ka_sa 2
|
||||
.#define bfd_mach_i960_kb_sb 3
|
||||
.#define bfd_mach_i960_mc 4
|
||||
.#define bfd_mach_i960_xa 5
|
||||
.#define bfd_mach_i960_ca 6
|
||||
.#define bfd_mach_i960_jx 7
|
||||
.#define bfd_mach_i960_hx 8
|
||||
.
|
||||
. bfd_arch_a29k, {* AMD 29000 *}
|
||||
. bfd_arch_sparc, {* SPARC *}
|
||||
.#define bfd_mach_sparc 1
|
||||
.{* The difference between v8plus and v9 is that v9 is a true 64 bit env. *}
|
||||
.#define bfd_mach_sparc_v8plus 2
|
||||
.#define bfd_mach_sparc_v8plusa 3 {* with ultrasparc add'ns *}
|
||||
.#define bfd_mach_sparc_v9 4
|
||||
.#define bfd_mach_sparc_v9a 5 {* with ultrasparc add'ns *}
|
||||
.{* Nonzero if MACH has the v9 instruction set. *}
|
||||
.#define bfd_mach_sparc_v9_p(mach) ((mach) != bfd_mach_sparc)
|
||||
. bfd_arch_mips, {* MIPS Rxxxx *}
|
||||
. bfd_arch_i386, {* Intel 386 *}
|
||||
. bfd_arch_we32k, {* AT&T WE32xxx *}
|
||||
. bfd_arch_tahoe, {* CCI/Harris Tahoe *}
|
||||
. bfd_arch_i860, {* Intel 860 *}
|
||||
. bfd_arch_romp, {* IBM ROMP PC/RT *}
|
||||
. bfd_arch_alliant, {* Alliant *}
|
||||
. bfd_arch_convex, {* Convex *}
|
||||
. bfd_arch_m88k, {* Motorola 88xxx *}
|
||||
. bfd_arch_pyramid, {* Pyramid Technology *}
|
||||
. bfd_arch_h8300, {* Hitachi H8/300 *}
|
||||
.#define bfd_mach_h8300 1
|
||||
.#define bfd_mach_h8300h 2
|
||||
. bfd_arch_powerpc, {* PowerPC *}
|
||||
. bfd_arch_rs6000, {* IBM RS/6000 *}
|
||||
. bfd_arch_hppa, {* HP PA RISC *}
|
||||
. bfd_arch_z8k, {* Zilog Z8000 *}
|
||||
.#define bfd_mach_z8001 1
|
||||
.#define bfd_mach_z8002 2
|
||||
. bfd_arch_h8500, {* Hitachi H8/500 *}
|
||||
. bfd_arch_sh, {* Hitachi SH *}
|
||||
. bfd_arch_alpha, {* Dec Alpha *}
|
||||
. bfd_arch_arm, {* Advanced Risc Machines ARM *}
|
||||
. bfd_arch_ns32k, {* National Semiconductors ns32000 *}
|
||||
. bfd_arch_w65, {* WDC 65816 *}
|
||||
. bfd_arch_last
|
||||
. };
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
SUBSECTION
|
||||
bfd_arch_info
|
||||
|
||||
DESCRIPTION
|
||||
This structure contains information on architectures for use
|
||||
within BFD.
|
||||
|
||||
.
|
||||
.typedef struct bfd_arch_info
|
||||
.{
|
||||
. int bits_per_word;
|
||||
. int bits_per_address;
|
||||
. int bits_per_byte;
|
||||
. enum bfd_architecture arch;
|
||||
. unsigned long mach;
|
||||
. const char *arch_name;
|
||||
. const char *printable_name;
|
||||
. unsigned int section_align_power;
|
||||
. {* true if this is the default machine for the architecture *}
|
||||
. boolean the_default;
|
||||
. const struct bfd_arch_info * (*compatible)
|
||||
. PARAMS ((const struct bfd_arch_info *a,
|
||||
. const struct bfd_arch_info *b));
|
||||
.
|
||||
. boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *));
|
||||
.
|
||||
. const struct bfd_arch_info *next;
|
||||
.} bfd_arch_info_type;
|
||||
*/
|
||||
|
||||
extern const bfd_arch_info_type bfd_a29k_arch;
|
||||
extern const bfd_arch_info_type bfd_alpha_arch;
|
||||
extern const bfd_arch_info_type bfd_arm_arch;
|
||||
extern const bfd_arch_info_type bfd_h8300_arch;
|
||||
extern const bfd_arch_info_type bfd_h8500_arch;
|
||||
extern const bfd_arch_info_type bfd_hppa_arch;
|
||||
extern const bfd_arch_info_type bfd_i386_arch;
|
||||
extern const bfd_arch_info_type bfd_i860_arch;
|
||||
extern const bfd_arch_info_type bfd_i960_arch;
|
||||
extern const bfd_arch_info_type bfd_m68k_arch;
|
||||
extern const bfd_arch_info_type bfd_m88k_arch;
|
||||
extern const bfd_arch_info_type bfd_mips_arch;
|
||||
extern const bfd_arch_info_type bfd_powerpc_arch;
|
||||
extern const bfd_arch_info_type bfd_rs6000_arch;
|
||||
extern const bfd_arch_info_type bfd_sh_arch;
|
||||
extern const bfd_arch_info_type bfd_sparc_arch;
|
||||
extern const bfd_arch_info_type bfd_vax_arch;
|
||||
extern const bfd_arch_info_type bfd_we32k_arch;
|
||||
extern const bfd_arch_info_type bfd_z8k_arch;
|
||||
extern const bfd_arch_info_type bfd_ns32k_arch;
|
||||
extern const bfd_arch_info_type bfd_w65_arch;
|
||||
|
||||
static const bfd_arch_info_type * const bfd_archures_list[] =
|
||||
{
|
||||
#ifdef SELECT_ARCHITECTURES
|
||||
SELECT_ARCHITECTURES,
|
||||
#else
|
||||
&bfd_a29k_arch,
|
||||
&bfd_alpha_arch,
|
||||
&bfd_arm_arch,
|
||||
&bfd_h8300_arch,
|
||||
&bfd_h8500_arch,
|
||||
&bfd_hppa_arch,
|
||||
&bfd_i386_arch,
|
||||
&bfd_i860_arch,
|
||||
&bfd_i960_arch,
|
||||
&bfd_m68k_arch,
|
||||
&bfd_m88k_arch,
|
||||
&bfd_mips_arch,
|
||||
&bfd_powerpc_arch,
|
||||
&bfd_rs6000_arch,
|
||||
&bfd_sh_arch,
|
||||
&bfd_sparc_arch,
|
||||
&bfd_vax_arch,
|
||||
&bfd_we32k_arch,
|
||||
&bfd_z8k_arch,
|
||||
&bfd_ns32k_arch,
|
||||
&bfd_w65_arch,
|
||||
#endif
|
||||
0
|
||||
};
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_printable_name
|
||||
|
||||
SYNOPSIS
|
||||
const char *bfd_printable_name(bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return a printable string representing the architecture and machine
|
||||
from the pointer to the architecture info structure.
|
||||
|
||||
*/
|
||||
|
||||
const char *
|
||||
bfd_printable_name (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return abfd->arch_info->printable_name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_scan_arch
|
||||
|
||||
SYNOPSIS
|
||||
const bfd_arch_info_type *bfd_scan_arch(const char *string);
|
||||
|
||||
DESCRIPTION
|
||||
Figure out if BFD supports any cpu which could be described with
|
||||
the name @var{string}. Return a pointer to an <<arch_info>>
|
||||
structure if a machine is found, otherwise NULL.
|
||||
|
||||
*/
|
||||
|
||||
const bfd_arch_info_type *
|
||||
bfd_scan_arch (string)
|
||||
const char *string;
|
||||
{
|
||||
const bfd_arch_info_type * const *app, *ap;
|
||||
|
||||
/* Look through all the installed architectures */
|
||||
for (app = bfd_archures_list; *app != NULL; app++)
|
||||
{
|
||||
for (ap = *app; ap != NULL; ap = ap->next)
|
||||
{
|
||||
if (ap->scan (ap, string))
|
||||
return ap;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_arch_get_compatible
|
||||
|
||||
SYNOPSIS
|
||||
const bfd_arch_info_type *bfd_arch_get_compatible(
|
||||
const bfd *abfd,
|
||||
const bfd *bbfd);
|
||||
|
||||
DESCRIPTION
|
||||
Determine whether two BFDs'
|
||||
architectures and machine types are compatible. Calculates
|
||||
the lowest common denominator between the two architectures
|
||||
and machine types implied by the BFDs and returns a pointer to
|
||||
an <<arch_info>> structure describing the compatible machine.
|
||||
*/
|
||||
|
||||
const bfd_arch_info_type *
|
||||
bfd_arch_get_compatible (abfd, bbfd)
|
||||
const bfd *abfd;
|
||||
const bfd *bbfd;
|
||||
{
|
||||
/* If either architecture is unknown, then all we can do is assume
|
||||
the user knows what he's doing. */
|
||||
if (abfd->arch_info->arch == bfd_arch_unknown)
|
||||
return bbfd->arch_info;
|
||||
if (bbfd->arch_info->arch == bfd_arch_unknown)
|
||||
return abfd->arch_info;
|
||||
|
||||
/* Otherwise architecture-specific code has to decide. */
|
||||
return abfd->arch_info->compatible (abfd->arch_info, bbfd->arch_info);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
INTERNAL_DEFINITION
|
||||
bfd_default_arch_struct
|
||||
|
||||
DESCRIPTION
|
||||
The <<bfd_default_arch_struct>> is an item of
|
||||
<<bfd_arch_info_type>> which has been initialized to a fairly
|
||||
generic state. A BFD starts life by pointing to this
|
||||
structure, until the correct back end has determined the real
|
||||
architecture of the file.
|
||||
|
||||
.extern const bfd_arch_info_type bfd_default_arch_struct;
|
||||
|
||||
*/
|
||||
|
||||
const bfd_arch_info_type bfd_default_arch_struct =
|
||||
{
|
||||
32,32,8,bfd_arch_unknown,0,"unknown","unknown",2,true,
|
||||
bfd_default_compatible,
|
||||
bfd_default_scan,
|
||||
0,
|
||||
};
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_set_arch_info
|
||||
|
||||
SYNOPSIS
|
||||
void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg);
|
||||
|
||||
DESCRIPTION
|
||||
Set the architecture info of @var{abfd} to @var{arg}.
|
||||
*/
|
||||
|
||||
void
|
||||
bfd_set_arch_info (abfd, arg)
|
||||
bfd *abfd;
|
||||
const bfd_arch_info_type *arg;
|
||||
{
|
||||
abfd->arch_info = arg;
|
||||
}
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_default_set_arch_mach
|
||||
|
||||
SYNOPSIS
|
||||
boolean bfd_default_set_arch_mach(bfd *abfd,
|
||||
enum bfd_architecture arch,
|
||||
unsigned long mach);
|
||||
|
||||
DESCRIPTION
|
||||
Set the architecture and machine type in BFD @var{abfd}
|
||||
to @var{arch} and @var{mach}. Find the correct
|
||||
pointer to a structure and insert it into the <<arch_info>>
|
||||
pointer.
|
||||
*/
|
||||
|
||||
boolean
|
||||
bfd_default_set_arch_mach (abfd, arch, mach)
|
||||
bfd *abfd;
|
||||
enum bfd_architecture arch;
|
||||
unsigned long mach;
|
||||
{
|
||||
const bfd_arch_info_type * const *app, *ap;
|
||||
|
||||
for (app = bfd_archures_list; *app != NULL; app++)
|
||||
{
|
||||
for (ap = *app; ap != NULL; ap = ap->next)
|
||||
{
|
||||
if (ap->arch == arch
|
||||
&& (ap->mach == mach
|
||||
|| (mach == 0 && ap->the_default)))
|
||||
{
|
||||
abfd->arch_info = ap;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abfd->arch_info = &bfd_default_arch_struct;
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_get_arch
|
||||
|
||||
SYNOPSIS
|
||||
enum bfd_architecture bfd_get_arch(bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return the enumerated type which describes the BFD @var{abfd}'s
|
||||
architecture.
|
||||
|
||||
*/
|
||||
|
||||
enum bfd_architecture
|
||||
bfd_get_arch (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return abfd->arch_info->arch;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_get_mach
|
||||
|
||||
SYNOPSIS
|
||||
unsigned long bfd_get_mach(bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return the long type which describes the BFD @var{abfd}'s
|
||||
machine.
|
||||
*/
|
||||
|
||||
unsigned long
|
||||
bfd_get_mach (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return abfd->arch_info->mach;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_arch_bits_per_byte
|
||||
|
||||
SYNOPSIS
|
||||
unsigned int bfd_arch_bits_per_byte(bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return the number of bits in one of the BFD @var{abfd}'s
|
||||
architecture's bytes.
|
||||
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
bfd_arch_bits_per_byte (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return abfd->arch_info->bits_per_byte;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_arch_bits_per_address
|
||||
|
||||
SYNOPSIS
|
||||
unsigned int bfd_arch_bits_per_address(bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return the number of bits in one of the BFD @var{abfd}'s
|
||||
architecture's addresses.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
bfd_arch_bits_per_address (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return abfd->arch_info->bits_per_address;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_default_compatible
|
||||
|
||||
SYNOPSIS
|
||||
const bfd_arch_info_type *bfd_default_compatible
|
||||
(const bfd_arch_info_type *a,
|
||||
const bfd_arch_info_type *b);
|
||||
|
||||
DESCRIPTION
|
||||
The default function for testing for compatibility.
|
||||
*/
|
||||
|
||||
const bfd_arch_info_type *
|
||||
bfd_default_compatible (a,b)
|
||||
const bfd_arch_info_type *a;
|
||||
const bfd_arch_info_type *b;
|
||||
{
|
||||
if (a->arch != b->arch)
|
||||
return NULL;
|
||||
|
||||
if (a->mach > b->mach)
|
||||
return a;
|
||||
|
||||
if (b->mach > a->mach)
|
||||
return b;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_default_scan
|
||||
|
||||
SYNOPSIS
|
||||
boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string);
|
||||
|
||||
DESCRIPTION
|
||||
The default function for working out whether this is an
|
||||
architecture hit and a machine hit.
|
||||
*/
|
||||
|
||||
boolean
|
||||
bfd_default_scan (info, string)
|
||||
const struct bfd_arch_info *info;
|
||||
const char *string;
|
||||
{
|
||||
const char *ptr_src;
|
||||
const char *ptr_tst;
|
||||
unsigned long number;
|
||||
enum bfd_architecture arch;
|
||||
|
||||
/* First test for an exact match */
|
||||
if (strcmp (string, info->printable_name) == 0)
|
||||
return true;
|
||||
|
||||
/* See how much of the supplied string matches with the
|
||||
architecture, eg the string m68k:68020 would match the 68k entry
|
||||
up to the :, then we get left with the machine number */
|
||||
|
||||
for (ptr_src = string, ptr_tst = info->arch_name;
|
||||
*ptr_src && *ptr_tst;
|
||||
ptr_src++, ptr_tst++)
|
||||
{
|
||||
if (*ptr_src != *ptr_tst) break;
|
||||
}
|
||||
|
||||
/* Chewed up as much of the architecture as will match, skip any
|
||||
colons */
|
||||
if (*ptr_src == ':')
|
||||
ptr_src++;
|
||||
|
||||
if (*ptr_src == 0)
|
||||
{
|
||||
/* nothing more, then only keep this one if it is the default
|
||||
machine for this architecture */
|
||||
return info->the_default;
|
||||
}
|
||||
|
||||
number = 0;
|
||||
while (isdigit(*ptr_src))
|
||||
{
|
||||
number = number * 10 + *ptr_src - '0';
|
||||
ptr_src++;
|
||||
}
|
||||
|
||||
switch (number)
|
||||
{
|
||||
case 65:
|
||||
arch = bfd_arch_w65;
|
||||
break;
|
||||
|
||||
case 300:
|
||||
arch = bfd_arch_h8300;
|
||||
break;
|
||||
|
||||
case 500:
|
||||
arch = bfd_arch_h8500;
|
||||
break;
|
||||
|
||||
case 68010:
|
||||
case 68020:
|
||||
case 68030:
|
||||
case 68040:
|
||||
case 68332:
|
||||
case 68050:
|
||||
case 68000:
|
||||
arch = bfd_arch_m68k;
|
||||
break;
|
||||
|
||||
case 386:
|
||||
case 80386:
|
||||
case 486:
|
||||
case 80486:
|
||||
arch = bfd_arch_i386;
|
||||
break;
|
||||
|
||||
case 29000:
|
||||
arch = bfd_arch_a29k;
|
||||
break;
|
||||
|
||||
case 8000:
|
||||
arch = bfd_arch_z8k;
|
||||
break;
|
||||
|
||||
case 32000:
|
||||
arch = bfd_arch_we32k;
|
||||
break;
|
||||
|
||||
case 860:
|
||||
case 80860:
|
||||
arch = bfd_arch_i860;
|
||||
break;
|
||||
case 960:
|
||||
case 80960:
|
||||
arch = bfd_arch_i960;
|
||||
break;
|
||||
|
||||
case 2000:
|
||||
case 3000:
|
||||
case 4000:
|
||||
case 4400:
|
||||
arch = bfd_arch_mips;
|
||||
break;
|
||||
|
||||
case 6000:
|
||||
arch = bfd_arch_rs6000;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (arch != info->arch)
|
||||
return false;
|
||||
|
||||
if (number != info->mach)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_get_arch_info
|
||||
|
||||
SYNOPSIS
|
||||
const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);
|
||||
|
||||
DESCRIPTION
|
||||
Return the architecture info struct in @var{abfd}.
|
||||
*/
|
||||
|
||||
const bfd_arch_info_type *
|
||||
bfd_get_arch_info (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return abfd->arch_info;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_lookup_arch
|
||||
|
||||
SYNOPSIS
|
||||
const bfd_arch_info_type *bfd_lookup_arch
|
||||
(enum bfd_architecture
|
||||
arch,
|
||||
unsigned long machine);
|
||||
|
||||
DESCRIPTION
|
||||
Look for the architecure info structure which matches the
|
||||
arguments @var{arch} and @var{machine}. A machine of 0 matches the
|
||||
machine/architecture structure which marks itself as the
|
||||
default.
|
||||
*/
|
||||
|
||||
const bfd_arch_info_type *
|
||||
bfd_lookup_arch (arch, machine)
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
{
|
||||
const bfd_arch_info_type * const *app, *ap;
|
||||
|
||||
for (app = bfd_archures_list; *app != NULL; app++)
|
||||
{
|
||||
for (ap = *app; ap != NULL; ap = ap->next)
|
||||
{
|
||||
if (ap->arch == arch
|
||||
&& (ap->mach == machine
|
||||
|| (machine == 0 && ap->the_default)))
|
||||
return ap;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_printable_arch_mach
|
||||
|
||||
SYNOPSIS
|
||||
const char *bfd_printable_arch_mach
|
||||
(enum bfd_architecture arch, unsigned long machine);
|
||||
|
||||
DESCRIPTION
|
||||
Return a printable string representing the architecture and
|
||||
machine type.
|
||||
|
||||
This routine is depreciated.
|
||||
*/
|
||||
|
||||
const char *
|
||||
bfd_printable_arch_mach (arch, machine)
|
||||
enum bfd_architecture arch;
|
||||
unsigned long machine;
|
||||
{
|
||||
const bfd_arch_info_type *ap = bfd_lookup_arch (arch, machine);
|
||||
|
||||
if (ap)
|
||||
return ap->printable_name;
|
||||
return "UNKNOWN!";
|
||||
}
|
||||
@@ -0,0 +1,668 @@
|
||||
/* Main header file for the bfd library -- portable access to object files.
|
||||
Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
Contributed by Cygnus Support.
|
||||
|
||||
** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them;
|
||||
** instead, change bfd-in.h or the other BFD source files processed to
|
||||
** generate these files.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* bfd.h -- The only header file required by users of the bfd library
|
||||
|
||||
The bfd.h file is generated from bfd-in.h and various .c files; if you
|
||||
change it, your changes will probably be lost.
|
||||
|
||||
All the prototypes and definitions following the comment "THE FOLLOWING
|
||||
IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
|
||||
BFD. If you change it, someone oneday will extract it from the source
|
||||
again, and your changes will be lost. To save yourself from this bind,
|
||||
change the definitions in the source in the bfd directory. Type "make
|
||||
docs" and then "make headers" in that directory, and magically this file
|
||||
will change to reflect your changes.
|
||||
|
||||
If you don't have the tools to perform the extraction, then you are
|
||||
safe from someone on your system trampling over your header files.
|
||||
You should still maintain the equivalence between the source and this
|
||||
file though; every change you make to the .c file should be reflected
|
||||
here. */
|
||||
|
||||
#ifndef __BFD_H_SEEN__
|
||||
#define __BFD_H_SEEN__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "obstack.h"
|
||||
|
||||
/* These two lines get substitutions done by commands in Makefile.in. */
|
||||
#define BFD_VERSION "@VERSION@"
|
||||
#define BFD_ARCH_SIZE @WORDSIZE@
|
||||
#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
|
||||
|
||||
#if BFD_ARCH_SIZE >= 64
|
||||
#define BFD64
|
||||
#endif
|
||||
|
||||
#ifndef INLINE
|
||||
#if __GNUC__ >= 2
|
||||
#define INLINE __inline__
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* forward declaration */
|
||||
typedef struct _bfd bfd;
|
||||
|
||||
/* To squelch erroneous compiler warnings ("illegal pointer
|
||||
combination") from the SVR3 compiler, we would like to typedef
|
||||
boolean to int (it doesn't like functions which return boolean.
|
||||
Making sure they are never implicitly declared to return int
|
||||
doesn't seem to help). But this file is not configured based on
|
||||
the host. */
|
||||
/* General rules: functions which are boolean return true on success
|
||||
and false on failure (unless they're a predicate). -- bfd.doc */
|
||||
/* I'm sure this is going to break something and someone is going to
|
||||
force me to change it. */
|
||||
/* typedef enum boolean {false, true} boolean; */
|
||||
/* Yup, SVR4 has a "typedef enum boolean" in <sys/types.h> -fnf */
|
||||
/* It gets worse if the host also defines a true/false enum... -sts */
|
||||
/* And even worse if your compiler has built-in boolean types... -law */
|
||||
#if defined (__GNUG__) && (__GNUC_MINOR__ > 5)
|
||||
#define TRUE_FALSE_ALREADY_DEFINED
|
||||
#endif
|
||||
#ifdef MPW
|
||||
/* Pre-emptive strike - get the file with the enum. */
|
||||
#include <Types.h>
|
||||
#define TRUE_FALSE_ALREADY_DEFINED
|
||||
#endif /* MPW */
|
||||
#ifndef TRUE_FALSE_ALREADY_DEFINED
|
||||
typedef enum bfd_boolean {false, true} boolean;
|
||||
#define BFD_TRUE_FALSE
|
||||
#else
|
||||
/* Use enum names that will appear nowhere else. */
|
||||
typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
|
||||
#endif
|
||||
|
||||
/* A pointer to a position in a file. */
|
||||
/* FIXME: This should be using off_t from <sys/types.h>.
|
||||
For now, try to avoid breaking stuff by not including <sys/types.h> here.
|
||||
This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
|
||||
Probably the best long-term answer is to avoid using file_ptr AND off_t
|
||||
in this header file, and to handle this in the BFD implementation
|
||||
rather than in its interface. */
|
||||
/* typedef off_t file_ptr; */
|
||||
typedef long int file_ptr;
|
||||
|
||||
/* Support for different sizes of target format ints and addresses.
|
||||
If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
|
||||
set to 1 above. Otherwise, if gcc is being used, this code will
|
||||
use gcc's "long long" type. Otherwise, the compilation will fail
|
||||
if 64-bit targets are requested. */
|
||||
|
||||
#ifdef BFD64
|
||||
|
||||
#ifndef BFD_HOST_64_BIT
|
||||
#if BFD_HOST_64BIT_LONG
|
||||
#define BFD_HOST_64_BIT long
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#define BFD_HOST_64_BIT long long
|
||||
#endif /* defined (__GNUC__) */
|
||||
#endif /* ! BFD_HOST_64BIT_LONG */
|
||||
#endif /* ! defined (BFD_HOST_64_BIT) */
|
||||
|
||||
typedef unsigned BFD_HOST_64_BIT bfd_vma;
|
||||
typedef BFD_HOST_64_BIT bfd_signed_vma;
|
||||
typedef unsigned BFD_HOST_64_BIT bfd_size_type;
|
||||
typedef unsigned BFD_HOST_64_BIT symvalue;
|
||||
|
||||
#ifndef fprintf_vma
|
||||
#if BFD_HOST_64BIT_LONG
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
|
||||
#else
|
||||
#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
|
||||
#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
|
||||
#define fprintf_vma(s,x) \
|
||||
fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
|
||||
#define sprintf_vma(s,x) \
|
||||
sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else /* not BFD64 */
|
||||
|
||||
/* Represent a target address. Also used as a generic unsigned type
|
||||
which is guaranteed to be big enough to hold any arithmetic types
|
||||
we need to deal with. */
|
||||
typedef unsigned long bfd_vma;
|
||||
|
||||
/* A generic signed type which is guaranteed to be big enough to hold any
|
||||
arithmetic types we need to deal with. Can be assumed to be compatible
|
||||
with bfd_vma in the same way that signed and unsigned ints are compatible
|
||||
(as parameters, in assignment, etc). */
|
||||
typedef long bfd_signed_vma;
|
||||
|
||||
typedef unsigned long symvalue;
|
||||
typedef unsigned long bfd_size_type;
|
||||
|
||||
/* Print a bfd_vma x on stream s. */
|
||||
#define fprintf_vma(s,x) fprintf(s, "%08lx", x)
|
||||
#define sprintf_vma(s,x) sprintf(s, "%08lx", x)
|
||||
#endif /* not BFD64 */
|
||||
#define printf_vma(x) fprintf_vma(stdout,x)
|
||||
|
||||
typedef unsigned int flagword; /* 32 bits of flags */
|
||||
typedef unsigned char bfd_byte;
|
||||
|
||||
/** File formats */
|
||||
|
||||
typedef enum bfd_format {
|
||||
bfd_unknown = 0, /* file format is unknown */
|
||||
bfd_object, /* linker/assember/compiler output */
|
||||
bfd_archive, /* object archive file */
|
||||
bfd_core, /* core dump */
|
||||
bfd_type_end} /* marks the end; don't use it! */
|
||||
bfd_format;
|
||||
|
||||
/* Values that may appear in the flags field of a BFD. These also
|
||||
appear in the object_flags field of the bfd_target structure, where
|
||||
they indicate the set of flags used by that backend (not all flags
|
||||
are meaningful for all object file formats) (FIXME: at the moment,
|
||||
the object_flags values have mostly just been copied from backend
|
||||
to another, and are not necessarily correct). */
|
||||
|
||||
/* No flags. */
|
||||
#define NO_FLAGS 0x00
|
||||
|
||||
/* BFD contains relocation entries. */
|
||||
#define HAS_RELOC 0x01
|
||||
|
||||
/* BFD is directly executable. */
|
||||
#define EXEC_P 0x02
|
||||
|
||||
/* BFD has line number information (basically used for F_LNNO in a
|
||||
COFF header). */
|
||||
#define HAS_LINENO 0x04
|
||||
|
||||
/* BFD has debugging information. */
|
||||
#define HAS_DEBUG 0x08
|
||||
|
||||
/* BFD has symbols. */
|
||||
#define HAS_SYMS 0x10
|
||||
|
||||
/* BFD has local symbols (basically used for F_LSYMS in a COFF
|
||||
header). */
|
||||
#define HAS_LOCALS 0x20
|
||||
|
||||
/* BFD is a dynamic object. */
|
||||
#define DYNAMIC 0x40
|
||||
|
||||
/* Text section is write protected (if D_PAGED is not set, this is
|
||||
like an a.out NMAGIC file) (the linker sets this by default, but
|
||||
clears it for -r or -N). */
|
||||
#define WP_TEXT 0x80
|
||||
|
||||
/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
|
||||
linker sets this by default, but clears it for -r or -n or -N). */
|
||||
#define D_PAGED 0x100
|
||||
|
||||
/* BFD is relaxable (this means that bfd_relax_section may be able to
|
||||
do something) (sometimes bfd_relax_section can do something even if
|
||||
this is not set). */
|
||||
#define BFD_IS_RELAXABLE 0x200
|
||||
|
||||
/* This may be set before writing out a BFD to request using a
|
||||
traditional format. For example, this is used to request that when
|
||||
writing out an a.out object the symbols not be hashed to eliminate
|
||||
duplicates. */
|
||||
#define BFD_TRADITIONAL_FORMAT 0x400
|
||||
|
||||
/* This flag indicates that the BFD contents are actually cached in
|
||||
memory. If this is set, iostream points to a bfd_in_memory struct. */
|
||||
#define BFD_IN_MEMORY 0x800
|
||||
|
||||
/* symbols and relocation */
|
||||
|
||||
/* A count of carsyms (canonical archive symbols). */
|
||||
typedef unsigned long symindex;
|
||||
|
||||
/* How to perform a relocation. */
|
||||
typedef const struct reloc_howto_struct reloc_howto_type;
|
||||
|
||||
#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
|
||||
|
||||
/* General purpose part of a symbol X;
|
||||
target specific parts are in libcoff.h, libaout.h, etc. */
|
||||
|
||||
#define bfd_get_section(x) ((x)->section)
|
||||
#define bfd_get_output_section(x) ((x)->section->output_section)
|
||||
#define bfd_set_section(x,y) ((x)->section) = (y)
|
||||
#define bfd_asymbol_base(x) ((x)->section->vma)
|
||||
#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
|
||||
#define bfd_asymbol_name(x) ((x)->name)
|
||||
/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
|
||||
#define bfd_asymbol_bfd(x) ((x)->the_bfd)
|
||||
#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
|
||||
|
||||
/* A canonical archive symbol. */
|
||||
/* This is a type pun with struct ranlib on purpose! */
|
||||
typedef struct carsym {
|
||||
char *name;
|
||||
file_ptr file_offset; /* look here to find the file */
|
||||
} carsym; /* to make these you call a carsymogen */
|
||||
|
||||
|
||||
/* Used in generating armaps (archive tables of contents).
|
||||
Perhaps just a forward definition would do? */
|
||||
struct orl { /* output ranlib */
|
||||
char **name; /* symbol name */
|
||||
file_ptr pos; /* bfd* or file position */
|
||||
int namidx; /* index into string table */
|
||||
};
|
||||
|
||||
|
||||
/* Linenumber stuff */
|
||||
typedef struct lineno_cache_entry {
|
||||
unsigned int line_number; /* Linenumber from start of function*/
|
||||
union {
|
||||
struct symbol_cache_entry *sym; /* Function name */
|
||||
unsigned long offset; /* Offset into section */
|
||||
} u;
|
||||
} alent;
|
||||
|
||||
/* object and core file sections */
|
||||
|
||||
#define align_power(addr, align) \
|
||||
( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
|
||||
|
||||
typedef struct sec *sec_ptr;
|
||||
|
||||
#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
|
||||
#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
|
||||
#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
|
||||
#define bfd_section_name(bfd, ptr) ((ptr)->name)
|
||||
#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
|
||||
#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
|
||||
#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
|
||||
#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
|
||||
#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
|
||||
|
||||
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
|
||||
|
||||
#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
|
||||
#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
|
||||
#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
|
||||
|
||||
typedef struct stat stat_type;
|
||||
|
||||
typedef enum bfd_print_symbol
|
||||
{
|
||||
bfd_print_symbol_name,
|
||||
bfd_print_symbol_more,
|
||||
bfd_print_symbol_all
|
||||
} bfd_print_symbol_type;
|
||||
|
||||
/* Information about a symbol that nm needs. */
|
||||
|
||||
typedef struct _symbol_info
|
||||
{
|
||||
symvalue value;
|
||||
char type;
|
||||
CONST char *name; /* Symbol name. */
|
||||
unsigned char stab_type; /* Stab type. */
|
||||
char stab_other; /* Stab other. */
|
||||
short stab_desc; /* Stab desc. */
|
||||
CONST char *stab_name; /* String for stab type. */
|
||||
} symbol_info;
|
||||
|
||||
/* Get the name of a stabs type code. */
|
||||
|
||||
extern const char *bfd_get_stab_name PARAMS ((int));
|
||||
|
||||
/* Hash table routines. There is no way to free up a hash table. */
|
||||
|
||||
/* An element in the hash table. Most uses will actually use a larger
|
||||
structure, and an instance of this will be the first field. */
|
||||
|
||||
struct bfd_hash_entry
|
||||
{
|
||||
/* Next entry for this hash code. */
|
||||
struct bfd_hash_entry *next;
|
||||
/* String being hashed. */
|
||||
const char *string;
|
||||
/* Hash code. This is the full hash code, not the index into the
|
||||
table. */
|
||||
unsigned long hash;
|
||||
};
|
||||
|
||||
/* A hash table. */
|
||||
|
||||
struct bfd_hash_table
|
||||
{
|
||||
/* The hash array. */
|
||||
struct bfd_hash_entry **table;
|
||||
/* The number of slots in the hash table. */
|
||||
unsigned int size;
|
||||
/* A function used to create new elements in the hash table. The
|
||||
first entry is itself a pointer to an element. When this
|
||||
function is first invoked, this pointer will be NULL. However,
|
||||
having the pointer permits a hierarchy of method functions to be
|
||||
built each of which calls the function in the superclass. Thus
|
||||
each function should be written to allocate a new block of memory
|
||||
only if the argument is NULL. */
|
||||
struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
|
||||
struct bfd_hash_table *,
|
||||
const char *));
|
||||
/* An obstack for this hash table. */
|
||||
struct obstack memory;
|
||||
};
|
||||
|
||||
/* Initialize a hash table. */
|
||||
extern boolean bfd_hash_table_init
|
||||
PARAMS ((struct bfd_hash_table *,
|
||||
struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
|
||||
struct bfd_hash_table *,
|
||||
const char *)));
|
||||
|
||||
/* Initialize a hash table specifying a size. */
|
||||
extern boolean bfd_hash_table_init_n
|
||||
PARAMS ((struct bfd_hash_table *,
|
||||
struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
|
||||
struct bfd_hash_table *,
|
||||
const char *),
|
||||
unsigned int size));
|
||||
|
||||
/* Free up a hash table. */
|
||||
extern void bfd_hash_table_free PARAMS ((struct bfd_hash_table *));
|
||||
|
||||
/* Look up a string in a hash table. If CREATE is true, a new entry
|
||||
will be created for this string if one does not already exist. The
|
||||
COPY argument must be true if this routine should copy the string
|
||||
into newly allocated memory when adding an entry. */
|
||||
extern struct bfd_hash_entry *bfd_hash_lookup
|
||||
PARAMS ((struct bfd_hash_table *, const char *, boolean create,
|
||||
boolean copy));
|
||||
|
||||
/* Replace an entry in a hash table. */
|
||||
extern void bfd_hash_replace
|
||||
PARAMS ((struct bfd_hash_table *, struct bfd_hash_entry *old,
|
||||
struct bfd_hash_entry *nw));
|
||||
|
||||
/* Base method for creating a hash table entry. */
|
||||
extern struct bfd_hash_entry *bfd_hash_newfunc
|
||||
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
|
||||
const char *));
|
||||
|
||||
/* Grab some space for a hash table entry. */
|
||||
extern PTR bfd_hash_allocate PARAMS ((struct bfd_hash_table *,
|
||||
unsigned int));
|
||||
|
||||
/* Traverse a hash table in a random order, calling a function on each
|
||||
element. If the function returns false, the traversal stops. The
|
||||
INFO argument is passed to the function. */
|
||||
extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *,
|
||||
boolean (*) (struct bfd_hash_entry *,
|
||||
PTR),
|
||||
PTR info));
|
||||
|
||||
/* Semi-portable string concatenation in cpp.
|
||||
The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors.
|
||||
The problem is, "32_" is not a valid preprocessing token, and we don't
|
||||
want extra underscores (e.g., "nlm_32_"). The XCAT2 macro will cause the
|
||||
inner CAT macros to be evaluated first, producing still-valid pp-tokens.
|
||||
Then the final concatenation can be done. (Sigh.) */
|
||||
#ifndef CAT
|
||||
#ifdef SABER
|
||||
#define CAT(a,b) a##b
|
||||
#define CAT3(a,b,c) a##b##c
|
||||
#define CAT4(a,b,c,d) a##b##c##d
|
||||
#else
|
||||
#if defined(__STDC__) || defined(ALMOST_STDC)
|
||||
#define CAT(a,b) a##b
|
||||
#define CAT3(a,b,c) a##b##c
|
||||
#define XCAT2(a,b) CAT(a,b)
|
||||
#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d))
|
||||
#else
|
||||
#define CAT(a,b) a/**/b
|
||||
#define CAT3(a,b,c) a/**/b/**/c
|
||||
#define CAT4(a,b,c,d) a/**/b/**/c/**/d
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table
|
||||
|
||||
/* User program access to BFD facilities */
|
||||
|
||||
/* Direct I/O routines, for programs which know more about the object
|
||||
file than BFD does. Use higher level routines if possible. */
|
||||
|
||||
extern bfd_size_type bfd_read
|
||||
PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
|
||||
extern bfd_size_type bfd_write
|
||||
PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
|
||||
extern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction));
|
||||
extern long bfd_tell PARAMS ((bfd *abfd));
|
||||
extern int bfd_flush PARAMS ((bfd *abfd));
|
||||
extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
|
||||
|
||||
|
||||
/* Cast from const char * to char * so that caller can assign to
|
||||
a char * without a warning. */
|
||||
#define bfd_get_filename(abfd) ((char *) (abfd)->filename)
|
||||
#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
|
||||
#define bfd_get_format(abfd) ((abfd)->format)
|
||||
#define bfd_get_target(abfd) ((abfd)->xvec->name)
|
||||
#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
|
||||
#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
|
||||
#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
|
||||
#define bfd_header_big_endian(abfd) \
|
||||
((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
|
||||
#define bfd_header_little_endian(abfd) \
|
||||
((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
|
||||
#define bfd_get_file_flags(abfd) ((abfd)->flags)
|
||||
#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
|
||||
#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
|
||||
#define bfd_my_archive(abfd) ((abfd)->my_archive)
|
||||
#define bfd_has_map(abfd) ((abfd)->has_armap)
|
||||
|
||||
#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
|
||||
#define bfd_usrdata(abfd) ((abfd)->usrdata)
|
||||
|
||||
#define bfd_get_start_address(abfd) ((abfd)->start_address)
|
||||
#define bfd_get_symcount(abfd) ((abfd)->symcount)
|
||||
#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
|
||||
#define bfd_count_sections(abfd) ((abfd)->section_count)
|
||||
|
||||
#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
|
||||
|
||||
#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean)(bool)), true)
|
||||
|
||||
extern boolean bfd_record_phdr
|
||||
PARAMS ((bfd *, unsigned long, boolean, flagword, boolean, bfd_vma,
|
||||
boolean, boolean, unsigned int, struct sec **));
|
||||
|
||||
/* Byte swapping routines. */
|
||||
|
||||
bfd_vma bfd_getb64 PARAMS ((const unsigned char *));
|
||||
bfd_vma bfd_getl64 PARAMS ((const unsigned char *));
|
||||
bfd_signed_vma bfd_getb_signed_64 PARAMS ((const unsigned char *));
|
||||
bfd_signed_vma bfd_getl_signed_64 PARAMS ((const unsigned char *));
|
||||
bfd_vma bfd_getb32 PARAMS ((const unsigned char *));
|
||||
bfd_vma bfd_getl32 PARAMS ((const unsigned char *));
|
||||
bfd_signed_vma bfd_getb_signed_32 PARAMS ((const unsigned char *));
|
||||
bfd_signed_vma bfd_getl_signed_32 PARAMS ((const unsigned char *));
|
||||
bfd_vma bfd_getb16 PARAMS ((const unsigned char *));
|
||||
bfd_vma bfd_getl16 PARAMS ((const unsigned char *));
|
||||
bfd_signed_vma bfd_getb_signed_16 PARAMS ((const unsigned char *));
|
||||
bfd_signed_vma bfd_getl_signed_16 PARAMS ((const unsigned char *));
|
||||
void bfd_putb64 PARAMS ((bfd_vma, unsigned char *));
|
||||
void bfd_putl64 PARAMS ((bfd_vma, unsigned char *));
|
||||
void bfd_putb32 PARAMS ((bfd_vma, unsigned char *));
|
||||
void bfd_putl32 PARAMS ((bfd_vma, unsigned char *));
|
||||
void bfd_putb16 PARAMS ((bfd_vma, unsigned char *));
|
||||
void bfd_putl16 PARAMS ((bfd_vma, unsigned char *));
|
||||
|
||||
/* Externally visible ECOFF routines. */
|
||||
|
||||
#if defined(__STDC__) || defined(ALMOST_STDC)
|
||||
struct ecoff_debug_info;
|
||||
struct ecoff_debug_swap;
|
||||
struct ecoff_extr;
|
||||
struct symbol_cache_entry;
|
||||
struct bfd_link_info;
|
||||
struct bfd_link_hash_entry;
|
||||
#endif
|
||||
extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd));
|
||||
extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value));
|
||||
extern boolean bfd_ecoff_set_regmasks
|
||||
PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask,
|
||||
unsigned long *cprmask));
|
||||
extern PTR bfd_ecoff_debug_init
|
||||
PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug,
|
||||
const struct ecoff_debug_swap *output_swap,
|
||||
struct bfd_link_info *));
|
||||
extern void bfd_ecoff_debug_free
|
||||
PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
|
||||
const struct ecoff_debug_swap *output_swap,
|
||||
struct bfd_link_info *));
|
||||
extern boolean bfd_ecoff_debug_accumulate
|
||||
PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
|
||||
const struct ecoff_debug_swap *output_swap,
|
||||
bfd *input_bfd, struct ecoff_debug_info *input_debug,
|
||||
const struct ecoff_debug_swap *input_swap,
|
||||
struct bfd_link_info *));
|
||||
extern boolean bfd_ecoff_debug_accumulate_other
|
||||
PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
|
||||
const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
|
||||
struct bfd_link_info *));
|
||||
extern boolean bfd_ecoff_debug_externals
|
||||
PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap,
|
||||
boolean relocateable,
|
||||
boolean (*get_extr) (struct symbol_cache_entry *,
|
||||
struct ecoff_extr *),
|
||||
void (*set_index) (struct symbol_cache_entry *,
|
||||
bfd_size_type)));
|
||||
extern boolean bfd_ecoff_debug_one_external
|
||||
PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap,
|
||||
const char *name, struct ecoff_extr *esym));
|
||||
extern bfd_size_type bfd_ecoff_debug_size
|
||||
PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap));
|
||||
extern boolean bfd_ecoff_write_debug
|
||||
PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap, file_ptr where));
|
||||
extern boolean bfd_ecoff_write_accumulated_debug
|
||||
PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug,
|
||||
const struct ecoff_debug_swap *swap,
|
||||
struct bfd_link_info *info, file_ptr where));
|
||||
extern boolean bfd_mips_ecoff_create_embedded_relocs
|
||||
PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
|
||||
char **));
|
||||
|
||||
/* Externally visible ELF routines. */
|
||||
|
||||
struct bfd_link_needed_list
|
||||
{
|
||||
struct bfd_link_needed_list *next;
|
||||
bfd *by;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
extern boolean bfd_elf32_record_link_assignment
|
||||
PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
|
||||
extern boolean bfd_elf64_record_link_assignment
|
||||
PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
|
||||
extern struct bfd_link_needed_list *bfd_elf_get_needed_list
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean bfd_elf32_size_dynamic_sections
|
||||
PARAMS ((bfd *, const char *, const char *, boolean,
|
||||
struct bfd_link_info *, struct sec **));
|
||||
extern boolean bfd_elf64_size_dynamic_sections
|
||||
PARAMS ((bfd *, const char *, const char *, boolean,
|
||||
struct bfd_link_info *, struct sec **));
|
||||
extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *));
|
||||
extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *));
|
||||
|
||||
/* SunOS shared library support routines for the linker. */
|
||||
|
||||
extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean bfd_sunos_record_link_assignment
|
||||
PARAMS ((bfd *, struct bfd_link_info *, const char *));
|
||||
extern boolean bfd_sunos_size_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *, struct sec **, struct sec **,
|
||||
struct sec **));
|
||||
|
||||
/* Linux shared library support routines for the linker. */
|
||||
|
||||
extern boolean bfd_i386linux_size_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean bfd_m68klinux_size_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
|
||||
/* mmap hacks */
|
||||
|
||||
struct _bfd_window_internal;
|
||||
typedef struct _bfd_window_internal bfd_window_internal;
|
||||
|
||||
typedef struct _bfd_window {
|
||||
/* What the user asked for. */
|
||||
PTR data;
|
||||
bfd_size_type size;
|
||||
/* The actual window used by BFD. Small user-requested read-only
|
||||
regions sharing a page may share a single window into the object
|
||||
file. Read-write versions shouldn't until I've fixed things to
|
||||
keep track of which portions have been claimed by the
|
||||
application; don't want to give the same region back when the
|
||||
application wants two writable copies! */
|
||||
struct _bfd_window_internal *i;
|
||||
} bfd_window;
|
||||
|
||||
extern void bfd_init_window PARAMS ((bfd_window *));
|
||||
extern void bfd_free_window PARAMS ((bfd_window *));
|
||||
extern boolean bfd_get_file_window
|
||||
PARAMS ((bfd *, file_ptr, bfd_size_type, bfd_window *, boolean));
|
||||
|
||||
/* XCOFF support routines for the linker. */
|
||||
|
||||
extern boolean bfd_xcoff_link_record_set
|
||||
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
|
||||
bfd_size_type));
|
||||
extern boolean bfd_xcoff_import_symbol
|
||||
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
|
||||
bfd_vma, const char *, const char *, const char *));
|
||||
extern boolean bfd_xcoff_export_symbol
|
||||
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
|
||||
boolean));
|
||||
extern boolean bfd_xcoff_link_count_reloc
|
||||
PARAMS ((bfd *, struct bfd_link_info *, const char *));
|
||||
extern boolean bfd_xcoff_record_link_assignment
|
||||
PARAMS ((bfd *, struct bfd_link_info *, const char *));
|
||||
extern boolean bfd_xcoff_size_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
|
||||
unsigned long, unsigned long, unsigned long, boolean,
|
||||
int, boolean, boolean, struct sec **));
|
||||
|
||||
/* And more from the source. */
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,348 @@
|
||||
/* BFD back-end for binary objects.
|
||||
Copyright 1994 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This is a BFD backend which may be used to write binary objects.
|
||||
It may only be used for output, not input. The intention is that
|
||||
this may be used as an output format for objcopy in order to
|
||||
generate raw binary data.
|
||||
|
||||
This is very simple. The only complication is that the real data
|
||||
will start at some address X, and in some cases we will not want to
|
||||
include X zeroes just to get to that point. Since the start
|
||||
address is not meaningful for this object file format, we use it
|
||||
instead to indicate the number of zeroes to skip at the start of
|
||||
the file. objcopy cooperates by specially setting the start
|
||||
address to zero by default. */
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
/* Any bfd we create by reading a binary file has three symbols:
|
||||
a start symbol, an end symbol, and an absolute length symbol. */
|
||||
#define BIN_SYMS 3
|
||||
|
||||
static boolean binary_mkobject PARAMS ((bfd *));
|
||||
static const bfd_target *binary_object_p PARAMS ((bfd *));
|
||||
static boolean binary_get_section_contents
|
||||
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
|
||||
static long binary_get_symtab_upper_bound PARAMS ((bfd *));
|
||||
static char *mangle_name PARAMS ((bfd *, char *));
|
||||
static long binary_get_symtab PARAMS ((bfd *, asymbol **));
|
||||
static asymbol *binary_make_empty_symbol PARAMS ((bfd *));
|
||||
static void binary_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
|
||||
static boolean binary_set_section_contents
|
||||
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
|
||||
static int binary_sizeof_headers PARAMS ((bfd *, boolean));
|
||||
|
||||
/* Create a binary object. Invoked via bfd_set_format. */
|
||||
|
||||
static boolean
|
||||
binary_mkobject (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Any file may be considered to be a binary file, provided the target
|
||||
was not defaulted. That is, it must be explicitly specified as
|
||||
being binary. */
|
||||
|
||||
static const bfd_target *
|
||||
binary_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct stat statbuf;
|
||||
asection *sec;
|
||||
|
||||
if (abfd->target_defaulted)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
abfd->symcount = BIN_SYMS;
|
||||
|
||||
/* Find the file size. */
|
||||
if (bfd_stat (abfd, &statbuf) < 0)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* One data section. */
|
||||
sec = bfd_make_section (abfd, ".data");
|
||||
if (sec == NULL)
|
||||
return NULL;
|
||||
sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS;
|
||||
sec->vma = 0;
|
||||
sec->_raw_size = statbuf.st_size;
|
||||
sec->filepos = 0;
|
||||
|
||||
abfd->tdata.any = (PTR) sec;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
#define binary_close_and_cleanup _bfd_generic_close_and_cleanup
|
||||
#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
|
||||
#define binary_new_section_hook _bfd_generic_new_section_hook
|
||||
|
||||
/* Get contents of the only section. */
|
||||
|
||||
static boolean
|
||||
binary_get_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
PTR location;
|
||||
file_ptr offset;
|
||||
bfd_size_type count;
|
||||
{
|
||||
if (bfd_seek (abfd, offset, SEEK_SET) != 0
|
||||
|| bfd_read (location, 1, count, abfd) != count)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Return the amount of memory needed to read the symbol table. */
|
||||
|
||||
static long
|
||||
binary_get_symtab_upper_bound (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return (BIN_SYMS + 1) * sizeof (asymbol *);
|
||||
}
|
||||
|
||||
/* Create a symbol name based on the bfd's filename. */
|
||||
|
||||
static char *
|
||||
mangle_name (abfd, suffix)
|
||||
bfd *abfd;
|
||||
char *suffix;
|
||||
{
|
||||
int size;
|
||||
char *buf;
|
||||
char *p;
|
||||
|
||||
size = (strlen (bfd_get_filename (abfd))
|
||||
+ strlen (suffix)
|
||||
+ sizeof "_binary__");
|
||||
|
||||
buf = (char *) bfd_alloc (abfd, size);
|
||||
if (buf == NULL)
|
||||
return "";
|
||||
|
||||
sprintf (buf, "_binary_%s_%s", bfd_get_filename (abfd), suffix);
|
||||
|
||||
/* Change any non-alphanumeric characters to underscores. */
|
||||
for (p = buf; *p; p++)
|
||||
if (! isalnum (*p))
|
||||
*p = '_';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Return the symbol table. */
|
||||
|
||||
static long
|
||||
binary_get_symtab (abfd, alocation)
|
||||
bfd *abfd;
|
||||
asymbol **alocation;
|
||||
{
|
||||
asection *sec = (asection *) abfd->tdata.any;
|
||||
asymbol *syms;
|
||||
unsigned int i;
|
||||
|
||||
syms = (asymbol *) bfd_alloc (abfd, BIN_SYMS * sizeof (asymbol));
|
||||
if (syms == NULL)
|
||||
return false;
|
||||
|
||||
/* Start symbol. */
|
||||
syms[0].the_bfd = abfd;
|
||||
syms[0].name = mangle_name (abfd, "start");
|
||||
syms[0].value = 0;
|
||||
syms[0].flags = BSF_GLOBAL;
|
||||
syms[0].section = sec;
|
||||
syms[0].udata.p = NULL;
|
||||
|
||||
/* End symbol. */
|
||||
syms[1].the_bfd = abfd;
|
||||
syms[1].name = mangle_name (abfd, "end");
|
||||
syms[1].value = sec->_raw_size;
|
||||
syms[1].flags = BSF_GLOBAL;
|
||||
syms[1].section = sec;
|
||||
syms[1].udata.p = NULL;
|
||||
|
||||
/* Size symbol. */
|
||||
syms[2].the_bfd = abfd;
|
||||
syms[2].name = mangle_name (abfd, "size");
|
||||
syms[2].value = sec->_raw_size;
|
||||
syms[2].flags = BSF_GLOBAL;
|
||||
syms[2].section = bfd_abs_section_ptr;
|
||||
syms[2].udata.p = NULL;
|
||||
|
||||
for (i = 0; i < BIN_SYMS; i++)
|
||||
*alocation++ = syms++;
|
||||
*alocation = NULL;
|
||||
|
||||
return BIN_SYMS;
|
||||
}
|
||||
|
||||
/* Make an empty symbol. */
|
||||
|
||||
static asymbol *
|
||||
binary_make_empty_symbol (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
|
||||
}
|
||||
|
||||
#define binary_print_symbol _bfd_nosymbols_print_symbol
|
||||
|
||||
/* Get information about a symbol. */
|
||||
|
||||
static void
|
||||
binary_get_symbol_info (ignore_abfd, symbol, ret)
|
||||
bfd *ignore_abfd;
|
||||
asymbol *symbol;
|
||||
symbol_info *ret;
|
||||
{
|
||||
bfd_symbol_info (symbol, ret);
|
||||
}
|
||||
|
||||
#define binary_bfd_is_local_label bfd_generic_is_local_label
|
||||
#define binary_get_lineno _bfd_nosymbols_get_lineno
|
||||
#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
|
||||
#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
#define binary_read_minisymbols _bfd_generic_read_minisymbols
|
||||
#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
|
||||
|
||||
#define binary_get_reloc_upper_bound \
|
||||
((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
|
||||
#define binary_canonicalize_reloc \
|
||||
((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
|
||||
#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
|
||||
|
||||
/* Set the architecture of a binary file. */
|
||||
#define binary_set_arch_mach _bfd_generic_set_arch_mach
|
||||
|
||||
/* Write section contents of a binary file. */
|
||||
|
||||
static boolean
|
||||
binary_set_section_contents (abfd, sec, data, offset, size)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
PTR data;
|
||||
file_ptr offset;
|
||||
bfd_size_type size;
|
||||
{
|
||||
if (! abfd->output_has_begun)
|
||||
{
|
||||
bfd_vma low;
|
||||
asection *s;
|
||||
|
||||
/* The lowest section VMA sets the virtual address of the start
|
||||
of the file. We use the set the file position of all the
|
||||
sections. */
|
||||
low = abfd->sections->vma;
|
||||
for (s = abfd->sections->next; s != NULL; s = s->next)
|
||||
if (s->vma < low)
|
||||
low = s->vma;
|
||||
|
||||
for (s = abfd->sections; s != NULL; s = s->next)
|
||||
s->filepos = s->vma - low;
|
||||
|
||||
abfd->output_has_begun = true;
|
||||
}
|
||||
|
||||
return _bfd_generic_set_section_contents (abfd, sec, data, offset, size);
|
||||
}
|
||||
|
||||
/* No space is required for header information. */
|
||||
|
||||
static int
|
||||
binary_sizeof_headers (abfd, exec)
|
||||
bfd *abfd;
|
||||
boolean exec;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define binary_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
#define binary_bfd_relax_section bfd_generic_relax_section
|
||||
#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
||||
#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define binary_bfd_final_link _bfd_generic_final_link
|
||||
#define binary_bfd_link_split_section _bfd_generic_link_split_section
|
||||
#define binary_get_section_contents_in_window \
|
||||
_bfd_generic_get_section_contents_in_window
|
||||
|
||||
const bfd_target binary_vec =
|
||||
{
|
||||
"binary", /* name */
|
||||
bfd_target_unknown_flavour, /* flavour */
|
||||
BFD_ENDIAN_UNKNOWN, /* byteorder */
|
||||
BFD_ENDIAN_UNKNOWN, /* header_byteorder */
|
||||
EXEC_P, /* object_flags */
|
||||
(SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
|
||||
| SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
|
||||
0, /* symbol_leading_char */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target,
|
||||
binary_object_p, /* bfd_check_format */
|
||||
_bfd_dummy_target,
|
||||
_bfd_dummy_target,
|
||||
},
|
||||
{ /* bfd_set_format */
|
||||
bfd_false,
|
||||
binary_mkobject,
|
||||
bfd_false,
|
||||
bfd_false,
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false,
|
||||
bfd_true,
|
||||
bfd_false,
|
||||
bfd_false,
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (binary),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (binary),
|
||||
BFD_JUMP_TABLE_RELOCS (binary),
|
||||
BFD_JUMP_TABLE_WRITE (binary),
|
||||
BFD_JUMP_TABLE_LINK (binary),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
||||
/* BFD library -- caching of file descriptors.
|
||||
Copyright 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
|
||||
Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
@@ -16,7 +16,7 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/*
|
||||
SECTION
|
||||
@@ -31,7 +31,7 @@ SECTION
|
||||
<<bfd_cache_lookup>>, which runs around and makes sure that
|
||||
the required BFD is open. If not, then it chooses a file to
|
||||
close, closes it and opens the one wanted, returning its file
|
||||
handle.
|
||||
handle.
|
||||
|
||||
*/
|
||||
|
||||
@@ -78,19 +78,19 @@ bfd *bfd_last_cache;
|
||||
/*
|
||||
INTERNAL_FUNCTION
|
||||
bfd_cache_lookup
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
Check to see if the required BFD is the same as the last one
|
||||
looked up. If so, then it can use the stream in the BFD with
|
||||
impunity, since it can't have changed since the last lookup;
|
||||
otherwise, it has to perform the complicated lookup function.
|
||||
|
||||
|
||||
.#define bfd_cache_lookup(x) \
|
||||
. ((x)==bfd_last_cache? \
|
||||
. (FILE*)(bfd_last_cache->iostream): \
|
||||
. bfd_cache_lookup_worker(x))
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* Insert a BFD into the cache. */
|
||||
@@ -235,7 +235,8 @@ boolean
|
||||
bfd_cache_close (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
if (abfd->iostream == NULL)
|
||||
if (abfd->iostream == NULL
|
||||
|| (abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
return true;
|
||||
|
||||
return bfd_cache_delete (abfd);
|
||||
@@ -272,20 +273,20 @@ bfd_open_file (abfd)
|
||||
{
|
||||
case read_direction:
|
||||
case no_direction:
|
||||
abfd->iostream = (char *) fopen (abfd->filename, FOPEN_RB);
|
||||
abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RB);
|
||||
break;
|
||||
case both_direction:
|
||||
case write_direction:
|
||||
if (abfd->opened_once == true)
|
||||
{
|
||||
abfd->iostream = (char *) fopen (abfd->filename, FOPEN_RUB);
|
||||
abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_RUB);
|
||||
if (abfd->iostream == NULL)
|
||||
abfd->iostream = (char *) fopen (abfd->filename, FOPEN_WUB);
|
||||
abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WUB);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*open for creat */
|
||||
abfd->iostream = (char *) fopen (abfd->filename, FOPEN_WB);
|
||||
abfd->iostream = (PTR) fopen (abfd->filename, FOPEN_WB);
|
||||
abfd->opened_once = true;
|
||||
}
|
||||
break;
|
||||
@@ -312,14 +313,17 @@ DESCRIPTION
|
||||
quick answer. Find a file descriptor for @var{abfd}. If
|
||||
necessary, it open it. If there are already more than
|
||||
<<BFD_CACHE_MAX_OPEN>> files open, it tries to close one first, to
|
||||
avoid running out of file descriptors.
|
||||
avoid running out of file descriptors.
|
||||
*/
|
||||
|
||||
FILE *
|
||||
bfd_cache_lookup_worker (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
if (abfd->my_archive)
|
||||
if ((abfd->flags & BFD_IN_MEMORY) != 0)
|
||||
abort ();
|
||||
|
||||
if (abfd->my_archive)
|
||||
abfd = abfd->my_archive;
|
||||
|
||||
if (abfd->iostream != NULL)
|
||||
@@ -0,0 +1,31 @@
|
||||
/* BFD back-end for Intel 386 COFF LynxOS files.
|
||||
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
#define TARGET_SYM i386lynx_coff_vec
|
||||
#define TARGET_NAME "coff-i386-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#include "coff-i386.c"
|
||||
@@ -0,0 +1,223 @@
|
||||
/* BFD back-end for Motorola M68K COFF LynxOS files.
|
||||
Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68klynx_coff_vec
|
||||
#define TARGET_NAME "coff-m68k-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#define _bfd_m68kcoff_howto_table _bfd_m68klynx_howto_table
|
||||
#define _bfd_m68kcoff_rtype2howto _bfd_m68klynx_rtype2howto
|
||||
#define _bfd_m68kcoff_howto2rtype _bfd_m68klynx_howto2rtype
|
||||
#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68klynx_reloc_type_lookup
|
||||
|
||||
#define LYNX_SPECIAL_FN _bfd_m68klynx_special_fn
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
struct internal_reloc;
|
||||
struct coff_link_hash_entry;
|
||||
struct internal_syment;
|
||||
#endif
|
||||
|
||||
static bfd_reloc_status_type _bfd_m68klynx_special_fn
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_m68k_lynx_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
|
||||
/* For some reason when using m68k COFF the value stored in the .text
|
||||
section for a reference to a common symbol is the value itself plus
|
||||
any desired offset. (taken from work done by Ian Taylor, Cygnus Support,
|
||||
for I386 COFF). */
|
||||
|
||||
/* If we are producing relocateable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
_bfd_m68klynx_special_fn (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocateable output. This seems to be always wrong for 386
|
||||
COFF, so we handle the addend here instead. */
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||
the object file contains the value of the common symbol. By the
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && (reloc.r_type == R_PCRBYTE \
|
||||
|| reloc.r_type == R_PCRWORD \
|
||||
|| reloc.r_type == R_PCRLONG)) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto coff_m68k_lynx_rtype_to_howto
|
||||
|
||||
#include "coff-m68k.c"
|
||||
|
||||
/* coff-m68k.c uses the special COFF backend linker. We need to
|
||||
adjust common symbols.
|
||||
|
||||
We can't define this function until after we have included
|
||||
coff-m68k.c, because it uses RTYPE2HOWTO. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static reloc_howto_type *
|
||||
coff_m68k_lynx_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent relent;
|
||||
reloc_howto_type *howto;
|
||||
|
||||
RTYPE2HOWTO (&relent, rel);
|
||||
|
||||
howto = relent.howto;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
BFD_ASSERT (h != NULL);
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocateable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
|
||||
return howto;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/* BFD back-end for Sparc COFF LynxOS files.
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM sparclynx_coff_vec
|
||||
#define TARGET_NAME "coff-sparc-lynx"
|
||||
|
||||
#define LYNXOS
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#include "coff-sparc.c"
|
||||
@@ -0,0 +1,313 @@
|
||||
/* BFD back-end for CISCO crash dumps.
|
||||
|
||||
Copyright 1994 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
/* core_file_failing_signal returns a host signal (this probably should
|
||||
be fixed). */
|
||||
#include <signal.h>
|
||||
|
||||
#define CRASH_INFO (0xffc)
|
||||
#define CRASH_MAGIC 0xdead1234
|
||||
|
||||
typedef enum {
|
||||
CRASH_REASON_NOTCRASHED = 0,
|
||||
CRASH_REASON_EXCEPTION = 1,
|
||||
CRASH_REASON_CORRUPT = 2,
|
||||
} crashreason;
|
||||
|
||||
struct crashinfo_external
|
||||
{
|
||||
char magic[4]; /* Magic number */
|
||||
char version[4]; /* Version number */
|
||||
char reason[4]; /* Crash reason */
|
||||
char cpu_vector[4]; /* CPU vector for exceptions */
|
||||
char registers[4]; /* Pointer to saved registers */
|
||||
char rambase[4]; /* Base of RAM (not in V1 crash info) */
|
||||
};
|
||||
|
||||
struct cisco_core_struct
|
||||
{
|
||||
int sig;
|
||||
};
|
||||
|
||||
static const bfd_target *
|
||||
cisco_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
char buf[4];
|
||||
unsigned int crashinfo_offset;
|
||||
struct crashinfo_external crashinfo;
|
||||
int nread;
|
||||
unsigned int rambase;
|
||||
sec_ptr asect;
|
||||
struct stat statbuf;
|
||||
|
||||
if (bfd_seek (abfd, CRASH_INFO, SEEK_SET) != 0)
|
||||
return NULL;
|
||||
|
||||
nread = bfd_read (buf, 1, 4, abfd);
|
||||
if (nread != 4)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
crashinfo_offset = bfd_get_32 (abfd, buf);
|
||||
|
||||
if (bfd_seek (abfd, crashinfo_offset, SEEK_SET) != 0)
|
||||
return NULL;
|
||||
|
||||
nread = bfd_read (&crashinfo, 1, sizeof (crashinfo), abfd);
|
||||
if (nread != sizeof (crashinfo))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (bfd_stat (abfd, &statbuf) < 0)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (bfd_get_32 (abfd, crashinfo.magic) != CRASH_MAGIC)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (bfd_get_32 (abfd, crashinfo.version))
|
||||
{
|
||||
case 0:
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
case 1:
|
||||
rambase = 0;
|
||||
break;
|
||||
default:
|
||||
case 2:
|
||||
rambase = bfd_get_32 (abfd, crashinfo.rambase);
|
||||
break;
|
||||
}
|
||||
|
||||
/* OK, we believe you. You're a core file. */
|
||||
|
||||
abfd->tdata.cisco_core_data =
|
||||
((struct cisco_core_struct *)
|
||||
bfd_zmalloc (sizeof (struct cisco_core_struct)));
|
||||
if (abfd->tdata.cisco_core_data == NULL)
|
||||
return NULL;
|
||||
|
||||
switch ((crashreason) bfd_get_32 (abfd, crashinfo.reason))
|
||||
{
|
||||
case CRASH_REASON_NOTCRASHED:
|
||||
/* Crash file probably came from write core. */
|
||||
abfd->tdata.cisco_core_data->sig = 0;
|
||||
break;
|
||||
case CRASH_REASON_CORRUPT:
|
||||
/* The crash context area was corrupt -- proceed with caution.
|
||||
We have no way of passing this information back to the caller. */
|
||||
abfd->tdata.cisco_core_data->sig = 0;
|
||||
break;
|
||||
case CRASH_REASON_EXCEPTION:
|
||||
/* Crash occured due to CPU exception. */
|
||||
|
||||
/* This is 68k-specific; for MIPS we'll need to interpret
|
||||
cpu_vector differently based on the target configuration
|
||||
(since CISCO core files don't seem to have the processor
|
||||
encoded in them). */
|
||||
|
||||
switch (bfd_get_32 (abfd, crashinfo.cpu_vector))
|
||||
{
|
||||
/* bus error */
|
||||
case 2 : abfd->tdata.cisco_core_data->sig = SIGBUS; break;
|
||||
/* address error */
|
||||
case 3 : abfd->tdata.cisco_core_data->sig = SIGBUS; break;
|
||||
/* illegal instruction */
|
||||
case 4 : abfd->tdata.cisco_core_data->sig = SIGILL; break;
|
||||
/* zero divide */
|
||||
case 5 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* chk instruction */
|
||||
case 6 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* trapv instruction */
|
||||
case 7 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* privilege violation */
|
||||
case 8 : abfd->tdata.cisco_core_data->sig = SIGSEGV; break;
|
||||
/* trace trap */
|
||||
case 9 : abfd->tdata.cisco_core_data->sig = SIGTRAP; break;
|
||||
/* line 1010 emulator */
|
||||
case 10: abfd->tdata.cisco_core_data->sig = SIGILL; break;
|
||||
/* line 1111 emulator */
|
||||
case 11: abfd->tdata.cisco_core_data->sig = SIGILL; break;
|
||||
|
||||
/* Coprocessor protocol violation. Using a standard MMU or FPU
|
||||
this cannot be triggered by software. Call it a SIGBUS. */
|
||||
case 13: abfd->tdata.cisco_core_data->sig = SIGBUS; break;
|
||||
|
||||
/* interrupt */
|
||||
case 31: abfd->tdata.cisco_core_data->sig = SIGINT; break;
|
||||
/* breakpoint */
|
||||
case 33: abfd->tdata.cisco_core_data->sig = SIGTRAP; break;
|
||||
|
||||
/* floating point err */
|
||||
case 48: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* floating point err */
|
||||
case 49: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* zero divide */
|
||||
case 50: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* underflow */
|
||||
case 51: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* operand error */
|
||||
case 52: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* overflow */
|
||||
case 53: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
/* NAN */
|
||||
case 54: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
|
||||
default:
|
||||
/* "software generated"*/
|
||||
abfd->tdata.cisco_core_data->sig = SIGEMT;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* Unknown crash reason. */
|
||||
abfd->tdata.cisco_core_data->sig = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
abfd->sections = NULL;
|
||||
abfd->section_count = 0;
|
||||
|
||||
asect = (asection *) bfd_zmalloc (sizeof (asection));
|
||||
if (asect == NULL)
|
||||
goto error_return;
|
||||
asect->name = ".reg";
|
||||
asect->flags = SEC_HAS_CONTENTS;
|
||||
/* This can be bigger than the real size. Set it to the size of the whole
|
||||
core file. */
|
||||
asect->_raw_size = statbuf.st_size;
|
||||
asect->vma = 0;
|
||||
asect->filepos = bfd_get_32 (abfd, crashinfo.registers) - rambase;
|
||||
asect->next = abfd->sections;
|
||||
abfd->sections = asect;
|
||||
++abfd->section_count;
|
||||
|
||||
/* There is only one section containing data from the target system's RAM.
|
||||
We call it .data. */
|
||||
asect = (asection *) bfd_zmalloc (sizeof (asection));
|
||||
if (asect == NULL)
|
||||
goto error_return;
|
||||
asect->name = ".data";
|
||||
asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
/* The size of memory is the size of the core file itself. */
|
||||
asect->_raw_size = statbuf.st_size;
|
||||
asect->vma = rambase;
|
||||
asect->filepos = 0;
|
||||
asect->next = abfd->sections;
|
||||
abfd->sections = asect;
|
||||
++abfd->section_count;
|
||||
|
||||
return abfd->xvec;
|
||||
|
||||
error_return:
|
||||
{
|
||||
sec_ptr nextsect;
|
||||
for (asect = abfd->sections; asect != NULL;)
|
||||
{
|
||||
nextsect = asect->next;
|
||||
free (asect);
|
||||
asect = nextsect;
|
||||
}
|
||||
free (abfd->tdata.cisco_core_data);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
cisco_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
cisco_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return abfd->tdata.cisco_core_data->sig;
|
||||
}
|
||||
|
||||
boolean
|
||||
cisco_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const bfd_target cisco_core_vec =
|
||||
{
|
||||
"trad-core",
|
||||
bfd_target_unknown_flavour,
|
||||
BFD_ENDIAN_BIG, /* target byte order */
|
||||
BFD_ENDIAN_BIG, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* symbol prefix */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target, /* unknown format */
|
||||
_bfd_dummy_target, /* object file */
|
||||
_bfd_dummy_target, /* archive */
|
||||
cisco_core_file_p /* a core file */
|
||||
},
|
||||
{ /* bfd_set_format */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
{ /* bfd_write_contents */
|
||||
bfd_false, bfd_false,
|
||||
bfd_false, bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (cisco),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0 /* backend_data */
|
||||
};
|
||||
@@ -0,0 +1,641 @@
|
||||
/* BFD back-end for AMD 29000 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Contributed by David Wood at New York University 7/8/91.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define A29K 1
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/a29k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static long get_symbol_value PARAMS ((asymbol *));
|
||||
static bfd_reloc_status_type a29k_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static boolean coff_a29k_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static boolean coff_a29k_adjust_symndx
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||
struct internal_reloc *, boolean *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
|
||||
#define INSERT_HWORD(WORD,HWORD) \
|
||||
(((WORD) & 0xff00ff00) | (((HWORD) & 0xff00) << 8) | ((HWORD)& 0xff))
|
||||
#define EXTRACT_HWORD(WORD) \
|
||||
((((WORD) & 0x00ff0000) >> 8) | ((WORD)& 0xff))
|
||||
#define SIGN_EXTEND_HWORD(HWORD) \
|
||||
((HWORD) & 0x8000 ? (HWORD)|(~0xffffL) : (HWORD))
|
||||
|
||||
/* Provided the symbol, returns the value reffed */
|
||||
static long
|
||||
get_symbol_value (symbol)
|
||||
asymbol *symbol;
|
||||
{
|
||||
long relocation = 0;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
relocation = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
relocation = symbol->value +
|
||||
symbol->section->output_section->vma +
|
||||
symbol->section->output_offset;
|
||||
}
|
||||
|
||||
return(relocation);
|
||||
}
|
||||
|
||||
/* this function is in charge of performing all the 29k relocations */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
a29k_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol_in;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
/* the consth relocation comes in two parts, we have to remember
|
||||
the state between calls, in these variables */
|
||||
static boolean part1_consth_active = false;
|
||||
static unsigned long part1_consth_value;
|
||||
|
||||
unsigned long insn;
|
||||
unsigned long sym_value;
|
||||
unsigned long unsigned_value;
|
||||
unsigned short r_type;
|
||||
long signed_value;
|
||||
|
||||
unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
|
||||
bfd_byte *hit_data =addr + (bfd_byte *)(data);
|
||||
|
||||
r_type = reloc_entry->howto->type;
|
||||
|
||||
if (output_bfd) {
|
||||
/* Partial linking - do nothing */
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
|
||||
}
|
||||
|
||||
if (symbol_in != NULL
|
||||
&& bfd_is_und_section (symbol_in->section))
|
||||
{
|
||||
/* Keep the state machine happy in case we're called again */
|
||||
if (r_type == R_IHIHALF)
|
||||
{
|
||||
part1_consth_active = true;
|
||||
part1_consth_value = 0;
|
||||
}
|
||||
return(bfd_reloc_undefined);
|
||||
}
|
||||
|
||||
if ((part1_consth_active) && (r_type != R_IHCONST))
|
||||
{
|
||||
part1_consth_active = false;
|
||||
*error_message = (char *) "Missing IHCONST";
|
||||
return(bfd_reloc_dangerous);
|
||||
}
|
||||
|
||||
|
||||
sym_value = get_symbol_value(symbol_in);
|
||||
|
||||
switch (r_type)
|
||||
{
|
||||
case R_IREL:
|
||||
insn = bfd_get_32(abfd, hit_data);
|
||||
/* Take the value in the field and sign extend it */
|
||||
signed_value = EXTRACT_HWORD(insn);
|
||||
signed_value = SIGN_EXTEND_HWORD(signed_value);
|
||||
signed_value <<= 2;
|
||||
|
||||
/* See the note on the R_IREL reloc in coff_a29k_relocate_section. */
|
||||
if (signed_value == - (long) reloc_entry->address)
|
||||
signed_value = 0;
|
||||
|
||||
signed_value += sym_value + reloc_entry->addend;
|
||||
if ((signed_value & ~0x3ffff) == 0)
|
||||
{ /* Absolute jmp/call */
|
||||
insn |= (1<<24); /* Make it absolute */
|
||||
/* FIXME: Should we change r_type to R_IABS */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Relative jmp/call, so subtract from the value the
|
||||
address of the place we're coming from */
|
||||
signed_value -= (reloc_entry->address
|
||||
+ input_section->output_section->vma
|
||||
+ input_section->output_offset);
|
||||
if (signed_value>0x1ffff || signed_value<-0x20000)
|
||||
return(bfd_reloc_overflow);
|
||||
}
|
||||
signed_value >>= 2;
|
||||
insn = INSERT_HWORD(insn, signed_value);
|
||||
bfd_put_32(abfd, insn ,hit_data);
|
||||
break;
|
||||
case R_ILOHALF:
|
||||
insn = bfd_get_32(abfd, hit_data);
|
||||
unsigned_value = EXTRACT_HWORD(insn);
|
||||
unsigned_value += sym_value + reloc_entry->addend;
|
||||
insn = INSERT_HWORD(insn, unsigned_value);
|
||||
bfd_put_32(abfd, insn, hit_data);
|
||||
break;
|
||||
case R_IHIHALF:
|
||||
insn = bfd_get_32(abfd, hit_data);
|
||||
/* consth, part 1
|
||||
Just get the symbol value that is referenced */
|
||||
part1_consth_active = true;
|
||||
part1_consth_value = sym_value + reloc_entry->addend;
|
||||
/* Don't modify insn until R_IHCONST */
|
||||
break;
|
||||
case R_IHCONST:
|
||||
insn = bfd_get_32(abfd, hit_data);
|
||||
/* consth, part 2
|
||||
Now relocate the reference */
|
||||
if (part1_consth_active == false) {
|
||||
*error_message = (char *) "Missing IHIHALF";
|
||||
return(bfd_reloc_dangerous);
|
||||
}
|
||||
/* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */
|
||||
unsigned_value = 0; /*EXTRACT_HWORD(insn) << 16;*/
|
||||
unsigned_value += reloc_entry->addend; /* r_symndx */
|
||||
unsigned_value += part1_consth_value;
|
||||
unsigned_value = unsigned_value >> 16;
|
||||
insn = INSERT_HWORD(insn, unsigned_value);
|
||||
part1_consth_active = false;
|
||||
bfd_put_32(abfd, insn, hit_data);
|
||||
break;
|
||||
case R_BYTE:
|
||||
insn = bfd_get_8(abfd, hit_data);
|
||||
unsigned_value = insn + sym_value + reloc_entry->addend;
|
||||
if (unsigned_value & 0xffffff00)
|
||||
return(bfd_reloc_overflow);
|
||||
bfd_put_8(abfd, unsigned_value, hit_data);
|
||||
break;
|
||||
case R_HWORD:
|
||||
insn = bfd_get_16(abfd, hit_data);
|
||||
unsigned_value = insn + sym_value + reloc_entry->addend;
|
||||
if (unsigned_value & 0xffff0000)
|
||||
return(bfd_reloc_overflow);
|
||||
bfd_put_16(abfd, insn, hit_data);
|
||||
break;
|
||||
case R_WORD:
|
||||
insn = bfd_get_32(abfd, hit_data);
|
||||
insn += sym_value + reloc_entry->addend;
|
||||
bfd_put_32(abfd, insn, hit_data);
|
||||
break;
|
||||
default:
|
||||
*error_message = "Unrecognized reloc";
|
||||
return (bfd_reloc_dangerous);
|
||||
}
|
||||
|
||||
|
||||
return(bfd_reloc_ok);
|
||||
}
|
||||
|
||||
/* type rightshift
|
||||
size
|
||||
bitsize
|
||||
pc-relative
|
||||
bitpos
|
||||
absolute
|
||||
complain_on_overflow
|
||||
special_function
|
||||
relocation name
|
||||
partial_inplace
|
||||
src_mask
|
||||
*/
|
||||
|
||||
/*FIXME: I'm not real sure about this table */
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
{R_ABS, 0, 3, 32, false, 0, complain_overflow_bitfield,a29k_reloc,"ABS", true, 0xffffffff,0xffffffff, false},
|
||||
{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10},
|
||||
{11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20},
|
||||
{21}, {22}, {23},
|
||||
{R_IREL, 0, 3, 32, true, 0, complain_overflow_signed,a29k_reloc,"IREL", true, 0xffffffff,0xffffffff, false},
|
||||
{R_IABS, 0, 3, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"IABS", true, 0xffffffff,0xffffffff, false},
|
||||
{R_ILOHALF, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"ILOHALF", true, 0x0000ffff,0x0000ffff, false},
|
||||
{R_IHIHALF, 0, 3, 16, true, 16, complain_overflow_signed, a29k_reloc,"IHIHALF", true, 0xffff0000,0xffff0000, false},
|
||||
{R_IHCONST, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"IHCONST", true, 0xffff0000,0xffff0000, false},
|
||||
{R_BYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, a29k_reloc,"BYTE", true, 0x000000ff,0x000000ff, false},
|
||||
{R_HWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, a29k_reloc,"HWORD", true, 0x0000ffff,0x0000ffff, false},
|
||||
{R_WORD, 0, 2, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"WORD", true, 0xffffffff,0xffffffff, false},
|
||||
};
|
||||
|
||||
#define BADMAG(x) A29KBADMAG(x)
|
||||
|
||||
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (relent,reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
static bfd_vma ihihalf_vaddr = (bfd_vma) -1;
|
||||
|
||||
relent->address = reloc->r_vaddr;
|
||||
relent->howto = howto_table + reloc->r_type;
|
||||
if (reloc->r_type == R_IHCONST)
|
||||
{
|
||||
/* The address of an R_IHCONST should always be the address of
|
||||
the immediately preceding R_IHIHALF. relocs generated by gas
|
||||
are correct, but relocs generated by High C are different (I
|
||||
can't figure out what the address means for High C). We can
|
||||
handle both gas and High C by ignoring the address here, and
|
||||
simply reusing the address saved for R_IHIHALF. */
|
||||
if (ihihalf_vaddr == (bfd_vma) -1)
|
||||
abort ();
|
||||
relent->address = ihihalf_vaddr;
|
||||
ihihalf_vaddr = (bfd_vma) -1;
|
||||
relent->addend = reloc->r_symndx;
|
||||
relent->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
asymbol *ptr;
|
||||
relent->sym_ptr_ptr = symbols + obj_convert(abfd)[reloc->r_symndx];
|
||||
|
||||
ptr = *(relent->sym_ptr_ptr);
|
||||
|
||||
if (ptr
|
||||
&& bfd_asymbol_bfd(ptr) == abfd
|
||||
|
||||
&& ((ptr->flags & BSF_OLD_COMMON)== 0))
|
||||
{
|
||||
relent->addend = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->addend = 0;
|
||||
}
|
||||
relent->address-= section->vma;
|
||||
if (reloc->r_type == R_IHIHALF)
|
||||
ihihalf_vaddr = relent->address;
|
||||
else if (ihihalf_vaddr != (bfd_vma) -1)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* The reloc processing routine for the optimized COFF linker. */
|
||||
|
||||
static boolean
|
||||
coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, syms, sections)
|
||||
bfd *output_bfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
struct internal_reloc *relocs;
|
||||
struct internal_syment *syms;
|
||||
asection **sections;
|
||||
{
|
||||
struct internal_reloc *rel;
|
||||
struct internal_reloc *relend;
|
||||
boolean hihalf;
|
||||
bfd_vma hihalf_val;
|
||||
|
||||
/* If we are performing a relocateable link, we don't need to do a
|
||||
thing. The caller will take care of adjusting the reloc
|
||||
addresses and symbol indices. */
|
||||
if (info->relocateable)
|
||||
return true;
|
||||
|
||||
hihalf = false;
|
||||
hihalf_val = 0;
|
||||
|
||||
rel = relocs;
|
||||
relend = rel + input_section->reloc_count;
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
long symndx;
|
||||
bfd_byte *loc;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
asection *sec;
|
||||
bfd_vma val;
|
||||
boolean overflow;
|
||||
unsigned long insn;
|
||||
long signed_value;
|
||||
unsigned long unsigned_value;
|
||||
bfd_reloc_status_type rstat;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
loc = contents + rel->r_vaddr - input_section->vma;
|
||||
|
||||
if (symndx == -1)
|
||||
h = NULL;
|
||||
else
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
|
||||
sym = NULL;
|
||||
sec = NULL;
|
||||
val = 0;
|
||||
|
||||
/* An R_IHCONST reloc does not have a symbol. Instead, the
|
||||
symbol index is an addend. R_IHCONST is always used in
|
||||
conjunction with R_IHHALF. */
|
||||
if (rel->r_type != R_IHCONST)
|
||||
{
|
||||
if (h == NULL)
|
||||
{
|
||||
if (symndx == -1)
|
||||
sec = bfd_abs_section_ptr;
|
||||
else
|
||||
{
|
||||
sym = syms + symndx;
|
||||
sec = sections[symndx];
|
||||
val = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->n_value
|
||||
- sec->vma);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
sec = h->root.u.def.section;
|
||||
val = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (hihalf)
|
||||
{
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info, "missing IHCONST reloc", input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
hihalf = false;
|
||||
}
|
||||
}
|
||||
|
||||
overflow = false;
|
||||
|
||||
switch (rel->r_type)
|
||||
{
|
||||
default:
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return false;
|
||||
|
||||
case R_IREL:
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
|
||||
/* Extract the addend. */
|
||||
signed_value = EXTRACT_HWORD (insn);
|
||||
signed_value = SIGN_EXTEND_HWORD (signed_value);
|
||||
signed_value <<= 2;
|
||||
|
||||
/* Unfortunately, there are two different versions of COFF
|
||||
a29k. In the original AMD version, the value stored in
|
||||
the field for the R_IREL reloc is a simple addend. In
|
||||
the GNU version, the value is the negative of the address
|
||||
of the reloc within section. We try to cope here by
|
||||
assuming the AMD version, unless the addend is exactly
|
||||
the negative of the address; in the latter case we assume
|
||||
the GNU version. This means that something like
|
||||
.text
|
||||
nop
|
||||
jmp i-4
|
||||
will fail, because the addend of -4 will happen to equal
|
||||
the negative of the address within the section. The
|
||||
compiler will never generate code like this.
|
||||
|
||||
At some point in the future we may want to take out this
|
||||
check. */
|
||||
|
||||
if (signed_value == - (long) (rel->r_vaddr - input_section->vma))
|
||||
signed_value = 0;
|
||||
|
||||
/* Determine the destination of the jump. */
|
||||
signed_value += val;
|
||||
|
||||
if ((signed_value & ~0x3ffff) == 0)
|
||||
{
|
||||
/* We can use an absolute jump. */
|
||||
insn |= (1 << 24);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make the destination PC relative. */
|
||||
signed_value -= (input_section->output_section->vma
|
||||
+ input_section->output_offset
|
||||
+ (rel->r_vaddr - input_section->vma));
|
||||
if (signed_value > 0x1ffff || signed_value < - 0x20000)
|
||||
{
|
||||
overflow = true;
|
||||
signed_value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Put the adjusted value back into the instruction. */
|
||||
signed_value >>= 2;
|
||||
insn = INSERT_HWORD (insn, signed_value);
|
||||
|
||||
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||
|
||||
break;
|
||||
|
||||
case R_ILOHALF:
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
unsigned_value = EXTRACT_HWORD (insn);
|
||||
unsigned_value += val;
|
||||
insn = INSERT_HWORD (insn, unsigned_value);
|
||||
bfd_put_32 (input_bfd, insn, loc);
|
||||
break;
|
||||
|
||||
case R_IHIHALF:
|
||||
/* Save the value for the R_IHCONST reloc. */
|
||||
hihalf = true;
|
||||
hihalf_val = val;
|
||||
break;
|
||||
|
||||
case R_IHCONST:
|
||||
if (! hihalf)
|
||||
{
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info, "missing IHIHALF reloc", input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
hihalf_val = 0;
|
||||
}
|
||||
|
||||
insn = bfd_get_32 (input_bfd, loc);
|
||||
unsigned_value = rel->r_symndx + hihalf_val;
|
||||
unsigned_value >>= 16;
|
||||
insn = INSERT_HWORD (insn, unsigned_value);
|
||||
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
|
||||
|
||||
hihalf = false;
|
||||
|
||||
break;
|
||||
|
||||
case R_BYTE:
|
||||
case R_HWORD:
|
||||
case R_WORD:
|
||||
rstat = _bfd_relocate_contents (howto_table + rel->r_type,
|
||||
input_bfd, val, loc);
|
||||
if (rstat == bfd_reloc_overflow)
|
||||
overflow = true;
|
||||
else if (rstat != bfd_reloc_ok)
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
const char *name;
|
||||
char buf[SYMNMLEN + 1];
|
||||
|
||||
if (symndx == -1)
|
||||
name = "*ABS*";
|
||||
else if (h != NULL)
|
||||
name = h->root.root.string;
|
||||
else if (sym == NULL)
|
||||
name = "*unknown*";
|
||||
else if (sym->_n._n_n._n_zeroes == 0
|
||||
&& sym->_n._n_n._n_offset != 0)
|
||||
name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
|
||||
else
|
||||
{
|
||||
strncpy (buf, sym->_n._n_name, SYMNMLEN);
|
||||
buf[SYMNMLEN] = '\0';
|
||||
name = buf;
|
||||
}
|
||||
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, name, howto_table[rel->r_type].name, (bfd_vma) 0,
|
||||
input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define coff_relocate_section coff_a29k_relocate_section
|
||||
|
||||
/* We don't want to change the symndx of a R_IHCONST reloc, since it
|
||||
is actually an addend, not a symbol index at all. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static boolean
|
||||
coff_a29k_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||
bfd *obfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *ibfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *irel;
|
||||
boolean *adjustedp;
|
||||
{
|
||||
if (irel->r_type == R_IHCONST)
|
||||
*adjustedp = true;
|
||||
else
|
||||
*adjustedp = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#define coff_adjust_symndx coff_a29k_adjust_symndx
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target a29kcoff_big_vec =
|
||||
{
|
||||
"coff-a29k-big", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC /* section flags */
|
||||
| SEC_LOAD | SEC_RELOC
|
||||
| SEC_READONLY ),
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
/* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
|
||||
/* hdrs */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
|
||||
|
||||
{
|
||||
|
||||
_bfd_dummy_target,
|
||||
coff_object_p,
|
||||
bfd_generic_archive_p,
|
||||
_bfd_dummy_target
|
||||
},
|
||||
{
|
||||
bfd_false,
|
||||
coff_mkobject,
|
||||
_bfd_generic_mkarchive,
|
||||
bfd_false
|
||||
},
|
||||
{
|
||||
bfd_false,
|
||||
coff_write_object_contents,
|
||||
_bfd_write_archive_contents,
|
||||
bfd_false
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,162 @@
|
||||
/* BFD back-end for Apollo 68000 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
By Troy Rollo (troy@cbme.unsw.edu.au)
|
||||
Based on m68k standard COFF version Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/apollo.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern reloc_howto_type apollocoff_howto_table[];
|
||||
#else
|
||||
reloc_howto_type apollocoff_howto_table[] =
|
||||
{
|
||||
HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "-32", true, 0xffffffff,0xffffffff, false),
|
||||
};
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#ifndef BADMAG
|
||||
#define BADMAG(x) M68KBADMAG(x)
|
||||
#endif
|
||||
#define APOLLO_M68 1 /* Customize coffcode.h */
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern void apollo_rtype2howto PARAMS ((arelent *internal, int relocentry));
|
||||
extern int apollo_howto2rtype PARAMS ((reloc_howto_type *));
|
||||
#else
|
||||
void
|
||||
apollo_rtype2howto(internal, relocentry)
|
||||
arelent *internal;
|
||||
int relocentry;
|
||||
{
|
||||
switch (relocentry)
|
||||
{
|
||||
case R_RELBYTE: internal->howto = apollocoff_howto_table + 0; break;
|
||||
case R_RELWORD: internal->howto = apollocoff_howto_table + 1; break;
|
||||
case R_RELLONG: internal->howto = apollocoff_howto_table + 2; break;
|
||||
case R_PCRBYTE: internal->howto = apollocoff_howto_table + 3; break;
|
||||
case R_PCRWORD: internal->howto = apollocoff_howto_table + 4; break;
|
||||
case R_PCRLONG: internal->howto = apollocoff_howto_table + 5; break;
|
||||
case R_RELLONG_NEG: internal->howto = apollocoff_howto_table + 6; break;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
apollo_howto2rtype (internal)
|
||||
reloc_howto_type *internal;
|
||||
{
|
||||
if (internal->pc_relative)
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_PCRLONG;
|
||||
case 16: return R_PCRWORD;
|
||||
case 8: return R_PCRBYTE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_RELLONG;
|
||||
case 16: return R_RELWORD;
|
||||
case 8: return R_RELBYTE;
|
||||
}
|
||||
}
|
||||
return R_RELLONG;
|
||||
}
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) \
|
||||
apollo_rtype2howto(internal, (relocentry)->r_type)
|
||||
|
||||
#define SELECT_RELOC(external, internal) \
|
||||
external.r_type = apollo_howto2rtype(internal);
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
apollocoff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"apollo-m68k", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
#ifdef NAMES_HAVE_UNDERSCORE
|
||||
'_',
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
@@ -0,0 +1,537 @@
|
||||
/* BFD back-end for ARM COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
|
||||
#include "coff/arm.h"
|
||||
|
||||
#include "coff/internal.h"
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
#include "coff/pe.h"
|
||||
#endif
|
||||
|
||||
#include "libcoff.h"
|
||||
|
||||
static bfd_reloc_status_type
|
||||
aoutarm_fix_pcrel_26_done PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
|
||||
static bfd_reloc_status_type
|
||||
aoutarm_fix_pcrel_26 PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
|
||||
|
||||
static bfd_reloc_status_type coff_arm_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
|
||||
|
||||
/* Used by the assembler. */
|
||||
static bfd_reloc_status_type
|
||||
coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
symvalue diff;
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
diff = reloc_entry->addend;
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
#ifndef PCRELOFFSET
|
||||
#define PCRELOFFSET true
|
||||
#endif
|
||||
|
||||
static reloc_howto_type aoutarm_std_reloc_howto[] =
|
||||
{
|
||||
/* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
|
||||
HOWTO(0, /* type */
|
||||
0, /* rs */
|
||||
0, /* size */
|
||||
8, /* bsz */
|
||||
false, /* pcrel */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* ovf */
|
||||
coff_arm_reloc, /* sf */
|
||||
"8", /*name */
|
||||
true, /* partial */
|
||||
0x000000ff, /*read mask */
|
||||
0x000000ff, /* setmask */
|
||||
PCRELOFFSET /* pcdone */),
|
||||
HOWTO(1,
|
||||
0,
|
||||
1,
|
||||
16,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_bitfield,
|
||||
coff_arm_reloc,
|
||||
"16",
|
||||
true,
|
||||
0x0000ffff,
|
||||
0x0000ffff,
|
||||
PCRELOFFSET),
|
||||
HOWTO( 2,
|
||||
0,
|
||||
2,
|
||||
32,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_bitfield,
|
||||
coff_arm_reloc,
|
||||
"32",
|
||||
true,
|
||||
0xffffffff,
|
||||
0xffffffff,
|
||||
PCRELOFFSET),
|
||||
HOWTO( 3,
|
||||
2,
|
||||
2,
|
||||
26,
|
||||
true,
|
||||
0,
|
||||
complain_overflow_signed,
|
||||
aoutarm_fix_pcrel_26 ,
|
||||
"ARM26",
|
||||
false,
|
||||
0x00ffffff,
|
||||
0x00ffffff,
|
||||
PCRELOFFSET),
|
||||
HOWTO( 4,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
true,
|
||||
0,
|
||||
complain_overflow_signed,
|
||||
coff_arm_reloc,
|
||||
"DISP8",
|
||||
true,
|
||||
0x000000ff,
|
||||
0x000000ff,
|
||||
true),
|
||||
HOWTO( 5,
|
||||
0,
|
||||
1,
|
||||
16,
|
||||
true,
|
||||
0,
|
||||
complain_overflow_signed,
|
||||
coff_arm_reloc,
|
||||
"DISP16",
|
||||
true,
|
||||
0x0000ffff,
|
||||
0x0000ffff,
|
||||
true),
|
||||
HOWTO( 6,
|
||||
0,
|
||||
2,
|
||||
32,
|
||||
true,
|
||||
0,
|
||||
complain_overflow_signed,
|
||||
coff_arm_reloc,
|
||||
"DISP32",
|
||||
true,
|
||||
0xffffffff,
|
||||
0xffffffff,
|
||||
true),
|
||||
HOWTO( 7,
|
||||
2,
|
||||
2,
|
||||
26,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_signed,
|
||||
aoutarm_fix_pcrel_26_done,
|
||||
"ARM26D",
|
||||
true,
|
||||
0x00ffffff,
|
||||
0x00ffffff,
|
||||
false),
|
||||
{-1},
|
||||
HOWTO( 9,
|
||||
0,
|
||||
-1,
|
||||
16,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_bitfield,
|
||||
coff_arm_reloc,
|
||||
"NEG16",
|
||||
true,
|
||||
0x0000ffff,
|
||||
0x0000ffff,
|
||||
false),
|
||||
HOWTO( 10,
|
||||
0,
|
||||
-2,
|
||||
32,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_bitfield,
|
||||
coff_arm_reloc,
|
||||
"NEG32",
|
||||
true,
|
||||
0xffffffff,
|
||||
0xffffffff,
|
||||
false),
|
||||
HOWTO( 11,
|
||||
0,
|
||||
2,
|
||||
32,
|
||||
false,
|
||||
0,
|
||||
complain_overflow_bitfield,
|
||||
coff_arm_reloc,
|
||||
"rva32",
|
||||
true,
|
||||
0xffffffff,
|
||||
0xffffffff,
|
||||
PCRELOFFSET),
|
||||
};
|
||||
#ifdef COFF_WITH_PE
|
||||
/* Return true if this relocation should
|
||||
appear in the output .reloc section. */
|
||||
|
||||
static boolean in_reloc_p (abfd, howto)
|
||||
bfd * abfd;
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return !howto->pc_relative && howto->type != 11;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = aoutarm_std_reloc_howto + (dst)->r_type;
|
||||
|
||||
#define coff_rtype_to_howto coff_arm_rtype_to_howto
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
reloc_howto_type *howto;
|
||||
|
||||
howto = aoutarm_std_reloc_howto + rel->r_type;
|
||||
|
||||
if (rel->r_type == 11)
|
||||
{
|
||||
*addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||
}
|
||||
return howto;
|
||||
|
||||
}
|
||||
/* Used by the assembler. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
aoutarm_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
/* This is dead simple at present. */
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
/* Used by the assembler. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
bfd_vma relocation;
|
||||
bfd_size_type addr = reloc_entry->address;
|
||||
long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
|
||||
bfd_reloc_status_type flag = bfd_reloc_ok;
|
||||
|
||||
/* If this is an undefined symbol, return error */
|
||||
if (symbol->section == &bfd_und_section
|
||||
&& (symbol->flags & BSF_WEAK) == 0)
|
||||
return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
|
||||
|
||||
/* If the sections are different, and we are doing a partial relocation,
|
||||
just ignore it for now. */
|
||||
if (symbol->section->name != input_section->name
|
||||
&& output_bfd != (bfd *)NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
relocation = (target & 0x00ffffff) << 2;
|
||||
relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
|
||||
relocation += symbol->value;
|
||||
relocation += symbol->section->output_section->vma;
|
||||
relocation += symbol->section->output_offset;
|
||||
relocation += reloc_entry->addend;
|
||||
relocation -= input_section->output_section->vma;
|
||||
relocation -= input_section->output_offset;
|
||||
relocation -= addr;
|
||||
if (relocation & 3)
|
||||
return bfd_reloc_overflow;
|
||||
|
||||
/* Check for overflow */
|
||||
if (relocation & 0x02000000)
|
||||
{
|
||||
if ((relocation & ~0x03ffffff) != ~0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
}
|
||||
else if (relocation & ~0x03ffffff)
|
||||
flag = bfd_reloc_overflow;
|
||||
|
||||
target &= ~0x00ffffff;
|
||||
target |= (relocation >> 2) & 0x00ffffff;
|
||||
bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
|
||||
|
||||
/* Now the ARM magic... Change the reloc type so that it is marked as done.
|
||||
Strictly this is only necessary if we are doing a partial relocation. */
|
||||
reloc_entry->howto = &aoutarm_std_reloc_howto[7];
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
static CONST struct reloc_howto_struct *
|
||||
arm_reloc_type_lookup(abfd,code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
#define ASTD(i,j) case i: return &aoutarm_std_reloc_howto[j]
|
||||
if (code == BFD_RELOC_CTOR)
|
||||
switch (bfd_get_arch_info (abfd)->bits_per_address)
|
||||
{
|
||||
case 32:
|
||||
code = BFD_RELOC_32;
|
||||
break;
|
||||
default: return (CONST struct reloc_howto_struct *) 0;
|
||||
}
|
||||
|
||||
switch (code)
|
||||
{
|
||||
ASTD (BFD_RELOC_16, 1);
|
||||
ASTD (BFD_RELOC_32, 2);
|
||||
ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
|
||||
ASTD (BFD_RELOC_8_PCREL, 4);
|
||||
ASTD (BFD_RELOC_16_PCREL, 5);
|
||||
ASTD (BFD_RELOC_32_PCREL, 6);
|
||||
ASTD (BFD_RELOC_RVA, 11);
|
||||
default: return (CONST struct reloc_howto_struct *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define coff_bfd_reloc_type_lookup arm_reloc_type_lookup
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
/* Turn a howto into a reloc nunmber */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||
#define BADMAG(x) ARMBADMAG(x)
|
||||
#define ARM 1 /* Customize coffcode.h */
|
||||
|
||||
|
||||
/* We use the special COFF backend linker. */
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_LITTLE_SYM
|
||||
TARGET_LITTLE_SYM =
|
||||
#else
|
||||
armcoff_little_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_LITTLE_NAME
|
||||
TARGET_LITTLE_NAME,
|
||||
#else
|
||||
"coff-arm-little",
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
TARGET_UNDERSCORE, /* leading underscore */
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_BIG_SYM
|
||||
TARGET_BIG_SYM =
|
||||
#else
|
||||
armcoff_big_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_BIG_NAME
|
||||
TARGET_BIG_NAME,
|
||||
#else
|
||||
"coff-arm-big",
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
TARGET_UNDERSCORE, /* leading underscore */
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
@@ -0,0 +1,332 @@
|
||||
/* BFD back-end for Apple M68K COFF A/UX 3.x files.
|
||||
Copyright 1996 Free Software Foundation, Inc.
|
||||
Portions written by Richard Henderson <rth@tamu.edu>,
|
||||
COMMON symbol munging cribbed from cf-m68klynx.c which was
|
||||
written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68kaux_coff_vec
|
||||
#define TARGET_NAME "coff-m68k-aux"
|
||||
|
||||
#ifndef TARG_AUX
|
||||
#define TARG_AUX
|
||||
#endif
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
/* 4k pages */
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
/* On AUX, a STYP_NOLOAD|STYP_BSS section is part of a shared library. */
|
||||
#define BSS_NOLOAD_IS_SHARED_LIBRARY
|
||||
|
||||
#define _bfd_m68kcoff_howto_table _bfd_m68kaux_howto_table
|
||||
#define _bfd_m68kcoff_rtype2howto _bfd_m68kaux_rtype2howto
|
||||
#define _bfd_m68kcoff_howto2rtype _bfd_m68kaux_howto2rtype
|
||||
#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68kaux_reloc_type_lookup
|
||||
|
||||
/* Rather than change names lots of places, reuse the same hack */
|
||||
#define LYNX_SPECIAL_FN _bfd_m68kaux_special_fn
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
struct internal_reloc;
|
||||
struct coff_link_hash_entry;
|
||||
struct internal_syment;
|
||||
#endif
|
||||
|
||||
|
||||
static bfd_reloc_status_type _bfd_m68kaux_special_fn
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_m68k_aux_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
static boolean coff_m68k_aux_link_add_one_symbol
|
||||
PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
|
||||
asection *, bfd_vma, const char *, boolean, boolean,
|
||||
struct bfd_link_hash_entry **));
|
||||
|
||||
|
||||
#define coff_rtype_to_howto coff_m68k_aux_rtype_to_howto
|
||||
#define coff_link_add_one_symbol coff_m68k_aux_link_add_one_symbol
|
||||
|
||||
|
||||
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||
the object file contains the value of the common symbol. By the
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && (reloc.r_type == R_PCRBYTE \
|
||||
|| reloc.r_type == R_PCRWORD \
|
||||
|| reloc.r_type == R_PCRLONG)) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "coff/aux-coff.h" /* override coff/internal.h and coff/m68k.h */
|
||||
#include "coff-m68k.c"
|
||||
|
||||
|
||||
|
||||
/* For some reason when using m68k COFF the value stored in the .text
|
||||
section for a reference to a common symbol is the value itself plus
|
||||
any desired offset. (taken from work done by Ian Taylor, Cygnus Support,
|
||||
for I386 COFF). */
|
||||
|
||||
/* If we are producing relocateable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
_bfd_m68kaux_special_fn (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocateable output. This seems to be always wrong for 386
|
||||
COFF, so we handle the addend here instead. */
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | \
|
||||
(((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
|
||||
/* coff-m68k.c uses the special COFF backend linker. We need to
|
||||
adjust common symbols. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static reloc_howto_type *
|
||||
coff_m68k_aux_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
arelent relent;
|
||||
reloc_howto_type *howto;
|
||||
|
||||
RTYPE2HOWTO (&relent, rel);
|
||||
|
||||
howto = relent.howto;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
BFD_ASSERT (h != NULL);
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocateable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
|
||||
/* We need non-absolute symbols to override absolute symbols. This
|
||||
mirrors Apple's "solution" to let a static library symbol override
|
||||
a shared library symbol. On the whole not a good thing, given how
|
||||
shared libraries work here, but can work if you are careful with
|
||||
what you include in the shared object. */
|
||||
|
||||
boolean
|
||||
coff_m68k_aux_link_add_one_symbol (info, abfd, name, flags, section, value,
|
||||
string, copy, collect, hashp)
|
||||
struct bfd_link_info *info;
|
||||
bfd *abfd;
|
||||
const char *name;
|
||||
flagword flags;
|
||||
asection *section;
|
||||
bfd_vma value;
|
||||
const char *string;
|
||||
boolean copy;
|
||||
boolean collect;
|
||||
struct bfd_link_hash_entry **hashp;
|
||||
{
|
||||
struct bfd_link_hash_entry *h;
|
||||
|
||||
if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0 &&
|
||||
!bfd_is_und_section (section) &&
|
||||
!bfd_is_com_section (section))
|
||||
{
|
||||
/* The new symbol is a definition or an indirect definition */
|
||||
|
||||
/* This bit copied from linker.c */
|
||||
if (hashp != NULL && *hashp != NULL)
|
||||
{
|
||||
h = *hashp;
|
||||
BFD_ASSERT (strcmp (h->root.string, name) == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
h = bfd_link_hash_lookup (info->hash, name, true, copy, false);
|
||||
if (h == NULL)
|
||||
{
|
||||
if (hashp != NULL)
|
||||
*hashp = NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (info->notice_hash != (struct bfd_hash_table *) NULL
|
||||
&& (bfd_hash_lookup (info->notice_hash, name, false, false)
|
||||
!= (struct bfd_hash_entry *) NULL))
|
||||
{
|
||||
if (! (*info->callbacks->notice) (info, name, abfd, section, value))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hashp != (struct bfd_link_hash_entry **) NULL)
|
||||
*hashp = h;
|
||||
/* end duplication from linker.c */
|
||||
|
||||
if (h->type == bfd_link_hash_defined
|
||||
|| h->type == bfd_link_hash_indirect)
|
||||
{
|
||||
asection *msec;
|
||||
|
||||
if (h->type == bfd_link_hash_defined)
|
||||
msec = h->u.def.section;
|
||||
else
|
||||
msec = bfd_ind_section_ptr;
|
||||
|
||||
if (bfd_is_abs_section (msec) && !bfd_is_abs_section (section))
|
||||
{
|
||||
h->u.def.section = section;
|
||||
h->u.def.value = value;
|
||||
return true;
|
||||
}
|
||||
else if (bfd_is_abs_section (section) && !bfd_is_abs_section (msec))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't exit early, finish processing in the generic routine */
|
||||
return _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
|
||||
value, string, copy, collect,
|
||||
hashp);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/* BFD back-end for Intel 386 COFF files (go32 variant).
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by DJ Delorie.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM go32coff_vec
|
||||
#define TARGET_NAME "coff-go32"
|
||||
#define TARGET_UNDERSCORE '_'
|
||||
|
||||
#include "coff-i386.c"
|
||||
@@ -0,0 +1,650 @@
|
||||
/* BFD back-end for Hitachi H8/300 COFF binaries.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "obstack.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "genlink.h"
|
||||
#include "coff/h8300.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
|
||||
|
||||
/* special handling for H8/300 relocs.
|
||||
We only come here for pcrel stuff and return normally if not an -r link.
|
||||
When doing -r, we can't do any arithmetic for the pcrel stuff, because
|
||||
the code in reloc.c assumes that we can manipulate the targets of
|
||||
the pcrel branches. This isn't so, since the H8/300 can do relaxing,
|
||||
which means that the gap after the instruction may not be enough to
|
||||
contain the offset required for the branch, so we have to use the only
|
||||
the addend until the final link */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
special (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
HOWTO (R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8", false, 0x000000ff, 0x000000ff, false),
|
||||
HOWTO (R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16", false, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "32", false, 0xffffffff, 0xffffffff, false),
|
||||
HOWTO (R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, special, "DISP8", false, 0x000000ff, 0x000000ff, true),
|
||||
HOWTO (R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, special, "DISP16", false, 0x0000ffff, 0x0000ffff, true),
|
||||
HOWTO (R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, special, "DISP32", false, 0xffffffff, 0xffffffff, true),
|
||||
HOWTO (R_MOVB1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/8", false, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_MOVB2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "8/16", false, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_JMP1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/pcrel", false, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_JMP2, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pcrecl/16", false, 0x000000ff, 0x000000ff, false),
|
||||
|
||||
|
||||
HOWTO (R_JMPL1, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "24/pcrell", false, 0x00ffffff, 0x00ffffff, false),
|
||||
HOWTO (R_JMPL_B8, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pc8/24", false, 0x000000ff, 0x000000ff, false),
|
||||
|
||||
HOWTO (R_MOVLB1, 0, 1, 16, false, 0, complain_overflow_bitfield,special, "24/8", false, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_MOVLB2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "8/24", false, 0x0000ffff, 0x0000ffff, false),
|
||||
|
||||
/* An indirect reference to a function. This causes the function's address
|
||||
to be added to the function vector in lo-mem and puts the address of
|
||||
the function vector's entry in the jsr instruction. */
|
||||
HOWTO (R_MEM_INDIRECT, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8/indirect", false, 0x000000ff, 0x000000ff, false),
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
#define SELECT_RELOC(x,howto) \
|
||||
{ x.r_type = select_reloc(howto); }
|
||||
|
||||
#define BADMAG(x) (H8300BADMAG(x)&& H8300HBADMAG(x))
|
||||
#define H8300 1 /* Customize coffcode.h */
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
|
||||
static int
|
||||
select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type;
|
||||
}
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||
*/
|
||||
|
||||
static void
|
||||
rtype2howto (internal, dst)
|
||||
arelent *internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
switch (dst->r_type)
|
||||
{
|
||||
case R_RELBYTE:
|
||||
internal->howto = howto_table + 0;
|
||||
break;
|
||||
case R_RELWORD:
|
||||
internal->howto = howto_table + 1;
|
||||
break;
|
||||
case R_RELLONG:
|
||||
internal->howto = howto_table + 2;
|
||||
break;
|
||||
case R_PCRBYTE:
|
||||
internal->howto = howto_table + 3;
|
||||
break;
|
||||
case R_PCRWORD:
|
||||
internal->howto = howto_table + 4;
|
||||
break;
|
||||
case R_PCRLONG:
|
||||
internal->howto = howto_table + 5;
|
||||
break;
|
||||
case R_MOVB1:
|
||||
internal->howto = howto_table + 6;
|
||||
break;
|
||||
case R_MOVB2:
|
||||
internal->howto = howto_table + 7;
|
||||
break;
|
||||
case R_JMP1:
|
||||
internal->howto = howto_table + 8;
|
||||
break;
|
||||
case R_JMP2:
|
||||
internal->howto = howto_table + 9;
|
||||
break;
|
||||
case R_JMPL1:
|
||||
internal->howto = howto_table + 10;
|
||||
break;
|
||||
case R_JMPL_B8:
|
||||
internal->howto = howto_table + 11;
|
||||
break;
|
||||
case R_MOVLB1:
|
||||
internal->howto = howto_table + 12;
|
||||
break;
|
||||
case R_MOVLB2:
|
||||
internal->howto = howto_table + 13;
|
||||
break;
|
||||
case R_MEM_INDIRECT:
|
||||
internal->howto = howto_table + 14;
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
|
||||
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent * relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol ** symbols;
|
||||
bfd * abfd;
|
||||
asection * section;
|
||||
{
|
||||
relent->address = reloc->r_vaddr;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (((int) reloc->r_symndx) > 0)
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
|
||||
relent->address -= section->vma;
|
||||
/* relent->section = 0;*/
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
h8300_reloc16_estimate(abfd, input_section, reloc, shrink, link_info)
|
||||
bfd *abfd;
|
||||
asection *input_section;
|
||||
arelent *reloc;
|
||||
unsigned int shrink;
|
||||
struct bfd_link_info *link_info;
|
||||
{
|
||||
bfd_vma value;
|
||||
bfd_vma dot;
|
||||
bfd_vma gap;
|
||||
|
||||
/* The address of the thing to be relocated will have moved back by
|
||||
the size of the shrink - but we don't change reloc->address here,
|
||||
since we need it to know where the relocation lives in the source
|
||||
uncooked section */
|
||||
|
||||
/* reloc->address -= shrink; conceptual */
|
||||
|
||||
bfd_vma address = reloc->address - shrink;
|
||||
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_MOVB2:
|
||||
case R_JMP2:
|
||||
shrink+=2;
|
||||
break;
|
||||
|
||||
/* Thing is a move one byte */
|
||||
case R_MOVB1:
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
if (value >= 0xff00)
|
||||
{
|
||||
|
||||
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||
possible 16 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* The place to relc moves back by one */
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
|
||||
break;
|
||||
/* This is the 24 bit branch which could become an 8 bitter,
|
||||
the relocation points to the first byte of the insn, not the
|
||||
actual data */
|
||||
|
||||
case R_JMPL1:
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
dot = input_section->output_section->vma +
|
||||
input_section->output_offset + address;
|
||||
|
||||
/* See if the address we're looking at within 127 bytes of where
|
||||
we are, if so then we can use a small branch rather than the
|
||||
jump we were going to */
|
||||
|
||||
gap = value - dot ;
|
||||
|
||||
if (-120 < (long)gap && (long)gap < 120 )
|
||||
{
|
||||
|
||||
/* Change the reloc type from 24bit, possible 8 to 8bit
|
||||
possible 32 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_JMP1:
|
||||
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
dot = input_section->output_section->vma +
|
||||
input_section->output_offset + address;
|
||||
|
||||
/* See if the address we're looking at within 127 bytes of where
|
||||
we are, if so then we can use a small branch rather than the
|
||||
jump we were going to */
|
||||
|
||||
gap = value - (dot - shrink);
|
||||
|
||||
|
||||
if (-120 < (long)gap && (long)gap < 120 )
|
||||
{
|
||||
|
||||
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||
possible 16 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* The place to relc moves back by one */
|
||||
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return shrink;
|
||||
}
|
||||
|
||||
|
||||
/* First phase of a relaxing link */
|
||||
|
||||
/* Reloc types
|
||||
large small
|
||||
R_MOVB1 R_MOVB2 mov.b with 16bit or 8 bit address
|
||||
R_JMP1 R_JMP2 jmp or pcrel branch
|
||||
R_JMPL1 R_JMPL_B8 24jmp or pcrel branch
|
||||
R_MOVLB1 R_MOVLB2 24 or 8 bit reloc for mov.b
|
||||
|
||||
*/
|
||||
|
||||
static void
|
||||
h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
|
||||
dst_ptr)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *link_info;
|
||||
struct bfd_link_order *link_order;
|
||||
arelent *reloc;
|
||||
bfd_byte *data;
|
||||
unsigned int *src_ptr;
|
||||
unsigned int *dst_ptr;
|
||||
{
|
||||
unsigned int src_address = *src_ptr;
|
||||
unsigned int dst_address = *dst_ptr;
|
||||
asection *input_section = link_order->u.indirect.section;
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
/* A 24 bit branch which could be a 8 bit pcrel, really pointing to
|
||||
the byte before the 24bit hole, so we can treat it as a 32bit pointer */
|
||||
case R_PCRBYTE:
|
||||
{
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
- dot);
|
||||
if (gap > 127 || gap < -128)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
gap &= ~1;
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address++;
|
||||
src_address++;
|
||||
|
||||
break;
|
||||
}
|
||||
case R_PCRWORD:
|
||||
{
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
- dot) - 1;
|
||||
if (gap > 32767 || gap < -32768)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address+=2;
|
||||
src_address+=2;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case R_MEM_INDIRECT: /* Temporary */
|
||||
case R_RELBYTE:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
if (gap < 0xff
|
||||
|| (gap >= 0x0000ff00
|
||||
&& gap <= 0x0000ffff)
|
||||
|| ( gap >= 0x00ffff00
|
||||
&& gap <= 0x00ffffff)
|
||||
|| ( gap >= 0xffffff00
|
||||
&& gap <= 0xffffffff))
|
||||
{
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case R_JMP1:
|
||||
/* A relword which would have like to have been a pcrel */
|
||||
case R_MOVB1:
|
||||
/* A relword which would like to have been modified but
|
||||
didn't make it */
|
||||
case R_RELWORD:
|
||||
bfd_put_16 (abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
break;
|
||||
case R_RELLONG:
|
||||
bfd_put_32 (abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
data + dst_address);
|
||||
dst_address += 4;
|
||||
src_address += 4;
|
||||
break;
|
||||
|
||||
case R_MOVB2:
|
||||
/* Special relaxed type, there will be a gap between where we
|
||||
get stuff from and where we put stuff to now
|
||||
|
||||
for a mov.b @aa:16 -> mov.b @aa:8
|
||||
opcode 0x6a 0x0y offset
|
||||
-> 0x2y off
|
||||
*/
|
||||
if (data[dst_address - 1] != 0x6a)
|
||||
abort ();
|
||||
switch (data[src_address] & 0xf0)
|
||||
{
|
||||
case 0x00:
|
||||
/* Src is memory */
|
||||
data[dst_address - 1] = (data[src_address] & 0xf) | 0x20;
|
||||
break;
|
||||
case 0x80:
|
||||
/* Src is reg */
|
||||
data[dst_address - 1] = (data[src_address] & 0xf) | 0x30;
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* the offset must fit ! after all, what was all the relaxing
|
||||
about ? */
|
||||
|
||||
bfd_put_8 (abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
data + dst_address);
|
||||
|
||||
/* Note the magic - src goes up by two bytes, but dst by only
|
||||
one */
|
||||
dst_address += 1;
|
||||
src_address += 3;
|
||||
|
||||
break;
|
||||
|
||||
case R_JMP2:
|
||||
|
||||
/* Speciial relaxed type */
|
||||
{
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
|
||||
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
- dot - 1);
|
||||
|
||||
if ((gap & ~0xff) != 0 && ((gap & 0xff00) != 0xff00))
|
||||
abort ();
|
||||
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
|
||||
switch (data[dst_address - 1])
|
||||
{
|
||||
case 0x5e:
|
||||
/* jsr -> bsr */
|
||||
bfd_put_8 (abfd, 0x55, data + dst_address - 1);
|
||||
break;
|
||||
case 0x5a:
|
||||
/* jmp ->bra */
|
||||
bfd_put_8 (abfd, 0x40, data + dst_address - 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
dst_address++;
|
||||
src_address += 3;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_JMPL_B8: /* 24 bit branch which is now 8 bits */
|
||||
|
||||
/* Speciial relaxed type */
|
||||
{
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
|
||||
int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
- dot - 2);
|
||||
|
||||
if ((gap & ~0xff) != 0 && ((gap & 0xff00) != 0xff00))
|
||||
abort ();
|
||||
|
||||
switch (data[src_address])
|
||||
{
|
||||
case 0x5e:
|
||||
/* jsr -> bsr */
|
||||
bfd_put_8 (abfd, 0x55, data + dst_address);
|
||||
break;
|
||||
case 0x5a:
|
||||
/* jmp ->bra */
|
||||
bfd_put_8 (abfd, 0x40, data + dst_address);
|
||||
break;
|
||||
|
||||
default:
|
||||
bfd_put_8 (abfd, 0xde, data + dst_address);
|
||||
break;
|
||||
}
|
||||
|
||||
bfd_put_8 (abfd, gap, data + dst_address + 1);
|
||||
dst_address += 2;
|
||||
src_address += 4;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case R_JMPL1:
|
||||
{
|
||||
int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
int o = bfd_get_32 (abfd, data + src_address);
|
||||
v = (v & 0x00ffffff) | (o & 0xff000000);
|
||||
bfd_put_32 (abfd, v, data + dst_address);
|
||||
dst_address += 4;
|
||||
src_address += 4;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
/* A 24 bit mov which could be an 8 bit move, really pointing to
|
||||
the byte before the 24bit hole, so we can treat it as a 32bit pointer */
|
||||
case R_MOVLB1:
|
||||
{
|
||||
int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
|
||||
int o = bfd_get_32 (abfd, data + dst_address);
|
||||
v = (v & 0x00ffffff) | (o & 0xff000000);
|
||||
bfd_put_32 (abfd, v, data + dst_address);
|
||||
dst_address += 4;
|
||||
src_address += 4;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
abort ();
|
||||
break;
|
||||
|
||||
}
|
||||
*src_ptr = src_address;
|
||||
*dst_ptr = dst_address;
|
||||
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases h8300_reloc16_extra_cases
|
||||
#define coff_reloc16_estimate h8300_reloc16_estimate
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
#include "coffcode.h"
|
||||
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
|
||||
|
||||
const bfd_target h8300coff_vec =
|
||||
{
|
||||
"coff-h8300", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading char */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
@@ -0,0 +1,355 @@
|
||||
/* BFD back-end for Hitachi H8/500 COFF binaries.
|
||||
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||
Contributed by Cygnus Support.
|
||||
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "obstack.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/h8500.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
|
||||
static reloc_howto_type r_imm8 =
|
||||
HOWTO (R_H8500_IMM8, 0, 1, 8, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff, false);
|
||||
|
||||
static reloc_howto_type r_imm16 =
|
||||
HOWTO (R_H8500_IMM16, 0, 1, 16, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm16", true, 0x0000ffff, 0x0000ffff, false);
|
||||
|
||||
static reloc_howto_type r_imm24 =
|
||||
HOWTO (R_H8500_IMM24, 0, 1, 24, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm24", true, 0x00ffffff, 0x00ffffff, false);
|
||||
|
||||
static reloc_howto_type r_imm32 =
|
||||
HOWTO (R_H8500_IMM32, 0, 1, 32, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff, 0xffffffff, false);
|
||||
|
||||
|
||||
static reloc_howto_type r_high8 =
|
||||
HOWTO (R_H8500_HIGH8, 0, 1, 8, false, 0,
|
||||
complain_overflow_dont, 0, "r_high8", true, 0x000000ff, 0x000000ff, false);
|
||||
|
||||
static reloc_howto_type r_low16 =
|
||||
HOWTO (R_H8500_LOW16, 0, 1, 16, false, 0,
|
||||
complain_overflow_dont, 0, "r_low16", true, 0x0000ffff, 0x0000ffff, false);
|
||||
|
||||
static reloc_howto_type r_pcrel8 =
|
||||
HOWTO (R_H8500_PCREL8, 0, 1, 8, true, 0, complain_overflow_signed, 0, "r_pcrel8", true, 0, 0, true);
|
||||
|
||||
|
||||
static reloc_howto_type r_pcrel16 =
|
||||
HOWTO (R_H8500_PCREL16, 0, 1, 16, true, 0, complain_overflow_signed, 0, "r_pcrel16", true, 0, 0, true);
|
||||
|
||||
static reloc_howto_type r_high16 =
|
||||
HOWTO (R_H8500_HIGH16, 0, 1, 8, false, 0,
|
||||
complain_overflow_dont, 0, "r_high16", true, 0x000ffff, 0x0000ffff, false);
|
||||
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
static int
|
||||
coff_h8500_select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type;
|
||||
}
|
||||
|
||||
#define SELECT_RELOC(x,howto) x.r_type = coff_h8500_select_reloc(howto)
|
||||
|
||||
|
||||
#define BADMAG(x) H8500BADMAG(x)
|
||||
#define H8500 1 /* Customize coffcode.h */
|
||||
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||
*/
|
||||
|
||||
static void
|
||||
rtype2howto(internal, dst)
|
||||
arelent * internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
switch (dst->r_type)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
break;
|
||||
case R_H8500_IMM8:
|
||||
internal->howto = &r_imm8;
|
||||
break;
|
||||
case R_H8500_IMM16:
|
||||
internal->howto = &r_imm16;
|
||||
break;
|
||||
case R_H8500_IMM24:
|
||||
internal->howto = &r_imm24;
|
||||
break;
|
||||
case R_H8500_IMM32:
|
||||
internal->howto = &r_imm32;
|
||||
break;
|
||||
case R_H8500_PCREL8:
|
||||
internal->howto = &r_pcrel8;
|
||||
break;
|
||||
case R_H8500_PCREL16:
|
||||
internal->howto = &r_pcrel16;
|
||||
break;
|
||||
case R_H8500_HIGH8:
|
||||
internal->howto = &r_high8;
|
||||
break;
|
||||
case R_H8500_HIGH16:
|
||||
internal->howto = &r_high16;
|
||||
break;
|
||||
case R_H8500_LOW16:
|
||||
internal->howto = &r_low16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
|
||||
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent * relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol ** symbols;
|
||||
bfd * abfd;
|
||||
asection * section;
|
||||
{
|
||||
relent->address = reloc->r_vaddr;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (reloc->r_symndx > 0)
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
relent->address -= section->vma;
|
||||
}
|
||||
|
||||
static void
|
||||
extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
|
||||
bfd *in_abfd;
|
||||
struct bfd_link_info *link_info;
|
||||
struct bfd_link_order *link_order;
|
||||
arelent *reloc;
|
||||
bfd_byte *data;
|
||||
unsigned int *src_ptr;
|
||||
unsigned int *dst_ptr;
|
||||
{
|
||||
bfd_byte *d = data+*dst_ptr;
|
||||
asection *input_section = link_order->u.indirect.section;
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_H8500_IMM8:
|
||||
bfd_put_8 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
d);
|
||||
(*dst_ptr) += 1;
|
||||
(*src_ptr) += 1;
|
||||
break;
|
||||
|
||||
case R_H8500_HIGH8:
|
||||
bfd_put_8 (in_abfd,
|
||||
(bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
>> 16),
|
||||
d );
|
||||
(*dst_ptr) += 1;
|
||||
(*src_ptr) += 1;
|
||||
break;
|
||||
|
||||
case R_H8500_IMM16:
|
||||
bfd_put_16 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
d );
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_H8500_LOW16:
|
||||
bfd_put_16 (in_abfd,
|
||||
bfd_coff_reloc16_get_value (reloc, link_info, input_section),
|
||||
d);
|
||||
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_H8500_HIGH16:
|
||||
bfd_put_16 (in_abfd,
|
||||
(bfd_coff_reloc16_get_value (reloc, link_info, input_section)
|
||||
>>16),
|
||||
d);
|
||||
|
||||
(*dst_ptr) += 2;
|
||||
(*src_ptr) += 2;
|
||||
break;
|
||||
|
||||
case R_H8500_IMM24:
|
||||
{
|
||||
int v = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
int o = bfd_get_32(in_abfd, data+ *dst_ptr -1);
|
||||
v = (v & 0x00ffffff) | (o & 0xff00000);
|
||||
bfd_put_32 (in_abfd, v, data + *dst_ptr -1);
|
||||
(*dst_ptr) +=3;
|
||||
(*src_ptr)+=3;;
|
||||
}
|
||||
break;
|
||||
case R_H8500_IMM32:
|
||||
{
|
||||
int v = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
bfd_put_32 (in_abfd, v, data + *dst_ptr);
|
||||
(*dst_ptr) +=4;
|
||||
(*src_ptr)+=4;;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case R_H8500_PCREL8:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ *dst_ptr
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
int gap = dst - dot - 1; /* -1 since were in the odd byte of the
|
||||
word and the pc's been incremented */
|
||||
|
||||
if (gap > 128 || gap < -128)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_8 (in_abfd, gap, data + *dst_ptr);
|
||||
(*dst_ptr)++;
|
||||
(*src_ptr)++;
|
||||
break;
|
||||
}
|
||||
case R_H8500_PCREL16:
|
||||
{
|
||||
bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ *dst_ptr
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
int gap = dst - dot - 1; /* -1 since were in the odd byte of the
|
||||
word and the pc's been incremented */
|
||||
|
||||
if (gap > 32767 || gap < -32768)
|
||||
{
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort ();
|
||||
}
|
||||
bfd_put_16 (in_abfd, gap, data + *dst_ptr);
|
||||
(*dst_ptr)+=2;
|
||||
(*src_ptr)+=2;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases extra_case
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
const bfd_target h8500coff_vec =
|
||||
{
|
||||
"coff-h8500", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
@@ -0,0 +1,493 @@
|
||||
/* BFD back-end for Intel 386 COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
|
||||
#include "coff/i386.h"
|
||||
|
||||
#include "coff/internal.h"
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
#include "coff/pe.h"
|
||||
#endif
|
||||
|
||||
#include "libcoff.h"
|
||||
|
||||
static bfd_reloc_status_type coff_i386_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_i386_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
|
||||
bfd_vma *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
/* The page size is a guess based on ELF. */
|
||||
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
/* For some reason when using i386 COFF the value stored in the .text
|
||||
section for a reference to a common symbol is the value itself plus
|
||||
any desired offset. Ian Taylor, Cygnus Support. */
|
||||
|
||||
/* If we are producing relocateable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocateable output. This seems to be always wrong for 386
|
||||
COFF, so we handle the addend here instead. */
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
if (reloc_entry->howto->type == 7)
|
||||
{
|
||||
/* diff -= coff_data(output_bfd)->link_info->pe_info.image_base.value;*/
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
/* Return true if this relocation should
|
||||
appear in the output .reloc section. */
|
||||
|
||||
static boolean in_reloc_p(abfd, howto)
|
||||
bfd * abfd;
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return ! howto->pc_relative && howto->type != R_IMAGEBASE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PCRELOFFSET
|
||||
#define PCRELOFFSET false
|
||||
#endif
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
{0},
|
||||
{1},
|
||||
{2},
|
||||
{3},
|
||||
{4},
|
||||
{5},
|
||||
HOWTO (R_DIR32, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"dir32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
/* {7}, */
|
||||
HOWTO (R_IMAGEBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"rva32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
{010},
|
||||
{011},
|
||||
{012},
|
||||
{013},
|
||||
{014},
|
||||
{015},
|
||||
{016},
|
||||
HOWTO (R_RELBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"8", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_RELWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"16", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_RELLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"DISP8", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"DISP16", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"DISP32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET) /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Turn a howto into a reloc nunmber */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||
#define BADMAG(x) I386BADMAG(x)
|
||||
#define I386 1 /* Customize coffcode.h */
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = howto_table + (dst)->r_type;
|
||||
|
||||
/* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
|
||||
library. On some other COFF targets STYP_BSS is normally
|
||||
STYP_NOLOAD. */
|
||||
#define BSS_NOLOAD_IS_SHARED_LIBRARY
|
||||
|
||||
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||
the object file contains the value of the common symbol. By the
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && howto_table[reloc.r_type].pc_relative) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
|
||||
/* We use the special COFF backend linker. */
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
|
||||
reloc_howto_type *howto;
|
||||
|
||||
howto = howto_table + rel->r_type;
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
*addendp = 0;
|
||||
#endif
|
||||
|
||||
if (howto->pc_relative)
|
||||
*addendp += sec->vma;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
|
||||
BFD_ASSERT (h != NULL);
|
||||
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
/* I think we *do* want to bypass this. If we don't, I have seen some data
|
||||
parameters get the wrong relcation address. If I link two versions
|
||||
with and without this section bypassed and then do a binary comparison,
|
||||
the addresses which are different can be looked up in the map. The
|
||||
case in which this section has been bypassed has addresses which correspond
|
||||
to values I can find in the map */
|
||||
*addendp -= sym->n_value;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocateable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
if (howto->pc_relative)
|
||||
*addendp -= 4;
|
||||
|
||||
if (rel->r_type == R_IMAGEBASE)
|
||||
{
|
||||
*addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||
}
|
||||
#endif
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
|
||||
#define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup
|
||||
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i386_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case BFD_RELOC_RVA:
|
||||
return howto_table +R_IMAGEBASE;
|
||||
case BFD_RELOC_32:
|
||||
return howto_table + R_DIR32;
|
||||
case BFD_RELOC_32_PCREL:
|
||||
return howto_table + R_PCRLONG;
|
||||
default:
|
||||
BFD_FAIL ();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define coff_rtype_to_howto coff_i386_rtype_to_howto
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
static const bfd_target *
|
||||
i3coff_object_p(a)
|
||||
bfd *a;
|
||||
{
|
||||
return coff_object_p(a);
|
||||
}
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
i386coff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-i386", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
#ifdef TARGET_UNDERSCORE
|
||||
TARGET_UNDERSCORE, /* leading underscore */
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, i3coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
@@ -0,0 +1,423 @@
|
||||
/* BFD back-end for Intel 860 COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Created mostly by substituting "860" for "386" in coff-i386.c
|
||||
Harry Dolan <dolan@ssd.intel.com>, October 1995
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
|
||||
#include "coff/i860.h"
|
||||
|
||||
#include "coff/internal.h"
|
||||
|
||||
#include "libcoff.h"
|
||||
|
||||
static bfd_reloc_status_type coff_i860_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_i860_rtype_to_howto
|
||||
PARAMS ((bfd *, asection *, struct internal_reloc *,
|
||||
struct coff_link_hash_entry *, struct internal_syment *,
|
||||
bfd_vma *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
/* The page size is a guess based on ELF. */
|
||||
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
/* For some reason when using i860 COFF the value stored in the .text
|
||||
section for a reference to a common symbol is the value itself plus
|
||||
any desired offset. Ian Taylor, Cygnus Support. */
|
||||
|
||||
/* If we are producing relocateable output, we need to do some
|
||||
adjustments to the object file that are not done by the
|
||||
bfd_perform_relocation function. This function is called by every
|
||||
reloc type to make any required adjustments. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_i860_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
symvalue diff;
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
object file is ORIG + OFFSET, where ORIG is the value of the
|
||||
common symbol as seen by the object file when it was compiled
|
||||
(this may be zero if the symbol was undefined) and OFFSET is
|
||||
the offset into the common symbol (normally zero, but may be
|
||||
non-zero when referring to a field in a common structure).
|
||||
ORIG is the negative of reloc_entry->addend, which is set by
|
||||
the CALC_ADDEND macro below. We want to replace the value in
|
||||
the object file with NEW + OFFSET, where NEW is the value of
|
||||
the common symbol which we are going to put in the final
|
||||
object file. NEW is symbol->value. */
|
||||
diff = symbol->value + reloc_entry->addend;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* For some reason bfd_perform_relocation always effectively
|
||||
ignores the addend for a COFF target when producing
|
||||
relocateable output. This seems to be always wrong for 860
|
||||
COFF, so we handle the addend here instead. */
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
#ifndef PCRELOFFSET
|
||||
#define PCRELOFFSET false
|
||||
#endif
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
{0},
|
||||
{1},
|
||||
{2},
|
||||
{3},
|
||||
{4},
|
||||
{5},
|
||||
HOWTO (R_DIR32, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"dir32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
/* {7}, */
|
||||
HOWTO (R_IMAGEBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"rva32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
false), /* pcrel_offset */
|
||||
{010},
|
||||
{011},
|
||||
{012},
|
||||
{013},
|
||||
{014},
|
||||
{015},
|
||||
{016},
|
||||
HOWTO (R_RELBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"8", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_RELWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"16", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_RELLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRBYTE, /* type */
|
||||
0, /* rightshift */
|
||||
0, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
8, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"DISP8", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x000000ff, /* src_mask */
|
||||
0x000000ff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRWORD, /* type */
|
||||
0, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"DISP16", /* name */
|
||||
true, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
PCRELOFFSET), /* pcrel_offset */
|
||||
HOWTO (R_PCRLONG, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
coff_i860_reloc, /* special_function */
|
||||
"DISP32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
PCRELOFFSET) /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Turn a howto into a reloc nunmber */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||
#define BADMAG(x) I860BADMAG(x)
|
||||
#define I860 1 /* Customize coffcode.h */
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = howto_table + (dst)->r_type;
|
||||
|
||||
/* For 860 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
|
||||
library. On some other COFF targets STYP_BSS is normally
|
||||
STYP_NOLOAD. */
|
||||
#define BSS_NOLOAD_IS_SHARED_LIBRARY
|
||||
|
||||
/* Compute the addend of a reloc. If the reloc is to a common symbol,
|
||||
the object file contains the value of the common symbol. By the
|
||||
time this is called, the linker may be using a different symbol
|
||||
from a different object file with a different value. Therefore, we
|
||||
hack wildly to locate the original symbol from this file so that we
|
||||
can make the correct adjustment. This macro sets coffsym to the
|
||||
symbol from the original file, and uses it to set the addend value
|
||||
correctly. If this is not a common symbol, the usual addend
|
||||
calculation is done, except that an additional tweak is needed for
|
||||
PC relative relocs.
|
||||
FIXME: This macro refers to symbols and asect; these are from the
|
||||
calling function, not the macro arguments. */
|
||||
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = - coffsym->native->u.syment.n_value; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && howto_table[reloc.r_type].pc_relative) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
|
||||
/* We use the special COFF backend linker. */
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i860_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *rel;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma *addendp;
|
||||
{
|
||||
|
||||
reloc_howto_type *howto;
|
||||
|
||||
howto = howto_table + rel->r_type;
|
||||
|
||||
if (howto->pc_relative)
|
||||
*addendp += sec->vma;
|
||||
|
||||
if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
|
||||
{
|
||||
/* This is a common symbol. The section contents include the
|
||||
size (sym->n_value) as an addend. The relocate_section
|
||||
function will be adding in the final value of the symbol. We
|
||||
need to subtract out the current size in order to get the
|
||||
correct result. */
|
||||
|
||||
BFD_ASSERT (h != NULL);
|
||||
|
||||
|
||||
/* I think we *do* want to bypass this. If we don't, I have seen some data
|
||||
parameters get the wrong relcation address. If I link two versions
|
||||
with and without this section bypassed and then do a binary comparison,
|
||||
the addresses which are different can be looked up in the map. The
|
||||
case in which this section has been bypassed has addresses which correspond
|
||||
to values I can find in the map */
|
||||
*addendp -= sym->n_value;
|
||||
}
|
||||
|
||||
/* If the output symbol is common (in which case this must be a
|
||||
relocateable link), we need to add in the final size of the
|
||||
common symbol. */
|
||||
if (h != NULL && h->root.type == bfd_link_hash_common)
|
||||
*addendp += h->root.u.c.size;
|
||||
|
||||
return howto;
|
||||
}
|
||||
|
||||
#define coff_rtype_to_howto coff_i860_rtype_to_howto
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
static const bfd_target *
|
||||
i3coff_object_p(a)
|
||||
bfd *a;
|
||||
{
|
||||
return coff_object_p(a);
|
||||
}
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
i860coff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-i860", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, i3coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
@@ -0,0 +1,683 @@
|
||||
/* BFD back-end for Intel 960 COFF files.
|
||||
Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define I960 1
|
||||
#define BADMAG(x) I960BADMAG(x)
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/i960.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h" /* to allow easier abstraction-breaking */
|
||||
|
||||
static bfd_reloc_status_type optcall_callback
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type coff_i960_relocate
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *coff_i960_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static boolean coff_i960_start_final_link
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static boolean coff_i960_relocate_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
||||
struct internal_reloc *, struct internal_syment *, asection **));
|
||||
static boolean coff_i960_adjust_symndx
|
||||
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
|
||||
struct internal_reloc *, boolean *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
/* The i960 does not support an MMU, so COFF_PAGE_SIZE can be
|
||||
arbitrarily small. */
|
||||
#define COFF_PAGE_SIZE 1
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
/* This is just like the usual CALC_ADDEND, but it includes the
|
||||
section VMA for PC relative relocs. */
|
||||
#ifndef CALC_ADDEND
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = 0; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
if (ptr && (reloc.r_type == 25 || reloc.r_type == 27)) \
|
||||
cache_ptr->addend += asect->vma; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CALLS 0x66003800 /* Template for 'calls' instruction */
|
||||
#define BAL 0x0b000000 /* Template for 'bal' instruction */
|
||||
#define BAL_MASK 0x00ffffff
|
||||
|
||||
static bfd_reloc_status_type
|
||||
optcall_callback (abfd, reloc_entry, symbol_in, data,
|
||||
input_section, ignore_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol_in;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *ignore_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
/* This item has already been relocated correctly, but we may be
|
||||
* able to patch in yet better code - done by digging out the
|
||||
* correct info on this symbol */
|
||||
bfd_reloc_status_type result;
|
||||
coff_symbol_type *cs = coffsymbol(symbol_in);
|
||||
|
||||
/* Don't do anything with symbols which aren't tied up yet,
|
||||
except move the reloc. */
|
||||
if (bfd_is_und_section (cs->symbol.section)) {
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
/* So the target symbol has to be of coff type, and the symbol
|
||||
has to have the correct native information within it */
|
||||
if ((bfd_asymbol_flavour(&cs->symbol) != bfd_target_coff_flavour)
|
||||
|| (cs->native == (combined_entry_type *)NULL))
|
||||
{
|
||||
/* This is interesting, consider the case where we're outputting coff
|
||||
from a mix n match input, linking from coff to a symbol defined in a
|
||||
bout file will cause this match to be true. Should I complain? This
|
||||
will only work if the bout symbol is non leaf. */
|
||||
*error_message =
|
||||
(char *) "uncertain calling convention for non-COFF symbol";
|
||||
result = bfd_reloc_dangerous;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (cs->native->u.syment.n_sclass)
|
||||
{
|
||||
case C_LEAFSTAT:
|
||||
case C_LEAFEXT:
|
||||
/* This is a call to a leaf procedure, replace instruction with a bal
|
||||
to the correct location. */
|
||||
{
|
||||
union internal_auxent *aux = &((cs->native+2)->u.auxent);
|
||||
int word = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
|
||||
int olf = (aux->x_bal.x_balntry - cs->native->u.syment.n_value);
|
||||
BFD_ASSERT(cs->native->u.syment.n_numaux==2);
|
||||
|
||||
/* We replace the original call instruction with a bal to
|
||||
the bal entry point - the offset of which is described in
|
||||
the 2nd auxent of the original symbol. We keep the native
|
||||
sym and auxents untouched, so the delta between the two
|
||||
is the offset of the bal entry point. */
|
||||
word = ((word + olf) & BAL_MASK) | BAL;
|
||||
bfd_put_32(abfd, word, (bfd_byte *) data + reloc_entry->address);
|
||||
}
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
case C_SCALL:
|
||||
/* This is a call to a system call, replace with a calls to # */
|
||||
BFD_ASSERT(0);
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
default:
|
||||
result = bfd_reloc_ok;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
|
||||
appear to correctly handle a reloc against a symbol defined in the
|
||||
same object file. It appears to simply discard such relocs, rather
|
||||
than adding their values into the object file. We handle this here
|
||||
by converting all relocs against defined symbols into relocs
|
||||
against the section symbol, when generating a relocateable output
|
||||
file.
|
||||
|
||||
Note that this function is only called if we are not using the COFF
|
||||
specific backend linker. It only does something when doing a
|
||||
relocateable link, which will almost certainly fail when not
|
||||
generating COFF i960 output, so this function is actually no longer
|
||||
useful. It was used before this target was converted to use the
|
||||
COFF specific backend linker. */
|
||||
|
||||
static bfd_reloc_status_type
|
||||
coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
asection *osec;
|
||||
|
||||
if (output_bfd == NULL)
|
||||
{
|
||||
/* Not generating relocateable output file. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
if (bfd_is_und_section (bfd_get_section (symbol)))
|
||||
{
|
||||
/* Symbol is not defined, so no need to worry about it. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
if (bfd_is_com_section (bfd_get_section (symbol)))
|
||||
{
|
||||
/* I don't really know what the right action is for a common
|
||||
symbol. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
/* Convert the reloc to use the section symbol. FIXME: This method
|
||||
is ridiculous. */
|
||||
osec = bfd_get_section (symbol)->output_section;
|
||||
if (coff_section_data (output_bfd, osec) != NULL
|
||||
&& coff_section_data (output_bfd, osec)->tdata != NULL)
|
||||
reloc_entry->sym_ptr_ptr =
|
||||
(asymbol **) coff_section_data (output_bfd, osec)->tdata;
|
||||
else
|
||||
{
|
||||
const char *sec_name;
|
||||
asymbol **syms, **sym_end;
|
||||
|
||||
sec_name = bfd_get_section_name (output_bfd, osec);
|
||||
syms = bfd_get_outsymbols (output_bfd);
|
||||
sym_end = syms + bfd_get_symcount (output_bfd);
|
||||
for (; syms < sym_end; syms++)
|
||||
{
|
||||
if (bfd_asymbol_name (*syms) != NULL
|
||||
&& (*syms)->value == 0
|
||||
&& strcmp ((*syms)->section->output_section->name,
|
||||
sec_name) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (syms >= sym_end)
|
||||
abort ();
|
||||
|
||||
reloc_entry->sym_ptr_ptr = syms;
|
||||
|
||||
if (coff_section_data (output_bfd, osec) == NULL)
|
||||
{
|
||||
osec->used_by_bfd =
|
||||
((PTR) bfd_zalloc (abfd,
|
||||
sizeof (struct coff_section_tdata)));
|
||||
if (osec->used_by_bfd == NULL)
|
||||
return bfd_reloc_overflow;
|
||||
}
|
||||
coff_section_data (output_bfd, osec)->tdata = (PTR) syms;
|
||||
}
|
||||
|
||||
/* Let bfd_perform_relocation do its thing, which will include
|
||||
stuffing the symbol addend into the object file. */
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
static reloc_howto_type howto_rellong =
|
||||
HOWTO ((unsigned int) R_RELLONG, 0, 2, 32,false, 0,
|
||||
complain_overflow_bitfield, coff_i960_relocate,"rellong", true,
|
||||
0xffffffff, 0xffffffff, 0);
|
||||
static reloc_howto_type howto_iprmed =
|
||||
HOWTO (R_IPRMED, 0, 2, 24,true,0, complain_overflow_signed,
|
||||
coff_i960_relocate, "iprmed ", true, 0x00ffffff, 0x00ffffff, 0);
|
||||
static reloc_howto_type howto_optcall =
|
||||
HOWTO (R_OPTCALL, 0,2,24,true,0, complain_overflow_signed,
|
||||
optcall_callback, "optcall", true, 0x00ffffff, 0x00ffffff, 0);
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_i960_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
case BFD_RELOC_I960_CALLJ:
|
||||
return &howto_optcall;
|
||||
case BFD_RELOC_32:
|
||||
case BFD_RELOC_CTOR:
|
||||
return &howto_rellong;
|
||||
case BFD_RELOC_24_PCREL:
|
||||
return &howto_iprmed;
|
||||
}
|
||||
}
|
||||
|
||||
/* The real code is in coffcode.h */
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
{ \
|
||||
reloc_howto_type *howto_ptr; \
|
||||
switch ((dst)->r_type) { \
|
||||
case 17: howto_ptr = &howto_rellong; break; \
|
||||
case 25: howto_ptr = &howto_iprmed; break; \
|
||||
case 27: howto_ptr = &howto_optcall; break; \
|
||||
default: howto_ptr = 0; break; \
|
||||
} \
|
||||
(cache_ptr)->howto = howto_ptr; \
|
||||
}
|
||||
|
||||
/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
|
||||
appear to correctly handle a reloc against a symbol defined in the
|
||||
same object file. It appears to simply discard such relocs, rather
|
||||
than adding their values into the object file. We handle this by
|
||||
converting all relocs against global symbols into relocs against
|
||||
internal symbols at the start of the section. This routine is
|
||||
called at the start of the linking process, and it creates the
|
||||
necessary symbols. */
|
||||
|
||||
static boolean
|
||||
coff_i960_start_final_link (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
bfd_size_type symesz = bfd_coff_symesz (abfd);
|
||||
asection *o;
|
||||
bfd_byte *esym;
|
||||
|
||||
if (! info->relocateable)
|
||||
return true;
|
||||
|
||||
esym = (bfd_byte *) bfd_malloc (symesz);
|
||||
if (esym == NULL)
|
||||
return false;
|
||||
|
||||
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
|
||||
return false;
|
||||
|
||||
for (o = abfd->sections; o != NULL; o = o->next)
|
||||
{
|
||||
struct internal_syment isym;
|
||||
|
||||
strncpy (isym._n._n_name, o->name, SYMNMLEN);
|
||||
isym.n_value = 0;
|
||||
isym.n_scnum = o->target_index;
|
||||
isym.n_type = T_NULL;
|
||||
isym.n_sclass = C_STAT;
|
||||
isym.n_numaux = 0;
|
||||
|
||||
bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
|
||||
|
||||
if (bfd_write (esym, symesz, 1, abfd) != symesz)
|
||||
{
|
||||
free (esym);
|
||||
return false;
|
||||
}
|
||||
|
||||
obj_raw_syment_count (abfd) += 1;
|
||||
}
|
||||
|
||||
free (esym);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* The reloc processing routine for the optimized COFF linker. */
|
||||
|
||||
static boolean
|
||||
coff_i960_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, syms, sections)
|
||||
bfd *output_bfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
struct internal_reloc *relocs;
|
||||
struct internal_syment *syms;
|
||||
asection **sections;
|
||||
{
|
||||
struct internal_reloc *rel;
|
||||
struct internal_reloc *relend;
|
||||
|
||||
rel = relocs;
|
||||
relend = rel + input_section->reloc_count;
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
long symndx;
|
||||
struct coff_link_hash_entry *h;
|
||||
struct internal_syment *sym;
|
||||
bfd_vma addend;
|
||||
bfd_vma val;
|
||||
reloc_howto_type *howto;
|
||||
bfd_reloc_status_type rstat = bfd_reloc_ok;
|
||||
boolean done;
|
||||
|
||||
symndx = rel->r_symndx;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
h = NULL;
|
||||
sym = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
sym = syms + symndx;
|
||||
}
|
||||
|
||||
if (sym != NULL && sym->n_scnum != 0)
|
||||
addend = - sym->n_value;
|
||||
else
|
||||
addend = 0;
|
||||
|
||||
switch (rel->r_type)
|
||||
{
|
||||
case 17: howto = &howto_rellong; break;
|
||||
case 25: howto = &howto_iprmed; break;
|
||||
case 27: howto = &howto_optcall; break;
|
||||
default:
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return false;
|
||||
}
|
||||
|
||||
val = 0;
|
||||
|
||||
if (h == NULL)
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
if (symndx == -1)
|
||||
{
|
||||
sec = bfd_abs_section_ptr;
|
||||
val = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sec = sections[symndx];
|
||||
val = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->n_value
|
||||
- sec->vma);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
sec = h->root.u.def.section;
|
||||
val = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
else if (! info->relocateable)
|
||||
{
|
||||
if (! ((*info->callbacks->undefined_symbol)
|
||||
(info, h->root.root.string, input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
done = false;
|
||||
|
||||
if (howto->type == R_OPTCALL && ! info->relocateable && symndx != -1)
|
||||
{
|
||||
int class;
|
||||
|
||||
if (h != NULL)
|
||||
class = h->class;
|
||||
else
|
||||
class = sym->n_sclass;
|
||||
|
||||
switch (class)
|
||||
{
|
||||
case C_NULL:
|
||||
/* This symbol is apparently not from a COFF input file.
|
||||
We warn, and then assume that it is not a leaf
|
||||
function. */
|
||||
if (! ((*info->callbacks->reloc_dangerous)
|
||||
(info,
|
||||
"uncertain calling convention for non-COFF symbol",
|
||||
input_bfd, input_section,
|
||||
rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
break;
|
||||
case C_LEAFSTAT:
|
||||
case C_LEAFEXT:
|
||||
/* This is a call to a leaf procedure; use the bal
|
||||
instruction. */
|
||||
{
|
||||
long olf;
|
||||
unsigned long word;
|
||||
|
||||
if (h != NULL)
|
||||
{
|
||||
BFD_ASSERT (h->numaux == 2);
|
||||
olf = h->aux[1].x_bal.x_balntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
bfd_byte *esyms;
|
||||
union internal_auxent aux;
|
||||
|
||||
BFD_ASSERT (sym->n_numaux == 2);
|
||||
esyms = (bfd_byte *) obj_coff_external_syms (input_bfd);
|
||||
esyms += (symndx + 2) * bfd_coff_symesz (input_bfd);
|
||||
bfd_coff_swap_aux_in (input_bfd, (PTR) esyms, sym->n_type,
|
||||
sym->n_sclass, 1, sym->n_numaux,
|
||||
(PTR) &aux);
|
||||
olf = aux.x_bal.x_balntry;
|
||||
}
|
||||
|
||||
word = bfd_get_32 (input_bfd,
|
||||
(contents
|
||||
+ (rel->r_vaddr - input_section->vma)));
|
||||
word = ((word + olf - val) & BAL_MASK) | BAL;
|
||||
bfd_put_32 (input_bfd,
|
||||
word,
|
||||
(contents
|
||||
+ (rel->r_vaddr - input_section->vma)));
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
case C_SCALL:
|
||||
BFD_ASSERT (0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! done)
|
||||
{
|
||||
if (howto->pc_relative)
|
||||
addend += input_section->vma;
|
||||
rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
||||
contents,
|
||||
rel->r_vaddr - input_section->vma,
|
||||
val, addend);
|
||||
}
|
||||
|
||||
switch (rstat)
|
||||
{
|
||||
default:
|
||||
abort ();
|
||||
case bfd_reloc_ok:
|
||||
break;
|
||||
case bfd_reloc_overflow:
|
||||
{
|
||||
const char *name;
|
||||
char buf[SYMNMLEN + 1];
|
||||
|
||||
if (symndx == -1)
|
||||
name = "*ABS*";
|
||||
else if (h != NULL)
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
|
||||
if (name == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! ((*info->callbacks->reloc_overflow)
|
||||
(info, name, howto->name, (bfd_vma) 0, input_bfd,
|
||||
input_section, rel->r_vaddr - input_section->vma)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Adjust the symbol index of any reloc against a global symbol to
|
||||
instead be a reloc against the internal symbol we created specially
|
||||
for the section. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static boolean
|
||||
coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
|
||||
bfd *obfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *ibfd;
|
||||
asection *sec;
|
||||
struct internal_reloc *irel;
|
||||
boolean *adjustedp;
|
||||
{
|
||||
struct coff_link_hash_entry *h;
|
||||
|
||||
*adjustedp = false;
|
||||
|
||||
h = obj_coff_sym_hashes (ibfd)[irel->r_symndx];
|
||||
if (h == NULL
|
||||
|| (h->root.type != bfd_link_hash_defined
|
||||
&& h->root.type != bfd_link_hash_defweak))
|
||||
return true;
|
||||
|
||||
irel->r_symndx = h->root.u.def.section->output_section->target_index - 1;
|
||||
*adjustedp = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define coff_start_final_link coff_i960_start_final_link
|
||||
|
||||
#define coff_relocate_section coff_i960_relocate_section
|
||||
|
||||
#define coff_adjust_symndx coff_i960_adjust_symndx
|
||||
|
||||
#define coff_bfd_reloc_type_lookup coff_i960_reloc_type_lookup
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target icoff_little_vec =
|
||||
{
|
||||
"coff-Intel-little", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
|
||||
|
||||
const bfd_target icoff_big_vec =
|
||||
{
|
||||
"coff-Intel-big", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
@@ -0,0 +1,203 @@
|
||||
/* BFD back-end for Motorola 68000 COFF binaries.
|
||||
Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/m68k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#ifndef LYNX_SPECIAL_FN
|
||||
#define LYNX_SPECIAL_FN 0
|
||||
#endif
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
|
||||
#ifndef COFF_PAGE_SIZE
|
||||
/* The page size is a guess based on ELF. */
|
||||
#define COFF_PAGE_SIZE 0x2000
|
||||
#endif
|
||||
|
||||
/* Clean up namespace. */
|
||||
#define m68kcoff_howto_table _bfd_m68kcoff_howto_table
|
||||
#define m68k_rtype2howto _bfd_m68kcoff_rtype2howto
|
||||
#define m68k_howto2rtype _bfd_m68kcoff_howto2rtype
|
||||
#define m68k_reloc_type_lookup _bfd_m68kcoff_reloc_type_lookup
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern reloc_howto_type m68kcoff_howto_table[];
|
||||
#else
|
||||
reloc_howto_type m68kcoff_howto_table[] =
|
||||
{
|
||||
HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "-32", true, 0xffffffff,0xffffffff, false),
|
||||
};
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#ifndef BADMAG
|
||||
#define BADMAG(x) M68KBADMAG(x)
|
||||
#endif
|
||||
#define M68 1 /* Customize coffcode.h */
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
#ifdef ONLY_DECLARE_RELOCS
|
||||
extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry));
|
||||
extern int m68k_howto2rtype PARAMS ((reloc_howto_type *));
|
||||
extern reloc_howto_type *m68k_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
#else
|
||||
void
|
||||
m68k_rtype2howto(internal, relocentry)
|
||||
arelent *internal;
|
||||
int relocentry;
|
||||
{
|
||||
switch (relocentry)
|
||||
{
|
||||
case R_RELBYTE: internal->howto = m68kcoff_howto_table + 0; break;
|
||||
case R_RELWORD: internal->howto = m68kcoff_howto_table + 1; break;
|
||||
case R_RELLONG: internal->howto = m68kcoff_howto_table + 2; break;
|
||||
case R_PCRBYTE: internal->howto = m68kcoff_howto_table + 3; break;
|
||||
case R_PCRWORD: internal->howto = m68kcoff_howto_table + 4; break;
|
||||
case R_PCRLONG: internal->howto = m68kcoff_howto_table + 5; break;
|
||||
case R_RELLONG_NEG: internal->howto = m68kcoff_howto_table + 6; break;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
m68k_howto2rtype (internal)
|
||||
reloc_howto_type *internal;
|
||||
{
|
||||
if (internal->pc_relative)
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_PCRLONG;
|
||||
case 16: return R_PCRWORD;
|
||||
case 8: return R_PCRBYTE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (internal->bitsize)
|
||||
{
|
||||
case 32: return R_RELLONG;
|
||||
case 16: return R_RELWORD;
|
||||
case 8: return R_RELBYTE;
|
||||
}
|
||||
}
|
||||
return R_RELLONG;
|
||||
}
|
||||
|
||||
reloc_howto_type *
|
||||
m68k_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
default: return NULL;
|
||||
case BFD_RELOC_8: return m68kcoff_howto_table + 0;
|
||||
case BFD_RELOC_16: return m68kcoff_howto_table + 1;
|
||||
case BFD_RELOC_CTOR:
|
||||
case BFD_RELOC_32: return m68kcoff_howto_table + 2;
|
||||
case BFD_RELOC_8_PCREL: return m68kcoff_howto_table + 3;
|
||||
case BFD_RELOC_16_PCREL: return m68kcoff_howto_table + 4;
|
||||
case BFD_RELOC_32_PCREL: return m68kcoff_howto_table + 5;
|
||||
/* FIXME: There doesn't seem to be a code for R_RELLONG_NEG. */
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
#endif /* not ONLY_DECLARE_RELOCS */
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) \
|
||||
m68k_rtype2howto(internal, (relocentry)->r_type)
|
||||
|
||||
#define SELECT_RELOC(external, internal) \
|
||||
external.r_type = m68k_howto2rtype(internal);
|
||||
|
||||
#define coff_bfd_reloc_type_lookup m68k_reloc_type_lookup
|
||||
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
m68kcoff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-m68k", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
#ifdef NAMES_HAVE_UNDERSCORE
|
||||
'_',
|
||||
#else
|
||||
0, /* leading underscore */
|
||||
#endif
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
@@ -0,0 +1,311 @@
|
||||
/* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define M88 1 /* Customize various include files */
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/m88k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
static bfd_reloc_status_type m88k_special_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
|
||||
static void reloc_processing
|
||||
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
static bfd_reloc_status_type
|
||||
m88k_special_reloc (abfd, reloc_entry, symbol, data,
|
||||
input_section, output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
|
||||
switch (howto->type)
|
||||
{
|
||||
case R_HVRT16:
|
||||
case R_LVRT16:
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
{
|
||||
/* This is a partial relocation, and we want to apply the
|
||||
relocation to the reloc entry rather than the raw data.
|
||||
Modify the reloc inplace to reflect what we now know. */
|
||||
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
bfd_vma output_base = 0;
|
||||
bfd_vma addr = reloc_entry->address;
|
||||
bfd_vma x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
|
||||
asection *reloc_target_output_section;
|
||||
long relocation = 0;
|
||||
|
||||
/* Work out which section the relocation is targetted at and the
|
||||
initial relocation command value. */
|
||||
|
||||
/* Get symbol value. (Common symbols are special.) */
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
relocation = 0;
|
||||
else
|
||||
relocation = symbol->value;
|
||||
|
||||
reloc_target_output_section = symbol->section->output_section;
|
||||
|
||||
/* Convert input-section-relative symbol value to absolute. */
|
||||
if (output_bfd)
|
||||
output_base = 0;
|
||||
else
|
||||
output_base = reloc_target_output_section->vma;
|
||||
|
||||
relocation += output_base + symbol->section->output_offset;
|
||||
|
||||
/* Add in supplied addend. */
|
||||
relocation += ((reloc_entry->addend << howto->bitsize) + x);
|
||||
|
||||
reloc_entry->addend = 0;
|
||||
|
||||
relocation >>= (bfd_vma) howto->rightshift;
|
||||
|
||||
/* Shift everything up to where it's going to be used */
|
||||
|
||||
relocation <<= (bfd_vma) howto->bitpos;
|
||||
|
||||
if (relocation)
|
||||
bfd_put_16 (abfd, relocation, (unsigned char *) data + addr);
|
||||
}
|
||||
|
||||
return bfd_reloc_ok;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
{
|
||||
/* This is a partial relocation, and we want to apply the
|
||||
relocation to the reloc entry rather than the raw data.
|
||||
Modify the reloc inplace to reflect what we now know. */
|
||||
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
HOWTO (R_PCR16L, /* type */
|
||||
02, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"PCR16L", /* name */
|
||||
false, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PCR26L, /* type */
|
||||
02, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
26, /* bitsize */
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"PCR26L", /* name */
|
||||
false, /* partial_inplace */
|
||||
0x03ffffff, /* src_mask */
|
||||
0x03ffffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_VRT16, /* type */
|
||||
00, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"VRT16", /* name */
|
||||
false, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_HVRT16, /* type */
|
||||
16, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"HVRT16", /* name */
|
||||
false, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_LVRT16, /* type */
|
||||
00, /* rightshift */
|
||||
1, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
16, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"LVRT16", /* name */
|
||||
false, /* partial_inplace */
|
||||
0x0000ffff, /* src_mask */
|
||||
0x0000ffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_VRT32, /* type */
|
||||
00, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
m88k_special_reloc, /* special_function */
|
||||
"VRT32", /* name */
|
||||
false, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
};
|
||||
|
||||
/* Code to turn an external r_type into a pointer to an entry in the
|
||||
above howto table. */
|
||||
static void
|
||||
rtype2howto (cache_ptr, dst)
|
||||
arelent *cache_ptr;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
if (dst->r_type >= R_PCR16L && dst->r_type <= R_VRT32)
|
||||
{
|
||||
cache_ptr->howto = howto_table + dst->r_type - R_PCR16L;
|
||||
}
|
||||
else
|
||||
{
|
||||
BFD_ASSERT (0);
|
||||
}
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst)
|
||||
|
||||
|
||||
/* Code to swap in the reloc offset */
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_16
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_16
|
||||
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent *relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol **symbols;
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
{
|
||||
relent->address = reloc->r_vaddr;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (((int) reloc->r_symndx) > 0)
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
relent->address -= section->vma;
|
||||
}
|
||||
|
||||
#define BADMAG(x) MC88BADMAG(x)
|
||||
#include "coffcode.h"
|
||||
|
||||
#undef coff_write_armap
|
||||
|
||||
const bfd_target m88kbcs_vec =
|
||||
{
|
||||
"coff-m88kbcs", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,27 @@
|
||||
/* BFD back-end for Apple et al PowerPC Mac "XCOFF" files.
|
||||
Copyright 1995 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM pmac_xcoff_vec
|
||||
#define TARGET_NAME "xcoff-powermac"
|
||||
|
||||
/* Tweak coffcode.h based on this being a PowerMac instead of RS/6000. */
|
||||
|
||||
#define POWERMAC
|
||||
|
||||
#include "coff-rs6000.c"
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,278 @@
|
||||
/* BFD back-end for Sparc COFF files.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/sparc.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
#define BADMAG(x) ((x).f_magic != SPARCMAGIC && (x).f_magic != LYNXCOFFMAGIC)
|
||||
|
||||
/* The page size is a guess based on ELF. */
|
||||
#define COFF_PAGE_SIZE 0x10000
|
||||
|
||||
enum reloc_type
|
||||
{
|
||||
R_SPARC_NONE = 0,
|
||||
R_SPARC_8, R_SPARC_16, R_SPARC_32,
|
||||
R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
|
||||
R_SPARC_WDISP30, R_SPARC_WDISP22,
|
||||
R_SPARC_HI22, R_SPARC_22,
|
||||
R_SPARC_13, R_SPARC_LO10,
|
||||
R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
|
||||
R_SPARC_PC10, R_SPARC_PC22,
|
||||
R_SPARC_WPLT30,
|
||||
R_SPARC_COPY,
|
||||
R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
|
||||
R_SPARC_RELATIVE,
|
||||
R_SPARC_UA32,
|
||||
R_SPARC_max
|
||||
};
|
||||
|
||||
#if 0
|
||||
static CONST char *CONST reloc_type_names[] =
|
||||
{
|
||||
"R_SPARC_NONE",
|
||||
"R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
|
||||
"R_SPARC_DISP8", "R_SPARC_DISP16", "R_SPARC_DISP32",
|
||||
"R_SPARC_WDISP30", "R_SPARC_WDISP22",
|
||||
"R_SPARC_HI22", "R_SPARC_22",
|
||||
"R_SPARC_13", "R_SPARC_LO10",
|
||||
"R_SPARC_GOT10", "R_SPARC_GOT13", "R_SPARC_GOT22",
|
||||
"R_SPARC_PC10", "R_SPARC_PC22",
|
||||
"R_SPARC_WPLT30",
|
||||
"R_SPARC_COPY",
|
||||
"R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT",
|
||||
"R_SPARC_RELATIVE",
|
||||
"R_SPARC_UA32",
|
||||
};
|
||||
#endif
|
||||
|
||||
/* This is stolen pretty directly from elf.c. */
|
||||
static bfd_reloc_status_type
|
||||
bfd_coff_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR,
|
||||
asection *, bfd *, char **));
|
||||
|
||||
static bfd_reloc_status_type
|
||||
bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
if (output_bfd != (bfd *) NULL
|
||||
&& (symbol->flags & BSF_SECTION_SYM) == 0
|
||||
&& reloc_entry->addend == 0)
|
||||
{
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
static reloc_howto_type coff_sparc_howto_table[] =
|
||||
{
|
||||
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_NONE", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_8", false,0,0x000000ff,true),
|
||||
HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_16", false,0,0x0000ffff,true),
|
||||
HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_32", false,0,0xffffffff,true),
|
||||
HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP8", false,0,0x000000ff,true),
|
||||
HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP16", false,0,0x0000ffff,true),
|
||||
HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP32", false,0,0x00ffffff,true),
|
||||
HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP30", false,0,0x3fffffff,true),
|
||||
HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_HI22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_13", false,0,0x00001fff,true),
|
||||
HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_LO10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT13", false,0,0x00001fff,true),
|
||||
HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_PC10, 0,2,10,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC10", false,0,0x000003ff,true),
|
||||
HOWTO(R_SPARC_PC22, 0,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC22", false,0,0x003fffff,true),
|
||||
HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_WPLT30", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_COPY", false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_GLOB_DAT",false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_JMP_SLOT",false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_RELATIVE",false,0,0x00000000,true),
|
||||
HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_UA32", false,0,0x00000000,true),
|
||||
};
|
||||
|
||||
struct coff_reloc_map {
|
||||
unsigned char bfd_reloc_val;
|
||||
unsigned char coff_reloc_val;
|
||||
};
|
||||
|
||||
static CONST struct coff_reloc_map sparc_reloc_map[] =
|
||||
{
|
||||
{ BFD_RELOC_NONE, R_SPARC_NONE, },
|
||||
{ BFD_RELOC_16, R_SPARC_16, },
|
||||
{ BFD_RELOC_8, R_SPARC_8 },
|
||||
{ BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
|
||||
{ BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
|
||||
{ BFD_RELOC_32, R_SPARC_32 },
|
||||
{ BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
|
||||
{ BFD_RELOC_HI22, R_SPARC_HI22 },
|
||||
{ BFD_RELOC_LO10, R_SPARC_LO10, },
|
||||
{ BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
|
||||
{ BFD_RELOC_SPARC22, R_SPARC_22 },
|
||||
{ BFD_RELOC_SPARC13, R_SPARC_13 },
|
||||
{ BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
|
||||
{ BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
|
||||
{ BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
|
||||
{ BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
|
||||
{ BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
|
||||
{ BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
|
||||
{ BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
|
||||
{ BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
|
||||
{ BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
|
||||
{ BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
|
||||
{ BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
|
||||
/* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
|
||||
};
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_sparc_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++)
|
||||
{
|
||||
if (sparc_reloc_map[i].bfd_reloc_val == code)
|
||||
return &coff_sparc_howto_table[(int) sparc_reloc_map[i].coff_reloc_val];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#define coff_bfd_reloc_type_lookup coff_sparc_reloc_type_lookup
|
||||
|
||||
static void
|
||||
rtype2howto (cache_ptr, dst)
|
||||
arelent *cache_ptr;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
BFD_ASSERT (dst->r_type < (unsigned int) R_SPARC_max);
|
||||
cache_ptr->howto = &coff_sparc_howto_table[dst->r_type];
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||
/* This is just like the standard one, except that we don't set up an
|
||||
addend for relocs against global symbols (otherwise linking objects
|
||||
created by -r fails), and we add in the reloc offset at the end. */
|
||||
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
|
||||
{ \
|
||||
coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
|
||||
if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
|
||||
coffsym = (obj_symbols (abfd) \
|
||||
+ (cache_ptr->sym_ptr_ptr - symbols)); \
|
||||
else if (ptr) \
|
||||
coffsym = coff_symbol_from (abfd, ptr); \
|
||||
if (coffsym != (coff_symbol_type *) NULL \
|
||||
&& coffsym->native->u.syment.n_scnum == 0) \
|
||||
cache_ptr->addend = 0; \
|
||||
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
|
||||
&& ptr->section != (asection *) NULL \
|
||||
&& (ptr->flags & BSF_GLOBAL) == 0) \
|
||||
cache_ptr->addend = - (ptr->section->vma + ptr->value); \
|
||||
else \
|
||||
cache_ptr->addend = 0; \
|
||||
cache_ptr->addend += reloc.r_offset; \
|
||||
}
|
||||
|
||||
/* Clear the r_spare field in relocs. */
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
|
||||
do { \
|
||||
dst->r_spare[0] = 0; \
|
||||
dst->r_spare[1] = 0; \
|
||||
} while (0)
|
||||
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
/* Enable Sparc-specific hacks in coffcode.h. */
|
||||
|
||||
#define COFF_SPARC
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
const bfd_target
|
||||
#ifdef TARGET_SYM
|
||||
TARGET_SYM =
|
||||
#else
|
||||
sparccoff_vec =
|
||||
#endif
|
||||
{
|
||||
#ifdef TARGET_NAME
|
||||
TARGET_NAME,
|
||||
#else
|
||||
"coff-sparc", /* name */
|
||||
#endif
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
/* Note that we allow an object file to be treated as a core file as well. */
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, coff_object_p},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
/* BFD back-end for Motorola 68000 COFF binaries having underscore with name.
|
||||
Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define TARGET_SYM m68kcoffun_vec
|
||||
#define TARGET_NAME "coff-m68k-un"
|
||||
|
||||
#define NAMES_HAVE_UNDERSCORE
|
||||
|
||||
/* define this to not have multiple copy of m68k_rtype2howto
|
||||
in the executable file */
|
||||
#define ONLY_DECLARE_RELOCS
|
||||
|
||||
/* This magic number indicates that the names have underscores.
|
||||
Other 68k magic numbers indicate that the names do not have
|
||||
underscores. */
|
||||
#define BADMAG(x) ((x).f_magic != MC68KBCSMAGIC)
|
||||
|
||||
#include "coff-m68k.c"
|
||||
@@ -0,0 +1,446 @@
|
||||
/* BFD back-end for WDC 65816 COFF binaries.
|
||||
Copyright 1995 Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain, <sac@cygnus.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "obstack.h"
|
||||
#include "libbfd.h"
|
||||
#include "bfdlink.h"
|
||||
#include "coff/w65.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
HOWTO (R_W65_ABS8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "abs8", true, 0x000000ff, 0x000000ff, false),
|
||||
HOWTO (R_W65_ABS16, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_W65_ABS24, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "abs24", true, 0x00ffffff, 0x00ffffff, false),
|
||||
HOWTO (R_W65_ABS8S8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, ">abs8", true, 0x000000ff, 0x000000ff, false),
|
||||
HOWTO (R_W65_ABS8S16, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "^abs8", true, 0x000000ff, 0x000000ff, false),
|
||||
HOWTO (R_W65_ABS16S8, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, ">abs16", true, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_W65_ABS16S16,1, 0, 16, false, 0, complain_overflow_bitfield, 0, "^abs16", true, 0x0000ffff, 0x0000ffff, false),
|
||||
HOWTO (R_W65_PCR8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "pcrel8", true, 0x000000ff, 0x000000ff, true),
|
||||
HOWTO (R_W65_PCR16, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, "pcrel16", true, 0x0000ffff, 0x0000ffff, true),
|
||||
HOWTO (R_W65_DP, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "dp", true, 0x000000ff, 0x000000ff, false),
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Turn a howto into a reloc number */
|
||||
|
||||
#define SELECT_RELOC(x,howto) \
|
||||
{ x.r_type = select_reloc(howto); }
|
||||
|
||||
#define BADMAG(x) (W65BADMAG(x))
|
||||
#define W65 1 /* Customize coffcode.h */
|
||||
#define __A_MAGIC_SET__
|
||||
|
||||
|
||||
/* Code to swap in the reloc */
|
||||
#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
|
||||
#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
|
||||
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
|
||||
dst->r_stuff[0] = 'S'; \
|
||||
dst->r_stuff[1] = 'C';
|
||||
|
||||
|
||||
static int
|
||||
select_reloc (howto)
|
||||
reloc_howto_type *howto;
|
||||
{
|
||||
return howto->type ;
|
||||
}
|
||||
|
||||
/* Code to turn a r_type into a howto ptr, uses the above howto table
|
||||
*/
|
||||
|
||||
static void
|
||||
rtype2howto (internal, dst)
|
||||
arelent *internal;
|
||||
struct internal_reloc *dst;
|
||||
{
|
||||
internal->howto = howto_table + dst->r_type - 1;
|
||||
}
|
||||
|
||||
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
|
||||
|
||||
|
||||
/* Perform any necessaru magic to the addend in a reloc entry */
|
||||
|
||||
|
||||
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
||||
cache_ptr->addend = ext_reloc.r_offset;
|
||||
|
||||
|
||||
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
|
||||
reloc_processing(relent, reloc, symbols, abfd, section)
|
||||
|
||||
static void
|
||||
reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
arelent * relent;
|
||||
struct internal_reloc *reloc;
|
||||
asymbol ** symbols;
|
||||
bfd * abfd;
|
||||
asection * section;
|
||||
{
|
||||
relent->address = reloc->r_vaddr;
|
||||
rtype2howto (relent, reloc);
|
||||
|
||||
if (((int) reloc->r_symndx) > 0)
|
||||
{
|
||||
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = (asymbol **)&(bfd_abs_symbol);
|
||||
}
|
||||
|
||||
|
||||
|
||||
relent->addend = reloc->r_offset;
|
||||
|
||||
relent->address -= section->vma;
|
||||
/* relent->section = 0;*/
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
h8300_reloc16_estimate(abfd, input_section, reloc, shrink, link_info)
|
||||
bfd *abfd;
|
||||
asection *input_section;
|
||||
arelent *reloc;
|
||||
unsigned int shrink;
|
||||
struct bfd_link_info *link_info;
|
||||
{
|
||||
bfd_vma value;
|
||||
bfd_vma dot;
|
||||
bfd_vma gap;
|
||||
|
||||
/* The address of the thing to be relocated will have moved back by
|
||||
the size of the shrink - but we don't change reloc->address here,
|
||||
since we need it to know where the relocation lives in the source
|
||||
uncooked section */
|
||||
|
||||
/* reloc->address -= shrink; conceptual */
|
||||
|
||||
bfd_vma address = reloc->address - shrink;
|
||||
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_MOVB2:
|
||||
case R_JMP2:
|
||||
shrink+=2;
|
||||
break;
|
||||
|
||||
/* Thing is a move one byte */
|
||||
case R_MOVB1:
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
if (value >= 0xff00)
|
||||
{
|
||||
|
||||
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||
possible 16 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* The place to relc moves back by one */
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
|
||||
break;
|
||||
/* This is the 24 bit branch which could become an 8 bitter,
|
||||
the relocation points to the first byte of the insn, not the
|
||||
actual data */
|
||||
|
||||
case R_JMPL1:
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
dot = input_section->output_section->vma +
|
||||
input_section->output_offset + address;
|
||||
|
||||
/* See if the address we're looking at within 127 bytes of where
|
||||
we are, if so then we can use a small branch rather than the
|
||||
jump we were going to */
|
||||
|
||||
gap = value - dot ;
|
||||
|
||||
if (-120 < (long)gap && (long)gap < 120 )
|
||||
{
|
||||
|
||||
/* Change the reloc type from 24bit, possible 8 to 8bit
|
||||
possible 32 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_JMP1:
|
||||
|
||||
value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
|
||||
|
||||
dot = input_section->output_section->vma +
|
||||
input_section->output_offset + address;
|
||||
|
||||
/* See if the address we're looking at within 127 bytes of where
|
||||
we are, if so then we can use a small branch rather than the
|
||||
jump we were going to */
|
||||
|
||||
gap = value - (dot - shrink);
|
||||
|
||||
|
||||
if (-120 < (long)gap && (long)gap < 120 )
|
||||
{
|
||||
|
||||
/* Change the reloc type from 16bit, possible 8 to 8bit
|
||||
possible 16 */
|
||||
reloc->howto = reloc->howto + 1;
|
||||
/* The place to relc moves back by one */
|
||||
|
||||
/* This will be two bytes smaller in the long run */
|
||||
shrink +=2 ;
|
||||
bfd_perform_slip(abfd, 2, input_section, address);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return shrink;
|
||||
}
|
||||
|
||||
|
||||
/* First phase of a relaxing link */
|
||||
|
||||
/* Reloc types
|
||||
large small
|
||||
R_MOVB1 R_MOVB2 mov.b with 16bit or 8 bit address
|
||||
R_JMP1 R_JMP2 jmp or pcrel branch
|
||||
R_JMPL1 R_JMPL_B8 24jmp or pcrel branch
|
||||
R_MOVLB1 R_MOVLB2 24 or 8 bit reloc for mov.b
|
||||
|
||||
*/
|
||||
|
||||
static void
|
||||
h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
|
||||
dst_ptr)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *link_info;
|
||||
struct bfd_link_order *link_order;
|
||||
arelent *reloc;
|
||||
bfd_byte *data;
|
||||
unsigned int *src_ptr;
|
||||
unsigned int *dst_ptr;
|
||||
{
|
||||
unsigned int src_address = *src_ptr;
|
||||
unsigned int dst_address = *dst_ptr;
|
||||
asection *input_section = link_order->u.indirect.section;
|
||||
|
||||
switch (reloc->howto->type)
|
||||
{
|
||||
case R_W65_ABS8:
|
||||
case R_W65_DP:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS8S8:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>= 8;
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS8S16:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>=16;
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS16:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
case R_W65_ABS16S8:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>= 8;
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
case R_W65_ABS16S16:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
gap >>= 16;
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_ABS24:
|
||||
{
|
||||
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
bfd_put_8 (abfd, gap>>16, data+dst_address+2);
|
||||
dst_address += 3;
|
||||
src_address += 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_PCR8:
|
||||
{
|
||||
int gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
|
||||
gap -= dot + 1;
|
||||
if (gap < -128 || gap > 127) {
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort();
|
||||
}
|
||||
bfd_put_8 (abfd, gap, data + dst_address);
|
||||
dst_address += 1;
|
||||
src_address += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_W65_PCR16:
|
||||
{
|
||||
bfd_vma gap = bfd_coff_reloc16_get_value (reloc, link_info,
|
||||
input_section);
|
||||
bfd_vma dot = link_order->offset
|
||||
+ dst_address
|
||||
+ link_order->u.indirect.section->output_section->vma;
|
||||
|
||||
|
||||
/* This wraps within the page, so ignore the relativeness, look at the
|
||||
high part */
|
||||
if ((gap & 0xf0000) != (dot & 0xf0000)) {
|
||||
if (! ((*link_info->callbacks->reloc_overflow)
|
||||
(link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
|
||||
reloc->howto->name, reloc->addend, input_section->owner,
|
||||
input_section, reloc->address)))
|
||||
abort();
|
||||
}
|
||||
|
||||
gap -= dot + 2;
|
||||
bfd_put_16 (abfd, gap, data + dst_address);
|
||||
dst_address += 2;
|
||||
src_address += 2;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("ignoring reloc %s\n", reloc->howto->name);
|
||||
break;
|
||||
|
||||
}
|
||||
*src_ptr = src_address;
|
||||
*dst_ptr = dst_address;
|
||||
|
||||
}
|
||||
|
||||
#define coff_reloc16_extra_cases h8300_reloc16_extra_cases
|
||||
#define coff_reloc16_estimate h8300_reloc16_estimate
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
|
||||
#undef coff_bfd_get_relocated_section_contents
|
||||
#undef coff_bfd_relax_section
|
||||
#define coff_bfd_get_relocated_section_contents \
|
||||
bfd_coff_reloc16_get_relocated_section_contents
|
||||
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
|
||||
|
||||
|
||||
|
||||
bfd_target w65_vec =
|
||||
{
|
||||
"coff-w65", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_LITTLE, /* data byte order is little */
|
||||
BFD_ENDIAN_LITTLE, /* header byte order is little */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
'_', /* leading char */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
@@ -0,0 +1,110 @@
|
||||
/* BFD back-end for we32k COFF files.
|
||||
Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Contributed by Brendan Kehoe (brendan@cs.widener.edu).
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "obstack.h"
|
||||
#include "coff/we32k.h"
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
static reloc_howto_type howto_table[] =
|
||||
{
|
||||
{0},
|
||||
{1},
|
||||
{2},
|
||||
{3},
|
||||
{4},
|
||||
{5},
|
||||
HOWTO(R_DIR32, 0, 2, 32, false, 0,complain_overflow_bitfield, 0, "dir32", true, 0xffffffff,0xffffffff, false),
|
||||
{7},
|
||||
{010},
|
||||
{011},
|
||||
{012},
|
||||
{013},
|
||||
{014},
|
||||
{015},
|
||||
{016},
|
||||
HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
|
||||
HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
|
||||
HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
|
||||
HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
|
||||
};
|
||||
|
||||
/* Turn a howto into a reloc nunmber */
|
||||
|
||||
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
|
||||
#define BADMAG(x) WE32KBADMAG(x)
|
||||
#define WE32K 1
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) \
|
||||
(cache_ptr)->howto = howto_table + (dst)->r_type;
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#define coff_write_armap bsd_write_armap
|
||||
|
||||
const bfd_target we32kcoff_vec =
|
||||
{
|
||||
"coff-we32k", /* name */
|
||||
bfd_target_coff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
bfd_generic_archive_p, _bfd_dummy_target},
|
||||
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
|
||||
bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (coff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
COFF_SWAP_TABLE,
|
||||
};
|
||||
Loaded 100 of 4322 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user