No public description

PiperOrigin-RevId: 855586710
Change-Id: I21542ac9afc2150d3b9b3316b23465dbc0291ee6
diff --git a/mpact/sim/util/asm/resolver.cc b/mpact/sim/util/asm/resolver.cc
index e82087d..d1937ae 100644
--- a/mpact/sim/util/asm/resolver.cc
+++ b/mpact/sim/util/asm/resolver.cc
@@ -39,10 +39,10 @@
         absl::StrCat("SymbolResolver: Symbol '", text, "' not found"));
   }
   auto index = iter->second;
-  if (elf_file_class_ == ELFCLASS64) {
+  if (elf_file_class_ == ELFIO::ELFCLASS64) {
     auto* sym = reinterpret_cast<const ELFIO::Elf64_Sym*>(symtab_->get_data());
     return sym[index].st_value;
-  } else if (elf_file_class_ == ELFCLASS32) {
+  } else if (elf_file_class_ == ELFIO::ELFCLASS32) {
     auto* sym = reinterpret_cast<const ELFIO::Elf32_Sym*>(symtab_->get_data());
     return sym[index].st_value;
   }
diff --git a/mpact/sim/util/asm/simple_assembler.cc b/mpact/sim/util/asm/simple_assembler.cc
index 78276ec..ff5faa1 100644
--- a/mpact/sim/util/asm/simple_assembler.cc
+++ b/mpact/sim/util/asm/simple_assembler.cc
@@ -261,21 +261,21 @@
           ")?\\s*"
           "$") {
   // Configure the ELF file writer.
-  writer_.create(elf_file_class_, ELFDATA2LSB);
-  writer_.set_os_abi(ELFOSABI_NONE);
-  writer_.set_machine(EM_NONE);
+  writer_.create(elf_file_class_, ELFIO::ELFDATA2LSB);
+  writer_.set_os_abi(ELFIO::ELFOSABI_NONE);
+  writer_.set_machine(ELFIO::EM_NONE);
   // Create the symbol table section.
   symtab_ = writer_.sections.add(".symtab");
   section_index_map_.insert({symtab_->get_index(), symtab_});
-  symtab_->set_type(SHT_SYMTAB);
+  symtab_->set_type(ELFIO::SHT_SYMTAB);
   symtab_->set_addr_align(0x8);
-  symtab_->set_entry_size(elf_file_class_ == ELFCLASS64
+  symtab_->set_entry_size(elf_file_class_ == ELFIO::ELFCLASS64
                               ? sizeof(ELFIO::Elf64_Sym)
                               : sizeof(ELFIO::Elf32_Sym));
   // Create the string table section.
   strtab_ = writer_.sections.add(".strtab");
   section_index_map_.insert({strtab_->get_index(), strtab_});
-  strtab_->set_type(SHT_STRTAB);
+  strtab_->set_type(ELFIO::SHT_STRTAB);
   strtab_->set_addr_align(0x1);
   // Link the symbol table to the string table.
   symtab_->set_link(strtab_->get_index());
@@ -371,7 +371,7 @@
           symbol_address = address / data_address_unit_;
         }
         auto status = AddSymbolToCurrentSection(label, symbol_address, 0,
-                                                STT_NOTYPE, 0, 0);
+                                                ELFIO::STT_NOTYPE, 0, 0);
         if (!status.ok()) return status;
       }
       continue;
@@ -388,7 +388,7 @@
 
   // Add undefined symbols to the symbol table.
   for (auto const& symbol : undefined_symbols_) {
-    auto status = AddSymbol(symbol, 0, 0, STT_NOTYPE, 0, 0, nullptr);
+    auto status = AddSymbol(symbol, 0, 0, ELFIO::STT_NOTYPE, 0, 0, nullptr);
     if (!status.ok()) {
       cleanup();
       return absl::InternalError(absl::StrCat(
@@ -425,7 +425,7 @@
     auto shndx = sym.st_shndx;
     std::string name = string_accessor_->get_string(sym.st_name);
     if (global_symbols_.contains(name)) {
-      sym.st_info = ELF_ST_INFO(STB_GLOBAL, ELF_ST_TYPE(sym.st_info));
+      sym.st_info = ELF_ST_INFO(ELFIO::STB_GLOBAL, ELF_ST_TYPE(sym.st_info));
     }
     if ((text_section_ != nullptr) && (shndx == text_section_->get_index())) {
       sym.st_value += text_segment_start;
@@ -451,7 +451,7 @@
     auto& sym = symbols[i];
     std::string name = string_accessor_->get_string(sym.st_name);
     if (global_symbols_.contains(name)) {
-      sym.st_info = ELF_ST_INFO(STB_GLOBAL, ELF_ST_TYPE(sym.st_info));
+      sym.st_info = ELF_ST_INFO(ELFIO::STB_GLOBAL, ELF_ST_TYPE(sym.st_info));
     }
   }
   symtab_->set_data(reinterpret_cast<char*>(symbols), size);
@@ -471,7 +471,7 @@
     }
     return absl::InvalidArgumentError(message);
   }
-  writer_.set_type(ET_EXEC);
+  writer_.set_type(ELFIO::ET_EXEC);
   // Section sizes are now known. So let's compute the layout and update all
   // the symbol values/addresses before the next pass.
   // The layout is:
@@ -487,10 +487,10 @@
     if (text_segment == nullptr) {
       return absl::InternalError("Failed to create elf segment for text");
     }
-    text_segment->set_type(PT_LOAD);
+    text_segment->set_type(ELFIO::PT_LOAD);
     text_segment->set_virtual_address(text_segment_start);
     text_segment->set_physical_address(text_segment_start);
-    text_segment->set_flags(PF_X | PF_R);
+    text_segment->set_flags(ELFIO::PF_X | ELFIO::PF_R);
     text_segment->set_align(4096);
   }
 
@@ -509,10 +509,10 @@
     if (data_segment == nullptr) {
       return absl::InternalError("Failed to create elf segment for data");
     }
-    data_segment->set_type(PT_LOAD);
+    data_segment->set_type(ELFIO::PT_LOAD);
     data_segment->set_virtual_address(data_segment_start);
     data_segment->set_physical_address(data_segment_start);
-    data_segment->set_flags(PF_W | PF_R);
+    data_segment->set_flags(ELFIO::PF_W | ELFIO::PF_R);
     data_segment->set_align(4096);
 
     uint64_t bss_align = bss_section_->get_addr_align() - 1;
@@ -524,10 +524,10 @@
   // Now we can update the symbol table based on the new section sizes.
 
   // Different size symbol table entries for 32 and 64 bit ELF files.
-  if (elf_file_class_ == ELFCLASS64) {
+  if (elf_file_class_ == ELFIO::ELFCLASS64) {
     UpdateSymbolsForExecutable<ELFIO::Elf64_Sym>(
         text_segment_start, data_segment_start, bss_segment_start);
-  } else if (elf_file_class_ == ELFCLASS32) {
+  } else if (elf_file_class_ == ELFIO::ELFCLASS32) {
     UpdateSymbolsForExecutable<ELFIO::Elf32_Sym>(
         text_segment_start, data_segment_start, bss_segment_start);
   } else {
@@ -623,14 +623,14 @@
   for (int i = 0; i < syms.size(); ++i) {
     auto name = string_accessor_->get_string(syms[i].st_name);
     symbol_indices_.insert({name, i});
-    if (ELF_ST_BIND(syms[i].st_info) == STB_LOCAL) last_local = i;
+    if (ELF_ST_BIND(syms[i].st_info) == ELFIO::STB_LOCAL) last_local = i;
   }
   symtab_->set_info(last_local + 1);
 }
 
 absl::Status SimpleAssembler::CreateRelocatable(
     ResolverInterface* symbol_resolver) {
-  writer_.set_type(ET_REL);
+  writer_.set_type(ELFIO::ET_REL);
   // Reset the section address map to zero since we are creating a relocatable
   // file.
   section_address_map_[text_section_] = 0;
@@ -640,9 +640,9 @@
   // Since the symbols now are rearranged, we need to set global symbols flag
   // for those in the global_symbols_ set.
   // Different size symbol table entries for 32 and 64 bit ELF files.
-  if (elf_file_class_ == ELFCLASS64) {
+  if (elf_file_class_ == ELFIO::ELFCLASS64) {
     UpdateSymbolsForRelocatable<ELFIO::Elf64_Sym>();
-  } else if (elf_file_class_ == ELFCLASS32) {
+  } else if (elf_file_class_ == ELFIO::ELFCLASS32) {
     UpdateSymbolsForRelocatable<ELFIO::Elf32_Sym>();
   } else {
     return absl::InternalError(
@@ -654,7 +654,7 @@
   // Find the last local symbol and set the section header info for symbtab
   // to point to 1 past that. Update the symbol_indices_ map.
   symbol_indices_.clear();
-  if (elf_file_class_ == ELFCLASS64) {
+  if (elf_file_class_ == ELFIO::ELFCLASS64) {
     UpdateSymtabHeaderInfo<ELFIO::Elf64_Sym>();
   } else {
     UpdateSymtabHeaderInfo<ELFIO::Elf32_Sym>();
@@ -697,9 +697,9 @@
       std::string name =
           absl::StrCat(".rela", section_index_map_[section_index]->get_name());
       auto* rela_section = writer_.sections.add(name);
-      rela_section->set_type(SHT_RELA);
-      rela_section->set_flags(SHF_INFO_LINK);
-      rela_section->set_entry_size(elf_file_class_ == ELFCLASS64
+      rela_section->set_type(ELFIO::SHT_RELA);
+      rela_section->set_flags(ELFIO::SHF_INFO_LINK);
+      rela_section->set_entry_size(elf_file_class_ == ELFIO::ELFCLASS64
                                        ? sizeof(ELFIO::Elf64_Rela)
                                        : sizeof(ELFIO::Elf32_Rela));
       rela_section->set_link(symtab_->get_index());
@@ -707,10 +707,10 @@
       rela_section->set_addr_align(8);
       // Process the relocation vector entries.
       absl::Status status;
-      if (elf_file_class_ == ELFCLASS64) {
+      if (elf_file_class_ == ELFIO::ELFCLASS64) {
         status = AddRelocationEntries<ELFIO::Elf64_Rela>(
             relo_vec, symbol_indices_, rela_section);
-      } else if (elf_file_class_ == ELFCLASS32) {
+      } else if (elf_file_class_ == ELFIO::ELFCLASS32) {
         status = AddRelocationEntries<ELFIO::Elf32_Rela>(
             relo_vec, symbol_indices_, rela_section);
       } else {
@@ -940,8 +940,8 @@
       return absl::InvalidArgumentError(
           absl::StrCat("Label: '", label, "' defined outside of a section"));
     }
-    auto status =
-        AddSymbol(label, address, size, STT_NOTYPE, STB_LOCAL, 0, section);
+    auto status = AddSymbol(label, address, size, ELFIO::STT_NOTYPE,
+                            ELFIO::STB_LOCAL, 0, section);
   }
   return absl::OkStatus();
 }
@@ -971,12 +971,13 @@
     return;
   }
   section = writer_.sections.add(name);
-  auto status = AddSymbol(name, 0, 0, STT_SECTION, STB_LOCAL, 0, section);
+  auto status =
+      AddSymbol(name, 0, 0, ELFIO::STT_SECTION, ELFIO::STB_LOCAL, 0, section);
   if (!status.ok()) {
     LOG(ERROR) << "Failed to add symbol for data section: " << status.message();
   }
-  section->set_type(SHT_PROGBITS);
-  section->set_flags(SHF_ALLOC | SHF_EXECINSTR);
+  section->set_type(ELFIO::SHT_PROGBITS);
+  section->set_flags(ELFIO::SHF_ALLOC | ELFIO::SHF_EXECINSTR);
   section->set_addr_align(0x10);
   // Should probably add the section symbol to the symbol table.
   current_section_ = section;
@@ -992,12 +993,13 @@
     return;
   }
   section = writer_.sections.add(name);
-  auto status = AddSymbol(name, 0, 0, STT_SECTION, STB_LOCAL, 0, section);
+  auto status =
+      AddSymbol(name, 0, 0, ELFIO::STT_SECTION, ELFIO::STB_LOCAL, 0, section);
   if (!status.ok()) {
     LOG(ERROR) << "Failed to add symbol for data section: " << status.message();
   }
-  section->set_type(SHT_PROGBITS);
-  section->set_flags(SHF_ALLOC | SHF_WRITE);
+  section->set_type(ELFIO::SHT_PROGBITS);
+  section->set_flags(ELFIO::SHF_ALLOC | ELFIO::SHF_WRITE);
   section->set_addr_align(0x10);
   // Should probably add the section symbol to the symbol table.
   current_section_ = section;
@@ -1013,12 +1015,13 @@
     return;
   }
   section = writer_.sections.add(name);
-  auto status = AddSymbol(name, 0, 0, STT_SECTION, STB_LOCAL, 0, section);
+  auto status =
+      AddSymbol(name, 0, 0, ELFIO::STT_SECTION, ELFIO::STB_LOCAL, 0, section);
   if (!status.ok()) {
     LOG(ERROR) << "Failed to add symbol for bss section: " << status.message();
   }
-  section->set_type(SHT_NOBITS);
-  section->set_flags(SHF_ALLOC | SHF_WRITE);
+  section->set_type(ELFIO::SHT_NOBITS);
+  section->set_flags(ELFIO::SHF_ALLOC | ELFIO::SHF_WRITE);
   section->set_addr_align(0x10);
   // Should probably add the section symbol to the symbol table.
   current_section_ = section;
@@ -1059,7 +1062,7 @@
   }
   auto index = symbol_accessor_->add_symbol(
       *string_accessor_, name.c_str(), value, size, binding, type, other,
-      section == nullptr ? SHN_UNDEF : section->get_index());
+      section == nullptr ? ELFIO::SHN_UNDEF : section->get_index());
   symbol_indices_.insert({name, index});
   // If this is not an undefined symbol reference, then see if the symbol name
   // is part of the "current" undefined symbols, and if so, remove it.
diff --git a/mpact/sim/util/asm/test/riscv64x_asm_test.cc b/mpact/sim/util/asm/test/riscv64x_asm_test.cc
index 4f55ed8..b3cf03d 100644
--- a/mpact/sim/util/asm/test/riscv64x_asm_test.cc
+++ b/mpact/sim/util/asm/test/riscv64x_asm_test.cc
@@ -64,7 +64,8 @@
     // with the current address.
     std::string label;
     if (RE2::Consume(&text, label_re_, &label)) {
-      auto status = add_symbol_callback(label, address, 0, STT_NOTYPE, 0, 0);
+      auto status =
+          add_symbol_callback(label, address, 0, ELFIO::STT_NOTYPE, 0, 0);
       if (!status.ok()) return status;
     }
     // Call the slot matcher to get the encoded value.
@@ -145,9 +146,10 @@
       : matcher_(&bin_encoder_interface_), riscv_64x_assembler_(&matcher_) {
     CHECK_OK(matcher_.Initialize());
     // Create the assembler.
-    assembler_ = new SimpleAssembler(";", ELFCLASS64, &riscv_64x_assembler_);
-    assembler_->writer().set_os_abi(ELFOSABI_LINUX);
-    assembler_->writer().set_machine(EM_RISCV);
+    assembler_ =
+        new SimpleAssembler(";", ELFIO::ELFCLASS64, &riscv_64x_assembler_);
+    assembler_->writer().set_os_abi(ELFIO::ELFOSABI_LINUX);
+    assembler_->writer().set_machine(ELFIO::EM_RISCV);
     std::istringstream source(*kTestAssembly);
     // Parse the assembly code.
     auto status = assembler_->Parse(source);
@@ -185,9 +187,9 @@
   auto status = assembler()->CreateExecutable(0x1000, "main");
   CHECK_OK(status) << status.message();
   auto* text = elf().sections[".text"];
-  EXPECT_EQ(text->get_type(), SHT_PROGBITS);
-  EXPECT_EQ(text->get_flags(), SHF_ALLOC | SHF_EXECINSTR);
-  EXPECT_EQ(text->get_link(), SHN_UNDEF);
+  EXPECT_EQ(text->get_type(), ELFIO::SHT_PROGBITS);
+  EXPECT_EQ(text->get_flags(), ELFIO::SHF_ALLOC | ELFIO::SHF_EXECINSTR);
+  EXPECT_EQ(text->get_link(), ELFIO::SHN_UNDEF);
   EXPECT_EQ(text->get_size(), /*num inst*/ 21 * /*bytes per inst*/ 4);
 }
 
@@ -195,9 +197,9 @@
   auto status = assembler()->CreateExecutable(0x1000, "main");
   CHECK_OK(status) << status.message();
   auto* data = elf().sections[".data"];
-  EXPECT_EQ(data->get_type(), SHT_PROGBITS);
-  EXPECT_EQ(data->get_flags(), SHF_ALLOC | SHF_WRITE);
-  EXPECT_EQ(data->get_link(), SHN_UNDEF);
+  EXPECT_EQ(data->get_type(), ELFIO::SHT_PROGBITS);
+  EXPECT_EQ(data->get_flags(), ELFIO::SHF_ALLOC | ELFIO::SHF_WRITE);
+  EXPECT_EQ(data->get_link(), ELFIO::SHN_UNDEF);
   // Hello world is 12 bytes, plus the null terminator.
   // Add one .char declaration.
   EXPECT_EQ(data->get_size(), 14);
@@ -207,9 +209,9 @@
   auto status = assembler()->CreateExecutable(0x1000, "main");
   CHECK_OK(status) << status.message();
   auto* bss = elf().sections[".bss"];
-  EXPECT_EQ(bss->get_type(), SHT_NOBITS);
-  EXPECT_EQ(bss->get_flags(), SHF_ALLOC | SHF_WRITE);
-  EXPECT_EQ(bss->get_link(), SHN_UNDEF);
+  EXPECT_EQ(bss->get_type(), ELFIO::SHT_NOBITS);
+  EXPECT_EQ(bss->get_flags(), ELFIO::SHF_ALLOC | ELFIO::SHF_WRITE);
+  EXPECT_EQ(bss->get_link(), ELFIO::SHN_UNDEF);
   // Two .space declarations, each 16 bytes.
   EXPECT_EQ(bss->get_size(), 32);
 }
@@ -240,30 +242,30 @@
   symbols.get_symbol("main", value, size, bind, type, section_index, other);
   auto* sym = &symspan[symbol_map["main"]];
   EXPECT_EQ(sym->st_value, 0x0);
-  EXPECT_EQ(ELF_ST_BIND(sym->st_info), STB_GLOBAL);
+  EXPECT_EQ(ELF_ST_BIND(sym->st_info), ELFIO::STB_GLOBAL);
   EXPECT_EQ(sym->st_shndx, elf().sections[".text"]->get_index());
-  EXPECT_EQ(ELF_ST_TYPE(sym->st_info), STT_NOTYPE);
+  EXPECT_EQ(ELF_ST_TYPE(sym->st_info), ELFIO::STT_NOTYPE);
   // Verify that exit is valued 16 * 4, local and located in the text
   // section.
   sym = &symspan[symbol_map["exit"]];
   EXPECT_EQ(sym->st_value, 16 * 4);
-  EXPECT_EQ(ELF_ST_BIND(sym->st_info), STB_LOCAL);
+  EXPECT_EQ(ELF_ST_BIND(sym->st_info), ELFIO::STB_LOCAL);
   EXPECT_EQ(sym->st_shndx, elf().sections[".text"]->get_index());
-  EXPECT_EQ(ELF_ST_TYPE(sym->st_info), STT_NOTYPE);
+  EXPECT_EQ(ELF_ST_TYPE(sym->st_info), ELFIO::STT_NOTYPE);
   // Verify that hello is global and located in the data section at 0x2000.
   symbols.get_symbol("hello", value, size, bind, type, section_index, other);
   sym = &symspan[symbol_map["hello"]];
   EXPECT_EQ(sym->st_value, 0);
   EXPECT_EQ(sym->st_shndx, elf().sections[".data"]->get_index());
-  EXPECT_EQ(ELF_ST_BIND(sym->st_info), STB_GLOBAL);
-  EXPECT_EQ(ELF_ST_TYPE(sym->st_info), STT_NOTYPE);
+  EXPECT_EQ(ELF_ST_BIND(sym->st_info), ELFIO::STB_GLOBAL);
+  EXPECT_EQ(ELF_ST_TYPE(sym->st_info), ELFIO::STT_NOTYPE);
   // Verify that semihost_param is global and located in the bss section at
   // 16 bytes.
   sym = &symspan[symbol_map["semihost_param"]];
   EXPECT_EQ(sym->st_value, 16);
   EXPECT_EQ(sym->st_shndx, elf().sections[".bss"]->get_index());
-  EXPECT_EQ(ELF_ST_BIND(sym->st_info), STB_LOCAL);
-  EXPECT_EQ(ELF_ST_TYPE(sym->st_info), STT_NOTYPE);
+  EXPECT_EQ(ELF_ST_BIND(sym->st_info), ELFIO::STB_LOCAL);
+  EXPECT_EQ(ELF_ST_TYPE(sym->st_info), ELFIO::STT_NOTYPE);
   delete string_accessor;
 }
 
@@ -282,28 +284,28 @@
   symbols.get_symbol("main", value, size, bind, type, section_index, other);
   EXPECT_EQ(value, 0x1000);
   EXPECT_EQ(section_index, elf().sections[".text"]->get_index());
-  EXPECT_EQ(type, STT_NOTYPE);
+  EXPECT_EQ(type, ELFIO::STT_NOTYPE);
   // Verify that exit is valued 0x1000 + 16 * 4, local and located in the text
   // section.
   symbols.get_symbol("exit", value, size, bind, type, section_index, other);
   EXPECT_EQ(value, 0x1000 + 16 * 4);
-  EXPECT_EQ(bind, STB_LOCAL);
+  EXPECT_EQ(bind, ELFIO::STB_LOCAL);
   EXPECT_EQ(section_index, elf().sections[".text"]->get_index());
-  EXPECT_EQ(type, STT_NOTYPE);
+  EXPECT_EQ(type, ELFIO::STT_NOTYPE);
   // Verify that hello is global and located in the data section at 0x2000.
   symbols.get_symbol("hello", value, size, bind, type, section_index, other);
   EXPECT_EQ(value, 0x2000);
   EXPECT_EQ(section_index, elf().sections[".data"]->get_index());
-  EXPECT_EQ(bind, STB_GLOBAL);
-  EXPECT_EQ(type, STT_NOTYPE);
+  EXPECT_EQ(bind, ELFIO::STB_GLOBAL);
+  EXPECT_EQ(type, ELFIO::STT_NOTYPE);
   // Verify that semihost_param is global and located in the bss section at
   // 0x2000 + 14 + alignment to 16 byte boundary, plus 16 bytes.
   symbols.get_symbol("semihost_param", value, size, bind, type, section_index,
                      other);
   EXPECT_EQ(value, 0x2000 + 16 + 16);
   EXPECT_EQ(section_index, elf().sections[".bss"]->get_index());
-  EXPECT_EQ(bind, STB_LOCAL);
-  EXPECT_EQ(type, STT_NOTYPE);
+  EXPECT_EQ(bind, ELFIO::STB_LOCAL);
+  EXPECT_EQ(type, ELFIO::STT_NOTYPE);
 }
 
 // Verify that the first 16 instructions were assembled correctly.
diff --git a/mpact/sim/util/other/instruction_profiler.cc b/mpact/sim/util/other/instruction_profiler.cc
index 85941fa..966dea3 100644
--- a/mpact/sim/util/other/instruction_profiler.cc
+++ b/mpact/sim/util/other/instruction_profiler.cc
@@ -94,8 +94,8 @@
   // during simulation.
   for (auto const& segment : elf_loader_->elf_reader()->segments) {
     // Only consider segments that are loaded, executable, and with size > 0.
-    if (segment->get_type() != PT_LOAD) continue;
-    if ((segment->get_flags() & PF_X) == 0) continue;
+    if (segment->get_type() != ELFIO::PT_LOAD) continue;
+    if ((segment->get_flags() & ELFIO::PF_X) == 0) continue;
     uint64_t size = segment->get_memory_size() >> shift_;
     if (size == 0) continue;
 
diff --git a/mpact/sim/util/program_loader/elf_program_loader.cc b/mpact/sim/util/program_loader/elf_program_loader.cc
index 1f33b91..6ebb974 100644
--- a/mpact/sim/util/program_loader/elf_program_loader.cc
+++ b/mpact/sim/util/program_loader/elf_program_loader.cc
@@ -80,9 +80,9 @@
   loaded_ = true;
   // Now look up any symbol sections.
   for (auto const& section : elf_reader_.sections) {
-    if (section->get_type() == SHT_SYMTAB) {
+    if (section->get_type() == ELFIO::SHT_SYMTAB) {
       symbol_accessors_.push_back(
-          new ELFIO::symbol_section_accessor(elf_reader_, section));
+          new ELFIO::symbol_section_accessor(elf_reader_, section.get()));
     }
   }
   std::string name;
@@ -97,7 +97,7 @@
     for (unsigned i = 0; i < symtab->get_symbols_num(); i++) {
       symtab->get_symbol(i, name, value, size, bind, type, section_index,
                          other);
-      if (type == STT_FUNC) {
+      if (type == ELFIO::STT_FUNC) {
         fcn_symbol_map_.emplace(value, name);
         function_range_map_.insert(
             std::make_pair(AddressRange(value, size / text_size_scale_), name));
@@ -124,7 +124,7 @@
       continue;
     }
     // If the section isn 't loadable, continue.
-    if (segment->get_type() != PT_LOAD) continue;
+    if (segment->get_type() != ELFIO::PT_LOAD) continue;
     if (segment->get_file_size() == 0) continue;
     // Compute the destination address - use paddr if available, else use
     // vaddr.
@@ -139,7 +139,7 @@
       std::memcpy(db->raw_ptr(), segment->get_data(), size);
       if (memories_ == nullptr) {
         if (segment->get_flags() &
-            PF_X) {  // Executable, so write to code memory.
+            ELFIO::PF_X) {  // Executable, so write to code memory.
           code_memory_->Store(dest_addr, db);
         } else {  // Write to data memory.
           data_memory_->Store(dest_addr, db);
diff --git a/mpact/sim/util/program_loader/test/elf_program_loader_test.cc b/mpact/sim/util/program_loader/test/elf_program_loader_test.cc
index 6ef8f6e..c5d3c97 100644
--- a/mpact/sim/util/program_loader/test/elf_program_loader_test.cc
+++ b/mpact/sim/util/program_loader/test/elf_program_loader_test.cc
@@ -78,7 +78,7 @@
   auto result = loader_.LoadProgram(input_file);
   ASSERT_TRUE(result.status().ok());
   for (auto const& segment : elf_reader_.segments) {
-    if (segment->get_type() != PT_LOAD) continue;
+    if (segment->get_type() != ELFIO::PT_LOAD) continue;
     if (segment->get_file_size() == 0) continue;
 
     int size = segment->get_file_size();