This repository was archived by the owner on Nov 10, 2022. It is now read-only.
Commit 3c1a130
committed
Use lld as the linker and add a linker script
This patch aims only to add linker script semantics and should retain
linking equivalence. It does not aim to produce address for address
equality with `ld`. Functional changes in linker output should follow in
additional patches.
Before this patch, `ld` produced the following:
```
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000002898 0x0000000000002898 R 0x1000
LOAD 0x0000000000003000 0x0000000000003000 0x0000000000003000
0x00000000000340ae 0x00000000000340ae RWE 0x1000
LOAD 0x0000000000038000 0x0000000000038000 0x0000000000038000
0x0000000000007520 0x0000000000007520 R 0x1000
LOAD 0x000000000003f728 0x0000000000040728 0x0000000000040728
0x00000000000018d8 0x00000000000020d8 RW 0x1000
DYNAMIC 0x00000000000408c0 0x00000000000418c0 0x00000000000418c0
0x0000000000000110 0x0000000000000110 RW 0x8
NOTE 0x0000000000000238 0x0000000000000238 0x0000000000000238
0x0000000000000024 0x0000000000000024 R 0x4
GNU_EH_FRAME 0x000000000003c638 0x000000000003c638 0x000000000003c638
0x0000000000000a04 0x0000000000000a04 R 0x4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
GNU_RELRO 0x000000000003f728 0x0000000000040728 0x0000000000040728
0x00000000000018d8 0x00000000000018d8 R 0x1
Section to Segment mapping:
Segment Sections...
00 .note.gnu.build-id .gnu.hash .dynsym .dynstr .rela.dyn
01 .init .text
02 .rodata .eh_frame_hdr .eh_frame
03 .data.rel.ro .dynamic .got .bss
04 .dynamic
05 .note.gnu.build-id
06 .eh_frame_hdr
07
08 .data.rel.ro .dynamic .got
```
After this patch, `lld` + linker script produce the following:
```
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000003830 0x0000000000003830 R 0x1000
LOAD 0x0000000000004000 0x0000000000004000 0x0000000000004000
0x00000000000340ae 0x00000000000340ae RWE 0x1000
LOAD 0x0000000000039000 0x0000000000039000 0x0000000000039000
0x0000000000007464 0x0000000000007464 R 0x1000
LOAD 0x0000000000041000 0x0000000000041000 0x0000000000041000
0x0000000000001920 0x0000000000002800 RW 0x1000
DYNAMIC 0x0000000000042198 0x0000000000042198 0x0000000000042198
0x00000000000000d0 0x00000000000000d0 RW 0x8
NOTE 0x0000000000001000 0x0000000000001000 0x0000000000001000
0x0000000000000018 0x0000000000000018 R 0x4
GNU_EH_FRAME 0x000000000003d42c 0x000000000003d42c 0x000000000003d42c
0x0000000000000a04 0x0000000000000a04 R 0x4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x0
GNU_RELRO 0x0000000000041000 0x0000000000041000 0x0000000000041000
0x0000000000001920 0x0000000000002000 R 0x1
Section to Segment mapping:
Segment Sections...
00 .note.gnu.build-id .gnu.hash .dynsym .dynstr .rela.dyn
01 .init .text
02 .rodata .eh_frame_hdr .eh_frame
03 .data.rel.ro .dynamic .got .bss
04 .dynamic
05 .note.gnu.build-id
06 .eh_frame_hdr
07
08 .data.rel.ro .dynamic .got
```
Signed-off-by: Nathaniel McCallum <[email protected]>1 parent f7f2e60 commit 3c1a130
3 files changed
+66
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
7 | 13 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
0 commit comments