include/ChangeLog
[deliverable/binutils-gdb.git] / gold / testsuite / binary_unittest.cc
index 0be2478a8bf56dfc803d8a12fb1144cad3c0ffdb..a9f47c20fcbeddcbc75d67cbc7821cd3110b0f11 100644 (file)
@@ -44,8 +44,9 @@ using namespace gold;
 
 template<int size, bool big_endian>
 bool
-Sized_binary_test(Target* target)
+Sized_binary_test()
 {
+  parameters_clear_target();
   // We need a pretend Task.
   const Task* task = reinterpret_cast<const Task*>(-1);
 
@@ -67,19 +68,18 @@ Sized_binary_test(Target* target)
                        binary.converted_size());
   Object* object = make_elf_object("test.o", &input_file, 0,
                                   binary.converted_data(),
-                                  binary.converted_size());
+                                  binary.converted_size(), NULL);
   CHECK(object != NULL);
   if (object == NULL)
     return false;
 
   CHECK(!object->is_dynamic());
-  CHECK(object->target() == target);
   CHECK(object->shnum() == 5);
   CHECK(object->section_name(1) == ".data");
-  CHECK(object->section_flags(1) == elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE);
+  CHECK(object->section_flags(1) == (elfcpp::SHF_ALLOC | elfcpp::SHF_WRITE));
   section_size_type len;
   const unsigned char* contents = object->section_contents(1, &len, false);
-  CHECK(len == st.st_size);
+  CHECK(len == convert_to_section_size_type(st.st_size));
   CHECK(memcmp(filedata, contents, len) == 0);
 
   // Force the symbols to be read internally, so that
@@ -87,20 +87,30 @@ Sized_binary_test(Target* target)
   Read_symbols_data sd;
   object->read_symbols(&sd);
   delete sd.section_headers;
+  sd.section_headers = NULL;
   delete sd.section_names;
+  sd.section_names = NULL;
   delete sd.symbols;
+  sd.symbols = NULL;
   delete sd.symbol_names;
-
-  Sized_relobj<size, big_endian>* relobj =
-    static_cast<Sized_relobj<size, big_endian>*>(object);
-  typename Sized_relobj<size, big_endian>::Address value;
-  CHECK(relobj->symbol_section_and_value(0, &value) == 0);
+  sd.symbol_names = NULL;
+
+  Sized_relobj_file<size, big_endian>* relobj =
+    static_cast<Sized_relobj_file<size, big_endian>*>(object);
+  typename Sized_relobj_file<size, big_endian>::Address value;
+  bool is_ordinary;
+  CHECK(relobj->symbol_section_and_value(0, &value, &is_ordinary) == 0);
+  CHECK(is_ordinary);
   CHECK(value == 0);
-  CHECK(relobj->symbol_section_and_value(1, &value) == 1);
+  CHECK(relobj->symbol_section_and_value(1, &value, &is_ordinary) == 1);
+  CHECK(is_ordinary);
   CHECK(value == 0);
-  CHECK(relobj->symbol_section_and_value(2, &value) == 1);
+  CHECK(relobj->symbol_section_and_value(2, &value, &is_ordinary) == 1);
+  CHECK(is_ordinary);
   CHECK(static_cast<off_t>(value) == st.st_size);
-  CHECK(relobj->symbol_section_and_value(3, &value) == elfcpp::SHN_ABS);
+  CHECK(relobj->symbol_section_and_value(3, &value, &is_ordinary)
+       == elfcpp::SHN_ABS);
+  CHECK(!is_ordinary);
   CHECK(static_cast<off_t>(value) == st.st_size);
 
   object->unlock(task);
@@ -111,32 +121,35 @@ bool
 Binary_test(Test_report*)
 {
   Errors errors(gold::program_name);
-  initialize_parameters(&errors);
+  set_parameters_errors(&errors);
 
-  Script_options script_options;
-  General_options options(&script_options);
-  set_parameters_from_options(&options);
+  General_options options;
+  set_parameters_options(&options);
 
   int fail = 0;
 
 #ifdef HAVE_TARGET_32_LITTLE
-  if (!Sized_binary_test<32, false>(target_test_pointer_32_little))
+  if (!Sized_binary_test<32, false>())
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_32_little);
 #endif
 
 #ifdef HAVE_TARGET_32_BIG
-  if (!Sized_binary_test<32, true>(target_test_pointer_32_big))
+  if (!Sized_binary_test<32, true>())
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_32_big);
 #endif
 
 #ifdef HAVE_TARGET_64_LITTLE
-  if (!Sized_binary_test<64, false>(target_test_pointer_64_little))
+  if (!Sized_binary_test<64, false>())
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_64_little);
 #endif
 
 #ifdef HAVE_TARGET_64_BIG
-  if (!Sized_binary_test<64, true>(target_test_pointer_64_big))
+  if (!Sized_binary_test<64, true>())
     ++fail;
+  CHECK(&parameters->target() == target_test_pointer_64_big);
 #endif
 
   return fail == 0;
This page took 0.024668 seconds and 4 git commands to generate.