New object format
PATCH 1/1 New object format
Hi,
This patch implement a new object format, the advantages are:
Reduce size dramatically, some result:
Size of all modules:
original: 645575
new: 519093
Dynamic loader:
original
text data bss dec hex filename
412 0 0 412 19c kernel_img-kern___target_cpu__dl.o3052 0 2064 5116 13fc kernel_img-kern_dl.o
new:
text data bss dec hex filename
2272 0 2064 4336 10f0 kernel_img-kern_dl.o
Greatly simplify the build process:
1, compile *.c, *.S to *.o
2, use grub-mkmod to merge *.o file to mod
3, use grub-symdb to maintain module dependence
so there is no pre-* mod-* def-* und-* anymore.
grub-mkmod support both pe and elf format, no need to convert with grub-pe2elf.
BTW, this patch breaks other platform. And it seems there is some bug in elf->mod converter. But the pe->mod works quite nice, I can load graphic menu and even run osdetect script with lua.
Signature · 1 line
Bean
Makefile.in +3 -5
@@ -147,11 +147,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 parttool.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 parttool.lst handler.lst +modsym.lst: $(MODFILES) grub-symdb + ./grub-symdb -d . update $? command.lst: $(COMMANDFILES) cat $^ /dev/null | sort > $@
conf/common.rmk +20 -3
@@ -125,6 +125,23 @@ endif grub_pe2elf_SOURCES = util/grub-pe2elf.c util/misc.c CLEANFILES += grub-pe2elf +# grub-mkmod +bin_UTILITIES += grub-mkmod +grub_mkmod_SOURCES = util/grub-mkmod.c util/misc.c util/obj.c \ + util/obj_pe.c util/obj_elf.c kern/list.c +CLEANFILES += grub-mkmod + +# grub-symdb +bin_UTILITIES += grub-symdb +grub_symdb_SOURCES = util/grub-symdb.c util/obj.c util/misc.c kern/list.c +CLEANFILES += grub-symdb + +# grub-objdump +bin_UTILITIES += grub-objdump +grub_objdump_SOURCES = util/grub-objdump.c util/obj.c util/misc.c \ + util/obj_dump.c kern/list.c +CLEANFILES += grub-objdump + # grub_macho2img assumes a lot about source file. # So installing it definitively is useless # But adding to bin_UTILITIES is needed for
@@ -512,15 +529,15 @@ sh_mod_CFLAGS = $(COMMON_CFLAGS) sh_mod_LDFLAGS = $(COMMON_LDFLAGS) # For lua.mod. -lua_mod_SOURCES = script/lua/lapi.c script/lua/lcode.c script/lua/ldebug.c \ +lua_mod_SOURCES = script/lua/grub_main.c script/lua/grub_lib.c \ + script/lua/lapi.c script/lua/lcode.c script/lua/ldebug.c \ script/lua/ldo.c script/lua/ldump.c script/lua/lfunc.c \ script/lua/lgc.c script/lua/llex.c script/lua/lmem.c \ script/lua/lobject.c script/lua/lopcodes.c script/lua/lparser.c \ script/lua/lstate.c script/lua/lstring.c script/lua/ltable.c \ script/lua/ltm.c script/lua/lundump.c script/lua/lvm.c \ script/lua/lzio.c script/lua/lauxlib.c script/lua/lbaselib.c \ - script/lua/linit.c script/lua/ltablib.c script/lua/lstrlib.c \ - script/lua/grub_main.c script/lua/grub_lib.c + script/lua/linit.c script/lua/ltablib.c script/lua/lstrlib.c lua_mod_CFLAGS = $(COMMON_CFLAGS) lua_mod_LDFLAGS = $(COMMON_LDFLAGS)
conf/i386-pc.rmk +1 -1
@@ -53,7 +53,7 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \ kern/misc.c kern/mm.c kern/reader.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \ - kern/$(target_cpu)/dl.c kern/i386/pc/init.c kern/i386/pc/mmap.c \ + kern/i386/pc/init.c kern/i386/pc/mmap.c \ kern/parser.c kern/partition.c \ kern/i386/tsc.c kern/i386/pit.c \ kern/generic/rtc_get_time_ms.c \
genmk.rb +4 -48
64 lines not on this page · raw message
include/grub/dl.h +0 -1
@@ -85,7 +85,6 @@ struct grub_dl };typedef struct grub_dl *grub_dl_t ; -grub_err_t EXPORT_FUNC (grub_dl_check_header ) (void *ehdr,grub_size_t size);grub_dl_t EXPORT_FUNC (grub_dl_load_file ) (const char *filename);grub_dl_t EXPORT_FUNC (grub_dl_load ) (const char *name);grub_dl_t grub_dl_load_core (void *addr,grub_size_t size);
include/grub/elf.h +2 -2
@@ -454,8 +454,8 @@ typedef structthe end of a chain, meaning no further symbols are found in that bucket. */ #define STN_UNDEF 0/* End of a chain. */ -#define STN_ABS 65521 - +#define STN_ABS 0xfff1 +#define STN_COMMON 0xfff2/* How to extract and insert information held in the st_other field. */
include/grub/obj.h new file +90 -0
90 lines not on this page · raw message
include/grub/util/misc.h +6 -0
@@ -26,6 +26,7 @@#include <config.h> #include <grub/types.h> +#include <grub/list.h> #ifdef __NetBSD__/* NetBSD uses /boot for its boot block. */
@@ -46,6 +47,9 @@ void grub_util_error (const char *fmt, ...) __attribute__ ((noreturn));void *xmalloc (size_t size);void *xrealloc (void *ptr,size_t size);char *xstrdup (const char *str); +void *xmalloc_zero (size_t size); + +void *grub_list_reverse (grub_list_t head);char *grub_util_get_path (const char *dir,const char *file);size_t grub_util_get_fp_size (FILE *fp);
@@ -56,6 +60,8 @@ void grub_util_load_image (const char *path, char *buf);void grub_util_write_image (const char *img,size_t size,FILE *out);void grub_util_write_image_at (const void *img,size_t size,off_t offset,FILE *out); +char *grub_util_get_module_name (const char *str); +char *grub_util_get_module_path (const char *prefix,const char *str);#ifndef HAVE_ASPRINTF
include/grub/util/obj.h new file +85 -0
85 lines not on this page · raw message
kern/dl.c +107 -214
402 lines not on this page · raw message
util/grub-mkmod.c new file +176 -0
176 lines not on this page · raw message
util/grub-objdump.c new file +172 -0
172 lines not on this page · raw message
util/grub-symdb.c new file +811 -0
811 lines not on this page · raw message
util/misc.c +82 -0
94 lines not on this page · raw message
util/obj.c new file +634 -0
634 lines not on this page · raw message
util/obj_dump.c new file +140 -0
140 lines not on this page · raw message
util/obj_elf.c new file +360 -0
228 lines not on this page · raw message
util/obj_pe.c new file +272 -0
272 lines not on this page · raw message
util/resolve.c +2 -54
56 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
please stop this
Quoted 3 lines · Bean
Hi,
This patch implement a new object format, the advantages are:
Hi Bean,
Last time this was discussed [1], there was no consensus that we should switch to a new object format. Furthermore, Marco had some objections:
http://lists.gnu.org/archive/html/grub-devel/2009-07/msg00101.html
and I'm growing increasingly worried about this tendency. Just about every week we have to discuss a proposal that significantly affects core functionality, which may later be implemented and sent as a patch no matter what we have discussed, and if left unattended, merged in SVN, and afterwards we and our users have and additional burden of finding new bugs and fixing them.
I agree that we have a problem due to lack of leadership, but this is not acceptable. Marco is busy right now (traveling), so please put this on hold untill he's back, then we can discuss it.
Don't take me wrong, Bean I really appreciate your contribution to GRUB, but you see it as an experimentation ground, and GRUB is not a research project. PUPA was, but GRUB aims to be a stable bootloader.
[1] http://lists.gnu.org/archive/html/grub-devel/2009-07/msg00098.html
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Re: please stop this
Quoted 3 lines · Robert Millan
I agree that we have a problem due to lack of leadership, but this is not acceptable. Marco is busy right now (traveling), so please put this on hold untill he's back, then we can discuss it.
I agree that we should not rush with such changes. However, publishing patches for discussion and testing is a good thing and should not be discouraged.
Signature · 2 lines
Regards, Pavel Roskin
Re: please stop this
Quoted 9 lines · Pavel Roskin
Quoted 3 lines · Robert Millan
I agree that we have a problem due to lack of leadership, but this is not acceptable. Marco is busy right now (traveling), so please put this on hold untill he's back, then we can discuss it.
I agree that we should not rush with such changes. However, publishing patches for discussion and testing is a good thing and should not be discouraged.
Hi,
Yeah, I don't mean to push it. In fact, I've created a git repository for my temporary work
http://repo.or.cz/w/grub2/bean.git
The new object format and library support would be committed there in case someone is interested.
Signature · 1 line
Bean
Re: please stop this
Quoted 11 lines · Bean
Quoted 9 lines · Pavel Roskin
Quoted 3 lines · Robert Millan
I agree that we have a problem due to lack of leadership, but this is not acceptable. Marco is busy right now (traveling), so please put this on hold untill he's back, then we can discuss it.
I agree that we should not rush with such changes. However, publishing patches for discussion and testing is a good thing and should not be discouraged.
Quoted 6 lines
Hi,
Yeah, I don't mean to push it. In fact, I've created a git repository for my temporary work
Hi,
Usually, I only go through the trouble of implementing things when it's clear they will be merged in some form. But I understand it's not the same for everyone. So if I missunderstood, please accept my apology.
In any case, this kind of changes need wider consensus, and including the maintainers in it. And in general, I think we should hold off from big restructuring at this time. Using branches is a good idea IMHO (be it "someone's branch" or "pupa2" or whatever).
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Re: please stop this
Quoted 17 lines · Robert Millan
Quoted 16 lines · Bean
Quoted 9 lines · Pavel Roskin
Quoted 3 lines · Robert Millan
I agree that we have a problem due to lack of leadership, but this is not acceptable. Marco is busy right now (traveling), so please put this on hold untill he's back, then we can discuss it.
I agree that we should not rush with such changes. However, publishing patches for discussion and testing is a good thing and should not be discouraged.
Hi,
Yeah, I don't mean to push it. In fact, I've created a git repository for my temporary work
Quoted 7 lines
Quoted 1 line
Hi,
Usually, I only go through the trouble of implementing things when it's clear they will be merged in some form. But I understand it's not the same for everyone. So if I missunderstood, please accept my apology.
In some cases actually implementing something is needed to know whether it will give an advantage
Quoted 3 lines
In any case, this kind of changes need wider consensus, and including the maintainers in it.
The problem is that most comments are in the form "maybe I agree maybe I don't". Such kind of discussions may never result in consensus. Useful patches lying in bitrot somewhere on the list is unfortunately something common. We need a better organisation and more dynamism if we want project to advance. New maintainer can make these changes happen. And generally I tend to accept a rule "absent person is wrong and agrees". Not because I don't respect other people but just because I don't see why project would eternally wait for someone to come by. I think that main rules are Sane-o-cracy and Do-o-cracy: As long as choice is sane and expandable doer decides
Quoted 3 lines
And in general, I think we should hold off from big restructuring at this time. Using branches is a good idea IMHO (be it "someone's branch" or "pupa2" or whatever).
Having too many branches per developer may prevent GRUB from being GRand and Unified.
Quoted 14 lines
--
Robert MillanThe DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Re: please stop this
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
Quoted 4 lines
Usually, I only go through the trouble of implementing things when it's clear they will be merged in some form. But I understand it's not the same for everyone. So if I missunderstood, please accept my apology.
In some cases actually implementing something is needed to know whether it will give an advantage
Agreed, in some cases it helps.
Quoted 12 lines
Quoted 2 lines
In any case, this kind of changes need wider consensus, and including the maintainers in it.
The problem is that most comments are in the form "maybe I agree maybe I don't". Such kind of discussions may never result in consensus. Useful patches lying in bitrot somewhere on the list is unfortunately something common. We need a better organisation and more dynamism if we want project to advance. New maintainer can make these changes happen. And generally I tend to accept a rule "absent person is wrong and agrees". Not because I don't respect other people but just because I don't see why project would eternally wait for someone to come by. I think that main rules are Sane-o-cracy and Do-o-cracy: As long as choice is sane and expandable doer decides
I agree we need better organisation, but I don't think even more dynamism is the answer. Actually I think we've got _more_ dynamism than we can handle (I don't think dynamism is bad, but we have to acknowledge our limits).
Some people do lots of work, sometimes things we obviously want, and sometimes design changes that need careful review and analisys. The problem is that our resources to do the latter are not a la par with the amount of contribution we receive.
What we have now is that often a single person comes up with an idea that changes GRUB in significant ways, it is proposed, and because we lack the resources to review it it's not reviewed, or only barely so. Then the "absent person is wrong and agrees" rule prevails, change is merged, and we may later find that this is not really what we wanted.
Marco's been in Catalonia this week. Last thursday he came to Barcelona and we had some talk about the situation with GRUB. I can assure you that he's concerned about this. He sees this "maintainer's not here so let's do what ever we want" approach as a problem, although it's pretty understandable given the situation (he acknoledges that as well).
Quoted 5 lines
Quoted 3 lines
And in general, I think we should hold off from big restructuring at this time. Using branches is a good idea IMHO (be it "someone's branch" or "pupa2" or whatever).
Having too many branches per developer may prevent GRUB from being GRand and Unified.
I think the "Unified" means it supports multiple filesystems, the Multiboot standard, etc, allowing it to support a wide variety of OSes. But it's just a word anyway...
IMO, branches are useful sometimes, because they make it easier to experiment with new things without risk of breaking our core functionality.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Re: please stop this
Quoted 13 lines
Quoted 12 lines
Quoted 2 lines
In any case, this kind of changes need wider consensus, and including the maintainers in it.
The problem is that most comments are in the form "maybe I agree maybe I don't". Such kind of discussions may never result in consensus. Useful patches lying in bitrot somewhere on the list is unfortunately something common. We need a better organisation and more dynamism if we want project to advance. New maintainer can make these changes happen. And generally I tend to accept a rule "absent person is wrong and agrees". Not because I don't respect other people but just because I don't see why project would eternally wait for someone to come by. I think that main rules are Sane-o-cracy and Do-o-cracy: As long as choice is sane and expandable doer decides
Quoted 8 lines
I agree we need better organisation, but I don't think even more dynamism is the answer. Actually I think we've got _more_ dynamism than we can handle (I don't think dynamism is bad, but we have to acknowledge our limits).
Some people do lots of work, sometimes things we obviously want, and sometimes design changes that need careful review and analisys. The problem is that our resources to do the latter are not a la par with the amount of contribution we receive.
I don't think that grub as a project isn't able to handle incoming patches. I think that lack of organisation just wastes the effort. Perhaps we could use some kind of core team approach. One example is to designate N core team members and need a confirmation of floor (N/2) core members for design changes and no oppositions and that at least one weak passed after such consensus and a confirmation of one core team member for ordinary patches or in case if author is in core team and no further replies one weak that patch is laying on the list. This way even if some core members are on vacation the system continues to work
Quoted 7 lines
What we have now is that often a single person comes up with an idea that changes GRUB in significant ways, it is proposed, and because we lack the resources to review it it's not reviewed, or only barely so. Then the "absent person is wrong and agrees" rule prevails, change is merged, and we may later find that this is not really what we wanted.
Quoted 6 lines
Marco's been in Catalonia this week. Last thursday he came to Barcelona and we had some talk about the situation with GRUB. I can assure you that he's concerned about this. He sees this "maintainer's not here so let's do what ever we want" approach as a problem, although it's pretty understandable given the situation (he acknoledges that as well).
If he'll be soonish available for discussion we should wait for him and discuss this altogether.
Quoted 2 lines
I think the "Unified" means it supports multiple filesystems, the Multiboot standard, etc, allowing it to support a wide variety of OSes.
Exactly. And if patches have problems to get in we risk not to recieve features the project merits and gets loads of forks (=fragmentation instead of unification) instead
Quoted 6 lines
But it's just
a word anyway...IMO, branches are useful sometimes, because they make it easier to experiment with new things without risk of breaking our core functionality.
Could we perhaps create a developement branch in svn to share code easier?
Quoted 13 lines
--
Robert MillanThe DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Hi,
Ok, find the bug for elf converter. elf and pe are both ok now.
Quoted 39 lines · Bean
Hi,
This patch implement a new object format, the advantages are:
Reduce size dramatically, some result:
Size of all modules:
original: 645575
new: 519093Dynamic loader:
original
text data bss dec hex filename
412 0 0 412 19c kernel_img-kern___target_cpu__dl.o 3052 0 2064 5116 13fc kernel_img-kern_dl.onew:
text data bss dec hex filename 2272 0 2064 4336 10f0 kernel_img-kern_dl.oGreatly simplify the build process:
1, compile *.c, *.S to *.o
2, use grub-mkmod to merge *.o file to mod
3, use grub-symdb to maintain module dependenceso there is no pre-* mod-* def-* und-* anymore.
grub-mkmod support both pe and elf format, no need to convert with grub-pe2elf.
BTW, this patch breaks other platform. And it seems there is some bug in
elf->modconverter. But thepe->modworks quite nice, I can load graphic menu and even run osdetect script with lua.--
Bean
Signature · 1 line
Bean
Makefile.in +3 -5
@@ -147,11 +147,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 parttool.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 parttool.lst handler.lst +modsym.lst: $(MODFILES) grub-symdb + ./grub-symdb -d . update $? command.lst: $(COMMANDFILES) cat $^ /dev/null | sort > $@
conf/common.rmk +20 -3
@@ -125,6 +125,23 @@ endif grub_pe2elf_SOURCES = util/grub-pe2elf.c util/misc.c CLEANFILES += grub-pe2elf +# grub-mkmod +bin_UTILITIES += grub-mkmod +grub_mkmod_SOURCES = util/grub-mkmod.c util/misc.c util/obj.c \ + util/obj_pe.c util/obj_elf.c kern/list.c +CLEANFILES += grub-mkmod + +# grub-symdb +bin_UTILITIES += grub-symdb +grub_symdb_SOURCES = util/grub-symdb.c util/obj.c util/misc.c kern/list.c +CLEANFILES += grub-symdb + +# grub-objdump +bin_UTILITIES += grub-objdump +grub_objdump_SOURCES = util/grub-objdump.c util/obj.c util/misc.c \ + util/obj_dump.c kern/list.c +CLEANFILES += grub-objdump + # grub_macho2img assumes a lot about source file. # So installing it definitively is useless # But adding to bin_UTILITIES is needed for
@@ -512,15 +529,15 @@ sh_mod_CFLAGS = $(COMMON_CFLAGS) sh_mod_LDFLAGS = $(COMMON_LDFLAGS) # For lua.mod. -lua_mod_SOURCES = script/lua/lapi.c script/lua/lcode.c script/lua/ldebug.c \ +lua_mod_SOURCES = script/lua/grub_main.c script/lua/grub_lib.c \ + script/lua/lapi.c script/lua/lcode.c script/lua/ldebug.c \ script/lua/ldo.c script/lua/ldump.c script/lua/lfunc.c \ script/lua/lgc.c script/lua/llex.c script/lua/lmem.c \ script/lua/lobject.c script/lua/lopcodes.c script/lua/lparser.c \ script/lua/lstate.c script/lua/lstring.c script/lua/ltable.c \ script/lua/ltm.c script/lua/lundump.c script/lua/lvm.c \ script/lua/lzio.c script/lua/lauxlib.c script/lua/lbaselib.c \ - script/lua/linit.c script/lua/ltablib.c script/lua/lstrlib.c \ - script/lua/grub_main.c script/lua/grub_lib.c + script/lua/linit.c script/lua/ltablib.c script/lua/lstrlib.c lua_mod_CFLAGS = $(COMMON_CFLAGS) lua_mod_LDFLAGS = $(COMMON_LDFLAGS)
conf/i386-pc.rmk +1 -1
@@ -53,7 +53,7 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \ kern/misc.c kern/mm.c kern/reader.c kern/term.c \ kern/rescue_parser.c kern/rescue_reader.c \ kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \ - kern/$(target_cpu)/dl.c kern/i386/pc/init.c kern/i386/pc/mmap.c \ + kern/i386/pc/init.c kern/i386/pc/mmap.c \ kern/parser.c kern/partition.c \ kern/i386/tsc.c kern/i386/pit.c \ kern/generic/rtc_get_time_ms.c \
genmk.rb +4 -48
64 lines not on this page · raw message
include/grub/dl.h +0 -1
@@ -85,7 +85,6 @@ struct grub_dl };typedef struct grub_dl *grub_dl_t ; -grub_err_t EXPORT_FUNC (grub_dl_check_header ) (void *ehdr,grub_size_t size);grub_dl_t EXPORT_FUNC (grub_dl_load_file ) (const char *filename);grub_dl_t EXPORT_FUNC (grub_dl_load ) (const char *name);grub_dl_t grub_dl_load_core (void *addr,grub_size_t size);
include/grub/elf.h +2 -2
@@ -454,8 +454,8 @@ typedef structthe end of a chain, meaning no further symbols are found in that bucket. */ #define STN_UNDEF 0/* End of a chain. */ -#define STN_ABS 65521 - +#define STN_ABS 0xfff1 +#define STN_COMMON 0xfff2/* How to extract and insert information held in the st_other field. */
include/grub/obj.h new file +90 -0
90 lines not on this page · raw message
include/grub/util/misc.h +6 -0
@@ -26,6 +26,7 @@#include <config.h> #include <grub/types.h> +#include <grub/list.h> #ifdef __NetBSD__/* NetBSD uses /boot for its boot block. */
@@ -46,6 +47,9 @@ void grub_util_error (const char *fmt, ...) __attribute__ ((noreturn));void *xmalloc (size_t size);void *xrealloc (void *ptr,size_t size);char *xstrdup (const char *str); +void *xmalloc_zero (size_t size); + +void *grub_list_reverse (grub_list_t head);char *grub_util_get_path (const char *dir,const char *file);size_t grub_util_get_fp_size (FILE *fp);
@@ -56,6 +60,8 @@ void grub_util_load_image (const char *path, char *buf);void grub_util_write_image (const char *img,size_t size,FILE *out);void grub_util_write_image_at (const void *img,size_t size,off_t offset,FILE *out); +char *grub_util_get_module_name (const char *str); +char *grub_util_get_module_path (const char *prefix,const char *str);#ifndef HAVE_ASPRINTF
include/grub/util/obj.h new file +84 -0
84 lines not on this page · raw message
kern/dl.c +107 -214
402 lines not on this page · raw message
util/grub-mkmod.c new file +176 -0
176 lines not on this page · raw message
util/grub-objdump.c new file +176 -0
176 lines not on this page · raw message
util/grub-symdb.c new file +811 -0
811 lines not on this page · raw message
util/misc.c +82 -0
94 lines not on this page · raw message
util/obj.c new file +634 -0
634 lines not on this page · raw message
util/obj_dump.c new file +140 -0
140 lines not on this page · raw message
util/obj_elf.c new file +365 -0
225 lines not on this page · raw message
util/obj_pe.c new file +272 -0
272 lines not on this page · raw message
util/resolve.c +2 -54
56 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 10 lines · Bean
Hi,
This patch implement a new object format, the advantages are:
Reduce size dramatically, some result:
Size of all modules:
original: 645575
new: 519093
[I thought I sent this message a few days ago, guess not?]
What are the compressed-size comparisons?
-Isaac
Quoted 8 lines · Isaac Dupree
Quoted 7 lines · Bean
Hi,
This patch implement a new object format, the advantages are:
Reduce size dramatically, some result:
Quoted 8 lines
Quoted 4 lines
Size of all modules:
original: 645575
new: 519093[I thought I sent this message a few days ago, guess not?]
What are the compressed-size comparisons?
Hi,
An example (reiserfs on lvm on raid)
grub-mkimage -d . -o core.img pc biosdisk reiserfs lvm raid mdraid raid5rec raid6rec
old: 33248
new: 31939
Signature · 1 line
Bean
Update:
Various bug fix
Support EFI platform,
i386-efi: both elf and pe are ok
x86_64-efi: elf ok
BTW, it's very closed to build x86_64-efi using pe64. In order to build it, you need to download mingw-w64, and link x86_64-w64-mingw32-gcc.exe to x86_64-gcc.exe, etc, then:
./configure CC=x86_64-gcc --with-platform=efi --target=x86_64
compile ok, grub-mkimage also generate the efi image, but it crash when loading.
The source code have been pushed to my git repository:
http://github.com/bean123/grub
lib branch
Signature · 1 line
Bean
Update:
Now fully support mingw-w64, the configure line is this:
./configure --with-platform=efi --target=x86_64-w64-mingw32
Compile ok in both XP64 and linux with mingw-w64 cross compiler, the generated grub.efi tested all right on macbook.
Fix some wrong assumption in types.h and efi header files. For example, grub_efi_uint_t is defined as unsigned long, but it should be grub_uint64_t in 64-bit EFI, this problem won't show previously as unsigned long is 64-bit in elf64 gcc, but it's 32-bit in mingw-w64 gcc.
Fix a bug in grub-symdb.
New code updated to http://github.com/bean123/grub.
Quoted 23 lines · Bean
Update:
Various bug fix
Support EFI platform,
i386-efi: both elf and pe are ok
x86_64-efi: elf okBTW, it's very closed to build x86_64-efi using pe64. In order to build it, you need to download mingw-w64, and link x86_64-w64-mingw32-gcc.exe to x86_64-gcc.exe, etc, then:
./configure CC=x86_64-gcc --with-platform=efi --target=x86_64
compile ok, grub-mkimage also generate the efi image, but it crash when loading.
The source code have been pushed to my git repository:
http://github.com/bean123/grub
lib branch
--
Bean
Signature · 1 line
Bean
Quoted 5 lines · Bean
Fix some wrong assumption in
types.hand efi header files. For example,grub_efi_uint_tis defined as unsigned long, but it should begrub_uint64_tin 64-bit EFI, this problem won't show previously as unsigned long is 64-bit in elf64 gcc, but it's 32-bit in mingw-w64 gcc.
I think you haven't corrected _all_ such assumptions. For example, in your grub/types.h:
#if GRUB_CPU_SIZEOF_VOID_P == 8
# define GRUB_ULONG_MAX 18446744073709551615UL # define GRUB_LONG_MAX 9223372036854775807L # define GRUB_LONG_MIN (-9223372036854775807L - 1) #else # define GRUB_ULONG_MAX 4294967295UL # define GRUB_LONG_MAX 2147483647L # define GRUB_LONG_MIN (-2147483647L - 1) #endif
In mingw64, sizeof(void*) = 8, but ULONG_MAX = 2^32-1. grub/machine/types.h defines a GRUB_TARGET_SIZEOF_LONG that might be suitable for this. Or am I mixing "target" with "host"?
Signature · 1 line
-- Lazy, Oblivious, Recurrent Disaster -- Habbit
2009/7/22 Javier Martín <[email protected]>:
Quoted 19 lines · Bean
Quoted 5 lines
Fix some wrong assumption in
types.hand efi header files. For example,grub_efi_uint_tis defined as unsigned long, but it should begrub_uint64_tin 64-bit EFI, this problem won't show previously as unsigned long is 64-bit in elf64 gcc, but it's 32-bit in mingw-w64 gcc.I think you haven't corrected _all_ such assumptions. For example, in your
grub/types.h:#if
GRUB_CPU_SIZEOF_VOID_P== 8# define GRUB_ULONG_MAX 18446744073709551615UL # define GRUB_LONG_MAX 9223372036854775807L # define GRUB_LONG_MIN (-9223372036854775807L - 1) #else # define GRUB_ULONG_MAX 4294967295UL # define GRUB_LONG_MAX 2147483647L # define GRUB_LONG_MIN (-2147483647L - 1) #endif
Quoted 3 lines
In mingw64,
sizeof(void*)= 8, butULONG_MAX= 2^32-1.grub/machine/types.hdefines aGRUB_TARGET_SIZEOF_LONGthat might be suitable for this. Or am I mixing "target" with "host"?
Hi,
Oh, thanks for the note. In fact, we can use GRUB_CPU_SIZEOF_LONG, its value is GRUB_TARGET_SIZEOF_LONG when building target, and SIZEOF_LONG when building utilities. For example, I now define grub_uint64_t as:
#if GRUB_CPU_SIZEOF_LONG == 8
typedef unsigned long grub_uint64_t;
#else
typedef unsigned long long grub_uint64_t;
#endif
The previous definition is not correct:
#if GRUB_CPU_SIZEOF_VOID_P == 8
typedef unsigned long grub_uint64_t;
#else
typedef unsigned long long grub_uint64_t;
#endif
As GRUB_CPU_SIZEOF_LONG doesn't necessary equal to GRUB_CPU_SIZEOF_VOID_P. (It actually avoid this by generating an #errror message when GRUB_CPU_SIZEOF_VOID_P != GRUB_CPU_SIZEOF_LONG).
Signature · 1 line
Bean
Quoted 24 lines · Bean
2009/7/22 Javier Martín <[email protected]>:
Quoted 19 lines · Bean
Quoted 5 lines
Fix some wrong assumption in
types.hand efi header files. For example,grub_efi_uint_tis defined as unsigned long, but it should begrub_uint64_tin 64-bit EFI, this problem won't show previously as unsigned long is 64-bit in elf64 gcc, but it's 32-bit in mingw-w64 gcc.I think you haven't corrected _all_ such assumptions. For example, in your
grub/types.h:#if
GRUB_CPU_SIZEOF_VOID_P== 8# define GRUB_ULONG_MAX 18446744073709551615UL # define GRUB_LONG_MAX 9223372036854775807L # define GRUB_LONG_MIN (-9223372036854775807L - 1) #else # define GRUB_ULONG_MAX 4294967295UL # define GRUB_LONG_MAX 2147483647L # define GRUB_LONG_MIN (-2147483647L - 1) #endifQuoted 3 lines
In mingw64,
sizeof(void*)= 8, butULONG_MAX= 2^32-1.grub/machine/types.hdefines aGRUB_TARGET_SIZEOF_LONGthat might be suitable for this. Or am I mixing "target" with "host"?
Quoted 5 lines
Hi,
Oh, thanks for the note. In fact, we can use
GRUB_CPU_SIZEOF_LONG, its value isGRUB_TARGET_SIZEOF_LONGwhen building target, andSIZEOF_LONGwhen building utilities.
Wonderful idea. I'm researching this for a possible implementation of a GRUB equivalent to the C99 fixed-length integers print specifiers like PRIx64. It would most likely go into <grub/types.h>, so I'm paying special attention to anyone working on that file.
Quoted 3 lines
As
GRUB_CPU_SIZEOF_LONGdoesn't necessary equal toGRUB_CPU_SIZEOF_VOID_P. (It actually avoid this by generating an #errror message whenGRUB_CPU_SIZEOF_VOID_P!=GRUB_CPU_SIZEOF_LONG).
I think you lost me here. This check is in the trunk GRUB, but not in your "lib" branch, and actually it would make it impossible to build on mingw64, where void* is 64-bit and long is 32-bit.
Signature · 1 line
-- Lazy, Oblivious, Recurrent Disaster -- Habbit
Hi,
Quoted 7 lines
Quoted 3 lines
Oh, thanks for the note. In fact, we can use GRUB_CPU_SIZEOF_LONG, its value is
GRUB_TARGET_SIZEOF_LONGwhen building target, andSIZEOF_LONGwhen building utilities.Wonderful idea. I'm researching this for a possible implementation of a GRUB equivalent to the C99 fixed-length integers print specifiers like PRIx64. It would most likely go into <
grub/types.h>, so I'm paying special attention to anyone working on that file.
Yeah, that would be very useful, most warning message from mingw64 is caused by grub_printf format.
Quoted 7 lines
Quoted 4 lines
As
GRUB_CPU_SIZEOF_LONGdoesn't necessary equal toGRUB_CPU_SIZEOF_VOID_P. (It actually avoid this by generating an #errror message whenGRUB_CPU_SIZEOF_VOID_P!=GRUB_CPU_SIZEOF_LONG).I think you lost me here. This check is in the trunk GRUB, but not in your "lib" branch, and actually it would make it impossible to build on mingw64, where void* is 64-bit and long is 32-bit.
The check is in svn trunk so that you can't compile at all, I remove it in my lib branch so that it can be compiled in mingw64.
Signature · 1 line
Bean
Hi,
Update:
New tool grub-mkrawimage, used to generate img file from object files directly, no need for ld and objcopy anymore. It inject the grub_bss_start and grub_bss_end symbol, so no need to check for them in configure.ac.
Remove the memcpy alias in kern/misc.c, instead, it map memcpy to grub_memmove when generating the module file.
Signature · 1 line
Bean
Hi,
Update:
Now the attributes are stored inside mod file, for example, "fs:", "command:ls", etc. grub-symdb uses it to generate the list files automatically (fs.lst, partmap.lst, parttool.lst, command.lst, handler.lst). Don't use sed to scan source file, and eliminate the fs-*.lst, partmap-*.lst, parttool-*.lst, command-*.lst and handler-*.lst.
grub-objdump can show the mod attributes, for example:
# grub-objdump gfxterm.mod filename: gfxterm.mod mod name: gfxterm mod deps: bitmap font video mod attr: handler:terminal_output.gfxterm command:background_image init func: 0xcad fini func: 0xce6
Signature · 1 line
Bean
Hi,
Update:
Now global symbol must be defined using GRUB_EXPORT macro, otherwise it'd be removed from the module symbol list. I also add GRUB_EXPORT to modules in i386-pc platform.
Some reason to define global symbols explicitly:
For modules that consists of multiple files, some external function is used to communicate with each other, they should not be exported, for example, sh.mod and lua.mod all have many function that's not static. It'd be nice to distinguish between function we want to export and those used by other files in the same module.
For normal module, exported function is not common, for those that consist of functions mainly, we can move it to the library, which export all external function so that we don't need GRUB_EXPORT anyway.
The export symbol is not cheap, by exporting only the symbols we need, we can save some space.
Signature · 1 line
Bean
Hi,
Update:
Now change kernel.img to kernel.mod, and export symbol using GRUB_EXPORT instead of EXPORT_FUNC and EXPORT_VAR. grub-mkimage would link all modules files to generate core.img. The symbol list is generated by grub-mkimage, no need for symlist.c anymore.
Here are some test results using the latest lib branch and corresponding unpatched version (svn r2435). The test uses mingw in a windows host:
Compile time:
svn:
real 3m52.625s user 1m9.647s sys 2m8.904s
lib:
real 1m13.282s user 0m11.365s sys 0m22.748s
Files generated in the compile process: (not counting include/machine and include/cpu)
svn:
Files 2599 (24308485 bytes)
lib:
Files 1007 (20610273 bytes)
Size of all modules:
svn:
635991
lib:
549199
Size of core.img using modules: pc biosdisk reiserfs raid raid6rec mdraid lvm svn:
33035
lib:
29822
Signature · 1 line
Bean
Hi,
Update:
Fix for i386-efi and x86_64-efi platform, now grub-mkimage works just like i386-pc, it linked the modules to form the runtime image instead of embedding them.
Signature · 1 line
Bean
Hi,
Update:
Support mach-o object file, now you can compile grub2 in OSX using gcc 4.0 from Xcode. No other tool is needed except gcc and as.
Tested ok with i386-pc and i386-efi.
BTW, here are a list of issues of apple gcc 4.0:
Local jumps with more that one digit (such as 10f, 10b) doesn't work, this affect the lzma decoder. I change it with symbol label like lzma_10.
Relocation in code16 segment is trouble, apple cc generate wrong information sometimes. So use local symbol (L_xx) in 16-bit code.
Line
asm volatile ("jmp *%2" : : "b" (0), "S" (real_mode_mem), "g" (params->code32_start));
in loader/i386/linux.c generate an error message, i comment it out so that compilation can continue, so the linux loader would be broken for the time being.
Signature · 1 line
Bean
Hi,
Update:
Support 64-bit mach-o object files, now you can build i386-pc, i386-efi and x86_64-efi in OSX.
Use PIC in x86_64-efi. Relocation R_X86_64_32S would cause problem in machine with 2G or more memory, the only way to get rid of it is to use large memory model, or use PIC. Large model is only available in gcc-4.3 or later, and the generated image is quite large as all address is 8 bytes long. PIC is always enabled in mingw-w64 and apple's gcc, it just need a little work to support PIC in elf platform. Now all system uses PIC instead of large memory model.
As with this version, it's possible to build i386-pc, i386-efi and x86_64-efi in Linux/OSX/Windows, using the native build tool, no cross compiler. Only gcc and as is needed to generated object file *.o from source code, linker (ld) and converter (objcopy, objconv, grub-pe2elf, grub-macho2img) are not needed as the conversion is handled by grub-mkrawimage and grub-mkmod.
Signature · 1 line
Bean
Hi,
Update:
Add support for i386-ieee1275, i386-qemu and i386-coreboot, now the x86 platform is complete, you can build either one of it in Linux/OSX/Windows:
Note: grub-mkfont doesn't compile in OSX, so you should add --disable-grub-mkfont, grub-emu could also cause problem in OSX/Windows, you can use --disable-grub-emu to disable it.
Here are some information on how to compile them:
i386-pc: (Linux/OSX/Windows)
./configure --with-platform=pc
make
.
i386-efi: (Linux/OSX/Windows)
./configure --with-platform=efi
make
i386-ieee1275 (Linux/OSX/Windows)
./configure --with-platform=ieee1275
make
i386-qemu (Linux/OSX/Windows)
./configure --with-platform=qemu
make
i386-coreboot (Linux/OSX/Windows)
./configure --with-platform=coreboot
make
x86_64-efi
Linux: (needs gcc-multilib on 32-bit system)
./configure --with-platform=efi --target=x86_64
make
OSX:
./configure --with-platform=efi --target=x86_64
make
Windows: (needs mingw-w64)
./configure --with-platform=efi --target=x86_64-w64-mingw32 make
Signature · 1 line
Bean