Esempio n. 1
0
void ARMAttributeParser::ParseSubsection(const uint8_t *Data, uint32_t Length) {
  uint32_t Offset = sizeof(uint32_t); /* SectionLength */

  SW.printNumber("SectionLength", Length);

  const char *VendorName = reinterpret_cast<const char*>(Data + Offset);
  size_t VendorNameLength = std::strlen(VendorName);
  SW.printString("Vendor", StringRef(VendorName, VendorNameLength));
  Offset = Offset + VendorNameLength + 1;

  if (StringRef(VendorName, VendorNameLength).lower() != "aeabi")
    return;

  while (Offset < Length) {
    /// Tag_File | Tag_Section | Tag_Symbol   uleb128:byte-size
    uint8_t Tag = Data[Offset];
    SW.printEnum("Tag", Tag, makeArrayRef(TagNames));
    Offset = Offset + sizeof(Tag);

    uint32_t Size =
      *reinterpret_cast<const support::ulittle32_t*>(Data + Offset);
    SW.printNumber("Size", Size);
    Offset = Offset + sizeof(Size);

    if (Size > Length) {
      errs() << "subsection length greater than section length\n";
      return;
    }

    StringRef ScopeName, IndexName;
    SmallVector<uint8_t, 8> Indicies;
    switch (Tag) {
    case ARMBuildAttrs::File:
      ScopeName = "FileAttributes";
      break;
    case ARMBuildAttrs::Section:
      ScopeName = "SectionAttributes";
      IndexName = "Sections";
      ParseIndexList(Data, Offset, Indicies);
      break;
    case ARMBuildAttrs::Symbol:
      ScopeName = "SymbolAttributes";
      IndexName = "Symbols";
      ParseIndexList(Data, Offset, Indicies);
      break;
    default:
      errs() << "unrecognised tag: 0x" << utohexstr(Tag) << '\n';
      return;
    }

    DictScope ASS(SW, ScopeName);

    if (!Indicies.empty())
      SW.printList(IndexName, Indicies);

    ParseAttributeList(Data, Offset, Length);
  }
}
Qualifier* Sintactico::ParseIndex()
{
	if ( proximo_token.GetTipo() == punt_corchizq )
	{
		proximo_token = analizador_lexico->ObtenerSiguienteToken();

		list<Expresion*>expression_list = ParseIndexList();

		if ( proximo_token.GetTipo() == punt_corchder )
			proximo_token = analizador_lexico->ObtenerSiguienteToken();
		else
			throw SyntaxException("Falta corchete derecho: produccion Index",analizador_lexico->GetLineaActual());

		return new Indexacion(expression_list);
	}
	else
		throw SyntaxException("Falta un corchete izq: producccion Index",analizador_lexico->GetLineaActual());
}