Commit b260061
committed
[lld] macho: Support section branch relocations, including the 1-byte form
I noticed that we had a hardcoded value of 4 for the pcrel section relocations,
which seems like an issue given that we recently added support for 1-byte
branch relocations in llvm#164439. The
code included an assert that the relevant relocation had the BYTE4 attribute,
but that is actually not enough to use a hardcoded value of 4: we need to
assert that the *other* `BYTE<n>` attributes are not set either.
However, since we did not support local branch relocations, that doesn't seem
to have mattered in practice. That said, local branch relocations can be
emitted by compilers, and ld64 does handle the 4-byte version of them, so I've
added support for it here.
ld64 actually seems to reject 1-byte section relocations, so the questionable
code is actually probably fine (minus the incorrect assert). So we have two
options: add an equivalent check in LLD, or just support 1-byte local branch
relocations. Supporting it actually requires less code, so I've gone with that
option here.1 parent 01227ab commit b260061
File tree
3 files changed
+21
-4
lines changed- lld
- MachO
- Arch
- test/MachO
3 files changed
+21
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
597 | | - | |
598 | | - | |
| 597 | + | |
| 598 | + | |
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
| |||
33 | 42 | | |
34 | 43 | | |
35 | 44 | | |
36 | | - | |
| 45 | + | |
37 | 46 | | |
38 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
39 | 51 | | |
40 | 52 | | |
41 | 53 | | |
| |||
48 | 60 | | |
49 | 61 | | |
50 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
51 | 67 | | |
52 | 68 | | |
53 | 69 | | |
| |||
0 commit comments