Skip to content

Commit

Permalink
Update object
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed May 1, 2024
1 parent 9e1084f commit d851125
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ wit-component = "0.202.0"

# Non-Bytecode Alliance maintained dependencies:
# --------------------------
object = { version = "0.33", default-features = false, features = ['read_core', 'elf', 'std'] }
object = { version = "0.33", default-features = false, features = ['read_core', 'elf', 'std'], path = "../object" }
gimli = { version = "0.28.0", default-features = false, features = ['read', 'std'] }
anyhow = "1.0.22"
windows-sys = "0.52.0"
Expand Down
18 changes: 8 additions & 10 deletions cranelift/object/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ impl ObjectModule {
let mut object = Object::new(builder.binary_format, builder.architecture, builder.endian);
object.flags = builder.flags;
object.add_file_symbol(builder.name);
if builder.per_function_section {
object.set_subsections_via_symbols();
}
Self {
isa: builder.isa,
object,
Expand Down Expand Up @@ -368,19 +371,14 @@ impl Module for ObjectModule {
let align = alignment
.max(self.isa.function_alignment().minimum.into())
.max(self.isa.symbol_alignment());
let (section, offset) = if self.per_function_section {
let section = if self.per_function_section {
let symbol_name = self.object.symbol(symbol).name.clone();
let (section, offset) =
self.object
.add_subsection(StandardSection::Text, &symbol_name, bytes, align);
self.object.symbol_mut(symbol).section = SymbolSection::Section(section);
self.object.symbol_mut(symbol).value = offset;
(section, offset)
self.object
.add_subsection(StandardSection::Text, &symbol_name)
} else {
let section = self.object.section_id(StandardSection::Text);
let offset = self.object.add_symbol_data(symbol, section, bytes, align);
(section, offset)
self.object.section_id(StandardSection::Text)
};
let offset = self.object.add_symbol_data(symbol, section, bytes, align);

if !relocs.is_empty() {
let relocs = relocs
Expand Down

0 comments on commit d851125

Please sign in to comment.