Skip to content

Commit d8d8620

Browse files
committed
update
1 parent e7a55da commit d8d8620

6 files changed

Lines changed: 82 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
112112
- MOVW `UABS` / `SABS` / `PREL` families
113113
- starter TLS instruction-form relocation ID support (`TLSGD`, `TLSLD`, `TLSDESC`) with strict unsupported apply-path handling for non-implemented descriptor semantics
114114
- host-runtime-backed AArch64 TLS data relocation values for `TLS_DTPMOD`, `TLS_DTPREL`, and `TLS_TPREL` in non-shared links using deterministic TLS layout metadata
115+
- AArch64 TLSLE/TLSLD low12 offset instruction relocations (`ADD`/`LDST64`/`LDST128`) now route through host-runtime TLS offset helpers in non-shared links
115116
- host runtime shared-object ingestion now returns `ERR_INVALID_FORMAT` for unknown/unsupported shared-object payloads instead of silently succeeding
117+
- host runtime shared-object symbol ingest now validates target/ABI compatibility and shared-file kind before symbol ingestion (`ELF ET_DYN`, Windows PE DLL/COFF machine, Mach-O dylib CPU type)
116118

117119
### Changed
118120

@@ -129,6 +131,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
129131
- Host linker-script runtime no longer silently accepts unknown linker-script directives.
130132
- Host linker compatibility/no-op flag handling now surfaces diagnostics instead of silent acceptance.
131133
- Dust-built linker relocation parsing/validation now accepts and processes a broader AArch64 ELF relocation set (including MOVW and TLS starter forms) instead of rejecting them during ingest.
134+
- Dust-built linker relocation apply path no longer blanket-rejects all AArch64 TLS instruction-family relocations; TLSLE/TLSLD low12 offset forms now apply in non-shared links via host TLS offset helpers.
135+
- Host shared-object symbol ingest no longer accepts cross-target or wrong-kind binaries as valid shared inputs during symbol-ingest resolution.
132136

133137
## [0.1.0] - 2026-02-12
134138

Cargo.lock

Lines changed: 15 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ This repository contains:
5050
- starter TLS relocation families:
5151
- instruction/descriptor forms (`TLSGD`, `TLSLD`, `TLSDESC`) recognized/validated with strict `ERR_NOT_IMPLEMENTED_YET` application for unsupported TLS descriptor semantics
5252
- data relocs (`TLS_DTPMOD` / `TLS_DTPREL` / `TLS_TPREL`) use host-runtime TLS layout metadata helpers for non-shared links
53+
- TLSLE/TLSLD low12 offset instruction forms (`*_ADD_*_LO12_NC`, `*_LDST64_*_LO12_NC`, `*_LDST128_*_LO12_NC`) now reuse host-runtime TLS offset helpers in non-shared links
5354
- host runtime shared-object symbol ingest now returns `ERR_INVALID_FORMAT` for unknown/unsupported shared object payloads (no silent success on unknown format)
55+
- host runtime shared-object symbol ingest now validates target/ABI compatibility and shared-file kind before symbol ingest (ELF `ET_DYN`, Windows PE DLL/COFF machine, Mach-O dylib CPU type)
5456
- architecture-correct output header stamping in ELF/PE/Mach-O writers based on resolved target
5557
- real PE compatibility-state wiring for `/NOENTRY`, `/DYNAMICBASE`, `/NXCOMPAT`, `/LARGEADDRESSAWARE`
5658
- broader soft-compatibility handling for common ld/lld/lld-link metadata/profiling flag families (`--warn-*`, `--time-trace*`, `--lto-*`, `/GUARD:*`, `/TIMESTAMP:*`, `/MERGE:*`, `/SECTION:*`)

crates/dust_codegen/src/host_runtime_shim.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ const OBJECT_FORMAT_MACHO64: u32 = 3;
9999
const COFF_MACHINE_X86_64: u16 = 0x8664;
100100
const COFF_MACHINE_X86: u16 = 0x14c;
101101
const COFF_MACHINE_AARCH64: u16 = 0xaa64;
102+
const IMAGE_FILE_DLL: u16 = 0x2000;
102103
const MACH_CPU_X86_64: u32 = 0x0100_0007;
103104
const MACH_CPU_ARM64: u32 = 0x0100_000c;
105+
const MH_DYLIB: u32 = 0x6;
104106

105107
const R_X86_64_NONE: u32 = 0;
106108
const R_X86_64_64: u32 = 1;
@@ -3067,6 +3069,23 @@ fn ingest_shared_elf_symbols(state: &mut LinkerState, raw: &[u8]) -> u32 {
30673069
if raw.get(4).copied().unwrap_or(0) != 2 || raw.get(5).copied().unwrap_or(0) != 1 {
30683070
return ERR_INVALID_FORMAT;
30693071
}
3072+
if target_is_windows(state.target) || target_is_macos(state.target) {
3073+
return ERR_UNSUPPORTED_TARGET;
3074+
}
3075+
let e_type = match read_u16_le_at(raw, 16) {
3076+
Some(v) => v,
3077+
None => return ERR_INVALID_FORMAT,
3078+
};
3079+
if e_type != ET_DYN {
3080+
return ERR_INVALID_FORMAT;
3081+
}
3082+
let e_machine = match read_u16_le_at(raw, 18) {
3083+
Some(v) => v,
3084+
None => return ERR_INVALID_FORMAT,
3085+
};
3086+
if e_machine != target_elf_machine(state.target) {
3087+
return ERR_UNSUPPORTED_TARGET;
3088+
}
30703089

30713090
let shoff = match read_u64_le_at(raw, 40) {
30723091
Some(v) => v as usize,
@@ -3178,6 +3197,9 @@ fn ingest_shared_pe_symbols(state: &mut LinkerState, raw: &[u8]) -> u32 {
31783197
if raw.len() < 0x40 || raw.get(0).copied() != Some(b'M') || raw.get(1).copied() != Some(b'Z') {
31793198
return ERR_INVALID_FORMAT;
31803199
}
3200+
if !target_is_windows(state.target) {
3201+
return ERR_UNSUPPORTED_TARGET;
3202+
}
31813203
let pe_offset = match read_u32_le_at(raw, 0x3c) {
31823204
Some(v) => v as usize,
31833205
None => return ERR_INVALID_FORMAT,
@@ -3190,6 +3212,13 @@ fn ingest_shared_pe_symbols(state: &mut LinkerState, raw: &[u8]) -> u32 {
31903212
}
31913213

31923214
let coff_off = pe_offset + 4;
3215+
let machine = match read_u16_le_at(raw, coff_off) {
3216+
Some(v) => v,
3217+
None => return ERR_INVALID_FORMAT,
3218+
};
3219+
if machine != target_pe_machine(state.target) {
3220+
return ERR_UNSUPPORTED_TARGET;
3221+
}
31933222
let section_count = match read_u16_le_at(raw, coff_off + 2) {
31943223
Some(v) => v as usize,
31953224
None => return ERR_INVALID_FORMAT,
@@ -3202,6 +3231,13 @@ fn ingest_shared_pe_symbols(state: &mut LinkerState, raw: &[u8]) -> u32 {
32023231
if optional_off + optional_size > raw.len() {
32033232
return ERR_INVALID_FORMAT;
32043233
}
3234+
let characteristics = match read_u16_le_at(raw, coff_off + 18) {
3235+
Some(v) => v,
3236+
None => return ERR_INVALID_FORMAT,
3237+
};
3238+
if characteristics & IMAGE_FILE_DLL == 0 {
3239+
return ERR_INVALID_FORMAT;
3240+
}
32053241

32063242
let magic = match read_u16_le_at(raw, optional_off) {
32073243
Some(v) => v,
@@ -3282,13 +3318,19 @@ fn ingest_shared_coff_symbols(state: &mut LinkerState, raw: &[u8]) -> u32 {
32823318
if raw.len() < 20 {
32833319
return ERR_INVALID_FORMAT;
32843320
}
3321+
if !target_is_windows(state.target) {
3322+
return ERR_UNSUPPORTED_TARGET;
3323+
}
32853324
let machine = match read_u16_le_at(raw, 0) {
32863325
Some(v) => v,
32873326
None => return ERR_INVALID_FORMAT,
32883327
};
32893328
if machine != COFF_MACHINE_X86_64 && machine != COFF_MACHINE_AARCH64 {
32903329
return ERR_UNSUPPORTED_TARGET;
32913330
}
3331+
if machine != target_pe_machine(state.target) {
3332+
return ERR_UNSUPPORTED_TARGET;
3333+
}
32923334
let ptr_symtab = match read_u32_le_at(raw, 8) {
32933335
Some(v) => v as usize,
32943336
None => return ERR_INVALID_FORMAT,
@@ -3345,6 +3387,9 @@ fn ingest_shared_macho_symbols(state: &mut LinkerState, raw: &[u8]) -> u32 {
33453387
if raw.len() < 32 {
33463388
return ERR_INVALID_FORMAT;
33473389
}
3390+
if !target_is_macos(state.target) {
3391+
return ERR_UNSUPPORTED_TARGET;
3392+
}
33483393
let magic = match read_u32_le_at(raw, 0) {
33493394
Some(v) => v,
33503395
None => return ERR_INVALID_FORMAT,
@@ -3360,6 +3405,17 @@ fn ingest_shared_macho_symbols(state: &mut LinkerState, raw: &[u8]) -> u32 {
33603405
if cpu_type != MACH_CPU_X86_64 && cpu_type != MACH_CPU_ARM64 {
33613406
return ERR_UNSUPPORTED_TARGET;
33623407
}
3408+
let (target_cpu_type, _) = target_macho_cpu_type(state.target);
3409+
if cpu_type != target_cpu_type {
3410+
return ERR_UNSUPPORTED_TARGET;
3411+
}
3412+
let file_type = match read_u32_le_at(raw, 12) {
3413+
Some(v) => v,
3414+
None => return ERR_INVALID_FORMAT,
3415+
};
3416+
if file_type != MH_DYLIB {
3417+
return ERR_INVALID_FORMAT;
3418+
}
33633419

33643420
let ncmds = match read_u32_le_at(raw, 16) {
33653421
Some(v) => v as usize,

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The following existing files remain part of the repository history and analysis
2626
## Release Notes
2727

2828
Compiler change history is tracked in `../CHANGELOG.md`.
29-
Recent host-link/runtime parity work for Dust-built tooling is summarized in `status_and_limitations.md`, including stricter linker-script semantics, expanded target alias coverage, compatibility-state behavior wiring, and newer AArch64 ELF relocation/TLS starter coverage used by Dust-built `dustlink`.
29+
Recent host-link/runtime parity work for Dust-built tooling is summarized in `status_and_limitations.md`, including stricter linker-script semantics, expanded target alias coverage, compatibility-state behavior wiring, newer AArch64 ELF relocation/TLS coverage (including TLSLE/TLSLD low12 offset forms), and stricter shared-object target/ABI validation used by Dust-built `dustlink`.
3030

3131
## Normative Language Reference
3232

docs/status_and_limitations.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- MOVW `UABS` / `SABS` / `PREL` families
3838
- starter TLS instruction/data relocations for `TLSGD` / `TLSLD` / `TLSDESC` plus `TLS_DTPMOD` / `TLS_DTPREL` / `TLS_TPREL`
3939
- host linker runtime now computes AArch64 TLS data relocation values (`TLS_DTPMOD`, `TLS_DTPREL`, `TLS_TPREL`) for non-shared links using a deterministic synthesized TLS layout derived from object TLS sections
40+
- Dust linker relocation apply path now also supports AArch64 TLSLE/TLSLD low12 offset instruction relocations (`ADD`/`LDST64`/`LDST128`) in non-shared links by reusing host-runtime TLS offset helpers
4041
- host linker output writers now emit architecture-correct machine/cpu identifiers for ELF/PE/Mach-O outputs
4142
- host linker PE output now applies `/NOENTRY`, `/DYNAMICBASE`, `/NXCOMPAT`, and `/LARGEADDRESSAWARE` to emitted header fields (entrypoint/characteristics)
4243
- host linker compatibility handling now includes broader soft-compatibility ld/lld/lld-link families (`--warn-*`, `--time-trace*`, `--lto-*`, `/GUARD:*`, `/TIMESTAMP:*`, `/MERGE:*`, `/SECTION:*`)
@@ -54,8 +55,11 @@
5455
- `--emit-relocs` (map-row relocation reporting)
5556
- `--print-gc-sections` (GC drop diagnostics)
5657
- host object ingestion now uses refined machine-aware COFF and Mach-O relocation-kind mapping during relocation record ingestion
58+
- host shared-object symbol ingest now enforces target/ABI/file-kind checks before symbol ingestion (`ELF ET_DYN` + target machine, Windows PE DLL/COFF machine, Mach-O dylib target CPU)
5759
- full AArch64 ELF TLS descriptor / TLS instruction-family semantics are not complete yet (current coverage includes ingest/validation, bitfield patching for non-TLS instruction forms, and host-backed TLS data reloc math, but not exhaustive TLSDESC/GOT/TLS relaxation behavior parity)
60+
- AArch64 TLS instruction-family coverage is still partial: TLSLE/TLSLD low12 offset forms now apply in non-shared links, but TLSDESC/TLSGD/TLSLD descriptor-sequence semantics and relaxations remain incomplete
5861
- shared-object handling remains primarily symbol-ingest oriented rather than full dynamic-linker semantic parity (though unknown shared-object formats now fail instead of silently succeeding)
62+
- shared-object handling remains primarily symbol-ingest oriented rather than full dynamic-linker semantic parity (now with stricter target/ABI/file-kind rejection before ingest)
5963

6064
## Important Mismatches to Track
6165

0 commit comments

Comments
 (0)