Blame libebl/eblcorenotetypename.c

Packit 032894
/* Return note type name.
Packit 032894
   Copyright (C) 2002, 2007, 2008, 2012, 2013 Red Hat, Inc.
Packit 032894
   This file is part of elfutils.
Packit 032894
   Written by Ulrich Drepper <drepper@redhat.com>, 2002.
Packit 032894
Packit 032894
   This file is free software; you can redistribute it and/or modify
Packit 032894
   it under the terms of either
Packit 032894
Packit 032894
     * the GNU Lesser General Public License as published by the Free
Packit 032894
       Software Foundation; either version 3 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or
Packit 032894
Packit 032894
     * the GNU General Public License as published by the Free
Packit 032894
       Software Foundation; either version 2 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or both in parallel, as here.
Packit 032894
Packit 032894
   elfutils is distributed in the hope that it will be useful, but
Packit 032894
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 032894
   General Public License for more details.
Packit 032894
Packit 032894
   You should have received copies of the GNU General Public License and
Packit 032894
   the GNU Lesser General Public License along with this program.  If
Packit 032894
   not, see <http://www.gnu.org/licenses/>.  */
Packit 032894
Packit 032894
#ifdef HAVE_CONFIG_H
Packit 032894
# include <config.h>
Packit 032894
#endif
Packit 032894
Packit 032894
#include <inttypes.h>
Packit 032894
#include <stdio.h>
Packit 032894
#include <libeblP.h>
Packit 032894
Packit 032894
const char *
Packit 032894
ebl_core_note_type_name (Ebl *ebl, uint32_t type, char *buf, size_t len)
Packit 032894
{
Packit 032894
  const char *res = ebl->core_note_type_name (type, buf, len);
Packit 032894
Packit 032894
  if (res == NULL)
Packit 032894
    {
Packit 032894
      static const char *knowntypes[] =
Packit 032894
	{
Packit 032894
#define KNOWNSTYPE(name) [NT_##name] = #name
Packit 032894
	  KNOWNSTYPE (PRSTATUS),
Packit 032894
	  KNOWNSTYPE (FPREGSET),
Packit 032894
	  KNOWNSTYPE (PRPSINFO),
Packit 032894
	  KNOWNSTYPE (TASKSTRUCT),
Packit 032894
	  KNOWNSTYPE (PLATFORM),
Packit 032894
	  KNOWNSTYPE (AUXV),
Packit 032894
	  KNOWNSTYPE (GWINDOWS),
Packit 032894
	  KNOWNSTYPE (ASRS),
Packit 032894
	  KNOWNSTYPE (PSTATUS),
Packit 032894
	  KNOWNSTYPE (PSINFO),
Packit 032894
	  KNOWNSTYPE (PRCRED),
Packit 032894
	  KNOWNSTYPE (UTSNAME),
Packit 032894
	  KNOWNSTYPE (LWPSTATUS),
Packit 032894
	  KNOWNSTYPE (LWPSINFO),
Packit 032894
	  KNOWNSTYPE (PRFPXREG)
Packit 032894
#undef KNOWNSTYPE
Packit 032894
	};
Packit 032894
Packit 032894
      /* Handle standard names.  */
Packit 032894
      if (type < sizeof (knowntypes) / sizeof (knowntypes[0])
Packit 032894
	  && knowntypes[type] != NULL)
Packit 032894
	res = knowntypes[type];
Packit 032894
      else
Packit 032894
	switch (type)
Packit 032894
	  {
Packit 032894
#define KNOWNSTYPE(name) case NT_##name: res = #name; break
Packit 032894
	    KNOWNSTYPE (PRXFPREG);
Packit 032894
	    KNOWNSTYPE (PPC_VMX);
Packit 032894
	    KNOWNSTYPE (PPC_SPE);
Packit 032894
	    KNOWNSTYPE (PPC_VSX);
Packit 032894
	    KNOWNSTYPE (PPC_TM_SPR);
Packit 032894
	    KNOWNSTYPE (386_TLS);
Packit 032894
	    KNOWNSTYPE (386_IOPERM);
Packit 032894
	    KNOWNSTYPE (X86_XSTATE);
Packit 032894
	    KNOWNSTYPE (S390_HIGH_GPRS);
Packit 032894
	    KNOWNSTYPE (S390_TIMER);
Packit 032894
	    KNOWNSTYPE (S390_TODCMP);
Packit 032894
	    KNOWNSTYPE (S390_TODPREG);
Packit 032894
	    KNOWNSTYPE (S390_CTRS);
Packit 032894
	    KNOWNSTYPE (S390_PREFIX);
Packit 032894
	    KNOWNSTYPE (S390_LAST_BREAK);
Packit 032894
	    KNOWNSTYPE (S390_SYSTEM_CALL);
Packit 032894
	    KNOWNSTYPE (ARM_VFP);
Packit 032894
	    KNOWNSTYPE (ARM_TLS);
Packit 032894
	    KNOWNSTYPE (ARM_HW_BREAK);
Packit 032894
	    KNOWNSTYPE (ARM_HW_WATCH);
Packit 032894
	    KNOWNSTYPE (ARM_SYSTEM_CALL);
Packit 032894
	    KNOWNSTYPE (SIGINFO);
Packit 032894
	    KNOWNSTYPE (FILE);
Packit 032894
#undef KNOWNSTYPE
Packit 032894
Packit 032894
	  default:
Packit 032894
	    snprintf (buf, len, "%s: %" PRIu32, gettext ("<unknown>"), type);
Packit 032894
Packit 032894
	    res = buf;
Packit 032894
	  }
Packit 032894
    }
Packit 032894
Packit 032894
  return res;
Packit 032894
}