aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/sortextable.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/sortextable.c')
-rw-r--r--scripts/sortextable.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index 7c2310c5b996..7941fbdfb050 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -31,6 +31,10 @@
31#include <tools/be_byteshift.h> 31#include <tools/be_byteshift.h>
32#include <tools/le_byteshift.h> 32#include <tools/le_byteshift.h>
33 33
34#ifndef EM_ARCOMPACT
35#define EM_ARCOMPACT 93
36#endif
37
34#ifndef EM_AARCH64 38#ifndef EM_AARCH64
35#define EM_AARCH64 183 39#define EM_AARCH64 183
36#endif 40#endif
@@ -152,6 +156,30 @@ static void (*w2)(uint16_t, uint16_t *);
152 156
153typedef void (*table_sort_t)(char *, int); 157typedef void (*table_sort_t)(char *, int);
154 158
159/*
160 * Move reserved section indices SHN_LORESERVE..SHN_HIRESERVE out of
161 * the way to -256..-1, to avoid conflicting with real section
162 * indices.
163 */
164#define SPECIAL(i) ((i) - (SHN_HIRESERVE + 1))
165
166static inline int is_shndx_special(unsigned int i)
167{
168 return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE;
169}
170
171/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
172static inline unsigned int get_secindex(unsigned int shndx,
173 unsigned int sym_offs,
174 const Elf32_Word *symtab_shndx_start)
175{
176 if (is_shndx_special(shndx))
177 return SPECIAL(shndx);
178 if (shndx != SHN_XINDEX)
179 return shndx;
180 return r(&symtab_shndx_start[sym_offs]);
181}
182
155/* 32 bit and 64 bit are very similar */ 183/* 32 bit and 64 bit are very similar */
156#include "sortextable.h" 184#include "sortextable.h"
157#define SORTEXTABLE_64 185#define SORTEXTABLE_64
@@ -244,6 +272,7 @@ do_file(char const *const fname)
244 case EM_S390: 272 case EM_S390:
245 custom_sort = sort_relative_table; 273 custom_sort = sort_relative_table;
246 break; 274 break;
275 case EM_ARCOMPACT:
247 case EM_ARM: 276 case EM_ARM:
248 case EM_AARCH64: 277 case EM_AARCH64:
249 case EM_MIPS: 278 case EM_MIPS: