* [patch] Dynamic Loader Bugs
@ 2004-10-09 16:42 Timothy Baldwin
2004-10-14 11:34 ` Marco Gerards
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Timothy Baldwin @ 2004-10-09 16:42 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1.1: Type: text/plain, Size: 957 bytes --]
1. Gcc 3.4 will delete the module initialization and finalisation functions as
they appear to be unused.
2. grub_dl_load_file contains a null pointer dereference.
3. The modules contain common symbols, which the dynamic loader can't handle.
4. The dynamic loader uses the size of common symbols as their address,
instead of returning an error.
Attached is a patch which fixes points 1 to 3.
2004-10-09 Timothy Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
* include/grub/dl.h (GRUB_MOD_INIT): Changed __attribute__ ((unused))
to __attribute__ ((used)).
(GRUB_MOD_FINI): Likewise.
* kern/dl.c (grub_dl_load_file): Fix null pointer dereference.
* genmk.rb (PModule): Assign space to common symbols when
linking modules.
--
Member AFFS, WYLUG, SWP (UK), ANL, RESPECT, Leeds SA, Leeds Anti-war coalition
No to software patents! No to DRM/EUCD - hands off our computers!
[-- Attachment #1.2: dl.diff --]
[-- Type: text/x-diff, Size: 1847 bytes --]
Index: genmk.rb
===================================================================
RCS file: /cvsroot/grub/grub2/genmk.rb,v
retrieving revision 1.8
diff -u -r1.8 genmk.rb
--- genmk.rb 4 Apr 2004 13:45:59 -0000 1.8
+++ genmk.rb 9 Oct 2004 15:31:20 -0000
@@ -117,12 +117,12 @@
#{@name}: #{pre_obj} #{mod_obj}
-rm -f $@
- $(LD) -r -o $@ $^
+ $(LD) -r -d -o $@ $^
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
#{pre_obj}: #{objs_str}
-rm -f $@
- $(LD) -r -o $@ $^
+ $(LD) -r -d -o $@ $^
#{mod_obj}: #{mod_src}
$(CC) $(CPPFLAGS) $(CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $<
Index: include/grub/dl.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/dl.h,v
retrieving revision 1.6
diff -u -r1.6 dl.h
--- include/grub/dl.h 4 Apr 2004 13:46:00 -0000 1.6
+++ include/grub/dl.h 9 Oct 2004 15:31:21 -0000
@@ -26,13 +26,13 @@
#include <grub/types.h>
#define GRUB_MOD_INIT \
-static void grub_mod_init (grub_dl_t mod) __attribute__ ((unused)); \
+static void grub_mod_init (grub_dl_t mod) __attribute__ ((used)); \
static void \
grub_mod_init (grub_dl_t mod)
#define GRUB_MOD_FINI \
-static void grub_mod_fini (void) __attribute__ ((unused)); \
+static void grub_mod_fini (void) __attribute__ ((used)); \
static void \
grub_mod_fini (void)
#define GRUB_MOD_NAME(name) \
Index: kern/dl.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/dl.c,v
retrieving revision 1.7
diff -u -r1.7 dl.c
--- kern/dl.c 4 Apr 2004 13:46:01 -0000 1.7
+++ kern/dl.c 9 Oct 2004 15:31:21 -0000
@@ -548,6 +548,8 @@
goto failed;
mod = grub_dl_load_core (core, size);
+ if (! mod) goto failed;
+
mod->ref_count = 0;
failed:
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [patch] Dynamic Loader Bugs
2004-10-09 16:42 [patch] Dynamic Loader Bugs Timothy Baldwin
@ 2004-10-14 11:34 ` Marco Gerards
2004-10-17 23:11 ` Timothy Baldwin
2004-10-15 0:07 ` Tomas Ebenlendr
2005-01-20 17:33 ` Marco Gerards
2 siblings, 1 reply; 11+ messages in thread
From: Marco Gerards @ 2004-10-14 11:34 UTC (permalink / raw)
To: The development of GRUB 2
Timothy Baldwin <tim.lists@majoroak.f2s.com> writes:
> 1. Gcc 3.4 will delete the module initialization and finalisation functions as
> they appear to be unused.
Why do you use the used attribute here? Isn't that what is default?
> 2. grub_dl_load_file contains a null pointer dereference.
Right. I have seen this bug too.
> 3. The modules contain common symbols, which the dynamic loader can't handle.
What does this mean? Can you give an example about this.
> 4. The dynamic loader uses the size of common symbols as their address,
> instead of returning an error.
>
> Attached is a patch which fixes points 1 to 3.
This patch fixes 2 as well, right?
Can you fix bug #4 as well?
I hope someone else with more knowledge about modules can reply as
well. The patch seems ok to me at first sight, but I am not too sure.
Can you please use "diff -up" next time when making a patch? That
makes it easier to read.
Thanks,
Marco
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Dynamic Loader Bugs
2004-10-14 11:34 ` Marco Gerards
@ 2004-10-17 23:11 ` Timothy Baldwin
0 siblings, 0 replies; 11+ messages in thread
From: Timothy Baldwin @ 2004-10-17 23:11 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 987 bytes --]
I've just come back from the European Social Forum - been staying at the
Millennium Dome.
On Thursday 14 Oct 2004 12:34, Marco Gerards wrote:
> Timothy Baldwin <tim.lists@majoroak.f2s.com> writes:
> > 1. Gcc 3.4 will delete the module initialization and finalisation
> > functions as they appear to be unused.
>
> Why do you use the used attribute here? Isn't that what is default?
The used attribute is neither the default or the opposite of the unused
attribute, it tells gcc that a static function is used despite not being
referred to in the same source file (after preprocessing). I refer you to the
gcc documentation.
> Can you fix bug #4 as well?
Can do, now that I have read some ELF docs.
> Can you please use "diff -up" next time when making a patch? That
> makes it easier to read.
Will do.
--
Member AFFS, WYLUG, SWP (UK), ANL, RESPECT, Leeds SA, Leeds Anti-war coalition
No to software patents! Victory to the Iraqi resistance!
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Dynamic Loader Bugs
2004-10-09 16:42 [patch] Dynamic Loader Bugs Timothy Baldwin
2004-10-14 11:34 ` Marco Gerards
@ 2004-10-15 0:07 ` Tomas Ebenlendr
2004-10-15 10:51 ` Marco Gerards
2004-10-17 23:11 ` Timothy Baldwin
2005-01-20 17:33 ` Marco Gerards
2 siblings, 2 replies; 11+ messages in thread
From: Tomas Ebenlendr @ 2004-10-15 0:07 UTC (permalink / raw)
To: The development of GRUB 2
This patch is nice, after aplying this patch, and fixing the
mregparm=3 stuff, grub-emu can be changed to load the modules dynamically,
instead of statically linking.
I have just few questions, because I want to know how it works.
> 1. Gcc 3.4 will delete the module initialization and finalisation functions as
> they appear to be unused.
>
It is deleted before objcopy -K ... aplies ? Or -K is just ignored?
> 2. grub_dl_load_file contains a null pointer dereference.
>
> 3. The modules contain common symbols, which the dynamic loader can't handle.
>
Yes I saw one variable somwhere in normal.mod that was not
preinitialized, and so gcc assumes, that dynamic loader will aloccate
appropriate space.(And it doesn't.) Is this what you mean?
> 4. The dynamic loader uses the size of common symbols as their address,
> instead of returning an error.
>
If I understand it well, it thinks that the symbol lives at address 0x4.
( I'm sorry that I'm not more specific, but I lost all my data about two
weeks ago, and I didn't installed all my stuff yet. )
> Attached is a patch which fixes points 1 to 3.
>
> 2004-10-09 Timothy Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
>
> * include/grub/dl.h (GRUB_MOD_INIT): Changed __attribute__ ((unused))
> to __attribute__ ((used)).
This fixes 1.
> (GRUB_MOD_FINI): Likewise.
> * kern/dl.c (grub_dl_load_file): Fix null pointer dereference.
This fixes 2.
> * genmk.rb (PModule): Assign space to common symbols when
> linking modules.
This fixes the 3. am I rigt? And so 4. need not to be fixed.
--
Tomas 'ebi' Ebenlendr
http://get.to/ebik
PF 2004.78708475638
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [patch] Dynamic Loader Bugs
2004-10-15 0:07 ` Tomas Ebenlendr
@ 2004-10-15 10:51 ` Marco Gerards
2004-10-15 12:13 ` Yoshinori K. Okuji
2004-10-17 23:11 ` Timothy Baldwin
1 sibling, 1 reply; 11+ messages in thread
From: Marco Gerards @ 2004-10-15 10:51 UTC (permalink / raw)
To: The development of GRUB 2
Tomas Ebenlendr <ebik@artax.karlin.mff.cuni.cz> writes:
> This patch is nice, after aplying this patch, and fixing the
> mregparm=3 stuff, grub-emu can be changed to load the modules dynamically,
> instead of statically linking.
Right. And when all of that is in CVS I can get working on the
relocator for the PPC. These bugs and a missing module support
in grub-emu made my work almost impossible to do.
I really hope these two patches can be applied ASAP. AFAIK assignment
papers are not required for bug fixes like these. Okuji, am I right
about this and can I apply this patch?
Thanks,
Marco
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Dynamic Loader Bugs
2004-10-15 10:51 ` Marco Gerards
@ 2004-10-15 12:13 ` Yoshinori K. Okuji
2004-10-15 13:19 ` Marco Gerards
2004-11-13 12:32 ` Marco Gerards
0 siblings, 2 replies; 11+ messages in thread
From: Yoshinori K. Okuji @ 2004-10-15 12:13 UTC (permalink / raw)
To: The development of GRUB 2
On Friday 15 October 2004 12:51, Marco Gerards wrote:
> I really hope these two patches can be applied ASAP. AFAIK
> assignment papers are not required for bug fixes like these. Okuji,
> am I right about this and can I apply this patch?
They are required even for bug fixes. Copyright is independent of the
purpose of text.
You may apply one of the bug fixes if you are in a hurry, but don't
apply all of them. This is related to the number of changed lines.
Another way is to fix the same problems yourself without using his
patch.
Okuji
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Dynamic Loader Bugs
2004-10-15 12:13 ` Yoshinori K. Okuji
@ 2004-10-15 13:19 ` Marco Gerards
2004-11-13 12:32 ` Marco Gerards
1 sibling, 0 replies; 11+ messages in thread
From: Marco Gerards @ 2004-10-15 13:19 UTC (permalink / raw)
To: The development of GRUB 2
"Yoshinori K. Okuji" <okuji@enbug.org> writes:
> On Friday 15 October 2004 12:51, Marco Gerards wrote:
>> I really hope these two patches can be applied ASAP. AFAIK
>> assignment papers are not required for bug fixes like these. Okuji,
>> am I right about this and can I apply this patch?
>
> They are required even for bug fixes. Copyright is independent of the
> purpose of text.
>
> You may apply one of the bug fixes if you are in a hurry, but don't
> apply all of them. This is related to the number of changed lines.
>
> Another way is to fix the same problems yourself without using his
> patch.
Ok. I'm not in a hurry, I've to wait for Tomas' patch anyway. I
assume Timothy have the assignment papers already?
Thanks,
Marco
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Dynamic Loader Bugs
2004-10-15 12:13 ` Yoshinori K. Okuji
2004-10-15 13:19 ` Marco Gerards
@ 2004-11-13 12:32 ` Marco Gerards
2004-11-13 13:15 ` Yoshinori K. Okuji
1 sibling, 1 reply; 11+ messages in thread
From: Marco Gerards @ 2004-11-13 12:32 UTC (permalink / raw)
To: The development of GRUB 2
"Yoshinori K. Okuji" <okuji@enbug.org> writes:
> On Friday 15 October 2004 12:51, Marco Gerards wrote:
>> I really hope these two patches can be applied ASAP. AFAIK
>> assignment papers are not required for bug fixes like these. Okuji,
>> am I right about this and can I apply this patch?
>
> They are required even for bug fixes. Copyright is independent of the
> purpose of text.
Can I apply the full patch now? This patch and Tomas' are required to
get modules loading working on the PPC. And this is a high priority
for me at the moment.
Thanks,
Marco
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Dynamic Loader Bugs
2004-10-15 0:07 ` Tomas Ebenlendr
2004-10-15 10:51 ` Marco Gerards
@ 2004-10-17 23:11 ` Timothy Baldwin
1 sibling, 0 replies; 11+ messages in thread
From: Timothy Baldwin @ 2004-10-17 23:11 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]
On Friday 15 Oct 2004 01:07, Tomas Ebenlendr wrote:
> This patch is nice, after aplying this patch, and fixing the
> mregparm=3 stuff, grub-emu can be changed to load the modules dynamically,
> instead of statically linking.
>
> I have just few questions, because I want to know how it works.
>
> > 1. Gcc 3.4 will delete the module initialization and finalisation
> > functions as they appear to be unused.
>
> It is deleted before objcopy -K ... aplies ? Or -K is just ignored?
Yes, it is not included in the assembler output of gcc 3.4.
> > 3. The modules contain common symbols, which the dynamic loader can't
> > handle.
>
> Yes I saw one variable somwhere in normal.mod that was not
> preinitialized, and so gcc assumes, that dynamic loader will aloccate
> appropriate space.(And it doesn't.) Is this what you mean?
Yes
>
> > 4. The dynamic loader uses the size of common symbols as their address,
> > instead of returning an error.
Sorry, it uses the alignment of the sysmbol.
>
> If I understand it well, it thinks that the symbol lives at address 0x4.
Or whatever the alignment is.
--
Member AFFS, WYLUG, SWP (UK), ANL, RESPECT, Leeds SA, Leeds Anti-war coalition
No to software patents! Victory to the iraqi resistance!
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Dynamic Loader Bugs
2004-10-09 16:42 [patch] Dynamic Loader Bugs Timothy Baldwin
2004-10-14 11:34 ` Marco Gerards
2004-10-15 0:07 ` Tomas Ebenlendr
@ 2005-01-20 17:33 ` Marco Gerards
2 siblings, 0 replies; 11+ messages in thread
From: Marco Gerards @ 2005-01-20 17:33 UTC (permalink / raw)
To: The development of GRUB 2
Timothy Baldwin <tim.lists@majoroak.f2s.com> writes:
> 2004-10-09 Timothy Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
>
> * include/grub/dl.h (GRUB_MOD_INIT): Changed __attribute__ ((unused))
> to __attribute__ ((used)).
> (GRUB_MOD_FINI): Likewise.
> * kern/dl.c (grub_dl_load_file): Fix null pointer dereference.
> * genmk.rb (PModule): Assign space to common symbols when
> linking modules.
Sorry, I almost forgot about this patch. I've applied it now.
Thanks,
Marco
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-01-20 18:05 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-09 16:42 [patch] Dynamic Loader Bugs Timothy Baldwin
2004-10-14 11:34 ` Marco Gerards
2004-10-17 23:11 ` Timothy Baldwin
2004-10-15 0:07 ` Tomas Ebenlendr
2004-10-15 10:51 ` Marco Gerards
2004-10-15 12:13 ` Yoshinori K. Okuji
2004-10-15 13:19 ` Marco Gerards
2004-11-13 12:32 ` Marco Gerards
2004-11-13 13:15 ` Yoshinori K. Okuji
2004-10-17 23:11 ` Timothy Baldwin
2005-01-20 17:33 ` Marco Gerards
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.