+2018-06-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #23145]
+ * elf/Makefile (tests-special): Add $(objpfx)check-initfini.out.
+ ($(all-built-dso:=.dynsym): New target.
+ (common-generated): Add $(all-built-dso:$(common-objpfx)%=%.dynsym).
+ ($(objpfx)check-initfini.out): New target.
+ (generated): Add check-initfini.out.
+ * scripts/check-initfini.awk: New file.
+ * sysdeps/aarch64/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/alpha/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/arm/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/hppa/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/i386/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/ia64/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/m68k/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/microblaze/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/mips/mips32/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/mips/mips64/n32/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/mips/mips64/n64/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/nios2/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/powerpc/powerpc32/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/powerpc/powerpc64/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/s390/s390-32/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/s390/s390-64/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/sh/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/sparc/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+ * sysdeps/x86_64/crti.S (_init): Mark as hidden.
+ (_fini): Likewise.
+
2018-06-06 Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
* sysdeps/powerpc/powerpc64/le/fpu/e_sqrtf128.c
tests-special += $(objpfx)tst-pathopt.out $(objpfx)tst-rtld-load-self.out
endif
tests-special += $(objpfx)check-textrel.out $(objpfx)check-execstack.out \
- $(objpfx)check-localplt.out
+ $(objpfx)check-localplt.out $(objpfx)check-initfini.out
endif
ifeq ($(run-built-tests),yes)
$(evaluate-test)
endif
+$(all-built-dso:=.dynsym): %.dynsym: %
+ @rm -f $@T
+ LC_ALL=C $(READELF) -W --dyn-syms $< > $@T
+ test -s $@T
+ mv -f $@T $@
+common-generated += $(all-built-dso:$(common-objpfx)%=%.dynsym)
+
+$(objpfx)check-initfini.out: $(..)scripts/check-initfini.awk \
+ $(all-built-dso:=.dynsym)
+ LC_ALL=C $(AWK) -f $^ > $@; \
+ $(evaluate-test)
+generated += check-initfini.out
+
$(objpfx)tst-dlopenrpathmod.so: $(libdl)
$(objpfx)tst-dlopenrpath: $(objpfx)tst-dlopenrpathmod.so $(libdl)
CFLAGS-tst-dlopenrpath.c += -DPFX=\"$(objpfx)\"
--- /dev/null
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+# This awk script expects to get command-line files that are each
+# the output of 'readelf -W --dyn-syms' on a single shared object.
+# It exits successfully (0) if none contained _init nor _fini in dynamic
+# symbol table.
+# It fails (1) if any did contain _init or _fini in dynamic symbol table.
+# It fails (2) if the input did not take the expected form.
+
+BEGIN { result = _init = _fini = sanity = 0 }
+
+function check_one(name) {
+ if (!sanity) {
+ print name ": *** input did not look like readelf -d output";
+ result = 2;
+ } else {
+ ok = 1;
+ if (_init) {
+ print name ": *** _init is in dynamic symbol table";
+ result = result ? result : 1;
+ ok = 0;
+ }
+ if (_fini) {
+ print name ": *** _fini is in dynamic symbol table";
+ result = result ? result : 1;
+ ok = 0;
+ }
+ if (ok)
+ print name ": OK";
+ }
+
+ _init = _fini = sanity = 0
+}
+
+FILENAME != lastfile {
+ if (lastfile)
+ check_one(lastfile);
+ lastfile = FILENAME;
+}
+
+$1 == "Symbol" && $2 == "table" && $3 == "'.dynsym'" { sanity = 1 }
+$8 == "_init" { _init = 1 }
+$8 == "_fini" { _fini = 1 }
+
+END {
+ check_one(lastfile);
+ exit(result);
+}
.section .init,"ax",%progbits
.align 2
.global _init
+ .hidden _init
.type _init, %function
_init:
stp x29, x30, [sp, -16]!
.section .fini,"ax",%progbits
.align 2
.global _fini
+ .hidden _fini
.type _fini, %function
_fini:
stp x29, x30, [sp, -16]!
.section .init, "ax", @progbits
.globl _init
+ .hidden _init
.type _init, @function
.usepv _init, std
_init:
.section .fini, "ax", @progbits
.globl _fini
+ .hidden _fini
.type _fini,@function
.usepv _fini,std
_fini:
.section .init,"ax",%progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, %function
_init:
push {r3, lr}
.section .fini,"ax",%progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, %function
_fini:
push {r3, lr}
.section .init, "ax", %progbits
.align 4
.globl _init
+ .hidden _init
.type _init,@function
_init:
stw %rp,-20(%sp)
.section .fini,"ax",%progbits
.align 4
.globl _fini
+ .hidden _fini
.type _fini,@function
_fini:
stw %rp,-20(%sp)
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
pushl %ebx
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
pushl %ebx
.section .init,"ax",@progbits
.global _init#
+ .hidden _init#
.proc _init#
_init:
.prologue
.section .fini,"ax",@progbits
.global _fini#
+ .hidden _fini#
.proc _fini#
_fini:
.prologue
.section .init,"ax",@progbits
.align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
link.w %fp, #0
.section .fini,"ax",@progbits
.align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
link.w %fp, #0
.section .init,"ax",@progbits
.align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
addik r1,r1,-32
.section .fini,"ax",@progbits
.align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
addik r1,r1,-32
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
.set noreorder
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
.set noreorder
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
addiu $sp,$sp,-16
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
addiu $sp,$sp,-16
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
daddiu $sp,$sp,-16
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
daddiu $sp,$sp,-16
.section .init,"ax",@progbits
.align 2
.global _init
+ .hidden _init
.type _init, @function
_init:
addi sp, sp, -8
.section .fini,"ax",@progbits
.align 2
.global _fini
+ .hidden _fini
.type _fini, @function
_fini:
addi sp, sp, -8
.section .init,"ax",@progbits
.align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
stwu r1, -16(r1)
.section .fini,"ax",@progbits
.align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
stwu r1, -16(r1)
#endif
.section ".init", "ax", @progbits
ENTRY_2(_init)
+ .hidden _init
.align ALIGNARG (2)
BODY_LABEL (_init):
LOCALENTRY(_init)
.section ".fini", "ax", @progbits
ENTRY_2(_fini)
+ .hidden _fini
.align ALIGNARG (2)
BODY_LABEL (_fini):
LOCALENTRY(_fini)
.section .init,"ax",@progbits
.globl _init
+ .hidden _init
.type _init,@function
.align 4
_init:
.section .fini,"ax",@progbits
.globl _fini
+ .hidden _fini
.type _fini,@function
.align 4
_fini:
.section .init,"ax",@progbits
.align 4
.globl _init
+ .hidden _init
.type _init,@function
_init:
stmg %r6,%r15,48(%r15)
.section .fini,"ax",@progbits
.align 4
.globl _fini
+ .hidden _fini
.type _fini,@function
_fini:
stmg %r6,%r15,48(%r15)
.section .init,"ax",@progbits
.align 5
.global _init
+ .hidden _init
.type _init, @function
_init:
mov.l r12,@-r15
.section .fini,"ax",@progbits
.align 5
.global _fini
+ .hidden _fini
.type _fini, @function
_fini:
mov.l r12,@-r15
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
save %sp, -STACKFRAME_SIZE, %sp
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
save %sp, -STACKFRAME_SIZE, %sp
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
/* Maintain 16-byte stack alignment for called functions. */
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
subq $8, %rsp