Ejemplo n.º 1
0
int ElfWriter::writeStringSection() {
  int section = -1;
  if ((section = newSection(
      ".shstrtab", m_strtab.size(), SHT_STRTAB, SHF_STRINGS)) < 0) {
    logError("unable to create string section");
    return -1;
  }
  if (!addSectionData(section, &m_strtab[0], m_strtab.size())) {
    logError("unable to add string data");
    return -1;
  }
  return section;
}
Ejemplo n.º 2
0
int ElfWriter::writeTextSection() {
  int section = -1;
  CodeBlock& a = tx64->code.main();
  if ((section = newSection(
      ".text.tracelets", a.capacity(), SHT_NOBITS, SHF_ALLOC | SHF_EXECINSTR,
      reinterpret_cast<uint64_t>(a.base()))) < 0) {
    logError("unable to create text section");
    return -1;
  }
  if (!addSectionData(section, nullptr, a.capacity())) {
    logError("unable to add text data");
    return -1;
  }
  return section;
}
Ejemplo n.º 3
0
int ElfWriter::writeTextSection() {
  int section = -1;
  HPHP::x64::X64Assembler &a(TranslatorX64::Get()->getAsm());
  if ((section = newSection(
      ".text.tracelets", a.code.size, SHT_NOBITS, SHF_ALLOC | SHF_EXECINSTR,
      reinterpret_cast<uint64_t>(a.code.base))) < 0) {
    logError("unable to create text section");
    return -1;
  }
  if (!addSectionData(section, NULL, a.code.size)) {
    logError("unable to add text data");
    return -1;
  }
  return section;
}
Ejemplo n.º 4
0
int ElfWriter::writeTextSection() {
  int section = -1;
  auto& code = mcg->code;
  if ((section = newSection(
         ".text.tracelets", code.codeSize(),
         SHT_NOBITS, SHF_ALLOC | SHF_EXECINSTR,
         reinterpret_cast<uint64_t>(code.base()))) < 0) {
    logError("unable to create text section");
    return -1;
  }
  if (!addSectionData(section, nullptr, code.codeSize())) {
    logError("unable to add text data");
    return -1;
  }
  return section;
}
Ejemplo n.º 5
0
bool ElfWriter::writeDwarfInfo() {
  Dwarf_Signed sections = dwarf_transform_to_disk_form (m_dwarfProducer, 0);

  Dwarf_Signed i = 0;
  Dwarf_Signed elf_section_index = 0;
  Dwarf_Unsigned length = 0;

  for (i = 0; i < sections; i++) {
    Dwarf_Ptr bytes = dwarf_get_section_bytes(
      m_dwarfProducer, 0, &elf_section_index, &length, 0);

    if (!addSectionData(elf_section_index, bytes, length)) {
      logError("Unable to create section");
      return false;
    }
  }
  return true;
}