From 04091772bc561ec7bae2e02f7d70de6f32fcf6c4 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Fri, 16 Oct 2020 17:19:22 +0300 Subject: [PATCH] Use architecture pointer size for AddConstructor (#1094) * Use architecture pointer size for AddConstructor * Update src/backend.rs Co-authored-by: bjorn3 --- src/backend.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/backend.rs b/src/backend.rs index c0df85f681c..8b900fd0dd0 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -132,10 +132,16 @@ impl AddConstructor for ObjectProduct { let init_array_section = self.object .add_section(segment.to_vec(), b".init_array".to_vec(), SectionKind::Data); + let address_size = self + .object + .architecture() + .address_size() + .expect("address_size must be known") + .bytes(); self.object.append_section_data( init_array_section, &std::iter::repeat(0) - .take(8 /*FIXME pointer size*/) + .take(address_size.into()) .collect::>(), 8, ); @@ -144,7 +150,7 @@ impl AddConstructor for ObjectProduct { init_array_section, object::write::Relocation { offset: 0, - size: 64, // FIXME pointer size + size: address_size * 8, kind: RelocationKind::Absolute, encoding: RelocationEncoding::Generic, symbol,