Skip to contentSkip to conversation

FRV: Fix the extern declaration of kallsyms_num_syms [try #2]

PATCH In review David Howells 2 participants 4 messages Nov 13, 2007 – Nov 15, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 FRV: Fix the extern declaration of kallsyms_num_syms [try #2]

From: David Howells <[email protected]>

Fix the extern declaration of kallsyms_num_syms to indicate that the symbol does not reside in the small-data storage space, and so may not be accessed relative to the small data base register.

---

 kernel/kallsyms.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
kernel/kallsyms.c +6 -1
index 474219a..2fc2581 100644
@@ -32,9 +32,14 @@
 
 /* These will be re-linked against their real values during the second link stage */
 extern const unsigned long kallsyms_addresses[] __attribute__((weak));
-extern const unsigned long kallsyms_num_syms __attribute__((weak));
 extern const u8 kallsyms_names[] __attribute__((weak));
 
+/* tell the compiler that the count isn't in the small data section if the arch
+ * has one (eg: FRV)
+ */
+extern const unsigned long kallsyms_num_syms
+__attribute__((weak, section(".rodata")));
+
 extern const u8 kallsyms_token_table[] __attribute__((weak));
 extern const u16 kallsyms_token_index[] __attribute__((weak));
 
#1 lore raw
Quoted 22 lines · On Tue, 13 Nov 2007 16:53:16 +0000 David Howells <[email protected]> wrote:

From: David Howells <[email protected]>

Fix the extern declaration of kallsyms_num_syms to indicate that the symbol does not reside in the small-data storage space, and so may not be accessed relative to the small data base register.

---

 kernel/kallsyms.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
kernel/kallsyms.c +0 -1
index 474219a..2fc2581 100644
@@ -32,9 +32,14 @@
 
 /* These will be re-linked against their real values during the second link stage */
 extern const unsigned long kallsyms_addresses[] __attribute__((weak));
-extern const unsigned long kallsyms_num_syms __attribute__((weak));
 extern const u8 kallsyms_names[] __attribute__((weak));

kernel/kallsyms.c line 45

Quoted 10 lines
kernel/kallsyms.c +6 -0
 
+/* tell the compiler that the count isn't in the small data section if the arch
+ * has one (eg: FRV)
+ */
+extern const unsigned long kallsyms_num_syms
+__attribute__((weak, section(".rodata")));
+
 extern const u8 kallsyms_token_table[] __attribute__((weak));
 extern const u16 kallsyms_token_index[] __attribute__((weak));
 

hm, OK, so it lines up with what scripts/kallsyms.c presently does.

But it all strikes me as a bit fragile and grotty. Perhaps longer-term it would be better if scripts/kallsyms.c were to also emit a header file which declares all the things which that program emits the definitions of, no?

I guess that means that we'd need to run the program twice - once at the start of compilation in generate-the-header-file mode and once at the end of compilation in generate-the-symbols mode.

Or something like that.

#2 lore raw
Quoted 7 lines · On Thu, 15 Nov 2007 14:40:07 -0800 Andrew Morton <[email protected]>…

But it all strikes me as a bit fragile and grotty. Perhaps longer-term it would be better if scripts/kallsyms.c were to also emit a header file which declares all the things which that program emits the definitions of, no?

I guess that means that we'd need to run the program twice - once at the start of compilation in generate-the-header-file mode and once at the end of compilation in generate-the-symbols mode.

Although given that this header file will be the same each time that program is run, we might as well just type the thing in. And remember to keep it in sync with changes to scritps/kallsyms output?

#3 lore raw
In reply to Andrew Morton
Quoted 1 line · Andrew Morton

hm, OK, so it lines up with what scripts/kallsyms.c presently does.

I'm sure there's a way to pass the kallsyms_num_syms value directly by way of the linker rather than consigning it to a bit of memory.

The immediately obvious way is to declare it to be at an address that it the symbol count value, and then C can do "&kallsyms_num_syms" to get at it. Horrible, I know, but I'm not sure it's worse than some of the other stuff we do.

David