Use symbol database to maintain module dependence
PATCH 1/1 Use symbol database to maintain module dependence
Hi,
This patch add a new tool grub-symdb to manage symbol database and update module dependence as required. The build process is greatly simplified, moddep.lst, def-*.lst, und-*.lst are not generated anymore. grub-symdb will read the module files and update modsym.lst and moddep.lst automatically.
Signature · 1 line
Bean
Makefile.in +3 -5
@@ -139,11 +139,9 @@ include $(srcdir)/conf/$(target_cpu)-$(platform).mk ### General targets. CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) -pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst handler.lst -moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk - cat $(DEFSYMFILES) /dev/null \ - | $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \ - || (rm -f $@; exit 1) +pkglib_DATA += modsym.lst command.lst fs.lst partmap.lst handler.lst +modsym.lst: $(MODFILES) grub-symdb + ./grub-symdb -d . update $? command.lst: $(COMMANDFILES) cat $^ /dev/null | sort > $@
conf/common.rmk +4 -0
@@ -23,6 +23,10 @@ grub_probe_SOURCES = util/grub-probe.c \ kern/fs.c kern/env.c fs/fshelp.c \ disk/raid.c disk/mdraid_linux.c disk/lvm.c grub_probe_init.c +# For grub-symdb +bin_UTILITIES += grub-symdb +grub_symdb_SOURCES = util/grub-symdb.c util/misc.c util/resolve.c + ifeq ($(enable_grub_fstest), yes) bin_UTILITIES += grub-fstest endif
genmk.rb +4 -19
@@ -99,18 +99,10 @@ class PModule pre_obj = 'pre-' + @name.suffix('o') mod_src = 'mod-' + @name.suffix('c') mod_obj = mod_src.suffix('o') - defsym = 'def-' + @name.suffix('lst') - undsym = 'und-' + @name.suffix('lst') mod_name = File.basename(@name, '.mod') symbolic_name = mod_name.sub(/\.[^\.]*$/, '') - "CLEANFILES += #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym} -ifneq ($(#{prefix}_EXPORTS),no) -CLEANFILES += #{defsym} -DEFSYMFILES += #{defsym} -endif -MOSTLYCLEANFILES += #{deps_str} -UNDSYMFILES += #{undsym} + "CLEANFILES += #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF) -rm -f $@
@@ -125,17 +117,10 @@ UNDSYMFILES += #{undsym} #{mod_obj}: #{mod_src} $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $< -#{mod_src}: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh - sh $(srcdir)/genmodsrc.sh '#{mod_name}' $< > $@ || (rm -f $@; exit 1) - -ifneq ($(#{prefix}_EXPORTS),no) -#{defsym}: #{pre_obj} - $(NM) -g --defined-only -P -p $< | sed 's/^\\([^ ]*\\).*/\\1 #{mod_name}/' > $@ -endif +#{mod_src}: $(srcdir)/genmodsrc.sh + sh $(srcdir)/genmodsrc.sh '#{mod_name}' > $@ || (rm -f $@; exit 1) -#{undsym}: #{pre_obj} - echo '#{mod_name}' > $@ - $(NM) -u -P -p $< | cut -f1 -d' ' >> $@ +MODFILES += #{@name} " + objs.collect_with_index do |obj, i| src = sources[i]
genmodsrc.sh +1 -4
@@ -41,7 +41,4 @@ cat <<EOF EOF echo "GRUB_MOD_NAME(${mod_name});" - -for mod in `grep "^${mod_name}:" ${deps} | sed 's/^[^:]*://'`; do - echo "GRUB_MOD_DEP(${mod});" -done +echo 'GRUB_MOD_DEP("");'
include/grub/util/resolve.h +3 -0
@@ -32,4 +32,7 @@ grub_util_resolve_dependencies (const char *prefix,const char *dep_list_file, char *modules[]); +char *grub_util_get_module_name (const char *str); +char *grub_util_get_module_path (const char *prefix,const char *str); +#endif /* ! GRUB_UTIL_RESOLVE_HEADER */
util/grub-symdb.c new file +1050 -0
1,050 lines not on this page · raw message
util/resolve.c +6 -6
@@ -126,8 +126,8 @@ read_dep_list (FILE *fp)return dep_list; } -static char * -get_module_name (const char *str) +char * +grub_util_get_module_name (const char *str) {char *base;char *ext;
@@ -152,8 +152,8 @@ get_module_name (const char *str)return xstrdup (base); } -static char * -get_module_path (const char *prefix,const char *str) +char * +grub_util_get_module_path (const char *prefix,const char *str) {char *dir;char *base;
@@ -190,7 +190,7 @@ add_module (const char *dir,struct mod_list *mod;struct dep_list *dep; - mod_name =get_module_name (name); + mod_name =grub_util_get_module_name (name);/* Check if the module has already been added. */ for (mod = *mod_head; mod; mod = mod->next)
@@ -218,7 +218,7 @@ add_module (const char *dir,/* Add this path. */ path = (struct grub_util_path_list *)xmalloc (sizeof (*path)); - path->name =get_module_path (dir, name); + path->name =grub_util_get_module_path (dir, name); path->next = *path_head; *path_head = path; }
Hi,
ping ?
Quoted 11 lines · Bean
Hi,
This patch add a new tool grub-symdb to manage symbol database and update module dependence as required. The build process is greatly simplified, moddep.lst, def-*.lst, und-*.lst are not generated anymore. grub-symdb will read the module files and update modsym.lst and moddep.lst automatically.
--
Bean
Signature · 1 line
Bean
symdb code seems to duplicate your list code. Perhaps you could reuse the file from kernel thus making maintaining easier
I liked the file modsym.lst: it gives clear view of symbols. This patch brek grub-install because moddep.lst isn't copied correctly Also check that
Also in some places I saw
+ while (n)
+ {
+ modified += remove_string (&u->cur_mods, (char *) n->name);
Here perhaps modified = remove_string (..) || modified; is more appropriate
+ n = n->next;
+ }
+ remove MODULES remove modules from the symbol databsae\n\
Typo
Quoted 28 lines · Bean
Hi,
ping ?
Quoted 11 lines · Bean
Hi,
This patch add a new tool grub-symdb to manage symbol database and update module dependence as required. The build process is greatly simplified, moddep.lst, def-*.lst, und-*.lst are not generated anymore. grub-symdb will read the module files and update modsym.lst and moddep.lst automatically.
--
Bean--
Bean_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko
Quoted 2 lines · Vladimir 'phcoder' Serbinenko
symdb code seems to duplicate your list code. Perhaps you could reuse the file from kernel thus making maintaining easier
Hi,
I'm planning to use kern/list.c at first, but there is some issue. list.c uses grub_strcmp, which means we need to add kern/misc.c as well. But kern/misc.c uses environment and terminal output, etc. I end up adding a lot of unrelated stuff just to satisfy the dependence. So perhaps it'd be better to keep it simple for now.
A better solution is to move the string function to a separate source file, such as kern/string.c. But this is the subject of another patch.
Quoted 11 lines
I liked the file modsym.lst: it gives clear view of symbols. This patch brek grub-install because moddep.lst isn't copied correctly Also check that
Also in some places I saw
+ while (n)
+ {
+ modified +=remove_string(&u->cur_mods, (char *)n->name); Here perhaps modified =remove_string(..) || modified; is more appropriate + n =n->next;
+ }
Right, the += is a quick trick, || would be more meaningful.
Quoted 3 lines
+ remove MODULES remove modules from the symbol databsae\n\
Typo
Oh, thanks for noticing this.
Quoted 42 lines · Bean
Quoted 20 lines
Hi,
ping ?
Quoted 11 lines · Bean
Hi,
This patch add a new tool grub-symdb to manage symbol database and update module dependence as required. The build process is greatly simplified, moddep.lst, def-*.lst, und-*.lst are not generated anymore. grub-symdb will read the module files and update modsym.lst and moddep.lst automatically.
--
BeanQuoted 8 lines
--
Bean_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel--
Regards
Vladimir 'phcoder' Serbinenko_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 1 line
Bean
Quoted 5 lines · Bean
Quoted 2 lines · Vladimir 'phcoder' Serbinenko
symdb code seems to duplicate your list code. Perhaps you could reuse the file from kernel thus making maintaining easier
Quoted 7 lines
Hi,
I'm planning to use
kern/list.cat first, but there is some issue.list.cusesgrub_strcmp, which means we need to addkern/misc.cas well. Butkern/misc.cuses environment and terminal output, etc. I end up adding a lot of unrelated stuff just to satisfy the dependence. So perhaps it'd be better to keep it simple for now.
why not just do
intgrub_strcmp (....)
{
return strcmp(...);
}
like it's done it other utils?
Quoted 5 lines
A better solution is to move the string function to a separate source file, such as
kern/string.c. But this is the subject of another patch.
Also now I'm looking into compiling of grub2 with Apple's gcc and binutils and this patch makes this easier. Was it done in perspective of compiling with Apple's tools? Do you work on this? If you do we could share the effort
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko
Quoted 18 lines · Vladimir 'phcoder' Serbinenko
Quoted 7 lines · Bean
Quoted 3 lines · Vladimir 'phcoder' Serbinenko
symdb code seems to duplicate your list code. Perhaps you could reuse the
file from kernel thus making maintaining easierQuoted 7 lines
Hi,
I'm planning to use
kern/list.cat first, but there is some issue.list.cusesgrub_strcmp, which means we need to addkern/misc.cas well. Butkern/misc.cuses environment and terminal output, etc. I end up adding a lot of unrelated stuff just to satisfy the dependence. So perhaps it'd be better to keep it simple for now.
Quoted 9 lines
why not just do
intgrub_strcmp(....)
{
return strcmp(...);
}
like it's done it other utils?Quoted 2 lines
Hi,
Or perhaps just define macro in header files:
#ifdef GRUB_UTIL
#define grub_strcmp strcmp
#endif
I remember grub legacy used to do this.
Quoted 6 lines
Quoted 2 lines
A better solution is to move the string function to a separate source file, such as
kern/string.c. But this is the subject of another patch.Also now I'm looking into compiling of grub2 with Apple's gcc and binutils and this patch makes this easier. Was it done in perspective of compiling with Apple's tools? Do you work on this? If you do we could share the effort
My original plan for this patch is to lay the foundation for external module support. I haven't try the apple build tools yet. In fact, I scratched osx in testing sometime ago, and having find the time to reinstall it yet.
Quoted 11 lines
--
Regards
Vladimir 'phcoder' Serbinenko_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 1 line
Bean