Пример #1
0
static int choose_best_symbol(struct symbol *syma, struct symbol *symb)
{
    s64 a;
    s64 b;
    size_t na, nb;

    /* Prefer a symbol with non zero length */
    a = syma->end - syma->start;
    b = symb->end - symb->start;
    if ((b == 0) && (a > 0))
        return SYMBOL_A;
    else if ((a == 0) && (b > 0))
        return SYMBOL_B;

    /* Prefer a non weak symbol over a weak one */
    a = syma->binding == STB_WEAK;
    b = symb->binding == STB_WEAK;
    if (b && !a)
        return SYMBOL_A;
    if (a && !b)
        return SYMBOL_B;

    /* Prefer a global symbol over a non global one */
    a = syma->binding == STB_GLOBAL;
    b = symb->binding == STB_GLOBAL;
    if (a && !b)
        return SYMBOL_A;
    if (b && !a)
        return SYMBOL_B;

    /* Prefer a symbol with less underscores */
    a = prefix_underscores_count(syma->name);
    b = prefix_underscores_count(symb->name);
    if (b > a)
        return SYMBOL_A;
    else if (a > b)
        return SYMBOL_B;

    /* Choose the symbol with the longest name */
    na = strlen(syma->name);
    nb = strlen(symb->name);
    if (na > nb)
        return SYMBOL_A;
    else if (na < nb)
        return SYMBOL_B;

    /* Avoid "SyS" kernel syscall aliases */
    if (na >= 3 && !strncmp(syma->name, "SyS", 3))
        return SYMBOL_B;
    if (na >= 10 && !strncmp(syma->name, "compat_SyS", 10))
        return SYMBOL_B;

    return SYMBOL_A;
}
Пример #2
0
static int choose_best_symbol(struct symbol *syma, struct symbol *symb)
{
	s64 a;
	s64 b;

	/* Prefer a symbol with non zero length */
	a = syma->end - syma->start;
	b = symb->end - symb->start;
	if ((b == 0) && (a > 0))
		return SYMBOL_A;
	else if ((a == 0) && (b > 0))
		return SYMBOL_B;

	/* Prefer a non weak symbol over a weak one */
	a = syma->binding == STB_WEAK;
	b = symb->binding == STB_WEAK;
	if (b && !a)
		return SYMBOL_A;
	if (a && !b)
		return SYMBOL_B;

	/* Prefer a global symbol over a non global one */
	a = syma->binding == STB_GLOBAL;
	b = symb->binding == STB_GLOBAL;
	if (a && !b)
		return SYMBOL_A;
	if (b && !a)
		return SYMBOL_B;

	/* Prefer a symbol with less underscores */
	a = prefix_underscores_count(syma->name);
	b = prefix_underscores_count(symb->name);
	if (b > a)
		return SYMBOL_A;
	else if (a > b)
		return SYMBOL_B;

	/* If all else fails, choose the symbol with the longest name */
	if (strlen(syma->name) >= strlen(symb->name))
		return SYMBOL_A;
	else
		return SYMBOL_B;
}