From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, konrad@kernel.org,
ross.lagerwall@citrix.com
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v3 8/9] symbols: Generate an xen-sym.map
Date: Sun, 14 Aug 2016 17:52:25 -0400 [thread overview]
Message-ID: <1471211546-2235-9-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1471211546-2235-1-git-send-email-konrad.wilk@oracle.com>
You could construct _most_ of the names of the functions
by doing 'nm --defined' but unfortunatly you do not get the
<file> prefix that is added on in Xen . For example:
$ cat xen-syms.symbols |grep do_domain_pause
0xffff82d080104920 t domain.c#do_domain_pause
$ nm --defined xen-syms|grep do_domain_pause
ffff82d080104920 t do_domain_pause
This is normally not an issue, but if one is doing livepatching and
wants during build-time verify that the symbols the livepatch payloads
will patch do correspond to the one the hypervisor has built - this helps a lot.
Note that during runtime one can do:
[root@localhost xen]# cat /proc/xen/xensyms |grep do_domain_pause
ffff82d080104920 t domain.c#do_domain_pause
But one may not want to build and verify a livepatch on the same host.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
v1: First submission
v2: Do not use intermediary object file but the final one
Fix comment to have the example from /proc/xen/xensyms. Using '#'
at start of line is a BAD IDEA.
---
.gitignore | 1 +
xen/Makefile | 4 +++-
xen/arch/arm/Makefile | 3 +++
xen/arch/x86/Makefile | 4 ++++
xen/tools/symbols.c | 12 +++++++++++-
5 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index d193820..44cc7bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -287,6 +287,7 @@ tools/flask/policy/policy.conf
tools/flask/policy/xenpolicy-*
xen/xen
xen/xen-syms
+xen/xen-syms.map
xen/xen.*
unmodified_drivers/linux-2.6/.tmp_versions
unmodified_drivers/linux-2.6/*.cmd
diff --git a/xen/Makefile b/xen/Makefile
index 76b60bc..4427771 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -62,6 +62,7 @@ _install: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX)
ln -f -s $(T)-$(XEN_FULLVERSION)$(Z) $(D)$(BOOT_DIR)/$(T)$(Z)
[ -d "$(D)$(DEBUG_DIR)" ] || $(INSTALL_DIR) $(D)$(DEBUG_DIR)
$(INSTALL_DATA) $(TARGET)-syms $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION)
+ $(INSTALL_DATA) $(TARGET)-syms.map $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION).map
$(INSTALL_DATA) $(KCONFIG_CONFIG) $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION).config
if [ -r $(TARGET).efi -a -n '$(EFI_DIR)' ]; then \
[ -d $(D)$(EFI_DIR) ] || $(INSTALL_DIR) $(D)$(EFI_DIR); \
@@ -91,6 +92,7 @@ _uninstall:
rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION)$(Z)
rm -f $(D)$(BOOT_DIR)/$(T)$(Z)
rm -f $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION)
+ rm -f $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION).map
rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_FULLVERSION).efi
rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION).efi
rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).efi
@@ -112,7 +114,7 @@ _clean: delete-unfresh-files
$(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) clean
$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) clean
find . \( -name "*.o" -o -name ".*.d" \) -exec rm -f {} \;
- rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET).efi $(TARGET)-syms *~ core
+ rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET).efi $(TARGET)-syms $(TARGET)-syms.map *~ core
rm -f include/asm-*/asm-offsets.h
rm -f .banner
diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 23aaf52..0a96713 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -102,6 +102,9 @@ $(TARGET)-syms: prelink.o xen.lds $(BASEDIR)/common/symbols-dummy.o
$(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1.o
$(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
$(@D)/.$(@F).1.o -o $@
+ $(NM) -pa --format=sysv $(@D)/$(@F) \
+ | $(BASEDIR)/tools/symbols --xensyms --sysv --sort \
+ >$(@D)/$(@F).map
rm -f $(@D)/.$(@F).[0-9]*
asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index b18f033..d87ecd8 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -136,8 +136,12 @@ $(TARGET)-syms: prelink.o xen.lds $(BASEDIR)/common/symbols-dummy.o
| $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort --warn-dup \
>$(@D)/.$(@F).1.S
$(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1.o
+ $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1.o
$(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \
$(@D)/.$(@F).1.o -o $@
+ $(NM) -pa --format=sysv $(@D)/$(@F) \
+ | $(BASEDIR)/tools/symbols --xensyms --sysv --sort --warn-dup \
+ >$(@D)/$(@F).map
rm -f $(@D)/.$(@F).[0-9]*
note.o: $(TARGET)-syms
diff --git a/xen/tools/symbols.c b/xen/tools/symbols.c
index 941fbe7..8c5842d 100644
--- a/xen/tools/symbols.c
+++ b/xen/tools/symbols.c
@@ -52,6 +52,7 @@ static unsigned int table_size, table_cnt;
static unsigned long long _stext, _etext, _sinittext, _einittext, _sextratext, _eextratext;
static int all_symbols = 0;
static int sort_by_name = 0;
+static int map_only = 0;
static char symbol_prefix_char = '\0';
static enum { fmt_bsd, fmt_sysv } input_format;
static int compare_name(const void *p1, const void *p2);
@@ -181,7 +182,7 @@ static int read_symbol(FILE *in, struct sym_entry *s)
*sym++ = '#';
}
strcpy(sym, str);
- if (sort_by_name) {
+ if (sort_by_name || map_only) {
s->orig_symbol = strdup(SYMBOL_NAME(s));
s->type = stype; /* As s->sym[0] ends mangled. */
}
@@ -307,6 +308,13 @@ static void write_src(void)
unsigned int *markers;
char buf[KSYM_NAME_LEN+1];
+ if (map_only) {
+ for (i = 0; i < table_cnt; i++)
+ printf("%#llx %c %s\n", table[i].addr, table[i].type,
+ table[i].orig_symbol);
+
+ return;
+ }
printf("#include <xen/config.h>\n");
printf("#include <asm/types.h>\n");
printf("#if BITS_PER_LONG == 64 && !defined(SYMBOLS_ORIGIN)\n");
@@ -609,6 +617,8 @@ int main(int argc, char **argv)
sort_by_name = 1;
else if (strcmp(argv[i], "--warn-dup") == 0)
warn_dup = true;
+ else if (strcmp(argv[i], "--xensyms") == 0)
+ map_only = true;
else
usage();
}
--
2.4.11
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-14 21:53 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-14 21:52 [PATCH v3] Livepatch fixes and features for v4.8 Konrad Rzeszutek Wilk
2016-08-14 21:52 ` [PATCH v3 1/9] livepatch: Clear .bss when payload is reverted Konrad Rzeszutek Wilk
2016-08-15 10:27 ` Jan Beulich
2016-08-15 14:29 ` Konrad Rzeszutek Wilk
2016-08-15 15:10 ` Jan Beulich
2016-08-19 8:37 ` Ross Lagerwall
2016-08-19 8:42 ` Jan Beulich
2016-08-14 21:52 ` [PATCH v3 2/9] livepatch: Deal with payloads without any .text Konrad Rzeszutek Wilk
2016-08-15 10:28 ` Jan Beulich
2016-08-19 9:31 ` Ross Lagerwall
2016-08-14 21:52 ` [PATCH v3 3/9] version/livepatch: Move xen_build_id_check to version.h Konrad Rzeszutek Wilk
2016-08-15 10:35 ` Jan Beulich
2016-08-19 9:29 ` Ross Lagerwall
2016-08-14 21:52 ` [PATCH v3 4/9] livepatch: Sync cache of build-id before using it first time Konrad Rzeszutek Wilk
2016-08-15 10:38 ` Jan Beulich
2016-08-15 10:46 ` Andrew Cooper
2016-08-15 14:33 ` Konrad Rzeszutek Wilk
2016-08-14 21:52 ` [PATCH v3 5/9] livepatch: Move code from prepare_payload to own routine Konrad Rzeszutek Wilk
2016-08-15 10:41 ` Jan Beulich
2016-08-19 9:37 ` Ross Lagerwall
2016-08-14 21:52 ` [PATCH v3 6/9] livepatch: Add parsing for the symbol+0x<offset>/<len> Konrad Rzeszutek Wilk
2016-08-15 10:53 ` Jan Beulich
2016-08-15 14:35 ` Konrad Rzeszutek Wilk
2016-08-15 15:12 ` Jan Beulich
2016-08-15 15:21 ` Konrad Rzeszutek Wilk
2016-08-14 21:52 ` [PATCH v3 7/9] livepatch: NOP if func->new_[addr, size] is zero Konrad Rzeszutek Wilk
2016-08-15 10:59 ` Jan Beulich
2016-08-15 14:38 ` Konrad Rzeszutek Wilk
2016-08-14 21:52 ` Konrad Rzeszutek Wilk [this message]
2016-08-15 11:02 ` [PATCH v3 8/9] symbols: Generate an xen-sym.map Jan Beulich
2016-08-14 21:52 ` [PATCH v3 9/9] livepach: Add .livepatch.hooks functions and test-case Konrad Rzeszutek Wilk
2016-08-15 11:15 ` Jan Beulich
2016-08-15 14:46 ` Konrad Rzeszutek Wilk
2016-08-15 15:17 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1471211546-2235-9-git-send-email-konrad.wilk@oracle.com \
--to=konrad.wilk@oracle.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=konrad@kernel.org \
--cc=ross.lagerwall@citrix.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).