modpost: refactor get_secindex()
SPECIAL() is only used in get_secindex(). Squash it. Make the code more readable with more comments. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
parent
dd29865633
commit
36b0f0deed
@ -156,22 +156,28 @@ static inline int is_shndx_special(unsigned int i)
|
|||||||
return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE;
|
return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Move reserved section indices SHN_LORESERVE..SHN_HIRESERVE out of
|
|
||||||
* the way to -256..-1, to avoid conflicting with real section
|
|
||||||
* indices.
|
|
||||||
*/
|
|
||||||
#define SPECIAL(i) ((i) - (SHN_HIRESERVE + 1))
|
|
||||||
|
|
||||||
/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
|
/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
|
||||||
static inline unsigned int get_secindex(const struct elf_info *info,
|
static inline unsigned int get_secindex(const struct elf_info *info,
|
||||||
const Elf_Sym *sym)
|
const Elf_Sym *sym)
|
||||||
{
|
{
|
||||||
if (is_shndx_special(sym->st_shndx))
|
unsigned int index = sym->st_shndx;
|
||||||
return SPECIAL(sym->st_shndx);
|
|
||||||
if (sym->st_shndx != SHN_XINDEX)
|
/*
|
||||||
return sym->st_shndx;
|
* Elf{32,64}_Sym::st_shndx is 2 byte. Big section numbers are available
|
||||||
return info->symtab_shndx_start[sym - info->symtab_start];
|
* in the .symtab_shndx section.
|
||||||
|
*/
|
||||||
|
if (index == SHN_XINDEX)
|
||||||
|
return info->symtab_shndx_start[sym - info->symtab_start];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Move reserved section indices SHN_LORESERVE..SHN_HIRESERVE out of
|
||||||
|
* the way to UINT_MAX-255..UINT_MAX, to avoid conflicting with real
|
||||||
|
* section indices.
|
||||||
|
*/
|
||||||
|
if (index >= SHN_LORESERVE && index <= SHN_HIRESERVE)
|
||||||
|
return index - SHN_HIRESERVE - 1;
|
||||||
|
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* file2alias.c */
|
/* file2alias.c */
|
||||||
|
Loading…
Reference in New Issue
Block a user