PATCH: Don't use weak function
Subsystems (4)
Quoted 7 lines · Hongjiu
Hi David,
I think it is the result of the usage of weak function. I am enclosing a testcase to show it. The correct approach is to use comdat section group or linkonce section. The problem will go away. I will see if I can come up with a kernel patch.
This patch works for me. The key here is the arch dependent file has to come before generic one during the final link.
H.J.
---
arch/ia64/kernel/irq.c renamed from arch/ia64/kernel/irq.c.weak +3 -1
@@ -103,7 +103,9 @@ static char irq_redir [NR_IRQS]; // = {* Arch specific routine for deferred write to iosapic rte to reprogram * intr destination. */ -void proc_set_irq_affinity (unsigned int irq,cpumask_t mask_val) +void +__attribute__ ((__section__ (".gnu.linkonce.t.proc_set_irq_affinity" ))) +proc_set_irq_affinity (unsigned int irq,cpumask_t mask_val) { pending_irq_cpumask[irq] = mask_val; }
arch/ia64/kernel/smpboot.c renamed from arch/ia64/kernel/smpboot.c.weak +3 -1
@@ -404,7 +404,9 @@ start_secondary (void *unused)return 0 ; } -struct pt_regs *__devinit idle_regs (struct pt_regs *regs) +struct pt_regs * +__devinit __attribute__ ((__section__ (".gnu.linkonce.t.idle_regs"))) +idle_regs(struct pt_regs *regs) {return NULL ; }
kernel/fork.c renamed from kernel/fork.c.weak +3 -1
@@ -1148,7 +1148,9 @@ bad_fork_free: goto fork_out; } -struct pt_regs * __devinit __attribute__((weak)) idle_regs(struct pt_regs *regs) +struct pt_regs * +__devinit __attribute__ ((__section__ (".gnu.linkonce.t.idle_regs"))) +idle_regs(struct pt_regs *regs) {memset (regs,0 ,sizeof (struct pt_regs ));return regs;
kernel/irq/proc.c renamed from kernel/irq/proc.c.weak +2 -1
@@ -19,7 +19,8 @@ static struct proc_dir_entry *root_irq_d*/ static struct proc_dir_entry *smp_affinity_entry[NR_IRQS ]; -void __attribute__((weak)) +void +__attribute__ ((__section__ (".gnu.linkonce.t.proc_set_irq_affinity" )))proc_set_irq_affinity (unsigned int irq,cpumask_t mask_val) { irq_affinity[irq] = mask_val;
Quoted 11 lines · H. J. Lu
Quoted 7 lines · Hongjiu
Hi David,
I think it is the result of the usage of weak function. I am enclosing a testcase to show it. The correct approach is to use comdat section group or linkonce section. The problem will go away. I will see if I can come up with a kernel patch.
This patch works for me. The key here is the arch dependent file has to come before generic one during the final link.
The duplicate functions should not be compiled in the first place.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."