Skip to content

Allow access to section contents while building#367

Merged
philipc merged 1 commit intogimli-rs:masterfrom
alexcrichton:section-data
Aug 28, 2021
Merged

Allow access to section contents while building#367
philipc merged 1 commit intogimli-rs:masterfrom
alexcrichton:section-data

Conversation

@alexcrichton
Copy link
Copy Markdown
Contributor

This commit adds Section::{data, data_mut} accessors to
write::Section to allow accessing data after it's been appended. The
motivation for this is that in Wasmtime we build an Object but we try
to patch relocations after the locations of all symbols are known,
handling them before load-time. Currently the logic of
appending-with-alignment is duplicated in Wasmtime but allowing access
to the underlying section data as-been-appended-so-far should enable us
to remove that duplication.

This commit adds `Section::{data, data_mut}` accessors to
`write::Section` to allow accessing data after it's been appended. The
motivation for this is that in Wasmtime we build an `Object` but we try
to patch relocations after the locations of all symbols are known,
handling them before load-time. Currently the logic of
appending-with-alignment is duplicated in Wasmtime but allowing access
to the underlying section data as-been-appended-so-far should enable us
to remove that duplication.
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Aug 27, 2021
Hopefully can remove all this with gimli-rs/object#367
@philipc philipc merged commit 6178499 into gimli-rs:master Aug 28, 2021
@philipc
Copy link
Copy Markdown
Contributor

philipc commented Aug 28, 2021

I'm considering changing the section data to be Cow, but I think that'll still be compatible with this (data_mut will convert to owned first).

@alexcrichton alexcrichton deleted the section-data branch August 28, 2021 03:49
mcbegamerxx954 pushed a commit to mcbegamerxx954/object that referenced this pull request Jun 15, 2024
This commit adds `Section::{data, data_mut}` accessors to
`write::Section` to allow accessing data after it's been appended. The
motivation for this is that in Wasmtime we build an `Object` but we try
to patch relocations after the locations of all symbols are known,
handling them before load-time. Currently the logic of
appending-with-alignment is duplicated in Wasmtime but allowing access
to the underlying section data as-been-appended-so-far should enable us
to remove that duplication.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants