1/* Return dynamic tag name.
2   Copyright (C) 2001, 2002 Red Hat, Inc.
3   Written by Ulrich Drepper <drepper@redhat.com>, 2001.
4
5   This program is Open Source software; you can redistribute it and/or
6   modify it under the terms of the Open Software License version 1.0 as
7   published by the Open Source Initiative.
8
9   You should have received a copy of the Open Software License along
10   with this program; if not, you may obtain a copy of the Open Software
11   License version 1.0 from http://www.opensource.org/licenses/osl.php or
12   by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
13   3001 King Ranch Road, Ukiah, CA 95482.   */
14
15#ifdef HAVE_CONFIG_H
16# include <config.h>
17#endif
18
19#include <inttypes.h>
20#include <stdio.h>
21#include <libeblP.h>
22
23
24const char *
25ebl_dynamic_tag_name (ebl, tag, buf, len)
26     Ebl *ebl;
27     int64_t tag;
28     char *buf;
29     size_t len;
30{
31  const char *res = ebl != NULL ? ebl->dynamic_tag_name (tag, buf, len) : NULL;
32
33  if (res == NULL)
34    {
35      if (tag >= 0 && tag < DT_NUM)
36	{
37	  static const char *stdtags[] =
38	    {
39	      "NULL", "NEEDED", "PLTRELSZ", "PLTGOT", "HASH", "STRTAB",
40	      "SYMTAB", "RELA", "RELASZ", "RELAENT", "STRSZ", "SYMENT",
41	      "INIT", "FINI", "SONAME", "RPATH", "SYMBOLIC", "REL", "RELSZ",
42	      "RELENT", "PLTREL", "DEBUG", "TEXTREL", "JMPREL", "BIND_NOW",
43	      "INIT_ARRAY", "FINI_ARRAY", "INIT_ARRAYSZ", "FINI_ARRAYSZ",
44	      "RUNPATH", "FLAGS", "ENCODING", "PREINIT_ARRAY",
45	      "PREINIT_ARRAYSZ"
46	    };
47
48	  res = stdtags[tag];
49	}
50      else if (tag == DT_VERSYM)
51	res = "VERSYM";
52      else if (tag >= DT_GNU_PRELINKED && tag <= DT_SYMINENT)
53	{
54	  static const char *valrntags[] =
55	    {
56	      "GNU_PRELINKED", "GNU_CONFLICTSZ", "GNU_LIBLISTSZ",
57	      "CHECKSUM", "PLTPADSZ", "MOVEENT", "MOVESZ", "FEATURE_1",
58	      "POSFLAG_1", "SYMINSZ", "SYMINENT"
59	    };
60
61	  res = valrntags[tag - DT_GNU_PRELINKED];
62	}
63      else if (tag >= DT_GNU_CONFLICT && tag <= DT_SYMINFO)
64	{
65	  static const char *addrrntags[] =
66	    {
67	      "GNU_CONFLICT", "GNU_LIBLIST", "CONFIG", "DEPAUDIT", "AUDIT",
68	      "PLTPAD", "MOVETAB", "SYMINFO"
69	    };
70
71	  res = addrrntags[tag - DT_GNU_CONFLICT];
72	}
73      else if (tag >= DT_RELACOUNT && tag <= DT_VERNEEDNUM)
74	{
75	  static const char *suntags[] =
76	    {
77	      "RELACOUNT", "RELCOUNT", "FLAGS_1", "VERDEF", "VERDEFNUM",
78	      "VERNEED", "VERNEEDNUM"
79	    };
80
81	  res = suntags[tag - DT_RELACOUNT];
82	}
83      else if (tag == DT_AUXILIARY)
84	res = "AUXILIARY";
85      else if (tag == DT_FILTER)
86	res = "FILTER";
87      else
88	{
89	  snprintf (buf, len, gettext ("<unknown>: %" PRId64), tag);
90
91	  res = buf;
92
93	}
94    }
95
96  return res;
97}
98