Ejemplo n.º 1
0
struct node *stringToLinkedList(char *s,struct node *root)
{
	int i,j,num=0,flag = 0;
	for(i=0;s[i] != '\0';i++)
		if(s[i] == '-')
			flag = 1;
		else if(s[i] != ',')
			num = num * 10 + s[i]-'0';
		else 
		{
			root = endInsert(num=flag==0?num:-num,root);
			num = 0;
			flag = 0;
		}
	root = endInsert(num=flag==0?num:-num,root);
	return root;
}
Ejemplo n.º 2
0
struct node *stringToLinkedList(char *s)
{
	struct node *root = (struct node*)malloc(sizeof(struct node));
	root = NULL;
	int i,j,num=0,flag = 0;
	if(s[0]=='\0') return NULL;
	for(i=0;s[i] != '\0';i++)
		if(s[i] == '-')
			flag = 1;
		else if(s[i] != ',')
			num = num * 10 + s[i]-'0';
		else 
		{
			root = endInsert(num=flag==0?num:-num,root);
			num = 0;
			flag = 0;
		}
	root = endInsert(num=flag==0?num:-num,root);
	return root;
}
Ejemplo n.º 3
0
int RelTab::addRel(string name, RT type, int off)
{
	Elf_Sym *sym = symTab->getSymRef(name);

	if (sym != NULL)
	{
		Elf_Rel rel;

		if (sym->getDef() == false) sym->addFRef(off, type);

		if (sym->getBinding() == STB_GLOBAL)
		{
			rel = Elf_Rel(off, type, sym);
			endInsert(rel);
			return (-1)*INS_SIZE;
		}
		if (sym->getBinding() == STB_LOCAL)
		{
			if (sym->getSection() == NULL) rel = Elf_Rel(off, type, NULL);	// dodati fref na mesto
			else
			{
				string sec = sym->getSection()->getName();
				rel = Elf_Rel(off, type, symTab->getSymRef(sec));
			}
			//rel = Elf_Rel(off, type, );
			endInsert(rel);
			return (-1)*INS_SIZE + sym->getValue();
		}
		// throw unknown binding?
	}
	else
	{
		sym = symTab->addUndSym(name, off);
		sym->addFRef(off, type);
		return 0;
	}
}