symbols: Generate an xen-sym.map file similar to Linux's
PATCH 1/1 symbols: Generate an xen-sym.map file similar to Linux's
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. 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.
Also note that during runtime one can do:ffff82d080104920 t domain.c#do_domain_pause
But one may not want to build and verify a livepatch on the same host.
---
Cc:Ross Lagerwall <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
--- .gitignore | 1 + xen/Makefile | 4 +++- xen/arch/arm/Makefile | 3 +++ xen/arch/x86/Makefile | 4 ++++ xen/tools/symbols.c | 11 ++++++++++- 5 files changed, 21 insertions(+), 2 deletions(-)
.gitignore +1 -0
@@ -284,6 +284,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
xen/Makefile +3 -1
@@ -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
xen/arch/arm/Makefile +3 -0
@@ -97,6 +97,9 @@ $(TARGET)-syms: prelink.o xen.lds $(BASEDIR)/common/symbols-dummy.o $(@D)/.$(@F).0.o -o $(@D)/.$(@F).1 $(NM) -pa --format=sysv $(@D)/.$(@F).1 \ | $(BASEDIR)/tools/symbols --sysv --sort >$(@D)/.$(@F).1.S + $(NM) -pa --format=sysv $(@D)/.$(@F).1 \ + | $(BASEDIR)/tools/symbols --xensyms --sysv --sort \ + >$(@D)/$(@F).map $(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 $@
xen/arch/x86/Makefile +4 -0
@@ -135,6 +135,10 @@ $(TARGET)-syms: prelink.o xen.lds $(BASEDIR)/common/symbols-dummy.o $(NM) -pa --format=sysv $(@D)/.$(@F).1 \ | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort --warn-dup \ >$(@D)/.$(@F).1.S + $(NM) -pa --format=sysv $(@D)/.$(@F).1 \ + | $(BASEDIR)/tools/symbols --xensyms --sysv --sort --warn-dup \ + >$(@D)/$(@F).map + $(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 $@
xen/tools/symbols.c +10 -1
@@ -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 skip_asm =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 || skip_asm) { s->orig_symbol =strdup (SYMBOL_NAME (s)); s->type = stype;/* As s->sym[0] ends mangled. */ }
@@ -307,6 +308,12 @@ static void write_src(void)unsigned int *markers;char buf[KSYM_NAME_LEN +1 ]; +if (skip_asm) { +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 +616,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) + skip_asm = true; else usage(); }
Signature · 7 lines
2.5.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 18.07.16 at 20:39, <[email protected]> wrote:
First of all, for the title: Is what you do really similar to Linux? Iirc there System.map is simply output from nm.
Quoted 2 lines
Also note that during runtime one can do:
ffff82d080104920t domain.c#do_domain_pause
I can't seem to make sense of this.
xen/tools/symbols.c static void write_src(void) · line 311
Quoted 5 lines
xen/tools/symbols.c +1
-0@@ -307,6 +308,12 @@ static void write_src(void)unsigned int *markers;char buf[KSYM_NAME_LEN +1 ]; +if (skip_asm) {
Especially with its use here I don't think this is a good name. How about using something that positively identifies what is being asked for, like "map_only" or "dump_symbols"?
xen/tools/symbols.c static void write_src(void) · line 313
Quoted 2 lines
xen/tools/symbols.c +2
-0+for (i =0 ; i < table_cnt; i++) +printf ("%#llx %c %s\n" , table[i].addr, table[i].type, table[i].orig_symbol);
Long line.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel