Skip to contentSkip to conversation

changing a function pointer in a module

DISCUSSION Carles Pina i Estany 2 participants 3 messages Jan 16, 2009 – Feb 7, 2009

lore
Share & tools
lore
#0 lore raw

Hello,

I'm doing some more gettext stuff. Right now I have (relevant code for the problem):

(briefly: the problem is that I'm changing a function pointer inside gettext module code and it's not changed in other parts in Grub, even when it's defined in include/grub/misc.h and only there)

include/grub/misc.h:
char* EXPORT_FUNC(grub_gettext_dummy) (const char *s); char* EXPORT_FUNC((*grub_gettext)) (const char *s);

(I've done tests without EXPORT_FUNC and with EXPORT_VAR for grub_gettext)

In normal/main.c, GRUB_MOD_INIT(normal) I have:
grub_gettext = grub_gettext_dummy;

In normal/cmdline.c, in grub_cmdline_run and after "ESC at any time exits":
grub_printf("grub_gettext: %d\n",grub_gettext);

In gettext/gettext.c, GRUB_MOD_INIT(gettext):
grub_gettext = grub_gettext_translate;
grub_printf("grub_gettext: %d\n",grub_gettext);

First time that I type "C" in Grub menu, I read grub_gettext: XXXX.

Then I insmod my module and it prints grub_printf("grub_gettext:
%d\n",grub_gettext); (different value, of course).

I press ESC (to go to Grub menu) and C (to go to the command line) and I get the first grub_gettext value, not the one that I changed.

How so? I don't declare grub_gettext again, how I can change (and check that it's changed) but not changed back?

I even tried to not assign in normal/main.c (just in case that code part is executed two times) but still it didn't work (again, value has not been changed).

Thanks,

Signature · 2 lines
Carles Pina i Estany		GPG id: 0x17756391
	http://pinux.info
#1 lore raw

Hello,

Quoted 2 lines · Carles Pina i Estany

I'm doing some more gettext stuff. Right now I have (relevant code for the problem):

printing &grub_gettext in normal/cmdline.c and gettext/gettext.c shows that it has a different address, even when I've declared only one time.

I've also tried extern in gettext.c

I will do some more checks (e.g. trying with a simple variable, and checking if it should be in symlist.c (it's not there because gensymlist.sh is not copying symbols with * in the name)

Signature · 2 lines
Carles Pina i Estany		GPG id: 0x17756391
	http://pinux.info
#2 lore raw
In reply to Carles Pina i Estany
Quoted 36 lines · Carles Pina i Estany

Hello,

I'm doing some more gettext stuff. Right now I have (relevant code for the problem):

(briefly: the problem is that I'm changing a function pointer inside gettext module code and it's not changed in other parts in Grub, even when it's defined in include/grub/misc.h and only there)

include/grub/misc.h:
char* EXPORT_FUNC(grub_gettext_dummy) (const char *s); char* EXPORT_FUNC((*grub_gettext)) (const char *s);

(I've done tests without EXPORT_FUNC and with EXPORT_VAR for grub_gettext)

In normal/main.c, GRUB_MOD_INIT(normal) I have:
grub_gettext = grub_gettext_dummy;

In normal/cmdline.c, in grub_cmdline_run and after "ESC at any time exits":
grub_printf("grub_gettext: %d\n",grub_gettext);

In gettext/gettext.c, GRUB_MOD_INIT(gettext):
grub_gettext = grub_gettext_translate;
grub_printf("grub_gettext: %d\n",grub_gettext);

First time that I type "C" in Grub menu, I read grub_gettext: XXXX.

Then I insmod my module and it prints grub_printf("grub_gettext:
%d\n",grub_gettext); (different value, of course).

I press ESC (to go to Grub menu) and C (to go to the command line) and I get the first grub_gettext value, not the one that I changed.

Quoted 6 lines

How so? I don't declare grub_gettext again, how I can change (and check that it's changed) but not changed back?

I even tried to not assign in normal/main.c (just in case that code part is executed two times) but still it didn't work (again, value has not been changed).

IIRC we sorted out these issues in our meeting, please let me know if something is missing.

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."