]> git.wh0rd.org Git - elf2flt.git/commitdiff
GCC properly provides CTOR/DTOR END/LIST symbols already via the normal
authorDavid McCullough <davidm@snapgear.com>
Thu, 7 May 2009 06:14:27 +0000 (06:14 +0000)
committerDavid McCullough <davidm@snapgear.com>
Thu, 7 May 2009 06:14:27 +0000 (06:14 +0000)
crtbegin and crtend objects.  Since it's been doing this for a while, add
a configure option to control the manual list found in the elf2flt linker
script and default it to off now.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Makefile.in
configure.in
elf2flt.ld.in
ld-elf2flt.in

index 5f9e17d9567c778ea9e073cce9ece3ee9162d598..1b192c46018d1097f2e1ecb07368924e4c9b682b 100644 (file)
@@ -48,7 +48,7 @@ PROG_ELF2FLT = elf2flt$(EXEEXT)
 PROG_FLTHDR = flthdr$(EXEEXT)
 PROGS = $(PROG_ELF2FLT) $(PROG_FLTHDR)
 
-all: $(PROGS)
+all: $(PROGS) ld-elf2flt
 
 $(PROG_ELF2FLT): $(srcdir)/elf2flt.c compress.o $(srcdir)/stubs.c
        $(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
@@ -56,6 +56,9 @@ $(PROG_ELF2FLT): $(srcdir)/elf2flt.c compress.o $(srcdir)/stubs.c
 $(PROG_FLTHDR): $(srcdir)/flthdr.c compress.o
        $(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
 
+ld-elf2flt: $(srcdir)/ld-elf2flt.in
+       ./config.status $@
+
 Makefile: $(srcdir)/Makefile.in
        ./config.status $@
 
index c3b71ed5045b0dd399499899bba01329d1ecfc92..e18e41cab24805ce463e0ee2ea1638238d8cc427 100644 (file)
@@ -55,6 +55,12 @@ AC_ARG_ENABLE(emit_relocs,
        [ emit_relocs=yes ]
 )
 
+AC_ARG_ENABLE(emit_ctor_dtor,
+       AS_HELP_STRING([--enable-emit-ctor-dtor], [manually create ctor/dtor list]),
+       [ emit_ctor_dtor=$enableval ],
+       [ emit_ctor_dtor=no ]
+)
+
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 
@@ -173,6 +179,7 @@ AC_SUBST(zlib_include_dir)
 AC_SUBST(binutils_ldscript_dir)
 AC_SUBST(got_check)
 AC_SUBST(emit_relocs)
+AC_SUBST(emit_ctor_dtor)
 AC_SUBST(SYMBOL_PREFIX)
 
 AC_OUTPUT(Makefile ld-elf2flt elf2flt.ld)
index f76eadf803f1b54de2500f5fe42a8aee29c17092..8a4b36b107a168fd229447bb0dda96f1c6c1c0a3 100644 (file)
@@ -87,8 +87,8 @@ R_RODAT               *(.gnu.linkonce.r*)
                PROVIDE(@SYMBOL_PREFIX@_SDA2_BASE_ = @SYMBOL_PREFIX@_ssro + (@SYMBOL_PREFIX@_ssro_size / 2));
 
                . = ALIGN(4) ;
-               @SYMBOL_PREFIX@__CTOR_LIST__ = .;
-               LONG((@SYMBOL_PREFIX@__CTOR_END__ - @SYMBOL_PREFIX@__CTOR_LIST__) / 4 - 2)
+TOR:           @SYMBOL_PREFIX@__CTOR_LIST__ = .;
+TOR:           LONG((@SYMBOL_PREFIX@__CTOR_END__ - @SYMBOL_PREFIX@__CTOR_LIST__) / 4 - 2)
 SINGLE_LINK:   /* gcc uses crtbegin.o to find the start of
 SINGLE_LINK:      the constructors, so we make sure it is
 SINGLE_LINK:      first.  Because this is a wildcard, it
@@ -106,16 +106,16 @@ SINGLE_LINK:         end of ctors marker and it must be last */
 SINGLE_LINK:   KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
 SINGLE_LINK:   KEEP (*(SORT(.ctors.*)))
                KEEP (*(.ctors))
-               LONG(0)
-               @SYMBOL_PREFIX@__CTOR_END__ = .;
-               @SYMBOL_PREFIX@__DTOR_LIST__ = .;
-               LONG((@SYMBOL_PREFIX@__DTOR_END__ - @SYMBOL_PREFIX@__DTOR_LIST__) / 4 - 2)
+TOR:           LONG(0)
+TOR:           @SYMBOL_PREFIX@__CTOR_END__ = .;
+TOR:           @SYMBOL_PREFIX@__DTOR_LIST__ = .;
+TOR:           LONG((@SYMBOL_PREFIX@__DTOR_END__ - @SYMBOL_PREFIX@__DTOR_LIST__) / 4 - 2)
 SINGLE_LINK:   KEEP (*crtbegin*.o(.dtors))
 SINGLE_LINK:   KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
 SINGLE_LINK:   KEEP (*(SORT(.dtors.*)))
                KEEP (*(.dtors))
-               LONG(0)
-               @SYMBOL_PREFIX@__DTOR_END__ = .;
+TOR:           LONG(0)
+TOR:           @SYMBOL_PREFIX@__DTOR_END__ = .;
 
                PROVIDE (@SYMBOL_PREFIX@__preinit_array_start = .);
                KEEP (*(.preinit_array))
index f3ad80b63f9ca843991e254b50892d969259a9c3..32eb7e0cab7fbb62655827f7edb5ec757cc49fb1 100644 (file)
@@ -152,6 +152,12 @@ then
                else
                        SEDOP="$SEDOP -e /^SINGLE_LINK:/d"
                fi
+               if [ "@emit_ctor_dtor@" = "yes" ]
+               then
+                       SEDOP="$SEDOP -e s/^TOR://"
+               else
+                       SEDOP="$SEDOP -e /^TOR:/d"
+               fi
                
                # provide a default linker script, we usually need one
                [ -z "$LDSCRIPT" ] && LDSCRIPT="${LDSCRIPTPATH}/elf2flt.ld"