1 /*
2 ** data.c for elfsh
3 **
4 ** Started on  Mon Feb 26 04:06:38 2001 mayhem
5 ** Last update Mon Jun 23 05:47:27 2003 mayhem
6 */
7 #include "elfsh.h"
8 
9 
10 
11 
12 
13 /* Program header (segment) entry strings */
14 elfshconst_t			elfsh_seg_type[] =
15 {
16   {"NULL segment"         , "PT_NULL"   , PT_NULL},
17   {"Loadable segment"     , "PT_LOAD"   , PT_LOAD},
18   {"Dynamic linking info" , "PT_DYNAMIC", PT_DYNAMIC},
19   {"Program interpreter"  , "PT_INTERP" , PT_INTERP},
20   {"Auxiliary information", "PT_NOTE"   , PT_NOTE},
21   {"Reserved"             , "PT_SHLIB"  , PT_SHLIB},
22   {"Program header table" , "PT_PHDR"   , PT_PHDR},
23 };
24 
25 
26 /* Encoding type in ELF header */
27 elfshconst_t			elfsh_encoding[] =
28 {
29   {"Invalid encoding", "ELFDATANONE", ELFDATANONE},
30   {"Little endian"   , "ELFDATA2LSB", ELFDATA2LSB},
31   {"Big endian"      , "ELFDATA2MSB", ELFDATA2MSB},
32 };
33 
34 
35 /* Section type strings */
36 elfshconst_t			elfsh_sh_type[] =
37   {
38   {"NULL section"           , "SHT_NULL"    , SHT_NULL},
39   {"Program data"           , "SHT_PROGBITS", SHT_PROGBITS},
40   {"Symbol table"           , "SHT_SYMTAB"  , SHT_SYMTAB},
41   {"String table"           , "SHT_STRTAB"  , SHT_STRTAB},
42   {"Reloc. ent. w/ addends" , "SHT_RELA"    , SHT_RELA},
43   {"Symbol hash table"      , "SHT_HASH"    , SHT_HASH},
44   {"Dynamic linking info"   , "SHT_DYNAMIC" , SHT_DYNAMIC},
45   {"Notes"                  , "SHT_NOTES"   , SHT_NOTE},
46   {"BSS"                    , "SHT_NOBITS"  , SHT_NOBITS},
47   {"Reloc. ent. w/o addends", "SHT_REL"     , SHT_REL},
48   {"Reserved"               , "SHT_SHLIB"   , SHT_SHLIB},
49   {"Dynamic linker symtab"  , "SHT_DYNSYM"  , SHT_DYNSYM},
50 };
51 
52 
53 /* ELF object type strings */
54 elfshconst_t			elfsh_obj_type[] =
55 {
56   {"Unknown"               , "ET_NONE", ET_NONE},
57   {"Relocatable object"    , "ET_REL" , ET_REL},
58   {"Executable object"     , "ET_EXEC", ET_EXEC},
59   {"Shared object"         , "ET_DYN" , ET_DYN},
60   {"Core file"             , "ET_CORE", ET_CORE},
61 };
62 
63 /* Symbol Binding strings */
64 elfshconst_t			elfsh_sym_bind[] =
65 {
66   {"Local"            , "STB_LOCAL"  , STB_LOCAL},
67   {"Global"           , "STB_GLOBAL" , STB_GLOBAL},
68   {"Weak"             , "STB_WEAK"   , STB_WEAK},
69 };
70 
71 
72 /* Symbol Type strings */
73 elfshconst_t			elfsh_sym_type[] =
74 {
75   {"NOTYPE"  , "STT_NOTYPE" , STT_NOTYPE},
76   {"VARIABLE", "STT_OBJECT" , STT_OBJECT},
77   {"FUNCTION", "STT_FUNC"   , STT_FUNC},
78   {"SECTION" , "STT_SECTION", STT_SECTION},
79   {"FILENAME", "STT_FILE"   , STT_FILE},
80   {"COMMON"  , "STT_COMMON" , STT_COMMON},
81   {"BLOCK"   , "STT_BLOCK"  , STT_BLOCK},
82 };
83 
84 
85 
86 /* Dynamic section entry type strings */
87 elfshconst_t			elfsh_dynentry_type[] =
88 {
89   {"END OF DYNAMIC SECTION"           , "DT_NULL"        , DT_NULL},
90   {"Name of needed library"           , "DT_NEEDED"      , DT_NEEDED},
91   {"Size in bytes for .rel.plt"       , "DT_PLTRELSZ"     , DT_PLTRELSZ},
92   {"Processor defined value"          , "DT_PLTGOT"      , DT_PLTGOT},
93   {"Address of symbol hash table"     , "DT_HASH"        , DT_HASH},
94   {"Address of dynamic string table"  , "DT_STRTAB"       , DT_STRTAB},
95   {"Address of dynamic symbol table"  , "DT_SYMTAB"      , DT_SYMTAB},
96   {"Address of relocs info w/ add-end", "DT_RELA"        , DT_RELA},
97   {"Totsize of relocs info w/ add-end", "DT_RELASZ"      , DT_RELASZ},
98   {"Size of RELA entry"               , "DT_RELAENT"     , DT_RELAENT},
99   {"Size of string table"             , "DT_STRSZ"       , DT_STRSZ},
100   {"Size of symbol table entry"       , "DT_SYMENT"      , DT_SYMENT},
101   {"Address of init function"         , "DT_INIT"        , DT_INIT},
102   {"Address of fini function"         , "DT_FINI"        , DT_FINI},
103   {"Name of shared object"            , "DT_SONAME"      , DT_SONAME},
104   {"Library search path"              , "DT_RPATH"       , DT_RPATH},
105   {"Start symbol search here"         , "DT_SYMBOLIC"    , DT_SYMBOLIC},
106   {"Address of .rel.got section"      , "DT_REL"         , DT_REL},
107   {"Total size of .rel section"       , "DT_RELSZ"       , DT_RELSZ},
108   {"Size of a REL entry"              , "DT_RELENT"      , DT_RELENT},
109   {"Type of reloc in PLT"             , "DT_PLTREL"      , DT_PLTREL},
110   {"Debugging entry (unknown)"        , "DT_DEBUG"       , DT_DEBUG},
111   {"Reloc might modify .text"         , "DT_TEXTREL"     , DT_TEXTREL},
112   {"Address of .rel.plt"              , "DT_JMPREL"      , DT_JMPREL},
113   {"Process relocations of object"    , "DT_BIND_NOW"    , DT_BIND_NOW},
114   {"Array with addresses of init fct" , "DT_INIT_ARRAY"  , DT_INIT_ARRAY},
115   {"Array with addresses of fini fct" , "DT_FINI_ARRAY"  , DT_FINI_ARRAY},
116   {"Size in bytes of DT_INIT_ARRAY"   , "DT_INIT_ARRAYSZ", DT_INIT_ARRAYSZ},
117   {"Size in bytes of DT_FINI_ARRAY"   , "DT_FINI_ARRAYSZ", DT_FINI_ARRAYSZ},
118   {"Library search path"              , "DT_RUNPATH"     , DT_RUNPATH},
119   {"Flags for the object being loaded", "DT_FLAGS"       , DT_FLAGS},
120   {"Start of encoded range"           , "DT_ENCODING"    , DT_ENCODING},
121   {"Pre-init function addresses array", "DT_PREINIT_ARRAY", DT_PREINIT_ARRAY},
122   {"Size in bytes of DT_PREINIT_ARRAY", "DT_PREINIT_ARRAYSZ", DT_PREINIT_ARRAYSZ},
123   {"Number used"                      , "DT_NUM"         , DT_NUM},
124 };
125 
126 
127 /* Extended dynamic types */
128 elfshconst_t			elfsh_extdyn_type[] =
129 {
130   {"Feature selection"                , "DT_FEATURE_1" , DT_FEATURE_1},
131   {"DT entries flags"                 , "DT_POSFLAG_1" , DT_POSFLAG_1},
132   {"Syminfo table size"               , "DT_SYMINSZ"   , DT_SYMINSZ},
133   {"Syminfo entry size"               , "DT_SYMINENT"  , DT_SYMINENT},
134   {"Syminfo table"                    , "DT_SYMINFO"   , DT_SYMINFO},
135   {"GNU version VERSYM"               , "DT_VERSYM"    , DT_VERSYM},
136   {"GNU version RELACCOUNT"           , "DT_RELACOUNT" , DT_RELACOUNT},
137   {"GNU version RELCOUNT"             , "DT_RELCOUNT"  , DT_RELCOUNT},
138   {"State flags"                      , "DT_FLAGS_1"   , DT_FLAGS_1},
139   {"SUN version table address"        , "DT_VERDEF"    , DT_VERDEF},
140   {"SUN version table number"         , "DT_VERDEFNUM" , DT_VERDEFNUM},
141   {"SUN needed version table"         , "DT_VERNEED"   , DT_VERNEED},
142   {"SUN needed version number"        , "DT_VERNEEDNUM", DT_VERNEEDNUM},
143   {"Shared object to load before self", "DT_AUXILIARY" , DT_AUXILIARY},
144   {"Shared object to get values from" , "DT_FILTER"    , DT_FILTER},
145   {"[?]"                              , "DT_CHECKSUM"  , DT_CHECKSUM},
146   {"[?]"                              , "DT_PLTPADSZ"  , DT_PLTPADSZ},
147   {"[?]"                              , "DT_MOVEENT"   , DT_MOVEENT},
148   {"[?]"                              , "DT_MOVESZ"    , DT_MOVESZ},
149 };
150 
151 
152 
153 /* The next 4 arrays are special flag based DT entries */
154 /* Enumeration of '<< 1' increment */
155 elfshconst_t			elfsh_feature1[] =
156 {
157   {"Option 1: PARINIT(?)", "DTF_1_PARINIT", DTF_1_PARINIT},
158   {"Option 2: CONFEXP(?)", "DTF_1_CONFEXP", DTF_1_CONFEXP},
159 };
160 
161 elfshconst_t			elfsh_posflag1[] =
162 {
163   {"Lazyload following object"              , "DF_P1_LAZYLOAD" , DF_P1_LAZYLOAD},
164   {"Next object symbols maybe not available", "DF_P1_GROUPPERM", DF_P1_GROUPPERM},
165 };
166 
167 elfshconst_t			elfsh_flags[] =
168 {
169   {"Object may use DF_ORIGIN"        , "DF_ORIGIN"  , DF_ORIGIN},
170   {"Symbol resolutions starts here"  , "DF_SYMBOLIC", DF_SYMBOLIC},
171   {"Object contains text relocations", "DF_TEXTREL" , DF_TEXTREL},
172   {"No lazy binding for this object" , "DF_BIND_NOW", DF_BIND_NOW},
173 };
174 
175 elfshconst_t			elfsh_flags1[] =
176 {
177   {"Set RTLD_NOW for this object"      , "DF_1_NOW"      , DF_1_NOW},
178   {"Set RTLD_GLOBAL for this object"   , "DF_1_GLOBAL"   , DF_1_GLOBAL},
179   {"Set RTLD_GROUP for this object"    , "DF_1_GROUP"    , DF_1_GROUP},
180   {"Set RTLD_NODELETE for this object" , "DF_1_NODELETE" , DF_1_NODELETE},
181   {"Trigger filtee loading at runtime" , "DF_1_LOADFLTR" , DF_1_LOADFLTR},
182   {"Set RTLD_INITFIRST for this object", "DF_1_INITFIRST", DF_1_INITFIRST},
183   {"Set RTLD_NOOPEN for this object"   , "DF_1_NOOPEN"   , DF_1_NOOPEN},
184   {"$ORIGIN must be handled"           , "DF_1_ORIGIN"   , DF_1_ORIGIN},
185   {"Direct binding enabled"            , "DF_1_DIRECT"   , DF_1_DIRECT},
186   {"Option 200: TRANS(?)"              , "DF_1_TRANS"    , DF_1_TRANS},
187   {"Object is used to interpose"       , "DF_1_INTERPOSE", DF_1_INTERPOSE},
188   {"Ignore default lib search path"    , "DF_1_NODEFLIB" , DF_1_NODEFLIB},
189   {"Option 1000: NODUMP(?)"            , "DF_1_NODUMP"   , DF_1_NODUMP},
190   {"Option 2000: CONFALT(?)"           , "DF_1_CONFALT"	 , DF_1_CONFALT},
191   {"Option 4000: ENDFILTEE(?)"         , "DF_1_ENDFILTEE", DF_1_ENDFILTEE},
192 };
193 
194 
195 
196 /* Relocation types strings */
197 elfshconst_t			elfsh_rel_type_i386[] =
198 {
199   {"No relocation"                   , "R_386_NONE"    , R_386_NONE},
200   {"Direct 32 bit"                   , "R_386_32"      , R_386_32},
201   {"Relative 32 bit"                 , "R_386_PC32"    , R_386_PC32},
202   {"32 bit GOT entry"                , "R_386_GOT32"   , R_386_GOT32},
203   {"32 bit PLT entry"                , "R_386_PLT32"   , R_386_PLT32},
204   {"Copy symbol at runtime"          , "R_386_COPY"    , R_386_COPY},
205   {"Create GOT entry"                , "R_386_GLOB_DAT", R_386_GLOB_DAT},
206   {"Create PLT entry"                , "R_386_JMP_SLOT", R_386_JMP_SLOT},
207   {"Adjust by program base address"  , "R_386_RELATIVE", R_386_RELATIVE},
208   {"32 bit offset to GOT"            , "R_386_GOTOFF"  , R_386_GOTOFF},
209   {"32 bit PC relative offset to GOT", "R_386_GOTPC"   , R_386_GOTPC},
210 };
211 
212 /* Relocation types strings for SPARC */
213 elfshconst_t                    elfsh_rel_type_sparc[] =
214 {
215   {"No relocation"                  , "R_SPARC_NONE"      , R_SPARC_NONE},
216   {"Direct 8 bit"                   , "R_SPARC_8"	  , R_SPARC_8},
217   {"Direct 16 bit"                  , "R_SPARC_16"        , R_SPARC_16},
218   {"Direct 32 bit"                  , "R_SPARC_32"        , R_SPARC_32},
219   {"PC relative 8 bit"              , "R_SPARC_DISP8"     , R_SPARC_DISP8},
220   {"PC relative 16 bit"             , "R_SPARC_DISP16"    , R_SPARC_DISP16},
221   {"PC relative 32 bit"             , "R_SPARC_DISP32"    , R_SPARC_DISP32},
222   {"PC relative 30 bit shifted"     , "R_SPARC_WDISP30"   , R_SPARC_WDISP30},
223   {"PC relative 22 bit shifted"     , "R_SPARC_WDISP22"   , R_SPARC_WDISP22},
224   {"High 22 bit"                    , "R_SPARC_HI22"      , R_SPARC_HI22},
225   {"Direct 22 bit"                  , "R_SPARC_22"        , R_SPARC_22},
226   {"Direct 13 bit"                  , "R_SPARC_13"        , R_SPARC_13},
227   {"Truncated 10 bit"               , "R_SPARC_LO10"      , R_SPARC_LO10},
228   {"Truncated 10 bit GOT entry"     , "R_SPARC_GOT10"     , R_SPARC_GOT10},
229   {"13 bit GOT entry"               , "R_SPARC_GOT13"     , R_SPARC_GOT13},
230   {"22 bit GOT entry shifted"       , "R_SPARC_GOT22"     , R_SPARC_GOT22},
231   {"PC relative 10 bit truncated"   , "R_SPARC_PC10"      , R_SPARC_PC10},
232   {"PC relative 22 bit shifted"     , "R_SPARC_PC22"      , R_SPARC_PC22},
233   {"30 bit PC relative PLT address" , "R_SPARC_WPLT30"    , R_SPARC_WPLT30},
234   {"Copy symbol at runtime"         , "R_SPARC_COPY"      , R_SPARC_COPY},
235   {"Create GOT entry"               , "R_SPARC_GLOB_DAT"  , R_SPARC_GLOB_DAT},
236   {"Create PLT entry"               , "R_SPARC_JMP_SLOT"  , R_SPARC_JMP_SLOT},
237   {"Adjust by program base"         , "R_SPARC_RELATIVE"  , R_SPARC_RELATIVE},
238   {"Direct 32 bit unaligned"        , "R_SPARC_UA32"      , R_SPARC_UA32},
239 };
240 
241 
242 
243 /* Architecture strings */
244 char			*elfsh_arch_type[] =
245 {
246   "No machine"           ,
247   "AT&T WE 32100"        ,
248   "SUN SPARC"            ,
249   "Intel 80386"          ,
250   "Motorola m68k family" ,
251   "Motorola m88k family" ,
252   "Intel 80486"          ,
253   "Intel 80860"          ,
254   "MIPS R3000 big-endian",
255   "Amdahl"               ,
256   "MIPS R4000 big-endian",
257   "RS6000"               ,
258   "Unknown"              ,
259   "Unknown"              ,
260   "Unknown"              ,
261   "HPPA"                 ,
262   "nCUBE"                ,
263   "Fujitsu VPP500"       ,
264   "Sun's v8plus"         ,
265   "Intel 80960"          ,
266   "PowerPC"              ,
267   "Unknown"              ,
268   "Unknown"              ,
269   "Unknown"              ,
270   "Unknown"              ,
271   "Unknown"              ,
272   "Unknown"              ,
273   "Unknown"              ,
274   "Unknown"              ,
275   "Unknown"              ,
276   "Unknown"              ,
277   "Unknown"              ,
278   "Unknown"              ,
279   "Unknown"              ,
280   "Unknown"              ,
281   "Unknown"              ,
282   "Unknown"              ,
283   "NEC V800 series"      ,
284   "Fujitsu FR20"         ,
285   "TRW RH32"             ,
286   "Fujitsu MMA"          ,
287   "ARM"                  ,
288   "Digital Alpha"        ,
289   "Hitachi SH"           ,
290   "SPARC v9 64-bit"      ,
291   "Siemens Tricore"      ,
292   "Argonaut RISC Core"   ,
293   "Hitachi H8/300"       ,
294   "Hitachi H8/300H"      ,
295   "Hitachi H8S"          ,
296   "Hitachi H8/500"       ,
297   "Intel Merced"         ,
298   "Stanford MIPS-X"      ,
299   "Motorola Coldfire"    ,
300   "Motorola M68HC12"     ,
301 };
302 
303 
304 /* Stab entry type strings */
305 char		*elfsh_stab_type[] =
306 {
307   "Undefined symbol",
308   "Unknown",
309   "File scope absolute symbol",
310   "External absolute symbol",
311   "File scope text symbol",
312   "External text symbol",
313   "File scope data symbol",
314   "External data symbol",
315   "File scope BSS symbol",
316   "External BSS symbol",
317   "Symbol is indirected to another symbol",
318   "Unknown",
319   "Same as N_FN, for Sequent compilers",
320   "Unknown",
321   "Unknown",
322   "Unknown",
323   "Unknown",
324   "Unknown",
325   "Common--visible after shared library dynamic link",
326   "Unknown",
327   "Unknown",
328   "Absolute set element",
329   "Unknown",
330   "Text segment set element",
331   "Unknown",
332   "Data segment set element",
333   "Unknown",
334   "BSS segment set element",
335   "Unknown",
336   "Pointer to set vector",
337   "Print a warning message during linking",
338   "File name of a module",
339   "Global symbol",
340   "Unknown",
341   "Function name (for BSD Fortran)",
342   "Unknown",
343   "Function name (see section 2.5 Procedures) or text segment variable",
344   "Unknown",
345   "Data segment file-scope variable",
346   "Unknown",
347   "BSS segment file-scope variable",
348   "Unknown",
349   "Name of main routine",
350   "Unknown",
351   "Variable in .rodata section",
352   "Unknown",
353   "Unknown",
354   "Unknown",
355   "Global symbol (for Pascal)",
356   "Unknown",
357   "Number of symbols (according to Ultrix V4.0)",
358   "Unknown",
359   "No DST map",
360   "Unknown",
361   "Unknown",
362   "Unknown",
363   "Object file (Solaris2)",
364   "Unknown",
365   "Unknown",
366   "Unknown",
367   "Debugger options (Solaris2)",
368   "Unknown",
369   "Unknown",
370   "Unknown",
371   "Register variable",
372   "Unknown",
373   "Modula-2 compilation unit",
374   "Unknown",
375   "Line number in text segment",
376   "Unknown",
377   "Line number in data segment",
378   "Unknown",
379   "Line number in bss segment",
380   "Unknown",
381   "GNU Modula2 definition module dependency",
382   "Unknown",
383   "Function start/body/end line numbers (Solaris2)",
384   "Unknown",
385   "Unknown",
386   "Unknown",
387   "GNU C++ exception variable",
388   "Unknown",
389   "Unknown",
390   "Unknown",
391   "GNU C++ catch clause",
392   "Unknown",
393   "Unknown",
394   "Unknown",
395   "Unknown",
396   "Unknown",
397   "Unknown",
398   "Unknown",
399   "Unknown",
400   "Unknown",
401   "Unknown",
402   "Unknown",
403   "Structure of union element",
404   "Unknown",
405   "Last stab for module (Solaris2)",
406   "Unknown",
407   "Path and name of source file",
408   "Unknown",
409   "Unknown",
410   "Unknown",
411   "Unknown",
412   "Unknown",
413   "Unknown",
414   "Unknown",
415   "Unknown",
416   "Unknown",
417   "Unknown",
418   "Unknown",
419   "Unknown",
420   "Unknown",
421   "Unknown",
422   "Unknown",
423   "Unknown",
424   "Unknown",
425   "Unknown",
426   "Unknown",
427   "Unknown",
428   "Unknown",
429   "Unknown",
430   "Unknown",
431   "Unknown",
432   "Unknown",
433   "Unknown",
434   "Unknown",
435   "Stack variable",
436   "Unknown",
437   "Beginning of an include file (Sun only)",
438   "Unknown",
439   "Name of include file",
440   "Unknown",
441   "Unknown",
442   "Unknown",
443   "Unknown",
444   "Unknown",
445   "Unknown",
446   "Unknown",
447   "Unknown",
448   "Unknown",
449   "Unknown",
450   "Unknown",
451   "Unknown",
452   "Unknown",
453   "Unknown",
454   "Unknown",
455   "Unknown",
456   "Unknown",
457   "Unknown",
458   "Unknown",
459   "Unknown",
460   "Unknown",
461   "Unknown",
462   "Unknown",
463   "Unknown",
464   "Unknown",
465   "Unknown",
466   "Unknown",
467   "Parameter variable",
468   "Unknown",
469   "End of an include file",
470   "Unknown",
471   "Alternate entry point",
472   "Unknown",
473   "Unknown",
474   "Unknown",
475   "Unknown",
476   "Unknown",
477   "Unknown",
478   "Unknown",
479   "Unknown",
480   "Unknown",
481   "Unknown",
482   "Unknown",
483   "Unknown",
484   "Unknown",
485   "Unknown",
486   "Unknown",
487   "Unknown",
488   "Unknown",
489   "Unknown",
490   "Unknown",
491   "Unknown",
492   "Unknown",
493   "Unknown",
494   "Unknown",
495   "Unknown",
496   "Unknown",
497   "Unknown",
498   "Unknown",
499   "Beginning of a lexical block",
500   "Unknown",
501   "Place holder for a deleted include file",
502   "Unknown",
503   "Modula2 scope information (Sun linker)",
504   "Unknown",
505   "Unknown",
506   "Unknown",
507   "Unknown",
508   "Unknown",
509   "Unknown",
510   "Unknown",
511   "Unknown",
512   "Unknown",
513   "Unknown",
514   "Unknown",
515   "Unknown",
516   "Unknown",
517   "Unknown",
518   "Unknown",
519   "Unknown",
520   "Unknown",
521   "Unknown",
522   "Unknown",
523   "Unknown",
524   "Unknown",
525   "Unknown",
526   "Unknown",
527   "Unknown",
528   "Unknown",
529   "Unknown",
530   "Unknown",
531   "End of a lexical block",
532   "Unknown",
533   "Begin named common block",
534   "Unknown",
535   "End named common block",
536   "Unknown",
537   "Unknown",
538   "Unknown",
539   "Member of a common block",
540   "Unknown",
541   "Pascal with statement: type,,0,0,offset (Solaris2)",
542   "Unknown",
543   "Unknown",
544   "Unknown",
545   "Unknown",
546   "Unknown",
547   "Gould non-base registers",
548   "Unknown",
549   "Gould non-base registers",
550   "Unknown",
551   "Gould non-base registers",
552   "Unknown",
553   "Gould non-base registers",
554   "Unknown",
555   "Gould non-base registers",
556   "Unknown",
557   "Unknown",
558   "Unknown",
559   "Unknown",
560   "Unknown",
561   "Unknown",
562   "Unknown",
563 };
564 
565 
566 
567 
568 
569 
570 
571 
572 
573 
574 
575 
576