aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.h
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mod/modpost.h')
-rw-r--r--scripts/mod/modpost.h27
1 files changed, 8 insertions, 19 deletions
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 0388cfccac8d..2031119080dc 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -145,33 +145,22 @@ static inline int is_shndx_special(unsigned int i)
145 return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; 145 return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE;
146} 146}
147 147
148/* shndx is in [0..SHN_LORESERVE) U (SHN_HIRESERVE, 0xfffffff], thus: 148/*
149 * shndx == 0 <=> sechdrs[0] 149 * Move reserved section indices SHN_LORESERVE..SHN_HIRESERVE out of
150 * ...... 150 * the way to -256..-1, to avoid conflicting with real section
151 * shndx == SHN_LORESERVE-1 <=> sechdrs[SHN_LORESERVE-1] 151 * indices.
152 * shndx == SHN_HIRESERVE+1 <=> sechdrs[SHN_LORESERVE]
153 * shndx == SHN_HIRESERVE+2 <=> sechdrs[SHN_LORESERVE+1]
154 * ......
155 * fyi: sym->st_shndx is uint16, SHN_LORESERVE = ff00, SHN_HIRESERVE = ffff,
156 * so basically we map 0000..feff -> 0000..feff
157 * ff00..ffff -> (you are a bad boy, dont do it)
158 * 10000..xxxx -> ff00..(xxxx-0x100)
159 */ 152 */
160static inline unsigned int shndx2secindex(unsigned int i) 153#define SPECIAL(i) ((i) - (SHN_HIRESERVE + 1))
161{
162 if (i <= SHN_HIRESERVE)
163 return i;
164 return i - (SHN_HIRESERVE + 1 - SHN_LORESERVE);
165}
166 154
167/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ 155/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
168static inline unsigned int get_secindex(const struct elf_info *info, 156static inline unsigned int get_secindex(const struct elf_info *info,
169 const Elf_Sym *sym) 157 const Elf_Sym *sym)
170{ 158{
159 if (is_shndx_special(sym->st_shndx))
160 return SPECIAL(sym->st_shndx);
171 if (sym->st_shndx != SHN_XINDEX) 161 if (sym->st_shndx != SHN_XINDEX)
172 return sym->st_shndx; 162 return sym->st_shndx;
173 return shndx2secindex(info->symtab_shndx_start[sym - 163 return info->symtab_shndx_start[sym - info->symtab_start];
174 info->symtab_start]);
175} 164}
176 165
177/* file2alias.c */ 166/* file2alias.c */