aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.h
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@ksplice.com>2011-05-19 18:55:27 -0400
committerRusty Russell <rusty@rustcorp.com.au>2011-05-19 03:25:28 -0400
commit6845756b29e4c4e7db41e2d75cafa9d091bc1c07 (patch)
treecceb66e295b238d2ab62a9ca77c9b6adce867935 /scripts/mod/modpost.h
parent9d63487f86115b1d3ef69670043bcf2b83c4d227 (diff)
modpost: Update 64k section support for binutils 2.18.50
Binutils 2.18.50 made a backwards-incompatible change in the way it writes ELF objects with over 65280 sections, to improve conformance with the ELF specification and interoperability with other ELF tools. Specifically, it no longer adds 256 to section indices SHN_LORESERVE and higher to skip over the reserved range SHN_LORESERVE through SHN_HIRESERVE; those values are only considered special in the st_shndx field, and not in other places where section indices are stored. See: http://sourceware.org/bugzilla/show_bug.cgi?id=5900 http://groups.google.com/group/generic-abi/browse_thread/thread/e8bb63714b072e67/6c63738f12cc8a17 Signed-off-by: Anders Kaseorg <andersk@ksplice.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
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 */