about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKitsu <mail@kitsu.me>2020-10-16 17:19:22 +0300
committerGitHub <noreply@github.com>2020-10-16 16:19:22 +0200
commit04091772bc561ec7bae2e02f7d70de6f32fcf6c4 (patch)
tree7cb172f7e7a1d6cb70af5add1713a3d38c2f5e8c
parent0416f122aae296e7fa78cff64b5df683be1dfc2f (diff)
downloadrust-04091772bc561ec7bae2e02f7d70de6f32fcf6c4.tar.gz
rust-04091772bc561ec7bae2e02f7d70de6f32fcf6c4.zip
Use architecture pointer size for AddConstructor (#1094)
* Use architecture pointer size for AddConstructor

* Update src/backend.rs

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
-rw-r--r--src/backend.rs10
1 files 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::<Vec<u8>>(),
             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,