mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Add linker data for strings, and deduplicate them
For references to addresses of constant strings, we make an entry in reloc.CODE and configure the relocation type to say it points at a memory address. (At least I think this is right, I can't test it yet!) The same info can also be used for de-duplication. It turns out we don't need reloc.DATA. I had misunderstood it. The use case for that would be constant nested data structures, where constant data would contain pointers to other constant data. I don't think we're doing this in Roc at all, but not sure.
This commit is contained in:
parent
2f0296a5fa
commit
38d9fc5bbd
5 changed files with 113 additions and 65 deletions
|
@ -303,11 +303,12 @@ impl Serialize for WasmObjectSymbol {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum DataSymbol {
|
||||
Defined {
|
||||
name: String,
|
||||
index: u32,
|
||||
offset: u32,
|
||||
segment_index: u32,
|
||||
segment_offset: u32,
|
||||
size: u32,
|
||||
},
|
||||
Imported {
|
||||
|
@ -320,14 +321,14 @@ impl Serialize for DataSymbol {
|
|||
match self {
|
||||
Self::Defined {
|
||||
name,
|
||||
index,
|
||||
offset,
|
||||
segment_index,
|
||||
segment_offset,
|
||||
size,
|
||||
} => {
|
||||
buffer.encode_u32(name.len() as u32);
|
||||
buffer.append_slice(name.as_bytes());
|
||||
buffer.encode_u32(*index);
|
||||
buffer.encode_u32(*offset);
|
||||
buffer.encode_u32(*segment_index);
|
||||
buffer.encode_u32(*segment_offset);
|
||||
buffer.encode_u32(*size);
|
||||
}
|
||||
Self::Imported { name } => {
|
||||
|
@ -367,6 +368,13 @@ impl SymInfo {
|
|||
info: SymInfoFields::Function(linking_symbol),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn for_data(data_symbol: DataSymbol) -> Self {
|
||||
SymInfo {
|
||||
flags: 0,
|
||||
info: SymInfoFields::Data(data_symbol),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for SymInfo {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue