-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.linking
Milestone
Description
//! empty.zig
pub fn main() void {}
Build with old and new self-hosted ELF linkers, and compare the section headers:
$ zig build-exe empty.zig -fno-new-linker
$ readelf -WS empty
There are 28 section headers, starting at offset 0x2b0:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .rodata PROGBITS 0000000001001000 0c5000 003540 00 A 0 0 64
[ 2] .rodata.cst PROGBITS 0000000001004540 0c8540 0007c0 04 AM 0 0 32
[ 3] .rodata.str PROGBITS 0000000001004d00 0c8d00 000007 01 AMS 0 0 1
[ 4] .eh_frame X86_64_UNWIND 0000000001004d08 0c8d08 014978 00 A 0 0 8
[ 5] .eh_frame_hdr PROGBITS 0000000001019680 0dd680 000008 00 A 0 0 4
[ 6] .text PROGBITS 000000000101a000 5fc000 1a123a 00 AX 0 0 16
[ 7] .tdata PROGBITS 00000000011bc000 03a000 000008 00 WAT 0 0 4
[ 8] .tbss NOBITS 00000000011bc008 000000 000008 00 WAT 0 0 8
[ 9] .data PROGBITS 00000000011bd000 03b000 005298 00 WA 0 0 4096
[10] .data.rel.ro PROGBITS 00000000011c22a0 0402a0 0110f1 00 WA 0 0 32
[11] .bss NOBITS 00000000011d33c0 000000 001040 00 WA 0 0 64
[12] .debug_abbrev PROGBITS 0000000000000000 0017e0 0008df 00 0 0 1
[13] .debug_aranges PROGBITS 0000000000000000 0062c0 005d20 00 0 0 16
[14] .debug_info PROGBITS 0000000000000000 3b9385 0f323f 00 0 0 1
[15] .debug_line PROGBITS 0000000000000000 4bf455 084ebe 00 0 0 1
[16] .debug_line_str PROGBITS 0000000000000000 0032fe 001410 01 MS 0 0 1
[17] .debug_loc PROGBITS 0000000000000000 5707fd 0680bc 00 0 0 1
[18] .debug_loclists PROGBITS 0000000000000000 0015aa 000040 00 0 0 1
[19] .debug_pubnames PROGBITS 0000000000000000 02429c 003838 00 0 0 1
[20] .debug_pubtypes PROGBITS 0000000000000000 004dbe 000c25 00 0 0 1
[21] .debug_ranges PROGBITS 0000000000000000 028d91 00c520 00 0 0 1
[22] .debug_rnglists PROGBITS 0000000000000000 01bf3a 00628a 00 0 0 1
[23] .debug_str PROGBITS 0000000000000000 070a8c 03eea7 01 MS 0 0 1
[24] .comment PROGBITS 0000000000000000 039466 00001d 01 MS 0 0 1
[25] .symtab SYMTAB 0000000000000000 0e58b8 014c28 18 27 3543 8
[26] .shstrtab STRTAB 0000000000000000 03948c 00013b 01 0 0 1
[27] .strtab STRTAB 0000000000000000 101398 015e6a 01 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
D (mbind), l (large), p (processor specific)
$ ./stage4/bin/zig build-exe empty.zig -fnew-linker
$ readelf -WS empty
There are 8 section headers, starting at offset 0x208:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .symtab SYMTAB 0000000000000000 022000 0174c0 18 3 3976 8
[ 2] .shstrtab STRTAB 0000000000000000 001000 001000 01 0 0 4096
[ 3] .strtab STRTAB 0000000000000000 003000 017000 01 0 0 4096
[ 4] .rodata PROGBITS 000000000101d000 01d000 005000 00 A 0 0 4096
[ 5] .text PROGBITS 0000000001077000 077000 2c5000 00 AX 0 0 4096
[ 6] .data PROGBITS 00000000019cf000 9cf000 027000 00 WA 0 0 4096
[ 7] .tdata PROGBITS 00000000019f6000 9f6000 001000 00 WAT 0 0 4096
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
D (mbind), l (large), p (processor specific)
$
The new linker has not emitted any DWARF sections (.debug_info
etc).
It should emit the .debug_*
sections when DWARF debug information is enabled (which it is by default in Debug mode).
CFI
DWARF's .debug_frame
section, which holds Call Frame Information (CFI) required for (among other things) stack unwinding, is a little different. When using the self-hosted backend, CFI (CIEs and FDEs) should be emitted into:
.eh_frame
, if-fno-unwind-tables
is not passed.debug_frame
, if-fno-unwind-tables
is passed and debug information is enabled- Not emitted, if
-fno-unwind-tables
is passed and debug information is being stripped
A .eh_frame_hdr
section should be emitted if there are any input .eh_frame
sections, unless --no-eh-frame-hdr
is passed.
Metadata
Metadata
Assignees
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.linking