Skip to content

Commit b15b9e4

Browse files
committed
Make test_reloc_iterator work on non-64-bit systems.
Name the module in each test. Fix an unused variable warning.
1 parent 8ac3774 commit b15b9e4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/all/test_object_file.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn test_section_iterator() {
3131
let target_machine = get_native_target_machine();
3232

3333
let context = Context::create();
34-
let mut module = context.create_module("my_module");
34+
let mut module = context.create_module("test_section_iterator");
3535

3636
let gv_a = module.add_global(context.i8_type(), None, "a");
3737
gv_a.set_initializer(&context.i8_type().const_zero().as_basic_value_enum());
@@ -90,7 +90,7 @@ fn test_symbol_iterator() {
9090
let target_machine = get_native_target_machine();
9191

9292
let context = Context::create();
93-
let mut module = context.create_module("my_module");
93+
let mut module = context.create_module("test_symbol_iterator");
9494
module
9595
.add_global(context.i8_type(), None, "a")
9696
.set_initializer(&context.i8_type().const_zero().as_basic_value_enum());
@@ -141,15 +141,18 @@ fn test_reloc_iterator() {
141141
let target_machine = get_native_target_machine();
142142

143143
let context = Context::create();
144-
let mut module = context.create_module("my_module");
144+
let target_data = target_machine.get_target_data();
145+
let intptr_t = target_data.ptr_sized_int_type_in_context(&context, None);
146+
147+
let mut module = context.create_module("test_reloc_iterator");
145148
let x_ptr = module
146149
.add_global(context.i8_type(), None, "x")
147150
.as_pointer_value();
148151
let x_plus_4 = x_ptr
149-
.const_to_int(context.i64_type())
150-
.const_add(context.i64_type().const_int(4, false));
152+
.const_to_int(intptr_t)
153+
.const_add(intptr_t.const_int(4, false));
151154
module
152-
.add_global(context.i64_type(), None, "a")
155+
.add_global(intptr_t, None, "a")
153156
.set_initializer(&x_plus_4);
154157

155158
module.set_triple(&target_machine.get_triple());
@@ -162,7 +165,7 @@ fn test_reloc_iterator() {
162165

163166
let mut found_relocation = false;
164167
for section in object_file.get_sections() {
165-
for reloc in section.get_relocations() {
168+
for _ in section.get_relocations() {
166169
found_relocation = true;
167170
// We don't stop the traversal here, so as to exercise the iterators.
168171
}

0 commit comments

Comments
 (0)