diff options
author | Roland McGrath <roland@redhat.com> | 2005-12-05 22:46:21 +0000 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2005-12-05 22:46:21 +0000 |
commit | 994b4899278199fc4d307780dac0ea50b238bc74 (patch) | |
tree | 319952538a8556fa7f4d1ffcb4ae258fc6c47a5b /libebl | |
parent | 038129b11ac71a13ccaf9029122be86d6c532990 (diff) | |
download | elfutils-994b4899278199fc4d307780dac0ea50b238bc74.tar.gz |
merge of 2cc527e6d8c8ff19dab478f7d12e58f1cfa6d6f5
and 7b542932f3e2947183b45bdbf39d448f457da9fd
Diffstat (limited to 'libebl')
-rw-r--r-- | libebl/ChangeLog | 9 | ||||
-rw-r--r-- | libebl/Makefile.am | 2 | ||||
-rw-r--r-- | libebl/ebl-hooks.h | 6 | ||||
-rw-r--r-- | libebl/eblopenbackend.c | 20 | ||||
-rw-r--r-- | libebl/eblregname.c | 33 | ||||
-rw-r--r-- | libebl/libebl.h | 14 |
6 files changed, 83 insertions, 1 deletions
diff --git a/libebl/ChangeLog b/libebl/ChangeLog index be170608..532c4eca 100644 --- a/libebl/ChangeLog +++ b/libebl/ChangeLog @@ -1,3 +1,12 @@ +2005-11-25 Roland McGrath <roland@redhat.com> + + * eblregname.c: New file. + * Makefile.am (gen_SOURCES): Add it. + * ebl-hooks.h: Declare register_name hook. + * libebl.h: Declare ebl_register_name. + * eblopenbackend.c (default_register_name): New function. + (fill_defaults): Use it. + 2005-11-16 Roland McGrath <roland@redhat.com> * libebl.h: Use "" for elf-knowledge.h, not <>. diff --git a/libebl/Makefile.am b/libebl/Makefile.am index f7c4a953..1f5c14d1 100644 --- a/libebl/Makefile.am +++ b/libebl/Makefile.am @@ -43,7 +43,7 @@ gen_SOURCES = eblopenbackend.c eblclosebackend.c eblstrtab.c \ eblcorenote.c eblobjnote.c ebldebugscnp.c \ eblgotpcreloccheck.c eblcopyrelocp.c eblsectionstripp.c \ eblelfclass.c eblelfdata.c eblelfmachine.c \ - ebl_check_special_symbol.c eblbsspltp.c eblretval.c + ebl_check_special_symbol.c eblbsspltp.c eblretval.c eblregname.c libebl_a_SOURCES = $(gen_SOURCES) diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h index 90a66c18..f9880532 100644 --- a/libebl/ebl-hooks.h +++ b/libebl/ebl-hooks.h @@ -92,5 +92,11 @@ bool EBLHOOK(bss_plt_p) (Elf *, GElf_Ehdr *); int EBLHOOK(return_value_location) (Dwarf_Die *functypedie, const Dwarf_Op **locp); +/* Return register name information. */ +ssize_t EBLHOOK(register_name) (Ebl *ebl, + int regno, char *name, size_t namelen, + const char **prefix, const char **setname); + + /* Destructor for ELF backend handle. */ void EBLHOOK(destr) (struct ebl *); diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c index 092cb97a..6f39eb49 100644 --- a/libebl/eblopenbackend.c +++ b/libebl/eblopenbackend.c @@ -21,6 +21,7 @@ #include <gelf.h> #include <stdlib.h> #include <string.h> +#include <stdio.h> #include <libeblP.h> @@ -160,6 +161,10 @@ static bool default_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr, static bool default_bss_plt_p (Elf *elf, GElf_Ehdr *ehdr); static int default_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locops); +static ssize_t default_register_name (Ebl *ebl, + int regno, char *name, size_t namelen, + const char **prefix, + const char **setname); static void @@ -191,6 +196,7 @@ fill_defaults (Ebl *result) result->check_special_symbol = default_check_special_symbol; result->bss_plt_p = default_bss_plt_p; result->return_value_location = default_return_value_location; + result->register_name = default_register_name; result->destr = default_destr; } @@ -587,3 +593,17 @@ default_return_value_location (Dwarf_Die *functypedie __attribute__ ((unused)), { return -2; } + +static ssize_t +default_register_name (Ebl *ebl __attribute__ ((unused)), + int regno, char *name, size_t namelen, + const char **prefix, + const char **setname) +{ + if (name == NULL) + return 0; + + *setname = "???"; + *prefix = ""; + return snprintf (name, namelen, "reg%d", regno); +} diff --git a/libebl/eblregname.c b/libebl/eblregname.c new file mode 100644 index 00000000..f6c09618 --- /dev/null +++ b/libebl/eblregname.c @@ -0,0 +1,33 @@ +/* Return register name information. + Copyright (C) 2005 Red Hat, Inc. + + This program is Open Source software; you can redistribute it and/or + modify it under the terms of the Open Software License version 1.0 as + published by the Open Source Initiative. + + You should have received a copy of the Open Software License along + with this program; if not, you may obtain a copy of the Open Software + License version 1.0 from http://www.opensource.org/licenses/osl.php or + by writing the Open Source Initiative c/o Lawrence Rosen, Esq., + 3001 King Ranch Road, Ukiah, CA 95482. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <inttypes.h> +#include <libeblP.h> + + +ssize_t +ebl_register_name (ebl, regno, name, namelen, prefix, setname) + Ebl *ebl; + int regno; + char *name; + size_t namelen; + const char **prefix; + const char **setname; +{ + return ebl == NULL ? -1 : ebl->register_name (ebl, regno, name, namelen, + prefix, setname); +} diff --git a/libebl/libebl.h b/libebl/libebl.h index 7e91b308..c3c96612 100644 --- a/libebl/libebl.h +++ b/libebl/libebl.h @@ -170,6 +170,20 @@ extern int ebl_return_value_location (Ebl *ebl, Dwarf_Die *functypedie, const Dwarf_Op **locops); +/* Fill in register name information given DWARF register numbers. + If NAME is null, return the maximum REGNO + 1 that has a name. + Otherwise, store in NAME the name for DWARF register number REGNO + and return the number of bytes written (including '\0' terminator). + Return -1 if NAMELEN is too short or REGNO is negative or too large. + Return 0 if REGNO is unused (a gap in the DWARF number assignment). + On success, set *SETNAME to a description like "integer" or "FPU" + fit for "%s registers" title display, and *PREFIX to the string + that precedes NAME in canonical assembler syntax (e.g. "%" or "$"). + The NAME string contains identifier characters only (maybe just digits). */ +extern ssize_t ebl_register_name (Ebl *ebl, + int regno, char *name, size_t namelen, + const char **prefix, const char **setname); + /* ELF string table handling. */ struct Ebl_Strtab; |