From: David McCullough Date: Thu, 7 May 2009 06:14:27 +0000 (+0000) Subject: GCC properly provides CTOR/DTOR END/LIST symbols already via the normal X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=4cf2544bde406fc1c7e3be6f92c972de02d6fef4;p=elf2flt.git GCC properly provides CTOR/DTOR END/LIST symbols already via the normal 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 --- diff --git a/Makefile.in b/Makefile.in index 5f9e17d..1b192c4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 $@ diff --git a/configure.in b/configure.in index c3b71ed..e18e41c 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/elf2flt.ld.in b/elf2flt.ld.in index f76eadf..8a4b36b 100644 --- a/elf2flt.ld.in +++ b/elf2flt.ld.in @@ -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)) diff --git a/ld-elf2flt.in b/ld-elf2flt.in index f3ad80b..32eb7e0 100644 --- a/ld-elf2flt.in +++ b/ld-elf2flt.in @@ -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"