@@ -348,7 +348,7 @@ ifeq ($(run-built-tests),yes)
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)
@@ -1136,6 +1136,19 @@ $(objpfx)check-localplt.out: $(..)scripts/check-localplt.awk \
$(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)\"
new file mode 100644
@@ -0,0 +1,45 @@
+# This awk script expects to get command-line files that are each
+# the output of 'readelf -d' on a single shared object.
+# It exits successfully (0) if none contained any TEXTREL markers.
+# It fails (1) if any did contain a TEXTREL marker.
+# 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);
+}
@@ -72,6 +72,7 @@ call_weak_fn:
.section .init,"ax",%progbits
.align 2
.global _init
+ .hidden _init
.type _init, %function
_init:
stp x29, x30, [sp, -16]!
@@ -85,6 +86,7 @@ _init:
.section .fini,"ax",%progbits
.align 2
.global _fini
+ .hidden _fini
.type _fini, %function
_fini:
stp x29, x30, [sp, -16]!
@@ -67,6 +67,7 @@
.section .init, "ax", @progbits
.globl _init
+ .hidden _init
.type _init, @function
.usepv _init, std
_init:
@@ -89,6 +90,7 @@ _init:
.section .fini, "ax", @progbits
.globl _fini
+ .hidden _fini
.type _fini,@function
.usepv _fini,std
_fini:
@@ -78,6 +78,7 @@ call_weak_fn:
.section .init,"ax",%progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, %function
_init:
push {r3, lr}
@@ -90,6 +91,7 @@ _init:
.section .fini,"ax",%progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, %function
_fini:
push {r3, lr}
@@ -142,6 +142,7 @@ gmon_initializer:
.section .init, "ax", %progbits
.align 4
.globl _init
+ .hidden _init
.type _init,@function
_init:
stw %rp,-20(%sp)
@@ -152,6 +153,7 @@ _init:
.section .fini,"ax",%progbits
.align 4
.globl _fini
+ .hidden _fini
.type _fini,@function
_fini:
stw %rp,-20(%sp)
@@ -58,6 +58,7 @@
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
pushl %ebx
@@ -77,6 +78,7 @@ _init:
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
pushl %ebx
@@ -129,6 +129,7 @@ gmon_initializer:
.section .init,"ax",@progbits
.global _init#
+ .hidden _init#
.proc _init#
_init:
.prologue
@@ -145,6 +146,7 @@ _init:
.section .fini,"ax",@progbits
.global _fini#
+ .hidden _fini#
.proc _fini#
_fini:
.prologue
@@ -58,6 +58,7 @@
.section .init,"ax",@progbits
.align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
link.w %fp, #0
@@ -75,6 +76,7 @@ _init:
.section .fini,"ax",@progbits
.align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
link.w %fp, #0
@@ -58,6 +58,7 @@
.section .init,"ax",@progbits
.align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
addik r1,r1,-32
@@ -79,6 +80,7 @@ $Lno_weak_fn:
.section .fini,"ax",@progbits
.align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
addik r1,r1,-32
@@ -65,6 +65,7 @@
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
.set noreorder
@@ -90,6 +91,7 @@ _init:
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
.set noreorder
@@ -65,6 +65,7 @@
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
addiu $sp,$sp,-16
@@ -90,6 +91,7 @@ _init:
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
addiu $sp,$sp,-16
@@ -65,6 +65,7 @@
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
daddiu $sp,$sp,-16
@@ -90,6 +91,7 @@ _init:
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
daddiu $sp,$sp,-16
@@ -57,6 +57,7 @@
.section .init,"ax",@progbits
.align 2
.global _init
+ .hidden _init
.type _init, @function
_init:
addi sp, sp, -8
@@ -84,6 +85,7 @@ _init:
.section .fini,"ax",@progbits
.align 2
.global _fini
+ .hidden _fini
.type _fini, @function
_fini:
addi sp, sp, -8
@@ -58,6 +58,7 @@
.section .init,"ax",@progbits
.align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
stwu r1, -16(r1)
@@ -80,6 +81,7 @@ _init:
.section .fini,"ax",@progbits
.align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
stwu r1, -16(r1)
@@ -62,6 +62,7 @@
#endif
.section ".init", "ax", @progbits
ENTRY_2(_init)
+ .hidden _init
.align ALIGNARG (2)
BODY_LABEL (_init):
LOCALENTRY(_init)
@@ -80,6 +81,7 @@ BODY_LABEL (_init):
.section ".fini", "ax", @progbits
ENTRY_2(_fini)
+ .hidden _fini
.align ALIGNARG (2)
BODY_LABEL (_fini):
LOCALENTRY(_fini)
@@ -57,6 +57,7 @@
.section .init,"ax",@progbits
.globl _init
+ .hidden _init
.type _init,@function
.align 4
_init:
@@ -88,6 +89,7 @@ _init:
.section .fini,"ax",@progbits
.globl _fini
+ .hidden _fini
.type _fini,@function
.align 4
_fini:
@@ -59,6 +59,7 @@
.section .init,"ax",@progbits
.align 4
.globl _init
+ .hidden _init
.type _init,@function
_init:
stmg %r6,%r15,48(%r15)
@@ -81,6 +82,7 @@ _init:
.section .fini,"ax",@progbits
.align 4
.globl _fini
+ .hidden _fini
.type _fini,@function
_fini:
stmg %r6,%r15,48(%r15)
@@ -58,6 +58,7 @@
.section .init,"ax",@progbits
.align 5
.global _init
+ .hidden _init
.type _init, @function
_init:
mov.l r12,@-r15
@@ -103,6 +104,7 @@ _init:
.section .fini,"ax",@progbits
.align 5
.global _fini
+ .hidden _fini
.type _fini, @function
_fini:
mov.l r12,@-r15
@@ -66,6 +66,7 @@
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
save %sp, -STACKFRAME_SIZE, %sp
@@ -88,6 +89,7 @@ _init:
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
save %sp, -STACKFRAME_SIZE, %sp
@@ -58,6 +58,7 @@
.section .init,"ax",@progbits
.p2align 2
.globl _init
+ .hidden _init
.type _init, @function
_init:
/* Maintain 16-byte stack alignment for called functions. */
@@ -75,6 +76,7 @@ _init:
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
+ .hidden _fini
.type _fini, @function
_fini:
subq $8, %rsp