Skip to content

Commit 0409177

Browse files
l4lbjorn3
andauthored
Use architecture pointer size for AddConstructor (rust-lang#1094)
* Use architecture pointer size for AddConstructor * Update src/backend.rs Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
1 parent 0416f12 commit 0409177

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,16 @@ impl AddConstructor for ObjectProduct {
132132
let init_array_section =
133133
self.object
134134
.add_section(segment.to_vec(), b".init_array".to_vec(), SectionKind::Data);
135+
let address_size = self
136+
.object
137+
.architecture()
138+
.address_size()
139+
.expect("address_size must be known")
140+
.bytes();
135141
self.object.append_section_data(
136142
init_array_section,
137143
&std::iter::repeat(0)
138-
.take(8 /*FIXME pointer size*/)
144+
.take(address_size.into())
139145
.collect::<Vec<u8>>(),
140146
8,
141147
);
@@ -144,7 +150,7 @@ impl AddConstructor for ObjectProduct {
144150
init_array_section,
145151
object::write::Relocation {
146152
offset: 0,
147-
size: 64, // FIXME pointer size
153+
size: address_size * 8,
148154
kind: RelocationKind::Absolute,
149155
encoding: RelocationEncoding::Generic,
150156
symbol,

0 commit comments

Comments
 (0)