diff mbox

[EXPERIMENTAL] enable thin archives and --gc-sections on ARM

Message ID 7664972.4URQm6Y4Ik@wuerfel (mailing list archive)
State New, archived
Headers show

Commit Message

Arnd Bergmann Aug. 11, 2016, 8:37 p.m. UTC
On Thursday, August 11, 2016 4:01:33 PM CEST Nicolas Pitre wrote:
> >  #ifdef CONFIG_SMP_ON_UP
> >       .init.smpalt : {
> >               __smpalt_begin = .;
> > -             *(.alt.smp.init)
> > +             KEEP(*(.alt.smp.init))
> 
> Yes unfortunately this needs a KEEP() right now as there is no explicit 
> references to those entries. But by doing so you force a reference from 
> those entries to all functions they annotate, preventing those functions 
> from being discarded if there isn't any reference to that code 
> otherwise. That's a case that falls into the "missing forward reference" 
> category in my slides.

I see. This actually relates to an existing problem with SMP alternatives
in exit sections, which cause a linker error. I've done a patch for
this at some point, but didn't feel confident enough to send it out

commit 0c598e53b3a0ad7daf077603618001edcf9bface
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Sun Mar 16 20:14:30 2014 +0100

    ARM: don't discard exit sections for spinlock debugging
    
    This avoids lots of warnings like this one:
    
    `.exit.text' referenced in section `.alt.smp.init' of drivers/built-in.o: defined in discarded section `.exit.text' of drivers/built-in.o
    
    for each spinlock that is used in an __exit function, because
    the smp alternatives try to patch out the spinlock locations.
    
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>


--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Nicolas Pitre Aug. 11, 2016, 9:05 p.m. UTC | #1
On Thu, 11 Aug 2016, Arnd Bergmann wrote:

> On Thursday, August 11, 2016 4:01:33 PM CEST Nicolas Pitre wrote:
> > >  #ifdef CONFIG_SMP_ON_UP
> > >       .init.smpalt : {
> > >               __smpalt_begin = .;
> > > -             *(.alt.smp.init)
> > > +             KEEP(*(.alt.smp.init))
> > 
> > Yes unfortunately this needs a KEEP() right now as there is no explicit 
> > references to those entries. But by doing so you force a reference from 
> > those entries to all functions they annotate, preventing those functions 
> > from being discarded if there isn't any reference to that code 
> > otherwise. That's a case that falls into the "missing forward reference" 
> > category in my slides.
> 
> I see. This actually relates to an existing problem with SMP alternatives
> in exit sections, which cause a linker error. I've done a patch for
> this at some point, but didn't feel confident enough to send it out

The only sane way I found to solve this implied a patch to gas, and it 
was accepted upstream. Please see:

http://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=451133cefa

The example given is for .init sections, but that would solve the 
link-time discarding of .exit sections just as well.


Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index d24e5dd2aa7a..1f5eeeb4c8d0 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -43,8 +43,7 @@ 
 #define ARM_CPU_KEEP(x)
 #endif
 
-#if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
-	defined(CONFIG_GENERIC_BUG) || defined(CONFIG_JUMP_LABEL)
+#if defined(CONFIG_SMP_ON_UP) || defined(CONFIG_GENERIC_BUG) || defined(CONFIG_JUMP_LABEL)
 #define ARM_EXIT_KEEP(x)	x
 #define ARM_EXIT_DISCARD(x)
 #else