let's say I have a top-level foo : List (List Str)
that's a giant literal, and we want to compile that entire thing to be stored in the readonly section of the binary
how do the internal pointers in there work? are there relocations or something?
basically I'm trying to get a sense for:
Yeah, relocation for each
Basically the relocation tells the loader to add the segment offset once loaded in memory to the pointer
Requires adding them to the dynamic relocation list
Also, shouldn't matter if it is top level or not. Either way we would probably want to generate this structure.
What is the general thought or goal?
Side note: this is the main case that the surgical linker doesn't support because it is annoying and adds a lot more binary shifting
I'm thinking about how canonicalization's data structures should change in order to make it cache-able
and one of the things that occurred to me is that when we're translating (for example) strings into the final format that will end up in the binary (e.g. replacing \n
in the strings actual newline bytes), we should probably just cut to the chase and store it in the format that the actual binary wants
so when we're reading it out of cache, we can just copy the bytes over as directly as possible
and same for lists, nested lists, etc.
For the pointers, you won't know the correct offsets yet. So I don't think you can do much.
ah interesting
so the offsets have to be based on how big the final header in the binary ends up being I guess?
I need to double check the exact anchor point, but it is an absolute value dependent on where the final pointee lands in the binary.
One thing I am a bit confused by with your goals, if using llvm, we don't control the relocations and such. So I'm not exactly sure what level you are trying to plan and work at.
I'm just trying to figure out what representation we want to cache
like what bytes to put on disk, so they're maximally useful when we read them back again because the file was cached
I see
Yeah, I mean could definitely dump relative offset based Bytes and then patch just the relative offset. As needed when continuing the build pipeline. Would be similar to catching in object files
that makes sense! :thumbs_up:
I guess we could cache where the relative offsets are, to make them easier to patch
Last updated: Jul 06 2025 at 12:14 UTC