|
Packit Service |
97d2fb |
/* i386 specific core note handling.
|
|
Packit Service |
97d2fb |
Copyright (C) 2007-2010 Red Hat, Inc.
|
|
Packit Service |
97d2fb |
This file is part of elfutils.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
This file is free software; you can redistribute it and/or modify
|
|
Packit Service |
97d2fb |
it under the terms of either
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
* the GNU Lesser General Public License as published by the Free
|
|
Packit Service |
97d2fb |
Software Foundation; either version 3 of the License, or (at
|
|
Packit Service |
97d2fb |
your option) any later version
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
or
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
* the GNU General Public License as published by the Free
|
|
Packit Service |
97d2fb |
Software Foundation; either version 2 of the License, or (at
|
|
Packit Service |
97d2fb |
your option) any later version
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
or both in parallel, as here.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
elfutils is distributed in the hope that it will be useful, but
|
|
Packit Service |
97d2fb |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
97d2fb |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
97d2fb |
General Public License for more details.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
You should have received copies of the GNU General Public License and
|
|
Packit Service |
97d2fb |
the GNU Lesser General Public License along with this program. If
|
|
Packit Service |
97d2fb |
not, see <http://www.gnu.org/licenses/>. */
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
97d2fb |
# include <config.h>
|
|
Packit Service |
97d2fb |
#endif
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#include <elf.h>
|
|
Packit Service |
97d2fb |
#include <inttypes.h>
|
|
Packit Service |
97d2fb |
#include <stddef.h>
|
|
Packit Service |
97d2fb |
#include <stdio.h>
|
|
Packit Service |
97d2fb |
#include <sys/time.h>
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#define BACKEND i386_
|
|
Packit Service |
97d2fb |
#include "libebl_CPU.h"
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
static const Ebl_Register_Location prstatus_regs[] =
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
#define GR(at, n, dwreg) \
|
|
Packit Service |
97d2fb |
{ .offset = at * 4, .regno = dwreg, .count = n, .bits = 32 }
|
|
Packit Service |
97d2fb |
#define SR(at, n, dwreg) \
|
|
Packit Service |
97d2fb |
{ .offset = at * 4, .regno = dwreg, .count = n, .bits = 16, .pad = 2 }
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
GR (0, 1, 3), /* %ebx */
|
|
Packit Service |
97d2fb |
GR (1, 2, 1), /* %ecx-%edx */
|
|
Packit Service |
97d2fb |
GR (3, 2, 6), /* %esi-%edi */
|
|
Packit Service |
97d2fb |
GR (5, 1, 5), /* %ebp */
|
|
Packit Service |
97d2fb |
GR (6, 1, 0), /* %eax */
|
|
Packit Service |
97d2fb |
SR (7, 1, 43), /* %ds */
|
|
Packit Service |
97d2fb |
SR (8, 1, 40), /* %es */
|
|
Packit Service |
97d2fb |
SR (9, 1, 44), /* %fs */
|
|
Packit Service |
97d2fb |
SR (10, 1, 45), /* %gs */
|
|
Packit Service |
97d2fb |
/* 11, 1, orig_eax */
|
|
Packit Service |
97d2fb |
GR (12, 1, 8), /* %eip */
|
|
Packit Service |
97d2fb |
SR (13, 1, 41), /* %cs */
|
|
Packit Service |
97d2fb |
GR (14, 1, 9), /* eflags */
|
|
Packit Service |
97d2fb |
GR (15, 1, 4), /* %esp */
|
|
Packit Service |
97d2fb |
SR (16, 1, 42), /* %ss */
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#undef GR
|
|
Packit Service |
97d2fb |
#undef SR
|
|
Packit Service |
97d2fb |
};
|
|
Packit Service |
97d2fb |
#define PRSTATUS_REGS_SIZE (17 * 4)
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#define ULONG uint32_t
|
|
Packit Service |
97d2fb |
#define PID_T int32_t
|
|
Packit Service |
97d2fb |
#define UID_T uint16_t
|
|
Packit Service |
97d2fb |
#define GID_T uint16_t
|
|
Packit Service |
97d2fb |
#define ALIGN_ULONG 4
|
|
Packit Service |
97d2fb |
#define ALIGN_PID_T 4
|
|
Packit Service |
97d2fb |
#define ALIGN_UID_T 2
|
|
Packit Service |
97d2fb |
#define ALIGN_GID_T 2
|
|
Packit Service |
97d2fb |
#define TYPE_ULONG ELF_T_WORD
|
|
Packit Service |
97d2fb |
#define TYPE_PID_T ELF_T_SWORD
|
|
Packit Service |
97d2fb |
#define TYPE_UID_T ELF_T_HALF
|
|
Packit Service |
97d2fb |
#define TYPE_GID_T ELF_T_HALF
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#define PRSTATUS_REGSET_ITEMS \
|
|
Packit Service |
97d2fb |
{ \
|
|
Packit Service |
97d2fb |
.name = "orig_eax", .type = ELF_T_SWORD, .format = 'd', \
|
|
Packit Service |
97d2fb |
.offset = offsetof (struct EBLHOOK(prstatus), pr_reg) + (4 * 11), \
|
|
Packit Service |
97d2fb |
.group = "register" \
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
static const Ebl_Register_Location fpregset_regs[] =
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
{ .offset = 0, .regno = 37, .count = 2, .bits = 32 }, /* fctrl-fstat */
|
|
Packit Service |
97d2fb |
{ .offset = 7 * 4, .regno = 11, .count = 8, .bits = 80 }, /* stN */
|
|
Packit Service |
97d2fb |
};
|
|
Packit Service |
97d2fb |
#define FPREGSET_SIZE 108
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
static const Ebl_Register_Location prxfpreg_regs[] =
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
{ .offset = 0, .regno = 37, .count = 2, .bits = 16 }, /* fctrl-fstat */
|
|
Packit Service |
97d2fb |
{ .offset = 24, .regno = 39, .count = 1, .bits = 32 }, /* mxcsr */
|
|
Packit Service |
97d2fb |
{ .offset = 32, .regno = 11, .count = 8, .bits = 80, .pad = 6 }, /* stN */
|
|
Packit Service |
97d2fb |
{ .offset = 32 + 128, .regno = 21, .count = 8, .bits = 128 }, /* xmm */
|
|
Packit Service |
97d2fb |
};
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#define EXTRA_NOTES \
|
|
Packit Service |
97d2fb |
EXTRA_REGSET (NT_PRXFPREG, 512, prxfpreg_regs) \
|
|
Packit Service |
97d2fb |
case NT_386_TLS: \
|
|
Packit Service |
97d2fb |
return tls_info (nhdr->n_descsz, regs_offset, nregloc, reglocs, \
|
|
Packit Service |
97d2fb |
nitems, items); \
|
|
Packit Service |
97d2fb |
EXTRA_NOTES_IOPERM
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
static const Ebl_Core_Item tls_items[] =
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
{ .type = ELF_T_WORD, .offset = 0x0, .format = 'd', .name = "index" },
|
|
Packit Service |
97d2fb |
{ .type = ELF_T_WORD, .offset = 0x4, .format = 'x', .name = "base" },
|
|
Packit Service |
97d2fb |
{ .type = ELF_T_WORD, .offset = 0x8, .format = 'x', .name = "limit" },
|
|
Packit Service |
97d2fb |
{ .type = ELF_T_WORD, .offset = 0xc, .format = 'x', .name = "flags" },
|
|
Packit Service |
97d2fb |
};
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
static int
|
|
Packit Service |
97d2fb |
tls_info (GElf_Word descsz, GElf_Word *regs_offset,
|
|
Packit Service |
97d2fb |
size_t *nregloc, const Ebl_Register_Location **reglocs,
|
|
Packit Service |
97d2fb |
size_t *nitems, const Ebl_Core_Item **items)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
if (descsz % 16 != 0)
|
|
Packit Service |
97d2fb |
return 0;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
*regs_offset = 0;
|
|
Packit Service |
97d2fb |
*nregloc = 0;
|
|
Packit Service |
97d2fb |
*reglocs = NULL;
|
|
Packit Service |
97d2fb |
*nitems = sizeof tls_items / sizeof tls_items[0];
|
|
Packit Service |
97d2fb |
*items = tls_items;
|
|
Packit Service |
97d2fb |
return 1;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#include "x86_corenote.c"
|
|
Packit Service |
97d2fb |
#include "linux-core-note.c"
|